Changeset 90152a4 for src/GenPoly/Specialize.cc
- Timestamp:
- Aug 27, 2018, 4:40:34 PM (7 years ago)
- 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. - File:
-
- 1 edited
-
src/GenPoly/Specialize.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Specialize.cc
rf9feab8 r90152a4 23 23 24 24 #include "Common/PassVisitor.h" 25 #include "Common/SemanticError.h" // for SemanticError26 25 #include "Common/UniqueName.h" // for UniqueName 27 26 #include "Common/utility.h" // for group_iterate … … 201 200 } 202 201 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 variables208 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 expression215 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 225 202 /// Generates a thunk that calls `actual` with type `funType` and returns its address 226 203 Expression * Specialize::createThunkFunction( FunctionType *funType, Expression *actual, InferredParams *inferParams ) { … … 266 243 } 267 244 268 appExpr-> set_env( trimEnv( appExpr, env ));245 appExpr->env = TypeSubstitution::newFromExpr( appExpr, env ); 269 246 if ( inferParams ) { 270 247 appExpr->get_inferParams() = *inferParams;
Note:
See TracChangeset
for help on using the changeset viewer.