예제 #1
0
// Perform qualified lookup to resolve the declaration referred to by obj.n.
Expr&
make_member_reference(Context& cxt, Expr& obj, Simple_id& name)
{
  Type& type = obj.type();
  Decl_list decls = qualified_lookup(cxt, type, name);
  if (decls.size() == 1)
    return make_member_reference(cxt, obj, decls.front());
  lingo_unreachable();
}
예제 #2
0
파일: expr-id.cpp 프로젝트: NoraAl/banjo
// Perform unqualified lookup.
//
// TODO: Allow an lookup to fail, indicating that we could not find
// a name. In function calls, this could be used to perform class
// lookup for member functions.
Expr&
make_reference(Context& cxt, Simple_id& id)
{
  Decl_list decls = unqualified_lookup(cxt, id);
  if (decls.size() == 1)
    return make_decl_ref(cxt, decls.front());
  else
    return make_ovl_ref(cxt, id, std::move(decls));
}
예제 #3
0
// Perform unqualified lookup.
Expr&
make_reference(Context& cxt, Simple_id& id)
{
  Decl_list decls = unqualified_lookup(cxt, id);
  if (decls.size() == 1)
    return make_reference(cxt, decls.front());

  // TODO: Return a reference to an overload set.
  banjo_unhandled_case(id);
}
예제 #4
0
파일: expr-id.cpp 프로젝트: NoraAl/banjo
// Perform qualified lookup to resolve the declaration referred to by obj.n.
//
// TODO: Allow class lookup to find 
static Expr&
make_member_ref(Context& cxt, Expr& obj, Simple_id& name)
{
  Type& type = obj.type();
  Decl_list decls = qualified_lookup(cxt, type, name);
  if (decls.size() == 1)
    return make_member_decl_ref(cxt, obj, decls.front());
  else
    return make_member_ovl_ref(cxt, obj, name, std::move(decls));
}
예제 #5
0
파일: template.cpp 프로젝트: NoraAl/banjo
// Synthesize a list of template arguments from a list of
// template parameter list.
Term_list
synthesize_template_arguments(Context& cxt, Decl_list& parms)
{
  Term_list args;
  args.reserve(parms.size());
  for (Decl& p : parms) {
    Term& arg = synthesize_template_argument(cxt, p);
    args.push_back(arg);
  }
  return args;
}
예제 #6
0
파일: expr-id.cpp 프로젝트: asutton/banjo
// Perform qualified lookup to resolve the declaration referred to by obj.n.
//
// FIXME: This needs to perform class lookup, not qualified lookup.
static Expr&
make_member_ref(Context& cxt, Expr& obj, Simple_id& name)
{
  Type& type = obj.type();
  Decl_list decls = qualified_lookup(cxt, type, name);
  if (decls.empty()) {
    error(cxt, "no matching declaration for '{}'", name);
    throw Lookup_error();
  }
  if (decls.size() == 1)
    return make_resolved_mem_ref(cxt, obj, decls.front());
  else
    return make_mem_overload_ref(cxt, obj, name, std::move(decls));
}
예제 #7
0
// Return a list of converted template arguments.
Term_list
initialize_template_parameters(Context& cxt, Decl_list& parms, Term_list& args)
{
  // TODO: Handle default arguments here.
  if (args.size() < parms.size())
    throw std::runtime_error("too few template arguments");

  // Build a list of converted template arguments by initializing
  // each parameter in turn.
  Term_list ret;
  Decl_iter p0 = parms.begin(), pi = p0, pn = parms.end();
  Term_iter a0 = args.begin(), ai = a0, an = args.end();
  while (pi != pn && ai != an) {
    Term& e = initialize_template_parameter(cxt, p0, pi, a0, ai);

    // TODO: If pi is a pack, then we want to merge e into
    // a single pack argument so that so that the number of
    // parameters and arguments conform.
    ret.push_back(e);
  }

  return ret;
}