tstosc
Version:
A transpiler that convert TypeScript to SuperCollider's SCLang.
82 lines (79 loc) • 4.62 kB
TypeScript
import ts from 'typescript';
import { GeneratorContext } from '../context.js';
import '../../../cli/args.js';
declare const supported_statement_syntax_kind: readonly [ts.SyntaxKind.VariableStatement, ts.SyntaxKind.ExpressionStatement, ts.SyntaxKind.IfStatement, ts.SyntaxKind.DoStatement, ts.SyntaxKind.WhileStatement, ts.SyntaxKind.ForStatement, ts.SyntaxKind.ForInStatement, ts.SyntaxKind.ForOfStatement, ts.SyntaxKind.ContinueStatement, ts.SyntaxKind.BreakStatement, ts.SyntaxKind.ReturnStatement, ts.SyntaxKind.SwitchStatement, ts.SyntaxKind.LabeledStatement, ts.SyntaxKind.ThrowStatement, ts.SyntaxKind.TryStatement, ts.SyntaxKind.EmptyStatement];
/**
* ### Generate Context Relationship
*
* * `block_with_early_return = true`:
* Convert all return statement from `return x` to `return_with.value(x)`
* * `indent_level`:
* By default, each statement handle the indentation.
* Literal, expression, or code block, they **should not** create indentation,
* unless they are returning lines of code using string constant.
* * `statement_label`: Delegate to convert-functions, if there is a label.
* **Should** be cleared after processing.
*/
declare function convertTSStatementToSC(stmt: ts.Statement, generator_context?: GeneratorContext): string;
/**
* If this variable declaration contains after-while-initialiser (e.g., expression with self-indecr operator),
* then convert. With ` ;` appended.
*
* Otherwise, return an empty string.
*/
declare function restyleTSVariableStatementToSC(s: ts.VariableStatement, generator_context?: GeneratorContext, force_conversion?: boolean): string;
/**
* If function has a name, then already hoisted.
*/
declare function converTSFunctionDeclarationToSC(s: ts.FunctionDeclaration, generator_context?: GeneratorContext): string;
declare function convertTSLabeledStatementToSC(s: ts.LabeledStatement, generator_context?: GeneratorContext): string;
/**
*
* ### Generate Context Relationship
*
* * `statement_label`: Handled and wrapped here, if there is a label.
*/
declare function convertTSIfStatementToSC(s: ts.IfStatement, generator_context?: GeneratorContext): string;
declare function convertTSDoStatementToSC(s: ts.DoStatement, generator_context?: GeneratorContext): string;
declare function convertTSWhileStatementToSC(s: ts.WhileStatement, generator_context?: GeneratorContext): string;
declare function convertTSForStatementToSC(s: ts.ForStatement, generator_context?: GeneratorContext): string;
/**
*
* ### Generate Context Relationship
*
* * `statement_label`: Delegate to `convertControlFlowBody`, if there is a label.
*/
declare function convertTSForInStatementToSC(s: ts.ForInStatement, generator_context?: GeneratorContext): string;
/**
*
* ### Generate Context Relationship
*
* * `statement_label`: Delegate to `convertControlFlowBody`, if there is a label.
*/
declare function convertTSForOfStatementToSC(s: ts.ForOfStatement, generator_context?: GeneratorContext): string;
/**
* Continue-statement-including block, will be wrapped by SuperCollider's `block`,
* in order to simulate this syntax.
*/
declare function translateTSContinueStatementToSC(s: ts.ContinueStatement, generator_context?: GeneratorContext): string;
declare function translateTSBreakStatementToSC(s: ts.BreakStatement, generator_context?: GeneratorContext): string;
/**
* May refer to `return_with` defined outside.
*/
declare function translateTSReturnStatementToSC(s: ts.ReturnStatement, generator_context?: GeneratorContext): string;
/**
*
* ### Generate Context Relationship
*
* * `statement_label`: Handled and wrapped here, if there is a label.
*/
declare function convertTSSwitchStatementToSC(s: ts.SwitchStatement, generator_context?: GeneratorContext): string;
declare function convertTSThrowStatementToSC(s: ts.ThrowStatement, generator_context?: GeneratorContext): string;
/**
*
* ### Generate Context Relationship
*
* * `statement_label`: Handled and wrapped here, if there is a label.
*/
declare function convertTSTryStatementToSC(s: ts.TryStatement, generator_context?: GeneratorContext): string;
export { converTSFunctionDeclarationToSC, convertTSDoStatementToSC, convertTSForInStatementToSC, convertTSForOfStatementToSC, convertTSForStatementToSC, convertTSIfStatementToSC, convertTSLabeledStatementToSC, convertTSStatementToSC, convertTSSwitchStatementToSC, convertTSThrowStatementToSC, convertTSTryStatementToSC, convertTSWhileStatementToSC, restyleTSVariableStatementToSC, supported_statement_syntax_kind, translateTSBreakStatementToSC, translateTSContinueStatementToSC, translateTSReturnStatementToSC };