Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/ExceptTranslate.cc

    rba3706f r36982fc  
    3030#include "SynTree/Expression.h"       // for UntypedExpr, ConstantExpr, Name...
    3131#include "SynTree/Initializer.h"      // for SingleInit, ListInit
    32 #include "SynTree/Label.h"            // for Label
     32#include "SynTree/Label.h"            // for Label, noLabels
    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(item));
     59                block->push_back(new DeclStmt(noLabels, item));
    6060        }
    6161
     
    205205                throwStmt->set_expr( nullptr );
    206206                delete throwStmt;
    207                 return new ExprStmt( call );
     207                return new ExprStmt( noLabels, 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();
    223                 result->labels =  throwStmt->labels;
    224                 result->push_back( new ExprStmt( UntypedExpr::createAssign(
     222                CompoundStmt * result = new CompoundStmt( throwStmt->get_labels() );
     223                result->push_back( new ExprStmt( noLabels, UntypedExpr::createAssign(
    225224                        nameOf( handler_except_decl ),
    226225                        new ConstantExpr( Constant::null(
     
    232231                        ) ) );
    233232                result->push_back( new ExprStmt(
    234                         new UntypedExpr( new NameExpr( "__cfaehm__rethrow_terminate" ) )
     233                        noLabels,
     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(),
    250251                        new ConstantExpr( Constant::from_bool( false ) )
    251252                        );
    252                 result->labels = throwStmt->labels;
    253253                delete throwStmt;
    254254                return result;
     
    291291                        // }
    292292                        // return;
    293                         CompoundStmt * block = new CompoundStmt();
     293                        CompoundStmt * block = new CompoundStmt( noLabels );
    294294
    295295                        // Just copy the exception value. (Post Validation)
     
    304304                                        ) })
    305305                                );
    306                         block->push_back( new DeclStmt( local_except ) );
     306                        block->push_back( new DeclStmt( noLabels, 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( nullptr ) };
     326                                        { block, new ReturnStmt( noLabels, nullptr ) };
    327327                        handler_wrappers.push_back( new CaseStmt(
     328                                noLabels,
    328329                                new ConstantExpr( Constant::from_int( index ) ),
    329330                                caseBody
     
    339340
    340341                SwitchStmt * handler_lookup = new SwitchStmt(
     342                        noLabels,
    341343                        nameOf( index_obj ),
    342344                        stmt_handlers
    343345                        );
    344                 CompoundStmt * body = new CompoundStmt();
     346                CompoundStmt * body = new CompoundStmt( noLabels );
    345347                body->push_back( handler_lookup );
    346348
     
    361363                // }
    362364
    363                 CompoundStmt * block = new CompoundStmt();
     365                CompoundStmt * block = new CompoundStmt( noLabels );
    364366
    365367                // Local Declaration
     
    367369                        dynamic_cast<ObjectDecl *>( modded_handler->get_decl() );
    368370                assert( local_except );
    369                 block->push_back( new DeclStmt( local_except ) );
     371                block->push_back( new DeclStmt( noLabels, local_except ) );
    370372
    371373                // Check for type match.
     
    379381                }
    380382                // Construct the match condition.
    381                 block->push_back( new IfStmt(
     383                block->push_back( new IfStmt( noLabels,
    382384                        cond, modded_handler->get_body(), nullptr ) );
    383385
     
    395397                // }
    396398
    397                 CompoundStmt * body = new CompoundStmt();
     399                CompoundStmt * body = new CompoundStmt( noLabels );
    398400
    399401                FunctionType * func_type = match_func_t.clone();
     
    411413
    412414                        // Create new body.
    413                         handler->set_body( new ReturnStmt(
     415                        handler->set_body( new ReturnStmt( noLabels,
    414416                                new ConstantExpr( Constant::from_int( index ) ) ) );
    415417
     
    419421                }
    420422
    421                 body->push_back( new ReturnStmt(
     423                body->push_back( new ReturnStmt( noLabels,
    422424                        new ConstantExpr( Constant::from_int( 0 ) ) ) );
    423425
     
    430432                        FunctionDecl * terminate_catch,
    431433                        FunctionDecl * terminate_match ) {
    432                 // { __cfaehm__try_terminate(`try`, `catch`, `match`); }
     434                // { __cfaabi_ehm__try_terminate(`try`, `catch`, `match`); }
    433435
    434436                UntypedExpr * caller = new UntypedExpr( new NameExpr(
    435                         "__cfaehm__try_terminate" ) );
     437                        "__cfaabi_ehm__try_terminate" ) );
    436438                std::list<Expression *>& args = caller->get_args();
    437439                args.push_back( nameOf( try_wrapper ) );
     
    439441                args.push_back( nameOf( terminate_match ) );
    440442
    441                 CompoundStmt * callStmt = new CompoundStmt();
    442                 callStmt->push_back( new ExprStmt( caller ) );
     443                CompoundStmt * callStmt = new CompoundStmt( noLabels );
     444                callStmt->push_back( new ExprStmt( noLabels, caller ) );
    443445                return callStmt;
    444446        }
     
    449451                //     HANDLER WRAPPERS { `hander->body`; return true; }
    450452                // }
    451                 CompoundStmt * body = new CompoundStmt();
     453                CompoundStmt * body = new CompoundStmt( noLabels );
    452454
    453455                FunctionType * func_type = handle_func_t.clone();
     
    462464                                dynamic_cast<CompoundStmt*>( handler->get_body() );
    463465                        if ( ! handling_code ) {
    464                                 handling_code = new CompoundStmt();
     466                                handling_code = new CompoundStmt( noLabels );
    465467                                handling_code->push_back( handler->get_body() );
    466468                        }
    467                         handling_code->push_back( new ReturnStmt(
     469                        handling_code->push_back( new ReturnStmt( noLabels,
    468470                                new ConstantExpr( Constant::from_bool( true ) ) ) );
    469471                        handler->set_body( handling_code );
     
    474476                }
    475477
    476                 body->push_back( new ReturnStmt(
     478                body->push_back( new ReturnStmt( noLabels,
    477479                        new ConstantExpr( Constant::from_bool( false ) ) ) );
    478480
     
    484486                        Statement * wraps,
    485487                        FunctionDecl * resume_handler ) {
    486                 CompoundStmt * body = new CompoundStmt();
     488                CompoundStmt * body = new CompoundStmt( noLabels );
    487489
    488490                // struct __try_resume_node __resume_node
    489                 //      __attribute__((cleanup( __cfaehm__try_resume_cleanup )));
     491                //      __attribute__((cleanup( __cfaabi_ehm__try_resume_cleanup )));
    490492                // ** unwinding of the stack here could cause problems **
    491493                // ** however I don't think that can happen currently **
    492                 // __cfaehm__try_resume_setup( &__resume_node, resume_handler );
     494                // __cfaabi_ehm__try_resume_setup( &__resume_node, resume_handler );
    493495
    494496                std::list< Attribute * > attributes;
     
    496498                        std::list< Expression * > attr_params;
    497499                        attr_params.push_back( new NameExpr(
    498                                 "__cfaehm__try_resume_cleanup" ) );
     500                                "__cfaabi_ehm__try_resume_cleanup" ) );
    499501                        attributes.push_back( new Attribute( "cleanup", attr_params ) );
    500502                }
     
    515517
    516518                UntypedExpr *setup = new UntypedExpr( new NameExpr(
    517                         "__cfaehm__try_resume_setup" ) );
     519                        "__cfaabi_ehm__try_resume_setup" ) );
    518520                setup->get_args().push_back( new AddressExpr( nameOf( obj ) ) );
    519521                setup->get_args().push_back( nameOf( resume_handler ) );
    520522
    521                 body->push_back( new ExprStmt( setup ) );
     523                body->push_back( new ExprStmt( noLabels, setup ) );
    522524
    523525                body->push_back( wraps );
     
    540542        ObjectDecl * ExceptionMutatorCore::create_finally_hook(
    541543                        FunctionDecl * finally_wrapper ) {
    542                 // struct __cfaehm__cleanup_hook __finally_hook
     544                // struct __cfaabi_ehm__cleanup_hook __finally_hook
    543545                //      __attribute__((cleanup( finally_wrapper )));
    544546
     
    594596                        // Skip children?
    595597                        return;
    596                 } else if ( structDecl->get_name() == "__cfaehm__base_exception_t" ) {
     598                } else if ( structDecl->get_name() == "__cfaabi_ehm__base_exception_t" ) {
    597599                        assert( nullptr == except_decl );
    598600                        except_decl = structDecl;
    599601                        init_func_types();
    600                 } else if ( structDecl->get_name() == "__cfaehm__try_resume_node" ) {
     602                } else if ( structDecl->get_name() == "__cfaabi_ehm__try_resume_node" ) {
    601603                        assert( nullptr == node_decl );
    602604                        node_decl = structDecl;
    603                 } else if ( structDecl->get_name() == "__cfaehm__cleanup_hook" ) {
     605                } else if ( structDecl->get_name() == "__cfaabi_ehm__cleanup_hook" ) {
    604606                        assert( nullptr == hook_decl );
    605607                        hook_decl = structDecl;
     
    644646                // Generate a prefix for the function names?
    645647
    646                 CompoundStmt * block = new CompoundStmt();
     648                CompoundStmt * block = new CompoundStmt( noLabels );
    647649                CompoundStmt * inner = take_try_block( tryStmt );
    648650
Note: See TracChangeset for help on using the changeset viewer.