Changes in src/CodeGen/CodeGenerator.cc [7f5566b:145f1fc]
- File:
-
- 1 edited
-
src/CodeGen/CodeGenerator.cc (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r7f5566b r145f1fc 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Jul 27 14:40:06201513 // Update Count : 21811 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jul 15 14:47:42 2015 13 // Update Count : 177 14 14 // 15 15 … … 52 52 } 53 53 54 CodeGenerator::CodeGenerator( std::ostream &os ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ) { }54 CodeGenerator::CodeGenerator( std::ostream &os ) : indent(*this), cur_indent( 0 ), insideFunction( false ), output( os ) { } 55 55 56 56 CodeGenerator::CodeGenerator( std::ostream &os, std::string init, int indentation, bool infunp ) 57 : indent( *this), cur_indent( indentation ), insideFunction( infunp ), output( os ) {57 : indent(*this), cur_indent( indentation ), insideFunction( infunp ), output( os ) { 58 58 //output << std::string( init ); 59 59 } 60 60 61 61 CodeGenerator::CodeGenerator( std::ostream &os, char *init, int indentation, bool infunp ) 62 : indent( *this), cur_indent( indentation ), insideFunction( infunp ), output( os ) {62 : indent(*this), cur_indent( indentation ), insideFunction( infunp ), output( os ) { 63 63 //output << std::string( init ); 64 64 } … … 91 91 // acceptAll( functionDecl->get_oldDecls(), *this ); 92 92 if ( functionDecl->get_statements() ) { 93 functionDecl->get_statements()->accept( *this );93 functionDecl->get_statements()->accept(*this ); 94 94 } // if 95 95 } … … 121 121 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++) { 122 122 output << indent; 123 (*i)->accept( *this );123 (*i)->accept(*this ); 124 124 output << ";" << endl; 125 125 } … … 159 159 if ( obj->get_init() ) { 160 160 output << " = "; 161 obj->get_init()->accept( *this );161 obj->get_init()->accept(*this ); 162 162 } // if 163 163 output << "," << endl; … … 450 450 void CodeGenerator::visit( TypeExpr *typeExpr ) {} 451 451 452 void CodeGenerator::visit( AsmExpr *asmExpr ) {453 if ( asmExpr->get_inout() ) {454 output << "[ ";455 asmExpr->get_inout()->accept( *this );456 output << " ] ";457 } // if458 asmExpr->get_constraint()->accept( *this );459 output << " ( ";460 asmExpr->get_operand()->accept( *this );461 output << " )";462 }463 464 452 //*** Statements 465 453 void CodeGenerator::visit( CompoundStmt *compoundStmt ) { … … 469 457 cur_indent += CodeGenerator::tabsize; 470 458 471 for ( std::list<Statement *>::iterator i = ks.begin(); i != ks.end(); i++ ) {459 for ( std::list<Statement *>::iterator i = ks.begin(); i != ks.end(); i++) { 472 460 output << indent << printLabels( (*i)->get_labels() ); 473 (*i)->accept( *this );461 (*i)->accept(*this ); 474 462 475 463 output << endl; … … 495 483 } 496 484 497 void CodeGenerator::visit( AsmStmt *asmStmt ) {498 output << "asm ";499 if ( asmStmt->get_voltile() ) output << "volatile ";500 if ( ! asmStmt->get_gotolabels().empty() ) output << "goto ";501 output << "( ";502 if ( asmStmt->get_instruction() ) asmStmt->get_instruction()->accept( *this );503 output << " : ";504 genCommaList( asmStmt->get_output().begin(), asmStmt->get_output().end() );505 output << " : ";506 genCommaList( asmStmt->get_input().begin(), asmStmt->get_input().end() );507 output << " : ";508 genCommaList( asmStmt->get_clobber().begin(), asmStmt->get_clobber().end() );509 if ( ! asmStmt->get_gotolabels().empty() ) {510 output << " : ";511 for ( std::list<Label>::iterator begin = asmStmt->get_gotolabels().begin();; ) {512 output << *begin++;513 if ( begin == asmStmt->get_gotolabels().end() ) break;514 output << ", ";515 } // for516 } // if517 output << " );" ;518 }519 520 485 void CodeGenerator::visit( IfStmt *ifStmt ) { 521 output << "if ( ";522 ifStmt->get_condition()->accept( *this );523 output << " ) ";524 525 ifStmt->get_thenPart()->accept( *this );486 output << "if ("; 487 ifStmt->get_condition()->accept(*this ); 488 output << ") "; 489 490 ifStmt->get_thenPart()->accept(*this ); 526 491 527 492 if ( ifStmt->get_elsePart() != 0) { 528 493 output << " else "; 529 ifStmt->get_elsePart()->accept( *this );494 ifStmt->get_elsePart()->accept(*this ); 530 495 } // if 531 496 } 532 497 533 498 void CodeGenerator::visit( SwitchStmt *switchStmt ) { 534 output << "switch ( " ;535 switchStmt->get_condition()->accept( *this );536 output << " ) ";499 output << "switch (" ; 500 switchStmt->get_condition()->accept(*this ); 501 output << ") "; 537 502 538 503 output << "{" << std::endl; … … 552 517 } else { 553 518 output << "case "; 554 caseStmt->get_condition()->accept( *this );519 caseStmt->get_condition()->accept(*this ); 555 520 } // if 556 521 output << ":\n"; … … 561 526 for ( std::list<Statement *>::iterator i = sts.begin(); i != sts.end(); i++) { 562 527 output << indent << printLabels( (*i)->get_labels() ) ; 563 (*i)->accept( *this );528 (*i)->accept(*this ); 564 529 output << endl; 565 530 } … … 605 570 else { 606 571 output << "while (" ; 607 whileStmt->get_condition()->accept( *this );572 whileStmt->get_condition()->accept(*this ); 608 573 output << ")"; 609 574 } // if … … 617 582 if ( whileStmt->get_isDoWhile() ) { 618 583 output << " while (" ; 619 whileStmt->get_condition()->accept( *this );584 whileStmt->get_condition()->accept(*this ); 620 585 output << ");"; 621 586 } // if
Note:
See TracChangeset
for help on using the changeset viewer.