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