Changes in src/GenPoly/Specialize.cc [2ec65ad:a16764a6]
- File:
-
- 1 edited
-
src/GenPoly/Specialize.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Specialize.cc
r2ec65ad ra16764a6 200 200 } 201 201 202 struct EnvTrimmer { 203 TypeSubstitution * env, * newEnv; 204 EnvTrimmer( TypeSubstitution * env, TypeSubstitution * newEnv ) : env( env ), newEnv( newEnv ){} 205 void previsit( TypeDecl * tyDecl ) { 206 // transfer known bindings for seen type variables 207 if ( Type * t = env->lookup( tyDecl->name ) ) { 208 newEnv->add( tyDecl->name, t ); 209 } 210 } 211 }; 212 213 /// reduce environment to just the parts that are referenced in a given expression 214 TypeSubstitution * trimEnv( ApplicationExpr * expr, TypeSubstitution * env ) { 215 if ( env ) { 216 TypeSubstitution * newEnv = new TypeSubstitution(); 217 PassVisitor<EnvTrimmer> trimmer( env, newEnv ); 218 expr->accept( trimmer ); 219 return newEnv; 220 } 221 return nullptr; 222 } 223 202 224 /// Generates a thunk that calls `actual` with type `funType` and returns its address 203 225 Expression * Specialize::createThunkFunction( FunctionType *funType, Expression *actual, InferredParams *inferParams ) { … … 243 265 } 244 266 245 appExpr-> env = TypeSubstitution::newFromExpr( appExpr, env);267 appExpr->set_env( trimEnv( appExpr, env ) ); 246 268 if ( inferParams ) { 247 269 appExpr->get_inferParams() = *inferParams;
Note:
See TracChangeset
for help on using the changeset viewer.