Changeset 8f6dfe7


Ignore:
Timestamp:
Aug 17, 2017, 5:22:30 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:
274ce8c
Parents:
e9145a3
Message:

Cleaned up the generated exception functions a bit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ControlStruct/ExceptTranslate.cc

    re9145a3 r8f6dfe7  
    1010// Created On       : Wed Jun 14 16:49:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Aug 17 15:48:00 2017
    13 // Update Count     : 8
     12// Last Modified On : Thr Aug 17 17:19:00 2017
     13// Update Count     : 9
    1414//
    1515
     
    166166                        /*bitfieldWidth*/ NULL,
    167167                        new BasicType( noQualifiers, BasicType::Bool ),
    168                         /*init*/ NULL
     168                        /*init*/ NULL,
     169                        std::list<Attribute *>{ new Attribute( "unused" ) }
    169170                        );
    170171                ObjectDecl voidptr_obj(
     
    183184                        );
    184185
     186                ObjectDecl * unused_index_obj = index_obj.clone();
     187                unused_index_obj->attributes.push_back( new Attribute( "unused" ) );
     188
    185189                catch_func_t.get_parameters().push_back( index_obj.clone() );
    186190                catch_func_t.get_parameters().push_back( exception_obj.clone() );
    187                 match_func_t.get_returnVals().push_back( index_obj.clone() );
     191                match_func_t.get_returnVals().push_back( unused_index_obj );
    188192                match_func_t.get_parameters().push_back( exception_obj.clone() );
    189193                handle_func_t.get_returnVals().push_back( bool_obj.clone() );
     
    387391        }
    388392
    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 
    402393        FunctionDecl * ExceptionMutatorCore::create_terminate_match(
    403394                        CatchList &handlers ) {
     
    410401                FunctionType * func_type = match_func_t.clone();
    411402                DeclarationWithType * except_obj = func_type->get_parameters().back();
    412                 DeclarationWithType * index_obj = func_type->get_returnVals().front();
    413403
    414404                // Index 1..{number of handlers}
     
    423413
    424414                        // Create new body.
    425                         handler->set_body( set_and_ret( index_obj,
     415                        handler->set_body( new ReturnStmt( noLabels,
    426416                                new ConstantExpr( Constant::from_int( index ) ) ) );
    427417
     
    431421                }
    432422
    433                 body->push_back( set_and_ret( index_obj,
     423                body->push_back( new ReturnStmt( noLabels,
    434424                        new ConstantExpr( Constant::from_int( 0 ) ) ) );
    435425
     
    465455                FunctionType * func_type = handle_func_t.clone();
    466456                DeclarationWithType * except_obj = func_type->get_parameters().back();
    467                 DeclarationWithType * bool_obj = func_type->get_returnVals().front();
    468457
    469458                CatchList::iterator it;
     
    478467                                handling_code->push_back( handler->get_body() );
    479468                        }
    480                         handling_code->push_back( set_and_ret( bool_obj,
     469                        handling_code->push_back( new ReturnStmt( noLabels,
    481470                                new ConstantExpr( Constant::from_bool( true ) ) ) );
    482471                        handler->set_body( handling_code );
     
    487476                }
    488477
    489                 body->push_back( set_and_ret( bool_obj,
     478                body->push_back( new ReturnStmt( noLabels,
    490479                        new ConstantExpr( Constant::from_bool( false ) ) ) );
    491480
Note: See TracChangeset for help on using the changeset viewer.