Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/ExceptTranslate.cc

    rba3706f r7543dec  
    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
     
    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(
     233                        noLabels,
    234234                        new UntypedExpr( new NameExpr( "__cfaehm__rethrow_terminate" ) )
    235235                        ) );
     
    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.
     
    315315                        {
    316316                                VarExprReplacer::DeclMap mapping;
    317                                 mapping[ handler_decl ] = local_except;
     317                                mapping[ handler_decl ] = new VariableExpr( local_except );
    318318                                VarExprReplacer mapper( mapping );
    319                                 handler->get_body()->accept( mapper );
     319                                handler->body->acceptMutator( mapper );
    320320                        }
    321321
    322                         block->push_back( handler->get_body() );
    323                         handler->set_body( nullptr );
     322                        block->push_back( handler->body );
     323                        handler->body = nullptr;
    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
     
    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
     
    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 );
     
    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.