Changes in src/CodeGen/CodeGenerator.cc [cda48b6:eb3261f]
- File:
-
- 1 edited
-
src/CodeGen/CodeGenerator.cc (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rcda48b6 reb3261f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Jun 11 13:22:39201513 // Update Count : 1 3712 // Last Modified On : Thu Jun 04 15:00:00 2015 13 // Update Count : 125 14 14 // 15 15 … … 43 43 } 44 44 45 ostream & CodeGenerator::Indenter::operator()( ostream & output ) { 46 return output << string( cg.cur_indent, ' ' ); 47 } 48 49 ostream & operator<<( ostream & output, CodeGenerator::Indenter &indent ) { 50 return indent( output ); 51 } 52 53 CodeGenerator::CodeGenerator( std::ostream &os ) : indent(*this), cur_indent( 0 ), insideFunction( false ), output( os ) { } 54 55 CodeGenerator::CodeGenerator( std::ostream &os, std::string init, int indentation, bool infunp ) 56 : indent(*this), cur_indent( indentation ), insideFunction( infunp ), output( os ) { 45 CodeGenerator::CodeGenerator( std::ostream &os ) : cur_indent( 0 ), insideFunction( false ), output( os ) { } 46 47 CodeGenerator::CodeGenerator( std::ostream &os, std::string init, int indent, bool infunp ) 48 : cur_indent( indent ), insideFunction( infunp ), output( os ) { 57 49 //output << std::string( init ); 58 50 } 59 51 60 CodeGenerator::CodeGenerator( std::ostream &os, char *init, int indent ation, bool infunp )61 : indent(*this), cur_indent( indentation), insideFunction( infunp ), output( os ) {52 CodeGenerator::CodeGenerator( std::ostream &os, char *init, int indent, bool infunp ) 53 : cur_indent( indent ), insideFunction( infunp ), output( os ) { 62 54 //output << std::string( init ); 63 55 } … … 70 62 } // if 71 63 } 72 64 73 65 //*** Declarations 74 66 void CodeGenerator::visit( FunctionDecl *functionDecl ) { … … 112 104 113 105 if ( ! memb.empty() ) { 114 output << endl << indent<< "{" << endl;106 output << endl << string( cur_indent, ' ' ) << "{" << endl; 115 107 116 108 cur_indent += CodeGenerator::tabsize; 117 109 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++) { 118 output << indent;110 output << string( cur_indent, ' ' ); 119 111 (*i)->accept(*this ); 120 112 output << ";" << endl; … … 123 115 cur_indent -= CodeGenerator::tabsize; 124 116 125 output << indent<< "}";117 output << string( cur_indent, ' ' ) << "}"; 126 118 } // if 127 119 } … … 146 138 147 139 if ( ! memb.empty() ) { 148 output << "{" << endl;140 output << endl << "{" << endl; 149 141 150 142 cur_indent += CodeGenerator::tabsize; … … 152 144 ObjectDecl *obj = dynamic_cast< ObjectDecl* >( *i ); 153 145 assert( obj ); 154 output << indent<< mangleName( obj );146 output << string( cur_indent, ' ' ) << mangleName( obj ); 155 147 if ( obj->get_init() ) { 156 148 output << " = "; … … 162 154 cur_indent -= CodeGenerator::tabsize; 163 155 164 output << indent << "}";156 output << "}" << endl; 165 157 } // if 166 158 } … … 452 444 453 445 for ( std::list<Statement *>::iterator i = ks.begin(); i != ks.end(); i++) { 454 output << indent<< printLabels( (*i)->get_labels() );446 output << string( cur_indent, ' ' ) << printLabels( (*i)->get_labels() ); 455 447 (*i)->accept(*this ); 456 448 … … 462 454 cur_indent -= CodeGenerator::tabsize; 463 455 464 output << indent<< "}";456 output << string( cur_indent, ' ' ) << "}"; 465 457 } 466 458 … … 502 494 cur_indent -= CodeGenerator::tabsize; 503 495 504 output << indent<< "}";496 output << string( cur_indent, ' ' ) << "}"; 505 497 } 506 498 507 499 void CodeGenerator::visit( CaseStmt *caseStmt ) { 508 output << indent;500 output << string( cur_indent, ' ' ); 509 501 if ( caseStmt->isDefault()) { 510 502 output << "default"; … … 519 511 cur_indent += CodeGenerator::tabsize; 520 512 for ( std::list<Statement *>::iterator i = sts.begin(); i != sts.end(); i++) { 521 output << indent<< printLabels( (*i)->get_labels() ) ;513 output << string( cur_indent, ' ' ) << printLabels( (*i)->get_labels() ) ; 522 514 (*i)->accept(*this ); 523 515 output << endl; … … 572 564 whileStmt->get_body()->accept( *this ); 573 565 574 output << indent;566 output << string( cur_indent, ' ' ); 575 567 576 568 if ( whileStmt->get_isDoWhile() ) { … … 604 596 605 597 void CodeGenerator::visit( NullStmt *nullStmt ) { 606 //output << indent<< CodeGenerator::printLabels( nullStmt->get_labels() );598 //output << string( cur_indent, ' ' ) << CodeGenerator::printLabels( nullStmt->get_labels() ); 607 599 output << "/* null statement */ ;"; 608 600 }
Note:
See TracChangeset
for help on using the changeset viewer.