예제 #1
0
파일: template.cpp 프로젝트: NoraAl/banjo
Decl&
specialize_function(Context& cxt, Template_decl& tmp, Function_decl& d, Substitution& sub)
{
#if 0
  // Create the specialization name.
  Name& n = cxt.get_template_id(tmp, sub.arguments());

  // Substitute through parameters.
  //
  // TODO: I think I need to re-establish name bindings during substitution
  // because we are going to be resolving types at the same time. This
  // means that I am going to have to move scoping facilities from the
  // parser to the context (which makes some sense).
  Decl_list parms;
  for (Decl& p1 : d.parameters()) {
    Decl& p2 = substitute(cxt, p1, sub);
    parms.push_back(p2);
  }

  // Substitute through the return type.
  Type& ret = substitute(cxt, d.return_type(), sub);

  // FIXME: I've just re-attached an uninstantiated definition
  // to the declaration. That is going to be a problem.
  // return cxt.make_function_declaration(n, parms, ret, d.definition());
#endif
  lingo_unreachable();
}
예제 #2
0
// Parse a template parameter list.
//
//    template-parameter-list:
//      template-parameter
//      template-parameter-list ',' template-parameter
Decl_list
Parser::template_parameter_list()
{
  Decl_list ds;
  do {
    Decl& d = template_parameter();
    ds.push_back(d);
  } while (match_if(tk::comma_tok));
  return ds;
}