]>
Commit | Line | Data |
---|---|---|
aed81407 GDR |
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 | ||
ed3cf953 | 5 | This file is part of GCC. |
aed81407 | 6 | |
ed3cf953 | 7 | GCC is free software; you can redistribute it and/or modify |
aed81407 GDR |
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 | ||
ed3cf953 | 12 | GCC is distributed in the hope that it will be useful, |
aed81407 GDR |
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 | |
ed3cf953 | 18 | along with GCC; see the file COPYING. If not, write to |
aed81407 GDR |
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 | ||
5e0c54e5 GDR |
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 | |
aed81407 GDR |
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 | ||
ed3cf953 GDR |
68 | /* The datatype used to implement C++ scope. */ |
69 | typedef struct cp_binding_level cxx_scope; | |
70 | ||
aed81407 GDR |
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 | ||
147135cc | 75 | /* True if NODE->value is from a base class of the class which is |
aed81407 GDR |
76 | currently being defined. */ |
77 | #define INHERITED_VALUE_BINDING_P(NODE) ((NODE)->value_is_inherited) | |
78 | ||
aed81407 GDR |
79 | /* Zero out a cxx_binding pointed to by B. */ |
80 | #define cxx_binding_clear(B) memset ((B), 0, sizeof (cxx_binding)) | |
81 | ||
82 | struct cxx_binding GTY(()) | |
83 | { | |
84 | /* Link to chain together various bindings for this name. */ | |
85 | cxx_binding *previous; | |
86 | /* The non-type entity this name is bound to. */ | |
87 | tree value; | |
88 | /* The type entity this name is bound to. */ | |
89 | tree type; | |
ed3cf953 GDR |
90 | /* The scope at which this binding was made. */ |
91 | cxx_scope *scope; | |
aed81407 GDR |
92 | unsigned value_is_inherited : 1; |
93 | unsigned is_local : 1; | |
94 | }; | |
95 | ||
96 | extern cxx_binding *cxx_binding_make (tree, tree); | |
97 | extern void cxx_binding_free (cxx_binding *); | |
c87ceb13 | 98 | extern bool supplement_binding (cxx_binding *, tree); |
aed81407 | 99 | \f |
5f52c0e0 GDR |
100 | /* True if SCOPE designates the global scope binding contour. */ |
101 | #define global_scope_p(SCOPE) \ | |
102 | ((SCOPE) == NAMESPACE_LEVEL (global_namespace)) | |
aed81407 | 103 | |
ed3cf953 GDR |
104 | extern cxx_binding *cxx_scope_find_binding_for_name (cxx_scope *, tree); |
105 | extern cxx_binding *binding_for_name (cxx_scope *, tree); | |
106 | \f | |
107 | extern tree namespace_binding (tree, tree); | |
108 | extern void set_namespace_binding (tree, tree, tree); | |
aed81407 GDR |
109 | |
110 | #endif /* GCC_CP_NAME_LOOKUP_H */ |