Ignore:
Timestamp:
Jul 25, 2022, 2:23:00 PM (22 months ago)
Author:
Fangren Yu <f37yu@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
ffec1bf
Parents:
76a798d
Message:

add specialize pass

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/SymbolTable.cpp

    r76a798d r9e23b446  
    6565
    6666Expr * SymbolTable::IdData::combine( const CodeLocation & loc, ResolvExpr::Cost & cost ) const {
    67         Expr * ret = ( baseExpr ) ?
    68                 (Expr *)new MemberExpr{ loc, id, referenceToRvalueConversion( baseExpr, cost ) } :
    69                 (Expr *)new VariableExpr{ loc, id };
     67        Expr * ret;
     68        if ( baseExpr ) {
     69                if (baseExpr->env) {
     70                        Expr * base = shallowCopy(baseExpr);
     71                        const TypeSubstitution * subs = baseExpr->env;
     72                        base->env = nullptr;
     73                        ret = new MemberExpr{loc, id, referenceToRvalueConversion( base, cost )};
     74                        ret->env = subs;
     75                }
     76                else {
     77                        ret = new MemberExpr{ loc, id, referenceToRvalueConversion( baseExpr, cost ) };
     78                }
     79        }
     80        else {
     81                ret = new VariableExpr{ loc, id };
     82        }
    7083        if ( deleter ) { ret = new DeletedExpr{ loc, ret, deleter }; }
    7184        return ret;
     
    772785                                                && ! dynamic_cast<const UnionInstType *>(rty) ) continue;
    773786                                        ResolvExpr::Cost cost = ResolvExpr::Cost::zero;
     787                                        ast::ptr<ast::TypeSubstitution> tmp = expr->env;
     788                                        expr = mutate_field(expr, &Expr::env, nullptr);
    774789                                        const Expr * base = ResolvExpr::referenceToRvalueConversion( expr, cost );
     790                                        base = mutate_field(base, &Expr::env, tmp);
     791
    775792                                        addMembers(
    776793                                                rty->aggr(), new MemberExpr{ base->location, dwt, base }, handleConflicts );
Note: See TracChangeset for help on using the changeset viewer.