|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r66977 - in sandbox/SOC/2010/phoenix3: boost/phoenix boost/phoenix/core boost/phoenix/core/detail boost/phoenix/fusion boost/phoenix/operator boost/phoenix/scope boost/phoenix/statement libs/phoenix/test libs/phoenix/test/scope
From: thom.heller_at_[hidden]
Date: 2010-12-02 12:01:32
Author: theller
Date: 2010-12-02 12:01:09 EST (Thu, 02 Dec 2010)
New Revision: 66977
URL: http://svn.boost.org/trac/boost/changeset/66977
Log:
refactoring of let complete
Text files modified:
sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor.hpp | 4
sandbox/SOC/2010/phoenix3/boost/phoenix/core/detail/actor_operator.hpp | 4
sandbox/SOC/2010/phoenix3/boost/phoenix/core/is_nullary.hpp | 11 +
sandbox/SOC/2010/phoenix3/boost/phoenix/core/value.hpp | 21 +-
sandbox/SOC/2010/phoenix3/boost/phoenix/fusion/at.hpp | 42 ++--
sandbox/SOC/2010/phoenix3/boost/phoenix/operator/arithmetic.hpp | 21 --
sandbox/SOC/2010/phoenix3/boost/phoenix/scope.hpp | 2
sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp | 78 ++++++++++
sandbox/SOC/2010/phoenix3/boost/phoenix/scope/let.hpp | 279 ++++--------------------------------
sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp | 301 +++++++++++++++++----------------------
sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp | 2
sandbox/SOC/2010/phoenix3/boost/phoenix/statement/try_catch.hpp | 1
sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile | 10
sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/lambda_tests.cpp | 7
sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/let_tests.cpp | 74 +++------
15 files changed, 321 insertions(+), 536 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-02 12:01:09 EST (Thu, 02 Dec 2010)
@@ -133,7 +133,7 @@
typedef fusion::vector0<> args_type;
args_type args;
fusion::vector2<args_type&, default_actions> env(args, default_actions());
-
+
return eval(*this, env);
}
@@ -147,7 +147,7 @@
typedef fusion::vector0<> args_type;
args_type args;
fusion::vector2<args_type&, default_actions> env(args, default_actions());
-
+
return eval(*this, env);
}
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/detail/actor_operator.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/detail/actor_operator.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/detail/actor_operator.hpp 2010-12-02 12:01:09 EST (Thu, 02 Dec 2010)
@@ -65,7 +65,7 @@
args_type;
args_type args(PHOENIX_a);
fusion::vector2<args_type&, default_actions> env(args, default_actions());
-
+
return eval(*this, env);
}
@@ -84,7 +84,7 @@
args_type;
args_type args(PHOENIX_a);
fusion::vector2<args_type&, default_actions> env(args, default_actions());
-
+
return eval(*this, env);
}
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-02 12:01:09 EST (Thu, 02 Dec 2010)
@@ -16,6 +16,9 @@
namespace boost { namespace phoenix
{
+ template <typename Expr>
+ struct is_nullary;
+
namespace detail
{
struct is_nullary_
@@ -40,7 +43,7 @@
template <typename Dummy>
struct is_nullary_::when<rule::custom_terminal, Dummy>
- : proto::make<mpl::true_()>
+ : proto::lazy<is_nullary<custom_terminal<proto::_value> >(proto::_, _env)>// proto::lazy<is_nullary<proto::_value>()>
{};
template <typename Dummy>
@@ -54,6 +57,12 @@
: boost::result_of<evaluator(Expr const&, fusion::vector2<fusion::vector0<>&, detail::is_nullary_>&)>
{};
+ template <typename T>
+ struct is_nullary<custom_terminal<T> >
+ : proto::make<mpl::true_()>
+ {};
+
+
}}
#endif
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-02 12:01:09 EST (Thu, 02 Dec 2010)
@@ -35,18 +35,10 @@
{
typedef actor<typename proto::terminal<T* >::type> type;
};
-
- template <typename T>
- typename value<T const>::type
- val(T const & t)
- {
- typename value<T const>::type const e = {{t}};
- return e;
- }
template <typename T>
- typename value<T>::type
- val(T & t)
+ typename value<T>::type const
+ val(T t)
{
typename value<T>::type const e = {{t}};
return e;
@@ -75,13 +67,18 @@
{};
template <typename Env>
- typename result<custom_terminal(actor<Expr> const &, Env &)>::type
- operator()(actor<Expr> const& expr, Env & env) const
+ typename result<custom_terminal(actor<Expr> &, Env &)>::type
+ operator()(actor<Expr> const & expr, Env & env) const
{
return eval(expr, env);
}
};
+ template <typename T>
+ struct is_nullary<custom_terminal<actor<T> > >
+ : proto::make<typename is_nullary<T>::type()>
+ {};
+
/*
namespace result_of
{
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/fusion/at.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/fusion/at.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/fusion/at.hpp 2010-12-02 12:01:09 EST (Thu, 02 Dec 2010)
@@ -9,22 +9,27 @@
#ifndef PHOENIX_FUSION_AT_HPP
#define PHOENIX_FUSION_AT_HPP
-#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/at_c.hpp>
#include <boost/phoenix/core/actor.hpp>
-#include <boost/phoenix/core/compose.hpp>
+#include <boost/phoenix/core/expression.hpp>
#include <boost/type_traits/remove_reference.hpp>
namespace boost { namespace phoenix
{
+ PHOENIX_DEFINE_EXPRESSION(
+ at_c
+ , (proto::terminal<proto::_>)
+ (meta_grammar)
+ )
+
namespace result_of
{
template <typename Env, typename Tuple, int N>
- struct at
+ struct at_c
: fusion::result_of::at_c<
typename boost::remove_reference<
typename boost::result_of<
- eval_grammar(Tuple const&, Env&)
+ evaluator(Tuple const&, Env)
>::type
>::type
, N
@@ -32,42 +37,37 @@
{};
}
- template <int N>
+
+ template <typename N>
struct at_eval
{
template <typename Sig>
struct result;
template <typename This, typename Env, typename Tuple>
- struct result<This(Env&, Tuple const&)>
- : result_of::at<Env, Tuple, N>
+ struct result<This(Env, Tuple const&)>
+ : result_of::at_c<Env, Tuple, N::value>
{};
template <typename Env, typename Tuple>
- typename result_of::at<Env, Tuple, N>::type
+ typename result_of::at_c<Env &, Tuple, N::value>::type
operator()(Env& env, Tuple const& tuple) const
{
- return fusion::at_c<N>(eval(tuple, env));
+ return fusion::at_c<N::value>(eval(tuple, env));
}
};
- template <int N, typename Tuple>
- struct make_at : compose<at_eval<N>, Tuple> {};
+ template <typename Dummy>
+ struct default_actions::when<rule::at_c, Dummy>
+ : proto::lazy<at_eval<proto::_value(proto::_child_c<0>)>(_env, proto::_child_c<1>)>
+ {};
template <int N, typename Tuple>
- typename make_at<N, Tuple>::type const
+ typename expression::at_c<mpl::int_<N>, Tuple>::type
at_c(Tuple const& tuple)
{
- return make_at<N, Tuple>()(tuple);
+ return expression::at_c<mpl::int_<N>, Tuple>::make(mpl::int_<N>(), tuple);
}
-
- template <typename N, typename Tuple>
- typename make_at<N::value, Tuple>::type const
- at(Tuple const& tuple)
- {
- return make_at<N::value, Tuple>()(tuple);
- }
-
}}
#endif
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/operator/arithmetic.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/operator/arithmetic.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/operator/arithmetic.hpp 2010-12-02 12:01:09 EST (Thu, 02 Dec 2010)
@@ -33,27 +33,6 @@
(divides)
(modulus)
)
-
- /*
- struct blubb
- : proto::callable
- {
- typedef int result_type;
-
- template <typename Env, typename Lhs, typename Rhs>
- result_type
- operator()(Env& env, Lhs const& lhs, Rhs const& rhs) const
- {
- std::cout << "ok ....\n";
- return 5;
- }
- };
-
- template <typename Dummy>
- struct default_actions::when<rule::plus_assign, Dummy>
- : proto::call<blubb(_env, proto::_child_c<0>, proto::_child_c<0>)>
- {};
- */
}}
#endif
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope.hpp 2010-12-02 12:01:09 EST (Thu, 02 Dec 2010)
@@ -10,7 +10,7 @@
#include <boost/phoenix/version.hpp>
#include <boost/phoenix/scope/scoped_environment.hpp>
-//#include <boost/phoenix/scope/lambda.hpp>
+#include <boost/phoenix/scope/lambda.hpp>
#include <boost/phoenix/scope/let.hpp>
#include <boost/phoenix/scope/local_variable.hpp>
Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp 2010-12-02 12:01:09 EST (Thu, 02 Dec 2010)
@@ -9,6 +9,7 @@
#ifndef PHOENIX_SCOPE_LAMBDA_HPP
#define PHOENIX_SCOPE_LAMBDA_HPP
+/*
#include <boost/fusion/include/transform.hpp>
#include <boost/fusion/include/as_vector.hpp>
#include <boost/fusion/include/mpl.hpp>
@@ -18,9 +19,85 @@
#include <boost/phoenix/scope/detail/local_variable.hpp>
#include <boost/phoenix/support/element_at.hpp>
#include <boost/phoenix/support/iterate.hpp>
+*/
+#include <boost/phoenix/core/limits.hpp>
+#include <boost/phoenix/core/actor.hpp>
+#include <boost/phoenix/scope/local_variable.hpp>
namespace boost { namespace phoenix
{
+ PHOENIX_DEFINE_EXPRESSION(
+ lambda
+ , (rule::local_var_def_list)
+ (meta_grammar)
+ )
+
+ template <typename Locals = void, typename Dummy = void>
+ struct lambda_actor_gen;
+
+ template <>
+ struct lambda_actor_gen<void, void>
+ {
+ template <typename Expr>
+ Expr const &
+ operator[](Expr const & expr) const
+ {
+ return expr;
+ }
+ };
+
+ template <typename Locals>
+ struct lambda_actor_gen<Locals>
+ {
+ lambda_actor_gen(Locals const & locals)
+ : locals(locals)
+ {}
+
+ template <typename Expr>
+ typename expression::lambda<
+ Locals
+ , Expr
+ >::type const
+ operator[](Expr const & expr) const
+ {
+ return expression::lambda<Locals, Expr>::make(locals, expr);
+ }
+
+ Locals locals;
+ };
+
+ struct lambda_local_gen
+ {
+ lambda_actor_gen<> const
+ operator()() const
+ {
+ return lambda_actor_gen<>();
+ }
+
+ template <typename Expr0>
+ lambda_actor_gen<Expr0> const
+ operator()(Expr0 const& expr0) const
+ {
+ return expr0;
+ }
+
+#define PHOENIX_LAMBDA_LOCAL_GEN(Z, N, DATA) \
+ template <PHOENIX_typename_A(N)> \
+ lambda_actor_gen< \
+ typename detail::make_locals<PHOENIX_A(N)>::type \
+ > const \
+ operator()(PHOENIX_A_const_ref_a(N)) const \
+ { \
+ return detail::make_locals<PHOENIX_A(N)>::make(PHOENIX_a(N)); \
+ } \
+ /**/
+ BOOST_PP_REPEAT_FROM_TO(2, PHOENIX_LOCAL_LIMIT, PHOENIX_LAMBDA_LOCAL_GEN, _)
+
+ };
+
+ lambda_local_gen const lambda = {};
+
+#if 0
namespace result_of
{
template <typename Env, typename Expr, typename OuterEnv, typename Locals, typename Map>
@@ -224,6 +301,7 @@
};
lambda_gen const lambda = lambda_gen();
+#endif
}}
#endif
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-02 12:01:09 EST (Thu, 02 Dec 2010)
@@ -9,14 +9,10 @@
#ifndef PHOENIX_SCOPE_LET_HPP
#define PHOENIX_SCOPE_LET_HPP
-//#include <boost/fusion/include/transform.hpp>
-//#include <boost/fusion/include/as_vector.hpp>
#include <boost/phoenix/core/limits.hpp>
#include <boost/phoenix/scope/scoped_environment.hpp>
#include <boost/phoenix/core/actor.hpp>
-#include <boost/phoenix/statement/sequence.hpp>
#include <boost/phoenix/scope/local_variable.hpp>
-//#include <boost/phoenix/support/element_at.hpp>
#include <boost/phoenix/support/iterate.hpp>
namespace boost { namespace phoenix
@@ -33,16 +29,8 @@
struct result;
template <typename This, typename Env, typename Locals, typename Let>
- struct result<This(Env, Locals const&, Let const&)>
+ struct result<This(Env, Locals const &, Let const&)>
{
- /*
- typedef
- typename proto::detail::uncvref<
- Env
- >::type
- env_type;
- */
-
typedef
typename proto::detail::uncvref<
typename boost::result_of<
@@ -66,14 +54,14 @@
typename boost::result_of<
evaluator(
Let const &
- , fusion::vector2<scoped_environment<Env, Env, locals_type> &, actions_type> &
+ , fusion::vector2<scoped_environment<Env, Env, locals_type&> &, actions_type> &
)
>::type
type;
};
template <typename Env, typename Locals, typename Let>
- typename result<let_eval(Env&, Locals const&, Let const&)>::type
+ typename result<let_eval(Env&, Locals const &, Let const &)>::type
operator()(Env & env, Locals const & locals, Let const & let) const
{
typedef
@@ -88,29 +76,28 @@
typename proto::detail::uncvref<
typename boost::result_of<
rule::local_var_def_list(
- Locals const &
+ Locals &
, Env &
)
>::type
>::type
locals_type;
- scoped_environment<Env, Env, locals_type>
+ locals_type l =
+ rule::local_var_def_list()(
+ locals
+ , env
+ );
+
+ scoped_environment<Env, Env, locals_type&>
scoped_env(
env
, env
- , rule::local_var_def_list()(
- locals
- , env
- )
+ , l
);
- fusion::vector2<scoped_environment<Env, Env, locals_type> &, actions_type>
+ fusion::vector2<scoped_environment<Env, Env, locals_type &> &, actions_type>
new_env(scoped_env, functional::actions()(env));
-
- std::cout << "let_eval\n";
- std::cout << typeid(Let).name() << "\n\n";
-
return eval(let, new_env);
}
};
@@ -128,7 +115,7 @@
{
template <typename Expr>
Expr const &
- operator[](Expr const& expr) const
+ operator[](Expr const & expr) const
{
return expr;
}
@@ -142,75 +129,18 @@
{}
template <typename Expr>
- typename expression::let<Locals, Expr>::type const
- operator[](Expr const& expr) const
+ typename expression::let<
+ Locals
+ , Expr
+ >::type const
+ operator[](Expr const & expr) const
{
- std::cout << "let_actor_gen\n";
- std::cout << typeid(Expr).name() << "\n\n";
return expression::let<Locals, Expr>::make(locals, expr);
}
Locals locals;
};
- namespace detail
- {
- template <PHOENIX_typename_A_void(PHOENIX_LOCAL_LIMIT)>
- struct make_locals;
-
- template <typename A0, typename A1>
- struct make_locals<A0, A1>
- {
- typedef
- typename expression::sequence<A0, A1>::type
- type;
-
- static type make(A0 a0, A1 a1)
- {
- return expression::sequence<A0, A1>::make(a0, a1);
- }
- };
-
- template <typename A0, typename A1, typename A2>
- struct make_locals<A0, A1, A2>
- {
- typedef
- typename make_locals<A0, A1>::type
- type0;
-
- typedef
- typename expression::sequence<
- type0
- , A2
- >::type
- type;
-
- static type make(A0 a0, A1 a1, A2 a2)
- {
- return expression::sequence<type0, A2>::make(make_locals<A0, A1>::make(a0, a1), a2);
- }
- };
-
- template <typename A0, typename A1, typename A2, typename A3>
- struct make_locals<A0, A1, A2, A3>
- {
- typedef
- typename make_locals<A0, A1, A2>::type
- type0;
-
- typedef
- typename expression::sequence<
- type0
- , A3
- >::type
- type;
-
- static type make(A0 a0, A1 a1, A2 a2, A3 a3)
- {
- return expression::sequence<type0, A3>::make(make_locals<A0, A1, A2>::make(a0, a1, a2), a3);
- }
- };
- }
struct let_local_gen
{
@@ -227,167 +157,20 @@
return expr0;
}
- template <typename Expr0, typename Expr1>
- let_actor_gen<
- typename detail::make_locals<Expr0, Expr1>::type
- > const
- operator()(Expr0 const& expr0, Expr1 const& expr1) const
- {
- return detail::make_locals<Expr0, Expr1>::make(expr0, expr1);
- }
-
- template <typename Expr0, typename Expr1, typename Expr2>
- let_actor_gen<
- typename detail::make_locals<Expr0, Expr1, Expr2>::type
- > const
- operator()(Expr0 const& expr0, Expr1 const& expr1, Expr2 const& expr2) const
- {
- return detail::make_locals<Expr0, Expr1, Expr2>::make(expr0, expr1, expr2);
- }
-
- template <typename Expr0, typename Expr1, typename Expr2, typename Expr3>
- let_actor_gen<
- typename detail::make_locals<Expr0, Expr1, Expr2, Expr3>::type
- > const
- operator()(Expr0 const& expr0, Expr1 const& expr1, Expr2 const& expr2, Expr3 const & expr3) const
- {
- return detail::make_locals<Expr0, Expr1, Expr2, Expr3>::make(expr0, expr1, expr2, expr3);
- }
- };
-
- let_local_gen const let = let_local_gen();
- /*
- template <typename Map>
- struct let_eval
- {
- template <typename Sig>
- struct result;
-
- template <typename This, typename Env, typename Expr, typename Vars>
- struct result<This(Env&, Expr const&, Vars const&)>
- {
- typedef typename
- fusion::result_of::as_vector<
- typename fusion::result_of::transform<
- typename proto::result_of::value<Vars>::type
- , detail::initialize_local<Env>
- >::type
- >::type
- locals_type;
-
- typedef scoped_environment<Env, Env, locals_type, Map> env_type;
-
- typedef typename boost::result_of<eval_grammar(Expr const&, env_type&)>::type type;
- };
-
- template <typename Env, typename Expr, typename Vars>
- typename result<let_eval(Env&, Expr const&, Vars const&)>::type
- operator()(Env& env, Expr const& expr, Vars const& vars) const
- {
- typename result<let_eval(Env&, Expr const&, Vars const&)>::env_type
- args(
- env
- , env
- , fusion::as_vector(
- fusion::transform(
- proto::value(vars)
- , detail::initialize_local<Env>(env)
- )
- )
- );
-
- return eval(expr, args);
- }
- };
-
- template <typename Map, typename Dummy>
- struct enable_nullary<let_eval<Map>, Dummy>
- : mpl::true_
- {};
-
- template <typename Expr, typename Vars, typename Map>
- struct make_let: compose<let_eval<Map>, Expr, Vars> {};
-
- template <typename Vars, typename Map>
- struct let_actor_gen
- {
- template <typename Expr>
- typename make_let<Expr, Vars, Map>::type const
- operator[](Expr const& expr) const
- {
- return make_let<Expr, Vars, Map>()(expr, vars);
- }
-
- let_actor_gen(Vars const& vars)
- : vars(vars) {}
-
- Vars vars;
- };
-
- struct let_gen
- : let_actor_gen<
- fusion::vector0<>
- , detail::map_local_index_to_tuple<> >
- {
- typedef let_actor_gen<fusion::vector0<>, detail::map_local_index_to_tuple<> > base_type;
-
- let_gen()
- : base_type(fusion::vector0<>())
- {}
-
- template <typename A0>
- let_actor_gen<
- fusion::vector1<typename proto::result_of::child_c<A0, 1>::type>
- , detail::map_local_index_to_tuple<
- typename proto::result_of::value<
- typename proto::result_of::child_c<
- typename proto::result_of::child_c<A0, 0>::type, 0
- >::type
- >::type::type::key_type
- >
- > const
- operator()(A0 const& a0) const
- {
- return fusion::vector1<typename proto::result_of::child_c<A0, 1>::type>(proto::child_c<1>(a0));
- }
-
- template <typename A0, typename A1>
- let_actor_gen<
- fusion::vector2<
- typename proto::result_of::child_c<A0, 1>::type
- , typename proto::result_of::child_c<A1, 1>::type
- >
- , detail::map_local_index_to_tuple<
- typename proto::result_of::value<
- typename proto::result_of::child_c<
- typename proto::result_of::child_c<A0, 0>::type, 0
- >::type
- >::type::type::key_type
- , typename proto::result_of::value<
- typename proto::result_of::child_c<
- typename proto::result_of::child_c<A1, 0>::type, 0
- >::type
- >::type::type::key_type
- >
- > const
- operator()(A0 const& a0, A1 const& a1) const
- {
- return fusion::vector2<
- typename proto::result_of::child_c<A0, 1>::type
- , typename proto::result_of::child_c<A1, 1>::type
- >(
- proto::child_c<1>(a0)
- , proto::child_c<1>(a1)
- );
- }
-
- #define PHOENIX_LOCAL_GEN_NAME let_actor_gen
- #include <boost/phoenix/scope/detail/local_gen.hpp>
- #undef PHOENIX_LOCAL_GEN_NAME
+#define PHOENIX_LET_LOCAL_GEN(Z, N, DATA) \
+ template <PHOENIX_typename_A(N)> \
+ let_actor_gen< \
+ typename detail::make_locals<PHOENIX_A(N)>::type \
+ > const \
+ operator()(PHOENIX_A_const_ref_a(N)) const \
+ { \
+ return detail::make_locals<PHOENIX_A(N)>::make(PHOENIX_a(N)); \
+ } \
+ /**/
+ BOOST_PP_REPEAT_FROM_TO(2, PHOENIX_LOCAL_LIMIT, PHOENIX_LET_LOCAL_GEN, _)
};
- let_gen const let = let_gen();
- */
+ let_local_gen const let = {};
}}
#endif
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-02 12:01:09 EST (Thu, 02 Dec 2010)
@@ -10,7 +10,7 @@
#include <boost/phoenix/core/actor.hpp>
#include <boost/phoenix/core/expression.hpp>
-//#include <boost/phoenix/scope/detail/local_variable.hpp>
+#include <boost/phoenix/statement/sequence.hpp>
namespace boost { namespace phoenix
{
@@ -24,14 +24,25 @@
{
template <typename Key>
struct local_variable
+ : proto::terminal< ::boost::phoenix::local_variable<Key> >
{
- typedef proto::terminal< ::boost::phoenix::local_variable<Key> > proto_grammar;
- typedef typename proto_grammar::type base_type;
- typedef base_type type;
+ typedef
+ actor<
+ typename proto::terminal<
+ ::boost::phoenix::local_variable<Key>
+ >::type
+ >
+ type;
- static type make()
+ static
+ actor<
+ typename proto::terminal<
+ ::boost::phoenix::local_variable<Key>
+ >::type
+ >
+ make()
{
- base_type e = {local_variable<Key>()};
+ actor<type> e = {{local_variable<Key>()}};
return e;
}
};
@@ -47,101 +58,71 @@
: proto::assign<local_variable, meta_grammar>
{};
- struct test_eval
+ struct local_eval
: proto::callable
{
template <typename Sig>
struct result;
template <typename This, typename Expr, typename Env>
- struct result<This(Expr const&, Env)>
+ struct result<This(Expr&, Env)>
{
typedef
typename boost::result_of<
evaluator(Expr const &, Env &)
>::type
result_type;
- /*
- typedef
- typename proto::terminal<
- typename mpl::if_<
- is_reference<result_type>
- , reference_wrapper<
- typename boost::remove_reference<
- result_type
- >::type
- >
- , result_type
- >::type
- >::type
- type;
- */
typedef
typename mpl::eval_if<
is_reference<result_type>
, reference<typename boost::remove_reference<result_type>::type>
- , value<result_type>//typename boost::remove_reference<result_type>::type>
+ , value<result_type>
>::type
type;
};
template <typename Expr, typename Env>
- typename result<test_eval(Expr const&, Env&)>::type
- operator()(Expr const& expr, Env & env) const
+ typename result<local_eval(Expr&, Env&)>::type
+ operator()(Expr& expr, Env & env) const
{
- typedef typename result<test_eval(Expr const&, Env&)>::result_type result_type;
+ typedef typename result<local_eval(Expr const&, Env&)>::result_type result_type;
- std::cout << "precompute locals ... ";
-
return this->make(expr, env, typename is_reference<result_type>::type());
}
private:
template <typename Expr, typename Env>
- typename result<test_eval(Expr const&, Env&)>::type
+ typename result<local_eval(Expr const&, Env&)>::type
make(Expr const& expr, Env & env, mpl::true_) const
{
typedef
typename remove_reference<
- typename result<test_eval(Expr const&, Env&)>::result_type
+ typename result<local_eval(Expr const&, Env&)>::result_type
>::type
result_type;
- std::cout << "as reference ... ";
-
- return this->make_ref(expr, env, typename is_const<result_type>::type());//phoenix::ref(eval(expr, env));
+ return this->make_ref(expr, env, typename is_const<result_type>::type());
}
template <typename Expr, typename Env>
- typename result<test_eval(Expr const&, Env&)>::type
+ typename result<local_eval(Expr const&, Env&)>::type
make_ref(Expr const& expr, Env & env, mpl::true_) const
{
- std::cout << "const ...\n";
- std::cout << typeid(Expr).name() << "\n";
return phoenix::cref(eval(expr, env));
}
template <typename Expr, typename Env>
- typename result<test_eval(Expr const&, Env&)>::type
+ typename result<local_eval(Expr const&, Env&)>::type
make_ref(Expr const& expr, Env & env, mpl::false_) const
{
- std::cout << "non-const ...\n";
- std::cout << typeid(phoenix::ref(eval(expr, env))).name() << "\n";
- //int &i = eval(expr, env);
return phoenix::ref(eval(expr, env));
}
template <typename Expr, typename Env>
- typename result<test_eval(Expr const&, Env&)>::type
+ typename result<local_eval(Expr const&, Env&)>::type
make(Expr const& expr, Env & env, mpl::false_) const
{
- typedef typename result<test_eval(Expr const&, Env&)>::result_type result_type;
- result_type i = eval(expr, env);
- std::cout << "as value\n";
- std::cout << typeid(Expr).name() << "\n";
- std::cout << typeid(boost::ref(fusion::at_c<0>(env))).name() << "\n";
- std::cout << typeid(reference_wrapper<typename boost::result_of<evaluator(Expr const &, Env &)>::type>).name() << "\n";
- return phoenix::val(i);//eval(expr, env));
+ return phoenix::val(eval(expr, env));
}
};
@@ -162,21 +143,10 @@
local_var_def
, proto::assign<
proto::_left
- , test_eval(proto::_right, proto::_state)
- /*, proto::terminal<
- evaluator(proto::_right, _env)
- >
- */
+ , local_eval(proto::_right, proto::_state)
>(
proto::_left
- , test_eval(proto::_right, proto::_state)
- /*
- , proto::terminal<
- evaluator(proto::_right, _env)
- >(
- evaluator(proto::_right, _env)
- )
- */
+ , local_eval(proto::_right, proto::_state)
)
>
>
@@ -185,7 +155,28 @@
namespace detail
{
- struct local_var_not_found {};
+ struct local_var_not_found
+ {
+ template <typename T>
+ T const & operator=(T const & t)
+ {
+ return t;
+ }
+ };
+
+ template <typename T>
+ T operator+(local_var_not_found const&, T const & t)
+ {
+ return t;
+ }
+
+ /*
+ template <typename T>
+ T operator+(T const & t, local_var_not_found const&)
+ {
+ return t;
+ }
+ */
struct find_local
: proto::or_<
@@ -194,8 +185,6 @@
, proto::if_<
proto::matches<proto::_left(proto::_right), proto::_data>()
, evaluator(proto::_right(proto::_right), proto::_state)
- //, proto::_value(proto::_right(proto::_right))
- //, proto::_right(proto::_right)
, find_local(proto::_left, proto::_state, proto::_data)
>
>
@@ -204,8 +193,6 @@
, proto::if_<
proto::matches<proto::_left, proto::_data>()
, evaluator(proto::_right, proto::_state)
- //, proto::_value(proto::_right)
- //, proto::_right
, detail::local_var_not_found()
>
>
@@ -218,7 +205,7 @@
typename is_same<
typename proto::detail::uncvref<
typename boost::result_of<
- detail::find_local(typename Args::locals_type, Env, Key)
+ detail::find_local(typename Args::locals_type &, Env, Key)
>::type
>::type
, detail::local_var_not_found
@@ -226,11 +213,9 @@
, typename boost::result_of<
This(typename Args::outer_env_type&)
>::type
- , //typename proto::result_of::value<
- typename boost::result_of<
- detail::find_local(typename Args::locals_type, Env, Key)
- >::type
- //>::type
+ , typename boost::result_of<
+ detail::find_local(typename Args::locals_type &, Env, Key)
+ >::type
>
{};
}
@@ -265,8 +250,6 @@
typename result<get_local<Key>(Env&)>::type
operator()(Env &env) const
{
- typedef typename result<get_local<Key>(Env&)>::type result_type;
-
typedef
typename proto::detail::uncvref<
typename boost::result_of<
@@ -274,8 +257,6 @@
>::type
>::type
env_type;
- std::cout << "getting local var\n";
- //std::cout << typeid(boost::ref(this->evaluate(env, typename is_scoped_environment<env_type>::type()))).name() << "\n";
return this->evaluate(
env
@@ -336,136 +317,64 @@
};
- /*
- struct scope_grammar
- : proto::or_<
- proto::when<rule::local_variable, proto::external_transform>
- , meta_grammar
- >
- {};
- */
-
template<typename T>
struct is_custom_terminal<local_variable<T> >
: mpl::true_
{};
- struct local_var_eval
+ template<typename T>
+ struct custom_terminal<local_variable<T> >
: proto::callable
{
template <typename Sig>
struct result;
template <typename This, typename Local, typename Env>
- struct result<This(Local const &, Env)>
+ struct result<This(Local &, Env)>
{
typedef
proto::terminal< local_variable<typename Local::type> >
lookup_grammar;
- /*
- typedef
- typename boost::result_of<
- functional::args(Env &)
- >::type
- args_type;
- */
+
typedef
typename boost::result_of<get_local<lookup_grammar>(Env)>::type
type;
};
- //typedef int result_type;
-
template <typename Local, typename Env>
- typename result<local_var_eval(Local const &, Env&)>::type
- operator()(Local const& local, Env & env)
+ typename result<custom_terminal(Local const &, Env&)>::type
+ operator()(Local & local, Env & env)
{
typedef
proto::terminal< local_variable<typename Local::type> >
lookup_grammar;
-
- std::cout << "local_var_eval\n";
-
- //std::cout << "local_var_eval\n";
- //std::cout << typeid(typename boost::result_of<functional::args(Env&)>::type).name() << "\n";
- //std::cout << typeid(Local).name() << "\n\n";
- //std::cout << typeid(typename boost::result_of<get_local<lookup_grammar>(typename boost::result_of<functional::args(Env &)>::type&)>::type).name() << "\n";
- //std::cout << detail::find_local()(functional::args()(env).locals, lookup_grammar()) << "\n";
- //std::cout << get_local<lookup_grammar>()(functional::args()(env)) << "\n";
- //std::cout << typeid(boost::ref(get_local<lookup_grammar>()(env))).name() << "\n";
- //get_local<lookup_grammar>()(env);
- return get_local<lookup_grammar>()(env);//functional::args()(env));
+ return get_local<lookup_grammar>()(env);
}
};
-
- template<typename T>
- struct custom_terminal<local_variable<T> >
- : local_var_eval
- {};
-
- /*
- template <typename Dummy>
- struct default_actions::when<rule::local_variable, Dummy>
- : proto::call<local_var_eval(_env, proto::_value)>
- {};
- */
-
- /*
- template <typename Env, typename OuterEnv, typename Locals, typename Map>
- struct scoped_environment;
- namespace result_of
- {
- template <typename Env, typename Key>
- struct local_variable
- : boost::phoenix::detail::apply_local<
- Key//typename boost::result_of<eval_grammar(Key const&)>::type
- , Env>
- {};
- }
-
-
- template <typename Key>
- struct local_variable
+ struct foo
+ : proto::callable
{
-
- typedef Key key_type;
-
template <typename Sig>
struct result;
template <typename This, typename Env>
- struct result<This(Env&)>
- : result_of::local_variable<Env, Key>
+ struct result<This(Env)>
+ : is_scoped_environment<Env>
{};
-
- template <typename Env>
- typename result_of::local_variable<Env, Key>::type
- operator()(Env & env)
- {
- typedef typename result_of::local_variable<Env, Key>::type return_type;
- typedef typename Env::map_type map_type;
- typedef typename
- detail::get_index<map_type, Key>::type
- index_type;
-
- typedef detail::eval_local<Key> eval_local;
-
- return eval_local::template get<return_type>(
- env
- , index_type());
- }
};
-
- template <typename Key>
- struct make_local_variable : compose<local_variable<Key> > {};
- template <typename Key, typename Dummy>
- struct enable_nullary<local_variable<Key>, Dummy>
- : mpl::false_
+ template <typename T>
+ struct is_nullary<custom_terminal<local_variable<T> > >
+ //: proto::make<mpl::false_()>
+ : proto::if_<
+ //is_scoped_environment<functional::args(proto::_state)>()
+ foo(functional::args(proto::_state))
+ , mpl::false_()
+ , mpl::true_()
+ >
{};
- */
namespace local_names
{
@@ -496,6 +405,60 @@
expression::local_variable<struct _y_key>::type const _y = {};
expression::local_variable<struct _z_key>::type const _z = {};
}
+
+ namespace detail
+ {
+ template <PHOENIX_typename_A_void(PHOENIX_LOCAL_LIMIT)>
+ struct make_locals;
+
+ template <typename A0, typename A1>
+ struct make_locals<A0, A1>
+ {
+ typedef
+ typename expression::sequence<A0, A1>::type
+ type;
+
+ static type make(A0 a0, A1 a1)
+ {
+ return expression::sequence<A0, A1>::make(a0, a1);
+ }
+ };
+
+ #define PHOENIX_MAKE_LOCALS(Z, N, DATA) \
+ template <PHOENIX_typename_A(N)> \
+ struct make_locals<PHOENIX_A(N)> \
+ { \
+ typedef \
+ typename make_locals<PHOENIX_A(BOOST_PP_DEC(N))>::type \
+ type0; \
+ \
+ typedef \
+ typename expression::sequence< \
+ type0 \
+ , BOOST_PP_CAT(A, BOOST_PP_DEC(N)) \
+ >::type \
+ type; \
+ \
+ static type make(PHOENIX_A_a(N)) \
+ { \
+ return \
+ expression::sequence< \
+ type0 \
+ , BOOST_PP_CAT(A, BOOST_PP_DEC(N)) \
+ >::make( \
+ make_locals< \
+ PHOENIX_A(BOOST_PP_DEC(N)) \
+ >::make( \
+ PHOENIX_a(BOOST_PP_DEC(N)) \
+ ) \
+ , BOOST_PP_CAT(a, BOOST_PP_DEC(N)) \
+ ); \
+ } \
+ }; \
+ /**/
+ BOOST_PP_REPEAT_FROM_TO(3, PHOENIX_LOCAL_LIMIT, PHOENIX_MAKE_LOCALS, _)
+ #undef PHOENIX_MAKE_LOCALS
+ }
}}
#endif
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-02 12:01:09 EST (Thu, 02 Dec 2010)
@@ -46,7 +46,7 @@
Env env;
OuterEnv outer_env;
- Locals const & locals;
+ Locals locals;
#define PHOENIX_ADAPT_SCOPED_ENVIRONMENT(INTRINSIC) \
template <typename Seq> \
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-02 12:01:09 EST (Thu, 02 Dec 2010)
@@ -11,6 +11,7 @@
#define PHOENIX_STATEMENT_TRY_CATCH_HPP
#include <boost/phoenix/core/expression.hpp>
+#include <boost/phoenix/core/unpack.hpp>
#include <boost/phoenix/support/iterate.hpp>
namespace boost { namespace phoenix
Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile 2010-12-02 12:01:09 EST (Thu, 02 Dec 2010)
@@ -74,7 +74,7 @@
test-suite phoenix_scope :
# [ run scope/lambda_tests.cpp ]
-# [ run scope/let_tests.cpp ]
+ [ run scope/let_tests.cpp ]
# [ run scope/dynamic_tests.cpp ]
# [ run scope/bug_000008.cpp : : : $(multi-threading) ]
;
@@ -100,8 +100,8 @@
[ run boost_bind_compatibility/bind_eq_test.cpp ]
[ run boost_bind_compatibility/bind_eq2_test.cpp ]
[ run boost_bind_compatibility/bind_eq3_test.cpp ]
- #[ run boost_bind_compatibility/bind_fastcall_mf_test.cpp ] # problem: result_of can't handle the fastcall attribute
- #[ run boost_bind_compatibility/bind_fastcall_test.cpp ] # problem: result_of can't handle the fastcall attribute
+ #[ run boost_bind_compatibility/bind_fastcall_mf_test.cpp ]
+ #[ run boost_bind_compatibility/bind_fastcall_test.cpp ]
[ run boost_bind_compatibility/bind_fn2_test.cpp ]
[ run boost_bind_compatibility/bind_function_test.cpp ]
[ run boost_bind_compatibility/bind_mf2_test.cpp ]
@@ -112,8 +112,8 @@
[ run boost_bind_compatibility/bind_rvalue_test.cpp ]
[ run boost_bind_compatibility/bind_rv_sp_test.cpp ]
[ run boost_bind_compatibility/bind_stateful_test.cpp ]
- #[ run boost_bind_compatibility/bind_stdcall_mf_test.cpp ] # problem: result_of can't handle the stdcall attribute
- #[ run boost_bind_compatibility/bind_stdcall_test.cpp ] # problem: result_of can't handle the stdcall attribute
+ #[ run boost_bind_compatibility/bind_stdcall_mf_test.cpp ]
+ #[ run boost_bind_compatibility/bind_stdcall_test.cpp ]
[ run boost_bind_compatibility/bind_test.cpp ]
;
Modified: sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/lambda_tests.cpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/lambda_tests.cpp (original)
+++ sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/lambda_tests.cpp 2010-12-02 12:01:09 EST (Thu, 02 Dec 2010)
@@ -14,10 +14,10 @@
#define PHOENIX_LIMIT 5
#include <boost/detail/lightweight_test.hpp>
-#include <boost/phoenix/scope.hpp>
#include <boost/phoenix/core.hpp>
#include <boost/phoenix/operator.hpp>
#include <boost/phoenix/function.hpp>
+#include <boost/phoenix/scope.hpp>
namespace boost { namespace phoenix
{
@@ -75,13 +75,14 @@
using boost::phoenix::local_names::_a;
using boost::phoenix::local_names::_b;
using boost::phoenix::placeholders::arg1;
-/*
+
{
int x = 1;
int y = lambda[_1]()(x);
BOOST_TEST(x == y);
}
+/*
{
int x = 1, y = 10;
BOOST_TEST(
@@ -102,7 +103,6 @@
(x, z)(y) == x + y + z
);
}
-*/
{
int x = 4;
int y = 5;
@@ -114,7 +114,6 @@
BOOST_TEST(x == 555);
(void)y;
}
-/*
{
int x = 1;
long x2 = 2;
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-02 12:01:09 EST (Thu, 02 Dec 2010)
@@ -14,15 +14,20 @@
#include <boost/phoenix/core.hpp>
#include <boost/phoenix/operator.hpp>
#include <boost/phoenix/function.hpp>
-//#include <boost/phoenix/fusion.hpp>
+#include <boost/phoenix/fusion.hpp>
#include <boost/phoenix/scope.hpp>
-#include <boost/fusion/container/vector.hpp>
+#include <boost/fusion/tuple.hpp>
#include <typeinfo>
namespace fusion = boost::fusion;
namespace mpl = boost::mpl;
+int test()
+{
+ return 5;
+}
+
int
main()
{
@@ -41,24 +46,6 @@
using boost::phoenix::local_names::_z;
using boost::phoenix::placeholders::arg1;
- {
- int x = 999;
- //BOOST_TEST(
- let(_x = val(_1)) // _x holds x by value
- [
- val(_x)// += val(888))
- ]
- (x);// == x + 888*/
- std::cout << typeid(
- let(_x = val(_1)) // _x holds x by value
- [
- val(_x)// += val(888))
- ]
- (x)).name() << "\n";// == x + 888*/
- //);
-
- BOOST_TEST(x == 999);
- }
#if 0
{
int x = 1;
@@ -83,18 +70,16 @@
}
{
- // TODO: fixme
int x = 1, y = 10, z = 13;
BOOST_TEST(
let(_x = _1, _y = _2)
[
let(_z = _3)
[
- _z
- //_x + _y + _z
+ _x + _y + _z
]
]
- (x, y, z) == z//x + y + z
+ (x, y, z) == x + y + z
);
}
@@ -128,44 +113,39 @@
{
int x = 999;
- //BOOST_TEST(
+ BOOST_TEST(
+ let(_x = val(_1)) // _x holds x by value
+ [
+ _x += 888
+ ]
+ (x) == x + 888
+ );
+
+ BOOST_TEST(x == 999);
+
+ BOOST_TEST(
let(_x = val(_1)) // _x holds x by value
[
val(_x += 888)
]
- (x);// == x + 888
- //);
+ (x) == x + 888
+ );
BOOST_TEST(x == 999);
}
+#endif
- /*
{
- // FIXME do not require a argument to return int
BOOST_TEST(
let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5)
[
_a + _b + _c + _d + _e
]
- (0) == 1 + 2 + 3 + 4 + 5
+ () == 1 + 2 + 3 + 4 + 5
);
- std::cout << typeid(
- let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5)
- [
- _a + _b + _c + _d + _e
- ]
- ()
- ).name() << "\n";
- std::cout << typeid(
- let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5)
- [
- _a + _b + _c + _d + _e
- ]
- (0)
- ).name() << "\n";
}
- */
+#if 0
#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST
{
// disallow this:
@@ -174,7 +154,6 @@
}
#endif
- /*
{
// show that we can return a local from an outer scope
int y = 0;
@@ -182,7 +161,6 @@
BOOST_TEST(x == 1);
}
- */
{
// show that this code returns an lvalue
@@ -198,7 +176,6 @@
BOOST_TEST(&i == &j);
}
- /*
{
using boost::phoenix::at_c;
@@ -207,7 +184,6 @@
BOOST_TEST( i == 0 );
}
- */
{
int i = 0;
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