Ignore:
Timestamp:
Mar 7, 2018, 4:59:00 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
02c816fc
Parents:
2097cd4
Message:

Refactor makeSub into genericSubstitution

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r2097cd4 r9bfc9da  
    345345}
    346346
    347 namespace {
    348         TypeSubstitution makeSub( Type * t ) {
    349                 if ( ReferenceType * refType = dynamic_cast< ReferenceType * >( t ) ) {
    350                         return makeSub( refType->get_base() );
    351                 } else if ( StructInstType * aggInst = dynamic_cast< StructInstType * >( t ) ) {
    352                         return TypeSubstitution( aggInst->get_baseParameters()->begin(), aggInst->get_baseParameters()->end(), aggInst->parameters.begin() );
    353                 } else if ( UnionInstType * aggInst = dynamic_cast< UnionInstType * >( t ) ) {
    354                         return TypeSubstitution( aggInst->get_baseParameters()->begin(), aggInst->get_baseParameters()->end(), aggInst->parameters.begin() );
    355                 } else {
    356                         assertf( false, "makeSub expects struct or union type for aggregate, but got: %s", toString( t ).c_str() );
    357                 }
    358         }
    359 }
    360 
    361 
    362347MemberExpr::MemberExpr( DeclarationWithType *member, Expression *aggregate ) :
    363348                Expression(), member(member), aggregate(aggregate) {
    364349        assert( member );
    365350        assert( aggregate );
    366 
    367         TypeSubstitution sub( makeSub( aggregate->get_result() ) );
     351        assert( aggregate->result );
     352
     353        TypeSubstitution sub = aggregate->result->genericSubstitution();
    368354        Type * res = member->get_type()->clone();
    369355        sub.apply( res );
Note: See TracChangeset for help on using the changeset viewer.