Ignore:
Timestamp:
Aug 27, 2018, 4:40:34 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
b7c89aa
Parents:
f9feab8 (diff), 305581d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into cleanup-dtors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Specialize.cc

    rf9feab8 r90152a4  
    2323
    2424#include "Common/PassVisitor.h"
    25 #include "Common/SemanticError.h"        // for SemanticError
    2625#include "Common/UniqueName.h"           // for UniqueName
    2726#include "Common/utility.h"              // for group_iterate
     
    201200        }
    202201
    203         struct EnvTrimmer {
    204                 TypeSubstitution * env, * newEnv;
    205                 EnvTrimmer( TypeSubstitution * env, TypeSubstitution * newEnv ) : env( env ), newEnv( newEnv ){}
    206                 void previsit( TypeDecl * tyDecl ) {
    207                         // transfer known bindings for seen type variables
    208                         if ( Type * t = env->lookup( tyDecl->name ) ) {
    209                                 newEnv->add( tyDecl->name, t );
    210                         }
    211                 }
    212         };
    213 
    214         /// reduce environment to just the parts that are referenced in a given expression
    215         TypeSubstitution * trimEnv( ApplicationExpr * expr, TypeSubstitution * env ) {
    216                 if ( env ) {
    217                         TypeSubstitution * newEnv = new TypeSubstitution();
    218                         PassVisitor<EnvTrimmer> trimmer( env, newEnv );
    219                         expr->accept( trimmer );
    220                         return newEnv;
    221                 }
    222                 return nullptr;
    223         }
    224 
    225202        /// Generates a thunk that calls `actual` with type `funType` and returns its address
    226203        Expression * Specialize::createThunkFunction( FunctionType *funType, Expression *actual, InferredParams *inferParams ) {
     
    266243                }
    267244
    268                 appExpr->set_env( trimEnv( appExpr, env ) );
     245                appExpr->env = TypeSubstitution::newFromExpr( appExpr, env );
    269246                if ( inferParams ) {
    270247                        appExpr->get_inferParams() = *inferParams;
Note: See TracChangeset for help on using the changeset viewer.