Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-05-31 14:51:54


Author: eric_niebler
Date: 2008-05-31 14:51:54 EDT (Sat, 31 May 2008)
New Revision: 45981
URL: http://svn.boost.org/trac/boost/changeset/45981

Log:
fix a bug in lambda
Text files modified:
   branches/proto/v4/boost/phoenix/scope/lambda.hpp | 8 +++++
   branches/proto/v4/boost/phoenix/scope/let.hpp | 52 +++++++++++++++++++--------------------
   branches/proto/v4/boost/phoenix/scope/local_variable.hpp | 33 ++++++++----------------
   3 files changed, 43 insertions(+), 50 deletions(-)

Modified: branches/proto/v4/boost/phoenix/scope/lambda.hpp
==============================================================================
--- branches/proto/v4/boost/phoenix/scope/lambda.hpp (original)
+++ branches/proto/v4/boost/phoenix/scope/lambda.hpp 2008-05-31 14:51:54 EDT (Sat, 31 May 2008)
@@ -63,7 +63,7 @@
             struct LocalVariable
               : proto::when<
                     proto::terminal<local_variable<proto::_> >
- , proto::lazy<local_variable_evaluator<local_variable_tag<proto::_value> > >
+ , local_variable_evaluator
>
             {};
 
@@ -120,6 +120,12 @@
         {};
 
         ////////////////////////////////////////////////////////////////////////////////////////////
+ template<typename SubGrammar>
+ struct is_nullary_extension<tag::lambda_, SubGrammar>
+ : proto::_
+ {};
+
+ ////////////////////////////////////////////////////////////////////////////////////////////
         detail::lambda_placeholder const lambda = {};
     }}
 

Modified: branches/proto/v4/boost/phoenix/scope/let.hpp
==============================================================================
--- branches/proto/v4/boost/phoenix/scope/let.hpp (original)
+++ branches/proto/v4/boost/phoenix/scope/let.hpp 2008-05-31 14:51:54 EDT (Sat, 31 May 2008)
@@ -88,14 +88,12 @@
> const
                 operator()(fusion::pair<First, Second> const &p) const
                 {
- typedef
- fusion::pair<
- First
- , typename boost::result_of<evaluator<SubGrammar>(Second const &, State, Data)>::type
- >
- pair_type;
- pair_type that(evaluator<SubGrammar>()(p.second, this->state, this->data));
- return that;
+ return fusion::pair<
+ First
+ , typename boost::result_of<evaluator<SubGrammar>(Second const &, State, Data)>::type
+ >(
+ evaluator<SubGrammar>()(p.second, this->state, this->data)
+ );
                 }
 
             private:
@@ -123,11 +121,6 @@
                   , data(data)
                   , locals(fusion::as_map(fusion::transform(map, initialize_locals<State, Data, SubGrammar>(state, data))))
                 {}
-
- friend std::ostream &operator<<(std::ostream &sout, scope const &)
- {
- return sout << typeid(scope).name();
- }
 
                 State state; // outer state
                 Data data; // outer data
@@ -158,6 +151,23 @@
             };
 
             ////////////////////////////////////////////////////////////////////////////////////////
+ template<typename Map, typename Callable = proto::callable>
+ struct is_local_variable : proto::transform<is_local_variable<Map> >
+ {
+ template<typename Expr, typename, typename>
+ struct impl
+ {
+ typedef mpl::false_ result_type;
+ };
+
+ template<typename Tag, typename State, typename Data>
+ struct impl<proto::expr<proto::tag::terminal, proto::term<local_variable<Tag> > >, State, Data>
+ {
+ typedef typename fusion::result_of::has_key<Map, Tag>::type result_type;
+ };
+ };
+
+ ////////////////////////////////////////////////////////////////////////////////////////
             template<typename SubGrammar>
             struct with_grammar
             {
@@ -174,21 +184,9 @@
                                 // If the current expression is a local variable declared in
                                 // a let() call ...
                                 proto::when<
- proto::and_<
- proto::terminal<detail::local_variable<proto::_> >
- , proto::if_<
- fusion::result_of::has_key<
- Map
- , detail::local_variable_tag<proto::_value>
- >()
- >
- >
+ proto::if_<is_local_variable<Map> >
                                     // ... evaluate it using the local variable evaluator
- , proto::lazy<
- detail::local_variable_evaluator<
- detail::local_variable_tag<proto::_value>
- >
- >
+ , local_variable_evaluator
>
                                 // Otherwise, defer handling of the current expression to the
                                 // currently active sub-grammar. This will also handle local

Modified: branches/proto/v4/boost/phoenix/scope/local_variable.hpp
==============================================================================
--- branches/proto/v4/boost/phoenix/scope/local_variable.hpp (original)
+++ branches/proto/v4/boost/phoenix/scope/local_variable.hpp 2008-05-31 14:51:54 EDT (Sat, 31 May 2008)
@@ -22,18 +22,6 @@
         struct local_variable
         {
             typedef Tag tag_type;
-
- friend std::ostream &operator<<(std::ostream &sout, local_variable const &)
- {
- return sout << typeid(local_variable).name();
- }
- };
-
- ////////////////////////////////////////////////////////////////////////////////////////////
- template<typename Local>
- struct local_variable_tag
- {
- typedef typename Local::tag_type type;
         };
 
         ////////////////////////////////////////////////////////////////////////////////////////////
@@ -45,8 +33,8 @@
>
         struct find_local
         {
- typedef typename
- fusion::result_of::at_key<typename State::locals_type, Tag>::type
+ typedef
+ typename fusion::result_of::at_key<typename State::locals_type, Tag>::type
             result_type;
 
             result_type operator()(State &state) const
@@ -60,8 +48,8 @@
         template<typename Tag, typename State>
         struct find_local<Tag, State, false>
         {
- typedef typename
- find_local<Tag, typename State::state_type>::result_type
+ typedef
+ typename find_local<Tag, typename State::state_type>::result_type
             result_type;
 
             result_type operator()(State &state) const
@@ -71,25 +59,26 @@
         };
 
         ////////////////////////////////////////////////////////////////////////////////////////////
- template<typename Tag, typename Callable = proto::callable>
         struct local_variable_evaluator
- : proto::transform<local_variable_evaluator<Tag> >
+ : proto::transform<local_variable_evaluator>
         {
             template<typename Expr, typename State, typename Data>
             struct impl
               : proto::transform_impl<Expr, State, Data>
             {
+ typedef typename impl::expr expr;
+ typedef typename expr::proto_child0::tag_type tag_type;
                 typedef
- typename find_local<Tag, typename impl::state>::result_type
+ typename find_local<tag_type, typename impl::state>::result_type
                 result_type;
 
                 result_type operator()(
- typename impl::expr_param expr
+ typename impl::expr_param
                   , typename impl::state_param state
- , typename impl::data_param data
+ , typename impl::data_param
                 ) const
                 {
- return find_local<Tag, typename impl::state>()(state);
+ return find_local<tag_type, typename impl::state>()(state);
                 }
             };
         };


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