1 /* Declarations for objc-act.c.
2 Copyright (C) 1990, 2000, 2001 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC 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 2, or (at your option)
11 GNU CC 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.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 #ifndef GCC_OBJC_ACT_H
22 #define GCC_OBJC_ACT_H
24 /*** Public Interface (procedures) ***/
26 const char *objc_init
PARAMS ((const char *));
27 int objc_decode_option
PARAMS ((int, char **));
28 const char *objc_printable_name
PARAMS ((tree
, int));
32 void finish_file
PARAMS ((void));
33 tree start_class
PARAMS ((enum tree_code
, tree
, tree
, tree
));
34 tree continue_class
PARAMS ((tree
));
35 void finish_class
PARAMS ((tree
));
36 void start_method_def
PARAMS ((tree
));
37 void continue_method_def
PARAMS ((void));
38 void finish_method_def
PARAMS ((void));
39 tree start_protocol
PARAMS ((enum tree_code
, tree
, tree
));
40 void finish_protocol
PARAMS ((tree
));
41 void add_objc_decls
PARAMS ((void));
43 tree is_ivar
PARAMS ((tree
, tree
));
44 int is_private
PARAMS ((tree
));
45 int is_public
PARAMS ((tree
, tree
));
46 tree add_instance_variable
PARAMS ((tree
, int, tree
, tree
, tree
));
47 tree add_class_method
PARAMS ((tree
, tree
));
48 tree add_instance_method
PARAMS ((tree
, tree
));
49 tree get_super_receiver
PARAMS ((void));
50 tree get_class_ivars
PARAMS ((tree
));
51 tree get_class_reference
PARAMS ((tree
));
52 tree get_static_reference
PARAMS ((tree
, tree
));
53 tree get_object_reference
PARAMS ((tree
));
54 tree build_message_expr
PARAMS ((tree
));
55 tree finish_message_expr
PARAMS ((tree
, tree
, tree
));
56 tree build_selector_expr
PARAMS ((tree
));
57 tree build_ivar_reference
PARAMS ((tree
));
58 tree build_keyword_decl
PARAMS ((tree
, tree
, tree
));
59 tree build_method_decl
PARAMS ((enum tree_code
, tree
, tree
, tree
));
60 tree build_protocol_expr
PARAMS ((tree
));
61 tree build_objc_string_object
PARAMS ((tree
));
63 void objc_declare_alias
PARAMS ((tree
, tree
));
64 void objc_declare_class
PARAMS ((tree
));
65 void objc_declare_protocols
PARAMS ((tree
));
67 extern int objc_receiver_context
;
69 /* the following routines are used to implement statically typed objects */
71 int objc_comptypes
PARAMS ((tree
, tree
, int));
72 void objc_check_decl
PARAMS ((tree
));
76 tree build_encode_expr
PARAMS ((tree
));
78 /* Objective-C structures */
81 #define KEYWORD_KEY_NAME(DECL) ((DECL)->decl.name)
82 #define KEYWORD_ARG_NAME(DECL) ((DECL)->decl.arguments)
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)
91 /* CLASS_INTERFACE_TYPE, CLASS_IMPLEMENTATION_TYPE,
92 CATEGORY_INTERFACE_TYPE, CATEGORY_IMPLEMENTATION_TYPE,
93 PROTOCOL_INTERFACE_TYPE */
94 #define CLASS_NAME(CLASS) ((CLASS)->type.name)
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)
102 #define CLASS_PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 4)
103 #define PROTOCOL_NAME(CLASS) ((CLASS)->type.name)
104 #define PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 0)
105 #define PROTOCOL_NST_METHODS(CLASS) ((CLASS)->type.minval)
106 #define PROTOCOL_CLS_METHODS(CLASS) ((CLASS)->type.maxval)
107 #define PROTOCOL_FORWARD_DECL(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 1)
108 #define PROTOCOL_DEFINED(CLASS) TREE_USED (CLASS)
109 #define TYPE_PROTOCOL_LIST(TYPE) ((TYPE)->type.context)
111 /* Set by `continue_class' and checked by `is_public'. */
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))
117 /* Define the Objective-C or Objective-C++ language-specific tree codes. */
119 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
120 enum objc_tree_code
{
122 LAST_BASE_TREE_CODE
= LAST_CPLUS_TREE_CODE
,
124 LAST_BASE_TREE_CODE
= LAST_C_TREE_CODE
,
126 #include "objc-tree.def"
131 /* Hash tables to manage the global pool of method prototypes. */
133 typedef struct hashed_entry
*hash
;
134 typedef struct hashed_attribute
*attr
;
136 struct hashed_attribute
148 extern hash
*nst_method_hash_list
;
149 extern hash
*cls_method_hash_list
;
151 #define HASH_ALLOC_LIST_SIZE 170
152 #define ATTR_ALLOC_LIST_SIZE 170
153 #define SIZEHASHTABLE 257
155 /* Objective-C/Objective-C++ @implementation list. */
159 struct imp_entry
*next
;
162 tree class_decl
; /* _OBJC_CLASS_<my_name>; */
163 tree meta_decl
; /* _OBJC_METACLASS_<my_name>; */
166 extern struct imp_entry
*imp_list
;
167 extern int imp_count
; /* `@implementation' */
168 extern int cat_count
; /* `@category' */
170 /* Objective-C/Objective-C++ global tree enumeration. */
175 OCTI_STATIC_NST_DECL
,
183 OCTI_UMSG_SUPER_DECL
,
185 OCTI_GET_MCLASS_DECL
,
201 OCTI_CLS_NAMES_CHAIN
,
202 OCTI_METH_VAR_NAMES_CHAIN
,
203 OCTI_METH_VAR_TYPES_CHAIN
,
228 OCTI_UUCLS_SUPER_REF
,
235 OCTI_METH_PROTO_TEMPL
,
236 OCTI_FUNCTION1_TEMPL
,
237 OCTI_FUNCTION2_TEMPL
,
244 OCTI_CNST_STR_GLOB_ID
,
245 OCTI_STRING_CLASS_DECL
,
251 extern tree objc_global_trees
[OCTI_MAX
];
253 /* List of classes with list of their static instances. */
254 #define objc_static_instances objc_global_trees[OCTI_STATIC_NST]
256 /* The declaration of the array administrating the static instances. */
257 #define static_instances_decl objc_global_trees[OCTI_STATIC_NST_DECL]
259 /* Some commonly used instances of "identifier_node". */
261 #define self_id objc_global_trees[OCTI_SELF_ID]
262 #define ucmd_id objc_global_trees[OCTI_UCMD_ID]
263 #define unused_list objc_global_trees[OCTI_UNUSED_LIST]
264 #define objc_ellipsis_node objc_global_trees[OCTI_ELLIPSIS_NODE]
266 #define self_decl objc_global_trees[OCTI_SELF_DECL]
267 #define umsg_decl objc_global_trees[OCTI_UMSG_DECL]
268 #define umsg_super_decl objc_global_trees[OCTI_UMSG_SUPER_DECL]
269 #define objc_get_class_decl objc_global_trees[OCTI_GET_CLASS_DECL]
270 #define objc_get_meta_class_decl \
271 objc_global_trees[OCTI_GET_MCLASS_DECL]
273 #define super_type objc_global_trees[OCTI_SUPER_TYPE]
274 #define selector_type objc_global_trees[OCTI_SEL_TYPE]
275 #define id_type objc_global_trees[OCTI_ID_TYPE]
276 #define objc_class_type objc_global_trees[OCTI_CLS_TYPE]
277 #define instance_type objc_global_trees[OCTI_NST_TYPE]
278 #define protocol_type objc_global_trees[OCTI_PROTO_TYPE]
280 /* Type checking macros. */
282 #define IS_ID(TYPE) \
283 (TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (id_type))
284 #define IS_PROTOCOL_QUALIFIED_ID(TYPE) \
285 (IS_ID (TYPE) && TYPE_PROTOCOL_LIST (TYPE))
286 #define IS_SUPER(TYPE) \
287 (super_type && TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (super_type))
289 #define class_chain objc_global_trees[OCTI_CLS_CHAIN]
290 #define alias_chain objc_global_trees[OCTI_ALIAS_CHAIN]
291 #define interface_chain objc_global_trees[OCTI_INTF_CHAIN]
292 #define protocol_chain objc_global_trees[OCTI_PROTO_CHAIN]
293 #define implemented_classes objc_global_trees[OCTI_IMPL_CHAIN]
295 /* Chains to manage selectors that are referenced and defined in the
298 #define cls_ref_chain objc_global_trees[OCTI_CLS_REF_CHAIN] /* Classes referenced. */
299 #define sel_ref_chain objc_global_trees[OCTI_SEL_REF_CHAIN] /* Selectors referenced. */
300 #define objc_ivar_chain objc_global_trees[OCTI_IVAR_CHAIN]
302 /* Chains to manage uniquing of strings. */
304 #define class_names_chain objc_global_trees[OCTI_CLS_NAMES_CHAIN]
305 #define meth_var_names_chain objc_global_trees[OCTI_METH_VAR_NAMES_CHAIN]
306 #define meth_var_types_chain objc_global_trees[OCTI_METH_VAR_TYPES_CHAIN]
309 /* Backend data declarations. */
311 #define UOBJC_SYMBOLS_decl objc_global_trees[OCTI_SYMBOLS_DECL]
312 #define UOBJC_INSTANCE_VARIABLES_decl objc_global_trees[OCTI_NST_VAR_DECL]
313 #define UOBJC_CLASS_VARIABLES_decl objc_global_trees[OCTI_CLS_VAR_DECL]
314 #define UOBJC_INSTANCE_METHODS_decl objc_global_trees[OCTI_NST_METH_DECL]
315 #define UOBJC_CLASS_METHODS_decl objc_global_trees[OCTI_CLS_METH_DECL]
316 #define UOBJC_CLASS_decl objc_global_trees[OCTI_CLS_DECL]
317 #define UOBJC_METACLASS_decl objc_global_trees[OCTI_MCLS_DECL]
318 #define UOBJC_SELECTOR_TABLE_decl objc_global_trees[OCTI_SEL_TABLE_DECL]
319 #define UOBJC_MODULES_decl objc_global_trees[OCTI_MODULES_DECL]
320 #define UOBJC_STRINGS_decl objc_global_trees[OCTI_STRG_DECL]
322 /* The following are used when compiling a class implementation.
323 implementation_template will normally be an interface, however if
324 none exists this will be equal to objc_implementation_context...it is
325 set in start_class. */
327 #define objc_interface_context objc_global_trees[OCTI_INTF_CTX]
328 #define objc_implementation_context objc_global_trees[OCTI_IMPL_CTX]
329 #define objc_method_context objc_global_trees[OCTI_METH_CTX]
330 #define objc_ivar_context objc_global_trees[OCTI_IVAR_CTX]
332 #define implementation_template objc_global_trees[OCTI_IMPL_TEMPL]
333 #define objc_class_template objc_global_trees[OCTI_CLS_TEMPL]
334 #define objc_category_template objc_global_trees[OCTI_CAT_TEMPL]
335 #define uprivate_record objc_global_trees[OCTI_UPRIV_REC]
336 #define objc_protocol_template objc_global_trees[OCTI_PROTO_TEMPL]
337 #define objc_selector_template objc_global_trees[OCTI_SEL_TEMPL]
338 #define ucls_super_ref objc_global_trees[OCTI_UCLS_SUPER_REF]
339 #define uucls_super_ref objc_global_trees[OCTI_UUCLS_SUPER_REF]
341 #define objc_method_template objc_global_trees[OCTI_METH_TEMPL]
342 #define objc_ivar_template objc_global_trees[OCTI_IVAR_TEMPL]
343 #define objc_symtab_template objc_global_trees[OCTI_SYMTAB_TEMPL]
344 #define objc_module_template objc_global_trees[OCTI_MODULE_TEMPL]
345 #define objc_super_template objc_global_trees[OCTI_SUPER_TEMPL]
346 #define objc_object_reference objc_global_trees[OCTI_OBJ_REF]
347 #define objc_method_prototype_template \
348 objc_global_trees[OCTI_METH_PROTO_TEMPL]
349 #define function1_template objc_global_trees[OCTI_FUNCTION1_TEMPL]
350 #define function2_template objc_global_trees[OCTI_FUNCTION2_TEMPL]
352 #define objc_object_id objc_global_trees[OCTI_OBJ_ID]
353 #define objc_class_id objc_global_trees[OCTI_CLS_ID]
354 #define objc_id_id objc_global_trees[OCTI_ID_ID]
355 #define constant_string_id objc_global_trees[OCTI_CNST_STR_ID]
356 #define constant_string_type objc_global_trees[OCTI_CNST_STR_TYPE]
357 #define constant_string_global_id \
358 objc_global_trees[OCTI_CNST_STR_GLOB_ID]
359 #define string_class_decl objc_global_trees[OCTI_STRING_CLASS_DECL]
360 #define UOBJC_SUPER_decl objc_global_trees[OCTI_SUPER_DECL]
362 #endif /* GCC_OBJC_ACT_H */