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