Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Tuples/TupleExpansion.cc

    r027c496 rf0ecf9b  
    315315        namespace {
    316316                /// 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:
    318319                        ImpurityDetector( bool ignoreUnique ) : ignoreUnique( ignoreUnique ) {}
    319320
    320                         void previsit( ApplicationExpr * appExpr ) {
    321                                 visit_children = false;
     321                        typedef Visitor Parent;
     322                        virtual void visit( ApplicationExpr * appExpr ) {
    322323                                if ( DeclarationWithType * function = InitTweak::getFunction( appExpr ) ) {
    323324                                        if ( function->get_linkage() == LinkageSpec::Intrinsic ) {
    324325                                                if ( function->get_name() == "*?" || function->get_name() == "?[?]" ) {
    325326                                                        // intrinsic dereference, subscript are pure, but need to recursively look for impurity
    326                                                         visit_children = true;
     327                                                        Parent::visit( appExpr );
    327328                                                        return;
    328329                                                }
     
    331332                                maybeImpure = true;
    332333                        }
    333                         void previsit( UntypedExpr * ) { maybeImpure = true; visit_children = false; }
    334                         void previsit( UniqueExpr * ) {
     334                        virtual void visit( UntypedExpr * ) { maybeImpure = true; }
     335                        virtual void visit( UniqueExpr * unq ) {
    335336                                if ( ignoreUnique ) {
    336337                                        // bottom out at unique expression.
    337338                                        // The existence of a unique expression doesn't change the purity of an expression.
    338339                                        // That is, even if the wrapped expression is impure, the wrapper protects the rest of the expression.
    339                                         visit_children = false;
    340340                                        return;
    341341                                }
     342                                maybeAccept( unq->expr, *this );
    342343                        }
    343344
     
    348349
    349350        bool maybeImpure( Expression * expr ) {
    350                 PassVisitor<ImpurityDetector> detector( false );
     351                ImpurityDetector detector( false );
    351352                expr->accept( detector );
    352                 return detector.pass.maybeImpure;
     353                return detector.maybeImpure;
    353354        }
    354355
    355356        bool maybeImpureIgnoreUnique( Expression * expr ) {
    356                 PassVisitor<ImpurityDetector> detector( true );
     357                ImpurityDetector detector( true );
    357358                expr->accept( detector );
    358                 return detector.pass.maybeImpure;
     359                return detector.maybeImpure;
    359360        }
    360361} // namespace Tuples
Note: See TracChangeset for help on using the changeset viewer.