Changes in src/AST/Pass.hpp [b2a11ba:73f1b1c]
- File:
-
- 1 edited
-
src/AST/Pass.hpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.hpp
rb2a11ba r73f1b1c 50 50 // | PureVisitor - makes the visitor pure, it never modifies nodes in place and always 51 51 // clones nodes it needs to make changes to 52 // | With ConstTypeSubstitution - provides polymorphic const TypeSubstitution * typeSubsfor the52 // | WithTypeSubstitution - provides polymorphic const TypeSubstitution * env for the 53 53 // current expression 54 54 // | WithStmtsToAdd - provides the ability to insert statements before or after the current … … 67 67 // | WithSymbolTable - provides symbol table functionality 68 68 // | WithForallSubstitutor - maintains links between TypeInstType and TypeDecl under mutation 69 //70 // Other Special Members:71 // | result - Either a method that takes no parameters or a field. If a method (or72 // callable field) get_result calls it, otherwise the value is returned.73 69 //------------------------------------------------------------------------------------------------- 74 70 template< typename core_t > … … 93 89 virtual ~Pass() = default; 94 90 95 /// Storage for the actual pass.96 core_t core;97 98 /// If the core defines a result, call it if possible, otherwise return it.99 inline auto get_result() -> decltype( __pass::get_result( core, '0' ) ) {100 return __pass::get_result( core, '0' );101 }102 103 91 /// Construct and run a pass on a translation unit. 104 92 template< typename... Args > … … 108 96 } 109 97 110 /// Contruct and run a pass on a pointer to extract a value.111 template< typename node_type, typename... Args >112 static auto read( node_type const * node, Args&&... args ) {113 Pass<core_t> visitor( std::forward<Args>( args )... );114 node_type const * temp = node->accept( visitor );115 assert( temp == node );116 return visitor.get_result();117 }118 119 // Versions of the above for older compilers.120 98 template< typename... Args > 121 99 static void run( std::list< ptr<Decl> > & decls ) { … … 124 102 } 125 103 126 template< typename node_type, typename... Args > 127 static auto read( node_type const * node ) { 128 Pass<core_t> visitor; 129 node_type const * temp = node->accept( visitor ); 130 assert( temp == node ); 131 return visitor.get_result(); 132 } 104 /// Storage for the actual pass 105 core_t core; 133 106 134 107 /// Visit function declarations … … 294 267 //------------------------------------------------------------------------------------------------- 295 268 269 /// Keep track of the polymorphic const TypeSubstitution * env for the current expression 270 296 271 /// If used the visitor will always clone nodes. 297 272 struct PureVisitor {}; 298 273 299 /// Keep track of the polymorphic const TypeSubstitution * typeSubs for the current expression.300 274 struct WithConstTypeSubstitution { 301 const TypeSubstitution * typeSubs= nullptr;275 const TypeSubstitution * env = nullptr; 302 276 }; 303 277
Note:
See TracChangeset
for help on using the changeset viewer.