Changes in src/CodeGen/CodeGenerator.cc [2b7bf59:ab4bff5]
- File:
-
- 1 edited
-
src/CodeGen/CodeGenerator.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r2b7bf59 rab4bff5 287 287 void CodeGenerator::postvisit( TypeDecl * typeDecl ) { 288 288 assertf( ! genC, "TypeDecls should not reach code generation." ); 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() ) {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() ) { 294 294 output << " | { "; 295 genCommaList( typeDecl->get_assertions().begin(), typeDecl->get_assertions().end() ); 295 for ( DeclarationWithType * assert : typeDecl->assertions ) { 296 assert->accept( *visitor ); 297 output << "; "; 298 } 296 299 output << " }"; 297 300 } … … 946 949 output << ";"; 947 950 } 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 948 1014 949 1015 void CodeGenerator::postvisit( WhileStmt * whileStmt ) { … … 1024 1090 } 1025 1091 } // namespace CodeGen 1092 1093 1094 unsigned Indenter::tabsize = 2; 1026 1095 1027 1096 std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node ) {
Note:
See TracChangeset
for help on using the changeset viewer.