Changeset e4ea10b7
- Timestamp:
- Sep 27, 2017, 4:11:50 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 12914e9, 5ea7a22
- Parents:
- 9fe39530
- Location:
- src/CodeGen
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r9fe39530 re4ea10b7 943 943 output << ";"; 944 944 } 945 void CodeGenerator::postvisit( CatchStmt * stmt ) { 946 assertf( ! genC, "Catch statements should not reach code generation." ); 947 948 output << ((stmt->get_kind() == CatchStmt::Terminate) ? 949 "catch" : "catchResume"); 950 output << "( "; 951 stmt->decl->accept( *visitor ); 952 output << " ) "; 953 954 if( stmt->cond ) { 955 output << "if/when(?) ("; 956 stmt->cond->accept( *visitor ); 957 output << ") "; 958 } 959 stmt->body->accept( *visitor ); 960 } 961 962 void CodeGenerator::postvisit( WaitForStmt * stmt ) { 963 assertf( ! genC, "Waitfor statements should not reach code generation." ); 964 965 bool first = true; 966 for( auto & clause : stmt->clauses ) { 967 if(first) { output << "or "; first = false; } 968 if( clause.condition ) { 969 output << "when("; 970 stmt->timeout.condition->accept( *visitor ); 971 output << ") "; 972 } 973 output << "waitfor("; 974 clause.target.function->accept( *visitor ); 975 for( Expression * expr : clause.target.arguments ) { 976 output << ","; 977 expr->accept( *visitor ); 978 } 979 output << ") "; 980 clause.statement->accept( *visitor ); 981 } 982 983 if( stmt->timeout.statement ) { 984 output << "or "; 985 if( stmt->timeout.condition ) { 986 output << "when("; 987 stmt->timeout.condition->accept( *visitor ); 988 output << ") "; 989 } 990 output << "timeout("; 991 stmt->timeout.time->accept( *visitor ); 992 output << ") "; 993 stmt->timeout.statement->accept( *visitor ); 994 } 995 996 if( stmt->orelse.statement ) { 997 output << "or "; 998 if( stmt->orelse.condition ) { 999 output << "when("; 1000 stmt->orelse.condition->accept( *visitor ); 1001 output << ")"; 1002 } 1003 output << "else "; 1004 stmt->orelse.statement->accept( *visitor ); 1005 } 1006 } 1007 945 1008 946 1009 void CodeGenerator::postvisit( WhileStmt * whileStmt ) { -
src/CodeGen/CodeGenerator.h
r9fe39530 re4ea10b7 100 100 void postvisit( ReturnStmt * ); 101 101 void postvisit( ThrowStmt * ); 102 void postvisit( CatchStmt * ); 103 void postvisit( WaitForStmt * ); 102 104 void postvisit( WhileStmt * ); 103 105 void postvisit( ForStmt * );
Note: See TracChangeset
for help on using the changeset viewer.