Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67206 - in sandbox/SOC/2010/phoenix3: boost/phoenix/core boost/phoenix/scope boost/phoenix/statement libs/phoenix/test/scope
From: thom.heller_at_[hidden]
Date: 2010-12-13 03:10:43


Author: theller
Date: 2010-12-13 03:10:37 EST (Mon, 13 Dec 2010)
New Revision: 67206
URL: http://svn.boost.org/trac/boost/changeset/67206

Log:
let almost working, again
Text files modified:
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor.hpp | 8 ++
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/is_nullary.hpp | 3
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/meta_grammar.hpp | 125 ---------------------------------------
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp | 2
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/let.hpp | 19 +++++
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp | 51 +++++++++------
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp | 2
   sandbox/SOC/2010/phoenix3/boost/phoenix/statement/try_catch.hpp | 2
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp | 28 ++------
   9 files changed, 69 insertions(+), 171 deletions(-)

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor.hpp 2010-12-13 03:10:37 EST (Mon, 13 Dec 2010)
@@ -34,6 +34,12 @@
             template <typename T>
             error_expecting_arguments(T const&) {}
         };
+
+ struct error_invalid_lambda_expr
+ {
+ template <typename T>
+ error_invalid_lambda_expr(T const&) {}
+ };
     }
 
     namespace result_of
@@ -66,7 +72,7 @@
                 typename mpl::eval_if<
                     typename proto::matches<Expr, meta_grammar>::type
                   , result_matches<Expr>
- , mpl::identity<detail::error_expecting_arguments>
+ , mpl::identity<detail::error_invalid_lambda_expr>
>::type
             type;
         };

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/is_nullary.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/is_nullary.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/is_nullary.hpp 2010-12-13 03:10:37 EST (Mon, 13 Dec 2010)
@@ -43,7 +43,8 @@
 
                 template <typename Dummy>
                 struct is_nullary_::when<rule::custom_terminal, Dummy>
- : proto::lazy<is_nullary<custom_terminal<proto::_value> >(proto::_, _env)>//proto::make<mpl::true_()>
+ : //proto::lazy<is_nullary<custom_terminal<proto::_value> >(proto::_, _env)>
+ proto::make<mpl::true_()>
                 {};
 
                 template <typename Dummy>

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/meta_grammar.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/meta_grammar.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/meta_grammar.hpp 2010-12-13 03:10:37 EST (Mon, 13 Dec 2010)
@@ -32,129 +32,7 @@
         {};
     };
 
- ////////////////////////////////////////////////////////////////////////////
- // An evaluation transform you can call to dispatch to different actions
- namespace detail
- {
- template <typename Expr>
- struct grammar_of
- {
- typedef typename proto::domain_of<Expr>::type domain_type;
- typedef typename domain_type::proto_grammar domain_grammar;
- typedef
- typename mpl::if_<
- is_same<domain_grammar, proto::_>
- , meta_grammar
- , domain_grammar
- >::type
- type;
- };
-
- template <typename Expr, typename State, typename Data>
- struct evaluator_impl
- : proto::transform_impl<Expr, State, Data>
- {
- typedef typename grammar_of<Expr>::type grammar_type;
- typedef
- typename grammar_type::
- template impl<Expr, State, Data>::result_type
- result_type;
-
- result_type
- operator()(
- typename evaluator_impl::expr_param expr
- , typename evaluator_impl::state_param state
- , typename evaluator_impl::data_param data
- )
- {
- //std::cout << "evaluator<Expr, State, Data>\n";
- return
- typename grammar_type::
- template impl<Expr, State, Data>()(
- expr, state, data
- );
- }
- };
-
- template <typename Expr, typename State>
- struct evaluator_impl<Expr, State, int>
- : proto::transform_impl<Expr, State, int>
- {
- typedef typename grammar_of<Expr>::type grammar_type;
- typedef typename boost::result_of<functional::args(State)>::type args_type;
- typedef typename boost::result_of<functional::actions(State)>::type actions_type;
- typedef typename grammar_type::template impl<Expr, args_type, actions_type>::result_type result_type;
-
- result_type
- operator()(
- typename evaluator_impl::expr_param expr
- , typename evaluator_impl::state_param state
- , typename evaluator_impl::data_param data
- )
- {
- /*
- std::cout << "evaluator<Expr, State, int>\n";
- std::cout << typeid(grammar_type).name() << "\n";
- std::cout << typeid(Expr).name() << "\n";
- */
- return
- typename grammar_type::
- template impl<Expr, args_type, actions_type>()(
- expr, functional::args()(state), functional::actions()(state)
- );
- }
- };
-
- template <typename Expr, typename State>
- struct evaluator_impl<Expr, State, State>
- : proto::transform_impl<Expr, State, State>
- {
- typedef typename grammar_of<Expr>::type grammar_type;
- typedef typename boost::result_of<functional::args(State)>::type args_type;
- typedef typename boost::result_of<functional::actions(State)>::type actions_type;
- typedef typename grammar_type::template impl<Expr, args_type, actions_type>::result_type result_type;
-
- result_type
- operator()(
- typename evaluator_impl::expr_param expr
- , typename evaluator_impl::state_param state
- , typename evaluator_impl::data_param data
- )
- {
- //std::cout << "evaluator<Expr, State, State>\n";
- return typename grammar_type::template impl<Expr, args_type, actions_type>()(expr, functional::args()(state), functional::actions()(state));
- }
- };
- }
-
     struct evaluator
