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