Changeset 888cbe4
- 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
- Location:
- src
- Files:
-
- 3 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() ) { -
src/CodeGen/CodeGenerator.h
r4d3ca1d8 r888cbe4 94 94 Indenter(CodeGenerator &cg) : cg(cg) {} 95 95 CodeGenerator & cg; 96 std::ostream& operator()(std::ostream & os); 96 std::ostream& operator()(std::ostream & os) const; 97 }; 98 99 struct LabelPrinter { 100 LabelPrinter(CodeGenerator &cg) : cg(cg), labels( 0 ) {} 101 LabelPrinter & operator()( std::list< Label > & l ); 102 CodeGenerator & cg; 103 std::list< Label > * labels; 97 104 }; 98 105 … … 108 115 bool insideFunction; 109 116 std::ostream &output; 117 LabelPrinter printLabels; 110 118 111 119 void printDesignators( std::list< Expression * > & ); 112 static std::string printLabels ( std::list < Label > & );113 120 void handleStorageClass( Declaration *decl ); 114 121 void handleAggregate( AggregateDecl *aggDecl ); -
src/ControlStruct/LabelGenerator.cc
r4d3ca1d8 r888cbe4 19 19 #include "LabelGenerator.h" 20 20 #include "SynTree/Label.h" 21 #include "SynTree/Attribute.h" 21 22 22 23 namespace ControlStruct { … … 34 35 os << "__L" << current++ << "__" << suffix; 35 36 std::string ret = os.str(); 36 return Label( ret ); 37 Label l( ret ); 38 l.get_attributes().push_back( new Attribute("unused") ); 39 return l; 37 40 } 38 41 } // namespace ControlStruct
Note: See TracChangeset
for help on using the changeset viewer.