Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64150 - in sandbox/SOC/2010/phoenix3: boost/phoenix boost/phoenix/core boost/phoenix/scope boost/phoenix/scope/detail libs/phoenix/test libs/phoenix/test/scope
From: thom.heller_at_[hidden]
Date: 2010-07-19 04:23:31


Author: theller
Date: 2010-07-19 04:23:28 EDT (Mon, 19 Jul 2010)
New Revision: 64150
URL: http://svn.boost.org/trac/boost/changeset/64150

Log:
started lambda implementation, basic stuff working
Added:
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope.hpp (contents, props changed)
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/detail/
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/detail/local_variable.hpp (contents, props changed)
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp (contents, props changed)
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_actor.hpp (contents, props changed)
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp (contents, props changed)
   sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp (contents, props changed)
Text files modified:
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/actor.hpp | 2 +-
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/argument.hpp | 4 ++--
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/arity.hpp | 10 ++++++++++
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/compose.hpp | 3 ++-
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/environment.hpp | 15 +++++++++++++--
   sandbox/SOC/2010/phoenix3/boost/phoenix/core/meta_grammar.hpp | 7 ++++++-
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/Jamfile | 4 ++--
   sandbox/SOC/2010/phoenix3/libs/phoenix/test/scope/lambda_tests.cpp | 29 ++++++++++++++++++++++-------
   8 files changed, 58 insertions(+), 16 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-07-19 04:23:28 EDT (Mon, 19 Jul 2010)
@@ -51,7 +51,7 @@
 
             typedef typename
                 mpl::eval_if_c<
- arity == 0 // avoid calling result_of::actor when this is true
+ arity == 0 // avoid calling result_of::actor when this is false
                   , boost::result_of<eval_grammar(Expr const&,
                         typename make_basic_environment<>::type&)>
                   , mpl::identity<detail::error_expecting_arguments>

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/argument.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/argument.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/argument.hpp 2010-07-19 04:23:28 EDT (Mon, 19 Jul 2010)
@@ -45,13 +45,13 @@
         struct result;
 
         template <typename This, typename Env, typename N>
- struct result<This(Env&, N&)>
+ struct result<This(Env&, N const&)>
             : result_of::argument<Env, N>
         {};
 
         template <typename Env, typename N>
         typename result_of::argument<Env, N>::type
- operator()(Env& env, N& n) const
+ operator()(Env& env, N const& n) const
         {
             return get_environment_argument()(env, eval(n));
         }

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/arity.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/arity.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/arity.hpp 2010-07-19 04:23:28 EDT (Mon, 19 Jul 2010)
@@ -33,6 +33,9 @@
     struct funcwrap;
 
     struct env;
