Changes in src/AST/Pass.impl.hpp [eb211bf:f8143a6]
- File:
-
- 1 edited
-
src/AST/Pass.impl.hpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.impl.hpp
reb211bf rf8143a6 111 111 } 112 112 113 113 114 //------------------------------ 114 115 /// Check if value was mutated, different for pointers and containers … … 124 125 } 125 126 127 128 template< typename core_t > 126 129 template< typename node_t > 127 130 template< typename object_t, typename super_t, typename field_t > 128 void __pass::result1< node_t >::apply( object_t * object, field_t super_t::* field) {131 void ast::Pass< core_t >::result1< node_t >::apply(object_t * object, field_t super_t::* field) { 129 132 object->*field = value; 130 133 } … … 133 136 template< typename node_t > 134 137 auto ast::Pass< core_t >::call_accept( const node_t * node ) 135 -> typename ast::Pass< core_t >::template generic_call_accept_result<node_t>::type 138 -> typename std::enable_if< 139 !std::is_base_of<ast::Expr, node_t>::value && 140 !std::is_base_of<ast::Stmt, node_t>::value 141 , ast::Pass< core_t >::result1< 142 typename std::remove_pointer< decltype( node->accept(*this) ) >::type 143 > 144 >::type 136 145 { 137 146 __pedantic_pass_assert( __visit_children() ); … … 142 151 143 152 auto nval = node->accept( *this ); 144 __pass::result1<153 ast::Pass< core_t >::result1< 145 154 typename std::remove_pointer< decltype( node->accept(*this) ) >::type 146 155 > res; … … 151 160 152 161 template< typename core_t > 153 __pass::templateresult1<ast::Expr> ast::Pass< core_t >::call_accept( const ast::Expr * expr ) {162 ast::Pass< core_t >::result1<ast::Expr> ast::Pass< core_t >::call_accept( const ast::Expr * expr ) { 154 163 __pedantic_pass_assert( __visit_children() ); 155 164 __pedantic_pass_assert( expr ); … … 165 174 166 175 template< typename core_t > 167 __pass::templateresult1<ast::Stmt> ast::Pass< core_t >::call_accept( const ast::Stmt * stmt ) {176 ast::Pass< core_t >::result1<ast::Stmt> ast::Pass< core_t >::call_accept( const ast::Stmt * stmt ) { 168 177 __pedantic_pass_assert( __visit_children() ); 169 178 __pedantic_pass_assert( stmt ); … … 174 183 175 184 template< typename core_t > 176 __pass::templateresult1<ast::Stmt> ast::Pass< core_t >::call_accept_as_compound( const ast::Stmt * stmt ) {185 ast::Pass< core_t >::result1<ast::Stmt> ast::Pass< core_t >::call_accept_as_compound( const ast::Stmt * stmt ) { 177 186 __pedantic_pass_assert( __visit_children() ); 178 187 __pedantic_pass_assert( stmt ); … … 224 233 } 225 234 235 template< typename core_t > 226 236 template< template <class...> class container_t > 227 237 template< typename object_t, typename super_t, typename field_t > 228 void __pass::resultNstmt<container_t>::apply(object_t * object, field_t super_t::* field) {238 void ast::Pass< core_t >::resultNstmt<container_t>::apply(object_t * object, field_t super_t::* field) { 229 239 auto & container = object->*field; 230 240 __pedantic_pass_assert( container.size() <= values.size() ); … … 233 243 234 244 container_t<ptr<Stmt>> nvals; 235 for (delta & d : values) {236 if ( d.is_old ) {245 for(delta & d : values) { 246 if( d.is_old ) { 237 247 __pedantic_pass_assert( cit.idx <= d.old_idx ); 238 248 std::advance( cit, d.old_idx - cit.idx ); 239 249 nvals.push_back( std::move( (*cit).val) ); 240 250 } else { 241 nvals.push_back( std::move(d.n ew_val) );251 nvals.push_back( std::move(d.nval) ); 242 252 } 243 253 } 244 254 245 container = std::move(nvals); 246 } 247 248 template< template <class...> class container_t > 249 template< template <class...> class incontainer_t > 250 void __pass::resultNstmt< container_t >::take_all( incontainer_t<ptr<Stmt>> * stmts ) { 251 if (!stmts || stmts->empty()) return; 252 253 std::transform(stmts->begin(), stmts->end(), std::back_inserter( values ), 254 [](ast::ptr<ast::Stmt>& stmt) -> delta { 255 return delta( stmt.release(), -1, false ); 256 }); 257 stmts->clear(); 258 differs = true; 259 } 260 261 template< template<class...> class container_t > 262 template< template<class...> class incontainer_t > 263 void __pass::resultNstmt< container_t >::take_all( incontainer_t<ptr<Decl>> * decls ) { 264 if (!decls || decls->empty()) return; 265 266 std::transform(decls->begin(), decls->end(), std::back_inserter( values ), 267 [](ast::ptr<ast::Decl>& decl) -> delta { 268 auto loc = decl->location; 269 auto stmt = new DeclStmt( loc, decl.release() ); 270 return delta( stmt, -1, false ); 271 }); 272 decls->clear(); 273 differs = true; 255 object->*field = std::move(nvals); 274 256 } 275 257 276 258 template< typename core_t > 277 259 template< template <class...> class container_t > 278 __pass::templateresultNstmt<container_t> ast::Pass< core_t >::call_accept( const container_t< ptr<Stmt> > & statements ) {260 ast::Pass< core_t >::resultNstmt<container_t> ast::Pass< core_t >::call_accept( const container_t< ptr<Stmt> > & statements ) { 279 261 __pedantic_pass_assert( __visit_children() ); 280 262 if( statements.empty() ) return {}; … … 303 285 pass_visitor_stats.avg->push(pass_visitor_stats.depth); 304 286 305 __pass::resultNstmt<container_t> new_kids;287 resultNstmt<container_t> new_kids; 306 288 for( auto value : enumerate( statements ) ) { 307 289 try { … … 345 327 } 346 328 329 template< typename core_t > 347 330 template< template <class...> class container_t, typename node_t > 348 331 template< typename object_t, typename super_t, typename field_t > 349 void __pass::resultN<container_t, node_t>::apply(object_t * object, field_t super_t::* field) {332 void ast::Pass< core_t >::resultN<container_t, node_t>::apply(object_t * object, field_t super_t::* field) { 350 333 auto & container = object->*field; 351 334 __pedantic_pass_assert( container.size() == values.size() ); … … 363 346 template< typename core_t > 364 347 template< template <class...> class container_t, typename node_t > 365 __pass::templateresultN<container_t, node_t> ast::Pass< core_t >::call_accept( const container_t< ast::ptr<node_t> > & container ) {348 ast::Pass< core_t >::resultN<container_t, node_t> ast::Pass< core_t >::call_accept( const container_t< ast::ptr<node_t> > & container ) { 366 349 __pedantic_pass_assert( __visit_children() ); 367 350 if( container.empty() ) return {}; … … 395 378 if ( ! errors.isEmpty() ) { throw errors; } 396 379 397 return ast:: __pass::resultN<container_t, node_t>{ mutated,new_kids };380 return ast::Pass< core_t >::resultN<container_t, node_t>{ mutated, new_kids }; 398 381 } 399 382
Note:
See TracChangeset
for help on using the changeset viewer.