Class: JavaScriptTargetCodeGenerator
The JavaScript target-specific code generator for translating Kipper code into JavaScript.
Since
0.10.0
Hierarchy
unknown
↳
JavaScriptTargetCodeGenerator
Table of contents
Constructors
Methods
- additiveExpression
- arrayPrimaryExpression
- assignmentExpression
- bitwiseAndExpression
- bitwiseOrExpression
- bitwiseShiftExpression
- bitwiseXorExpression
- boolPrimaryExpression
- castOrConvertExpression
- classConstructorDeclaration
- classDeclaration
- classMethodDeclaration
- classPropertyDeclaration
- compoundStatement
- conditionalExpression
- doWhileLoopIterationStatement
- equalityExpression
- expressionStatement
- fStringPrimaryExpression
- forLoopIterationStatement
- functionCallExpression
- functionDeclaration
- genericTypeSpecifierExpression
- identifierPrimaryExpression
- identifierTypeSpecifierExpression
- ifStatement
- incrementOrDecrementPostfixExpression
- incrementOrDecrementUnaryExpression
- instanceOfExpression
- interfaceDeclaration
- interfaceMethodDeclaration
- interfacePropertyDeclaration
- jumpStatement
- lambdaPrimaryExpression
- logicalAndExpression
- logicalOrExpression
- matchesExpression
- memberAccessExpression
- multiplicativeExpression
- newInstantiationExpression
- numberPrimaryExpression
- objectPrimaryExpression
- objectProperty
- operatorModifiedUnaryExpression
- parameterDeclaration
- relationalExpression
- returnStatement
- setUp
- stringPrimaryExpression
- switchStatement
- tangledPrimaryExpression
- translateOperatorExpressionWithOperands
- typeofExpression
- typeofTypeSpecifierExpression
- variableDeclaration
- voidOrNullOrUndefinedPrimaryExpression
- whileLoopIterationStatement
- wrapUp
Constructors
constructor
• new JavaScriptTargetCodeGenerator()
Inherited from
KipperTargetCodeGenerator.constructor
Methods
additiveExpression
▸ additiveExpression(node
): Promise
<TranslatedExpression
>
Translates a AdditiveExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
AdditiveExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:947
arrayPrimaryExpression
▸ arrayPrimaryExpression(node
): Promise
<TranslatedExpression
>
Translates a ArrayPrimaryExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
ArrayPrimaryExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:650
assignmentExpression
▸ assignmentExpression(node
): Promise
<TranslatedExpression
>
Translates a AssignmentExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
AssignmentExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:1054
bitwiseAndExpression
▸ bitwiseAndExpression(node
): Promise
<TranslatedExpression
>
Translates a BitwiseAndExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
BitwiseAndExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:1007
bitwiseOrExpression
▸ bitwiseOrExpression(node
): Promise
<TranslatedExpression
>
Translates a BitwiseOrExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
BitwiseOrExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:1000
bitwiseShiftExpression
▸ bitwiseShiftExpression(node
): Promise
<TranslatedExpression
>
Translates a BitwiseShiftExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
BitwiseShiftExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:1021
bitwiseXorExpression
▸ bitwiseXorExpression(node
): Promise
<TranslatedExpression
>
Translates a BitwiseXorExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
BitwiseXorExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:1014
boolPrimaryExpression
▸ boolPrimaryExpression(node
): Promise
<TranslatedExpression
>
Translates a BoolPrimaryExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
BoolPrimaryExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:813
castOrConvertExpression
▸ castOrConvertExpression(node
): Promise
<TranslatedExpression
>
Translates a CastOrConvertExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
CastOrConvertExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:906
classConstructorDeclaration
▸ classConstructorDeclaration(node
): Promise
<TranslatedCodeLine
[]>
Translates a ClassConstructorDeclaration into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
ClassConstructorDeclaration |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:617
classDeclaration
▸ classDeclaration(node
): Promise
<TranslatedCodeLine
[]>
Translates a ClassDeclaration into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
ClassDeclaration |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:552
classMethodDeclaration
▸ classMethodDeclaration(node
): Promise
<TranslatedCodeLine
[]>
Parameters
Name | Type |
---|---|
node |
ClassMethodDeclaration |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:596
classPropertyDeclaration
▸ classPropertyDeclaration(node
): Promise
<TranslatedCodeLine
>
Parameters
Name | Type |
---|---|
node |
ClassPropertyDeclaration |
Returns
Promise
<TranslatedCodeLine
>
Defined in
kipper/target-js/src/code-generator.ts:589
compoundStatement
▸ compoundStatement(node
): Promise
<TranslatedCodeLine
[]>
Translates a CompoundStatement into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
CompoundStatement |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:274
conditionalExpression
▸ conditionalExpression(node
): Promise
<TranslatedExpression
>
Translates a ConditionalExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
ConditionalExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:1042
doWhileLoopIterationStatement
▸ doWhileLoopIterationStatement(node
): Promise
<TranslatedCodeLine
[]>
Translates a DoWhileLoopIterationStatement into the JavaScript language.
Since
0.10.0
Parameters
Name | Type |
---|---|
node |
DoWhileLoopIterationStatement |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:385
equalityExpression
▸ equalityExpression(node
): Promise
<TranslatedExpression
>
Translates a EqualityExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
EqualityExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:993
expressionStatement
▸ expressionStatement(node
): Promise
<TranslatedCodeLine
[]>
Translates a ExpressionStatement into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
ExpressionStatement |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:370
fStringPrimaryExpression
▸ fStringPrimaryExpression(node
): Promise
<TranslatedExpression
>
Translates a FStringPrimaryExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
FStringPrimaryExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:797
forLoopIterationStatement
▸ forLoopIterationStatement(node
): Promise
<TranslatedCodeLine
[]>
Translates a ForLoopIterationStatement into the JavaScript language.
Since
0.10.0
Parameters
Name | Type |
---|---|
node |
ForLoopIterationStatement |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:423
functionCallExpression
▸ functionCallExpression(node
): Promise
<TranslatedExpression
>
Translates a FunctionCallExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
FunctionCallExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:851
functionDeclaration
▸ functionDeclaration(node
): Promise
<TranslatedCodeLine
[]>
Translates a FunctionDeclaration into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
FunctionDeclaration |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:503
genericTypeSpecifierExpression
▸ genericTypeSpecifierExpression(node
): Promise
<TranslatedExpression
>
Translates a GenericTypeSpecifierExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
GenericTypeSpecifierExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:774
identifierPrimaryExpression
▸ identifierPrimaryExpression(node
): Promise
<TranslatedExpression
>
Translates a IdentifierPrimaryExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
IdentifierPrimaryExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:711
identifierTypeSpecifierExpression
▸ identifierTypeSpecifierExpression(node
): Promise
<TranslatedExpression
>
Translates a IdentifierTypeSpecifierExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
IdentifierTypeSpecifierExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:765
ifStatement
▸ ifStatement(node
): Promise
<TranslatedCodeLine
[]>
Translates a IfStatement into the JavaScript language.
Implementation notes:
- This algorithm is indirectly recursive, as else-if statements are handling like else statements with an immediate if statement in them.
- The formatting algorithm tries to start at the top and slowly go down each area of the abstract syntax tree. First the starting 'if' will be formatted, and afterwards the alternative branches are processed if they exists. If they do, it is also formatted like with a regular starting 'if', unless there is another nested if-statement in which case it will pass that job down to the child if-statement.
Since
0.10.0
Parameters
Name | Type |
---|---|
node |
IfStatement |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:295
incrementOrDecrementPostfixExpression
▸ incrementOrDecrementPostfixExpression(node
): Promise
<TranslatedExpression
>
Translates a IncrementOrDecrementPostfixExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
IncrementOrDecrementPostfixExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:839
incrementOrDecrementUnaryExpression
▸ incrementOrDecrementUnaryExpression(node
): Promise
<TranslatedExpression
>
Translates a IncrementOrDecrementUnaryExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
IncrementOrDecrementUnaryExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:879
instanceOfExpression
▸ instanceOfExpression(node
): Promise
<TranslatedExpression
>
Translates a InstanceOfExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
InstanceOfExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:1138
interfaceDeclaration
▸ interfaceDeclaration(node
): Promise
<TranslatedCodeLine
[]>
Translates a AssignmentExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
InterfaceDeclaration |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:529
interfaceMethodDeclaration
▸ interfaceMethodDeclaration(node
): Promise
<TranslatedCodeLine
[]>
Translates a InterfaceMethodDeclaration into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
InterfaceMethodDeclaration |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:545
interfacePropertyDeclaration
▸ interfacePropertyDeclaration(node
): Promise
<TranslatedCodeLine
[]>
Translates a InterfacePropertyDeclaration into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
InterfacePropertyDeclaration |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:537
jumpStatement
▸ jumpStatement(node
): Promise
<TranslatedCodeLine
[]>
Translates a JumpStatement into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
JumpStatement |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:476
lambdaPrimaryExpression
▸ lambdaPrimaryExpression(node
): Promise
<TranslatedExpression
>
Translates a LambdaPrimaryExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
LambdaPrimaryExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:1065
logicalAndExpression
▸ logicalAndExpression(node
): Promise
<TranslatedExpression
>
Translates a LogicalAndExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
LogicalAndExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:1028
logicalOrExpression
▸ logicalOrExpression(node
): Promise
<TranslatedExpression
>
Translates a LogicalOrExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
LogicalOrExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:1035
matchesExpression
▸ matchesExpression(node
): Promise
<TranslatedExpression
>
Translates a MatchesExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
MatchesExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:1119
memberAccessExpression
▸ memberAccessExpression(node
): Promise
<TranslatedExpression
>
Translates a IdentifierPrimaryExpression into the JavaScript language.
Since
0.10.0
Parameters
Name | Type |
---|---|
node |
MemberAccessExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:724
multiplicativeExpression
▸ multiplicativeExpression(node
): Promise
<TranslatedExpression
>
Translates a MultiplicativeExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
MultiplicativeExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:928
newInstantiationExpression
▸ newInstantiationExpression(node
): Promise
<TranslatedExpression
>
Parameters
Name | Type |
---|---|
node |
NewInstantiationExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:577
numberPrimaryExpression
▸ numberPrimaryExpression(node
): Promise
<TranslatedExpression
>
Translates a NumberPrimaryExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
NumberPrimaryExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:639
objectPrimaryExpression
▸ objectPrimaryExpression(node
): Promise
<TranslatedExpression
>
Translates a ObjectPrimaryExpression into the JavaScript language.
Since
0.11.0
Parameters
Name | Type |
---|---|
node |
ObjectPrimaryExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:681
objectProperty
▸ objectProperty(node
): Promise
<TranslatedExpression
>
Translates a ObjectProperty into the JavaScript language.
Since
0.11.0
Parameters
Name | Type |
---|---|
node |
ObjectProperty |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:697
operatorModifiedUnaryExpression
▸ operatorModifiedUnaryExpression(node
): Promise
<TranslatedExpression
>
Translates a OperatorModifiedUnaryExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
OperatorModifiedUnaryExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:891
parameterDeclaration
▸ parameterDeclaration(node
): Promise
<TranslatedCodeLine
[]>
Translates a ParameterDeclaration into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
ParameterDeclaration |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:495
relationalExpression
▸ relationalExpression(node
): Promise
<TranslatedExpression
>
Translates a RelationalExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
RelationalExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:986
returnStatement
▸ returnStatement(node
): Promise
<TranslatedCodeLine
[]>
Translates a ReturnStatement into the JavaScript language.
Since
0.10.0
Parameters
Name | Type |
---|---|
node |
ReturnStatement |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:485
setUp
▸ setUp(programCtx
, requirements
): Promise
<TranslatedCodeLine
[]>
Code generation function, which is called at the start of a translation and generates the dependencies for a file in the target language.
This should be only used to set up a Kipper file in the target language and not as a replacement to KipperTargetBuiltInGenerator.
Since
0.10.0
Parameters
Name | Type |
---|---|
programCtx |
KipperProgramContext |
requirements |
TranslatedCodeLine [] |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:101
stringPrimaryExpression
▸ stringPrimaryExpression(node
): Promise
<TranslatedExpression
>
Translates a StringPrimaryExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
StringPrimaryExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:788
switchStatement
▸ switchStatement(node
): Promise
<TranslatedCodeLine
[]>
Translates a SwitchStatement into the JavaScript language.
Since
0.10.0
Parameters
Name | Type |
---|---|
node |
SwitchStatement |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:363
tangledPrimaryExpression
▸ tangledPrimaryExpression(node
): Promise
<TranslatedExpression
>
Translates a TangledPrimaryExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
TangledPrimaryExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:820
translateOperatorExpressionWithOperands
▸ Private
translateOperatorExpressionWithOperands(node
): Promise
<TranslatedExpression
>
Translates any form of operator-based expression with two operands into the JavaScript language.
Since
0.10.0
Parameters
Name | Type | Description |
---|---|---|
node |
any |
The node to translate. |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:962
typeofExpression
▸ typeofExpression(node
): Promise
<TranslatedExpression
>
Translates a TypeofExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
TypeofExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:1109
typeofTypeSpecifierExpression
▸ typeofTypeSpecifierExpression(node
): Promise
<TranslatedExpression
>
Translates a TypeofTypeSpecifierExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
TypeofTypeSpecifierExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:781
variableDeclaration
▸ variableDeclaration(node
): Promise
<TranslatedCodeLine
[]>
Translates a VariableDeclaration into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
VariableDeclaration |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:517
voidOrNullOrUndefinedPrimaryExpression
▸ voidOrNullOrUndefinedPrimaryExpression(node
): Promise
<TranslatedExpression
>
Translates a IncrementOrDecrementPostfixExpression into the JavaScript language.
Parameters
Name | Type |
---|---|
node |
VoidOrNullOrUndefinedPrimaryExpression |
Returns
Promise
<TranslatedExpression
>
Defined in
kipper/target-js/src/code-generator.ts:828
whileLoopIterationStatement
▸ whileLoopIterationStatement(node
): Promise
<TranslatedCodeLine
[]>
Translates a WhileLoopIterationStatement into the JavaScript language.
Since
0.10.0
Parameters
Name | Type |
---|---|
node |
WhileLoopIterationStatement |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:404
wrapUp
▸ wrapUp(programCtx
): Promise
<TranslatedCodeLine
[]>
Code generation function, which is called at the end of a translation and should wrap up a program in the target language.
This should be only used to add additional items to finish a Kipper file in the target language and not as a replacement to KipperTargetBuiltInGenerator.
Since
0.10.0
Parameters
Name | Type |
---|---|
programCtx |
KipperProgramContext |
Returns
Promise
<TranslatedCodeLine
[]>
Defined in
kipper/target-js/src/code-generator.ts:267