OSDN Git Service

* cp-tree.h (add_binding): Remove declaration.
[pf3gnuchains/gcc-fork.git] / gcc / cp / name-lookup.h
1 /* Declarations for C++ name lookup routines.
2    Copyright (C) 2003 Free Software Foundation, Inc.
3    Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 #ifndef GCC_CP_NAME_LOOKUP_H
23 #define GCC_CP_NAME_LOOKUP_H
24
25 #include "c-common.h"
26
27 /* The type of dictionary used to map names to types declared at
28    a given scope.  */
29 typedef struct binding_table_s *binding_table;
30 typedef struct binding_entry_s *binding_entry;
31
32 /* The type of a routine repeatedly called by binding_table_foreach.  */
33 typedef void (*bt_foreach_proc) (binding_entry, void *);
34
35 struct binding_entry_s GTY(())
36 {
37   binding_entry chain;
38   tree name;
39   tree type;
40 };
41
42 /* These macros indicate the initial chains count for binding_table.  */
43 #define SCOPE_DEFAULT_HT_SIZE                        (1 << 3)
44 #define CLASS_SCOPE_HT_SIZE                          (1 << 3)
45 #define NAMESPACE_ORDINARY_HT_SIZE                   (1 << 5)
46 #define NAMESPACE_STD_HT_SIZE                        (1 << 8)
47 #define GLOBAL_SCOPE_HT_SIZE                         (1 << 8)
48
49 extern binding_table binding_table_new (size_t);
50 extern void binding_table_free (binding_table);
51 extern void binding_table_insert (binding_table, tree, tree);
52 extern tree binding_table_find_anon_type (binding_table, tree);
53 extern binding_entry binding_table_reverse_maybe_remap (binding_table,
54                                                         tree, tree);
55 extern void binding_table_remove_anonymous_types (binding_table);
56 extern void binding_table_foreach (binding_table, bt_foreach_proc, void *);
57 extern binding_entry binding_table_find (binding_table, tree);
58 extern void cxx_remember_type_decls (binding_table);
59 \f
60 /* Datatype used to temporarily save C++ bindings (for implicit
61    instantiations purposes and like).  Implemented in decl.c.  */
62 typedef struct cxx_saved_binding cxx_saved_binding;
63
64 /* Datatype that represents binding established by a declaration between
65    a name and a C++ entity.  */
66 typedef struct cxx_binding cxx_binding;
67
68 /* The datatype used to implement C++ scope.  */
69 typedef struct cp_binding_level cxx_scope;
70
71 /* Nonzero if this binding is for a local scope, as opposed to a class
72    or namespace scope.  */
73 #define LOCAL_BINDING_P(NODE) ((NODE)->is_local)
74
75 /* Nonzero if BINDING_VALUE is from a base class of the class which is
76    currently being defined.  */
77 #define INHERITED_VALUE_BINDING_P(NODE) ((NODE)->value_is_inherited)
78
79 /* For a binding between a name and an entity at a non-local scope,
80    defines the scope where the binding is declared.  (Either a class
81    _TYPE node, or a NAMESPACE_DECL.).  */
82 #define BINDING_SCOPE(NODE) ((NODE)->scope)
83
84 /* This is the declaration bound to the name. Possible values:
85    variable, overloaded function, namespace, template, enumerator.  */
86 #define BINDING_VALUE(NODE) ((NODE)->value)
87
88 /* If name is bound to a type, this is the type (struct, union, enum).  */
89 #define BINDING_TYPE(NODE)   ((NODE)->type)
90
91 /* Zero out a cxx_binding pointed to by B.  */
92 #define cxx_binding_clear(B) memset ((B), 0, sizeof (cxx_binding))
93
94 struct cxx_binding GTY(())
95 {
96   /* Link to chain together various bindings for this name.  */
97   cxx_binding *previous;
98   /* The non-type entity this name is bound to.  */
99   tree value;
100   /* The type entity this name is bound to.  */
101   tree type;
102   /* The scope at which this binding was made.  */
103   cxx_scope *scope;
104   unsigned value_is_inherited : 1;
105   unsigned is_local : 1;
106 };
107
108 extern cxx_binding *cxx_binding_make (tree, tree);
109 extern void cxx_binding_free (cxx_binding *);
110 extern bool supplement_binding (cxx_binding *, tree);
111 \f
112 /* True if SCOPE designates the global scope binding contour.  */
113 #define global_scope_p(SCOPE) \
114   ((SCOPE) == NAMESPACE_LEVEL (global_namespace))
115
116 extern cxx_binding *cxx_scope_find_binding_for_name (cxx_scope *, tree);
117 extern cxx_binding *binding_for_name (cxx_scope *, tree);
118 \f
119 extern tree namespace_binding (tree, tree);
120 extern void set_namespace_binding (tree, tree, tree);
121
122 #endif /* GCC_CP_NAME_LOOKUP_H */