- Timestamp:
- Jun 18, 2019, 9:44:23 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- c8e4d2f8
- Parents:
- 07ca4dd
- Location:
- src/Tuples
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Tuples/Tuples.cc
r07ca4dd rbc92bee 10 10 // Created On : Mon Jun 17 14:41:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 12 15:43:00 201913 // Update Count : 012 // Last Modified On : Tue Jun 18 9:31:00 2019 13 // Update Count : 1 14 14 // 15 15 … … 27 27 /// impure. 28 28 struct ImpurityDetector : public ast::WithShortCircuiting { 29 ImpurityDetector( bool ignoreUnique ) : ignoreUnique( ignoreUnique ) {}30 29 bool maybeImpure = false; 31 bool ignoreUnique;32 30 33 31 void previsit( ast::ApplicationExpr const * appExpr ) { 34 visit_children = false;35 32 if ( ast::DeclWithType const * function = InitTweak::getFunction( appExpr ) ) { 36 33 if ( function->linkage == ast::Linkage::Intrinsic 37 34 && ( function->name == "*?" || function->name == "?[?]" ) ) { 38 visit_children = true;39 35 return; 40 36 } 41 37 } 42 maybeImpure = true; 38 maybeImpure = true; visit_children = false; 43 39 } 44 40 void previsit( ast::UntypedExpr const * ) { 45 41 maybeImpure = true; visit_children = false; 46 42 } 43 }; 44 struct ImpurityDetectorIgnoreUnique : public ImpurityDetector { 47 45 void previsit( ast::UniqueExpr const * ) { 48 if ( ignoreUnique ) { 49 visit_children = false; 50 } 46 visit_children = false; 51 47 } 52 48 }; 53 49 54 bool detectImpurity( const ast::Expr * expr, bool ignoreUnique ) { 55 ast::Pass<ImpurityDetector> detector( ignoreUnique ); 50 template<typename Detector> 51 bool detectImpurity( const ast::Expr * expr ) { 52 ast::Pass<Detector> detector; 56 53 expr->accept( detector ); 57 54 return detector.pass.maybeImpure; … … 59 56 } // namespace 60 57 58 bool maybeImpure( const ast::Expr * expr ) { 59 return detectImpurity<ImpurityDetector>( expr ); 60 } 61 61 62 bool maybeImpureIgnoreUnique( const ast::Expr * expr ) { 62 return detectImpurity ( expr, true);63 return detectImpurity<ImpurityDetectorIgnoreUnique>( expr ); 63 64 } 64 65 -
src/Tuples/Tuples.h
r07ca4dd rbc92bee 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jun 12 10:39:00 201713 // Update Count : 1 712 // Last Modified On : Tue Jun 18 09:36:00 2019 13 // Update Count : 18 14 14 // 15 15 … … 56 56 /// returns true if the expression may contain side-effects. 57 57 bool maybeImpure( Expression * expr ); 58 bool maybeImpure( const ast::Expr * expr ); 58 59 59 60 /// Returns true if the expression may contain side-effect,
Note: See TracChangeset
for help on using the changeset viewer.