OSDN Git Service

* config/xtensa/xtensa.c (xtensa_multibss_section_type_flags): Add
[pf3gnuchains/gcc-fork.git] / gcc / objc / objc-act.h
1 /* Declarations for objc-act.c.
2    Copyright (C) 1990, 2000, 2001, 2002, 2003
3    Free Software Foundation, Inc.
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_OBJC_ACT_H
23 #define GCC_OBJC_ACT_H
24
25 /*** Public Interface (procedures) ***/
26
27 bool objc_init (void);
28 const char *objc_printable_name (tree, int);
29
30 /* used by yyparse */
31
32 void finish_file (void);
33 tree start_class (enum tree_code, tree, tree, tree);
34 tree continue_class (tree);
35 void finish_class (tree);
36 void start_method_def (tree);
37 void continue_method_def (void);
38 void finish_method_def (void);
39 tree start_protocol (enum tree_code, tree, tree);
40 void finish_protocol (tree);
41 void add_objc_decls (void);
42
43 tree is_ivar (tree, tree);
44 int is_private (tree);
45 int is_public (tree, tree);
46 tree add_instance_variable (tree, int, tree, tree, tree);
47 tree add_class_method (tree, tree);
48 tree add_instance_method (tree, tree);
49 tree get_super_receiver (void);
50 tree get_class_ivars (tree);
51 tree get_class_reference (tree);
52 tree get_static_reference (tree, tree);
53 tree get_object_reference (tree);
54 tree build_message_expr (tree);
55 tree finish_message_expr (tree, tree, tree);
56 tree build_selector_expr (tree);
57 tree build_ivar_reference (tree);
58 tree build_keyword_decl (tree, tree, tree);
59 tree build_method_decl (enum tree_code, tree, tree, tree);
60 tree build_protocol_expr (tree);
61 tree build_objc_string_object (tree);
62
63 void objc_declare_alias (tree, tree);
64 void objc_declare_class (tree);
65 void objc_declare_protocols (tree);
66
67 /* the following routines are used to implement statically typed objects */
68
69 int objc_comptypes (tree, tree, int);
70 void objc_check_decl (tree);
71
72 /* NeXT extensions */
73
74 tree build_encode_expr (tree);
75
76 /* Objective-C structures */
77
78 /* KEYWORD_DECL */
79 #define KEYWORD_KEY_NAME(DECL) ((DECL)->decl.name)
80 #define KEYWORD_ARG_NAME(DECL) ((DECL)->decl.arguments)
81
82 /* INSTANCE_METHOD_DECL, CLASS_METHOD_DECL */
83 #define METHOD_SEL_NAME(DECL) ((DECL)->decl.name)
84 #define METHOD_SEL_ARGS(DECL) ((DECL)->decl.arguments)
85 #define METHOD_ADD_ARGS(DECL) ((DECL)->decl.result)
86 #define METHOD_DEFINITION(DECL) ((DECL)->decl.initial)
87 #define METHOD_ENCODING(DECL) ((DECL)->decl.context)
88
89 /* CLASS_INTERFACE_TYPE, CLASS_IMPLEMENTATION_TYPE,
90    CATEGORY_INTERFACE_TYPE, CATEGORY_IMPLEMENTATION_TYPE,
91    PROTOCOL_INTERFACE_TYPE */
92 #define CLASS_NAME(CLASS) ((CLASS)->type.name)
93 #define CLASS_SUPER_NAME(CLASS) (TYPE_CHECK (CLASS)->type.context)
94 #define CLASS_IVARS(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 0)
95 #define CLASS_RAW_IVARS(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 1)
96 #define CLASS_NST_METHODS(CLASS) ((CLASS)->type.minval)
97 #define CLASS_CLS_METHODS(CLASS) ((CLASS)->type.maxval)
98 #define CLASS_STATIC_TEMPLATE(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 2)
99 #define CLASS_CATEGORY_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 3)
100 #define CLASS_PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 4)
101 #define CLASS_OWN_IVARS(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 5)
102 #define PROTOCOL_NAME(CLASS) ((CLASS)->type.name)
103 #define PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 0)
104 #define PROTOCOL_NST_METHODS(CLASS) ((CLASS)->type.minval)
105 #define PROTOCOL_CLS_METHODS(CLASS) ((CLASS)->type.maxval)
106 #define PROTOCOL_FORWARD_DECL(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 1)
107 #define PROTOCOL_DEFINED(CLASS) TREE_USED (CLASS)
108 #define TYPE_PROTOCOL_LIST(TYPE)                                        \
109   ((!TYPE_CHECK (TYPE)->type.context                                    \
110     || TREE_CODE ((TYPE)->type.context) == TRANSLATION_UNIT_DECL)       \
111    ? NULL_TREE : (TYPE)->type.context)
112 #define SET_TYPE_PROTOCOL_LIST(TYPE, P) (TYPE_CHECK (TYPE)->type.context = (P))
113
114 /* Set by `continue_class' and checked by `is_public'.  */
115
116 #define TREE_STATIC_TEMPLATE(record_type) (TREE_PUBLIC (record_type))
117 #define TYPED_OBJECT(type) \
118        (TREE_CODE (type) == RECORD_TYPE && TREE_STATIC_TEMPLATE (type))
119
120 /* Define the Objective-C or Objective-C++ language-specific tree codes.  */
121
122 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
123 enum objc_tree_code {
124 #ifdef OBJCPLUS
125   LAST_BASE_TREE_CODE = LAST_CPLUS_TREE_CODE,
126 #else
127   LAST_BASE_TREE_CODE = LAST_C_TREE_CODE,
128 #endif
129 #include "objc-tree.def"
130   LAST_OBJC_TREE_CODE
131 };
132 #undef DEFTREECODE
133
134 /* Hash tables to manage the global pool of method prototypes.  */
135
136 typedef struct hashed_entry     *hash;
137 typedef struct hashed_attribute *attr;
138
139 struct hashed_attribute GTY(())
140 {
141   attr next;
142   tree value;
143 };
144 struct hashed_entry GTY(())
145 {
146   attr list;
147   hash next;
148   tree key;
149 };
150
151 extern GTY ((length ("SIZEHASHTABLE"))) hash *nst_method_hash_list;
152 extern GTY ((length ("SIZEHASHTABLE"))) hash *cls_method_hash_list;
153
154 #define SIZEHASHTABLE           257
155
156 /* Objective-C/Objective-C++ @implementation list.  */
157
158 struct imp_entry GTY(())
159 {
160   struct imp_entry *next;
161   tree imp_context;
162   tree imp_template;
163   tree class_decl;              /* _OBJC_CLASS_<my_name>; */
164   tree meta_decl;               /* _OBJC_METACLASS_<my_name>; */
165 };
166
167 extern GTY(()) struct imp_entry *imp_list;
168 extern int imp_count;   /* `@implementation' */
169 extern int cat_count;   /* `@category' */
170
171 /* Objective-C/Objective-C++ global tree enumeration.  */
172
173 enum objc_tree_index
174 {
175     OCTI_STATIC_NST,
176     OCTI_STATIC_NST_DECL,
177     OCTI_SELF_ID,
178     OCTI_UCMD_ID,
179     OCTI_UNUSED_LIST,
180     OCTI_ELLIPSIS_NODE,
181
182     OCTI_SELF_DECL,
183     OCTI_UMSG_DECL,
184     OCTI_UMSG_SUPER_DECL,
185     OCTI_GET_CLASS_DECL,
186     OCTI_GET_MCLASS_DECL,
187     OCTI_SUPER_TYPE,
188     OCTI_SEL_TYPE,
189     OCTI_ID_TYPE,
190     OCTI_CLS_TYPE,
191     OCTI_NST_TYPE,
192     OCTI_PROTO_TYPE,
193
194     OCTI_CLS_CHAIN,
195     OCTI_ALIAS_CHAIN,
196     OCTI_INTF_CHAIN,
197     OCTI_PROTO_CHAIN,
198     OCTI_IMPL_CHAIN,
199     OCTI_CLS_REF_CHAIN,
200     OCTI_SEL_REF_CHAIN,
201     OCTI_IVAR_CHAIN,
202     OCTI_CLS_NAMES_CHAIN,
203     OCTI_METH_VAR_NAMES_CHAIN,
204     OCTI_METH_VAR_TYPES_CHAIN,
205
206     OCTI_SYMBOLS_DECL,
207     OCTI_NST_VAR_DECL,
208     OCTI_CLS_VAR_DECL,
209     OCTI_NST_METH_DECL,
210     OCTI_CLS_METH_DECL,
211     OCTI_CLS_DECL,
212     OCTI_MCLS_DECL,
213     OCTI_SEL_TABLE_DECL,
214     OCTI_MODULES_DECL,
215     OCTI_STRG_DECL,
216
217     OCTI_INTF_CTX,
218     OCTI_IMPL_CTX,
219     OCTI_METH_CTX,
220     OCTI_IVAR_CTX,
221
222     OCTI_IMPL_TEMPL,
223     OCTI_CLS_TEMPL,
224     OCTI_CAT_TEMPL,
225     OCTI_UPRIV_REC,
226     OCTI_PROTO_TEMPL,
227     OCTI_SEL_TEMPL,
228     OCTI_UCLS_SUPER_REF,
229     OCTI_UUCLS_SUPER_REF,
230     OCTI_METH_TEMPL,
231     OCTI_IVAR_TEMPL,
232     OCTI_SYMTAB_TEMPL,
233     OCTI_MODULE_TEMPL,
234     OCTI_SUPER_TEMPL,
235     OCTI_OBJ_REF,
236     OCTI_METH_PROTO_TEMPL,
237     OCTI_FUNCTION1_TEMPL,
238     OCTI_FUNCTION2_TEMPL,
239
240     OCTI_OBJ_ID,
241     OCTI_CLS_ID,
242     OCTI_ID_ID,
243     OCTI_CNST_STR_ID,
244     OCTI_CNST_STR_TYPE,
245     OCTI_CNST_STR_GLOB_ID,
246     OCTI_STRING_CLASS_DECL,
247     OCTI_SUPER_DECL,
248
249     OCTI_MAX
250 };
251
252 extern GTY(()) tree objc_global_trees[OCTI_MAX];
253
254 /* List of classes with list of their static instances.  */
255 #define objc_static_instances   objc_global_trees[OCTI_STATIC_NST]
256
257 /* The declaration of the array administrating the static instances.  */
258 #define static_instances_decl   objc_global_trees[OCTI_STATIC_NST_DECL]
259
260 /* Some commonly used instances of "identifier_node".  */
261
262 #define self_id                 objc_global_trees[OCTI_SELF_ID]
263 #define ucmd_id                 objc_global_trees[OCTI_UCMD_ID]
264 #define unused_list             objc_global_trees[OCTI_UNUSED_LIST]
265 #define objc_ellipsis_node      objc_global_trees[OCTI_ELLIPSIS_NODE]
266
267 #define self_decl               objc_global_trees[OCTI_SELF_DECL]
268 #define umsg_decl               objc_global_trees[OCTI_UMSG_DECL]
269 #define umsg_super_decl         objc_global_trees[OCTI_UMSG_SUPER_DECL]
270 #define objc_get_class_decl     objc_global_trees[OCTI_GET_CLASS_DECL]
271 #define objc_get_meta_class_decl                        \
272                                 objc_global_trees[OCTI_GET_MCLASS_DECL]
273
274 #define super_type              objc_global_trees[OCTI_SUPER_TYPE]
275 #define selector_type           objc_global_trees[OCTI_SEL_TYPE]
276 #define id_type                 objc_global_trees[OCTI_ID_TYPE]
277 #define objc_class_type         objc_global_trees[OCTI_CLS_TYPE]
278 #define instance_type           objc_global_trees[OCTI_NST_TYPE]
279 #define protocol_type           objc_global_trees[OCTI_PROTO_TYPE]
280
281 /* Type checking macros.  */
282
283 #define IS_ID(TYPE) \
284   (TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (id_type))
285 #define IS_PROTOCOL_QUALIFIED_ID(TYPE) \
286   (IS_ID (TYPE) && TYPE_PROTOCOL_LIST (TYPE))
287 #define IS_SUPER(TYPE) \
288   (super_type && TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (super_type))
289
290 #define class_chain             objc_global_trees[OCTI_CLS_CHAIN]
291 #define alias_chain             objc_global_trees[OCTI_ALIAS_CHAIN]
292 #define interface_chain         objc_global_trees[OCTI_INTF_CHAIN]
293 #define protocol_chain          objc_global_trees[OCTI_PROTO_CHAIN]
294 #define implemented_classes     objc_global_trees[OCTI_IMPL_CHAIN]
295
296 /* Chains to manage selectors that are referenced and defined in the
297    module.  */
298
299 #define cls_ref_chain           objc_global_trees[OCTI_CLS_REF_CHAIN]   /* Classes referenced.  */
300 #define sel_ref_chain           objc_global_trees[OCTI_SEL_REF_CHAIN]   /* Selectors referenced.  */
301 #define objc_ivar_chain         objc_global_trees[OCTI_IVAR_CHAIN]
302
303 /* Chains to manage uniquing of strings.  */
304
305 #define class_names_chain       objc_global_trees[OCTI_CLS_NAMES_CHAIN]
306 #define meth_var_names_chain    objc_global_trees[OCTI_METH_VAR_NAMES_CHAIN]
307 #define meth_var_types_chain    objc_global_trees[OCTI_METH_VAR_TYPES_CHAIN]
308
309
310 /* Backend data declarations.  */
311
312 #define UOBJC_SYMBOLS_decl              objc_global_trees[OCTI_SYMBOLS_DECL]
313 #define UOBJC_INSTANCE_VARIABLES_decl   objc_global_trees[OCTI_NST_VAR_DECL]
314 #define UOBJC_CLASS_VARIABLES_decl      objc_global_trees[OCTI_CLS_VAR_DECL]
315 #define UOBJC_INSTANCE_METHODS_decl     objc_global_trees[OCTI_NST_METH_DECL]
316 #define UOBJC_CLASS_METHODS_decl        objc_global_trees[OCTI_CLS_METH_DECL]
317 #define UOBJC_CLASS_decl                objc_global_trees[OCTI_CLS_DECL]
318 #define UOBJC_METACLASS_decl            objc_global_trees[OCTI_MCLS_DECL]
319 #define UOBJC_SELECTOR_TABLE_decl       objc_global_trees[OCTI_SEL_TABLE_DECL]
320 #define UOBJC_MODULES_decl              objc_global_trees[OCTI_MODULES_DECL]
321 #define UOBJC_STRINGS_decl              objc_global_trees[OCTI_STRG_DECL]
322
323 /* The following are used when compiling a class implementation.
324    implementation_template will normally be an interface, however if
325    none exists this will be equal to objc_implementation_context...it is
326    set in start_class.  */
327
328 #define objc_interface_context          objc_global_trees[OCTI_INTF_CTX]
329 #define objc_implementation_context     objc_global_trees[OCTI_IMPL_CTX]
330 #define objc_method_context             objc_global_trees[OCTI_METH_CTX]
331 #define objc_ivar_context               objc_global_trees[OCTI_IVAR_CTX]
332
333 #define implementation_template objc_global_trees[OCTI_IMPL_TEMPL]
334 #define objc_class_template     objc_global_trees[OCTI_CLS_TEMPL]
335 #define objc_category_template  objc_global_trees[OCTI_CAT_TEMPL]
336 #define uprivate_record         objc_global_trees[OCTI_UPRIV_REC]
337 #define objc_protocol_template  objc_global_trees[OCTI_PROTO_TEMPL]
338 #define objc_selector_template  objc_global_trees[OCTI_SEL_TEMPL]
339 #define ucls_super_ref          objc_global_trees[OCTI_UCLS_SUPER_REF]
340 #define uucls_super_ref         objc_global_trees[OCTI_UUCLS_SUPER_REF]
341
342 #define objc_method_template    objc_global_trees[OCTI_METH_TEMPL]
343 #define objc_ivar_template      objc_global_trees[OCTI_IVAR_TEMPL]
344 #define objc_symtab_template    objc_global_trees[OCTI_SYMTAB_TEMPL]
345 #define objc_module_template    objc_global_trees[OCTI_MODULE_TEMPL]
346 #define objc_super_template     objc_global_trees[OCTI_SUPER_TEMPL]
347 #define objc_object_reference   objc_global_trees[OCTI_OBJ_REF]
348 #define objc_method_prototype_template          \
349                                 objc_global_trees[OCTI_METH_PROTO_TEMPL]
350 #define function1_template      objc_global_trees[OCTI_FUNCTION1_TEMPL]
351 #define function2_template      objc_global_trees[OCTI_FUNCTION2_TEMPL]
352
353 #define objc_object_id          objc_global_trees[OCTI_OBJ_ID]
354 #define objc_class_id           objc_global_trees[OCTI_CLS_ID]
355 #define objc_id_id              objc_global_trees[OCTI_ID_ID]
356 #define constant_string_id      objc_global_trees[OCTI_CNST_STR_ID]
357 #define constant_string_type    objc_global_trees[OCTI_CNST_STR_TYPE]
358 #define constant_string_global_id               \
359                                 objc_global_trees[OCTI_CNST_STR_GLOB_ID]
360 #define string_class_decl       objc_global_trees[OCTI_STRING_CLASS_DECL]
361 #define UOBJC_SUPER_decl        objc_global_trees[OCTI_SUPER_DECL]
362
363 #endif /* GCC_OBJC_ACT_H */