Changeset 027c496 for src/Tuples
- Timestamp:
- Dec 1, 2017, 10:35:50 AM (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:
- 2449aef
- Parents:
- c5f3c68
- git-author:
- Rob Schluntz <rschlunt@…> (12/01/17 10:35:42)
- git-committer:
- Rob Schluntz <rschlunt@…> (12/01/17 10:35:50)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Tuples/TupleExpansion.cc
rc5f3c68 r027c496 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 class ImpurityDetector : public Visitor { 318 public: 317 struct ImpurityDetector : public WithShortCircuiting { 319 318 ImpurityDetector( bool ignoreUnique ) : ignoreUnique( ignoreUnique ) {} 320 319 321 typedef Visitor Parent;322 virtual void visit( ApplicationExpr * appExpr ) {320 void previsit( ApplicationExpr * appExpr ) { 321 visit_children = false; 323 322 if ( DeclarationWithType * function = InitTweak::getFunction( appExpr ) ) { 324 323 if ( function->get_linkage() == LinkageSpec::Intrinsic ) { 325 324 if ( function->get_name() == "*?" || function->get_name() == "?[?]" ) { 326 325 // intrinsic dereference, subscript are pure, but need to recursively look for impurity 327 Parent::visit( appExpr );326 visit_children = true; 328 327 return; 329 328 } … … 332 331 maybeImpure = true; 333 332 } 334 v irtual void visit( UntypedExpr * ) { maybeImpure = true; }335 v irtual void visit( UniqueExpr * unq) {333 void previsit( UntypedExpr * ) { maybeImpure = true; visit_children = false; } 334 void previsit( UniqueExpr * ) { 336 335 if ( ignoreUnique ) { 337 336 // bottom out at unique expression. 338 337 // The existence of a unique expression doesn't change the purity of an expression. 339 338 // 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 );343 342 } 344 343 … … 349 348 350 349 bool maybeImpure( Expression * expr ) { 351 ImpurityDetectordetector( false );350 PassVisitor<ImpurityDetector> detector( false ); 352 351 expr->accept( detector ); 353 return detector. maybeImpure;352 return detector.pass.maybeImpure; 354 353 } 355 354 356 355 bool maybeImpureIgnoreUnique( Expression * expr ) { 357 ImpurityDetectordetector( true );356 PassVisitor<ImpurityDetector> detector( true ); 358 357 expr->accept( detector ); 359 return detector. maybeImpure;358 return detector.pass.maybeImpure; 360 359 } 361 360 } // namespace Tuples
Note: See TracChangeset
for help on using the changeset viewer.