annotate DEPENDENCIES/generic/include/boost/phoenix/scope/let.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
rev   line source
Chris@16 1 /*==============================================================================
Chris@16 2 Copyright (c) 2001-2010 Joel de Guzman
Chris@16 3 Copyright (c) 2004 Daniel Wallin
Chris@16 4 Copyright (c) 2010 Thomas Heller
Chris@16 5
Chris@16 6 Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8 ==============================================================================*/
Chris@16 9 #ifndef BOOST_PHOENIX_SCOPE_LET_HPP
Chris@16 10 #define BOOST_PHOENIX_SCOPE_LET_HPP
Chris@16 11
Chris@16 12 #include <boost/phoenix/core/limits.hpp>
Chris@16 13 #include <boost/fusion/include/transform.hpp>
Chris@16 14 #include <boost/fusion/include/as_vector.hpp>
Chris@16 15 #include <boost/phoenix/core/call.hpp>
Chris@16 16 #include <boost/phoenix/core/expression.hpp>
Chris@16 17 #include <boost/phoenix/core/meta_grammar.hpp>
Chris@16 18 #include <boost/phoenix/scope/scoped_environment.hpp>
Chris@16 19 #include <boost/phoenix/scope/local_variable.hpp>
Chris@16 20 #include <boost/phoenix/support/iterate.hpp>
Chris@16 21 #include <boost/phoenix/support/vector.hpp>
Chris@16 22
Chris@16 23 BOOST_PHOENIX_DEFINE_EXPRESSION(
Chris@16 24 (boost)(phoenix)(let_)
Chris@16 25 , (proto::terminal<proto::_>) // Locals
Chris@16 26 (proto::terminal<proto::_>) // Map
Chris@16 27 (meta_grammar)
Chris@16 28 )
Chris@16 29
Chris@16 30 namespace boost { namespace phoenix
Chris@16 31 {
Chris@16 32 struct let_eval
Chris@16 33 {
Chris@16 34 template <typename Sig>
Chris@16 35 struct result;
Chris@16 36
Chris@16 37 template <typename This, typename Vars, typename Map, typename Expr, typename Context>
Chris@16 38 struct result<This(Vars, Map, Expr, Context)>
Chris@16 39 {
Chris@16 40 typedef
Chris@16 41 typename proto::detail::uncvref<
Chris@16 42 typename result_of::env<Context>::type
Chris@16 43 >::type
Chris@16 44 env_type;
Chris@16 45 typedef
Chris@16 46 typename proto::detail::uncvref<
Chris@16 47 typename result_of::actions<Context>::type
Chris@16 48 >::type
Chris@16 49 actions_type;
Chris@16 50 typedef
Chris@16 51 typename proto::detail::uncvref<
Chris@16 52 typename proto::result_of::value<Vars>::type
Chris@16 53 >::type
Chris@16 54 vars_type;
Chris@16 55 typedef
Chris@16 56 typename proto::detail::uncvref<
Chris@16 57 typename proto::result_of::value<Map>::type
Chris@16 58 >::type
Chris@16 59 map_type;
Chris@16 60
Chris@16 61 typedef typename
Chris@16 62 detail::result_of::initialize_locals<
Chris@16 63 vars_type
Chris@16 64 , Context
Chris@16 65 >::type
Chris@16 66 locals_type;
Chris@16 67
Chris@16 68 typedef typename
Chris@16 69 result_of::eval<
Chris@16 70 Expr
Chris@16 71 , typename result_of::context<
Chris@16 72 scoped_environment<
Chris@16 73 env_type
Chris@16 74 , env_type
Chris@16 75 , locals_type
Chris@16 76 , map_type
Chris@16 77 >
Chris@16 78 , actions_type
Chris@16 79 >::type
Chris@16 80 >::type
Chris@16 81 type;
Chris@16 82 };
Chris@16 83
Chris@16 84 template <typename Vars, typename Map, typename Expr, typename Context>
Chris@16 85 typename result<let_eval(Vars const&, Map const&, Expr const &, Context const &)>::type const
Chris@16 86 operator()(Vars const & vars, Map, Expr const & expr, Context const & ctx) const
Chris@16 87 {
Chris@16 88 typedef
Chris@16 89 typename proto::detail::uncvref<
Chris@16 90 typename result_of::env<Context>::type
Chris@16 91 >::type
Chris@16 92 env_type;
Chris@16 93 typedef
Chris@16 94 typename proto::detail::uncvref<
Chris@16 95 typename proto::result_of::value<Vars>::type
Chris@16 96 >::type
Chris@16 97 vars_type;
Chris@16 98 typedef
Chris@16 99 typename proto::detail::uncvref<
Chris@16 100 typename proto::result_of::value<Map>::type
Chris@16 101 >::type
Chris@16 102 map_type;
Chris@16 103
Chris@16 104 typedef typename
Chris@16 105 detail::result_of::initialize_locals<
Chris@16 106 vars_type
Chris@16 107 , Context
Chris@16 108 >::type
Chris@16 109 locals_type;
Chris@16 110
Chris@16 111 locals_type locals = initialize_locals(proto::value(vars), ctx);
Chris@16 112
Chris@16 113 scoped_environment<
Chris@16 114 env_type
Chris@16 115 , env_type
Chris@16 116 , locals_type
Chris@16 117 , map_type
Chris@16 118 >
Chris@16 119 env(phoenix::env(ctx), phoenix::env(ctx), locals);
Chris@16 120
Chris@16 121 return eval(expr, phoenix::context(env, phoenix::actions(ctx)));
Chris@16 122 }
Chris@16 123 };
Chris@16 124
Chris@16 125 template <typename Dummy>
Chris@16 126 struct default_actions::when<rule::let_, Dummy>
Chris@16 127 : call<let_eval, Dummy>
Chris@16 128 {};
Chris@16 129
Chris@16 130 template <typename Locals, typename Map>
Chris@16 131 struct let_actor_gen
Chris@16 132 {
Chris@16 133 let_actor_gen(Locals const & locals)
Chris@16 134 : locals(locals)
Chris@16 135 {}
Chris@16 136
Chris@16 137 let_actor_gen(let_actor_gen const & o)
Chris@16 138 : locals(o.locals)
Chris@16 139 {}
Chris@16 140
Chris@16 141 template <typename Expr>
Chris@16 142 typename expression::let_<
Chris@16 143 Locals
Chris@16 144 , Map
Chris@16 145 , Expr
Chris@16 146 >::type const
Chris@16 147 operator[](Expr const & expr) const
Chris@16 148 {
Chris@16 149 return expression::let_<Locals, Map, Expr>::make(locals, Map(), expr);
Chris@16 150 }
Chris@16 151
Chris@16 152 Locals locals;
Chris@16 153 };
Chris@16 154
Chris@16 155 #define BOOST_PHOENIX_SCOPE_ACTOR_GEN_NAME let_actor_gen
Chris@16 156 #define BOOST_PHOENIX_SCOPE_ACTOR_GEN_FUNCTION let
Chris@16 157 #define BOOST_PHOENIX_SCOPE_ACTOR_GEN_CONST
Chris@16 158 #include <boost/phoenix/scope/detail/local_gen.hpp>
Chris@16 159 #undef BOOST_PHOENIX_SCOPE_ACTOR_GEN_NAME
Chris@16 160 #undef BOOST_PHOENIX_SCOPE_ACTOR_GEN_FUNCTION
Chris@16 161 #undef BOOST_PHOENIX_SCOPE_ACTOR_GEN_CONST
Chris@16 162
Chris@16 163 template <typename Dummy>
Chris@16 164 struct is_nullary::when<rule::let_, Dummy>
Chris@16 165 : proto::make<
Chris@16 166 mpl::and_<
Chris@16 167 proto::fold<
Chris@16 168 proto::call<proto::_value(proto::_child_c<0>)>
Chris@16 169 , proto::make<mpl::true_()>
Chris@16 170 , proto::make<
Chris@16 171 mpl::and_<
Chris@16 172 proto::_state
Chris@16 173 , proto::call<
Chris@16 174 evaluator(
Chris@16 175 proto::_
Chris@16 176 , _context
Chris@16 177 , proto::make<proto::empty_env()>
Chris@16 178 )
Chris@16 179 >
Chris@16 180 >()
Chris@16 181 >
Chris@16 182 >
Chris@16 183 , evaluator(
Chris@16 184 proto::_child_c<2>
Chris@16 185 , proto::call<
Chris@16 186 functional::context(
Chris@16 187 proto::make<
Chris@16 188 mpl::true_()
Chris@16 189 >
Chris@16 190 , proto::make<
Chris@16 191 detail::scope_is_nullary_actions()
Chris@16 192 >
Chris@16 193 )
Chris@16 194 >
Chris@16 195 , proto::make<
Chris@16 196 proto::empty_env()
Chris@16 197 >
Chris@16 198 )
Chris@16 199 >()
Chris@16 200 >
Chris@16 201 {};
Chris@16 202 }}
Chris@16 203
Chris@16 204 #endif