Ignore:
Timestamp:
Aug 17, 2017, 4:13:42 PM (7 years ago)
Author:
Andrew Beach <ajbeach@…>
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:
8f6dfe7
Parents:
21f0aa8
Message:

Updated exception tests to exception structures. Should be re-orginized still.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/ExceptTranslate.cc

    r21f0aa8 re9145a3  
    1010// Created On       : Wed Jun 14 16:49:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Aug  8 16:54:00 2017
    13 // Update Count     : 7
     12// Last Modified On : Thr Aug 17 15:48:00 2017
     13// Update Count     : 8
    1414//
    1515
     
    387387        }
    388388
     389        // TODO: Stoping the function from generating the 'return variable'
     390        // entirely would be cleaner. But this does get ride of warnings.
     391        CompoundStmt * set_and_ret(DeclarationWithType * var, Expression * val) {
     392                CompoundStmt * block = new CompoundStmt( noLabels );
     393                block->push_back( new ExprStmt( noLabels,
     394                        UntypedExpr::createAssign( new VariableExpr( var ), val )
     395                        ) );
     396                block->push_back( new ReturnStmt( noLabels,
     397                        new VariableExpr( var )
     398                        ) );
     399                return block;
     400        }
     401
    389402        FunctionDecl * ExceptionMutatorCore::create_terminate_match(
    390403                        CatchList &handlers ) {
     
    397410                FunctionType * func_type = match_func_t.clone();
    398411                DeclarationWithType * except_obj = func_type->get_parameters().back();
     412                DeclarationWithType * index_obj = func_type->get_returnVals().front();
    399413
    400414                // Index 1..{number of handlers}
     
    409423
    410424                        // Create new body.
    411                         handler->set_body( new ReturnStmt( noLabels,
     425                        handler->set_body( set_and_ret( index_obj,
    412426                                new ConstantExpr( Constant::from_int( index ) ) ) );
    413427
     
    417431                }
    418432
    419                 body->push_back( new ReturnStmt( noLabels, new ConstantExpr(
    420                         Constant::from_int( 0 ) ) ) );
     433                body->push_back( set_and_ret( index_obj,
     434                        new ConstantExpr( Constant::from_int( 0 ) ) ) );
    421435
    422436                return new FunctionDecl("match", Type::StorageClasses(),
     
    449463                CompoundStmt * body = new CompoundStmt( noLabels );
    450464
    451                 FunctionType * func_type = match_func_t.clone();
     465                FunctionType * func_type = handle_func_t.clone();
    452466                DeclarationWithType * except_obj = func_type->get_parameters().back();
     467                DeclarationWithType * bool_obj = func_type->get_returnVals().front();
    453468
    454469                CatchList::iterator it;
     
    463478                                handling_code->push_back( handler->get_body() );
    464479                        }
    465                         handling_code->push_back( new ReturnStmt( noLabels,
     480                        handling_code->push_back( set_and_ret( bool_obj,
    466481                                new ConstantExpr( Constant::from_bool( true ) ) ) );
    467482                        handler->set_body( handling_code );
     
    472487                }
    473488
    474                 body->push_back( new ReturnStmt( noLabels, new ConstantExpr(
    475                         Constant::from_bool( false ) ) ) );
     489                body->push_back( set_and_ret( bool_obj,
     490                        new ConstantExpr( Constant::from_bool( false ) ) ) );
    476491
    477492                return new FunctionDecl("handle", Type::StorageClasses(),
Note: See TracChangeset for help on using the changeset viewer.