Changeset cb25fc9


Ignore:
Timestamp:
Oct 27, 2020, 3:26:27 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:
5d2db68
Parents:
342be43
Message:

Added to new ast mixin for checker whether it is inFunction or not

Location:
src/AST
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.hpp

    r342be43 rcb25fc9  
    8888                if(visitor) {
    8989                        *const_cast<type **>( visitor ) = this;
     90                }
     91
     92                // After the pass is constructed, check if it wants to track the inFunction field
     93                const bool * const * infunc_ptr = __pass::infunc_ptr(core, 0);
     94                if(infunc_ptr) {
     95                        *const_cast<const bool **>( infunc_ptr ) = &this->inFunction;
    9096                }
    9197        }
     
    380386};
    381387
     388/// Used to track whether or not we are in a function.
     389class WithIsInFuncion {
     390        const bool * const __in_funct_ptr = nullptr;
     391
     392        template<typename core_t>
     393        friend class Pass;
     394public:
     395        bool isInFunction() {
     396                assert( __in_funct_ptr );
     397                return *__in_funct_ptr;
     398        }
     399};
     400
    382401/// Use when the templated visitor should update the symbol table
    383402struct WithSymbolTable {
  • src/AST/Pass.proto.hpp

    r342be43 rcb25fc9  
    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 )
    246247
    247248        // Remove the macro to make sure we don't clash
Note: See TracChangeset for help on using the changeset viewer.