Changeset 0ca9dea for src/ResolvExpr/AlternativeFinder.cc
- Timestamp:
- Feb 17, 2017, 3:32:58 PM (7 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:
- d150ea2
- Parents:
- 94ad12f (diff), 8a5cad8 (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
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r94ad12f r0ca9dea 1044 1044 1045 1045 void AlternativeFinder::visit( ConditionalExpr *conditionalExpr ) { 1046 // find alternatives for condition 1046 1047 AlternativeFinder firstFinder( indexer, env ); 1047 1048 firstFinder.findWithAdjustment( conditionalExpr->get_arg1() ); 1048 1049 for ( AltList::const_iterator first = firstFinder.alternatives.begin(); first != firstFinder.alternatives.end(); ++first ) { 1050 // find alternatives for true expression 1049 1051 AlternativeFinder secondFinder( indexer, first->env ); 1050 1052 secondFinder.findWithAdjustment( conditionalExpr->get_arg2() ); 1051 1053 for ( AltList::const_iterator second = secondFinder.alternatives.begin(); second != secondFinder.alternatives.end(); ++second ) { 1054 // find alterantives for false expression 1052 1055 AlternativeFinder thirdFinder( indexer, second->env ); 1053 1056 thirdFinder.findWithAdjustment( conditionalExpr->get_arg3() ); 1054 1057 for ( AltList::const_iterator third = thirdFinder.alternatives.begin(); third != thirdFinder.alternatives.end(); ++third ) { 1058 // unify true and false types, then infer parameters to produce new alternatives 1055 1059 OpenVarSet openVars; 1056 1060 AssertionSet needAssertions, haveAssertions; … … 1079 1083 } 1080 1084 1085 void AlternativeFinder::visit( RangeExpr * rangeExpr ) { 1086 // resolve low and high, accept alternatives whose low and high types unify 1087 AlternativeFinder firstFinder( indexer, env ); 1088 firstFinder.findWithAdjustment( rangeExpr->get_low() ); 1089 for ( AltList::const_iterator first = firstFinder.alternatives.begin(); first != firstFinder.alternatives.end(); ++first ) { 1090 AlternativeFinder secondFinder( indexer, first->env ); 1091 secondFinder.findWithAdjustment( rangeExpr->get_high() ); 1092 for ( AltList::const_iterator second = secondFinder.alternatives.begin(); second != secondFinder.alternatives.end(); ++second ) { 1093 OpenVarSet openVars; 1094 AssertionSet needAssertions, haveAssertions; 1095 Alternative newAlt( 0, second->env, first->cost + second->cost ); 1096 Type* commonType = nullptr; 1097 if ( unify( first->expr->get_result(), second->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 1098 RangeExpr *newExpr = new RangeExpr( first->expr->clone(), second->expr->clone() ); 1099 newExpr->set_result( commonType ? commonType : first->expr->get_result()->clone() ); 1100 newAlt.expr = newExpr; 1101 inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) ); 1102 } // if 1103 } // for 1104 } // for 1105 } 1106 1081 1107 void AlternativeFinder::visit( UntypedTupleExpr *tupleExpr ) { 1082 1108 std::list< AlternativeFinder > subExprAlternatives;
Note: See TracChangeset
for help on using the changeset viewer.