Changes in / [1f950c3b:ffec1bf]
- Location:
- src
- Files:
-
- 1 added
- 10 edited
-
AST/Pass.hpp (modified) (2 diffs)
-
AST/Pass.impl.hpp (modified) (13 diffs)
-
AST/SymbolTable.cpp (modified) (2 diffs)
-
AST/TypeSubstitution.cpp (modified) (1 diff)
-
GenPoly/Specialize.h (modified) (2 diffs)
-
GenPoly/SpecializeNew.cpp (added)
-
GenPoly/module.mk (modified) (1 diff)
-
InitTweak/FixInitNew.cpp (modified) (2 diffs)
-
ResolvExpr/CandidateFinder.cpp (modified) (1 diff)
-
ResolvExpr/Resolver.cc (modified) (2 diffs)
-
main.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.hpp
r1f950c3b rffec1bf 264 264 __pass::result1<ast::Stmt> call_accept_as_compound(const ast::Stmt *); 265 265 266 // requests type environment to be updated (why is it implemented like this?) 267 __pass::result1<ast::Expr> call_accept_top(const ast::Expr *); 268 266 269 template< template <class...> class container_t > 267 270 __pass::resultNstmt<container_t> call_accept( const container_t< ptr<Stmt> > & ); … … 277 280 template<typename node_t, typename parent_t, typename field_t> 278 281 void maybe_accept_as_compound(const node_t * &, field_t parent_t::* field); 282 283 template<typename node_t, typename parent_t, typename field_t> 284 void maybe_accept_top(const node_t * &, field_t parent_t::* field); 279 285 280 286 private: -
src/AST/Pass.impl.hpp
r1f950c3b rffec1bf 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"); … … 756 789 757 790 if ( __visit_children() ) { 758 maybe_accept ( node, &StaticAssertDecl::cond );791 maybe_accept_top( node, &StaticAssertDecl::cond ); 759 792 maybe_accept( node, &StaticAssertDecl::msg ); 760 793 } … … 798 831 799 832 if ( __visit_children() ) { 800 maybe_accept ( node, &ExprStmt::expr );833 maybe_accept_top( node, &ExprStmt::expr ); 801 834 } 802 835 … … 839 872 guard_symtab guard { *this }; 840 873 maybe_accept( node, &IfStmt::inits ); 841 maybe_accept ( node, &IfStmt::cond );874 maybe_accept_top( node, &IfStmt::cond ); 842 875 maybe_accept_as_compound( node, &IfStmt::then ); 843 876 maybe_accept_as_compound( node, &IfStmt::else_ ); … … 857 890 guard_symtab guard { *this }; 858 891 maybe_accept( node, &WhileDoStmt::inits ); 859 maybe_accept ( node, &WhileDoStmt::cond );892 maybe_accept_top( node, &WhileDoStmt::cond ); 860 893 maybe_accept_as_compound( node, &WhileDoStmt::body ); 861 894 } … … 875 908 // xxx - old ast does not create WithStmtsToAdd scope for loop inits. should revisit this later. 876 909 maybe_accept( node, &ForStmt::inits ); 877 maybe_accept ( node, &ForStmt::cond );878 maybe_accept ( node, &ForStmt::inc );910 maybe_accept_top( node, &ForStmt::cond ); 911 maybe_accept_top( node, &ForStmt::inc ); 879 912 maybe_accept_as_compound( node, &ForStmt::body ); 880 913 } … … 890 923 891 924 if ( __visit_children() ) { 892 maybe_accept ( node, &SwitchStmt::cond );925 maybe_accept_top( node, &SwitchStmt::cond ); 893 926 maybe_accept( node, &SwitchStmt::cases ); 894 927 } … … 904 937 905 938 if ( __visit_children() ) { 906 maybe_accept ( node, &CaseClause::cond );939 maybe_accept_top( node, &CaseClause::cond ); 907 940 maybe_accept( node, &CaseClause::stmts ); 908 941 } … … 926 959 927 960 if ( __visit_children() ) { 928 maybe_accept ( node, &ReturnStmt::expr );961 maybe_accept_top( node, &ReturnStmt::expr ); 929 962 } 930 963 … … 971 1004 guard_symtab guard { *this }; 972 1005 maybe_accept( node, &CatchClause::decl ); 973 maybe_accept ( node, &CatchClause::cond );1006 maybe_accept_top( node, &CatchClause::cond ); 974 1007 maybe_accept_as_compound( node, &CatchClause::body ); 975 1008 } … … 2058 2091 2059 2092 if ( __visit_children() ) { 2060 maybe_accept ( node, &SingleInit::value );2093 maybe_accept_top( node, &SingleInit::value ); 2061 2094 } 2062 2095 -
src/AST/SymbolTable.cpp
r1f950c3b rffec1bf 65 65 66 66 Expr * SymbolTable::IdData::combine( const CodeLocation & loc, ResolvExpr::Cost & cost ) const { 67 Expr * ret = ( baseExpr ) ? 68 (Expr *)new MemberExpr{ loc, id, referenceToRvalueConversion( baseExpr, cost ) } : 69 (Expr *)new VariableExpr{ loc, id }; 67 Expr * ret; 68 if ( baseExpr ) { 69 if (baseExpr->env) { 70 Expr * base = shallowCopy(baseExpr); 71 const TypeSubstitution * subs = baseExpr->env; 72 base->env = nullptr; 73 ret = new MemberExpr{loc, id, referenceToRvalueConversion( base, cost )}; 74 ret->env = subs; 75 } 76 else { 77 ret = new MemberExpr{ loc, id, referenceToRvalueConversion( baseExpr, cost ) }; 78 } 79 } 80 else { 81 ret = new VariableExpr{ loc, id }; 82 } 70 83 if ( deleter ) { ret = new DeletedExpr{ loc, ret, deleter }; } 71 84 return ret; … … 772 785 && ! dynamic_cast<const UnionInstType *>(rty) ) continue; 773 786 ResolvExpr::Cost cost = ResolvExpr::Cost::zero; 787 ast::ptr<ast::TypeSubstitution> tmp = expr->env; 788 expr = mutate_field(expr, &Expr::env, nullptr); 774 789 const Expr * base = ResolvExpr::referenceToRvalueConversion( expr, cost ); 790 base = mutate_field(base, &Expr::env, tmp); 791 775 792 addMembers( 776 793 rty->aggr(), new MemberExpr{ base->location, dwt, base }, handleConflicts ); -
src/AST/TypeSubstitution.cpp
r1f950c3b rffec1bf 97 97 TypeSubstitution * newEnv; 98 98 EnvTrimmer( const TypeSubstitution * env, TypeSubstitution * newEnv ) : env( env ), newEnv( newEnv ){} 99 void previsit( FunctionType * ftype ) {99 void previsit( const FunctionType * ftype ) { 100 100 // transfer known bindings for seen type variables 101 101 for (auto & formal : ftype->forall) { -
src/GenPoly/Specialize.h
r1f950c3b rffec1bf 17 17 18 18 #include <list> // for list 19 #include "AST/TranslationUnit.hpp" 19 20 20 21 class Declaration; … … 23 24 /// generates thunks where needed 24 25 void convertSpecializations( std::list< Declaration* >& translationUnit ); 26 27 void convertSpecializations( ast::TranslationUnit & translationUnit ); 25 28 } // namespace GenPoly 26 29 -
src/GenPoly/module.mk
r1f950c3b rffec1bf 34 34 GenPoly/ScrubTyVars.h \ 35 35 GenPoly/Specialize.cc \ 36 GenPoly/SpecializeNew.cpp \ 36 37 GenPoly/Specialize.h 37 38 -
src/InitTweak/FixInitNew.cpp
r1f950c3b rffec1bf 73 73 /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which 74 74 /// function calls need their parameters to be copy constructed 75 struct InsertImplicitCalls : public ast::With ConstTypeSubstitution, public ast::WithShortCircuiting {75 struct InsertImplicitCalls : public ast::WithShortCircuiting { 76 76 const ast::Expr * postvisit( const ast::ApplicationExpr * appExpr ); 77 77 … … 457 457 // is needed to obtain the type of temporary variables so that copy 458 458 // constructor calls can be resolved. 459 assert( typeSubs );460 459 expr->env = tmp; 461 460 return expr; -
src/ResolvExpr/CandidateFinder.cpp
r1f950c3b rffec1bf 1263 1263 newExpr, copy( tenv ), ast::OpenVarSet{}, ast::AssertionSet{}, Cost::zero, 1264 1264 cost ); 1265 1266 if (newCand->expr->env) { 1267 newCand->env.add(*newCand->expr->env); 1268 auto mutExpr = newCand->expr.get_and_mutate(); 1269 mutExpr->env = nullptr; 1270 newCand->expr = mutExpr; 1271 } 1272 1265 1273 PRINT( 1266 1274 std::cerr << "decl is "; -
src/ResolvExpr/Resolver.cc
r1f950c3b rffec1bf 1555 1555 if ( type->dimension ) { 1556 1556 ast::ptr< ast::Type > sizeType = context.global.sizeType; 1557 ast::ptr< ast::Expr > dimension = findSingleExpression( type->dimension, sizeType, context ); 1558 assertf(dimension->env->empty(), "array dimension expr has nonempty env"); 1559 dimension.get_and_mutate()->env = nullptr; 1557 1560 ast::mutate_field( 1558 1561 type, &PtrType::dimension, 1559 findSingleExpression( type->dimension, sizeType, context ));1562 dimension); 1560 1563 } 1561 1564 return type; … … 2008 2011 tmp->accept( *visitor ); 2009 2012 } 2013 else if (expr->env && expr->env->empty()) { 2014 expr = ast::mutate_field(expr.get(), &ast::Expr::env, nullptr); 2015 } 2010 2016 } 2011 2017 } -
src/main.cc
r1f950c3b rffec1bf 439 439 PASS( "Translate Tries", ControlStruct::translateTries( transUnit ) ); 440 440 PASS( "Gen Waitfor", Concurrency::generateWaitFor( transUnit ) ); 441 PASS( "Convert Specializations", GenPoly::convertSpecializations( transUnit ) ); // needs to happen before tuple types are expanded 442 441 443 442 444 translationUnit = convert( move( transUnit ) ); … … 513 515 PASS( "Translate Tries", ControlStruct::translateTries( translationUnit ) ); 514 516 PASS( "Gen Waitfor", Concurrency::generateWaitFor( translationUnit ) ); 517 PASS( "Convert Specializations", GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded 518 515 519 } 516 520 517 PASS( "Convert Specializations", GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded 521 522 // PASS( "Convert Specializations", GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded 518 523 519 524 PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?
Note:
See TracChangeset
for help on using the changeset viewer.