Changeset 9857e8d for src/CodeGen/CodeGenerator.h
- Timestamp:
- Sep 18, 2017, 1:25:03 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 698ec72
- Parents:
- acdfb45
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.h
racdfb45 r9857e8d 21 21 22 22 #include "Common/Indenter.h" // for Indenter 23 #include "Common/PassVisitor.h" // for PassVisitor 23 24 #include "SynTree/Declaration.h" // for DeclarationWithType (ptr only), Fun... 24 25 #include "SynTree/Visitor.h" // for Visitor … … 26 27 27 28 namespace CodeGen { 28 class CodeGenerator : public Visitor { 29 public: 30 static int tabsize; 29 struct CodeGenerator : public WithShortCircuiting, public WithVisitorRef<CodeGenerator> { 30 static int tabsize; 31 31 32 32 CodeGenerator( std::ostream &os, bool pretty = false, bool genC = false, bool lineMarks = false ); … … 34 34 CodeGenerator( std::ostream &os, char *, int indent = 0, bool infun = false ); 35 35 36 //*** Turn off visit_children for all nodes 37 void previsit( BaseSyntaxNode * ); 38 39 //*** Error for unhandled node types 40 void postvisit( BaseSyntaxNode * ); 41 36 42 //*** Declaration 37 v irtual voidvisit( StructDecl * );38 v irtual voidvisit( FunctionDecl * );39 v irtual voidvisit( ObjectDecl * );40 v irtual voidvisit( UnionDecl *aggregateDecl );41 v irtual voidvisit( EnumDecl *aggregateDecl );42 v irtual voidvisit( TraitDecl *aggregateDecl );43 v irtual voidvisit( TypedefDecl *typeDecl );44 v irtual voidvisit( TypeDecl *typeDecl );43 void postvisit( StructDecl * ); 44 void postvisit( FunctionDecl * ); 45 void postvisit( ObjectDecl * ); 46 void postvisit( UnionDecl *aggregateDecl ); 47 void postvisit( EnumDecl *aggregateDecl ); 48 void postvisit( TraitDecl *aggregateDecl ); 49 void postvisit( TypedefDecl *typeDecl ); 50 void postvisit( TypeDecl *typeDecl ); 45 51 46 52 //*** Initializer 47 v irtual voidvisit( Designation * );48 v irtual voidvisit( SingleInit * );49 v irtual voidvisit( ListInit * );50 v irtual voidvisit( ConstructorInit * );53 void postvisit( Designation * ); 54 void postvisit( SingleInit * ); 55 void postvisit( ListInit * ); 56 void postvisit( ConstructorInit * ); 51 57 52 58 //*** Constant 53 v irtual voidvisit( Constant * );59 void postvisit( Constant * ); 54 60 55 61 //*** Expression 56 v irtual voidvisit( ApplicationExpr *applicationExpr );57 v irtual voidvisit( UntypedExpr *untypedExpr );58 v irtual voidvisit( RangeExpr * rangeExpr );59 v irtual voidvisit( NameExpr *nameExpr );60 v irtual voidvisit( AddressExpr *addressExpr );61 v irtual voidvisit( LabelAddressExpr *addressExpr );62 v irtual voidvisit( CastExpr *castExpr );63 v irtual voidvisit( VirtualCastExpr *castExpr );64 v irtual voidvisit( UntypedMemberExpr *memberExpr );65 v irtual voidvisit( MemberExpr *memberExpr );66 v irtual voidvisit( VariableExpr *variableExpr );67 v irtual voidvisit( ConstantExpr *constantExpr );68 v irtual voidvisit( SizeofExpr *sizeofExpr );69 v irtual voidvisit( AlignofExpr *alignofExpr );70 v irtual voidvisit( UntypedOffsetofExpr *offsetofExpr );71 v irtual voidvisit( OffsetofExpr *offsetofExpr );72 v irtual voidvisit( OffsetPackExpr *offsetPackExpr );73 v irtual voidvisit( LogicalExpr *logicalExpr );74 v irtual voidvisit( ConditionalExpr *conditionalExpr );75 v irtual voidvisit( CommaExpr *commaExpr );76 v irtual voidvisit( CompoundLiteralExpr *compLitExpr );77 v irtual voidvisit( UniqueExpr * );78 v irtual voidvisit( TupleAssignExpr * tupleExpr );79 v irtual voidvisit( UntypedTupleExpr *tupleExpr );80 v irtual voidvisit( TupleExpr *tupleExpr );81 v irtual voidvisit( TupleIndexExpr * tupleExpr );82 v irtual voidvisit( TypeExpr *typeExpr );83 v irtual voidvisit( AsmExpr * );84 v irtual voidvisit( StmtExpr * );62 void postvisit( ApplicationExpr *applicationExpr ); 63 void postvisit( UntypedExpr *untypedExpr ); 64 void postvisit( RangeExpr * rangeExpr ); 65 void postvisit( NameExpr *nameExpr ); 66 void postvisit( AddressExpr *addressExpr ); 67 void postvisit( LabelAddressExpr *addressExpr ); 68 void postvisit( CastExpr *castExpr ); 69 void postvisit( VirtualCastExpr *castExpr ); 70 void postvisit( UntypedMemberExpr *memberExpr ); 71 void postvisit( MemberExpr *memberExpr ); 72 void postvisit( VariableExpr *variableExpr ); 73 void postvisit( ConstantExpr *constantExpr ); 74 void postvisit( SizeofExpr *sizeofExpr ); 75 void postvisit( AlignofExpr *alignofExpr ); 76 void postvisit( UntypedOffsetofExpr *offsetofExpr ); 77 void postvisit( OffsetofExpr *offsetofExpr ); 78 void postvisit( OffsetPackExpr *offsetPackExpr ); 79 void postvisit( LogicalExpr *logicalExpr ); 80 void postvisit( ConditionalExpr *conditionalExpr ); 81 void postvisit( CommaExpr *commaExpr ); 82 void postvisit( CompoundLiteralExpr *compLitExpr ); 83 void postvisit( UniqueExpr * ); 84 void postvisit( TupleAssignExpr * tupleExpr ); 85 void postvisit( UntypedTupleExpr *tupleExpr ); 86 void postvisit( TupleExpr *tupleExpr ); 87 void postvisit( TupleIndexExpr * tupleExpr ); 88 void postvisit( TypeExpr *typeExpr ); 89 void postvisit( AsmExpr * ); 90 void postvisit( StmtExpr * ); 85 91 86 92 //*** Statements 87 virtual void visit( CompoundStmt * ); 88 virtual void visit( ExprStmt * ); 89 virtual void visit( AsmStmt * ); 90 virtual void visit( AsmDecl * ); // special: statement in declaration context 91 virtual void visit( IfStmt * ); 92 virtual void visit( SwitchStmt * ); 93 virtual void visit( CaseStmt * ); 94 virtual void visit( BranchStmt * ); 95 virtual void visit( ReturnStmt * ); 96 virtual void visit( ThrowStmt * ); 97 virtual void visit( WhileStmt * ); 98 virtual void visit( ForStmt * ); 99 virtual void visit( NullStmt * ); 100 virtual void visit( DeclStmt * ); 93 void postvisit( CompoundStmt * ); 94 void postvisit( ExprStmt * ); 95 void postvisit( AsmStmt * ); 96 void postvisit( AsmDecl * ); // special: statement in declaration context 97 void postvisit( IfStmt * ); 98 void postvisit( SwitchStmt * ); 99 void postvisit( CaseStmt * ); 100 void postvisit( BranchStmt * ); 101 void postvisit( ReturnStmt * ); 102 void postvisit( ThrowStmt * ); 103 void postvisit( WhileStmt * ); 104 void postvisit( ForStmt * ); 105 void postvisit( NullStmt * ); 106 void postvisit( DeclStmt * ); 107 void postvisit( ImplicitCtorDtorStmt * ); 101 108 102 109 void genAttributes( std::list< Attribute * > & attributes ); … … 140 147 if ( begin == end ) return; 141 148 for ( ;; ) { 142 (*begin++)->accept( * this);149 (*begin++)->accept( *visitor ); 143 150 if ( begin == end ) break; 144 151 output << ", "; // separator
Note: See TracChangeset
for help on using the changeset viewer.