Exemplo n.º 1
0
  utree eval (utree& ut) const {
    phxpr::shared_ptr<runtime_environment> eptr
      = ut.get<runtime_environment*>()->checkout();

    if (!eptr) {
      BOOST_THROW_EXCEPTION
        (invalid_placeholder(n, frame, eptr, arity_type::fixed));
    }

    while (frame != eptr->level()) {
      if (!eptr->outer()) {
        BOOST_THROW_EXCEPTION
          (invalid_placeholder(n, frame, eptr, arity_type::fixed));
      }

      eptr = eptr->outer();
    } 

    if (eptr->size() <= n) {
      BOOST_THROW_EXCEPTION
        (invalid_placeholder(n, frame, eptr, arity_type::fixed));
    }

    return utree((*eptr)[n]);
  }
Exemplo n.º 2
0
  utree eval (utree& ut) const {
    phxpr::shared_ptr<runtime_environment> eptr
      = ut.get<runtime_environment*>()->checkout();

    if (!eptr) {
      BOOST_THROW_EXCEPTION
        (invalid_local_assignment(n, frame, eptr, arity_type::fixed));
    }

    while (frame != eptr->level()) {
      if (!eptr->outer()) {
        BOOST_THROW_EXCEPTION
          (invalid_local_assignment(n, frame, eptr, arity_type::fixed));
      }

      eptr = eptr->outer();
    } 

    if (eptr->size() <= n) {
      BOOST_THROW_EXCEPTION
        (invalid_local_assignment(n, frame, eptr, arity_type::fixed));
    }

    (*eptr)[n] = eptr->invoke(value);

    // assignment returns unspecified
    return utree(); 
  }
Exemplo n.º 3
0
 utree eval(scope const& env) const
 {
     scope const* eptr = &env;
     utree const& arg = (*eptr)[n];
     if (arg.which() != utree_type::function_type)
         return utree(boost::ref(arg));
     else
         return arg.eval(*eptr);
 }
Exemplo n.º 4
0
        utree eval(scope const& env) const
        {
            scope const* eptr = &env;
            while (level != eptr->level())
                eptr = eptr->outer();

            utree const& arg = (*eptr)[n];
            if (arg.which() != utree_type::function_type)
                return utree(boost::ref(arg));
            else
                return arg.eval(*eptr);
        }
Exemplo n.º 5
0
 utree eval(scope const& env) const
 {
     scope const* eptr = &env;
     utree result;
     for (std::size_t i = n; i < eptr->size(); ++i)
     {
         utree const& arg = (*eptr)[i];
         if (arg.which() != utree_type::function_type)
             result.push_back(utree(boost::ref(arg)));
         else
             result.push_back(arg.eval(*eptr));
     }
     return result;
 }
Exemplo n.º 6
0
 function operator()(T const& val) const
 {
     return scheme::val(utree(val));
 }
Exemplo n.º 7
0
 utree dispatch(A const&, boost::mpl::false_) const
 {
     return utree(); // cannot apply to non-integral types
 }
Exemplo n.º 8
0
 utree dispatch(A const&, boost::mpl::false_) const
 {
     return utree(); // cannot apply to non-arithmetic types
 }
Exemplo n.º 9
0
 static function as_function(T const& val)
 {
     return scheme::val(utree(val));
 }
Exemplo n.º 10
0
 utree eval(scope const& /*env*/) const
 {
     return utree(boost::ref(val));
 }
Exemplo n.º 11
0
 utree eval (utree const& subject) const { 
   if (!predicate(subject))
     BOOST_THROW_EXCEPTION(assertion_failed());
   return utree();
 } 
Exemplo n.º 12
0
 utree dispatch(A&, boost::mpl::false_) const
 {
     // $$$ Throw exception here? $$$
     return utree(); // cannot apply to non-integral types
 }
Exemplo n.º 13
0
 utree operator()(A const& a) const
 {
     // $$$ Throw exception here? $$$
     return utree(); // cannot apply to non booleans
 }