Changes in src/Tuples/TupleExpansion.cc [027c496:f0ecf9b]
- File:
-
- 1 edited
-
src/Tuples/TupleExpansion.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Tuples/TupleExpansion.cc
r027c496 rf0ecf9b 315 315 namespace { 316 316 /// determines if impurity (read: side-effects) may exist in a piece of code. Currently gives a very crude approximation, wherein any function call expression means the code may be impure 317 struct ImpurityDetector : public WithShortCircuiting { 317 class ImpurityDetector : public Visitor { 318 public: 318 319 ImpurityDetector( bool ignoreUnique ) : ignoreUnique( ignoreUnique ) {} 319 320 320 void previsit( ApplicationExpr * appExpr ) {321 visit_children = false;321 typedef Visitor Parent; 322 virtual void visit( ApplicationExpr * appExpr ) { 322 323 if ( DeclarationWithType * function = InitTweak::getFunction( appExpr ) ) { 323 324 if ( function->get_linkage() == LinkageSpec::Intrinsic ) { 324 325 if ( function->get_name() == "*?" || function->get_name() == "?[?]" ) { 325 326 // intrinsic dereference, subscript are pure, but need to recursively look for impurity 326 visit_children = true;327 Parent::visit( appExpr ); 327 328 return; 328 329 } … … 331 332 maybeImpure = true; 332 333 } 333 v oid previsit( UntypedExpr * ) { maybeImpure = true; visit_children = false; }334 v oid previsit( UniqueExpr *) {334 virtual void visit( UntypedExpr * ) { maybeImpure = true; } 335 virtual void visit( UniqueExpr * unq ) { 335 336 if ( ignoreUnique ) { 336 337 // bottom out at unique expression. 337 338 // The existence of a unique expression doesn't change the purity of an expression. 338 339 // That is, even if the wrapped expression is impure, the wrapper protects the rest of the expression. 339 visit_children = false;340 340 return; 341 341 } 342 maybeAccept( unq->expr, *this ); 342 343 } 343 344 … … 348 349 349 350 bool maybeImpure( Expression * expr ) { 350 PassVisitor<ImpurityDetector>detector( false );351 ImpurityDetector detector( false ); 351 352 expr->accept( detector ); 352 return detector. pass.maybeImpure;353 return detector.maybeImpure; 353 354 } 354 355 355 356 bool maybeImpureIgnoreUnique( Expression * expr ) { 356 PassVisitor<ImpurityDetector>detector( true );357 ImpurityDetector detector( true ); 357 358 expr->accept( detector ); 358 return detector. pass.maybeImpure;359 return detector.maybeImpure; 359 360 } 360 361 } // namespace Tuples
Note:
See TracChangeset
for help on using the changeset viewer.