Exemplo n.º 1
0
 Bound_Function(const Const_Proxy_Function &t_f, 
     const std::vector<Boxed_Value> &t_args)
   : Proxy_Function_Base(build_param_type_info(t_f, t_args)),
     m_f(t_f), m_args(t_args), m_arity(t_f->get_arity()<0?-1:static_cast<int>(get_param_types().size())-1)
 {
   assert(m_f->get_arity() < 0 || m_f->get_arity() == static_cast<int>(m_args.size()));
 }
Exemplo n.º 2
0
 inline ndt::type resolve(const ndt::type *src_tp) const
 {
   if (resolve_dst_type != NULL) {
     ndt::type result;
     resolve_dst_type(this, result, src_tp, true);
     return result;
   } else {
     intptr_t param_count = get_param_count();
     const ndt::type *param_types = get_param_types();
     std::map<nd::string, ndt::type> typevars;
     for (intptr_t i = 0; i != param_count; ++i) {
       if (!ndt::pattern_match(src_tp[i].value_type(), param_types[i],
                                    typevars)) {
         std::stringstream ss;
         ss << "parameter " << (i + 1) << " to arrfunc does not match, ";
         ss << "expected " << param_types[i] << ", received " << src_tp[i];
         throw std::invalid_argument(ss.str());
       }
     }
     // TODO:
     // return ndt::substitute_type_vars(get_return_type(), typevars);
     return get_return_type();
   }
 }
Exemplo n.º 3
0
 inline const ndt::type &get_param_type(intptr_t i) const
 {
   return get_param_types()[i];
 }