Changes in src/CodeGen/CodeGenerator.cc [721f17a:de62360d]
- File:
-
- 1 edited
-
src/CodeGen/CodeGenerator.cc (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r721f17a rde62360d 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 26 16:52:58201513 // Update Count : 1 4412 // Last Modified On : Tue Jun 23 16:16:57 2015 13 // Update Count : 133 14 14 // 15 15 … … 44 44 } 45 45 46 ostream & CodeGenerator::Indenter::operator()( ostream & output ) { 47 return output << string( cg.cur_indent, ' ' ); 48 } 49 50 ostream & operator<<( ostream & output, CodeGenerator::Indenter &indent ) { 51 return indent( output ); 52 } 53 54 CodeGenerator::CodeGenerator( std::ostream &os ) : indent(*this), cur_indent( 0 ), insideFunction( false ), output( os ) { } 55 56 CodeGenerator::CodeGenerator( std::ostream &os, std::string init, int indentation, bool infunp ) 57 : indent(*this), cur_indent( indentation ), insideFunction( infunp ), output( os ) { 46 CodeGenerator::CodeGenerator( std::ostream &os ) : cur_indent( 0 ), insideFunction( false ), output( os ) { } 47 48 CodeGenerator::CodeGenerator( std::ostream &os, std::string init, int indent, bool infunp ) 49 : cur_indent( indent ), insideFunction( infunp ), output( os ) { 58 50 //output << std::string( init ); 59 51 } 60 52 61 CodeGenerator::CodeGenerator( std::ostream &os, char *init, int indent ation, bool infunp )62 : indent(*this), cur_indent( indentation), insideFunction( infunp ), output( os ) {53 CodeGenerator::CodeGenerator( std::ostream &os, char *init, int indent, bool infunp ) 54 : cur_indent( indent ), insideFunction( infunp ), output( os ) { 63 55 //output << std::string( init ); 64 56 } … … 71 63 } // if 72 64 } 73 65 74 66 //*** Declarations 75 67 void CodeGenerator::visit( FunctionDecl *functionDecl ) { … … 116 108 117 109 if ( ! memb.empty() ) { 118 output << "{" << endl;110 output << endl << string( cur_indent, ' ' ) << "{" << endl; 119 111 120 112 cur_indent += CodeGenerator::tabsize; 121 113 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++) { 122 output << indent;114 output << string( cur_indent, ' ' ); 123 115 (*i)->accept(*this ); 124 116 output << ";" << endl; … … 127 119 cur_indent -= CodeGenerator::tabsize; 128 120 129 output << indent<< "}";121 output << string( cur_indent, ' ' ) << "}"; 130 122 } // if 131 123 } … … 150 142 151 143 if ( ! memb.empty() ) { 152 output << "{" << endl;144 output << endl << "{" << endl; 153 145 154 146 cur_indent += CodeGenerator::tabsize; … … 156 148 ObjectDecl *obj = dynamic_cast< ObjectDecl* >( *i ); 157 149 assert( obj ); 158 output << indent<< mangleName( obj );150 output << string( cur_indent, ' ' ) << mangleName( obj ); 159 151 if ( obj->get_init() ) { 160 152 output << " = "; … … 166 158 cur_indent -= CodeGenerator::tabsize; 167 159 168 output << indent << "}";160 output << "}" << endl; 169 161 } // if 170 162 } … … 269 261 270 262 case OT_CONSTANT: 271 case OT_LABELADDRESS: 272 // there are no intrinsic definitions of 0/1 or label addresses as functions 263 // there are no intrinsic definitions of 0 or 1 as functions 273 264 assert( false ); 274 265 } … … 458 449 459 450 for ( std::list<Statement *>::iterator i = ks.begin(); i != ks.end(); i++) { 460 output << indent<< printLabels( (*i)->get_labels() );451 output << string( cur_indent, ' ' ) << printLabels( (*i)->get_labels() ); 461 452 (*i)->accept(*this ); 462 453 … … 468 459 cur_indent -= CodeGenerator::tabsize; 469 460 470 output << indent<< "}";461 output << string( cur_indent, ' ' ) << "}"; 471 462 } 472 463 … … 508 499 cur_indent -= CodeGenerator::tabsize; 509 500 510 output << indent<< "}";501 output << string( cur_indent, ' ' ) << "}"; 511 502 } 512 503 513 504 void CodeGenerator::visit( CaseStmt *caseStmt ) { 514 output << indent;505 output << string( cur_indent, ' ' ); 515 506 if ( caseStmt->isDefault()) { 516 507 output << "default"; … … 525 516 cur_indent += CodeGenerator::tabsize; 526 517 for ( std::list<Statement *>::iterator i = sts.begin(); i != sts.end(); i++) { 527 output << indent<< printLabels( (*i)->get_labels() ) ;518 output << string( cur_indent, ' ' ) << printLabels( (*i)->get_labels() ) ; 528 519 (*i)->accept(*this ); 529 520 output << endl; … … 578 569 whileStmt->get_body()->accept( *this ); 579 570 580 output << indent;571 output << string( cur_indent, ' ' ); 581 572 582 573 if ( whileStmt->get_isDoWhile() ) { … … 610 601 611 602 void CodeGenerator::visit( NullStmt *nullStmt ) { 612 //output << indent<< CodeGenerator::printLabels( nullStmt->get_labels() );603 //output << string( cur_indent, ' ' ) << CodeGenerator::printLabels( nullStmt->get_labels() ); 613 604 output << "/* null statement */ ;"; 614 605 }
Note:
See TracChangeset
for help on using the changeset viewer.