Changes in src/CodeGen/CodeGenerator.cc [ab4bff5:2b7bf59]
- File:
-
- 1 edited
-
src/CodeGen/CodeGenerator.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rab4bff5 r2b7bf59 287 287 void CodeGenerator::postvisit( TypeDecl * typeDecl ) { 288 288 assertf( ! genC, "TypeDecls should not reach code generation." ); 289 output << typeDecl->genTypeString() << " " << typeDecl-> name;290 if ( typeDecl->get_kind() != TypeDecl::Any && typeDecl-> sized) {291 output << " | sized(" << typeDecl-> name<< ")";292 } 293 if ( ! typeDecl-> assertions.empty() ) {289 output << typeDecl->genTypeString() << " " << typeDecl->get_name(); 290 if ( typeDecl->get_kind() != TypeDecl::Any && typeDecl->get_sized() ) { 291 output << " | sized(" << typeDecl->get_name() << ")"; 292 } 293 if ( ! typeDecl->get_assertions().empty() ) { 294 294 output << " | { "; 295 for ( DeclarationWithType * assert : typeDecl->assertions ) { 296 assert->accept( *visitor ); 297 output << "; "; 298 } 295 genCommaList( typeDecl->get_assertions().begin(), typeDecl->get_assertions().end() ); 299 296 output << " }"; 300 297 } … … 949 946 output << ";"; 950 947 } 951 void CodeGenerator::postvisit( CatchStmt * stmt ) {952 assertf( ! genC, "Catch statements should not reach code generation." );953 954 output << ((stmt->get_kind() == CatchStmt::Terminate) ?955 "catch" : "catchResume");956 output << "( ";957 stmt->decl->accept( *visitor );958 output << " ) ";959 960 if( stmt->cond ) {961 output << "if/when(?) (";962 stmt->cond->accept( *visitor );963 output << ") ";964 }965 stmt->body->accept( *visitor );966 }967 968 void CodeGenerator::postvisit( WaitForStmt * stmt ) {969 assertf( ! genC, "Waitfor statements should not reach code generation." );970 971 bool first = true;972 for( auto & clause : stmt->clauses ) {973 if(first) { output << "or "; first = false; }974 if( clause.condition ) {975 output << "when(";976 stmt->timeout.condition->accept( *visitor );977 output << ") ";978 }979 output << "waitfor(";980 clause.target.function->accept( *visitor );981 for( Expression * expr : clause.target.arguments ) {982 output << ",";983 expr->accept( *visitor );984 }985 output << ") ";986 clause.statement->accept( *visitor );987 }988 989 if( stmt->timeout.statement ) {990 output << "or ";991 if( stmt->timeout.condition ) {992 output << "when(";993 stmt->timeout.condition->accept( *visitor );994 output << ") ";995 }996 output << "timeout(";997 stmt->timeout.time->accept( *visitor );998 output << ") ";999 stmt->timeout.statement->accept( *visitor );1000 }1001 1002 if( stmt->orelse.statement ) {1003 output << "or ";1004 if( stmt->orelse.condition ) {1005 output << "when(";1006 stmt->orelse.condition->accept( *visitor );1007 output << ")";1008 }1009 output << "else ";1010 stmt->orelse.statement->accept( *visitor );1011 }1012 }1013 1014 948 1015 949 void CodeGenerator::postvisit( WhileStmt * whileStmt ) { … … 1090 1024 } 1091 1025 } // namespace CodeGen 1092 1093 1094 unsigned Indenter::tabsize = 2;1095 1026 1096 1027 std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node ) {
Note:
See TracChangeset
for help on using the changeset viewer.