Changeset 5f08961d for src/CodeGen
- Timestamp:
- Apr 16, 2018, 4:48:43 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, with_gc
- Children:
- a3323db1
- Parents:
- e93f1d2
- Location:
- src/CodeGen
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
re93f1d2 r5f08961d 116 116 } 117 117 118 CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks ) : indent( CodeGenerator::tabsize ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ), endl( *this ) {}118 CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks, bool printExprTypes ) : indent( CodeGenerator::tabsize ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ), printExprTypes( printExprTypes ), endl( *this ) {} 119 119 120 120 string CodeGenerator::mangleName( DeclarationWithType * decl ) { … … 157 157 node->print( ss ); 158 158 assertf( false, "Unhandled node reached in CodeGenerator: %s", ss.str().c_str() ); 159 } 160 161 // *** Expression 162 void CodeGenerator::previsit( Expression * node ) { 163 previsit( (BaseSyntaxNode *)node ); 164 GuardAction( [this, node](){ 165 if ( printExprTypes ) { 166 output << " /* " << genType( node->result, "", pretty, genC ) << " */ "; 167 } 168 } ); 159 169 } 160 170 -
src/CodeGen/CodeGenerator.h
re93f1d2 r5f08961d 27 27 28 28 namespace CodeGen { 29 struct CodeGenerator : public WithShortCircuiting, public With VisitorRef<CodeGenerator> {29 struct CodeGenerator : public WithShortCircuiting, public WithGuards, public WithVisitorRef<CodeGenerator> { 30 30 static int tabsize; 31 31 32 CodeGenerator( std::ostream &os, bool pretty = false, bool genC = false, bool lineMarks = false );32 CodeGenerator( std::ostream &os, bool pretty = false, bool genC = false, bool lineMarks = false, bool printExprTypes = false ); 33 33 34 34 //*** Turn off visit_children for all nodes … … 37 37 //*** Error for unhandled node types 38 38 void postvisit( BaseSyntaxNode * ); 39 40 //*** print type for all expressions 41 void previsit( Expression * node ); 39 42 40 43 //*** Declaration … … 140 143 bool genC = false; // true if output has to be C code 141 144 bool lineMarks = false; 145 bool printExprTypes = false; 142 146 public: 143 147 LineEnder endl; -
src/CodeGen/Generate.cc
re93f1d2 r5f08961d 46 46 } // namespace 47 47 48 void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC, bool lineMarks ) {48 void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC, bool lineMarks, bool printExprTypes ) { 49 49 cleanTree( translationUnit ); 50 50 51 PassVisitor<CodeGenerator> cgv( os, pretty, generateC, lineMarks );51 PassVisitor<CodeGenerator> cgv( os, pretty, generateC, lineMarks, printExprTypes ); 52 52 for ( auto & dcl : translationUnit ) { 53 53 if ( LinkageSpec::isGeneratable( dcl->get_linkage() ) && (doIntrinsics || ! LinkageSpec::isBuiltin( dcl->get_linkage() ) ) ) { … … 66 66 os << CodeGen::genPrettyType( type, "" ); 67 67 } else { 68 PassVisitor<CodeGenerator> cgv( os, true, false, false );68 PassVisitor<CodeGenerator> cgv( os, true, false, false, false ); 69 69 node->accept( cgv ); 70 70 } -
src/CodeGen/Generate.h
re93f1d2 r5f08961d 24 24 namespace CodeGen { 25 25 /// Generates code. doIntrinsics determines if intrinsic functions are printed, pretty formats output nicely (e.g., uses unmangled names, etc.), generateC is true when the output must consist only of C code (allows some assertions, etc.) 26 void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC = false , bool lineMarks = false );26 void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC = false , bool lineMarks = false, bool printTypeExpr = false ); 27 27 28 28 /// Generate code for a single node -- helpful for debugging in gdb
Note: See TracChangeset
for help on using the changeset viewer.