Changeset a94b829 for src/ResolvExpr
- Timestamp:
- Nov 20, 2017, 2:20:10 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:
- 0872c42
- Parents:
- 403b388 (diff), c0b23644 (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. - Location:
- src/ResolvExpr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r403b388 ra94b829 779 779 return ! finalResults.empty(); 780 780 } 781 781 782 782 // iterate each current subresult 783 783 std::size_t genEnd = results.size(); … … 913 913 914 914 template<typename OutputIterator> 915 void AlternativeFinder::makeFunctionAlternatives( const Alternative &func, 916 FunctionType *funcType, const std::vector< AlternativeFinder > &args, 915 void AlternativeFinder::makeFunctionAlternatives( const Alternative &func, 916 FunctionType *funcType, const std::vector< AlternativeFinder > &args, 917 917 OutputIterator out ) { 918 918 OpenVarSet funcOpenVars; … … 920 920 TypeEnvironment funcEnv( func.env ); 921 921 makeUnifiableVars( funcType, funcOpenVars, funcNeed ); 922 // add all type variables as open variables now so that those not used in the parameter 922 // add all type variables as open variables now so that those not used in the parameter 923 923 // list are still considered open. 924 924 funcEnv.add( funcType->get_forall() ); 925 925 926 926 if ( targetType && ! targetType->isVoid() && ! funcType->get_returnVals().empty() ) { 927 927 // attempt to narrow based on expected target type 928 928 Type * returnType = funcType->get_returnVals().front()->get_type(); 929 if ( ! unify( returnType, targetType, funcEnv, funcNeed, funcHave, funcOpenVars, 929 if ( ! unify( returnType, targetType, funcEnv, funcNeed, funcHave, funcOpenVars, 930 930 indexer ) ) { 931 931 // unification failed, don't pursue this function alternative … … 1035 1035 1036 1036 std::vector< AlternativeFinder > argAlternatives; 1037 findSubExprs( untypedExpr->begin_args(), untypedExpr->end_args(), 1037 findSubExprs( untypedExpr->begin_args(), untypedExpr->end_args(), 1038 1038 back_inserter( argAlternatives ) ); 1039 1039 … … 1065 1065 Alternative newFunc( *func ); 1066 1066 referenceToRvalueConversion( newFunc.expr ); 1067 makeFunctionAlternatives( newFunc, function, argAlternatives, 1067 makeFunctionAlternatives( newFunc, function, argAlternatives, 1068 1068 std::back_inserter( candidates ) ); 1069 1069 } … … 1074 1074 Alternative newFunc( *func ); 1075 1075 referenceToRvalueConversion( newFunc.expr ); 1076 makeFunctionAlternatives( newFunc, function, argAlternatives, 1076 makeFunctionAlternatives( newFunc, function, argAlternatives, 1077 1077 std::back_inserter( candidates ) ); 1078 1078 } // if 1079 1079 } // if 1080 } 1080 } 1081 1081 } catch ( SemanticError &e ) { 1082 1082 errors.append( e ); … … 1093 1093 try { 1094 1094 // check if type is a pointer to function 1095 if ( PointerType* pointer = dynamic_cast<PointerType*>( 1095 if ( PointerType* pointer = dynamic_cast<PointerType*>( 1096 1096 funcOp->expr->get_result()->stripReferences() ) ) { 1097 if ( FunctionType* function = 1097 if ( FunctionType* function = 1098 1098 dynamic_cast<FunctionType*>( pointer->get_base() ) ) { 1099 1099 Alternative newFunc( *funcOp ); 1100 1100 referenceToRvalueConversion( newFunc.expr ); 1101 makeFunctionAlternatives( newFunc, function, argAlternatives, 1101 makeFunctionAlternatives( newFunc, function, argAlternatives, 1102 1102 std::back_inserter( candidates ) ); 1103 1103 } … … 1138 1138 candidates.splice( candidates.end(), alternatives ); 1139 1139 1140 findMinCost( candidates.begin(), candidates.end(), std::back_inserter( alternatives ) ); 1140 // use a new list so that alternatives are not examined by addAnonConversions twice. 1141 AltList winners; 1142 findMinCost( candidates.begin(), candidates.end(), std::back_inserter( winners ) ); 1141 1143 1142 1144 // function may return struct or union value, in which case we need to add alternatives for implicit 1143 1145 // conversions to each of the anonymous members, must happen after findMinCost since anon conversions 1144 1146 // are never the cheapest expression 1145 for ( const Alternative & alt : alternatives ) {1147 for ( const Alternative & alt : winners ) { 1146 1148 addAnonConversions( alt ); 1147 1149 } 1150 alternatives.splice( alternatives.begin(), winners ); 1148 1151 1149 1152 if ( alternatives.empty() && targetType && ! targetType->isVoid() ) { -
src/ResolvExpr/RenameVars.cc
r403b388 ra94b829 29 29 RenameVars global_renamer; 30 30 31 RenameVars::RenameVars() : level( 0 ) {31 RenameVars::RenameVars() : level( 0 ), resetCount( 0 ) { 32 32 mapStack.push_front( std::map< std::string, std::string >() ); 33 33 } … … 35 35 void RenameVars::reset() { 36 36 level = 0; 37 resetCount++; 37 38 } 38 39 … … 130 131 for ( Type::ForallList::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) { 131 132 std::ostringstream output; 132 output << "_" << level << "_" << (*i)->get_name();133 output << "_" << resetCount << "_" << level << "_" << (*i)->get_name(); 133 134 std::string newname( output.str() ); 134 135 mapStack.front()[ (*i)->get_name() ] = newname; -
src/ResolvExpr/RenameVars.h
r403b388 ra94b829 48 48 void typeBefore( Type *type ); 49 49 void typeAfter( Type *type ); 50 int level ;50 int level, resetCount; 51 51 std::list< std::map< std::string, std::string > > mapStack; 52 52 };
Note:
See TracChangeset
for help on using the changeset viewer.