- : proto::transform<evaluator>
- {
- template <typename Expr, typename State, typename Data>
- struct impl
- : detail::evaluator_impl<Expr, State, Data>
- {};
- /*
- : proto::transform_impl<Expr, State, Data>
- {
- typedef typename boost::result_of<functional::args(State)>::type args_type;
- typedef typename boost::result_of<functional::actions(State)>::type actions_type;
- typedef typename meta_grammar::template impl<Expr, args_type, actions_type>::result_type result_type;
-
- result_type
- operator()(
- typename impl::expr_param expr
- , typename impl::state_param state
- , typename impl::data_param data
- )
- {
- return typename meta_grammar::template impl<Expr, args_type, actions_type>()(expr, functional::args()(state), functional::actions()(state));
- //return meta_grammar()(expr
- }
- };
- */
- };
- /*
         : proto::call<
             meta_grammar(
                 proto::_
@@ -163,7 +41,6 @@
             )
>
     {};
- */
     
     ////////////////////////////////////////////////////////////////////////////
     // Set of default actions. Extend this whenever you add a new phoenix construct
@@ -171,7 +48,7 @@
     {
         template <typename Rule, typename Dummy = void>
         struct when
- : proto::_default<evaluator>
+ : proto::_default<meta_grammar>
         {};
     };
 

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp 2010-12-13 03:10:37 EST (Mon, 13 Dec 2010)
@@ -78,7 +78,7 @@
     struct is_nullary<custom_terminal<actor<T> > >
         //: proto::make<typename is_nullary<T>::type()>
         //: proto::make<mpl::false_()>
- : proto::call<evaluator(proto::_value, fusion::vector2<fusion::vector0<>, detail::is_nullary_>())>
+ : proto::call<evaluator(proto::_value)>//, fusion::vector2<fusion::vector0<>, detail::is_nullary_>())>
     {};
 
     /*

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/let.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/let.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/let.hpp 2010-12-13 03:10:37 EST (Mon, 13 Dec 2010)
@@ -26,6 +26,18 @@
 
     namespace detail
     {
+ struct let_is_nullary_actions
+ {
+ template <typename Rule, typename Dummy = void>
+ struct when : is_nullary_::when<Rule, Dummy>
+ {};
+ };
+
+ template <typename Dummy>
+ struct let_is_nullary_actions::when<rule::local_variable, Dummy>
+ : proto::make<mpl::true_()>
+ {};
+
         template <typename Dummy>
         struct is_nullary_::when<rule::let, Dummy>
             : proto::make<
@@ -33,7 +45,9 @@
                     detail::local_var_def_is_nullary(proto::_child_c<0>, _env)
                     //mpl::true_()
                   //, mpl::true_()//let_evaluator(proto::_child_c<1>, _env)
- , evaluator(proto::_child_c<1>, _env, int())
+ , evaluator(proto::_child_c<1>, //fusion::vector2<scoped_environment<_env, _env, mpl::void_()>(), functional::actions(_env)>()
+ fusion::vector2<fusion::vector0<>&, let_is_nullary_actions>()
+ )
>()
>
             //: proto::make<mpl::true_()>
@@ -122,9 +136,8 @@
             std::cout << ":(\n";
             //std::cout << typeid(Let).name() << "\n";
 
- return evaluator()(let, new_env);
             //return let_evaluator()(let, new_env);
- //return eval(let, new_env);
+ return eval(let, new_env);
         }
     };
 

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp 2010-12-13 03:10:37 EST (Mon, 13 Dec 2010)
@@ -11,6 +11,7 @@
 #include <boost/phoenix/core/actor.hpp>
 #include <boost/phoenix/core/expression.hpp>
 #include <boost/phoenix/scope/scope_actor.hpp>
+#include <boost/phoenix/scope/scoped_environment.hpp>
 #include <boost/phoenix/statement/sequence.hpp>
 
 namespace boost { namespace phoenix
@@ -35,6 +36,7 @@
         template <typename Key, typename _ = proto::is_proto_expr>
         struct local_variable
         {
+ /*
             typedef
                 typename proto::result_of::make_expr<
                     tag::local_variable
@@ -48,10 +50,11 @@
             typedef
                 typename proto::nary_expr<tag::local_variable, Key>::proto_grammar
                 proto_grammar;
+ */
                 
