Ignore:
Timestamp:
Dec 1, 2017, 2:55:41 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
a40d503
Parents:
882ad37 (diff), 5da9d6a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into with-statement

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/ExceptTranslate.cc

    r882ad37 r3ca540f  
    3030#include "SynTree/Expression.h"       // for UntypedExpr, ConstantExpr, Name...
    3131#include "SynTree/Initializer.h"      // for SingleInit, ListInit
    32 #include "SynTree/Label.h"            // for Label, noLabels
     32#include "SynTree/Label.h"            // for Label
    3333#include "SynTree/Mutator.h"          // for mutateAll
    3434#include "SynTree/Statement.h"        // for CompoundStmt, CatchStmt, ThrowStmt
     
    5757
    5858        void appendDeclStmt( CompoundStmt * block, Declaration * item ) {
    59                 block->push_back(new DeclStmt(noLabels, item));
     59                block->push_back(new DeclStmt(item));
    6060        }
    6161
     
    205205                throwStmt->set_expr( nullptr );
    206206                delete throwStmt;
    207                 return new ExprStmt( noLabels, call );
     207                return new ExprStmt( call );
    208208        }
    209209
     
    211211                        ThrowStmt *throwStmt ) {
    212212                // __throw_terminate( `throwStmt->get_name()` ); }
    213                 return create_given_throw( "__cfaehm__throw_terminate", throwStmt );
     213                return create_given_throw( "__cfaabi_ehm__throw_terminate", throwStmt );
    214214        }
    215215
     
    220220                assert( handler_except_decl );
    221221
    222                 CompoundStmt * result = new CompoundStmt( throwStmt->get_labels() );
    223                 result->push_back( new ExprStmt( noLabels, UntypedExpr::createAssign(
     222                CompoundStmt * result = new CompoundStmt();
     223                result->labels =  throwStmt->labels;
     224                result->push_back( new ExprStmt( UntypedExpr::createAssign(
    224225                        nameOf( handler_except_decl ),
    225226                        new ConstantExpr( Constant::null(
     
    231232                        ) ) );
    232233                result->push_back( new ExprStmt(
    233                         noLabels,
    234                         new UntypedExpr( new NameExpr( "__cfaehm__rethrow_terminate" ) )
     234                        new UntypedExpr( new NameExpr( "__cfaabi_ehm__rethrow_terminate" ) )
    235235                        ) );
    236236                delete throwStmt;
     
    241241                        ThrowStmt *throwStmt ) {
    242242                // __throw_resume( `throwStmt->get_name` );
    243                 return create_given_throw( "__cfaehm__throw_resume", throwStmt );
     243                return create_given_throw( "__cfaabi_ehm__throw_resume", throwStmt );
    244244        }
    245245
     
    248248                // return false;
    249249                Statement * result = new ReturnStmt(
    250                         throwStmt->get_labels(),
    251250                        new ConstantExpr( Constant::from_bool( false ) )
    252251                        );
     252                result->labels = throwStmt->labels;
    253253                delete throwStmt;
    254254                return result;
     
    291291                        // }
    292292                        // return;
    293                         CompoundStmt * block = new CompoundStmt( noLabels );
     293                        CompoundStmt * block = new CompoundStmt();
    294294
    295295                        // Just copy the exception value. (Post Validation)
     
    304304                                        ) })
    305305                                );
    306                         block->push_back( new DeclStmt( noLabels, local_except ) );
     306                        block->push_back( new DeclStmt( local_except ) );
    307307
    308308                        // Add the cleanup attribute.
    309309                        local_except->get_attributes().push_back( new Attribute(
    310310                                "cleanup",
    311                                 { new NameExpr( "__cfaehm__cleanup_terminate" ) }
     311                                { new NameExpr( "__cfaabi_ehm__cleanup_terminate" ) }
    312312                                ) );
    313313
     
    324324
    325325                        std::list<Statement *> caseBody
    326                                         { block, new ReturnStmt( noLabels, nullptr ) };
     326                                        { block, new ReturnStmt( nullptr ) };
    327327                        handler_wrappers.push_back( new CaseStmt(
    328                                 noLabels,
    329328                                new ConstantExpr( Constant::from_int( index ) ),
    330329                                caseBody
     
    340339
    341340                SwitchStmt * handler_lookup = new SwitchStmt(
    342                         noLabels,
    343341                        nameOf( index_obj ),
    344342                        stmt_handlers
    345343                        );
    346                 CompoundStmt * body = new CompoundStmt( noLabels );
     344                CompoundStmt * body = new CompoundStmt();
    347345                body->push_back( handler_lookup );
    348346
     
    363361                // }
    364362
    365                 CompoundStmt * block = new CompoundStmt( noLabels );
     363                CompoundStmt * block = new CompoundStmt();
    366364
    367365                // Local Declaration
     
    369367                        dynamic_cast<ObjectDecl *>( modded_handler->get_decl() );
    370368                assert( local_except );
    371                 block->push_back( new DeclStmt( noLabels, local_except ) );
     369                block->push_back( new DeclStmt( local_except ) );
    372370
    373371                // Check for type match.
     
    381379                }
    382380                // Construct the match condition.
    383                 block->push_back( new IfStmt( noLabels,
     381                block->push_back( new IfStmt(
    384382                        cond, modded_handler->get_body(), nullptr ) );
    385383
     
    397395                // }
    398396
    399                 CompoundStmt * body = new CompoundStmt( noLabels );
     397                CompoundStmt * body = new CompoundStmt();
    400398
    401399                FunctionType * func_type = match_func_t.clone();
     
    413411
    414412                        // Create new body.
    415                         handler->set_body( new ReturnStmt( noLabels,
     413                        handler->set_body( new ReturnStmt(
    416414                                new ConstantExpr( Constant::from_int( index ) ) ) );
    417415
     
    421419                }
    422420
    423                 body->push_back( new ReturnStmt( noLabels,
     421                body->push_back( new ReturnStmt(
    424422                        new ConstantExpr( Constant::from_int( 0 ) ) ) );
    425423
     
    432430                        FunctionDecl * terminate_catch,
    433431                        FunctionDecl * terminate_match ) {
    434                 // { __cfaehm__try_terminate(`try`, `catch`, `match`); }
     432                // { __cfaabi_ehm__try_terminate(`try`, `catch`, `match`); }
    435433
    436434                UntypedExpr * caller = new UntypedExpr( new NameExpr(
    437                         "__cfaehm__try_terminate" ) );
     435                        "__cfaabi_ehm__try_terminate" ) );
    438436                std::list<Expression *>& args = caller->get_args();
    439437                args.push_back( nameOf( try_wrapper ) );
     
    441439                args.push_back( nameOf( terminate_match ) );
    442440
    443                 CompoundStmt * callStmt = new CompoundStmt( noLabels );
    444                 callStmt->push_back( new ExprStmt( noLabels, caller ) );
     441                CompoundStmt * callStmt = new CompoundStmt();
     442                callStmt->push_back( new ExprStmt( caller ) );
    445443                return callStmt;
    446444        }
     
    451449                //     HANDLER WRAPPERS { `hander->body`; return true; }
    452450                // }
    453                 CompoundStmt * body = new CompoundStmt( noLabels );
     451                CompoundStmt * body = new CompoundStmt();
    454452
    455453                FunctionType * func_type = handle_func_t.clone();
     
    464462                                dynamic_cast<CompoundStmt*>( handler->get_body() );
    465463                        if ( ! handling_code ) {
    466                                 handling_code = new CompoundStmt( noLabels );
     464                                handling_code = new CompoundStmt();
    467465                                handling_code->push_back( handler->get_body() );
    468466                        }
    469                         handling_code->push_back( new ReturnStmt( noLabels,
     467                        handling_code->push_back( new ReturnStmt(
    470468                                new ConstantExpr( Constant::from_bool( true ) ) ) );
    471469                        handler->set_body( handling_code );
     
    476474                }
    477475
    478                 body->push_back( new ReturnStmt( noLabels,
     476                body->push_back( new ReturnStmt(
    479477                        new ConstantExpr( Constant::from_bool( false ) ) ) );
    480478
     
    486484                        Statement * wraps,
    487485                        FunctionDecl * resume_handler ) {
    488                 CompoundStmt * body = new CompoundStmt( noLabels );
     486                CompoundStmt * body = new CompoundStmt();
    489487
    490488                // struct __try_resume_node __resume_node
    491                 //      __attribute__((cleanup( __cfaehm__try_resume_cleanup )));
     489                //      __attribute__((cleanup( __cfaabi_ehm__try_resume_cleanup )));
    492490                // ** unwinding of the stack here could cause problems **
    493491                // ** however I don't think that can happen currently **
    494                 // __cfaehm__try_resume_setup( &__resume_node, resume_handler );
     492                // __cfaabi_ehm__try_resume_setup( &__resume_node, resume_handler );
    495493
    496494                std::list< Attribute * > attributes;
     
    498496                        std::list< Expression * > attr_params;
    499497                        attr_params.push_back( new NameExpr(
    500                                 "__cfaehm__try_resume_cleanup" ) );
     498                                "__cfaabi_ehm__try_resume_cleanup" ) );
    501499                        attributes.push_back( new Attribute( "cleanup", attr_params ) );
    502500                }
     
    517515
    518516                UntypedExpr *setup = new UntypedExpr( new NameExpr(
    519                         "__cfaehm__try_resume_setup" ) );
     517                        "__cfaabi_ehm__try_resume_setup" ) );
    520518                setup->get_args().push_back( new AddressExpr( nameOf( obj ) ) );
    521519                setup->get_args().push_back( nameOf( resume_handler ) );
    522520
    523                 body->push_back( new ExprStmt( noLabels, setup ) );
     521                body->push_back( new ExprStmt( setup ) );
    524522
    525523                body->push_back( wraps );
     
    542540        ObjectDecl * ExceptionMutatorCore::create_finally_hook(
    543541                        FunctionDecl * finally_wrapper ) {
    544                 // struct __cfaehm__cleanup_hook __finally_hook
     542                // struct __cfaabi_ehm__cleanup_hook __finally_hook
    545543                //      __attribute__((cleanup( finally_wrapper )));
    546544
     
    596594                        // Skip children?
    597595                        return;
    598                 } else if ( structDecl->get_name() == "__cfaehm__base_exception_t" ) {
     596                } else if ( structDecl->get_name() == "__cfaabi_ehm__base_exception_t" ) {
    599597                        assert( nullptr == except_decl );
    600598                        except_decl = structDecl;
    601599                        init_func_types();
    602                 } else if ( structDecl->get_name() == "__cfaehm__try_resume_node" ) {
     600                } else if ( structDecl->get_name() == "__cfaabi_ehm__try_resume_node" ) {
    603601                        assert( nullptr == node_decl );
    604602                        node_decl = structDecl;
    605                 } else if ( structDecl->get_name() == "__cfaehm__cleanup_hook" ) {
     603                } else if ( structDecl->get_name() == "__cfaabi_ehm__cleanup_hook" ) {
    606604                        assert( nullptr == hook_decl );
    607605                        hook_decl = structDecl;
     
    646644                // Generate a prefix for the function names?
    647645
    648                 CompoundStmt * block = new CompoundStmt( noLabels );
     646                CompoundStmt * block = new CompoundStmt();
    649647                CompoundStmt * inner = take_try_block( tryStmt );
    650648
Note: See TracChangeset for help on using the changeset viewer.