Package net.jangaroo.jooc.backend
Class CodeGeneratorBase
- java.lang.Object
-
- net.jangaroo.jooc.backend.CodeGeneratorBase
-
- All Implemented Interfaces:
AstVisitor
- Direct Known Subclasses:
JsCodeGenerator,TypeScriptCodeGenerator
public abstract class CodeGeneratorBase extends Object implements AstVisitor
-
-
Field Summary
Fields Modifier and Type Field Description protected CompilationUnitResolvercompilationUnitModelResolverprotected JsWriteroutprotected static StringPROPERTY_CLASS_INSTANCE
-
Constructor Summary
Constructors Constructor Description CodeGeneratorBase(JsWriter out, CompilationUnitResolver compilationUnitModelResolver)
-
Method Summary
-
-
-
Field Detail
-
PROPERTY_CLASS_INSTANCE
protected static final String PROPERTY_CLASS_INSTANCE
- See Also:
- Constant Field Values
-
compilationUnitModelResolver
protected final CompilationUnitResolver compilationUnitModelResolver
-
out
protected JsWriter out
-
-
Constructor Detail
-
CodeGeneratorBase
public CodeGeneratorBase(JsWriter out, CompilationUnitResolver compilationUnitModelResolver)
-
-
Method Detail
-
addBlockStartCodeGenerator
protected void addBlockStartCodeGenerator(BlockStatement block, CodeGenerator codeGenerator)
-
visitBlockStatement
public void visitBlockStatement(BlockStatement blockStatement) throws IOException
- Specified by:
visitBlockStatementin interfaceAstVisitor- Throws:
IOException
-
visitBlockStatementDirectives
protected void visitBlockStatementDirectives(BlockStatement blockStatement) throws IOException
- Throws:
IOException
-
writeModifiers
protected void writeModifiers(IdeDeclaration declaration) throws IOException
- Throws:
IOException
-
visitLiteralExpr
public void visitLiteralExpr(LiteralExpr literalExpr) throws IOException
- Specified by:
visitLiteralExprin interfaceAstVisitor- Throws:
IOException
-
visitPostfixOpExpr
public final void visitPostfixOpExpr(PostfixOpExpr postfixOpExpr) throws IOException
- Specified by:
visitPostfixOpExprin interfaceAstVisitor- Throws:
IOException
-
visitDotExpr
public void visitDotExpr(DotExpr dotExpr) throws IOException
- Specified by:
visitDotExprin interfaceAstVisitor- Throws:
IOException
-
visitPrefixOpExpr
public void visitPrefixOpExpr(PrefixOpExpr prefixOpExpr) throws IOException
- Specified by:
visitPrefixOpExprin interfaceAstVisitor- Throws:
IOException
-
visitBinaryOpExpr
public final void visitBinaryOpExpr(BinaryOpExpr binaryOpExpr) throws IOException
- Specified by:
visitBinaryOpExprin interfaceAstVisitor- Throws:
IOException
-
visitIsExpr
public final void visitIsExpr(IsExpr isExpr) throws IOException
- Specified by:
visitIsExprin interfaceAstVisitor- Throws:
IOException
-
visitConditionalExpr
public final void visitConditionalExpr(ConditionalExpr conditionalExpr) throws IOException
- Specified by:
visitConditionalExprin interfaceAstVisitor- Throws:
IOException
-
visitCommaSeparatedList
public final <T extends AstNode> void visitCommaSeparatedList(CommaSeparatedList<T> commaSeparatedList) throws IOException
- Specified by:
visitCommaSeparatedListin interfaceAstVisitor- Throws:
IOException
-
findMemberWithBindableAnnotation
protected TypedIdeDeclaration findMemberWithBindableAnnotation(Ide qIde, MethodType methodType, TypeDeclaration typeDeclaration)
-
getBindablePropertiesByName
protected static Map<String,Object> getBindablePropertiesByName(TypedIdeDeclaration member)
-
getBindablePropertyName
protected static String getBindablePropertyName(MethodType methodType, TypedIdeDeclaration member)
-
visitParameters
public void visitParameters(Parameters parameters) throws IOException
- Specified by:
visitParametersin interfaceAstVisitor- Throws:
IOException
-
visitPredefinedTypeDeclaration
public final void visitPredefinedTypeDeclaration(PredefinedTypeDeclaration predefinedTypeDeclaration)
- Specified by:
visitPredefinedTypeDeclarationin interfaceAstVisitor
-
writeOptSymbol
protected void writeOptSymbol(JooSymbol symbol) throws IOException
- Throws:
IOException
-
writeOptSymbolWhitespace
protected void writeOptSymbolWhitespace(JooSymbol symbol) throws IOException
- Throws:
IOException
-
writeOptSymbol
protected void writeOptSymbol(JooSymbol optSymbol, String defaultToken) throws IOException
- Throws:
IOException
-
writeSymbolReplacement
protected void writeSymbolReplacement(JooSymbol symbol, String replacementToken) throws IOException
- Throws:
IOException
-
visitIfNotNull
protected void visitIfNotNull(AstNode args) throws IOException
- Throws:
IOException
-
visitIfNotNull
protected void visitIfNotNull(AstNode args, String replacementToken) throws IOException
- Throws:
IOException
-
visitAll
protected void visitAll(Iterable<? extends AstNode> nodes) throws IOException
- Throws:
IOException
-
getPropertiesClassAssignments
protected List<AssignmentOpExpr> getPropertiesClassAssignments(FunctionDeclaration constructorDeclaration, boolean includeLiterals, boolean includeReferences)
-
renderPropertiesClassValues
protected void renderPropertiesClassValues(List<AssignmentOpExpr> propertyAssignments, boolean useComments, boolean useDeclarationComments, boolean startWithComma) throws IOException
- Throws:
IOException
-
getObjectAndProperty
protected Map.Entry<Expr,AstNode> getObjectAndProperty(AssignmentOpExpr assignmentOpExpr)
-
visitTypeRelation
public void visitTypeRelation(TypeRelation typeRelation) throws IOException
- Specified by:
visitTypeRelationin interfaceAstVisitor- Throws:
IOException
-
visitAnnotationParameter
public void visitAnnotationParameter(AnnotationParameter annotationParameter) throws IOException
- Specified by:
visitAnnotationParameterin interfaceAstVisitor- Throws:
IOException
-
visitExtends
public void visitExtends(Extends anExtends) throws IOException
- Specified by:
visitExtendsin interfaceAstVisitor- Throws:
IOException
-
visitInitializer
public void visitInitializer(Initializer initializer) throws IOException
- Specified by:
visitInitializerin interfaceAstVisitor- Throws:
IOException
-
visitObjectField
public void visitObjectField(ObjectField objectField) throws IOException
- Specified by:
visitObjectFieldin interfaceAstVisitor- Throws:
IOException
-
visitObjectFieldValue
protected void visitObjectFieldValue(ObjectField objectField) throws IOException
- Throws:
IOException
-
handleExmlAppendPrepend
protected abstract void handleExmlAppendPrepend(ObjectField objectField, DotExpr exmlAppendOrPrepend) throws IOException
- Throws:
IOException
-
visitForInitializer
public void visitForInitializer(ForInitializer forInitializer) throws IOException
- Specified by:
visitForInitializerin interfaceAstVisitor- Throws:
IOException
-
visitCompilationUnit
public void visitCompilationUnit(CompilationUnit compilationUnit) throws IOException
- Specified by:
visitCompilationUnitin interfaceAstVisitor- Throws:
IOException
-
visitIde
public void visitIde(Ide ide) throws IOException
- Specified by:
visitIdein interfaceAstVisitor- Throws:
IOException
-
visitQualifiedIde
public void visitQualifiedIde(QualifiedIde qualifiedIde) throws IOException
- Specified by:
visitQualifiedIdein interfaceAstVisitor- Throws:
IOException
-
visitIdeWithTypeParam
public void visitIdeWithTypeParam(IdeWithTypeParam ideWithTypeParam) throws IOException
- Specified by:
visitIdeWithTypeParamin interfaceAstVisitor- Throws:
IOException
-
visitNamespacedIde
public void visitNamespacedIde(NamespacedIde namespacedIde) throws IOException
- Specified by:
visitNamespacedIdein interfaceAstVisitor- Throws:
IOException
-
visitImplements
public void visitImplements(Implements anImplements) throws IOException
- Specified by:
visitImplementsin interfaceAstVisitor- Throws:
IOException
-
visitType
public void visitType(Type type) throws IOException
- Specified by:
visitTypein interfaceAstVisitor- Throws:
IOException
-
visitObjectLiteral
public void visitObjectLiteral(ObjectLiteral objectLiteral) throws IOException
- Specified by:
visitObjectLiteralin interfaceAstVisitor- Throws:
IOException
-
visitIdeExpression
public void visitIdeExpression(IdeExpr ideExpr) throws IOException
- Specified by:
visitIdeExpressionin interfaceAstVisitor- Throws:
IOException
-
visitParenthesizedExpr
public <T extends Expr> void visitParenthesizedExpr(ParenthesizedExpr<T> parenthesizedExpr) throws IOException
- Specified by:
visitParenthesizedExprin interfaceAstVisitor- Throws:
IOException
-
visitArrayLiteral
public void visitArrayLiteral(ArrayLiteral arrayLiteral) throws IOException
- Specified by:
visitArrayLiteralin interfaceAstVisitor- Throws:
IOException
-
visitAssignmentOpExpr
public void visitAssignmentOpExpr(AssignmentOpExpr assignmentOpExpr) throws IOException
- Specified by:
visitAssignmentOpExprin interfaceAstVisitor- Throws:
IOException
-
visitInfixOpExpr
public void visitInfixOpExpr(InfixOpExpr infixOpExpr) throws IOException
- Specified by:
visitInfixOpExprin interfaceAstVisitor- Throws:
IOException
-
visitAsExpr
public void visitAsExpr(AsExpr asExpr) throws IOException
- Specified by:
visitAsExprin interfaceAstVisitor- Throws:
IOException
-
visitArrayIndexExpr
public void visitArrayIndexExpr(ArrayIndexExpr arrayIndexExpr) throws IOException
- Specified by:
visitArrayIndexExprin interfaceAstVisitor- Throws:
IOException
-
findFunctionDeclaration
protected static FunctionDeclaration findFunctionDeclaration(AstNode node)
-
visitFunctionExpr
public void visitFunctionExpr(FunctionExpr functionExpr) throws IOException
- Specified by:
visitFunctionExprin interfaceAstVisitor- Throws:
IOException
-
visitVectorLiteral
public void visitVectorLiteral(VectorLiteral vectorLiteral) throws IOException
- Specified by:
visitVectorLiteralin interfaceAstVisitor- Throws:
IOException
-
visitApplyExpr
public void visitApplyExpr(ApplyExpr applyExpr) throws IOException
- Specified by:
visitApplyExprin interfaceAstVisitor- Throws:
IOException
-
visitApplyExprArguments
public void visitApplyExprArguments(ApplyExpr applyExpr) throws IOException
- Throws:
IOException
-
visitNewExpr
public void visitNewExpr(NewExpr newExpr) throws IOException
- Specified by:
visitNewExprin interfaceAstVisitor- Throws:
IOException
-
visitClassBody
public void visitClassBody(ClassBody classBody) throws IOException
- Specified by:
visitClassBodyin interfaceAstVisitor- Throws:
IOException
-
visitClassBodyDirectives
public void visitClassBodyDirectives(List<Directive> classBodyDirectives) throws IOException
- Throws:
IOException
-
visitDefaultStatement
public void visitDefaultStatement(DefaultStatement defaultStatement) throws IOException
- Specified by:
visitDefaultStatementin interfaceAstVisitor- Throws:
IOException
-
visitLabeledStatement
public void visitLabeledStatement(LabeledStatement labeledStatement) throws IOException
- Specified by:
visitLabeledStatementin interfaceAstVisitor- Throws:
IOException
-
visitIfStatement
public void visitIfStatement(IfStatement ifStatement) throws IOException
- Specified by:
visitIfStatementin interfaceAstVisitor- Throws:
IOException
-
visitCaseStatement
public void visitCaseStatement(CaseStatement caseStatement) throws IOException
- Specified by:
visitCaseStatementin interfaceAstVisitor- Throws:
IOException
-
visitTryStatement
public void visitTryStatement(TryStatement tryStatement) throws IOException
- Specified by:
visitTryStatementin interfaceAstVisitor- Throws:
IOException
-
visitCatch
public void visitCatch(Catch aCatch) throws IOException
- Specified by:
visitCatchin interfaceAstVisitor- Throws:
IOException
-
visitForInStatement
public void visitForInStatement(ForInStatement forInStatement) throws IOException
- Specified by:
visitForInStatementin interfaceAstVisitor- Throws:
IOException
-
visitWhileStatement
public void visitWhileStatement(WhileStatement whileStatement) throws IOException
- Specified by:
visitWhileStatementin interfaceAstVisitor- Throws:
IOException
-
visitForStatement
public void visitForStatement(ForStatement forStatement) throws IOException
- Specified by:
visitForStatementin interfaceAstVisitor- Throws:
IOException
-
visitDoStatement
public void visitDoStatement(DoStatement doStatement) throws IOException
- Specified by:
visitDoStatementin interfaceAstVisitor- Throws:
IOException
-
visitSwitchStatement
public void visitSwitchStatement(SwitchStatement switchStatement) throws IOException
- Specified by:
visitSwitchStatementin interfaceAstVisitor- Throws:
IOException
-
visitBreakStatement
public void visitBreakStatement(BreakStatement breakStatement) throws IOException
- Specified by:
visitBreakStatementin interfaceAstVisitor- Throws:
IOException
-
visitEmptyStatement
public void visitEmptyStatement(EmptyStatement emptyStatement) throws IOException
- Specified by:
visitEmptyStatementin interfaceAstVisitor- Throws:
IOException
-
visitEmptyDeclaration
public void visitEmptyDeclaration(EmptyDeclaration emptyDeclaration) throws IOException
- Specified by:
visitEmptyDeclarationin interfaceAstVisitor- Throws:
IOException
-
visitSemicolonTerminatedStatement
public void visitSemicolonTerminatedStatement(SemicolonTerminatedStatement semicolonTerminatedStatement) throws IOException
- Specified by:
visitSemicolonTerminatedStatementin interfaceAstVisitor- Throws:
IOException
-
visitContinueStatement
public void visitContinueStatement(ContinueStatement continueStatement) throws IOException
- Specified by:
visitContinueStatementin interfaceAstVisitor- Throws:
IOException
-
visitThrowStatement
public void visitThrowStatement(ThrowStatement throwStatement) throws IOException
- Specified by:
visitThrowStatementin interfaceAstVisitor- Throws:
IOException
-
visitReturnStatement
public void visitReturnStatement(ReturnStatement returnStatement) throws IOException
- Specified by:
visitReturnStatementin interfaceAstVisitor- Throws:
IOException
-
visitParameter
public void visitParameter(Parameter parameter) throws IOException
- Specified by:
visitParameterin interfaceAstVisitor- Throws:
IOException
-
visitVariableDeclaration
public void visitVariableDeclaration(VariableDeclaration variableDeclaration) throws IOException
- Specified by:
visitVariableDeclarationin interfaceAstVisitor- Throws:
IOException
-
visitFunctionDeclaration
public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) throws IOException
- Specified by:
visitFunctionDeclarationin interfaceAstVisitor- Throws:
IOException
-
visitClassDeclaration
public void visitClassDeclaration(ClassDeclaration classDeclaration) throws IOException
- Specified by:
visitClassDeclarationin interfaceAstVisitor- Throws:
IOException
-
visitNamespaceDeclaration
public void visitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration) throws IOException
- Specified by:
visitNamespaceDeclarationin interfaceAstVisitor- Throws:
IOException
-
visitPackageDeclaration
public void visitPackageDeclaration(PackageDeclaration packageDeclaration) throws IOException
- Specified by:
visitPackageDeclarationin interfaceAstVisitor- Throws:
IOException
-
visitSuperConstructorCallStatement
public void visitSuperConstructorCallStatement(SuperConstructorCallStatement superConstructorCallStatement) throws IOException
- Specified by:
visitSuperConstructorCallStatementin interfaceAstVisitor- Throws:
IOException
-
visitAnnotation
public void visitAnnotation(Annotation annotation) throws IOException
- Specified by:
visitAnnotationin interfaceAstVisitor- Throws:
IOException
-
visitUseNamespaceDirective
public void visitUseNamespaceDirective(UseNamespaceDirective useNamespaceDirective) throws IOException
- Specified by:
visitUseNamespaceDirectivein interfaceAstVisitor- Throws:
IOException
-
visitImportDirective
public void visitImportDirective(ImportDirective importDirective) throws IOException
- Specified by:
visitImportDirectivein interfaceAstVisitor- Throws:
IOException
-
-