Changeset 53d55b6


Ignore:
Timestamp:
Oct 27, 2020, 4:14:48 PM (12 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
1be1e5a, b35ab2d
Parents:
5d2db68
Message:

Changed approach for isInFunction and implemented for old ast

Location:
src
Files:
3 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};
  • src/AST/Pass.proto.hpp

    r5d2db68 r53d55b6  
    244244        FIELD_PTR( at_cleanup, __pass::at_cleanup_t )
    245245        FIELD_PTR( visitor, ast::Pass<core_t> * const )
    246         FIELD_PTR( infunc_ptr, const bool * const )
    247246
    248247        // Remove the macro to make sure we don't clash
  • src/Common/PassVisitor.h

    r5d2db68 r53d55b6  
    354354        virtual TypeSubstitution * mutate( TypeSubstitution * sub ) final;
    355355
     356        bool isInFunction() const {
     357                return inFunction;
     358        }
     359
    356360private:
    357361        bool inFunction = false;
     
    526530public:
    527531        PassVisitor<pass_type> * const visitor = nullptr;
     532
     533        bool isInFunction() const {
     534                return visitor->inFunction;
     535        }
    528536};
    529537
Note: See TracChangeset for help on using the changeset viewer.