Changes in src/CodeGen/CodeGenerator.cc [da9d79b:bd06384]
- File:
-
- 1 edited
-
src/CodeGen/CodeGenerator.cc (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rda9d79b rbd06384 116 116 } 117 117 118 CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks , bool printExprTypes ) : indent( CodeGenerator::tabsize ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ), printExprTypes( printExprTypes ), endl( *this ) {}118 CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks ) : indent( CodeGenerator::tabsize ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ), endl( *this ) {} 119 119 120 120 string CodeGenerator::mangleName( DeclarationWithType * decl ) { … … 159 159 } 160 160 161 // *** Expression162 void CodeGenerator::previsit( Expression * node ) {163 previsit( (BaseSyntaxNode *)node );164 GuardAction( [this, node](){165 if ( printExprTypes ) {166 output << " /* " << genType( node->result, "", pretty, genC ) << " */ ";167 }168 } );169 }170 171 161 // *** Declarations 172 162 void CodeGenerator::postvisit( FunctionDecl * functionDecl ) { … … 213 203 214 204 void CodeGenerator::handleAggregate( AggregateDecl * aggDecl, const std::string & kind ) { 205 genAttributes( aggDecl->get_attributes() ); 206 215 207 if( ! aggDecl->get_parameters().empty() && ! genC ) { 216 208 // assertf( ! genC, "Aggregate type parameters should not reach code generation." ); … … 221 213 } 222 214 223 output << kind; 224 genAttributes( aggDecl->get_attributes() ); 225 output << aggDecl->get_name(); 215 output << kind << aggDecl->get_name(); 226 216 227 217 if ( aggDecl->has_body() ) { … … 308 298 output << " }"; 309 299 } 310 }311 312 void CodeGenerator::postvisit( StaticAssertDecl * assertDecl ) {313 output << "_Static_assert(";314 assertDecl->condition->accept( *visitor );315 output << ", ";316 assertDecl->message->accept( *visitor );317 output << ")";318 300 } 319 301 … … 596 578 output << ")"; 597 579 } // if 598 castExpr->arg->accept( *visitor ); 599 output << ")"; 600 } 601 602 void CodeGenerator::postvisit( KeywordCastExpr * castExpr ) { 603 assertf( ! genC, "KeywordCast should not reach code generation." ); 604 extension( castExpr ); 605 output << "((" << castExpr->targetString() << " &)"; 606 castExpr->arg->accept( *visitor ); 580 castExpr->get_arg()->accept( *visitor ); 607 581 output << ")"; 608 582 } … … 954 928 output << "continue"; 955 929 break; 956 case BranchStmt::FallThrough:957 case BranchStmt::FallThroughDefault:958 assertf( ! genC, "fallthru should not reach code generation." );959 output << "fallthru";960 break;961 930 } // switch 962 // print branch target for labelled break/continue/fallthru in debug mode963 if ( ! genC && branchStmt->get_type() != BranchStmt::Goto ) {964 if ( ! branchStmt->get_target().empty() ) {965 output << " " << branchStmt->get_target();966 } else if ( branchStmt->get_type() == BranchStmt::FallThrough ) {967 output << " default";968 }969 }970 931 output << ";"; 971 932 } … … 1145 1106 unsigned Indenter::tabsize = 2; 1146 1107 1147 std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node ) {1148 if ( node ) {1149 node->print( out );1150 } else {1151 out << "nullptr";1152 }1153 return out;1154 }1155 1156 1108 // Local Variables: // 1157 1109 // tab-width: 4 //
Note:
See TracChangeset
for help on using the changeset viewer.