]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/objc/objc-act.h
use templates instead of gengtype for typed allocation functions
[thirdparty/gcc.git] / gcc / objc / objc-act.h
CommitLineData
25eddb2c 1/* Declarations for objc-act.c.
23a5b65a 2 Copyright (C) 1990-2014 Free Software Foundation, Inc.
02ba24b7 3
b9593599 4This file is part of GCC.
02ba24b7 5
b9593599 6GCC is free software; you can redistribute it and/or modify
02ba24b7 7it under the terms of the GNU General Public License as published by
2b7d992a 8the Free Software Foundation; either version 3, or (at your option)
02ba24b7
RS
9any later version.
10
b9593599 11GCC is distributed in the hope that it will be useful,
02ba24b7
RS
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
2b7d992a
NC
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
19
02ba24b7 20
4e089a75
ZL
21#ifndef GCC_OBJC_ACT_H
22#define GCC_OBJC_ACT_H
02ba24b7 23
9a4d6480 24/*** Language hooks ***/
02ba24b7 25
011d50d9
AJ
26bool objc_init (void);
27const char *objc_printable_name (tree, int);
744aa42f 28int objc_gimplify_expr (tree *, gimple_seq *, gimple_seq *);
81f653d6 29void objc_common_init_ts (void);
4e089a75 30
6408ef33
ZL
31/* NB: The remaining public functions are prototyped in c-common.h, for the
32 benefit of stub-objc.c and objc-act.c. */
02ba24b7
RS
33
34/* Objective-C structures */
35
668ea4b1
IS
36#define CLASS_LANG_SLOT_ELTS 7
37#define PROTOCOL_LANG_SLOT_ELTS 7
035e8f01 38#define OBJC_INFO_SLOT_ELTS 2
264fa2db 39
02ba24b7 40/* KEYWORD_DECL */
820cc88f
DB
41#define KEYWORD_KEY_NAME(DECL) ((DECL)->decl_minimal.name)
42#define KEYWORD_ARG_NAME(DECL) ((DECL)->decl_non_common.arguments)
02ba24b7
RS
43
44/* INSTANCE_METHOD_DECL, CLASS_METHOD_DECL */
820cc88f
DB
45#define METHOD_SEL_NAME(DECL) ((DECL)->decl_minimal.name)
46#define METHOD_SEL_ARGS(DECL) ((DECL)->decl_non_common.arguments)
47#define METHOD_ADD_ARGS(DECL) ((DECL)->decl_non_common.result)
48#define METHOD_ADD_ARGS_ELLIPSIS_P(DECL) ((DECL)->decl_common.lang_flag_0)
49#define METHOD_DEFINITION(DECL) ((DECL)->decl_common.initial)
50#define METHOD_ENCODING(DECL) ((DECL)->decl_minimal.context)
a1178b30 51#define METHOD_TYPE_ATTRIBUTES(DECL) ((DECL)->decl_common.abstract_origin)
668ea4b1
IS
52#define METHOD_PROPERTY_CONTEXT(DECL) ((DECL)->decl_common.size_unit)
53
46a88c12
NP
54
55/* PROPERTY_DECL. A PROPERTY_DECL repesents a @property declaration
56 (when attached to the list of properties of an interface) or a
57 @synthesize or @dynamic declaration (when attached to the list of
58 properties of an implementation). */
59
60/* TREE_TYPE is the type (int, float, etc) of the property. */
61
43236c26
NP
62/* DECL_ARTIFICIAL is set to 1 if the PROPERTY_DECL is an artificial
63 property declaration created when the dot-syntax object.component
64 is used with no actual @property matching the component, but a
65 valid getter/setter. */
66
46a88c12
NP
67/* PROPERTY_NAME is the name of the property. */
68#define PROPERTY_NAME(DECL) DECL_NAME(DECL)
69
70/* PROPERTY_GETTER_NAME is the identifier of the getter method. */
668ea4b1 71#define PROPERTY_GETTER_NAME(DECL) ((DECL)->decl_non_common.arguments)
46a88c12
NP
72
73/* PROPERTY_SETTER_NAME is the identifier of the setter method. */
668ea4b1 74#define PROPERTY_SETTER_NAME(DECL) ((DECL)->decl_non_common.result)
02ba24b7 75
46a88c12
NP
76/* PROPERTY_READONLY can be 0 or 1. */
77#define PROPERTY_READONLY(DECL) DECL_LANG_FLAG_0 (DECL)
78
79/* PROPERTY_NONATOMIC can be 0 or 1. */
80#define PROPERTY_NONATOMIC(DECL) DECL_LANG_FLAG_1 (DECL)
81
82typedef enum objc_property_assign_semantics {
200290f2
NP
83 OBJC_PROPERTY_ASSIGN = 1,
84 OBJC_PROPERTY_RETAIN = 2,
85 OBJC_PROPERTY_COPY = 3
46a88c12
NP
86} objc_property_assign_semantics;
87
88/* PROPERTY_ASSIGN_SEMANTICS can be OBJC_PROPERTY_ASSIGN,
89 OBJC_PROPERTY_RETAIN or OBJC_PROPERTY_COPY. We need an integer to
90 store it, so we hijack the alignment, that properties don't
91 have. */
92#define PROPERTY_ASSIGN_SEMANTICS(DECL) ((DECL)->decl_common.align)
93
94/* PROPERTY_IVAR_NAME is the identifier of the instance variable.
95 This is set only if the PROPERTY_DECL represents a @synthesize;
96 otherwise, it is set to TREE_NULL. */
97#define PROPERTY_IVAR_NAME(DECL) ((DECL)->decl_common.initial)
98
99/* PROPERTY_DYNAMIC can be 0 or 1. This is 1 if the PROPERTY_DECL
d36dba07 100 represents a @dynamic; otherwise, it is set to 0. */
46a88c12
NP
101#define PROPERTY_DYNAMIC(DECL) DECL_LANG_FLAG_2 (DECL)
102
43236c26
NP
103/* PROPERTY_HAS_NO_GETTER can be 0 or 1. Normally it is 0, but if
104 this is an artificial PROPERTY_DECL that we generate even without a
105 getter, it is set to 1. */
106#define PROPERTY_HAS_NO_GETTER(DECL) DECL_LANG_FLAG_3 (DECL)
107
108/* PROPERTY_HAS_NO_SETTER can be 0 or 1. Normally it is 0, but if
109 this is an artificial PROPERTY_DECL that we generate even without a
110 setter, it is set to 1. */
111#define PROPERTY_HAS_NO_SETTER(DECL) DECL_LANG_FLAG_4 (DECL)
46a88c12 112
2dd24dbd
NP
113/* PROPERTY_OPTIONAL can be 0 or 1. Normally it is 0, but if this is
114 a property declared as @optional in a @protocol, then it is set to
115 1. */
116#define PROPERTY_OPTIONAL(DECL) DECL_LANG_FLAG_5 (DECL)
117
46a88c12 118/* PROPERTY_REF. A PROPERTY_REF represents an 'object.property'
43236c26
NP
119 expression. It is normally used for property access, but when
120 the Objective-C 2.0 "dot-syntax" (object.component) is used
121 with no matching property, a PROPERTY_REF is still created to
122 represent it, with an artificial PROPERTY_DECL. */
46a88c12
NP
123
124/* PROPERTY_REF_OBJECT is the object whose property we are
125 accessing. */
126#define PROPERTY_REF_OBJECT(NODE) TREE_OPERAND (PROPERTY_REF_CHECK (NODE), 0)
127
128/* PROPERTY_REF_PROPERTY_DECL is the PROPERTY_DECL for the property
129 used in the expression. From it, you can get the property type,
43236c26 130 and the getter/setter names. This PROPERTY_DECL could be artificial
944fb799 131 if we are processing an 'object.component' syntax with no matching
43236c26 132 declared property. */
46a88c12
NP
133#define PROPERTY_REF_PROPERTY_DECL(NODE) TREE_OPERAND (PROPERTY_REF_CHECK (NODE), 1)
134
a9625a91
NP
135/* PROPERTY_REF_GETTER_CALL is the getter call expression, ready to
136 use at gimplify time if needed. Generating the getter call
137 requires modifying the selector table, and, in the case of
138 self/super, requires the context to be generated correctly. The
139 gimplify stage is too late to do these things, so we generate the
140 getter call earlier instead, and keep it here in case we need to
141 use it. */
142#define PROPERTY_REF_GETTER_CALL(NODE) TREE_OPERAND (PROPERTY_REF_CHECK (NODE), 2)
143
b4f588c4
NP
144/* PROPERTY_REF_DEPRECATED_GETTER is normally set to NULL_TREE. If
145 the property getter is deprecated, it is set to the method
146 prototype for it, which is used to generate the deprecation warning
147 when the getter is used. */
148#define PROPERTY_REF_DEPRECATED_GETTER(NODE) TREE_OPERAND (PROPERTY_REF_CHECK (NODE), 3)
200290f2 149
2fb31127
TW
150/* CLASS_INTERFACE_TYPE, CLASS_IMPLEMENTATION_TYPE,
151 CATEGORY_INTERFACE_TYPE, CATEGORY_IMPLEMENTATION_TYPE,
152 PROTOCOL_INTERFACE_TYPE */
4ca5d2a7 153/* CLASS_NAME is the name of the class. */
51545682 154#define CLASS_NAME(CLASS) (TYPE_NAME (CLASS))
4ca5d2a7
NP
155/* CLASS_SUPER_NAME is the name of the superclass, or, in the case of
156 categories, it is the name of the category itself. */
51545682 157#define CLASS_SUPER_NAME(CLASS) (TYPE_CONTEXT (CLASS))
95b4aca6
NS
158#define CLASS_IVARS(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 0)
159#define CLASS_RAW_IVARS(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 1)
51545682
NF
160#define CLASS_NST_METHODS(CLASS) (TYPE_MINVAL (CLASS))
161#define CLASS_CLS_METHODS(CLASS) (TYPE_MAXVAL (CLASS))
95b4aca6
NS
162#define CLASS_STATIC_TEMPLATE(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 2)
163#define CLASS_CATEGORY_LIST(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 3)
164#define CLASS_PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 4)
668ea4b1 165#define TOTAL_CLASS_RAW_IVARS(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 5)
79d82252 166#define CLASS_HAS_EXCEPTION_ATTR(CLASS) (TYPE_LANG_FLAG_0 (CLASS))
d764a8e6 167
51545682 168#define PROTOCOL_NAME(CLASS) (TYPE_NAME (CLASS))
95b4aca6 169#define PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 0)
51545682
NF
170#define PROTOCOL_NST_METHODS(CLASS) (TYPE_MINVAL (CLASS))
171#define PROTOCOL_CLS_METHODS(CLASS) (TYPE_MAXVAL (CLASS))
95b4aca6 172#define PROTOCOL_FORWARD_DECL(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 1)
f2e6e530 173#define PROTOCOL_DEFINED(CLASS) TREE_USED (CLASS)
92902b1b
IS
174#define PROTOCOL_OPTIONAL_CLS_METHODS(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 2)
175#define PROTOCOL_OPTIONAL_NST_METHODS(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 3)
6408ef33 176
668ea4b1
IS
177/* For CATEGORY_INTERFACE_TYPE, CLASS_INTERFACE_TYPE or PROTOCOL_INTERFACE_TYPE */
178#define CLASS_PROPERTY_DECL(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 6)
179/* For CLASS_IMPLEMENTATION_TYPE or CATEGORY_IMPLEMENTATION_TYPE. */
180#define IMPL_PROPERTY_DECL(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 6)
181
6b192a09
NP
182/* TREE_DEPRECATED is used for a CLASS_INTERFACE_TYPE or PROTOCOL_INTERFACE_TYPE. */
183
184/* TYPE_ATTRIBUTES is used for a CLASS_INTERFACE_TYPE or PROTOCOL_INTERFACE_TYPE. */
185
035e8f01
ZL
186/* ObjC-specific information pertaining to RECORD_TYPEs are stored in
187 the LANG_SPECIFIC structures, which may itself need allocating first. */
38b9c8c3
ZL
188
189/* The following three macros must be overridden (in objcp/objcp-decl.h)
190 for Objective-C++. */
035e8f01 191#define TYPE_OBJC_INFO(TYPE) TYPE_LANG_SPECIFIC (TYPE)->objc_info
38b9c8c3
ZL
192#define SIZEOF_OBJC_TYPE_LANG_SPECIFIC sizeof (struct lang_type)
193#define ALLOC_OBJC_TYPE_LANG_SPECIFIC(NODE) \
194 do { \
766090c2 195 TYPE_LANG_SPECIFIC (NODE) = ggc_cleared_alloc<struct lang_type> (); \
38b9c8c3
ZL
196 } while (0)
197
035e8f01 198#define TYPE_HAS_OBJC_INFO(TYPE) \
38b9c8c3 199 (TYPE_LANG_SPECIFIC (TYPE) && TYPE_OBJC_INFO (TYPE))
035e8f01
ZL
200#define TYPE_OBJC_INTERFACE(TYPE) TREE_VEC_ELT (TYPE_OBJC_INFO (TYPE), 0)
201#define TYPE_OBJC_PROTOCOL_LIST(TYPE) TREE_VEC_ELT (TYPE_OBJC_INFO (TYPE), 1)
202
38b9c8c3 203
035e8f01
ZL
204#define INIT_TYPE_OBJC_INFO(TYPE) \
205 do \
206 { \
207 if (!TYPE_LANG_SPECIFIC (TYPE)) \
38b9c8c3
ZL
208 ALLOC_OBJC_TYPE_LANG_SPECIFIC(TYPE); \
209 if (!TYPE_OBJC_INFO (TYPE)) \
210 TYPE_OBJC_INFO (TYPE) \
035e8f01
ZL
211 = make_tree_vec (OBJC_INFO_SLOT_ELTS); \
212 } \
213 while (0)
d764a8e6 214
035e8f01
ZL
215#define DUP_TYPE_OBJC_INFO(DST, SRC) \
216 do \
217 { \
38b9c8c3 218 ALLOC_OBJC_TYPE_LANG_SPECIFIC(DST); \
035e8f01
ZL
219 if (TYPE_LANG_SPECIFIC (SRC)) \
220 memcpy (TYPE_LANG_SPECIFIC (DST), \
221 TYPE_LANG_SPECIFIC (SRC), \
222 SIZEOF_OBJC_TYPE_LANG_SPECIFIC); \
38b9c8c3 223 TYPE_OBJC_INFO (DST) \
035e8f01
ZL
224 = make_tree_vec (OBJC_INFO_SLOT_ELTS); \
225 } \
226 while (0)
227
035e8f01
ZL
228#define TYPED_OBJECT(TYPE) \
229 (TREE_CODE (TYPE) == RECORD_TYPE \
230 && TYPE_HAS_OBJC_INFO (TYPE) \
231 && TYPE_OBJC_INTERFACE (TYPE))
232#define OBJC_TYPE_NAME(TYPE) TYPE_NAME(TYPE)
233#define OBJC_SET_TYPE_NAME(TYPE, NAME) (TYPE_NAME (TYPE) = NAME)
8607f1bc
ZL
234
235/* Hash tables to manage the global pool of method prototypes. */
236
237typedef struct hashed_entry *hash;
238typedef struct hashed_attribute *attr;
239
d1b38208 240struct GTY(()) hashed_attribute {
8607f1bc
ZL
241 attr next;
242 tree value;
243};
d764a8e6 244
d1b38208 245struct GTY(()) hashed_entry {
8607f1bc
ZL
246 attr list;
247 hash next;
248 tree key;
249};
250
d764a8e6
IS
251#define SIZEHASHTABLE 257
252
6c39e757
NP
253/* An array of all the local variables in the current function that
254 need to be marked as volatile. */
9771b263 255extern GTY(()) vec<tree, va_gc> *local_variables_to_volatilize;
6c39e757 256
8607f1bc
ZL
257/* Objective-C/Objective-C++ @implementation list. */
258
d1b38208 259struct GTY(()) imp_entry {
8607f1bc
ZL
260 struct imp_entry *next;
261 tree imp_context;
262 tree imp_template;
d764a8e6
IS
263 tree class_decl; /* _OBJC[_v2]_CLASS/CATEGORY_<my_name>; */
264 tree meta_decl; /* _OBJC[_v2]_METACLASS_<my_name>; */
38b9c8c3 265 BOOL_BITFIELD has_cxx_cdtors : 1;
8607f1bc
ZL
266};
267
e2500fed 268extern GTY(()) struct imp_entry *imp_list;
6408ef33
ZL
269extern GTY(()) int imp_count; /* `@implementation' */
270extern GTY(()) int cat_count; /* `@category' */
271
c37d8c30 272extern GTY(()) objc_ivar_visibility_kind objc_ivar_visibility;
8607f1bc
ZL
273
274/* Objective-C/Objective-C++ global tree enumeration. */
275
276enum objc_tree_index
277{
278 OCTI_STATIC_NST,
279 OCTI_STATIC_NST_DECL,
280 OCTI_SELF_ID,
281 OCTI_UCMD_ID,
8607f1bc
ZL
282
283 OCTI_SELF_DECL,
284 OCTI_UMSG_DECL,
38b9c8c3 285 OCTI_UMSG_FAST_DECL,
8607f1bc 286 OCTI_UMSG_SUPER_DECL,
264fa2db
ZL
287 OCTI_UMSG_STRET_DECL,
288 OCTI_UMSG_SUPER_STRET_DECL,
8607f1bc
ZL
289 OCTI_GET_CLASS_DECL,
290 OCTI_GET_MCLASS_DECL,
291 OCTI_SUPER_TYPE,
292 OCTI_SEL_TYPE,
293 OCTI_ID_TYPE,
294 OCTI_CLS_TYPE,
295 OCTI_NST_TYPE,
296 OCTI_PROTO_TYPE,
297
8607f1bc
ZL
298 OCTI_INTF_CHAIN,
299 OCTI_PROTO_CHAIN,
300 OCTI_IMPL_CHAIN,
301 OCTI_CLS_REF_CHAIN,
302 OCTI_SEL_REF_CHAIN,
303 OCTI_IVAR_CHAIN,
304 OCTI_CLS_NAMES_CHAIN,
305 OCTI_METH_VAR_NAMES_CHAIN,
306 OCTI_METH_VAR_TYPES_CHAIN,
307
308 OCTI_SYMBOLS_DECL,
309 OCTI_NST_VAR_DECL,
310 OCTI_CLS_VAR_DECL,
311 OCTI_NST_METH_DECL,
312 OCTI_CLS_METH_DECL,
313 OCTI_CLS_DECL,
314 OCTI_MCLS_DECL,
315 OCTI_SEL_TABLE_DECL,
316 OCTI_MODULES_DECL,
6408ef33 317 OCTI_GNU_INIT_DECL,
8607f1bc
ZL
318
319 OCTI_INTF_CTX,
320 OCTI_IMPL_CTX,
321 OCTI_METH_CTX,
322 OCTI_IVAR_CTX,
323
324 OCTI_IMPL_TEMPL,
325 OCTI_CLS_TEMPL,
326 OCTI_CAT_TEMPL,
327 OCTI_UPRIV_REC,
328 OCTI_PROTO_TEMPL,
329 OCTI_SEL_TEMPL,
330 OCTI_UCLS_SUPER_REF,
331 OCTI_UUCLS_SUPER_REF,
332 OCTI_METH_TEMPL,
333 OCTI_IVAR_TEMPL,
38b9c8c3
ZL
334 OCTI_METH_LIST_TEMPL,
335 OCTI_METH_PROTO_LIST_TEMPL,
336 OCTI_IVAR_LIST_TEMPL,
8607f1bc
ZL
337 OCTI_SYMTAB_TEMPL,
338 OCTI_MODULE_TEMPL,
339 OCTI_SUPER_TEMPL,
340 OCTI_OBJ_REF,
6408ef33 341 OCTI_CLS_REF,
8607f1bc
ZL
342 OCTI_METH_PROTO_TEMPL,
343 OCTI_FUNCTION1_TEMPL,
344 OCTI_FUNCTION2_TEMPL,
345
346 OCTI_OBJ_ID,
347 OCTI_CLS_ID,
6408ef33
ZL
348 OCTI_ID_NAME,
349 OCTI_CLASS_NAME,
8607f1bc
ZL
350 OCTI_CNST_STR_ID,
351 OCTI_CNST_STR_TYPE,
352 OCTI_CNST_STR_GLOB_ID,
353 OCTI_STRING_CLASS_DECL,
c64de75f 354 OCTI_INTERNAL_CNST_STR_TYPE,
8607f1bc 355 OCTI_SUPER_DECL,
d764a8e6 356 OCTI_SUPER_SUPERFIELD_ID,
264fa2db
ZL
357 OCTI_UMSG_NONNIL_DECL,
358 OCTI_UMSG_NONNIL_STRET_DECL,
359 OCTI_STORAGE_CLS,
360 OCTI_EXCEPTION_EXTRACT_DECL,
361 OCTI_EXCEPTION_TRY_ENTER_DECL,
362 OCTI_EXCEPTION_TRY_EXIT_DECL,
363 OCTI_EXCEPTION_MATCH_DECL,
364 OCTI_EXCEPTION_THROW_DECL,
365 OCTI_SYNC_ENTER_DECL,
366 OCTI_SYNC_EXIT_DECL,
367 OCTI_SETJMP_DECL,
368 OCTI_EXCDATA_TEMPL,
369 OCTI_STACK_EXCEPTION_DATA_DECL,
370 OCTI_LOCAL_EXCEPTION_DECL,
371 OCTI_RETHROW_EXCEPTION_DECL,
372 OCTI_EVAL_ONCE_DECL,
264fa2db 373 OCTI_CATCH_TYPE,
6408ef33 374 OCTI_EXECCLASS_DECL,
011d50d9 375
38b9c8c3
ZL
376 OCTI_ASSIGN_IVAR_DECL,
377 OCTI_ASSIGN_IVAR_FAST_DECL,
378 OCTI_ASSIGN_GLOBAL_DECL,
379 OCTI_ASSIGN_STRONGCAST_DECL,
380
f05b9d93
NP
381 OCTI_FAST_ENUM_STATE_TEMP,
382 OCTI_ENUM_MUTATION_DECL,
383
8f07a2aa
NP
384 OCTI_GET_PROPERTY_DECL,
385 OCTI_SET_PROPERTY_DECL,
386 OCTI_COPY_STRUCT_DECL,
387 OCTI_GET_PROPERTY_STRUCT_DECL,
388 OCTI_SET_PROPERTY_STRUCT_DECL,
389
d4c433f9 390 /* TODO: Add comment. */
d764a8e6
IS
391 /* "V1" stuff. */
392 OCTI_V1_PROP_LIST_TEMPL,
393 OCTI_V1_PROP_NAME_ATTR_CHAIN,
394
8607f1bc
ZL
395 OCTI_MAX
396};
397
e2500fed 398extern GTY(()) tree objc_global_trees[OCTI_MAX];
8607f1bc
ZL
399
400/* List of classes with list of their static instances. */
401#define objc_static_instances objc_global_trees[OCTI_STATIC_NST]
402
403/* The declaration of the array administrating the static instances. */
404#define static_instances_decl objc_global_trees[OCTI_STATIC_NST_DECL]
405
406/* Some commonly used instances of "identifier_node". */
407
408#define self_id objc_global_trees[OCTI_SELF_ID]
409#define ucmd_id objc_global_trees[OCTI_UCMD_ID]
8607f1bc
ZL
410
411#define self_decl objc_global_trees[OCTI_SELF_DECL]
412#define umsg_decl objc_global_trees[OCTI_UMSG_DECL]
38b9c8c3 413#define umsg_fast_decl objc_global_trees[OCTI_UMSG_FAST_DECL]
8607f1bc 414#define umsg_super_decl objc_global_trees[OCTI_UMSG_SUPER_DECL]
264fa2db
ZL
415#define umsg_stret_decl objc_global_trees[OCTI_UMSG_STRET_DECL]
416#define umsg_super_stret_decl objc_global_trees[OCTI_UMSG_SUPER_STRET_DECL]
8607f1bc
ZL
417#define objc_get_class_decl objc_global_trees[OCTI_GET_CLASS_DECL]
418#define objc_get_meta_class_decl \
419 objc_global_trees[OCTI_GET_MCLASS_DECL]
420
5c234cd7 421#define objc_super_type objc_global_trees[OCTI_SUPER_TYPE]
6408ef33
ZL
422#define objc_selector_type objc_global_trees[OCTI_SEL_TYPE]
423#define objc_object_type objc_global_trees[OCTI_ID_TYPE]
8607f1bc 424#define objc_class_type objc_global_trees[OCTI_CLS_TYPE]
5c234cd7
DA
425#define objc_instance_type objc_global_trees[OCTI_NST_TYPE]
426#define objc_protocol_type objc_global_trees[OCTI_PROTO_TYPE]
8607f1bc
ZL
427
428/* Type checking macros. */
429
035e8f01
ZL
430#define IS_ID(TYPE) \
431 (TREE_CODE (TYPE) == POINTER_TYPE \
432 && (TYPE_MAIN_VARIANT (TREE_TYPE (TYPE)) \
433 == TREE_TYPE (objc_object_type)))
d764a8e6 434
035e8f01
ZL
435#define IS_CLASS(TYPE) \
436 (TREE_CODE (TYPE) == POINTER_TYPE \
437 && (TYPE_MAIN_VARIANT (TREE_TYPE (TYPE)) \
438 == TREE_TYPE (objc_class_type)))
d764a8e6 439
035e8f01
ZL
440#define IS_PROTOCOL_QUALIFIED_UNTYPED(TYPE) \
441 ((IS_ID (TYPE) || IS_CLASS (TYPE)) \
442 && TYPE_HAS_OBJC_INFO (TREE_TYPE (TYPE)) \
443 && TYPE_OBJC_PROTOCOL_LIST (TREE_TYPE (TYPE)))
d764a8e6 444
035e8f01
ZL
445#define IS_SUPER(TYPE) \
446 (TREE_CODE (TYPE) == POINTER_TYPE \
447 && TREE_TYPE (TYPE) == objc_super_template)
8607f1bc 448
8607f1bc
ZL
449#define interface_chain objc_global_trees[OCTI_INTF_CHAIN]
450#define protocol_chain objc_global_trees[OCTI_PROTO_CHAIN]
451#define implemented_classes objc_global_trees[OCTI_IMPL_CHAIN]
452
453/* Chains to manage selectors that are referenced and defined in the
454 module. */
455
456#define cls_ref_chain objc_global_trees[OCTI_CLS_REF_CHAIN] /* Classes referenced. */
457#define sel_ref_chain objc_global_trees[OCTI_SEL_REF_CHAIN] /* Selectors referenced. */
458#define objc_ivar_chain objc_global_trees[OCTI_IVAR_CHAIN]
459
460/* Chains to manage uniquing of strings. */
461
462#define class_names_chain objc_global_trees[OCTI_CLS_NAMES_CHAIN]
463#define meth_var_names_chain objc_global_trees[OCTI_METH_VAR_NAMES_CHAIN]
464#define meth_var_types_chain objc_global_trees[OCTI_METH_VAR_TYPES_CHAIN]
465
466
467/* Backend data declarations. */
468
469#define UOBJC_SYMBOLS_decl objc_global_trees[OCTI_SYMBOLS_DECL]
470#define UOBJC_INSTANCE_VARIABLES_decl objc_global_trees[OCTI_NST_VAR_DECL]
471#define UOBJC_CLASS_VARIABLES_decl objc_global_trees[OCTI_CLS_VAR_DECL]
472#define UOBJC_INSTANCE_METHODS_decl objc_global_trees[OCTI_NST_METH_DECL]
473#define UOBJC_CLASS_METHODS_decl objc_global_trees[OCTI_CLS_METH_DECL]
474#define UOBJC_CLASS_decl objc_global_trees[OCTI_CLS_DECL]
475#define UOBJC_METACLASS_decl objc_global_trees[OCTI_MCLS_DECL]
476#define UOBJC_SELECTOR_TABLE_decl objc_global_trees[OCTI_SEL_TABLE_DECL]
477#define UOBJC_MODULES_decl objc_global_trees[OCTI_MODULES_DECL]
6408ef33 478#define GNU_INIT_decl objc_global_trees[OCTI_GNU_INIT_DECL]
8607f1bc
ZL
479
480/* The following are used when compiling a class implementation.
481 implementation_template will normally be an interface, however if
482 none exists this will be equal to objc_implementation_context...it is
483 set in start_class. */
484
485#define objc_interface_context objc_global_trees[OCTI_INTF_CTX]
486#define objc_implementation_context objc_global_trees[OCTI_IMPL_CTX]
487#define objc_method_context objc_global_trees[OCTI_METH_CTX]
488#define objc_ivar_context objc_global_trees[OCTI_IVAR_CTX]
489
490#define implementation_template objc_global_trees[OCTI_IMPL_TEMPL]
491#define objc_class_template objc_global_trees[OCTI_CLS_TEMPL]
492#define objc_category_template objc_global_trees[OCTI_CAT_TEMPL]
493#define uprivate_record objc_global_trees[OCTI_UPRIV_REC]
494#define objc_protocol_template objc_global_trees[OCTI_PROTO_TEMPL]
495#define objc_selector_template objc_global_trees[OCTI_SEL_TEMPL]
496#define ucls_super_ref objc_global_trees[OCTI_UCLS_SUPER_REF]
497#define uucls_super_ref objc_global_trees[OCTI_UUCLS_SUPER_REF]
498
264fa2db
ZL
499#define umsg_nonnil_decl objc_global_trees[OCTI_UMSG_NONNIL_DECL]
500#define umsg_nonnil_stret_decl objc_global_trees[OCTI_UMSG_NONNIL_STRET_DECL]
501#define objc_storage_class objc_global_trees[OCTI_STORAGE_CLS]
502#define objc_exception_extract_decl \
503 objc_global_trees[OCTI_EXCEPTION_EXTRACT_DECL]
504#define objc_exception_try_enter_decl \
505 objc_global_trees[OCTI_EXCEPTION_TRY_ENTER_DECL]
506#define objc_exception_try_exit_decl \
507 objc_global_trees[OCTI_EXCEPTION_TRY_EXIT_DECL]
508#define objc_exception_match_decl \
509 objc_global_trees[OCTI_EXCEPTION_MATCH_DECL]
510#define objc_exception_throw_decl \
511 objc_global_trees[OCTI_EXCEPTION_THROW_DECL]
512#define objc_sync_enter_decl objc_global_trees[OCTI_SYNC_ENTER_DECL]
513#define objc_sync_exit_decl objc_global_trees[OCTI_SYNC_EXIT_DECL]
514#define objc_exception_data_template \
515 objc_global_trees[OCTI_EXCDATA_TEMPL]
516#define objc_setjmp_decl objc_global_trees[OCTI_SETJMP_DECL]
517#define objc_stack_exception_data \
518 objc_global_trees[OCTI_STACK_EXCEPTION_DATA_DECL]
944fb799
MS
519#define objc_caught_exception objc_global_trees[OCTI_LOCAL_EXCEPTION_DECL]
520#define objc_rethrow_exception objc_global_trees[OCTI_RETHROW_EXCEPTION_DECL]
521#define objc_eval_once objc_global_trees[OCTI_EVAL_ONCE_DECL]
264fa2db
ZL
522#define objc_catch_type objc_global_trees[OCTI_CATCH_TYPE]
523
6408ef33
ZL
524#define execclass_decl objc_global_trees[OCTI_EXECCLASS_DECL]
525
38b9c8c3
ZL
526#define objc_assign_ivar_decl objc_global_trees[OCTI_ASSIGN_IVAR_DECL]
527#define objc_assign_ivar_fast_decl \
528 objc_global_trees[OCTI_ASSIGN_IVAR_FAST_DECL]
529#define objc_assign_global_decl objc_global_trees[OCTI_ASSIGN_GLOBAL_DECL]
530#define objc_assign_strong_cast_decl \
531 objc_global_trees[OCTI_ASSIGN_STRONGCAST_DECL]
532
8607f1bc
ZL
533#define objc_method_template objc_global_trees[OCTI_METH_TEMPL]
534#define objc_ivar_template objc_global_trees[OCTI_IVAR_TEMPL]
38b9c8c3
ZL
535#define objc_method_list_ptr objc_global_trees[OCTI_METH_LIST_TEMPL]
536#define objc_method_proto_list_ptr \
537 objc_global_trees[OCTI_METH_PROTO_LIST_TEMPL]
538#define objc_ivar_list_ptr objc_global_trees[OCTI_IVAR_LIST_TEMPL]
8607f1bc
ZL
539#define objc_symtab_template objc_global_trees[OCTI_SYMTAB_TEMPL]
540#define objc_module_template objc_global_trees[OCTI_MODULE_TEMPL]
541#define objc_super_template objc_global_trees[OCTI_SUPER_TEMPL]
542#define objc_object_reference objc_global_trees[OCTI_OBJ_REF]
6408ef33 543#define objc_class_reference objc_global_trees[OCTI_CLS_REF]
8607f1bc
ZL
544#define objc_method_prototype_template \
545 objc_global_trees[OCTI_METH_PROTO_TEMPL]
546#define function1_template objc_global_trees[OCTI_FUNCTION1_TEMPL]
547#define function2_template objc_global_trees[OCTI_FUNCTION2_TEMPL]
011d50d9 548
8607f1bc
ZL
549#define objc_object_id objc_global_trees[OCTI_OBJ_ID]
550#define objc_class_id objc_global_trees[OCTI_CLS_ID]
6408ef33
ZL
551#define objc_object_name objc_global_trees[OCTI_ID_NAME]
552#define objc_class_name objc_global_trees[OCTI_CLASS_NAME]
d764a8e6
IS
553
554/* Constant string classes. */
8607f1bc
ZL
555#define constant_string_id objc_global_trees[OCTI_CNST_STR_ID]
556#define constant_string_type objc_global_trees[OCTI_CNST_STR_TYPE]
557#define constant_string_global_id \
558 objc_global_trees[OCTI_CNST_STR_GLOB_ID]
559#define string_class_decl objc_global_trees[OCTI_STRING_CLASS_DECL]
c64de75f 560#define internal_const_str_type objc_global_trees[OCTI_INTERNAL_CNST_STR_TYPE]
d764a8e6 561
8607f1bc 562#define UOBJC_SUPER_decl objc_global_trees[OCTI_SUPER_DECL]
d764a8e6
IS
563#define super_superclassfield_id \
564 objc_global_trees[OCTI_SUPER_SUPERFIELD_ID]
565
f05b9d93
NP
566#define objc_fast_enumeration_state_template \
567 objc_global_trees[OCTI_FAST_ENUM_STATE_TEMP]
568#define objc_enumeration_mutation_decl \
569 objc_global_trees[OCTI_ENUM_MUTATION_DECL]
8607f1bc 570
8f07a2aa
NP
571/* Declarations of functions used when synthesizing property
572 accessors. */
d764a8e6
IS
573#define objc_getProperty_decl objc_global_trees[OCTI_GET_PROPERTY_DECL]
574#define objc_setProperty_decl objc_global_trees[OCTI_SET_PROPERTY_DECL]
575#define objc_copyStruct_decl objc_global_trees[OCTI_COPY_STRUCT_DECL]
576#define objc_getPropertyStruct_decl \
577 objc_global_trees[OCTI_GET_PROPERTY_STRUCT_DECL]
578#define objc_setPropertyStruct_decl \
579 objc_global_trees[OCTI_SET_PROPERTY_STRUCT_DECL]
580
d4c433f9 581/* TODO: Add comment. */
d764a8e6
IS
582/* V1 stuff. */
583#define objc_prop_list_ptr objc_global_trees[OCTI_V1_PROP_LIST_TEMPL]
584#define prop_names_attr_chain objc_global_trees[OCTI_V1_PROP_NAME_ATTR_CHAIN]
585
586/* Reserved tag definitions. */
587
588#define OBJECT_TYPEDEF_NAME "id"
589#define CLASS_TYPEDEF_NAME "Class"
590
591#define TAG_OBJECT "objc_object"
592#define TAG_CLASS "objc_class"
593#define TAG_SUPER "objc_super"
594#define TAG_SELECTOR "objc_selector"
595
596#define UTAG_CLASS "_objc_class"
597#define UTAG_IVAR "_objc_ivar"
598#define UTAG_IVAR_LIST "_objc_ivar_list"
599#define UTAG_METHOD "_objc_method"
600#define UTAG_METHOD_LIST "_objc_method_list"
601#define UTAG_CATEGORY "_objc_category"
602#define UTAG_MODULE "_objc_module"
603#define UTAG_SYMTAB "_objc_symtab"
604#define UTAG_SUPER "_objc_super"
605#define UTAG_SELECTOR "_objc_selector"
606
607#define UTAG_PROTOCOL "_objc_protocol"
608#define UTAG_METHOD_PROTOTYPE "_objc_method_prototype"
609#define UTAG_METHOD_PROTOTYPE_LIST "_objc__method_prototype_list"
610
611#define PROTOCOL_OBJECT_CLASS_NAME "Protocol"
612
613#define TAG_EXCEPTIONTHROW "objc_exception_throw"
614#define TAG_SYNCENTER "objc_sync_enter"
615#define TAG_SYNCEXIT "objc_sync_exit"
616
617/* Really should be NeXT private. */
618#define UTAG_EXCDATA "_objc_exception_data"
619
620#define TAG_CXX_CONSTRUCT ".cxx_construct"
621#define TAG_CXX_DESTRUCT ".cxx_destruct"
622
623#define TAG_ENUMERATION_MUTATION "objc_enumerationMutation"
624#define TAG_FAST_ENUMERATION_STATE "__objcFastEnumerationState"
625
626typedef enum string_section
627{
628 class_names, /* class, category, protocol, module names */
629 meth_var_names, /* method and variable names */
630 meth_var_types, /* method and variable type descriptors */
631 prop_names_attr /* property names and their attributes. */
632} string_section;
633
634#define METHOD_DEF 0
635#define METHOD_REF 1
636
d764a8e6 637#define BUFSIZE 1024
8f07a2aa 638
d764a8e6
IS
639#define CLS_FACTORY 0x0001L
640#define CLS_META 0x0002L
641
642/* Runtime metadata flags - ??? apparently unused. */
643
644#define OBJC_MODIFIER_STATIC 0x00000001
645#define OBJC_MODIFIER_FINAL 0x00000002
646#define OBJC_MODIFIER_PUBLIC 0x00000004
647#define OBJC_MODIFIER_PRIVATE 0x00000008
648#define OBJC_MODIFIER_PROTECTED 0x00000010
649#define OBJC_MODIFIER_NATIVE 0x00000020
650#define OBJC_MODIFIER_SYNCHRONIZED 0x00000040
651#define OBJC_MODIFIER_ABSTRACT 0x00000080
652#define OBJC_MODIFIER_VOLATILE 0x00000100
653#define OBJC_MODIFIER_TRANSIENT 0x00000200
654#define OBJC_MODIFIER_NONE_SPECIFIED 0x80000000
655
d764a8e6 656/* Exception handling constructs. We begin by having the parser do most
944fb799 657 of the work and passing us blocks.
d764a8e6
IS
658 This allows us to handle different exceptions implementations. */
659
660/* Stack of open try blocks. */
661
662struct objc_try_context
663{
664 struct objc_try_context *outer;
665
666 /* Statements (or statement lists) as processed by the parser. */
667 tree try_body;
668 tree finally_body;
669
670 /* Some file position locations. */
671 location_t try_locus;
672 location_t end_try_locus;
673 location_t end_catch_locus;
674 location_t finally_locus;
675 location_t end_finally_locus;
676
677 /* A STATEMENT_LIST of CATCH_EXPRs, appropriate for sticking into op1
678 of a TRY_CATCH_EXPR. Even when doing Darwin setjmp. */
679 tree catch_list;
680
681 /* The CATCH_EXPR of an open @catch clause. */
682 tree current_catch;
683
684 /* The VAR_DECL holding __builtin_eh_pointer (or equivalent). */
685 tree caught_decl;
686 tree stack_decl;
687 tree rethrow_decl;
688};
689
690/* A small number of routines used by the FE parser and the runtime code
691 generators. Put here as inlines for efficiency in non-lto builds rather
692 than making them externs. */
693
694extern tree objc_create_temporary_var (tree, const char *);
944fb799 695
d764a8e6
IS
696#define objc_is_object_id(TYPE) (OBJC_TYPE_NAME (TYPE) == objc_object_id)
697#define objc_is_class_id(TYPE) (OBJC_TYPE_NAME (TYPE) == objc_class_id)
698
699/* Retrieve category interface CAT_NAME (if any) associated with CLASS. */
700static inline tree
701lookup_category (tree klass, tree cat_name)
702{
703 tree category = CLASS_CATEGORY_LIST (klass);
704
705 while (category && CLASS_SUPER_NAME (category) != cat_name)
706 category = CLASS_CATEGORY_LIST (category);
707 return category;
708}
709
710/* Count only the fields occurring in T. */
711static inline int
712ivar_list_length (tree t)
713{
714 int count = 0;
715
716 for (; t; t = DECL_CHAIN (t))
717 if (TREE_CODE (t) == FIELD_DECL)
718 ++count;
719
720 return count;
721}
722
723static inline tree
724is_ivar (tree decl_chain, tree ident)
725{
726 for ( ; decl_chain; decl_chain = DECL_CHAIN (decl_chain))
727 if (DECL_NAME (decl_chain) == ident)
728 return decl_chain;
729 return NULL_TREE;
730}
8f07a2aa 731
4e089a75 732#endif /* GCC_OBJC_ACT_H */