comparison DEPENDENCIES/generic/include/boost/phoenix/scope/let.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
1 /*============================================================================== 1 /*==============================================================================
2 Copyright (c) 2001-2010 Joel de Guzman 2 Copyright (c) 2001-2010 Joel de Guzman
3 Copyright (c) 2004 Daniel Wallin 3 Copyright (c) 2004 Daniel Wallin
4 Copyright (c) 2010 Thomas Heller 4 Copyright (c) 2010 Thomas Heller
5 Copyright (c) 2015 John Fletcher
5 6
6 Distributed under the Boost Software License, Version 1.0. (See accompanying 7 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 ==============================================================================*/ 9 ==============================================================================*/
9 #ifndef BOOST_PHOENIX_SCOPE_LET_HPP 10 #ifndef BOOST_PHOENIX_SCOPE_LET_HPP
10 #define BOOST_PHOENIX_SCOPE_LET_HPP 11 #define BOOST_PHOENIX_SCOPE_LET_HPP
11 12
13 //#include <boost/assert.hpp>
14 //#include <sstream>
12 #include <boost/phoenix/core/limits.hpp> 15 #include <boost/phoenix/core/limits.hpp>
13 #include <boost/fusion/include/transform.hpp> 16 #include <boost/fusion/include/transform.hpp>
14 #include <boost/fusion/include/as_vector.hpp> 17 #include <boost/fusion/include/as_vector.hpp>
15 #include <boost/phoenix/core/call.hpp> 18 #include <boost/phoenix/core/call.hpp>
16 #include <boost/phoenix/core/expression.hpp> 19 #include <boost/phoenix/core/expression.hpp>
55 typedef 58 typedef
56 typename proto::detail::uncvref< 59 typename proto::detail::uncvref<
57 typename proto::result_of::value<Map>::type 60 typename proto::result_of::value<Map>::type
58 >::type 61 >::type
59 map_type; 62 map_type;
63
64 typedef
65 typename proto::detail::uncvref<Expr>::type
66 expr_type;
60 67
61 typedef typename 68 typedef typename
62 detail::result_of::initialize_locals< 69 detail::result_of::initialize_locals<
63 vars_type 70 vars_type
64 , Context 71 , Context
65 >::type 72 >::type
66 locals_type; 73 locals_type;
67 74
68 typedef typename 75 typedef typename
69 result_of::eval< 76 result_of::eval<
70 Expr 77 expr_type
71 , typename result_of::context< 78 , typename result_of::context<
72 scoped_environment< 79 scoped_environment<
73 env_type 80 env_type
74 , env_type 81 , env_type
75 , locals_type 82 , locals_type
83 90
84 template <typename Vars, typename Map, typename Expr, typename Context> 91 template <typename Vars, typename Map, typename Expr, typename Context>
85 typename result<let_eval(Vars const&, Map const&, Expr const &, Context const &)>::type const 92 typename result<let_eval(Vars const&, Map const&, Expr const &, Context const &)>::type const
86 operator()(Vars const & vars, Map, Expr const & expr, Context const & ctx) const 93 operator()(Vars const & vars, Map, Expr const & expr, Context const & ctx) const
87 { 94 {
95 Vars vars_(vars);
96
88 typedef 97 typedef
89 typename proto::detail::uncvref< 98 typename proto::detail::uncvref<
90 typename result_of::env<Context>::type 99 typename result_of::env<Context>::type
91 >::type 100 >::type
92 env_type; 101 env_type;
106 vars_type 115 vars_type
107 , Context 116 , Context
108 >::type 117 >::type
109 locals_type; 118 locals_type;
110 119
111 locals_type locals = initialize_locals(proto::value(vars), ctx); 120 locals_type locals = initialize_locals(proto::value(vars_), ctx);
121
122 typedef typename result<let_eval(Vars const&, Map const&, Expr const &, Context const &)>::type result_type;
112 123
113 scoped_environment< 124 scoped_environment<
114 env_type 125 env_type
115 , env_type 126 , env_type
116 , locals_type 127 , locals_type
117 , map_type 128 , map_type
118 > 129 >
119 env(phoenix::env(ctx), phoenix::env(ctx), locals); 130 env(phoenix::env(ctx), phoenix::env(ctx), locals);
120 131
121 return eval(expr, phoenix::context(env, phoenix::actions(ctx))); 132 // Fix for bugs (trial)
133 // The idea is to do something which will not be optimised away.
134 //int vsize = boost::fusion::size(vars);
135 //std::stringstream strm;
136 //strm << vsize << std::endl;
137 //int size = strm.str().length();
138 //BOOST_ASSERT(size >= 0);
139 result_type r = eval(expr, phoenix::context(env, phoenix::actions(ctx)));
140 // typedef is_value<result_type> is_val;
141 //if(is_val::value) This seems always to be true
142 //{
143 // std::cout << "let result has value type" << std::endl;
144 // }
145 //if (is_val(r) ) std::cout << "let returns val" << std::endl;
146 //std::cout << "result is " << r << std::endl;
147 return r;
122 } 148 }
123 }; 149 };
124 150
125 template <typename Dummy> 151 template <typename Dummy>
126 struct default_actions::when<rule::let_, Dummy> 152 struct default_actions::when<rule::let_, Dummy>
128 {}; 154 {};
129 155
130 template <typename Locals, typename Map> 156 template <typename Locals, typename Map>
131 struct let_actor_gen 157 struct let_actor_gen
132 { 158 {
133 let_actor_gen(Locals const & locals) 159 let_actor_gen(Locals const & locals_)
134 : locals(locals) 160 : locals(locals_)
135 {} 161 {}
136 162
137 let_actor_gen(let_actor_gen const & o) 163 let_actor_gen(let_actor_gen const & o)
138 : locals(o.locals) 164 : locals(o.locals)
139 {} 165 {}
144 , Map 170 , Map
145 , Expr 171 , Expr
146 >::type const 172 >::type const
147 operator[](Expr const & expr) const 173 operator[](Expr const & expr) const
148 { 174 {
149 return expression::let_<Locals, Map, Expr>::make(locals, Map(), expr); 175 typedef typename expression::let_<
176 Locals
177 , Map
178 , Expr
179 >::type let_type;
180 //typedef is_value<let_type> is_val;
181
182 let_type let_exp = expression::let_<Locals, Map, Expr>::make(locals, Map(), expr);
183 //if(is_val::value) //This seems always to be true
184 //{
185 // std::cout << "let has value type" << std::endl;
186 //}
187 return let_exp;
150 } 188 }
151 189
152 Locals locals; 190 Locals locals;
153 }; 191 };
154 192