示例#1
0
// In the first pass, just create the parameter. We'll declare it
// during elaboration of the function's definition.
Decl&
Parser::on_function_parameter(Name& n, Type& t)
{
  Decl& d = build.make_object_parm(n, t);
  d.spec_ = take_decl_specs();
  return d;
}
示例#2
0
Decl&
Parser::on_function_declaration(Name& n, Decl_list& p, Type& t, Stmt& s)
{
  Decl* ret;
  if (declaring_member(*this))
    ret = &cxt.make_method_declaration(n, p, t, s);
  else
    ret = &cxt.make_function_declaration(n, p, t, s);
  ret->spec_ = take_decl_specs();
  declare(cxt, *ret);
  return *ret;
}
示例#3
0
// FIXME: There's a lot of duplication hereabouts. Can we reduce it?
Decl&
Parser::on_variable_declaration(Name& n, Type& t, Expr& e)
{
  Decl* ret;
  if (declaring_member(*this))
    ret = &cxt.make_field_declaration(n, t, e);
  else
    ret = &cxt.make_variable_declaration(n, t, e);
  ret->spec_ = take_decl_specs();
  declare(cxt, *ret);
  return *ret;
}
示例#4
0
Decl&
Parser::on_variable_declaration(Name& n, Type& t, Def& d)
{
  Decl* ret;
  if (parsing_nonstatic_member())
    ret = &cxt.make_field_declaration(n, t, d);
  else
    ret = &cxt.make_variable_declaration(n, t, d);
  ret->spec_ = take_decl_specs();
  declare(cxt, *ret);
  return *ret;
}
示例#5
0
// Build and declare the function or method. A method is a non-static
// function declared in class scope.
Decl&
Parser::start_function_declaration(Name& n, Decl_list& ps, Type& t)
{
  // Form the (initial) function type.
  Type_list ts;
  for (Decl& p : ps)
    ts.push_back(cast<Typed_decl>(p).type());
  Type& ft = cxt.get_function_type(std::move(ts), t);

  // Generate the declaration.
  Decl* d;
  if (parsing_nonstatic_member())
    d = &cxt.make_method_declaration(n, ft, ps);
  else
    d = &cxt.make_function_declaration(n, ft, ps);
  d->spec_ = take_decl_specs();
  
  declare(cxt, *d);
  
  return *d;
}