+
+ template <typename Key>
+ struct local_variable;
 
     namespace detail
     {
@@ -47,6 +50,13 @@
>
                   , mpl::next<proto::_value(proto::_child2)>()
>
+ , proto::when<
+ proto::function<
+ proto::terminal<funcwrap<local_variable<proto::_> > >
+ , proto::terminal<env>
+ >
+ , mpl::int_<100>()
+ >
               , proto::otherwise<
                     proto::fold<
                         proto::_

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/compose.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/compose.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/compose.hpp 2010-07-19 04:23:28 EDT (Mon, 19 Jul 2010)
@@ -40,7 +40,8 @@
     template <typename F
         , PHOENIX_typename_A_void(PHOENIX_COMPOSITE_LIMIT)
         , typename Dummy = void>
- struct compose : compose_ex<F, actor, PHOENIX_A(PHOENIX_COMPOSITE_LIMIT)> {};
+ struct compose : compose_ex<F, actor, PHOENIX_A(PHOENIX_COMPOSITE_LIMIT)>
+ {};
 
     template <typename F, template<typename> class Actor>
     struct compose_ex<F, Actor>

Modified: sandbox/SOC/2010/phoenix3/boost/phoenix/core/environment.hpp
==============================================================================
--- sandbox/SOC/2010/phoenix3/boost/phoenix/core/environment.hpp (original)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/core/environment.hpp 2010-07-19 04:23:28 EDT (Mon, 19 Jul 2010)
@@ -20,11 +20,21 @@
     
     namespace result_of
     {
- template <typename Env, typename N>
+ template <typename Env, typename N, typename Dummy = void>
         struct get_environment_argument
             : fusion::result_of::at_c<Env, N::value> {};
     }
 
+ template <int N, typename Env>
+ typename boost::enable_if<
+ is_environment<Env>
+ , typename result_of::get_environment_argument<Env, mpl::int_<N> >::type
+ >::type
+ get_environment_argument_c(Env& env)
+ {
+ return fusion::at_c<N>(env);
+ }
+
     // Get the Nth argument from the environment
     struct get_environment_argument
     {
@@ -39,7 +49,8 @@
         typename result_of::get_environment_argument<Env, N>::type
         operator()(Env& env, N) const
         {
- return fusion::at_c<N::value>(env);
+ return get_environment_argument_c<N::value>(env);
+ //return fusion::at_c<N::value>(env);
         }
     };
     

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-07-19 04:23:28 EDT (Mon, 19 Jul 2010)
@@ -38,7 +38,12 @@
     struct eval_cases
     {
         template <class Tag>
- struct case_ : proto::_default<eval_grammar> {};
+ struct case_
+ : proto::or_<
+ proto::when<proto::terminal<env>, proto::_state>
+ , proto::otherwise<proto::_default<eval_grammar> >
+ >
+ {};
     };
 
     ////////////////////////////////////////////////////////////////////////////

Added: sandbox/SOC/2010/phoenix3/boost/phoenix/scope.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope.hpp 2010-07-19 04:23:28 EDT (Mon, 19 Jul 2010)
@@ -0,0 +1,17 @@
+/*==============================================================================
+ Copyright (c) 2005-2010 Joel de Guzman
+ Copyright (c) 2010 Thomas Heller
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#ifndef PHOENIX_SCOPE_HPP
+#define PHOENIX_SCOPE_HPP
+
+#include <boost/phoenix/version.hpp>
+#include <boost/phoenix/scope/scoped_environment.hpp>
+#include <boost/phoenix/scope/lambda.hpp>
+//#include <boost/phoenix/let.hpp>
+#include <boost/phoenix/scope/local_variable.hpp>
+
+#endif

Added: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/detail/local_variable.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/detail/local_variable.hpp 2010-07-19 04:23:28 EDT (Mon, 19 Jul 2010)
@@ -0,0 +1,173 @@
+/*==============================================================================
+ Copyright (c) 2005-2010 Joel de Guzman
+ Copyright (c) 2010 Thomas Heller
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#ifndef PHOENIX_SCOPE_DETAIL_LOCAL_VARIABLE_HPP
+#define PHOENIX_SCOPE_DETAIL_LOCAL_VARIABLE_HPP
+
+#define PHOENIX_MAP_LOCAL_TEMPLATE_PARAM(z, n, data) \
+ typename T##n = unused<n>
+
+#define PHOENIX_MAP_LOCAL_DISPATCH(z, n, data) \
+ typedef char(&result##n)[n+2]; \
+ static result##n get(T##n*);
+
+
+namespace boost { namespace phoenix
+{
+
+ namespace detail
+ {
+ template <typename Env>
+ struct initialize_local
+ {
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Expr>
+ struct result<This(Expr)>
+ {
+ typedef typename remove_reference<Expr>::type expr_type;
+ typedef typename boost::result_of<eval_grammar(expr_type const&, Env &)>::type type;
+ };
+
+ initialize_local(Env const& env)
+ : env(env) {}
+
+ template <typename Expr>
+ typename result<initialize_local(Expr)>::type
+ operator()(Expr const& expr) const
+ {
+ return eval(expr, env);
+ }
+
+ Env const& env;
+ };
+
+ template <int N>
+ struct unused;
+
+ template <BOOST_PP_ENUM(
+ PHOENIX_LOCAL_LIMIT, PHOENIX_MAP_LOCAL_TEMPLATE_PARAM, _)>
+ struct map_local_index_to_tuple
+ {
+ typedef char(&not_found)[1];
+ static not_found get(...);
+
+ BOOST_PP_REPEAT(PHOENIX_LOCAL_LIMIT, PHOENIX_MAP_LOCAL_DISPATCH, _)
+ };
+
+ template<typename T>
+ T* generate_pointer();
+
+ template <typename Map, typename Tag>
+ struct get_index
+ {
+ BOOST_STATIC_CONSTANT(int,
+ value = (
+ static_cast<int>((sizeof(Map::get(generate_pointer<Tag>()))) / sizeof(char)) - 2
+ ));
+
+ // if value == -1, Tag is not found
+ typedef mpl::int_<value> type;
+ };
+
+ template <typename Key, typename Env>
+ struct apply_local;
+
+ template <typename Key, typename Env>
+ struct outer_local
+ {
+ typedef typename
+ apply_local<Key, typename Env::outer_env_type>::type
+ type;
+ };
+
+ template <typename Locals, typename Index>
+ struct get_local_or_void
+ {
+ typedef typename
+ mpl::eval_if<
+ mpl::less<Index, mpl::size<Locals> >
+ , fusion::result_of::at<Locals, Index>
+ , mpl::identity<fusion::void_>
+ >::type
+ type;
+ };
+
+ template <typename Key, typename Env, typename Index>
+ struct get_local_from_index
+ {
+ typedef typename
+ mpl::eval_if<
+ mpl::equal_to<Index, mpl::int_<-1> >
+ , outer_local<Key, Env>
+ , get_local_or_void<typename Env::locals_type, Index>
+ >::type
+ type;
+ };
+
+ template <typename Key, typename Env>
+ struct get_local
+ {
+ typedef typename
+ get_index<
+ typename Env::map_type, Key>::type
+ index_type;
+
+ typedef typename
+ get_local_from_index<Key, Env, index_type>::type
+ type;
+ };
+
+ template <typename Key, typename Env>
+ struct apply_local
+ {
+ BOOST_STATIC_ASSERT( is_scoped_environment<Env>::value );
+ // $$$ TODO: static assert that Env is a scoped_environment $$$
+ typedef typename get_local<Key, Env>::type type;
+ };
+
+ template <typename Key>
+ struct eval_local
+ {
+ template <typename RT, typename Env, typename Index>
+ static RT
+ get(Env const& env, Index, mpl::false_)
+ {
+ return fusion::at<Index>(env.locals);
+ }
+
+ template <typename RT, typename Env, typename Index>
+ static RT
+ get(Env const& env, Index index, mpl::true_)
+ {
+ typedef typename
+ get_index<typename Env::outer_env_type::map_type, Key>::type
+ index_type;
+
+ return get<RT>(
+ env.outer_env
+ , index_type()
+ , mpl::equal_to<index_type, mpl::int_<-1> >());
+ }
+
+ template <typename RT, typename Env, typename Index>
+ static RT
+ get(Env const& env, Index index)
+ {
+ return get<RT>(
+ env
+ , index
+ , mpl::equal_to<Index, mpl::int_<-1> >());
+ }
+ };
+
+ }
+
+}}
+
+#endif

Added: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/lambda.hpp 2010-07-19 04:23:28 EDT (Mon, 19 Jul 2010)
@@ -0,0 +1,403 @@
+/*==============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+ Copyright (c) 2004 Daniel Wallin
+ Copyright (c) 2010 Thomas Heller
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#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/phoenix/core/limits.hpp>
+#include <boost/phoenix/scope/scoped_environment.hpp>
+#include <boost/phoenix/scope/local_actor.hpp>
+#include <boost/phoenix/scope/detail/local_variable.hpp>
+#include <boost/phoenix/support/element_at.hpp>
+#include <boost/phoenix/support/iterate.hpp>
+
+namespace boost { namespace phoenix
+{
+//#if 0
+ namespace result_of
+ {
+ template <typename Env, typename Expr>
+ struct lambda
+ {
+ typedef typename boost::result_of<eval_grammar(Expr const&, Env&)>::type type;
+ };
+ }
+
+ template <typename Map>
+ struct lambda_eval
+ {
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Env, typename Expr, typename OuterEnv, typename Locals>
+ struct result<This(Env&, Expr const&, OuterEnv const&, Locals const&)>
+ {
+ typedef scoped_environment<
+ Env
+ , typename proto::result_of::value<OuterEnv>::type
+ , typename proto::result_of::value<Locals>::type
+ , Map
+ > environment;
+
+ typedef typename boost::result_of<eval_grammar(Expr const&, environment&)>::type type;
+ };
+
+ template <typename Env, typename Expr, typename OuterEnv, typename Locals>
+ typename result<lambda_eval(Env&, Expr const&, OuterEnv const&, Locals const&)>::type
+ operator()(Env& env, Expr const& expr, OuterEnv const& outer_env, Locals const& locals) const
+ {
+ typedef typename result<lambda_eval(Env&, Expr const&, OuterEnv const&, Locals const&)>::environment environment;
+ environment args(env, proto::value(outer_env), proto::value(locals));
+
+ return eval(expr, args);
+ }
+ };
+
+ template <typename Expr, typename OuterEnv, typename Locals, typename Map>
+ struct make_lambda : compose<lambda_eval<Map>, Expr, OuterEnv, Locals> {};
+
+ template <typename Map>
+ struct lambda_actor_eval
+ {
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Env, typename A>
+ struct result<This(Env&, A const&)>
+ : boost::result_of<typename proto::result_of::value<A>::type(Env&)>
+ {};
+
+ template <typename Env, typename A>
+ typename result<lambda_actor_eval(Env&, A const&)>::type const
+ operator()(Env& env, A const& a)
+ {
+ return proto::value(a)(env);
+ }
+ };
+
+ template <typename Expr, typename Vars, typename Map>
+ struct lambda_actor
+ {
+ lambda_actor(Expr const& expr, Vars const& vars)
+ : expr(expr)
+ , vars(vars)
+ {}
+
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Env>
+ struct result<This(Env&)>
+ {
+ typedef typename
+ fusion::result_of::as_vector<
+ typename fusion::result_of::transform<
+ Vars
+ , detail::initialize_local<Env>
+ >::type
+ >::type
+ locals_type;
+
+ typedef typename make_lambda<Expr, Env, locals_type, Map>::type type;
+ };
+
+ template <typename Env>
+ typename result<lambda_actor(Env&)>::type const
+ operator()(Env& env) const
+ {
+ typedef typename result<lambda_actor(Env&)>::locals_type locals_type;
+
+ return make_lambda<Expr, Env, locals_type, Map>()(expr, env, fusion::transform(vars, detail::initialize_local<Env>(env)));
+ }
+
+ Expr expr;
+ Vars vars;
+ };
+
+ template <typename Expr, typename Vars, typename Map>
+ struct make_lambda_actor: compose<lambda_actor_eval<Map>, lambda_actor<Expr, Vars, Map> > {};
+
+ template <typename Vars, typename Map>
+ struct lambda_actor_gen
+ {
+
+ template <typename Expr>
+ typename make_lambda_actor<Expr, Vars, Map>::type const
+ operator[](Expr const expr) const
+ {
+ return make_lambda_actor<Expr, Vars, Map>()(lambda_actor<Expr, Vars, Map>(expr, vars));
+ }
+
+ lambda_actor_gen(Vars const& vars)
+ : vars(vars) {}
+
+ Vars const& vars;
+ };
+
+ struct lambda_gen
+ : lambda_actor_gen<
+ fusion::vector0<>
+ , detail::map_local_index_to_tuple<> >
+ {
+ typedef lambda_actor_gen<fusion::vector0<>, detail::map_local_index_to_tuple<> > base_type;
+
+ lambda_gen()
+ : base_type(fusion::vector0<>())
+ {}
+
+ template <typename A0>
+ lambda_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>
+ lambda_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)
+ );
+ }
+ };
+
+ lambda_gen const lambda = lambda_gen();
+
+//#endif
+#if 0
+
+ /*
+ namespace result_of
+ {
+ template <typename Expr, typename OuterEnv, typename Locals, typename Map, typename A0 = void, typename A1 = void>
+ struct lambda;
+
+ template <typename Expr, typename OuterEnv, typename Locals, typename Map, typename A0>
+ struct lambda<Expr, OuterEnv, Locals, Map, A0>
+ {
+ typedef typename make_basic_environment<A0>::type basic_env;
+ typedef scoped_environment<basic_env, OuterEnv, Locals, Map> args;
+
+ typedef typename boost::result_of<eval_grammar(Expr const&, args&)>::type type;
+ };
+ }
+
+ template <typename LambdaExpr, typename OuterEnv, typename Locals, typename Map>
+ struct lambda_eval
+ : LambdaExpr
+ {
+ typedef LambdaExpr base_type;
+
+ lambda_eval(LambdaExpr const& lambda_expr, OuterEnv const& outer_env, Locals const& locals)
+ : base_type(lambda_expr)
+ , outer_env(outer_env)
+ , locals(locals)
+ {}
+
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename A0>
+ struct result<This(A0)>
+ : result_of::lambda<LambdaExpr, OuterEnv, Locals, Map, A0>
+ {};
+
+ int
+ operator()() const
+ {
+ typename make_basic_environment<>::type env;
+ scoped_environment<typename make_basic_environment<>::type, OuterEnv, Locals, Map> args(env, outer_env, locals);
+
+ return eval(*this, args);
+ }
+
+ template <typename A0>
+ typename result_of::lambda<LambdaExpr, OuterEnv, Locals, Map, A0 const&>::type
+ operator()(A0 const& a0) const
+ {
+ typename make_basic_environment<A0 const&>::type env(a0);
+ scoped_environment<typename make_basic_environment<A0 const&>::type, OuterEnv, Locals, Map> args(env, outer_env, locals);
+
+ return eval(*this, args);
+ }
+
+ template <typename A0>
+ typename result_of::lambda<LambdaExpr, OuterEnv, Locals, Map, A0&>::type
+ operator()(A0& a0) const
+ {
+ typename make_basic_environment<A0&>::type env(a0);
+ scoped_environment<typename make_basic_environment<A0&>::type, OuterEnv, Locals, Map> args(env, outer_env, locals);
+
+ return eval(*this, args);
+ }
+
+ OuterEnv outer_env;
+ Locals locals;
+ };
+ */
+
+ template <typename LambdaExpr, typename Vars, typename Map>
+ struct lambda_actor_eval
+ {
+ lambda_actor_eval(LambdaExpr const& lambda_expr, Vars const& vars) : lambda_expr(lambda_expr), vars(vars) {}
+
+ LambdaExpr lambda_expr;
+ Vars vars;
+
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Env>
+ struct result<This(Env&)>
+ {
+
+ typedef typename
+ fusion::result_of::as_vector<
+ typename fusion::result_of::transform<
+ Vars
+ , detail::initialize_local<Env>
+ >::type
+ >::type
+ locals_type;
+ /*
+ typedef lambda_eval<LambdaExpr, Env, locals_type, Map> type;
+ */
+
+ typedef typename make_local_actor<LambdaExpr, Env, locals_type, Map>::type type;
+ };
+
+ template <typename Env>
+ typename result<lambda_actor_eval(Env&)>::type const
+ operator()(Env& env) const
+ {
+ typedef typename result<lambda_actor_eval(Env&)>::locals_type locals_type;
+ return make_local_actor<LambdaExpr, Env, locals_type, Map>()(lambda_expr, env, fusion::as_vector(fusion::transform(vars, detail::initialize_local<Env>(env))));
+ }
+
+ /*
+ template <typename Env>
+ typename result<lambda_actor_eval(Env&)>::type const
+ operator()(Env& env) const
+ {
+ typedef typename result<lambda_actor_eval(Env&)>::locals_type locals_type;
+ return lambda_eval<LambdaExpr, Env, locals_type, Map>(lambda_expr, env, fusion::as_vector(fusion::transform(vars, detail::initialize_local<Env>(env))));
+ }
+ */
+ };
+
+ template <typename LambdaExpr, typename Vars, typename Map>
+ struct make_lambda_actor_eval
+ {
+ typedef typename
+ proto::result_of::make_expr<
+ proto::tag::function
+ , default_domain_with_basic_expr
+ , lambda_actor_eval<LambdaExpr, Vars, Map>
+ , env
+ >::type
+ base_type;
+
+ typedef actor<base_type> type;
+ };
+
+ template <typename Vars, typename Map>
+ struct lambda_gen_actor
+ {
+ lambda_gen_actor(Vars const& vars) : vars(vars) {}
+
+ template <typename LambdaExpr>
+ typename make_lambda_actor_eval<LambdaExpr, Vars, Map>::type const
+ operator[](LambdaExpr const& lambda_expr) const
+ {
+ typename make_lambda_actor_eval<LambdaExpr, Vars,Map>::type const e = {{lambda_actor_eval<LambdaExpr, Vars, Map>(lambda_expr, vars), env()}};
+ return e;
+ }
+
+ Vars const & vars;
+ };
+
+ namespace local_names { struct _a_key; struct _b_key; }
+
+ struct lambda_gen
+ : lambda_gen_actor<fusion::vector0<>, detail::map_local_index_to_tuple<> >
+ {
+ typedef lambda_gen_actor<fusion::vector0<>, detail::map_local_index_to_tuple<> > base_type;
+
+ lambda_gen()
+ : base_type( fusion::vector0<>() )
+ {}
+
+ template <typename A0>
+ lambda_gen_actor<
+ fusion::vector1<typename proto::result_of::child_c<A0, 1>::type>
+ , detail::map_local_index_to_tuple<local_names::_a_key>
+ > 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>
+ lambda_gen_actor<
+ 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<local_names::_a_key, local_names::_b_key>
+ > 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)
+ );
+ }
+
+ };
+
+ lambda_gen const lambda = lambda_gen();
+#endif
+}}
+
+#endif

