Ignore:
Timestamp:
Oct 10, 2017, 3:17:45 PM (5 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, 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, resolv-new, with_gc
Children:
c366ec6
Parents:
ded5f07
Message:

Refactor findSingleExpr and remove unnecessary resolver-generated casts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    rded5f07 r08da53d  
    367367                        ImplicitCtorDtorStmt * stmt = genCtorDtor( fname, var, cpArg );
    368368                        ExprStmt * exprStmt = strict_dynamic_cast< ExprStmt * >( stmt->get_callStmt() );
    369                         Expression * untyped = exprStmt->get_expr();
     369                        Expression * resolved = exprStmt->expr;
     370                        exprStmt->expr = nullptr; // take ownership of expr
    370371
    371372                        // resolve copy constructor
    372373                        // should only be one alternative for copy ctor and dtor expressions, since all arguments are fixed
    373374                        // (VariableExpr and already resolved expression)
    374                         CP_CTOR_PRINT( std::cerr << "ResolvingCtorDtor " << untyped << std::endl; )
    375                         Expression * resolved = ResolvExpr::findVoidExpression( untyped, indexer );
     375                        CP_CTOR_PRINT( std::cerr << "ResolvingCtorDtor " << resolved << std::endl; )
     376                        ResolvExpr::findVoidExpression( resolved, indexer );
    376377                        assert( resolved );
    377378                        if ( resolved->get_env() ) {
     
    381382                                resolved->set_env( nullptr );
    382383                        } // if
    383 
    384384                        delete stmt;
    385385                        return resolved;
     
    11121112                }
    11131113
    1114                 DeclarationWithType * MutatingResolver::mutate( ObjectDecl *objectDecl ) {
     1114                DeclarationWithType * MutatingResolver::mutate( ObjectDecl * objectDecl ) {
    11151115                        // add object to the indexer assumes that there will be no name collisions
    11161116                        // in generated code. If this changes, add mutate methods for entities with
     
    11201120                }
    11211121
    1122                 Expression* MutatingResolver::mutate( UntypedExpr *untypedExpr ) {
    1123                         return strict_dynamic_cast< ApplicationExpr * >( ResolvExpr::findVoidExpression( untypedExpr, indexer ) );
     1122                Expression * MutatingResolver::mutate( UntypedExpr * untypedExpr ) {
     1123                        Expression * newExpr = untypedExpr;
     1124                        ResolvExpr::findVoidExpression( newExpr, indexer );
     1125                        return newExpr;
    11241126                }
    11251127
     
    11461148
    11471149                        // resolve assignment and dispose of new env
    1148                         Expression * resolvedAssign = ResolvExpr::findVoidExpression( assign, indexer );
    1149                         delete resolvedAssign->env;
    1150                         resolvedAssign->env = nullptr;
    1151                         delete assign;
     1150                        ResolvExpr::findVoidExpression( assign, indexer );
     1151                        delete assign->env;
     1152                        assign->env = nullptr;
    11521153
    11531154                        // for constructor expr:
     
    11581159                        //   T & tmp;
    11591160                        //   &tmp = &x, ?{}(tmp), tmp
    1160                         CommaExpr * commaExpr = new CommaExpr( resolvedAssign, new CommaExpr( callExpr, new VariableExpr( tmp ) ) );
     1161                        CommaExpr * commaExpr = new CommaExpr( assign, new CommaExpr( callExpr, new VariableExpr( tmp ) ) );
    11611162                        commaExpr->set_env( env );
    11621163                        return commaExpr;
Note: See TracChangeset for help on using the changeset viewer.