Changeset 888cbe4 for src/CodeGen/CodeGenerator.cc
- Timestamp:
- Jun 28, 2016, 3:17:26 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:
- e39aa0f
- Parents:
- 4d3ca1d8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r4d3ca1d8 r888cbe4 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 } … … 801 816 } 802 817 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).get_name() + ": ";809 810 return str;811 }812 813 818 void CodeGenerator::handleStorageClass( Declaration *decl ) { 814 819 switch ( decl->get_storageClass() ) {
Note: See TracChangeset
for help on using the changeset viewer.