Esempio n. 1
0
// Add the given AST to the given list, using the name from the specified
// child.
// ASTs with hygenic names are ignored.
// Leading underscores on names are ignored for sorting purposes.
// When false the allow_public parameter causes ASTs with public names to be
// ignored. allow_private does the same for private names.
static void doc_list_add_named(ast_list_t* list, ast_t* ast, size_t id_index,
  bool allow_public, bool allow_private)
{
  assert(list != NULL);
  assert(ast != NULL);

  const char* name = ast_name(ast_childidx(ast, id_index));
  assert(name != NULL);

  if(is_name_internal_test(name))  // Ignore internally generated names
    return;

  if(is_name_private(name) && !allow_private)  // Ignore private
    return;

  if(!is_name_private(name) && !allow_public)  // Ignore public
    return;

  if(is_name_private(name))  // Ignore leading underscore for ordering
    name++;

  doc_list_add(list, ast, name, false);
}
Esempio n. 2
0
File: id.c Progetto: enigma/ponyc
bool is_name_private(const char* name)
{
  return name[0] == '_' || (is_name_internal_test(name) && name[1] == '_');
}