]> gcc.gnu.org Git - gcc.git/blob - gcc/objc/objc-act.h
c-decl.c (c_in_iteration_stmt, [...]): Remove.
[gcc.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
42 tree objc_build_throw_stmt (tree);
43 void objc_begin_try_stmt (location_t, tree);
44 void objc_begin_catch_clause (tree);
45 void objc_finish_catch_clause (void);
46 void objc_build_finally_clause (location_t, tree);
47 void objc_finish_try_stmt (void);
48 void objc_build_synchronized (location_t, tree, tree);
49
50 tree is_ivar (tree, tree);
51 int is_private (tree);
52 int objc_is_public (tree, tree);
53 tree add_instance_variable (tree, int, tree, tree, tree);
54 tree objc_add_method (tree, tree, int);
55 tree get_super_receiver (void);
56 void objc_clear_super_receiver (void);
57 tree get_class_ivars_from_name (tree);
58 tree get_class_reference (tree);
59 tree get_static_reference (tree, tree);
60 tree get_protocol_reference (tree);
61 tree build_message_expr (tree);
62 tree finish_message_expr (tree, tree, tree);
63 tree build_selector_expr (tree);
64 tree build_ivar_reference (tree);
65 tree build_keyword_decl (tree, tree, tree);
66 tree build_method_decl (enum tree_code, tree, tree, tree);
67 tree build_protocol_expr (tree);
68 tree build_objc_string_object (tree);
69
70 void objc_declare_alias (tree, tree);
71 void objc_declare_class (tree);
72 void objc_declare_protocols (tree);
73
74 /* the following routines are used to implement statically typed objects */
75
76 int objc_comptypes (tree, tree, int);
77 void objc_check_decl (tree);
78
79 /* NeXT extensions */
80
81 tree build_encode_expr (tree);
82
83 /* Objective-C structures */
84
85 #define CLASS_BINFO_ELTS 6
86 #define PROTOCOL_BINFO_ELTS 2
87
88 /* KEYWORD_DECL */
89 #define KEYWORD_KEY_NAME(DECL) ((DECL)->decl.name)
90 #define KEYWORD_ARG_NAME(DECL) ((DECL)->decl.arguments)
91
92 /* INSTANCE_METHOD_DECL, CLASS_METHOD_DECL */
93 #define METHOD_SEL_NAME(DECL) ((DECL)->decl.name)
94 #define METHOD_SEL_ARGS(DECL) ((DECL)->decl.arguments)
95 #define METHOD_ADD_ARGS(DECL) ((DECL)->decl.result)
96 #define METHOD_DEFINITION(DECL) ((DECL)->decl.initial)
97 #define METHOD_ENCODING(DECL) ((DECL)->decl.context)
98
99 /* CLASS_INTERFACE_TYPE, CLASS_IMPLEMENTATION_TYPE,
100 CATEGORY_INTERFACE_TYPE, CATEGORY_IMPLEMENTATION_TYPE,
101 PROTOCOL_INTERFACE_TYPE */
102 #define CLASS_NAME(CLASS) ((CLASS)->type.name)
103 #define CLASS_SUPER_NAME(CLASS) (TYPE_CHECK (CLASS)->type.context)
104 #define CLASS_IVARS(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 0)
105 #define CLASS_RAW_IVARS(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 1)
106 #define CLASS_NST_METHODS(CLASS) ((CLASS)->type.minval)
107 #define CLASS_CLS_METHODS(CLASS) ((CLASS)->type.maxval)
108 #define CLASS_STATIC_TEMPLATE(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 2)
109 #define CLASS_CATEGORY_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 3)
110 #define CLASS_PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 4)
111 #define CLASS_OWN_IVARS(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 5)
112 #define PROTOCOL_NAME(CLASS) ((CLASS)->type.name)
113 #define PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 0)
114 #define PROTOCOL_NST_METHODS(CLASS) ((CLASS)->type.minval)
115 #define PROTOCOL_CLS_METHODS(CLASS) ((CLASS)->type.maxval)
116 #define PROTOCOL_FORWARD_DECL(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 1)
117 #define PROTOCOL_DEFINED(CLASS) TREE_USED (CLASS)
118 /* We need to distinguish TYPE_PROTOCOL_LISTs from TYPE_CONTEXTs, both of which
119 are stored in the same accessor slot. */
120 #define TYPE_PROTOCOL_LIST(TYPE) \
121 ((TYPE_CHECK (TYPE)->type.context \
122 && TREE_CODE ((TYPE)->type.context) == TREE_LIST) \
123 ? (TYPE)->type.context : NULL_TREE)
124 #define SET_TYPE_PROTOCOL_LIST(TYPE, P) (TYPE_CHECK (TYPE)->type.context = (P))
125
126 /* Set by `continue_class' and checked by `objc_is_public'. */
127
128 #define TREE_STATIC_TEMPLATE(record_type) (TREE_PUBLIC (record_type))
129 #define TYPED_OBJECT(type) \
130 (TREE_CODE (type) == RECORD_TYPE && TREE_STATIC_TEMPLATE (type))
131 #define OBJC_TYPE_NAME(type) TYPE_NAME(type)
132
133 /* Define the Objective-C or Objective-C++ language-specific tree codes. */
134
135 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
136 enum objc_tree_code {
137 #if defined (GCC_CP_TREE_H)
138 LAST_BASE_TREE_CODE = LAST_CPLUS_TREE_CODE,
139 #else
140 #if defined (GCC_C_TREE_H)
141 LAST_BASE_TREE_CODE = LAST_C_TREE_CODE,
142 #else
143 #error You must include <c-tree.h> or <cp/cp-tree.h> before <objc/objc-act.h>
144 #endif
145 #endif
146 #include "objc-tree.def"
147 LAST_OBJC_TREE_CODE
148 };
149 #undef DEFTREECODE
150
151 /* Hash tables to manage the global pool of method prototypes. */
152
153 typedef struct hashed_entry *hash;
154 typedef struct hashed_attribute *attr;
155
156 struct hashed_attribute GTY(())
157 {
158 attr next;
159 tree value;
160 };
161 struct hashed_entry GTY(())
162 {
163 attr list;
164 hash next;
165 tree key;
166 };
167
168 extern GTY ((length ("SIZEHASHTABLE"))) hash *nst_method_hash_list;
169 extern GTY ((length ("SIZEHASHTABLE"))) hash *cls_method_hash_list;
170
171 #define SIZEHASHTABLE 257
172
173 /* Objective-C/Objective-C++ @implementation list. */
174
175 struct imp_entry GTY(())
176 {
177 struct imp_entry *next;
178 tree imp_context;
179 tree imp_template;
180 tree class_decl; /* _OBJC_CLASS_<my_name>; */
181 tree meta_decl; /* _OBJC_METACLASS_<my_name>; */
182 };
183
184 extern GTY(()) struct imp_entry *imp_list;
185 extern int imp_count; /* `@implementation' */
186 extern int cat_count; /* `@category' */
187
188 /* Objective-C/Objective-C++ global tree enumeration. */
189
190 enum objc_tree_index
191 {
192 OCTI_STATIC_NST,
193 OCTI_STATIC_NST_DECL,
194 OCTI_SELF_ID,
195 OCTI_UCMD_ID,
196 OCTI_UNUSED_LIST,
197 OCTI_ELLIPSIS_NODE,
198
199 OCTI_SELF_DECL,
200 OCTI_UMSG_DECL,
201 OCTI_UMSG_SUPER_DECL,
202 OCTI_UMSG_STRET_DECL,
203 OCTI_UMSG_SUPER_STRET_DECL,
204 OCTI_GET_CLASS_DECL,
205 OCTI_GET_MCLASS_DECL,
206 OCTI_SUPER_TYPE,
207 OCTI_SEL_TYPE,
208 OCTI_ID_TYPE,
209 OCTI_CLS_TYPE,
210 OCTI_NST_TYPE,
211 OCTI_PROTO_TYPE,
212
213 OCTI_CLS_CHAIN,
214 OCTI_ALIAS_CHAIN,
215 OCTI_INTF_CHAIN,
216 OCTI_PROTO_CHAIN,
217 OCTI_IMPL_CHAIN,
218 OCTI_CLS_REF_CHAIN,
219 OCTI_SEL_REF_CHAIN,
220 OCTI_IVAR_CHAIN,
221 OCTI_CLS_NAMES_CHAIN,
222 OCTI_METH_VAR_NAMES_CHAIN,
223 OCTI_METH_VAR_TYPES_CHAIN,
224
225 OCTI_SYMBOLS_DECL,
226 OCTI_NST_VAR_DECL,
227 OCTI_CLS_VAR_DECL,
228 OCTI_NST_METH_DECL,
229 OCTI_CLS_METH_DECL,
230 OCTI_CLS_DECL,
231 OCTI_MCLS_DECL,
232 OCTI_SEL_TABLE_DECL,
233 OCTI_MODULES_DECL,
234
235 OCTI_INTF_CTX,
236 OCTI_IMPL_CTX,
237 OCTI_METH_CTX,
238 OCTI_IVAR_CTX,
239
240 OCTI_IMPL_TEMPL,
241 OCTI_CLS_TEMPL,
242 OCTI_CAT_TEMPL,
243 OCTI_UPRIV_REC,
244 OCTI_PROTO_TEMPL,
245 OCTI_SEL_TEMPL,
246 OCTI_UCLS_SUPER_REF,
247 OCTI_UUCLS_SUPER_REF,
248 OCTI_METH_TEMPL,
249 OCTI_IVAR_TEMPL,
250 OCTI_SYMTAB_TEMPL,
251 OCTI_MODULE_TEMPL,
252 OCTI_SUPER_TEMPL,
253 OCTI_OBJ_REF,
254 OCTI_METH_PROTO_TEMPL,
255 OCTI_FUNCTION1_TEMPL,
256 OCTI_FUNCTION2_TEMPL,
257
258 OCTI_OBJ_ID,
259 OCTI_CLS_ID,
260 OCTI_ID_ID,
261 OCTI_CNST_STR_ID,
262 OCTI_CNST_STR_TYPE,
263 OCTI_CNST_STR_GLOB_ID,
264 OCTI_STRING_CLASS_DECL,
265 OCTI_SUPER_DECL,
266 OCTI_UMSG_NONNIL_DECL,
267 OCTI_UMSG_NONNIL_STRET_DECL,
268 OCTI_STORAGE_CLS,
269 OCTI_EXCEPTION_EXTRACT_DECL,
270 OCTI_EXCEPTION_TRY_ENTER_DECL,
271 OCTI_EXCEPTION_TRY_EXIT_DECL,
272 OCTI_EXCEPTION_MATCH_DECL,
273 OCTI_EXCEPTION_THROW_DECL,
274 OCTI_SYNC_ENTER_DECL,
275 OCTI_SYNC_EXIT_DECL,
276 OCTI_SETJMP_DECL,
277 OCTI_EXCDATA_TEMPL,
278 OCTI_STACK_EXCEPTION_DATA_DECL,
279 OCTI_LOCAL_EXCEPTION_DECL,
280 OCTI_RETHROW_EXCEPTION_DECL,
281 OCTI_EVAL_ONCE_DECL,
282 OCTI_CATCH_TYPE,
283
284 OCTI_MAX
285 };
286
287 extern GTY(()) tree objc_global_trees[OCTI_MAX];
288
289 /* List of classes with list of their static instances. */
290 #define objc_static_instances objc_global_trees[OCTI_STATIC_NST]
291
292 /* The declaration of the array administrating the static instances. */
293 #define static_instances_decl objc_global_trees[OCTI_STATIC_NST_DECL]
294
295 /* Some commonly used instances of "identifier_node". */
296
297 #define self_id objc_global_trees[OCTI_SELF_ID]
298 #define ucmd_id objc_global_trees[OCTI_UCMD_ID]
299 #define unused_list objc_global_trees[OCTI_UNUSED_LIST]
300 #define objc_ellipsis_node objc_global_trees[OCTI_ELLIPSIS_NODE]
301
302 #define self_decl objc_global_trees[OCTI_SELF_DECL]
303 #define umsg_decl objc_global_trees[OCTI_UMSG_DECL]
304 #define umsg_super_decl objc_global_trees[OCTI_UMSG_SUPER_DECL]
305 #define umsg_stret_decl objc_global_trees[OCTI_UMSG_STRET_DECL]
306 #define umsg_super_stret_decl objc_global_trees[OCTI_UMSG_SUPER_STRET_DECL]
307 #define objc_get_class_decl objc_global_trees[OCTI_GET_CLASS_DECL]
308 #define objc_get_meta_class_decl \
309 objc_global_trees[OCTI_GET_MCLASS_DECL]
310
311 #define objc_super_type objc_global_trees[OCTI_SUPER_TYPE]
312 #define objc_selector_type objc_global_trees[OCTI_SEL_TYPE]
313 #define objc_id_type objc_global_trees[OCTI_ID_TYPE]
314 #define objc_class_type objc_global_trees[OCTI_CLS_TYPE]
315 #define objc_instance_type objc_global_trees[OCTI_NST_TYPE]
316 #define objc_protocol_type objc_global_trees[OCTI_PROTO_TYPE]
317
318 /* Type checking macros. */
319
320 #define IS_ID(TYPE) \
321 (TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (objc_id_type))
322 #define IS_PROTOCOL_QUALIFIED_ID(TYPE) \
323 (IS_ID (TYPE) && TYPE_PROTOCOL_LIST (TYPE))
324 #define IS_SUPER(TYPE) \
325 (TREE_CODE (TYPE) == POINTER_TYPE && TREE_TYPE (TYPE) == objc_super_template)
326
327 #define class_chain objc_global_trees[OCTI_CLS_CHAIN]
328 #define alias_chain objc_global_trees[OCTI_ALIAS_CHAIN]
329 #define interface_chain objc_global_trees[OCTI_INTF_CHAIN]
330 #define protocol_chain objc_global_trees[OCTI_PROTO_CHAIN]
331 #define implemented_classes objc_global_trees[OCTI_IMPL_CHAIN]
332
333 /* Chains to manage selectors that are referenced and defined in the
334 module. */
335
336 #define cls_ref_chain objc_global_trees[OCTI_CLS_REF_CHAIN] /* Classes referenced. */
337 #define sel_ref_chain objc_global_trees[OCTI_SEL_REF_CHAIN] /* Selectors referenced. */
338 #define objc_ivar_chain objc_global_trees[OCTI_IVAR_CHAIN]
339
340 /* Chains to manage uniquing of strings. */
341
342 #define class_names_chain objc_global_trees[OCTI_CLS_NAMES_CHAIN]
343 #define meth_var_names_chain objc_global_trees[OCTI_METH_VAR_NAMES_CHAIN]
344 #define meth_var_types_chain objc_global_trees[OCTI_METH_VAR_TYPES_CHAIN]
345
346
347 /* Backend data declarations. */
348
349 #define UOBJC_SYMBOLS_decl objc_global_trees[OCTI_SYMBOLS_DECL]
350 #define UOBJC_INSTANCE_VARIABLES_decl objc_global_trees[OCTI_NST_VAR_DECL]
351 #define UOBJC_CLASS_VARIABLES_decl objc_global_trees[OCTI_CLS_VAR_DECL]
352 #define UOBJC_INSTANCE_METHODS_decl objc_global_trees[OCTI_NST_METH_DECL]
353 #define UOBJC_CLASS_METHODS_decl objc_global_trees[OCTI_CLS_METH_DECL]
354 #define UOBJC_CLASS_decl objc_global_trees[OCTI_CLS_DECL]
355 #define UOBJC_METACLASS_decl objc_global_trees[OCTI_MCLS_DECL]
356 #define UOBJC_SELECTOR_TABLE_decl objc_global_trees[OCTI_SEL_TABLE_DECL]
357 #define UOBJC_MODULES_decl objc_global_trees[OCTI_MODULES_DECL]
358
359 /* The following are used when compiling a class implementation.
360 implementation_template will normally be an interface, however if
361 none exists this will be equal to objc_implementation_context...it is
362 set in start_class. */
363
364 #define objc_interface_context objc_global_trees[OCTI_INTF_CTX]
365 #define objc_implementation_context objc_global_trees[OCTI_IMPL_CTX]
366 #define objc_method_context objc_global_trees[OCTI_METH_CTX]
367 #define objc_ivar_context objc_global_trees[OCTI_IVAR_CTX]
368
369 #define implementation_template objc_global_trees[OCTI_IMPL_TEMPL]
370 #define objc_class_template objc_global_trees[OCTI_CLS_TEMPL]
371 #define objc_category_template objc_global_trees[OCTI_CAT_TEMPL]
372 #define uprivate_record objc_global_trees[OCTI_UPRIV_REC]
373 #define objc_protocol_template objc_global_trees[OCTI_PROTO_TEMPL]
374 #define objc_selector_template objc_global_trees[OCTI_SEL_TEMPL]
375 #define ucls_super_ref objc_global_trees[OCTI_UCLS_SUPER_REF]
376 #define uucls_super_ref objc_global_trees[OCTI_UUCLS_SUPER_REF]
377
378 #define umsg_nonnil_decl objc_global_trees[OCTI_UMSG_NONNIL_DECL]
379 #define umsg_nonnil_stret_decl objc_global_trees[OCTI_UMSG_NONNIL_STRET_DECL]
380 #define objc_storage_class objc_global_trees[OCTI_STORAGE_CLS]
381 #define objc_exception_extract_decl \
382 objc_global_trees[OCTI_EXCEPTION_EXTRACT_DECL]
383 #define objc_exception_try_enter_decl \
384 objc_global_trees[OCTI_EXCEPTION_TRY_ENTER_DECL]
385 #define objc_exception_try_exit_decl \
386 objc_global_trees[OCTI_EXCEPTION_TRY_EXIT_DECL]
387 #define objc_exception_match_decl \
388 objc_global_trees[OCTI_EXCEPTION_MATCH_DECL]
389 #define objc_exception_throw_decl \
390 objc_global_trees[OCTI_EXCEPTION_THROW_DECL]
391 #define objc_sync_enter_decl objc_global_trees[OCTI_SYNC_ENTER_DECL]
392 #define objc_sync_exit_decl objc_global_trees[OCTI_SYNC_EXIT_DECL]
393 #define objc_exception_data_template \
394 objc_global_trees[OCTI_EXCDATA_TEMPL]
395 #define objc_setjmp_decl objc_global_trees[OCTI_SETJMP_DECL]
396 #define objc_stack_exception_data \
397 objc_global_trees[OCTI_STACK_EXCEPTION_DATA_DECL]
398 #define objc_caught_exception objc_global_trees[OCTI_LOCAL_EXCEPTION_DECL]
399 #define objc_rethrow_exception objc_global_trees[OCTI_RETHROW_EXCEPTION_DECL]
400 #define objc_eval_once objc_global_trees[OCTI_EVAL_ONCE_DECL]
401 #define objc_catch_type objc_global_trees[OCTI_CATCH_TYPE]
402
403 #define objc_method_template objc_global_trees[OCTI_METH_TEMPL]
404 #define objc_ivar_template objc_global_trees[OCTI_IVAR_TEMPL]
405 #define objc_symtab_template objc_global_trees[OCTI_SYMTAB_TEMPL]
406 #define objc_module_template objc_global_trees[OCTI_MODULE_TEMPL]
407 #define objc_super_template objc_global_trees[OCTI_SUPER_TEMPL]
408 #define objc_object_reference objc_global_trees[OCTI_OBJ_REF]
409 #define objc_method_prototype_template \
410 objc_global_trees[OCTI_METH_PROTO_TEMPL]
411 #define function1_template objc_global_trees[OCTI_FUNCTION1_TEMPL]
412 #define function2_template objc_global_trees[OCTI_FUNCTION2_TEMPL]
413
414 #define objc_object_id objc_global_trees[OCTI_OBJ_ID]
415 #define objc_class_id objc_global_trees[OCTI_CLS_ID]
416 #define objc_id_id objc_global_trees[OCTI_ID_ID]
417 #define constant_string_id objc_global_trees[OCTI_CNST_STR_ID]
418 #define constant_string_type objc_global_trees[OCTI_CNST_STR_TYPE]
419 #define constant_string_global_id \
420 objc_global_trees[OCTI_CNST_STR_GLOB_ID]
421 #define string_class_decl objc_global_trees[OCTI_STRING_CLASS_DECL]
422 #define UOBJC_SUPER_decl objc_global_trees[OCTI_SUPER_DECL]
423
424 #endif /* GCC_OBJC_ACT_H */
This page took 0.05742 seconds and 6 git commands to generate.