- /*typedef expr<tag::local_variable, Key> expr_type;
+ typedef expr<tag::local_variable, Key> expr_type;
             typedef typename expr_type::type type;
- typedef typename expr_type::proto_grammar proto_grammar;*/
+ typedef typename expr_type::proto_grammar proto_grammar;
             //BOOST_PROTO_BASIC_EXTENDS(typename expr_type::type, local_variable, phoenix_domain)
         };
         /* : proto::transform<local_variable<Key>, int>
@@ -111,7 +114,13 @@
     namespace rule
     {
         struct local_variable
- : expression::local_variable<proto::_>
+ //: expression::local_variable<proto::_>
+ : proto::and_<
+ //proto::if_<is_scoped_environment<_env>()>
+ //proto::if_<blubb<_env>()>
+ //, rule::local_variable
+ expression::local_variable<proto::_>
+ >
             //: proto::terminal< ::boost::phoenix::local_variable<proto::_> >
         {};
 
@@ -215,21 +224,25 @@
     }
 
     template <typename Dummy>
- struct scope_grammar::case_<tag::local_variable, Dummy>
- : proto::when<rule::local_variable, proto::external_transform>
+ //struct scope_grammar::case_<tag::local_variable, Dummy>
+ struct meta_grammar::case_<tag::local_variable, Dummy>
+ : proto::when<
+ rule::local_variable
+ , proto::external_transform
+ >
     {};
 
     namespace detail
     {
         template <typename Dummy>
         struct is_nullary_::when<rule::local_variable, Dummy>
- : proto::make<mpl::true_()>
- /*: proto::if_<
- //is_scoped_environment<functional::args(proto::_state)>()
- foo(functional::args(proto::_state))
- , mpl::false_()
+ //: proto::make<mpl::true_()>
+ : proto::if_<
+ is_scoped_environment<functional::args(_env)>()
+ //foo(functional::args(proto::_state))
               , mpl::true_()
- >*/
+ , mpl::false_()
+ >
         {};
 
         struct local_var_def_is_nullary
@@ -289,7 +302,7 @@
                   , proto::if_<
                         proto::matches<proto::_left(proto::_right), proto::_data>()
                       //, evaluator(proto::_right(proto::_right), proto::_state)
- , evaluator(proto::_right, proto::_state, int())
+ , evaluator(proto::_right(proto::_right), proto::_state)
                       //, int()
                       , find_local(proto::_left, proto::_state, proto::_data)
>
@@ -298,7 +311,7 @@
                     rule::local_var_def
                   , proto::if_<
                         proto::matches<proto::_left, proto::_data>()
- , evaluator(proto::_right, proto::_state, int())
+ , evaluator(proto::_right, proto::_state)
                       //, int()
                       , detail::local_var_not_found()
>
@@ -376,7 +389,6 @@
                 typename mpl::eval_if<
                     is_scoped_environment<env_type>
                   , detail::get_local_result_impl<This, env_type, Env, Key>
- //, mpl::identity<int>
                   , mpl::identity<detail::local_var_not_found>
>::type
                 type;
@@ -407,9 +419,6 @@
             typename result<get_local<Key>(Env&)>::type
             evaluate(Env & env, mpl::true_) const
             {
- //Key k;
- //detail::find_local()(functional::args()(env).locals, env, k);
- //return 5;
                 typedef
                     typename proto::detail::uncvref<
                         typename boost::result_of<
@@ -428,6 +437,7 @@
                           , detail::local_var_not_found
>::type()
                     );
+
             }
 
             // is a scoped environment, and we need to look in the outer environment
@@ -493,6 +503,7 @@
                 typename expression::local_variable<Local>::type
                 lookup_grammar;
             std::cout << "muuh ...\n";
+ std::cout << typeid(lookup_grammar).name() << "\n";
             return get_local<lookup_grammar>()(env);
         }
     };
@@ -558,7 +569,7 @@
                 typename expression::sequence<A0, A1>::type
                 type;
 
- static type make(A0 a0, A1 a1)
+ static type const make(A0 a0, A1 a1)
             {
                 return expression::sequence<A0, A1>::make(a0, a1);
             }
