Exemplo n.º 1
0
// Parse a template argument list.
//
//    template-argument-list:
//      template-argument
//      template-argument-list ',' template-argument
//
// FIXME: Implement me.
Term_list
Parser::template_argument_list()
{
  Term_list args;
  do {
    Term& arg = template_argument();
    args.push_back(arg);
  } while(lookahead() == comma_tok);
  return args;
}
Exemplo n.º 2
0
// 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;
}
Exemplo n.º 3
0
// Initialize the substitution with a mapping from each
// `pi` in `p` to its corresponding `ai` in `a`.
inline
Substitution::Substitution(Decl_list& p, Term_list& a)
{
  auto pi = p.begin();
  auto ai = a.begin();
  while (pi != p.end()) {
    send(*pi, *ai);
    ++pi;
    ++ai;
  }
}
Exemplo n.º 4
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;
}