Changeset 7664fad


Ignore:
Timestamp:
Oct 4, 2017, 11:30:57 AM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
adb4a3a
Parents:
bb9d8e8
Message:

Update finishExpr so environment is not lost on multiple resolutions

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    rbb9d8e8 r7664fad  
    109109
    110110        namespace {
    111                 void finishExpr( Expression *expr, const TypeEnvironment &env ) {
    112                         expr->set_env( new TypeSubstitution );
     111                void finishExpr( Expression *expr, const TypeEnvironment &env, TypeSubstitution * oldenv = nullptr ) {
     112                        expr->env = oldenv ? oldenv->clone() : new TypeSubstitution;
    113113                        env.makeSubstitution( *expr->get_env() );
    114114                }
     
    119119                TypeEnvironment env;
    120120                Expression *newExpr = resolveInVoidContext( untyped, indexer, env );
    121                 finishExpr( newExpr, env );
     121                finishExpr( newExpr, env, untyped->env );
    122122                return newExpr;
    123123        }
     
    129129                #if 0
    130130                if ( finder.get_alternatives().size() != 1 ) {
    131                         std::cout << "untyped expr is ";
    132                         untyped->print( std::cout );
    133                         std::cout << std::endl << "alternatives are:";
    134                         for ( std::list< Alternative >::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) {
    135                                 i->print( std::cout );
     131                        std::cerr << "untyped expr is ";
     132                        untyped->print( std::cerr );
     133                        std::cerr << std::endl << "alternatives are:";
     134                        for ( const Alternative & alt : finder.get_alternatives() ) {
     135                                alt.print( std::cerr );
    136136                        } // for
    137137                } // if
     
    140140                Alternative &choice = finder.get_alternatives().front();
    141141                Expression *newExpr = choice.expr->clone();
    142                 finishExpr( newExpr, choice.env );
     142                finishExpr( newExpr, choice.env, untyped->env );
    143143                return newExpr;
    144144        }
     
    186186                                throw SemanticError( "No interpretations for case control expression", untyped );
    187187                        } // if
    188                         finishExpr( newExpr, *newEnv );
     188                        finishExpr( newExpr, *newEnv, untyped->env );
    189189                        return newExpr;
    190190                }
  • src/SymTab/Validate.cc

    rbb9d8e8 r7664fad  
    276276                ReturnChecker::checkFunctionReturns( translationUnit );
    277277                mutateAll( translationUnit, compoundliteral );
    278                 acceptAll( translationUnit, fpd );
     278                acceptAll( translationUnit, fpd ); // must happen before autogenerateRoutines
    279279                ArrayLength::computeLength( translationUnit );
    280280                acceptAll( translationUnit, finder );
Note: See TracChangeset for help on using the changeset viewer.