Added: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_actor.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_actor.hpp 2010-07-19 04:23:28 EDT (Mon, 19 Jul 2010)
@@ -0,0 +1,150 @@
+/*==============================================================================
+ Copyright (c) 2005-2010 Joel de Guzman
+ Copyright (c) 2010 Thomas Heller
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#ifndef PHOENIX_SCOPE_LOCAL_ACTOR_HPP
+#define PHOENIX_SCOPE_LOCAL_ACTOR_HPP
+
+#include <boost/phoenix/core/actor.hpp>
+#include <boost/phoenix/support/element_at.hpp>
+
+namespace boost { namespace phoenix
+{
+ namespace result_of
+ {
+ template <typename Expr, typename OuterEnv, typename Locals, typename Map, typename A0 = void, typename A1 = void>
+ struct local_actor;
+
+ template <typename Expr, typename OuterEnv, typename Locals, typename Map, typename A0>
+ struct local_actor<Expr, OuterEnv, Locals, Map, A0>
+ {
+ typedef typename make_basic_environment<A0>::type basic_env;
+ typedef scoped_environment<basic_env, OuterEnv, Locals, Map> args;
+
+ typedef typename boost::result_of<eval_grammar(Expr const&, args&)>::type type;
+ };
+ }
+
+ template <typename Expr>//, typename OuterEnv, typename Locals, typename Map>
+ struct local_actor
+ : actor<Expr>
+ {
+ typedef actor<Expr> base_type;
+
+ local_actor(base_type const& base)//LambdaExpr const& lambda_expr, OuterEnv const& outer_env, Locals const& locals)
+ : base_type(base)
+ //, outer_env(eval(element_at_c<0>(*this)))
+ //, locals(eval(element_at_c<1>(*this)))
+ /*: base_type(lambda_expr)
+ , outer_env(outer_env)
+ , locals(locals)*/
+ {}
+
+ typedef typename boost::result_of<eval_grammar(typename result_of::element_value_at_c<Expr, 0>::type const&)>::type outer_env_type;
+ typedef typename boost::result_of<eval_grammar(typename result_of::element_value_at_c<Expr, 1>::type const&)>::type locals_type;
+ typedef typename boost::result_of<eval_grammar(typename result_of::element_value_at_c<Expr, 2>::type const&)>::type map_type;
+
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename A0>
+ struct result<This(A0)>
+ : result_of::local_actor<Expr, outer_env_type, locals_type, map_type, A0>
+ {};
+ /*
+
+ int
+ operator()() const
+ {
+ typename make_basic_environment<>::type env;
+ scoped_environment<typename make_basic_environment<>::type, outer_env_type, locals_type, map_type> args(env, outer_env, locals);
+
+ return eval(*this, args);
+ }
+
+ template <typename A0>
+ int//typename result_of::local_actor<outer_env_type, locals_type, map_type, A0 const&>::type
+ operator()(A0 const& a0) const
+ {
+ typename make_basic_environment<A0 const&>::type env(a0);
+ scoped_environment<typename make_basic_environment<A0 const&>::type, outer_env_type, locals_type, map_type> args(env, outer_env, locals);
+
+ return eval(*this, args);
+ }
+
+ template <typename A0>
+ typename result_of::local_actor<Expr, outer_env_type, locals_type, map_type, A0&>::type
+ operator()(A0& a0) const
+ {
+ typename make_basic_environment<A0&>::type env(a0);
+ scoped_environment<typename make_basic_environment<A0&>::type, outer_env_type, locals_type, map_type> args(env, outer_env, locals);
+
+ return eval(*this, args);
+ }
+
+ outer_env_type const& outer_env;
+ locals_type const& locals;
+ */
+ };
+
+ template <typename Expr>
+ struct local_eval
+ {
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Env, typename OuterEnv, typename Locals, typename Map>
+ struct result<This(Env&, OuterEnv const&, Locals const&, Map const&)>
+ : boost::result_of<eval_grammar(Expr const&, scoped_environment<Env, OuterEnv, Locals, Map>&)>
+ {};
+
+ local_eval(Expr const& expr) : expr(expr) {}
+
+ template <typename Env, typename OuterEnv, typename Locals, typename Map>
+ typename boost::result_of<eval_grammar(Expr const&, scoped_environment<Env, OuterEnv, Locals, Map>&)>::type
+ operator()(Env& env, OuterEnv const& outer_env, Locals const& locals, Map const&) const
+ {
+ std::cout << typeid(Env).name() << "\n\n";
+ std::cout << typeid(OuterEnv).name() << "\n\n";
+ std::cout << typeid(Locals).name() << "\n\n";
+ std::cout << typeid(Expr).name() << "\n\n";
+ scoped_environment<Env, OuterEnv, Locals, Map> args(env, outer_env, locals);
+ return eval(expr, args);
+ }
+
+ Expr expr;
+ };
+
+ template <typename Expr, typename OuterEnv, typename Locals, typename Map>
+ struct make_local_actor //: compose_ex<local_eval, local_actor, OuterEnv, Locals, Map>
+ {
+ typedef typename
+ proto::result_of::make_expr<
+ proto::tag::function
+ , default_domain_with_basic_expr
+ , local_eval<Expr>//, Map>//lambda_actor_eval<LambdaExpr, Vars, Map>
+ , env
+ , OuterEnv
+ , Locals
+ , Map
+ >::type
+ base_type;
+
+ typedef local_actor<base_type> type;
+ typedef type result_type;
+
+ result_type const
+ operator()(Expr const& expr, OuterEnv const& outer_env, Locals const& locals) const
+ {
+ actor<base_type> const e = {local_eval<Expr>(expr), env(), outer_env, locals, Map()};
+
+ return e;
+ }
+ };
+
+}}
+
+#endif

