Changeset 59cf83b
- Timestamp:
- Oct 5, 2018, 10:30:21 AM (5 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 6d6e829
- Parents:
- 9ad2f9f
- Location:
- src/ResolvExpr
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r9ad2f9f r59cf83b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sat May 16 23:52:08 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Feb 17 11:19:39201813 // Update Count : 3 311 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Fri Oct -5 10:01:00 2018 13 // Update Count : 34 14 14 // 15 15 … … 244 244 } 245 245 246 void AlternativeFinder::find( Expression *expr, bool adjust, bool prune, bool failFast) {246 void AlternativeFinder::find( Expression *expr, ResolvMode mode ) { 247 247 PassVisitor<Finder> finder( *this ); 248 248 expr->accept( finder ); 249 if ( failFast && alternatives.empty() ) {249 if ( mode.failFast && alternatives.empty() ) { 250 250 PRINT( 251 251 std::cerr << "No reasonable alternatives for expression " << expr << std::endl; … … 253 253 SemanticError( expr, "No reasonable alternatives for expression " ); 254 254 } 255 if ( prune ) {255 if ( mode.prune ) { 256 256 auto oldsize = alternatives.size(); 257 257 PRINT( … … 261 261 AltList pruned; 262 262 pruneAlternatives( alternatives.begin(), alternatives.end(), back_inserter( pruned ) ); 263 if ( failFast && pruned.empty() ) {263 if ( mode.failFast && pruned.empty() ) { 264 264 std::ostringstream stream; 265 265 AltList winners; … … 280 280 } 281 281 // adjust types after pruning so that types substituted by pruneAlternatives are correctly adjusted 282 for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i) {283 if ( adjust) {284 adjustExprType( i ->expr->get_result(), i->env, indexer );282 if ( mode.adjust ) { 283 for ( Alternative& i : alternatives ) { 284 adjustExprType( i.expr->get_result(), i.env, indexer ); 285 285 } 286 286 } … … 294 294 295 295 void AlternativeFinder::findWithAdjustment( Expression *expr ) { 296 find( expr, true);296 find( expr, ResolvMode::withAdjustment() ); 297 297 } 298 298 299 299 void AlternativeFinder::findWithoutPrune( Expression * expr ) { 300 find( expr, true, false);300 find( expr, ResolvMode::withoutPrune() ); 301 301 } 302 302 303 303 void AlternativeFinder::maybeFind( Expression * expr ) { 304 find( expr, true, true, false);304 find( expr, ResolvMode::withoutFailFast() ); 305 305 } 306 306 -
src/ResolvExpr/AlternativeFinder.h
r9ad2f9f r59cf83b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sat May 16 23:56:12 2015 11 // Last Modified By : A ndrew Beach12 // Last Modified On : Wed Jul 26 11:24:00 201713 // Update Count : 411 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Fri Oct -5 10:01:00 2018 13 // Update Count : 5 14 14 // 15 15 … … 24 24 #include "ResolvExpr/Cost.h" // for Cost, Cost::infinity 25 25 #include "ResolvExpr/TypeEnvironment.h" // for AssertionSet, OpenVarSet 26 #include "ResolvMode.h" // for ResolvMode 26 27 #include "SynTree/Visitor.h" // for Visitor 27 28 #include "SynTree/SynTree.h" // for Visitor Nodes … … 68 69 } 69 70 70 void find( Expression *expr, bool adjust = false, bool prune = true, bool failFast = true);71 void find( Expression *expr, ResolvMode mode = ResolvMode{} ); 71 72 /// Calls find with the adjust flag set; adjustment turns array and function types into equivalent pointer types 72 73 void findWithAdjustment( Expression *expr ); -
src/ResolvExpr/Resolver.cc
r9ad2f9f r59cf83b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 12:17:01 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Feb 17 11:19:40 201813 // Update Count : 21 311 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Fri Oct 05 09:43:00 2018 13 // Update Count : 214 14 14 // 15 15 … … 31 31 #include "ResolvExpr/TypeEnvironment.h" // for TypeEnvironment 32 32 #include "Resolver.h" 33 #include "ResolvMode.h" // for ResolvMode 33 34 #include "SymTab/Autogen.h" // for SizeType 34 35 #include "SymTab/Indexer.h" // for Indexer … … 168 169 169 170 namespace { 170 void findUnfinishedKindExpression(Expression * untyped, Alternative & alt, const SymTab::Indexer & indexer, const std::string & kindStr, std::function<bool(const Alternative &)> pred, bool adjust = false, bool prune = true, bool failFast = true) {171 void findUnfinishedKindExpression(Expression * untyped, Alternative & alt, const SymTab::Indexer & indexer, const std::string & kindStr, std::function<bool(const Alternative &)> pred, ResolvMode mode = ResolvMode{} ) { 171 172 assertf( untyped, "expected a non-null expression." ); 172 173 TypeEnvironment env; 173 174 AlternativeFinder finder( indexer, env ); 174 finder.find( untyped, adjust, prune, failFast);175 finder.find( untyped, mode ); 175 176 176 177 #if 0 … … 216 217 217 218 /// resolve `untyped` to the expression whose alternative satisfies `pred` with the lowest cost; kindStr is used for providing better error messages 218 void findKindExpression(Expression *& untyped, const SymTab::Indexer & indexer, const std::string & kindStr, std::function<bool(const Alternative &)> pred, bool adjust = false, bool prune = true, bool failFast = true) {219 void findKindExpression(Expression *& untyped, const SymTab::Indexer & indexer, const std::string & kindStr, std::function<bool(const Alternative &)> pred, ResolvMode mode = ResolvMode{}) { 219 220 if ( ! untyped ) return; 220 221 Alternative choice; 221 findUnfinishedKindExpression( untyped, choice, indexer, kindStr, pred, adjust, prune, failFast);222 findUnfinishedKindExpression( untyped, choice, indexer, kindStr, pred, mode ); 222 223 finishExpr( choice.expr, choice.env, untyped->env ); 223 224 delete untyped; … … 250 251 untyped.arg = expr; 251 252 Alternative choice; 252 findUnfinishedKindExpression( &untyped, choice, indexer, "", standardAlternativeFilter, true);253 findUnfinishedKindExpression( &untyped, choice, indexer, "", standardAlternativeFilter, ResolvMode::withAdjustment() ); 253 254 CastExpr * castExpr = strict_dynamic_cast< CastExpr * >( choice.expr ); 254 255 env = std::move( choice.env );
Note: See TracChangeset
for help on using the changeset viewer.