Changeset c4187df for src/GenPoly


Ignore:
Timestamp:
Mar 22, 2017, 5:17:08 PM (9 years ago)
Author:
Aaron Moss <a3moss@…>
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:
22854f8, 37f9860, ccd8bc3
Parents:
06ccbc7 (diff), c2bfb31 (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' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/GenPoly
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r06ccbc7 rc4187df  
    12981298                        FunctionType * ftype = functionDecl->get_functionType();
    12991299                        if ( ! ftype->get_returnVals().empty() && functionDecl->get_statements() ) {
    1300                                 if ( functionDecl->get_name() != "?=?" && ! isPrefix( functionDecl->get_name(), "_thunk" ) ) { // xxx - remove check for ?=? once reference types are in; remove check for prefix once thunks properly use ctor/dtors
     1300                                if ( functionDecl->get_name() != "?=?" && ! isPrefix( functionDecl->get_name(), "_thunk" ) && ! isPrefix( functionDecl->get_name(), "_adapter" ) ) { // xxx - remove check for ?=? once reference types are in; remove check for prefix once thunks properly use ctor/dtors
    13011301                                        assert( ftype->get_returnVals().size() == 1 );
    13021302                                        DeclarationWithType * retval = ftype->get_returnVals().front();
  • src/GenPoly/Specialize.cc

    r06ccbc7 rc4187df  
    168168        }
    169169
     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
    170192        /// Generates a thunk that calls `actual` with type `funType` and returns its address
    171193        Expression * Specialize::createThunkFunction( FunctionType *funType, Expression *actual, InferredParams *inferParams ) {
     
    211233                }
    212234
    213                 appExpr->set_env( maybeClone( env ) );
     235                appExpr->set_env( trimEnv( appExpr, env ) );
    214236                if ( inferParams ) {
    215237                        appExpr->get_inferParams() = *inferParams;
Note: See TracChangeset for help on using the changeset viewer.