Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.hpp

    re67991f re0e9a0b  
    3535#include "AST/SymbolTable.hpp"
    3636
     37#include "AST/ForallSubstitutionTable.hpp"
     38
    3739// Private prelude header, needed for some of the magic tricks this class pulls off
    3840#include "AST/Pass.proto.hpp"
     
    4648//
    4749// Several additional features are available through inheritance
    48 // | WithTypeSubstitution - provides polymorphic const TypeSubstitution * env for the
    49 //                          current expression
    50 // | WithStmtsToAdd       - provides the ability to insert statements before or after the current
    51 //                          statement by adding new statements into stmtsToAddBefore or
    52 //                          stmtsToAddAfter respectively.
    53 // | WithDeclsToAdd       - provides the ability to insert declarations before or after the current
    54 //                          declarations by adding new DeclStmt into declsToAddBefore or
    55 //                          declsToAddAfter respectively.
    56 // | WithShortCircuiting  - provides the ability to skip visiting child nodes; set visit_children
    57 //                          to false in pre{visit,visit} to skip visiting children
    58 // | WithGuards           - provides the ability to save/restore data like a LIFO stack; to save,
    59 //                          call GuardValue with the variable to save, the variable will
    60 //                          automatically be restored to its previous value after the corresponding
    61 //                          postvisit/postmutate teminates.
    62 // | WithVisitorRef       - provides an pointer to the templated visitor wrapper
    63 // | WithSymbolTable      - provides symbol table functionality
     50// | WithTypeSubstitution  - provides polymorphic const TypeSubstitution * env for the
     51//                           current expression
     52// | WithStmtsToAdd        - provides the ability to insert statements before or after the current
     53//                           statement by adding new statements into stmtsToAddBefore or
     54//                           stmtsToAddAfter respectively.
     55// | WithDeclsToAdd        - provides the ability to insert declarations before or after the
     56//                           current declarations by adding new DeclStmt into declsToAddBefore or
     57//                           declsToAddAfter respectively.
     58// | WithShortCircuiting   - provides the ability to skip visiting child nodes; set visit_children
     59//                           to false in pre{visit,visit} to skip visiting children
     60// | WithGuards            - provides the ability to save/restore data like a LIFO stack; to save,
     61//                           call GuardValue with the variable to save, the variable will
     62//                           automatically be restored to its previous value after the
     63//                           corresponding postvisit/postmutate teminates.
     64// | WithVisitorRef        - provides an pointer to the templated visitor wrapper
     65// | WithSymbolTable       - provides symbol table functionality
     66// | WithForallSubstitutor - maintains links between TypeInstType and TypeDecl under mutation
    6467//-------------------------------------------------------------------------------------------------
    6568template< typename pass_t >
     
    112115        const ast::Stmt *             visit( const ast::FinallyStmt          * ) override final;
    113116        const ast::Stmt *             visit( const ast::WaitForStmt          * ) override final;
    114         const ast::Decl *             visit( const ast::WithStmt             * ) override final;
     117        const ast::Stmt *             visit( const ast::WithStmt             * ) override final;
    115118        const ast::NullStmt *         visit( const ast::NullStmt             * ) override final;
    116119        const ast::Stmt *             visit( const ast::DeclStmt             * ) override final;
     
    201204        container_t< ptr<node_t> > call_accept( const container_t< ptr<node_t> > & container );
    202205
     206        /// Mutate forall-list, accounting for presence of type substitution map
     207        template<typename node_t>
     208        void mutate_forall( const node_t *& );
     209
    203210public:
    204211        /// Logic to call the accept and mutate the parent if needed, delegates call to accept
     
    209216        /// Internal RAII guard for symbol table features
    210217        struct guard_symtab {
    211                 guard_symtab( Pass<pass_t> & pass ): pass( pass ) { __pass::symtab::enter(pass, 0); }
    212                 ~guard_symtab()                                   { __pass::symtab::leave(pass, 0); }
     218                guard_symtab( Pass<pass_t> & pass ): pass( pass ) { __pass::symtab::enter(pass.pass, 0); }
     219                ~guard_symtab()                                   { __pass::symtab::leave(pass.pass, 0); }
    213220                Pass<pass_t> & pass;
    214221        };
     
    216223        /// Internal RAII guard for scope features
    217224        struct guard_scope {
    218                 guard_scope( Pass<pass_t> & pass ): pass( pass ) { __pass::scope::enter(pass, 0); }
    219                 ~guard_scope()                                   { __pass::scope::leave(pass, 0); }
     225                guard_scope( Pass<pass_t> & pass ): pass( pass ) { __pass::scope::enter(pass.pass, 0); }
     226                ~guard_scope()                                   { __pass::scope::leave(pass.pass, 0); }
    220227                Pass<pass_t> & pass;
     228        };
     229
     230        /// Internal RAII guard for forall substitutions
     231        struct guard_forall_subs {
     232                guard_forall_subs( Pass<pass_t> & pass, const ParameterizedType * type )
     233                : pass( pass ), type( type ) { __pass::forall::enter(pass.pass, 0, type ); }
     234                ~guard_forall_subs()         { __pass::forall::leave(pass.pass, 0, type ); }
     235                Pass<pass_t> & pass;
     236                const ParameterizedType * type;
    221237        };
    222238
     
    313329        SymbolTable symtab;
    314330};
     331
     332/// Use when the templated visitor needs to keep TypeInstType instances properly linked to TypeDecl
     333struct WithForallSubstitutor {
     334        ForallSubstitutionTable subs;
     335};
     336
    315337}
    316338
Note: See TracChangeset for help on using the changeset viewer.