2003-03-30 15:18:18 +02:00
|
|
|
|
/* Declarations for C++ name lookup routines.
|
|
|
|
|
Copyright (C) 2003 Free Software Foundation, Inc.
|
|
|
|
|
Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
|
|
|
|
|
|
2003-03-30 18:00:39 +02:00
|
|
|
|
This file is part of GCC.
|
2003-03-30 15:18:18 +02:00
|
|
|
|
|
2003-03-30 18:00:39 +02:00
|
|
|
|
GCC is free software; you can redistribute it and/or modify
|
2003-03-30 15:18:18 +02:00
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
any later version.
|
|
|
|
|
|
2003-03-30 18:00:39 +02:00
|
|
|
|
GCC is distributed in the hope that it will be useful,
|
2003-03-30 15:18:18 +02:00
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2003-03-30 18:00:39 +02:00
|
|
|
|
along with GCC; see the file COPYING. If not, write to
|
2003-03-30 15:18:18 +02:00
|
|
|
|
the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
|
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
|
|
|
|
|
|
#ifndef GCC_CP_NAME_LOOKUP_H
|
|
|
|
|
#define GCC_CP_NAME_LOOKUP_H
|
|
|
|
|
|
|
|
|
|
#include "c-common.h"
|
|
|
|
|
|
2003-05-18 15:40:54 +02:00
|
|
|
|
/* The type of dictionary used to map names to types declared at
|
|
|
|
|
a given scope. */
|
|
|
|
|
typedef struct binding_table_s *binding_table;
|
|
|
|
|
typedef struct binding_entry_s *binding_entry;
|
|
|
|
|
|
|
|
|
|
/* The type of a routine repeatedly called by binding_table_foreach. */
|
|
|
|
|
typedef void (*bt_foreach_proc) (binding_entry, void *);
|
|
|
|
|
|
|
|
|
|
struct binding_entry_s GTY(())
|
|
|
|
|
{
|
|
|
|
|
binding_entry chain;
|
|
|
|
|
tree name;
|
|
|
|
|
tree type;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* These macros indicate the initial chains count for binding_table. */
|
|
|
|
|
#define SCOPE_DEFAULT_HT_SIZE (1 << 3)
|
|
|
|
|
#define CLASS_SCOPE_HT_SIZE (1 << 3)
|
|
|
|
|
#define NAMESPACE_ORDINARY_HT_SIZE (1 << 5)
|
|
|
|
|
#define NAMESPACE_STD_HT_SIZE (1 << 8)
|
|
|
|
|
#define GLOBAL_SCOPE_HT_SIZE (1 << 8)
|
|
|
|
|
|
|
|
|
|
extern binding_table binding_table_new (size_t);
|
|
|
|
|
extern void binding_table_free (binding_table);
|
|
|
|
|
extern void binding_table_insert (binding_table, tree, tree);
|
|
|
|
|
extern tree binding_table_find_anon_type (binding_table, tree);
|
|
|
|
|
extern binding_entry binding_table_reverse_maybe_remap (binding_table,
|
|
|
|
|
tree, tree);
|
|
|
|
|
extern void binding_table_remove_anonymous_types (binding_table);
|
|
|
|
|
extern void binding_table_foreach (binding_table, bt_foreach_proc, void *);
|
|
|
|
|
extern binding_entry binding_table_find (binding_table, tree);
|
|
|
|
|
extern void cxx_remember_type_decls (binding_table);
|
|
|
|
|
|
2003-03-30 15:18:18 +02:00
|
|
|
|
/* Datatype used to temporarily save C++ bindings (for implicit
|
|
|
|
|
instantiations purposes and like). Implemented in decl.c. */
|
|
|
|
|
typedef struct cxx_saved_binding cxx_saved_binding;
|
|
|
|
|
|
|
|
|
|
/* Datatype that represents binding established by a declaration between
|
|
|
|
|
a name and a C++ entity. */
|
|
|
|
|
typedef struct cxx_binding cxx_binding;
|
|
|
|
|
|
2003-03-30 18:00:39 +02:00
|
|
|
|
/* The datatype used to implement C++ scope. */
|
|
|
|
|
typedef struct cp_binding_level cxx_scope;
|
|
|
|
|
|
2003-03-30 15:18:18 +02:00
|
|
|
|
/* Nonzero if this binding is for a local scope, as opposed to a class
|
|
|
|
|
or namespace scope. */
|
|
|
|
|
#define LOCAL_BINDING_P(NODE) ((NODE)->is_local)
|
|
|
|
|
|
|
|
|
|
/* Nonzero if BINDING_VALUE is from a base class of the class which is
|
|
|
|
|
currently being defined. */
|
|
|
|
|
#define INHERITED_VALUE_BINDING_P(NODE) ((NODE)->value_is_inherited)
|
|
|
|
|
|
|
|
|
|
/* For a binding between a name and an entity at a non-local scope,
|
|
|
|
|
defines the scope where the binding is declared. (Either a class
|
2003-03-30 18:00:39 +02:00
|
|
|
|
_TYPE node, or a NAMESPACE_DECL.). */
|
|
|
|
|
#define BINDING_SCOPE(NODE) ((NODE)->scope)
|
2003-03-30 15:18:18 +02:00
|
|
|
|
|
|
|
|
|
/* This is the declaration bound to the name. Possible values:
|
|
|
|
|
variable, overloaded function, namespace, template, enumerator. */
|
|
|
|
|
#define BINDING_VALUE(NODE) ((NODE)->value)
|
|
|
|
|
|
|
|
|
|
/* If name is bound to a type, this is the type (struct, union, enum). */
|
|
|
|
|
#define BINDING_TYPE(NODE) ((NODE)->type)
|
|
|
|
|
|
|
|
|
|
/* Zero out a cxx_binding pointed to by B. */
|
|
|
|
|
#define cxx_binding_clear(B) memset ((B), 0, sizeof (cxx_binding))
|
|
|
|
|
|
|
|
|
|
struct cxx_binding GTY(())
|
|
|
|
|
{
|
|
|
|
|
/* Link to chain together various bindings for this name. */
|
|
|
|
|
cxx_binding *previous;
|
|
|
|
|
/* The non-type entity this name is bound to. */
|
|
|
|
|
tree value;
|
|
|
|
|
/* The type entity this name is bound to. */
|
|
|
|
|
tree type;
|
2003-03-30 18:00:39 +02:00
|
|
|
|
/* The scope at which this binding was made. */
|
|
|
|
|
cxx_scope *scope;
|
2003-03-30 15:18:18 +02:00
|
|
|
|
unsigned value_is_inherited : 1;
|
|
|
|
|
unsigned is_local : 1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern cxx_binding *cxx_binding_make (tree, tree);
|
|
|
|
|
extern void cxx_binding_free (cxx_binding *);
|
2003-09-06 21:03:44 +02:00
|
|
|
|
extern bool supplement_binding (cxx_binding *, tree);
|
2003-03-30 15:18:18 +02:00
|
|
|
|
|
2003-05-29 13:04:10 +02:00
|
|
|
|
/* True if SCOPE designates the global scope binding contour. */
|
|
|
|
|
#define global_scope_p(SCOPE) \
|
|
|
|
|
((SCOPE) == NAMESPACE_LEVEL (global_namespace))
|
2003-03-30 15:18:18 +02:00
|
|
|
|
|
2003-03-30 18:00:39 +02:00
|
|
|
|
extern cxx_binding *cxx_scope_find_binding_for_name (cxx_scope *, tree);
|
|
|
|
|
extern cxx_binding *binding_for_name (cxx_scope *, tree);
|
|
|
|
|
|
|
|
|
|
extern tree namespace_binding (tree, tree);
|
|
|
|
|
extern void set_namespace_binding (tree, tree, tree);
|
2003-03-30 15:18:18 +02:00
|
|
|
|
|
|
|
|
|
#endif /* GCC_CP_NAME_LOOKUP_H */
|