Changeset e64365c for src/CodeGen/CodeGenerator.cc
- Timestamp:
- Jun 29, 2016, 4:47:57 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- a1d7679
- Parents:
- 89b686a (diff), 87b5bf0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r89b686a re64365c 48 48 } 49 49 50 ostream & CodeGenerator::Indenter::operator()( ostream & output ) {50 ostream & CodeGenerator::Indenter::operator()( ostream & output ) const { 51 51 return output << string( cg.cur_indent, ' ' ); 52 52 } 53 53 54 ostream & operator<<( ostream & output, CodeGenerator::Indenter &indent ) {54 ostream & operator<<( ostream & output, const CodeGenerator::Indenter &indent ) { 55 55 return indent( output ); 56 56 } 57 57 58 CodeGenerator::CodeGenerator( std::ostream &os ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ) { } 58 CodeGenerator::LabelPrinter & CodeGenerator::LabelPrinter::operator()( std::list< Label > & l ) { 59 labels = &l; 60 return *this; 61 } 62 63 ostream & operator<<( ostream & output, CodeGenerator::LabelPrinter &printLabels ) { 64 std::list< Label > & labs = *printLabels.labels; 65 // l.unique(); // assumes a sorted list. Why not use set? Does order matter? 66 for ( Label & l : labs ) { 67 output << l.get_name() + ": "; 68 printLabels.cg.genAttributes( l.get_attributes() ); 69 } 70 return output; 71 } 72 73 CodeGenerator::CodeGenerator( std::ostream &os ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ) { } 59 74 60 75 CodeGenerator::CodeGenerator( std::ostream &os, std::string init, int indentation, bool infunp ) 61 : indent( *this), cur_indent( indentation ), insideFunction( infunp ), output( os ) {76 : indent( *this), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) { 62 77 //output << std::string( init ); 63 78 } 64 79 65 80 CodeGenerator::CodeGenerator( std::ostream &os, char *init, int indentation, bool infunp ) 66 : indent( *this ), cur_indent( indentation ), insideFunction( infunp ), output( os ) {81 : indent( *this ), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) { 67 82 //output << std::string( init ); 68 83 } … … 735 750 void CodeGenerator::visit( ReturnStmt *returnStmt ) { 736 751 output << "return "; 737 738 // xxx -- check for null expression; 739 if ( returnStmt->get_expr() ) { 740 returnStmt->get_expr()->accept( *this ); 741 } // if 752 maybeAccept( returnStmt->get_expr(), *this ); 742 753 output << ";"; 743 754 } … … 799 810 output << ";"; 800 811 } // if 801 }802 803 std::string CodeGenerator::printLabels( std::list< Label > &l ) {804 std::string str( "" );805 l.unique(); // assumes a sorted list. Why not use set?806 807 for ( std::list< Label >::iterator i = l.begin(); i != l.end(); i++ )808 str += *i + ": ";809 810 return str;811 812 } 812 813
Note: See TracChangeset
for help on using the changeset viewer.