Changeset 9e23b446 for src/AST/Pass.impl.hpp
- Timestamp:
- Jul 25, 2022, 2:23:00 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- ffec1bf
- Parents:
- 76a798d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.impl.hpp
r76a798d r9e23b446 155 155 __pedantic_pass_assert( expr ); 156 156 157 const ast::TypeSubstitution ** typeSubs_ptr = __pass::typeSubs( core, 0 );158 if ( typeSubs_ptr && expr->env ) {159 *typeSubs_ptr = expr->env;160 }161 162 157 auto nval = expr->accept( *this ); 163 158 return { nval != expr, nval }; … … 171 166 const ast::Stmt * nval = stmt->accept( *this ); 172 167 return { nval != stmt, nval }; 168 } 169 170 template< typename core_t > 171 __pass::template result1<ast::Expr> ast::Pass< core_t >::call_accept_top( const ast::Expr * expr ) { 172 __pedantic_pass_assert( __visit_children() ); 173 __pedantic_pass_assert( expr ); 174 175 const ast::TypeSubstitution ** typeSubs_ptr = __pass::typeSubs( core, 0 ); 176 if ( typeSubs_ptr && expr->env ) { 177 *typeSubs_ptr = expr->env; 178 } 179 180 auto nval = expr->accept( *this ); 181 return { nval != expr, nval }; 173 182 } 174 183 … … 410 419 411 420 auto new_val = call_accept( old_val ); 421 422 static_assert( !std::is_same<const ast::Node *, decltype(new_val)>::value /* || std::is_same<int, decltype(old_val)>::value */, "ERROR"); 423 424 if( new_val.differs ) { 425 auto new_parent = __pass::mutate<core_t>(parent); 426 new_val.apply(new_parent, field); 427 parent = new_parent; 428 } 429 } 430 431 template< typename core_t > 432 template<typename node_t, typename super_t, typename field_t> 433 void ast::Pass< core_t >::maybe_accept_top( 434 const node_t * & parent, 435 field_t super_t::*field 436 ) { 437 static_assert( std::is_base_of<super_t, node_t>::value, "Error deducing member object" ); 438 439 if(__pass::skip(parent->*field)) return; 440 const auto & old_val = __pass::get(parent->*field, 0); 441 442 static_assert( !std::is_same<const ast::Node * &, decltype(old_val)>::value, "ERROR"); 443 444 auto new_val = call_accept_top( old_val ); 412 445 413 446 static_assert( !std::is_same<const ast::Node *, decltype(new_val)>::value /* || std::is_same<int, decltype(old_val)>::value */, "ERROR"); … … 755 788 756 789 if ( __visit_children() ) { 757 maybe_accept ( node, &StaticAssertDecl::cond );790 maybe_accept_top( node, &StaticAssertDecl::cond ); 758 791 maybe_accept( node, &StaticAssertDecl::msg ); 759 792 } … … 797 830 798 831 if ( __visit_children() ) { 799 maybe_accept ( node, &ExprStmt::expr );832 maybe_accept_top( node, &ExprStmt::expr ); 800 833 } 801 834 … … 838 871 guard_symtab guard { *this }; 839 872 maybe_accept( node, &IfStmt::inits ); 840 maybe_accept ( node, &IfStmt::cond );873 maybe_accept_top( node, &IfStmt::cond ); 841 874 maybe_accept_as_compound( node, &IfStmt::then ); 842 875 maybe_accept_as_compound( node, &IfStmt::else_ ); … … 856 889 guard_symtab guard { *this }; 857 890 maybe_accept( node, &WhileDoStmt::inits ); 858 maybe_accept ( node, &WhileDoStmt::cond );891 maybe_accept_top( node, &WhileDoStmt::cond ); 859 892 maybe_accept_as_compound( node, &WhileDoStmt::body ); 860 893 } … … 874 907 // xxx - old ast does not create WithStmtsToAdd scope for loop inits. should revisit this later. 875 908 maybe_accept( node, &ForStmt::inits ); 876 maybe_accept ( node, &ForStmt::cond );877 maybe_accept ( node, &ForStmt::inc );909 maybe_accept_top( node, &ForStmt::cond ); 910 maybe_accept_top( node, &ForStmt::inc ); 878 911 maybe_accept_as_compound( node, &ForStmt::body ); 879 912 } … … 889 922 890 923 if ( __visit_children() ) { 891 maybe_accept ( node, &SwitchStmt::cond );924 maybe_accept_top( node, &SwitchStmt::cond ); 892 925 maybe_accept( node, &SwitchStmt::cases ); 893 926 } … … 903 936 904 937 if ( __visit_children() ) { 905 maybe_accept ( node, &CaseClause::cond );938 maybe_accept_top( node, &CaseClause::cond ); 906 939 maybe_accept( node, &CaseClause::stmts ); 907 940 } … … 925 958 926 959 if ( __visit_children() ) { 927 maybe_accept ( node, &ReturnStmt::expr );960 maybe_accept_top( node, &ReturnStmt::expr ); 928 961 } 929 962 … … 970 1003 guard_symtab guard { *this }; 971 1004 maybe_accept( node, &CatchClause::decl ); 972 maybe_accept ( node, &CatchClause::cond );1005 maybe_accept_top( node, &CatchClause::cond ); 973 1006 maybe_accept_as_compound( node, &CatchClause::body ); 974 1007 } … … 2057 2090 2058 2091 if ( __visit_children() ) { 2059 maybe_accept ( node, &SingleInit::value );2092 maybe_accept_top( node, &SingleInit::value ); 2060 2093 } 2061 2094
Note: See TracChangeset
for help on using the changeset viewer.