Changeset 53d55b6 for src/AST/Pass.hpp


Ignore:
Timestamp:
Oct 27, 2020, 4:14:48 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
1be1e5a, b35ab2d
Parents:
5d2db68
Message:

Changed approach for isInFunction and implemented for old ast

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.hpp

    r5d2db68 r53d55b6  
    6565//                           corresponding postvisit/postmutate teminates.
    6666// | WithVisitorRef        - provides an pointer to the templated visitor wrapper
    67 // | WithIsInFuncion       - provides a way to access the inFunction
    6867// | WithSymbolTable       - provides symbol table functionality
    6968// | WithForallSubstitutor - maintains links between TypeInstType and TypeDecl under mutation
     
    8988                if(visitor) {
    9089                        *const_cast<type **>( visitor ) = this;
    91                 }
    92 
    93                 // After the pass is constructed, check if it wants to track the inFunction field
    94                 const bool * const * infunc_ptr = __pass::infunc_ptr(core, 0);
    95                 if(infunc_ptr) {
    96                         *const_cast<const bool **>( infunc_ptr ) = &this->inFunction;
    9790                }
    9891        }
     
    235228        template<typename core_type>
    236229        friend void accept_all( std::list< ptr<Decl> > & decls, Pass<core_type>& visitor );
     230
     231        bool isInFunction() const {
     232                return inFunction;
     233        }
     234
    237235private:
    238236
     
    385383struct WithVisitorRef {
    386384        Pass<core_t> * const visitor = nullptr;
    387 };
    388 
    389 /// Used to track whether or not we are in a function.
    390 class WithIsInFuncion {
    391         const bool * const infunc_ptr = nullptr;
    392 
    393         template<typename core_t>
    394         friend class Pass;
    395 public:
    396         bool isInFunction() {
    397                 assert( infunc_ptr );
    398                 return *infunc_ptr;
     385
     386        bool isInFunction() const {
     387                return visitor->isInFunction();
    399388        }
    400389};
Note: See TracChangeset for help on using the changeset viewer.