@@ -569,7 +580,7 @@
         struct make_locals<PHOENIX_A(N)> \
         { \
             typedef \
- typename make_locals<PHOENIX_A(BOOST_PP_DEC(N))>::type \
+ typename make_locals<PHOENIX_A(BOOST_PP_DEC(N))>::type const \
                 type0; \
                                                                                 \
             typedef \
@@ -579,7 +590,7 @@
>::type \
                 type; \
                                                                                 \
- static type make(PHOENIX_A_a(N)) \
+ static type const make(PHOENIX_A_a(N)) \
             { \
                 return \
                     expression::sequence< \

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp 2010-12-13 03:10:37 EST (Mon, 13 Dec 2010)
@@ -107,7 +107,7 @@
     
     template <typename Env>
     struct is_scoped_environment<Env&> : is_scoped_environment<Env> {};
-
+
     template <typename Env, typename OuterEnv, typename Locals>
     struct is_scoped_environment<scoped_environment<Env, OuterEnv, Locals> >
         : mpl::true_

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/statement/try_catch.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/statement/try_catch.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/statement/try_catch.hpp 2010-12-13 03:10:37 EST (Mon, 13 Dec 2010)
@@ -187,7 +187,7 @@
               , proto::when<
                     rule::try_catch
                   , mpl::and_<
- proto::call<evaluator(proto::_child_c<0>, proto::_data)>
+ evaluator(proto::_child_c<0>, proto::_data)
                       , proto::fold<
                             proto::functional::pop_front(proto::_)
                           , mpl::true_()

Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp 2010-12-13 03:10:37 EST (Mon, 13 Dec 2010)
@@ -35,13 +35,13 @@
     using boost::phoenix::local_names::_x;
     using boost::phoenix::local_names::_y;
     using boost::phoenix::local_names::_z;
- std::cout << typeid(typename boost::phoenix::detail::grammar_of<Expr>::type).name() << "\n";
- std::cout << typeid(typename boost::proto::matches<Expr, boost::phoenix::scope_grammar>::type).name() << "\n";
+ //std::cout << typeid(typename boost::phoenix::detail::grammar_of<Expr>::type).name() << "\n";
     std::cout << typeid(typename boost::proto::matches<Expr, boost::phoenix::meta_grammar>::type).name() << "\n";
- std::cout << typeid(let(_a = 1, _b = 2, _c = 2, _d = 3, _e = 5)[expr]()).name() << "\n";
+ std::cout << typeid(typename boost::phoenix::is_nullary<Expr>::type).name() << "\n";
+ //std::cout << typeid(let(_a = 1, _b = 2, _c = 2, _d = 3, _e = 5)[expr]()).name() << "\n";
     //let(_a = 1/*, _b = 2, _c = 2, _d = 3, _e = 5*/)[expr]();
     //let(_a = 1, _b = 2, _c = 2, _d = 3, _e = 5)[expr]();
-
+ std::cout << "\n";
 }
 
 template <typename Expr0, typename Expr1>
@@ -70,13 +70,6 @@
     using boost::phoenix::local_names::_z;
     using boost::phoenix::placeholders::arg1;
 
- //fpp_test(_a);
- /*
- std::cout << typeid(_a).name() << "\n";
- fpp_test(_a, _b);
- //std::cout << typeid(_a + _b).name() << "\n";
- */
-
     {
         int x = 1;
         BOOST_TEST(
@@ -88,7 +81,6 @@
         );
     }
 
- /*
     {
         int x = 1, y = 10;
         BOOST_TEST(
@@ -144,6 +136,7 @@
 
     {
         int x = 999;
+ /*
         BOOST_TEST(
             let(_x = val(_1)) // _x holds x by value
             [
@@ -153,30 +146,29 @@
         );
         
         BOOST_TEST(x == 999);
+ */
 
         BOOST_TEST(
             let(_x = val(_1)) // _x holds x by value
             [
- val(_x += 888)
+ //val(_x += 888)
+ val(888 + 999)
             ]
             (x) == x + 888
         );
         
         BOOST_TEST(x == 999);
     }
- */
 
- /*
     {
         BOOST_TEST(
             let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5)
             [
- _a// + _b + _c + _d + _e
+ _a + _b + _c + _d + _e
             ]
             () == 1 + 2 + 3 + 4 + 5
         );
     }
- */
 
 #ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST
     {
@@ -217,13 +209,11 @@
         BOOST_TEST( i == 0 );
     }
 
- /*
     {
         int i = 0;
         let(_a = _1)[_a = _2](i, 2);
         BOOST_TEST(i == 2);
     }
- */
 
     return boost::report_errors();
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk