Changeset 66ba544
- Timestamp:
- May 21, 2020, 1:43:59 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 99fea48
- Parents:
- 8ad5752
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/ExceptTranslate.cc
r8ad5752 r66ba544 10 10 // Created On : Wed Jun 14 16:49:00 2017 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : T ue May 19 16:46:00 202013 // Update Count : 1 412 // Last Modified On : Thr May 21 13:18:00 2020 13 // Update Count : 15 14 14 // 15 15 … … 182 182 } 183 183 184 class TryMutatorCore : public WithGuards { 185 enum Context { NoHandler, TerHandler, ResHandler }; 186 187 // Also need to handle goto, break & continue. 188 // They need to be cut off in a ResHandler, until we enter another 189 // loop, switch or the goto stays within the function. 190 191 Context cur_context; 192 193 // The current (innermost) termination handler exception declaration. 194 ObjectDecl * handler_except_decl; 195 184 class TryMutatorCore { 196 185 // The built in types used in translation. 197 186 StructDecl * except_decl; … … 234 223 public: 235 224 TryMutatorCore() : 236 cur_context( NoHandler ),237 handler_except_decl( nullptr ),238 225 except_decl( nullptr ), node_decl( nullptr ), hook_decl( nullptr ), 239 226 try_func_t( noQualifiers, false ), … … 244 231 {} 245 232 246 void premutate( CatchStmt *catchStmt );247 233 void premutate( StructDecl *structDecl ); 248 234 Statement * postmutate( ThrowStmt *throwStmt ); … … 579 565 FunctionDecl * TryMutatorCore::create_finally_wrapper( 580 566 TryStmt * tryStmt ) { 581 // void finally() { <finally code>}567 // void finally() { `finally->block` } 582 568 FinallyStmt * finally = tryStmt->get_finally(); 583 569 CompoundStmt * body = finally->get_block(); … … 618 604 619 605 // Visiting/Mutating Functions 620 void TryMutatorCore::premutate( CatchStmt *catchStmt ) {621 // Validate the Statement's form.622 ObjectDecl * decl = dynamic_cast<ObjectDecl *>( catchStmt->get_decl() );623 if ( decl && true /* check decl->get_type() */ ) {624 // Pass.625 } else if ( CatchStmt::Terminate == catchStmt->get_kind() ) {626 SemanticError(catchStmt->location, "catch must have exception type");627 } else {628 SemanticError(catchStmt->location, "catchResume must have exception type");629 }630 631 // Track the handler context.632 GuardValue( cur_context );633 if ( CatchStmt::Terminate == catchStmt->get_kind() ) {634 cur_context = TerHandler;635 636 GuardValue( handler_except_decl );637 handler_except_decl = decl;638 } else {639 cur_context = ResHandler;640 }641 }642 643 606 void TryMutatorCore::premutate( StructDecl *structDecl ) { 644 607 if ( !structDecl->has_body() ) {
Note: See TracChangeset
for help on using the changeset viewer.