From 05170cf5cf9d3d04497f27d70b3c20ceb138fa4b Mon Sep 17 00:00:00 2001 From: Thomas Heller Date: Tue, 25 Jan 2011 10:54:07 +0000 Subject: [PATCH] introduced context, contexts contain the environment and the actions [SVN r68430] --- include/boost/phoenix/core/arity.hpp | 2 +- include/boost/phoenix/core/environment.hpp | 121 +++++++++++++----- include/boost/phoenix/core/is_nullary.hpp | 4 +- include/boost/phoenix/core/meta_grammar.hpp | 2 + include/boost/phoenix/core/terminal.hpp | 9 +- include/boost/phoenix/fusion/at.hpp | 2 +- include/boost/phoenix/object/const_cast.hpp | 4 +- include/boost/phoenix/object/construct.hpp | 4 +- include/boost/phoenix/object/delete.hpp | 4 +- include/boost/phoenix/object/dynamic_cast.hpp | 4 +- include/boost/phoenix/object/new.hpp | 4 +- .../boost/phoenix/object/reinterpret_cast.hpp | 4 +- include/boost/phoenix/object/static_cast.hpp | 4 +- include/boost/phoenix/operator/member.hpp | 2 +- .../operator/preprocessed/member_10.hpp | 2 +- .../operator/preprocessed/member_20.hpp | 2 +- .../operator/preprocessed/member_30.hpp | 2 +- .../operator/preprocessed/member_40.hpp | 2 +- .../operator/preprocessed/member_50.hpp | 2 +- include/boost/phoenix/scope/dynamic.hpp | 2 +- include/boost/phoenix/scope/lambda.hpp | 8 +- include/boost/phoenix/scope/let.hpp | 4 +- .../boost/phoenix/scope/local_variable.hpp | 4 +- .../phoenix/scope/scoped_environment.hpp | 16 +-- include/boost/phoenix/statement/do_while.hpp | 2 +- include/boost/phoenix/statement/for.hpp | 10 +- include/boost/phoenix/statement/if.hpp | 4 +- include/boost/phoenix/statement/switch.hpp | 6 +- include/boost/phoenix/statement/throw.hpp | 4 +- include/boost/phoenix/statement/try_catch.hpp | 4 +- include/boost/phoenix/statement/while.hpp | 2 +- 31 files changed, 146 insertions(+), 100 deletions(-) diff --git a/include/boost/phoenix/core/arity.hpp b/include/boost/phoenix/core/arity.hpp index a325fc7..fb4a7c4 100644 --- a/include/boost/phoenix/core/arity.hpp +++ b/include/boost/phoenix/core/arity.hpp @@ -57,7 +57,7 @@ namespace boost { namespace phoenix , mpl::int_<0> , mpl::max< proto::_state - , evaluator(proto::_, _env) + , evaluator(proto::_, _context) >() > {}; diff --git a/include/boost/phoenix/core/environment.hpp b/include/boost/phoenix/core/environment.hpp index 1c7fb6d..c9b2520 100644 --- a/include/boost/phoenix/core/environment.hpp +++ b/include/boost/phoenix/core/environment.hpp @@ -60,43 +60,10 @@ namespace boost { namespace phoenix BOOST_PHOENIX_GET_ENVIRONMENT(actions, 1) #undef BOOST_PHOENIX_GET_ENVIRONMENT - - struct args_at - { - BOOST_PROTO_CALLABLE() - - template - struct result; - - template - struct result - : result - {}; - - template - struct result - : fusion::result_of::at< - typename boost::remove_reference< - typename fusion::result_of::at< - Env - , mpl::int_<0> - >::type - >::type - , typename proto::detail::uncvref::type - > - {}; - - template - typename result::type - operator()(N const & n, Env& env) const - { - return proto::functional::at()(args()(env), n); - } - }; } - struct _env - : proto::transform<_env> + struct _context + : proto::transform<_context> { template struct impl @@ -115,6 +82,90 @@ namespace boost { namespace phoenix }; }; + struct _env + : proto::transform<_env> + { + template + struct impl + : proto::transform_impl + { + typedef State result_type; + + result_type operator()( + typename impl::expr_param + , typename impl::state_param s + , typename impl::data_param + ) const + { + return s; + } + }; + }; + + template + struct _env::impl + : proto::transform_impl + { + typedef + typename fusion::result_of::at_c< + typename boost::remove_reference::type + , 0 + >::type + result_type; + + result_type operator()( + typename impl::expr_param + , typename impl::state_param s + , typename impl::data_param + ) const + { + return fusion::at_c<0>(s); + } + }; + + /* + struct _actions + : proto::transform<_actions> + { + template + struct impl + : proto::transform_impl + { + typedef Data result_type; + + result_type operator()( + typename impl::expr_param + , typename impl::state_param + , typename impl::data_param d + ) const + { + return d; + } + }; + }; + + template + struct _actions::impl + : proto::transform_impl + { + typedef + typename fusion::result_of::at_c< + typename boost::remove_reference::type + , 1 + >::type + result_type; + + result_type operator()( + typename impl::expr_param + , typename impl::state_param s + , typename impl::data_param + ) const + { + return fusion::at_c<1>(s); + } + }; +*/ + template struct is_environment : fusion::traits::is_sequence {}; }} diff --git a/include/boost/phoenix/core/is_nullary.hpp b/include/boost/phoenix/core/is_nullary.hpp index 07c7d52..31b91eb 100644 --- a/include/boost/phoenix/core/is_nullary.hpp +++ b/include/boost/phoenix/core/is_nullary.hpp @@ -32,7 +32,7 @@ namespace boost { namespace phoenix , mpl::true_() , mpl::and_< proto::_state - , evaluator(proto::_, _env) + , evaluator(proto::_, _context) >() > {}; @@ -48,7 +48,7 @@ namespace boost { namespace phoenix : proto::lazy< result_of::is_nullary >( proto::_ - , _env + , _context ) > {}; diff --git a/include/boost/phoenix/core/meta_grammar.hpp b/include/boost/phoenix/core/meta_grammar.hpp index f1cd618..e9ee012 100644 --- a/include/boost/phoenix/core/meta_grammar.hpp +++ b/include/boost/phoenix/core/meta_grammar.hpp @@ -53,6 +53,8 @@ namespace boost { namespace phoenix // construct struct default_actions { + typedef void is_phoenix_action; + template struct when : proto::_default diff --git a/include/boost/phoenix/core/terminal.hpp b/include/boost/phoenix/core/terminal.hpp index cc206aa..229f528 100644 --- a/include/boost/phoenix/core/terminal.hpp +++ b/include/boost/phoenix/core/terminal.hpp @@ -45,7 +45,7 @@ namespace boost { namespace phoenix template struct default_actions::when - : proto::lazy(proto::_value, _env)> + : proto::lazy(proto::_value, _context)> {}; namespace detail @@ -59,10 +59,9 @@ namespace boost { namespace phoenix template struct default_actions::when : proto::call< - functional::args_at( - //mpl::prior()>() - detail::placeholder_idx()>() - , _env + proto::functional::at( + _env + , detail::placeholder_idx()>() ) > {}; diff --git a/include/boost/phoenix/fusion/at.hpp b/include/boost/phoenix/fusion/at.hpp index 91995bf..c75bd88 100644 --- a/include/boost/phoenix/fusion/at.hpp +++ b/include/boost/phoenix/fusion/at.hpp @@ -26,7 +26,7 @@ namespace boost { namespace phoenix struct default_actions::when : proto::call< proto::functional::at( - evaluator(proto::_child_c<1>, _env) + evaluator(proto::_child_c<1>, _context) , proto::_value(proto::_child_c<0>) ) > diff --git a/include/boost/phoenix/object/const_cast.hpp b/include/boost/phoenix/object/const_cast.hpp index 0d8e475..63dedcb 100644 --- a/include/boost/phoenix/object/const_cast.hpp +++ b/include/boost/phoenix/object/const_cast.hpp @@ -38,8 +38,8 @@ namespace boost { namespace phoenix struct default_actions::when : proto::lazy< const_cast_eval< - evaluator(proto::_child_c<0>, _env) - >(_env, proto::_child_c<1>) + evaluator(proto::_child_c<0>, _context) + >(_context, proto::_child_c<1>) > {}; diff --git a/include/boost/phoenix/object/construct.hpp b/include/boost/phoenix/object/construct.hpp index 8a21d0d..47c8503 100644 --- a/include/boost/phoenix/object/construct.hpp +++ b/include/boost/phoenix/object/construct.hpp @@ -48,7 +48,7 @@ namespace boost { namespace phoenix > \ , proto::lazy< \ construct_eval)>( \ - _env \ + _context \ , BOOST_PP_ENUM_SHIFTED( \ BOOST_PP_INC(N) \ , PHOENIX_CONSTRUCT_CHILD \ @@ -67,7 +67,7 @@ namespace boost { namespace phoenix , proto::lazy< construct_eval< proto::_value(proto::_child_c<0>) - >(_env) + >(_context) > > , BOOST_PP_ENUM_SHIFTED(PHOENIX_COMPOSITE_LIMIT, PHOENIX_CONSTRUCT_CALL, _) diff --git a/include/boost/phoenix/object/delete.hpp b/include/boost/phoenix/object/delete.hpp index 6463b38..0abf280 100644 --- a/include/boost/phoenix/object/delete.hpp +++ b/include/boost/phoenix/object/delete.hpp @@ -45,13 +45,13 @@ namespace boost { namespace phoenix result_type operator()(Env& env, P const& p) const { - /*return*/ delete eval(p, env); + delete eval(p, env); } }; template struct default_actions::when - : proto::call)> + : proto::call)> {}; template diff --git a/include/boost/phoenix/object/dynamic_cast.hpp b/include/boost/phoenix/object/dynamic_cast.hpp index c453230..a20e5e5 100644 --- a/include/boost/phoenix/object/dynamic_cast.hpp +++ b/include/boost/phoenix/object/dynamic_cast.hpp @@ -38,8 +38,8 @@ namespace boost { namespace phoenix struct default_actions::when : proto::lazy< dynamic_cast_eval< - evaluator(proto::_child_c<0>, _env) - >(_env, proto::_child_c<1>) + evaluator(proto::_child_c<0>, _context) + >(_context, proto::_child_c<1>) > {}; diff --git a/include/boost/phoenix/object/new.hpp b/include/boost/phoenix/object/new.hpp index 44dead0..3e25fab 100644 --- a/include/boost/phoenix/object/new.hpp +++ b/include/boost/phoenix/object/new.hpp @@ -49,7 +49,7 @@ namespace boost { namespace phoenix > \ , proto::lazy< \ new_eval)>( \ - _env \ + _context \ , BOOST_PP_ENUM_SHIFTED( \ BOOST_PP_INC(N) \ , PHOENIX_NEW_CHILD \ @@ -68,7 +68,7 @@ namespace boost { namespace phoenix , proto::lazy< new_eval< proto::_value(proto::_child_c<0>) - >(_env) + >(_context) > > , BOOST_PP_ENUM_SHIFTED(PHOENIX_COMPOSITE_LIMIT, PHOENIX_NEW_CALL, _) diff --git a/include/boost/phoenix/object/reinterpret_cast.hpp b/include/boost/phoenix/object/reinterpret_cast.hpp index ef33e80..a125bac 100644 --- a/include/boost/phoenix/object/reinterpret_cast.hpp +++ b/include/boost/phoenix/object/reinterpret_cast.hpp @@ -37,8 +37,8 @@ namespace boost { namespace phoenix template struct default_actions::when : proto::lazy< - reinterpret_cast_eval, _env) - >(_env, proto::_child_c<1>)> + reinterpret_cast_eval, _context) + >(_context, proto::_child_c<1>)> {}; template diff --git a/include/boost/phoenix/object/static_cast.hpp b/include/boost/phoenix/object/static_cast.hpp index d453d88..f690130 100644 --- a/include/boost/phoenix/object/static_cast.hpp +++ b/include/boost/phoenix/object/static_cast.hpp @@ -37,8 +37,8 @@ namespace boost { namespace phoenix template struct default_actions::when : proto::lazy< - static_cast_eval, _env) - >(_env, proto::_child_c<1>)> + static_cast_eval, _context) + >(_context, proto::_child_c<1>)> {}; template diff --git a/include/boost/phoenix/operator/member.hpp b/include/boost/phoenix/operator/member.hpp index af17b6b..086430e 100644 --- a/include/boost/phoenix/operator/member.hpp +++ b/include/boost/phoenix/operator/member.hpp @@ -115,7 +115,7 @@ namespace boost { namespace phoenix template struct default_actions::when - : proto::call + : proto::call {}; }} diff --git a/include/boost/phoenix/operator/preprocessed/member_10.hpp b/include/boost/phoenix/operator/preprocessed/member_10.hpp index 6cf41e4..7ef3f67 100644 --- a/include/boost/phoenix/operator/preprocessed/member_10.hpp +++ b/include/boost/phoenix/operator/preprocessed/member_10.hpp @@ -452,6 +452,6 @@ namespace boost { namespace phoenix }; template struct default_actions::when - : proto::call + : proto::call {}; }} diff --git a/include/boost/phoenix/operator/preprocessed/member_20.hpp b/include/boost/phoenix/operator/preprocessed/member_20.hpp index e882dcc..b4822e8 100644 --- a/include/boost/phoenix/operator/preprocessed/member_20.hpp +++ b/include/boost/phoenix/operator/preprocessed/member_20.hpp @@ -892,6 +892,6 @@ namespace boost { namespace phoenix }; template struct default_actions::when - : proto::call + : proto::call {}; }} diff --git a/include/boost/phoenix/operator/preprocessed/member_30.hpp b/include/boost/phoenix/operator/preprocessed/member_30.hpp index 06afb3a..ce3712f 100644 --- a/include/boost/phoenix/operator/preprocessed/member_30.hpp +++ b/include/boost/phoenix/operator/preprocessed/member_30.hpp @@ -1332,6 +1332,6 @@ namespace boost { namespace phoenix }; template struct default_actions::when - : proto::call + : proto::call {}; }} diff --git a/include/boost/phoenix/operator/preprocessed/member_40.hpp b/include/boost/phoenix/operator/preprocessed/member_40.hpp index e95b3ca..85dd0d0 100644 --- a/include/boost/phoenix/operator/preprocessed/member_40.hpp +++ b/include/boost/phoenix/operator/preprocessed/member_40.hpp @@ -1772,6 +1772,6 @@ namespace boost { namespace phoenix }; template struct default_actions::when - : proto::call + : proto::call {}; }} diff --git a/include/boost/phoenix/operator/preprocessed/member_50.hpp b/include/boost/phoenix/operator/preprocessed/member_50.hpp index 1a5ce88..baccdc3 100644 --- a/include/boost/phoenix/operator/preprocessed/member_50.hpp +++ b/include/boost/phoenix/operator/preprocessed/member_50.hpp @@ -2212,6 +2212,6 @@ namespace boost { namespace phoenix }; template struct default_actions::when - : proto::call + : proto::call {}; }} diff --git a/include/boost/phoenix/scope/dynamic.hpp b/include/boost/phoenix/scope/dynamic.hpp index 9a5f990..0b7f789 100644 --- a/include/boost/phoenix/scope/dynamic.hpp +++ b/include/boost/phoenix/scope/dynamic.hpp @@ -148,7 +148,7 @@ namespace boost { namespace phoenix struct default_actions::when : proto::call< dynamic_member_eval( - _env + _context , proto::_value(proto::_child_c<0>) , proto::_value(proto::_child_c<1>) ) diff --git a/include/boost/phoenix/scope/lambda.hpp b/include/boost/phoenix/scope/lambda.hpp index 3ccb8bb..8e1e831 100644 --- a/include/boost/phoenix/scope/lambda.hpp +++ b/include/boost/phoenix/scope/lambda.hpp @@ -169,7 +169,7 @@ namespace boost { namespace phoenix struct default_actions::when : proto::call< lambda_eval( - _env + _context , proto::_value(proto::_child_c<0>) , proto::_child_c<1> , proto::_child_c<2> @@ -238,7 +238,7 @@ namespace boost { namespace phoenix rule::local_var_def_list , meta_grammar > - , detail::local_var_def_is_nullary(proto::_child_c<0>, _env)// mpl::true_()//evaluator(proto::_child_c<1>, _env) + , detail::local_var_def_is_nullary(proto::_child_c<0>, _context)// mpl::true_()//evaluator(proto::_child_c<1>, _context) > > {}; @@ -435,14 +435,14 @@ namespace boost { namespace phoenix : proto::or_< proto::when< expression::lambda_actor - , lambda_actor_eval(_env, proto::_child_c<0>) + , lambda_actor_eval(_context, proto::_child_c<0>) > , proto::when< expression::lambda_actor< rule::local_var_def_list , meta_grammar > - , lambda_actor_eval(_env, proto::_child_c<0>, proto::_child_c<1>) + , lambda_actor_eval(_context, proto::_child_c<0>, proto::_child_c<1>) > > {}; diff --git a/include/boost/phoenix/scope/let.hpp b/include/boost/phoenix/scope/let.hpp index 0e50b49..6ed9330 100644 --- a/include/boost/phoenix/scope/let.hpp +++ b/include/boost/phoenix/scope/let.hpp @@ -110,7 +110,7 @@ namespace boost { namespace phoenix template struct default_actions::when - : proto::call, proto::_child_c<1>)> + : proto::call, proto::_child_c<1>)> {}; template @@ -172,7 +172,7 @@ namespace boost { namespace phoenix struct is_nullary::when : proto::make< mpl::and_< - detail::local_var_def_is_nullary(proto::_child_c<0>, _env) + detail::local_var_def_is_nullary(proto::_child_c<0>, _context) , evaluator( proto::_child_c<1> , fusion::vector2< diff --git a/include/boost/phoenix/scope/local_variable.hpp b/include/boost/phoenix/scope/local_variable.hpp index 3877592..6a2aec5 100644 --- a/include/boost/phoenix/scope/local_variable.hpp +++ b/include/boost/phoenix/scope/local_variable.hpp @@ -208,7 +208,7 @@ namespace boost { namespace phoenix , proto::when< rule::local_var_def , evaluator( - proto::_child_c<1> + proto::_right , fusion::vector2< mpl::true_ , boost::phoenix::is_nullary @@ -453,7 +453,7 @@ namespace boost { namespace phoenix template struct default_actions::when - : proto::call), _env)> + : proto::call), _context)> {}; namespace local_names diff --git a/include/boost/phoenix/scope/scoped_environment.hpp b/include/boost/phoenix/scope/scoped_environment.hpp index 8e975b5..0f8f2ef 100644 --- a/include/boost/phoenix/scope/scoped_environment.hpp +++ b/include/boost/phoenix/scope/scoped_environment.hpp @@ -58,16 +58,14 @@ namespace boost { namespace phoenix { \ typedef \ typename boost::remove_reference< \ - typename boost::result_of< \ - functional::args(typename Seq::env_type) \ - >::type \ + typename fusion::result_of::at_c::type \ >::type \ env_type; \ typedef typename fusion::result_of::INTRINSIC::type type; \ \ static type call(Seq & seq) \ { \ - return fusion::INTRINSIC(seq); \ + return fusion::INTRINSIC(seq.env); \ } \ } \ /**/ @@ -81,9 +79,7 @@ namespace boost { namespace phoenix { typedef typename boost::remove_reference< - typename boost::result_of< - functional::args(typename Seq::env_type) - >::type + typename fusion::result_of::at_c::type >::type env_type; typedef @@ -96,16 +92,14 @@ namespace boost { namespace phoenix { typedef typename boost::remove_reference< - typename boost::result_of< - functional::args(typename Seq::env_type) - >::type + typename fusion::result_of::at_c::type >::type env_type; typedef typename fusion::result_of::at::type type; static type call(Seq & seq) { - return fusion::at(functional::args()(seq.env)); + return fusion::at(fusion::at_c<0>(seq.env)); } }; }; diff --git a/include/boost/phoenix/statement/do_while.hpp b/include/boost/phoenix/statement/do_while.hpp index a6d9145..06d4a0e 100644 --- a/include/boost/phoenix/statement/do_while.hpp +++ b/include/boost/phoenix/statement/do_while.hpp @@ -37,7 +37,7 @@ namespace boost { namespace phoenix struct default_actions::when : proto::call< do_while_eval( - _env + _context , proto::_child_c<0> // Cond , proto::_child_c<1> // Do ) diff --git a/include/boost/phoenix/statement/for.hpp b/include/boost/phoenix/statement/for.hpp index 53b10d1..f9c709b 100644 --- a/include/boost/phoenix/statement/for.hpp +++ b/include/boost/phoenix/statement/for.hpp @@ -25,21 +25,21 @@ namespace boost { namespace phoenix typedef void result_type; template < - typename Env + typename Context , typename Init , typename Cond , typename Step , typename Do> result_type operator()( - Env& env + Context& ctx , Init const& init , Cond const& cond , Step const& step , Do const& do_) const { - for(eval(init, env); eval(cond, env); eval(step, env)) - eval(do_, env); + for(eval(init, ctx); eval(cond, ctx); eval(step, ctx)) + eval(do_, ctx); } }; @@ -47,7 +47,7 @@ namespace boost { namespace phoenix struct default_actions::when : proto::call< for_eval( - _env + _context , proto::_child_c<0> // Cond , proto::_child_c<1> // Init , proto::_child_c<2> // Step diff --git a/include/boost/phoenix/statement/if.hpp b/include/boost/phoenix/statement/if.hpp index 33afdd1..eccb78b 100644 --- a/include/boost/phoenix/statement/if.hpp +++ b/include/boost/phoenix/statement/if.hpp @@ -78,7 +78,7 @@ namespace boost { namespace phoenix struct default_actions::when : proto::call< if_else_eval( - _env + _context , proto::_child_c<0> // Cond , proto::_child_c<1> // Then ) @@ -89,7 +89,7 @@ namespace boost { namespace phoenix struct default_actions::when : proto::call< if_else_eval( - _env + _context , proto::_child_c<0> // Cond , proto::_child_c<1> // Then , proto::_child_c<2> // Else diff --git a/include/boost/phoenix/statement/switch.hpp b/include/boost/phoenix/statement/switch.hpp index 11b9fda..78464ae 100644 --- a/include/boost/phoenix/statement/switch.hpp +++ b/include/boost/phoenix/statement/switch.hpp @@ -148,8 +148,8 @@ namespace boost { namespace phoenix struct is_nullary::when : proto::make< mpl::and_< - evaluator(proto::_child_c<0>, _env) - , detail::switch_case_is_nullary(proto::_child_c<1>, _env) + evaluator(proto::_child_c<0>, _context) + , detail::switch_case_is_nullary(proto::_child_c<1>, _context) >() > {}; @@ -189,7 +189,7 @@ namespace boost { namespace phoenix struct default_actions::when : proto::call< switch_eval( - _env + _context , proto::_child_c<0> // Cond , proto::_child_c<1> // Cases ) diff --git a/include/boost/phoenix/statement/throw.hpp b/include/boost/phoenix/statement/throw.hpp index 59213ff..60fb940 100644 --- a/include/boost/phoenix/statement/throw.hpp +++ b/include/boost/phoenix/statement/throw.hpp @@ -66,12 +66,12 @@ namespace boost { namespace phoenix template struct default_actions::when - : proto::call + : proto::call {}; template struct default_actions::when - : proto::call)> + : proto::call)> {}; expression::throw_<>::type const diff --git a/include/boost/phoenix/statement/try_catch.hpp b/include/boost/phoenix/statement/try_catch.hpp index a6371f6..fa03796 100644 --- a/include/boost/phoenix/statement/try_catch.hpp +++ b/include/boost/phoenix/statement/try_catch.hpp @@ -109,7 +109,7 @@ namespace boost { namespace phoenix BOOST_PP_ENUM_PARAMS(N, proto::_ BOOST_PP_INTERCEPT) \ > \ , try_catch_eval( \ - _env \ + _context \ , BOOST_PP_ENUM( \ N \ , PHOENIX_TRY_CATCH_CHILD \ @@ -250,7 +250,7 @@ namespace boost { namespace phoenix template struct is_nullary::when - : proto::call + : proto::call {}; template diff --git a/include/boost/phoenix/statement/while.hpp b/include/boost/phoenix/statement/while.hpp index fecd279..eaf2dc1 100644 --- a/include/boost/phoenix/statement/while.hpp +++ b/include/boost/phoenix/statement/while.hpp @@ -37,7 +37,7 @@ namespace boost { namespace phoenix struct default_actions::when : proto::call< while_eval( - _env + _context , proto::_child_c<0> // Cond , proto::_child_c<1> // Do )