Changeset 66ba544


Ignore:
Timestamp:
May 21, 2020, 1:43:59 PM (4 years ago)
Author:
Andrew Beach <ajbeach@…>
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
Message:

Dead code elimination in the try block translation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/ExceptTranslate.cc

    r8ad5752 r66ba544  
    1010// Created On       : Wed Jun 14 16:49:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tue May 19 16:46:00 2020
    13 // Update Count     : 14
     12// Last Modified On : Thr May 21 13:18:00 2020
     13// Update Count     : 15
    1414//
    1515
     
    182182        }
    183183
    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 {
    196185                // The built in types used in translation.
    197186                StructDecl * except_decl;
     
    234223        public:
    235224                TryMutatorCore() :
    236                         cur_context( NoHandler ),
    237                         handler_except_decl( nullptr ),
    238225                        except_decl( nullptr ), node_decl( nullptr ), hook_decl( nullptr ),
    239226                        try_func_t( noQualifiers, false ),
     
    244231                {}
    245232
    246                 void premutate( CatchStmt *catchStmt );
    247233                void premutate( StructDecl *structDecl );
    248234                Statement * postmutate( ThrowStmt *throwStmt );
     
    579565        FunctionDecl * TryMutatorCore::create_finally_wrapper(
    580566                        TryStmt * tryStmt ) {
    581                 // void finally() { <finally code> }
     567                // void finally() { `finally->block` }
    582568                FinallyStmt * finally = tryStmt->get_finally();
    583569                CompoundStmt * body = finally->get_block();
     
    618604
    619605        // 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 
    643606        void TryMutatorCore::premutate( StructDecl *structDecl ) {
    644607                if ( !structDecl->has_body() ) {
Note: See TracChangeset for help on using the changeset viewer.