Changeset 623ecf3
- Timestamp:
- Mar 21, 2017, 3:26:09 PM (8 years ago)
- 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:
- 597db97
- Parents:
- f5392c1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Specialize.cc
rf5392c1 r623ecf3 168 168 } 169 169 170 struct EnvTrimmer : public Visitor { 171 TypeSubstitution * env, * newEnv; 172 EnvTrimmer( TypeSubstitution * env, TypeSubstitution * newEnv ) : env( env ), newEnv( newEnv ){} 173 virtual void visit( TypeDecl * tyDecl ) { 174 // transfer known bindings for seen type variables 175 if ( Type * t = env->lookup( tyDecl->get_name() ) ) { 176 newEnv->add( tyDecl->get_name(), t ); 177 } 178 } 179 }; 180 181 /// reduce environment to just the parts that are referenced in a given expression 182 TypeSubstitution * trimEnv( ApplicationExpr * expr, TypeSubstitution * env ) { 183 if ( env ) { 184 TypeSubstitution * newEnv = new TypeSubstitution(); 185 EnvTrimmer trimmer( env, newEnv ); 186 expr->accept( trimmer ); 187 return newEnv; 188 } 189 return nullptr; 190 } 191 170 192 /// Generates a thunk that calls `actual` with type `funType` and returns its address 171 193 Expression * Specialize::createThunkFunction( FunctionType *funType, Expression *actual, InferredParams *inferParams ) { … … 211 233 } 212 234 213 appExpr->set_env( maybeClone(env ) );235 appExpr->set_env( trimEnv( appExpr, env ) ); 214 236 if ( inferParams ) { 215 237 appExpr->get_inferParams() = *inferParams;
Note: See TracChangeset
for help on using the changeset viewer.