Changes in src/AST/Pass.hpp [73f1b1c:e6b42e7]
- File:
-
- 1 edited
-
src/AST/Pass.hpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.hpp
r73f1b1c re6b42e7 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 (or 72 // callable field) get_result calls it, otherwise the value is returned. 69 73 //------------------------------------------------------------------------------------------------- 70 74 template< typename core_t > … … 89 93 virtual ~Pass() = default; 90 94 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 91 103 /// Construct and run a pass on a translation unit. 92 104 template< typename... Args > … … 96 108 } 97 109 98 template< typename... Args > 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. 99 120 static void run( std::list< ptr<Decl> > & decls ) { 100 121 Pass<core_t> visitor; … … 102 123 } 103 124 104 /// Storage for the actual pass 105 core_t core; 125 static auto read( Node const * node ) { 126 Pass<core_t> visitor; 127 Node const * temp = node->accept( visitor ); 128 assert( temp == node ); 129 return visitor.get_result(); 130 } 106 131 107 132 /// Visit function declarations
Note:
See TracChangeset
for help on using the changeset viewer.