Changeset 10a7775 for src/ResolvExpr


Ignore:
Timestamp:
Jun 3, 2016, 2:02:29 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
e365cb5
Parents:
e01bfbc
Message:

can use intrinsic constructors on const objects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    re01bfbc r10a7775  
    531531                        assert( dynamic_cast< VariableExpr * >( arr ) );
    532532                        assert( arr && arr->get_results().size() == 1 );
    533                         ArrayType * arrType = dynamic_cast< ArrayType * >( arr->get_results().front() );
    534                         assert( arrType );
    535                         type = arrType->get_base();
     533                        type = InitTweak::getPointerBase( arr->get_results().front() );
     534                        assert( type );
    536535                } else {
    537536                        // otherwise, constructing a plain object, which means the object's address is being taken.
     
    557556                impCtorDtorStmt->get_callStmt()->accept( *this );
    558557
    559                 // and reset type qualifiers after resolving
    560                 type->get_qualifiers() = qualifiers;
     558                // reset type qualifiers, but first need to figure out where everything is again
     559                // because the expressions are often changed by the resolver.
     560                callExpr = InitTweak::getCtorDtorCall( impCtorDtorStmt );
     561                assert( callExpr );
     562                constructee = InitTweak::getCallArg( callExpr, 0 );
     563                if ( ApplicationExpr * plusExpr = dynamic_cast< ApplicationExpr * >( constructee ) ) {
     564                        // constructee is <array>+<index>
     565                        // get Variable <array>, then get the base type of the VariableExpr - this is the type that needs to be fixed
     566                        Expression * arr = InitTweak::getCallArg( plusExpr, 0 );
     567                        assert( dynamic_cast< VariableExpr * >( arr ) );
     568                        assert( arr && arr->get_results().size() == 1 );
     569                        type = InitTweak::getPointerBase( arr->get_results().front() );
     570                        assert( type );
     571                        type->get_qualifiers() = qualifiers;
     572                } else {
     573                        // otherwise constructing a plain object
     574                        // replace qualifiers on AddressExpr and on inner VariableExpr
     575                        assert( constructee->get_results().size() == 1 );
     576                        AddressExpr * addrExpr = dynamic_cast< AddressExpr * > ( constructee );
     577                        assert( addrExpr );
     578                        type = InitTweak::getPointerBase( addrExpr->get_results().front() );
     579                        assert( type );
     580                        type->get_qualifiers() = qualifiers;
     581
     582                        VariableExpr * varExpr = dynamic_cast< VariableExpr * >( addrExpr->get_arg() );
     583                        assert( varExpr && varExpr->get_results().size() == 1 );
     584                        type = varExpr->get_results().front();
     585                        type->get_qualifiers() = qualifiers;
     586                }
    561587        }
    562588} // namespace ResolvExpr
Note: See TracChangeset for help on using the changeset viewer.