File indexing completed on 2025-01-18 09:46:33
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_PHOENIX_SCOPE_LOCAL_VARIABLE_HPP
0009 #define BOOST_PHOENIX_SCOPE_LOCAL_VARIABLE_HPP
0010
0011 #include <boost/phoenix/core/limits.hpp>
0012 #include <boost/phoenix/core/call.hpp>
0013 #include <boost/phoenix/core/expression.hpp>
0014 #include <boost/phoenix/core/reference.hpp>
0015 #include <boost/phoenix/core/value.hpp>
0016 #include <boost/phoenix/scope/scoped_environment.hpp>
0017 #include <boost/phoenix/scope/detail/local_variable.hpp>
0018 #include <boost/phoenix/statement/sequence.hpp>
0019
0020 namespace boost { namespace phoenix
0021 {
0022 namespace expression
0023 {
0024 template <typename Key>
0025 struct local_variable
0026 : expression::terminal<detail::local<Key> >
0027 {
0028 typedef typename expression::terminal<detail::local<Key> >::type type;
0029
0030 static type make()
0031 {
0032 type const e = {};
0033 return e;
0034 }
0035 };
0036 }
0037
0038 namespace rule
0039 {
0040 struct local_variable
0041 : expression::local_variable<proto::_>
0042 {};
0043
0044 struct local_var_def
0045 : proto::assign<local_variable, meta_grammar>
0046 {};
0047 }
0048
0049 namespace result_of
0050 {
0051 template <typename Key>
0052 struct is_nullary<custom_terminal<detail::local<Key> > >
0053 : mpl::false_
0054 {};
0055 }
0056
0057 namespace detail
0058 {
0059 struct scope_is_nullary_actions
0060 {
0061 template <typename Rule, typename Dummy = void>
0062 struct when
0063 : boost::phoenix::is_nullary::when<Rule, Dummy>
0064 {};
0065 };
0066
0067 template <typename Dummy>
0068 struct scope_is_nullary_actions::when<boost::phoenix::rule::custom_terminal, Dummy>
0069 : proto::or_<
0070 proto::when<boost::phoenix::rule::local_variable, mpl::true_()>
0071 , proto::otherwise<
0072 is_nullary::when<boost::phoenix::rule::custom_terminal, Dummy>
0073 >
0074 >
0075 {};
0076
0077 struct local_var_not_found
0078 {
0079 };
0080 }
0081
0082 template<typename Key>
0083 struct is_custom_terminal<detail::local<Key> >
0084 : mpl::true_
0085 {};
0086
0087 template <typename Key>
0088 struct custom_terminal<detail::local<Key> >
0089 {
0090 template <typename Sig>
0091 struct result;
0092
0093 template <typename This, typename Local, typename Context>
0094 struct result<This(Local, Context)>
0095 : result<This(Local const &, Context)>
0096 {};
0097
0098 template <typename This, typename Local, typename Context>
0099 struct result<This(Local &, Context)>
0100 {
0101 typedef
0102 typename remove_reference<
0103 typename result_of::env<Context>::type
0104 >::type
0105 env_type;
0106
0107 typedef typename detail::apply_local<detail::local<Key>, env_type>::type type;
0108 };
0109
0110 template <typename Local, typename Context>
0111 typename result<custom_terminal(Local const &, Context const&)>::type
0112 operator()(Local, Context const & ctx)
0113 {
0114 typedef
0115 typename remove_reference<
0116 typename result_of::env<Context>::type
0117 >::type
0118 env_type;
0119
0120 typedef typename detail::apply_local<detail::local<Key>, env_type>::type return_type;
0121
0122 static const int index_value = detail::get_index<typename env_type::map_type, detail::local<Key> >::value;
0123
0124 typedef detail::eval_local<Key> eval_local;
0125
0126
0127
0128
0129 return eval_local::template get<return_type, index_value>(
0130 phoenix::env(ctx));
0131 }
0132 };
0133
0134 namespace local_names
0135 {
0136 typedef expression::local_variable<struct _a_key>::type _a_type;
0137 typedef expression::local_variable<struct _b_key>::type _b_type;
0138 typedef expression::local_variable<struct _c_key>::type _c_type;
0139 typedef expression::local_variable<struct _d_key>::type _d_type;
0140 typedef expression::local_variable<struct _e_key>::type _e_type;
0141 typedef expression::local_variable<struct _f_key>::type _f_type;
0142 typedef expression::local_variable<struct _g_key>::type _g_type;
0143 typedef expression::local_variable<struct _h_key>::type _h_type;
0144 typedef expression::local_variable<struct _i_key>::type _i_type;
0145 typedef expression::local_variable<struct _j_key>::type _j_type;
0146 typedef expression::local_variable<struct _k_key>::type _k_type;
0147 typedef expression::local_variable<struct _l_key>::type _l_type;
0148 typedef expression::local_variable<struct _m_key>::type _m_type;
0149 typedef expression::local_variable<struct _n_key>::type _n_type;
0150 typedef expression::local_variable<struct _o_key>::type _o_type;
0151 typedef expression::local_variable<struct _p_key>::type _p_type;
0152 typedef expression::local_variable<struct _q_key>::type _q_type;
0153 typedef expression::local_variable<struct _r_key>::type _r_type;
0154 typedef expression::local_variable<struct _s_key>::type _s_type;
0155 typedef expression::local_variable<struct _t_key>::type _t_type;
0156 typedef expression::local_variable<struct _u_key>::type _u_type;
0157 typedef expression::local_variable<struct _v_key>::type _v_type;
0158 typedef expression::local_variable<struct _w_key>::type _w_type;
0159 typedef expression::local_variable<struct _x_key>::type _x_type;
0160 typedef expression::local_variable<struct _y_key>::type _y_type;
0161 typedef expression::local_variable<struct _z_key>::type _z_type;
0162
0163 #ifndef BOOST_PHOENIX_NO_PREDEFINED_TERMINALS
0164 BOOST_ATTRIBUTE_UNUSED _a_type const _a = {{{}}};
0165 BOOST_ATTRIBUTE_UNUSED _b_type const _b = {{{}}};
0166 BOOST_ATTRIBUTE_UNUSED _c_type const _c = {{{}}};
0167 BOOST_ATTRIBUTE_UNUSED _d_type const _d = {{{}}};
0168 BOOST_ATTRIBUTE_UNUSED _e_type const _e = {{{}}};
0169 BOOST_ATTRIBUTE_UNUSED _f_type const _f = {{{}}};
0170 BOOST_ATTRIBUTE_UNUSED _g_type const _g = {{{}}};
0171 BOOST_ATTRIBUTE_UNUSED _h_type const _h = {{{}}};
0172 BOOST_ATTRIBUTE_UNUSED _i_type const _i = {{{}}};
0173 BOOST_ATTRIBUTE_UNUSED _j_type const _j = {{{}}};
0174 BOOST_ATTRIBUTE_UNUSED _k_type const _k = {{{}}};
0175 BOOST_ATTRIBUTE_UNUSED _l_type const _l = {{{}}};
0176 BOOST_ATTRIBUTE_UNUSED _m_type const _m = {{{}}};
0177 BOOST_ATTRIBUTE_UNUSED _n_type const _n = {{{}}};
0178 BOOST_ATTRIBUTE_UNUSED _o_type const _o = {{{}}};
0179 BOOST_ATTRIBUTE_UNUSED _p_type const _p = {{{}}};
0180 BOOST_ATTRIBUTE_UNUSED _q_type const _q = {{{}}};
0181 BOOST_ATTRIBUTE_UNUSED _r_type const _r = {{{}}};
0182 BOOST_ATTRIBUTE_UNUSED _s_type const _s = {{{}}};
0183 BOOST_ATTRIBUTE_UNUSED _t_type const _t = {{{}}};
0184 BOOST_ATTRIBUTE_UNUSED _u_type const _u = {{{}}};
0185 BOOST_ATTRIBUTE_UNUSED _v_type const _v = {{{}}};
0186 BOOST_ATTRIBUTE_UNUSED _w_type const _w = {{{}}};
0187 BOOST_ATTRIBUTE_UNUSED _x_type const _x = {{{}}};
0188 BOOST_ATTRIBUTE_UNUSED _y_type const _y = {{{}}};
0189 BOOST_ATTRIBUTE_UNUSED _z_type const _z = {{{}}};
0190 #endif
0191 }
0192 }}
0193
0194 #endif