Changes in src/CodeGen/CodeGenerator.cc [f975c65:6e300d9]
- File:
-
- 1 edited
-
src/CodeGen/CodeGenerator.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rf975c65 r6e300d9 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed May 10 14:45:00 201713 // Update Count : 48 412 // Last Modified On : Tus May 9 14:32:00 2017 13 // Update Count : 483 14 14 // 15 15 … … 41 41 namespace CodeGen { 42 42 int CodeGenerator::tabsize = 4; 43 44 // Pseudo Function: output << lineDirective(*currentNode); 45 struct lineDirective { 46 CodeLocation const & loc; 47 lineDirective(CodeLocation const & location) : loc(location) {} 48 lineDirective(BaseSyntaxNode const * node) : loc(node->location) {} 49 }; 50 std::ostream & operator<<(std::ostream & out, lineDirective const & ld) { 51 if (ld.loc.isSet()) 52 return out << "\n# " << ld.loc.linenumber << " \"" 53 << ld.loc.filename << "\"\n"; 54 return out << "\n// Unset Location\n"; 55 } 43 56 44 57 // the kinds of statements that would ideally be followed by whitespace … … 89 102 } 90 103 91 CodeGenerator::LineMarker::LineMarker( 92 CodeLocation const & loc, bool toPrint) : 93 loc(loc), toPrint(toPrint) 94 {} 95 96 CodeGenerator::LineMarker CodeGenerator::lineDirective( 97 BaseSyntaxNode const * node) { 98 return LineMarker(node->location, lineMarks); 99 } 100 101 std::ostream & operator<<(std::ostream & out, 102 CodeGenerator::LineMarker const & marker) { 103 if (marker.toPrint && marker.loc.isSet()) { 104 return out << "\n# " << marker.loc.linenumber << " \"" 105 << marker.loc.filename << "\"\n"; 106 } else if (marker.toPrint) { 107 return out << "\n/* Missing CodeLocation */\n"; 108 } else { 109 return out; 110 } 111 } 112 113 CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ) {} 104 CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ) {} 114 105 115 106 CodeGenerator::CodeGenerator( std::ostream & os, std::string init, int indentation, bool infunp ) … … 204 195 } 205 196 206 output << kind;197 output << lineDirective( aggDecl ) << kind; 207 198 if ( aggDecl->get_name() != "" ) 208 199 output << aggDecl->get_name(); … … 709 700 void CodeGenerator::visit( UntypedTupleExpr * tupleExpr ) { 710 701 assertf( ! genC, "UntypedTupleExpr should not reach code generation." ); 711 extension( tupleExpr );712 702 output << "["; 713 703 genCommaList( tupleExpr->get_exprs().begin(), tupleExpr->get_exprs().end() ); … … 717 707 void CodeGenerator::visit( TupleExpr * tupleExpr ) { 718 708 assertf( ! genC, "TupleExpr should not reach code generation." ); 719 extension( tupleExpr );720 709 output << "["; 721 710 genCommaList( tupleExpr->get_exprs().begin(), tupleExpr->get_exprs().end() ); 722 711 output << "]"; 723 }724 725 void CodeGenerator::visit( TupleIndexExpr * tupleExpr ) {726 assertf( ! genC, "TupleIndexExpr should not reach code generation." );727 extension( tupleExpr );728 tupleExpr->get_tuple()->accept( *this );729 output << "." << tupleExpr->get_index();730 712 } 731 713
Note:
See TracChangeset
for help on using the changeset viewer.