Added: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/local_variable.hpp 2010-07-19 04:23:28 EDT (Mon, 19 Jul 2010)
@@ -0,0 +1,98 @@
+/*==============================================================================
+ Copyright (c) 2005-2010 Joel de Guzman
+ Copyright (c) 2010 Thomas Heller
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#ifndef PHOENIX_SCOPE_LOCAL_VARIABLE_HPP
+#define PHOENIX_SCOPE_LOCAL_VARIABLE_HPP
+
+#include <boost/phoenix/core/actor.hpp>
+#include <boost/phoenix/scope/detail/local_variable.hpp>
+
+namespace boost { namespace phoenix
+{
+ 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
+ {
+
+ typedef Key key_type;
+
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename Env>
+ struct result<This(Env&)>
+ : result_of::local_variable<Env, Key>
+ {};
+
+ 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<typename Env::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> > {};
+
+ namespace local_names
+ {
+ make_local_variable<struct _a_key>::type const _a = {};
+ make_local_variable<struct _b_key>::type const _b = {};
+ make_local_variable<struct _c_key>::type const _c = {};
+ make_local_variable<struct _d_key>::type const _d = {};
+ make_local_variable<struct _e_key>::type const _e = {};
+ make_local_variable<struct _f_key>::type const _f = {};
+ make_local_variable<struct _g_key>::type const _g = {};
+ make_local_variable<struct _h_key>::type const _h = {};
+ make_local_variable<struct _i_key>::type const _i = {};
+ make_local_variable<struct _j_key>::type const _j = {};
+ make_local_variable<struct _k_key>::type const _k = {};
+ make_local_variable<struct _l_key>::type const _l = {};
+ make_local_variable<struct _m_key>::type const _m = {};
+ make_local_variable<struct _n_key>::type const _n = {};
+ make_local_variable<struct _o_key>::type const _o = {};
+ make_local_variable<struct _p_key>::type const _p = {};
+ make_local_variable<struct _q_key>::type const _q = {};
+ make_local_variable<struct _r_key>::type const _r = {};
+ make_local_variable<struct _s_key>::type const _s = {};
+ make_local_variable<struct _t_key>::type const _t = {};
+ make_local_variable<struct _u_key>::type const _u = {};
+ make_local_variable<struct _v_key>::type const _v = {};
+ make_local_variable<struct _w_key>::type const _w = {};
+ make_local_variable<struct _x_key>::type const _x = {};
+ make_local_variable<struct _y_key>::type const _y = {};
+ make_local_variable<struct _z_key>::type const _z = {};
+ }
+
+
+}}
+
+#endif

Added: sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/phoenix3/boost/phoenix/scope/scoped_environment.hpp 2010-07-19 04:23:28 EDT (Mon, 19 Jul 2010)
@@ -0,0 +1,77 @@
+/*==============================================================================
+ Copyright (c) 2005-2010 Joel de Guzman
+ Copyright (c) 2010 Thomas Heller
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+#ifndef PHOENIX_SCOPE_SCOPED_ENVIRONMENT_HPP
+#define PHOENIX_SCOPE_SCOPED_ENVIRONMENT_HPP
+
+#include <boost/mpl/int.hpp>
+#include <boost/fusion/sequence/intrinsic/at.hpp>
+#include <boost/phoenix/core/environment.hpp>
+
+namespace boost { namespace phoenix
+{
+ template <typename Env, typename OuterEnv, typename Locals, typename Map>
+ struct scoped_environment;
+
+ template <typename Env, typename Dummy = void>
+ struct is_scoped_environment : mpl::false_ {};
+
+ template <typename Env, typename OuterEnv, typename Locals, typename Map>
+ struct is_scoped_environment<scoped_environment<Env, OuterEnv, Locals, Map> >
+ : mpl::true_
+ {};
+
+ template <typename Env, typename OuterEnv, typename Locals, typename Map>
+ struct is_scoped_environment<scoped_environment<Env, OuterEnv, Locals, Map> const>
+ : mpl::true_
+ {};
+
+ // overload result_of::get_environment_argument to return the correct result type
+ namespace result_of
+ {
+ template <typename Env, typename OuterEnv, typename Locals, typename Map, typename N>
+ struct get_environment_argument<scoped_environment<Env, OuterEnv, Locals, Map> const, N>
+ : fusion::result_of::at_c<Env, N::value>
+ {};
+
+ template <typename Env, typename OuterEnv, typename Locals, typename Map, typename N>
+ struct get_environment_argument<scoped_environment<Env, OuterEnv, Locals, Map>, N>
+ : fusion::result_of::at_c<Env, N::value>
+ {};
+ }
+
+ // overload get_environment_argument_c to return the correct argument
+ template <int N, typename Env>
+ typename boost::enable_if<
+ is_scoped_environment<Env>
+ , typename result_of::get_environment_argument<Env, mpl::int_<N> >::type
+ >::type
+ get_environment_argument_c(Env& env)
+ {
+ return fusion::at_c<N>(env.env);
+ }
+
+ template <typename Env, typename OuterEnv, typename Locals, typename Map>
+ struct scoped_environment
+ {
+ typedef OuterEnv outer_env_type;
+ typedef Locals locals_type;
+ typedef Map map_type;
+
+ scoped_environment(Env& env, OuterEnv const& outer_env, Locals const& locals)
+ : env(env)
+ , outer_env(outer_env)
+ , locals(locals) {}
+
+ Env& env;
+ OuterEnv const& outer_env;
+ Locals const& locals;
+ };
+
+}}
+
+#endif

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-07-19 04:23:28 EDT (Mon, 19 Jul 2010)
@@ -72,12 +72,12 @@
     [ run container/container_tests6b.cpp ]
     ;
 
-#test-suite phoenix_scope :
+test-suite phoenix_scope :
 # [ run scope/lambda_tests.cpp ]
 # [ run scope/let_tests.cpp ]
 # [ run scope/dynamic_tests.cpp ]
 # [ run scope/bug_000008.cpp : : : $(multi-threading) ]
-# ;
+ ;
 
 test-suite phoenix_algorithm :
     [ run algorithm/iteration.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-07-19 04:23:28 EDT (Mon, 19 Jul 2010)
@@ -12,17 +12,20 @@
 #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/scope.hpp>
 #include <boost/phoenix/function.hpp>
 
 namespace boost { namespace phoenix
 {
     struct for_each_impl
     {
- template <typename C, typename F>
- struct result
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename C, typename F>
+ struct result<This(C,F)>
         {
             typedef void type;
         };
@@ -38,8 +41,11 @@
 
     struct push_back_impl
     {
- template <typename C, typename T>
- struct result
+ template <typename Sig>
+ struct result;
+
+ template <typename This, typename C, typename T>
+ struct result<This(C,T)>
         {
             typedef void type;
         };
@@ -61,15 +67,22 @@
 
 struct zzz {};
 
+template <typename Expr>
+void blubb(Expr const& expr)
+{
+ std::cout << typeid( typename boost::phoenix::result_of::actor<Expr, boost::fusion::vector1<int&> >::type ).name() << "\n";
+}
+
 int
 main()
 {
+
     {
         int x = 1;
         int y = lambda[_1]()(x);
         BOOST_TEST(x == y);
     }
-
+
     {
         int x = 1, y = 10;
         BOOST_TEST(
@@ -160,6 +173,7 @@
 
     {
         int x = 1, y = 10, z = 13;
+
         BOOST_TEST(
             lambda(_a = _1, _b = _2)
             [
@@ -170,11 +184,12 @@
     }
 
     {
+ /*
         // $$$ Fixme. This should not be failing $$$
         int x = (let(_a = lambda[val(1)])[_a])()();
         //~ BOOST_TEST(x == 1);
+ */
     }
-
     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