diff options
author | shebs <shebs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-10-03 22:05:57 +0000 |
---|---|---|
committer | shebs <shebs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-10-03 22:05:57 +0000 |
commit | 99ff41609b678c4b1b24b40c2f459db54a694dfe (patch) | |
tree | a9086dda614a021f61ce4b8b7024b034cf3e5ecc /gcc/objc | |
parent | 6fc632f6b524b4e35d7f625d94b2f87cbec48c85 (diff) | |
download | gcc-99ff41609b678c4b1b24b40c2f459db54a694dfe.tar.gz |
2001-10-03 Ziemowit Laski <zlaski@apple.com>
* c-parse.in (objc_inherit_code, objc_pq_context,
objc_public_flag): Make static.
(objc_interface_context, objc_implementation_context,
objc_method_context, objc_ivar_chain, objc_ivar_context): Move to
global tree array in objc/objc-act.[ch].
(methoddef): Remove unnecessary code.
* objc/objc-act.c: (hashed_attribute, hashed_entry, imp_entry):
Hoist struct definitions to objc-act.h.
(nst_method_hash_list, cls_method_hash_list, imp_list, imp_count,
cat_count): Place declaration in objc-act.h.
(objc_tree_index): Move enumeration to objc-act.h.
(objc_global_trees): Place declaration and macro accessors in
objc-act.h.
(implementation_context): Remove duplicate; use
objc_implementation_context instead:
(method_context): Remove duplicate; use objc_method_context
instead.
(objc_ellipsis_node, objc_method_prototype_template,
implemented_classes, function_type): Move global vars to
objc_global_trees.
(init_objc): Use LAST_BASE_TREE_CODE instead of LAST_CODE.
(build_message_expr): Move actual construction of ObjC message
send nodes to finish_message_expr.
(finish_message_expr): New routine, contains code formerly in
build_message_expr.
* objc/objc-act.h (finish_message_expr): New prototype.
(objc_ivar_chain, objc_method_context, objc_ellipsis_node): Remove
declarations; these vars are now part of objc_global_trees.
(objc_tree_index, objc_global_trees): Move definitions from
objc-act.c.
* objc/objc-tree.def: Update copyright info.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46000 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/objc')
-rw-r--r-- | gcc/objc/objc-act.c | 566 | ||||
-rw-r--r-- | gcc/objc/objc-act.h | 247 | ||||
-rw-r--r-- | gcc/objc/objc-tree.def | 5 |
3 files changed, 417 insertions, 401 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 1a2cd91dd27..c1e99d075ec 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -148,9 +148,6 @@ char *util_firstobj; #define OBJC_ENCODE_INLINE_DEFS 0 #define OBJC_ENCODE_DONT_INLINE_DEFS 1 -/* Needed to help fix missing @end situations. */ -extern tree objc_implementation_context; - /*** Private Interface (procedures) ***/ /* Used by compile_file. */ @@ -209,22 +206,10 @@ static const char *objc_demangle PARAMS ((const char *)); static const char *objc_printable_name PARAMS ((tree, int)); static void objc_expand_function_end PARAMS ((void)); -/* Misc. bookkeeping */ - -typedef struct hashed_entry *hash; -typedef struct hashed_attribute *attr; +/* Hash tables to manage the global pool of method prototypes. */ -struct hashed_attribute -{ - attr next; - tree value; -}; -struct hashed_entry -{ - attr list; - hash next; - tree key; -}; +hash *nst_method_hash_list = 0; +hash *cls_method_hash_list = 0; static void hash_init PARAMS ((void)); static void hash_enter PARAMS ((hash *, tree)); @@ -398,203 +383,17 @@ static const char *TAG_MSGSEND; static const char *TAG_MSGSENDSUPER; static const char *TAG_EXECCLASS; -/* Set by `continue_class' and checked by `is_public'. */ - -#define TREE_STATIC_TEMPLATE(record_type) (TREE_PUBLIC (record_type)) -#define TYPED_OBJECT(type) \ - (TREE_CODE (type) == RECORD_TYPE && TREE_STATIC_TEMPLATE (type)) - -tree objc_ellipsis_node; - -enum objc_tree_index -{ - OCTI_STATIC_NST, - OCTI_STATIC_NST_DECL, - OCTI_SELF_ID, - OCTI_UCMD_ID, - OCTI_UNUSED_LIST, - OCTI_SELF_DECL, - OCTI_UMSG_DECL, - OCTI_UMSG_SUPER_DECL, - OCTI_GET_CLASS_DECL, - OCTI_GET_MCLASS_DECL, - OCTI_SUPER_TYPE, - OCTI_SEL_TYPE, - OCTI_ID_TYPE, - OCTI_CLS_TYPE, - OCTI_NST_TYPE, - OCTI_PROTO_TYPE, - - OCTI_CLS_CHAIN, - OCTI_ALIAS_CHAIN, - OCTI_INTF_CHAIN, - OCTI_PROTO_CHAIN, - OCTI_CLS_REF_CHAIN, - OCTI_SEL_REF_CHAIN, - OCTI_CLS_NAMES_CHAIN, - OCTI_METH_VAR_NAMES_CHAIN, - OCTI_METH_VAR_TYPES_CHAIN, - - OCTI_SYMBOLS_DECL, - OCTI_NST_VAR_DECL, - OCTI_CLS_VAR_DECL, - OCTI_NST_METH_DECL, - OCTI_CLS_METH_DECL, - OCTI_CLS_DECL, - OCTI_MCLS_DECL, - OCTI_SEL_TABLE_DECL, - OCTI_MODULES_DECL, - OCTI_STRG_DECL, - - OCTI_IMPL_CTX, - OCTI_IMPL_TEMPL, - - OCTI_CLS_TEMPL, - OCTI_CAT_TEMPL, - OCTI_UPRIV_REC, - OCTI_PROTO_TEMPL, - OCTI_SEL_TEMPL, - OCTI_UCLS_SUPER_REF, - OCTI_UUCLS_SUPER_REF, - OCTI_METH_TEMPL, - OCTI_IVAR_TEMPL, - OCTI_SYMTAB_TEMPL, - OCTI_MODULE_TEMPL, - OCTI_SUPER_TEMPL, - OCTI_OBJ_REF, - OCTI_OBJ_ID, - OCTI_CLS_ID, - OCTI_ID_ID, - OCTI_CNST_STR_ID, - OCTI_CNST_STR_TYPE, - OCTI_CNST_STR_GLOB_ID, - OCTI_STRING_CLASS_DECL, - OCTI_SUPER_DECL, - OCTI_METH_CTX, - - OCTI_MAX -}; - -static tree objc_global_trees[OCTI_MAX]; - -/* List of classes with list of their static instances. */ -#define objc_static_instances objc_global_trees[OCTI_STATIC_NST] - -/* The declaration of the array administrating the static instances. */ -#define static_instances_decl objc_global_trees[OCTI_STATIC_NST_DECL] - -/* Some commonly used instances of "identifier_node". */ +/* The OCTI_... enumeration itself in in objc/objc-act.h. */ +tree objc_global_trees[OCTI_MAX]; -#define self_id objc_global_trees[OCTI_SELF_ID] -#define ucmd_id objc_global_trees[OCTI_UCMD_ID] -#define unused_list objc_global_trees[OCTI_UNUSED_LIST] - -#define self_decl objc_global_trees[OCTI_SELF_DECL] -#define umsg_decl objc_global_trees[OCTI_UMSG_DECL] -#define umsg_super_decl objc_global_trees[OCTI_UMSG_SUPER_DECL] -#define objc_get_class_decl objc_global_trees[OCTI_GET_CLASS_DECL] -#define objc_get_meta_class_decl \ - objc_global_trees[OCTI_GET_MCLASS_DECL] - -#define super_type objc_global_trees[OCTI_SUPER_TYPE] -#define selector_type objc_global_trees[OCTI_SEL_TYPE] -#define id_type objc_global_trees[OCTI_ID_TYPE] -#define objc_class_type objc_global_trees[OCTI_CLS_TYPE] -#define instance_type objc_global_trees[OCTI_NST_TYPE] -#define protocol_type objc_global_trees[OCTI_PROTO_TYPE] - -/* Type checking macros. */ - -#define IS_ID(TYPE) \ - (TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (id_type)) -#define IS_PROTOCOL_QUALIFIED_ID(TYPE) \ - (IS_ID (TYPE) && TYPE_PROTOCOL_LIST (TYPE)) -#define IS_SUPER(TYPE) \ - (super_type && TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (super_type)) - -#define class_chain objc_global_trees[OCTI_CLS_CHAIN] -#define alias_chain objc_global_trees[OCTI_ALIAS_CHAIN] -#define interface_chain objc_global_trees[OCTI_INTF_CHAIN] -#define protocol_chain objc_global_trees[OCTI_PROTO_CHAIN] - -/* Chains to manage selectors that are referenced and defined in the - module. */ - -#define cls_ref_chain objc_global_trees[OCTI_CLS_REF_CHAIN] /* Classes referenced. */ -#define sel_ref_chain objc_global_trees[OCTI_SEL_REF_CHAIN] /* Selectors referenced. */ - -/* Chains to manage uniquing of strings. */ - -#define class_names_chain objc_global_trees[OCTI_CLS_NAMES_CHAIN] -#define meth_var_names_chain objc_global_trees[OCTI_METH_VAR_NAMES_CHAIN] -#define meth_var_types_chain objc_global_trees[OCTI_METH_VAR_TYPES_CHAIN] - -/* Hash tables to manage the global pool of method prototypes. */ - -static hash *nst_method_hash_list = 0; -static hash *cls_method_hash_list = 0; - -/* Backend data declarations. */ - -#define UOBJC_SYMBOLS_decl objc_global_trees[OCTI_SYMBOLS_DECL] -#define UOBJC_INSTANCE_VARIABLES_decl objc_global_trees[OCTI_NST_VAR_DECL] -#define UOBJC_CLASS_VARIABLES_decl objc_global_trees[OCTI_CLS_VAR_DECL] -#define UOBJC_INSTANCE_METHODS_decl objc_global_trees[OCTI_NST_METH_DECL] -#define UOBJC_CLASS_METHODS_decl objc_global_trees[OCTI_CLS_METH_DECL] -#define UOBJC_CLASS_decl objc_global_trees[OCTI_CLS_DECL] -#define UOBJC_METACLASS_decl objc_global_trees[OCTI_MCLS_DECL] -#define UOBJC_SELECTOR_TABLE_decl objc_global_trees[OCTI_SEL_TABLE_DECL] -#define UOBJC_MODULES_decl objc_global_trees[OCTI_MODULES_DECL] -#define UOBJC_STRINGS_decl objc_global_trees[OCTI_STRG_DECL] - -/* The following are used when compiling a class implementation. - implementation_template will normally be an interface, however if - none exists this will be equal to implementation_context...it is - set in start_class. */ - -#define implementation_context objc_global_trees[OCTI_IMPL_CTX] -#define implementation_template objc_global_trees[OCTI_IMPL_TEMPL] - -struct imp_entry -{ - struct imp_entry *next; - tree imp_context; - tree imp_template; - tree class_decl; /* _OBJC_CLASS_<my_name>; */ - tree meta_decl; /* _OBJC_METACLASS_<my_name>; */ -}; +int objc_receiver_context; static void handle_impent PARAMS ((struct imp_entry *)); -static struct imp_entry *imp_list = 0; -static int imp_count = 0; /* `@implementation' */ -static int cat_count = 0; /* `@category' */ - -#define objc_class_template objc_global_trees[OCTI_CLS_TEMPL] -#define objc_category_template objc_global_trees[OCTI_CAT_TEMPL] -#define uprivate_record objc_global_trees[OCTI_UPRIV_REC] -#define objc_protocol_template objc_global_trees[OCTI_PROTO_TEMPL] -#define objc_selector_template objc_global_trees[OCTI_SEL_TEMPL] -#define ucls_super_ref objc_global_trees[OCTI_UCLS_SUPER_REF] -#define uucls_super_ref objc_global_trees[OCTI_UUCLS_SUPER_REF] - -#define objc_method_template objc_global_trees[OCTI_METH_TEMPL] -#define objc_ivar_template objc_global_trees[OCTI_IVAR_TEMPL] -#define objc_symtab_template objc_global_trees[OCTI_SYMTAB_TEMPL] -#define objc_module_template objc_global_trees[OCTI_MODULE_TEMPL] -#define objc_super_template objc_global_trees[OCTI_SUPER_TEMPL] -#define objc_object_reference objc_global_trees[OCTI_OBJ_REF] - -#define objc_object_id objc_global_trees[OCTI_OBJ_ID] -#define objc_class_id objc_global_trees[OCTI_CLS_ID] -#define objc_id_id objc_global_trees[OCTI_ID_ID] -#define constant_string_id objc_global_trees[OCTI_CNST_STR_ID] -#define constant_string_type objc_global_trees[OCTI_CNST_STR_TYPE] -#define constant_string_global_id objc_global_trees[OCTI_CNST_STR_GLOB_ID] -#define string_class_decl objc_global_trees[OCTI_STRING_CLASS_DECL] -#define UOBJC_SUPER_decl objc_global_trees[OCTI_SUPER_DECL] - -#define method_context objc_global_trees[OCTI_METH_CTX] +struct imp_entry *imp_list = 0; +int imp_count = 0; /* `@implementation' */ +int cat_count = 0; /* `@category' */ + static int method_slot = 0; /* Used by start_method_def, */ #define BUFSIZE 1024 @@ -1753,20 +1552,20 @@ static void forward_declare_categories () { struct imp_entry *impent; - tree sav = implementation_context; + tree sav = objc_implementation_context; for (impent = imp_list; impent; impent = impent->next) { if (TREE_CODE (impent->imp_context) == CATEGORY_IMPLEMENTATION_TYPE) { /* Set an invisible arg to synth_id_with_class_suffix. */ - implementation_context = impent->imp_context; + objc_implementation_context = impent->imp_context; impent->class_decl = create_builtin_decl (VAR_DECL, objc_category_template, - IDENTIFIER_POINTER (synth_id_with_class_suffix ("_OBJC_CATEGORY", implementation_context))); + IDENTIFIER_POINTER (synth_id_with_class_suffix ("_OBJC_CATEGORY", objc_implementation_context))); } } - implementation_context = sav; + objc_implementation_context = sav; } /* Create the declaration of _OBJC_SYMBOLS, with type `strict _objc_symtab' @@ -3012,7 +2811,6 @@ static void generate_method_descriptors (protocol) /* generate_dispatch_tables */ tree protocol; { - static tree objc_method_prototype_template; tree initlist, chain, method_list_template; tree cast, variable_length_type; int size; @@ -3020,7 +2818,6 @@ generate_method_descriptors (protocol) /* generate_dispatch_tables */ if (!objc_method_prototype_template) { objc_method_prototype_template = build_method_prototype_template (); - ggc_add_tree_root (&objc_method_prototype_template, 1); } cast = build_tree_list (build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE, @@ -3617,7 +3414,7 @@ synth_forward_declarations () /* extern struct objc_class _OBJC_CLASS_<my_name>; */ - an_id = synth_id_with_class_suffix ("_OBJC_CLASS", implementation_context); + an_id = synth_id_with_class_suffix ("_OBJC_CLASS", objc_implementation_context); sc_spec = build_tree_list (NULL_TREE, ridpointers[(int) RID_EXTERN]); decl_specs = tree_cons (NULL_TREE, objc_class_template, sc_spec); @@ -3628,7 +3425,7 @@ synth_forward_declarations () /* extern struct objc_class _OBJC_METACLASS_<my_name>; */ an_id = synth_id_with_class_suffix ("_OBJC_METACLASS", - implementation_context); + objc_implementation_context); UOBJC_METACLASS_decl = define_decl (an_id, decl_specs); TREE_USED (UOBJC_METACLASS_decl) = 1; @@ -3957,7 +3754,7 @@ generate_ivars_list (type, name, size, list) sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE); decl_specs = tree_cons (NULL_TREE, type, sc_spec); - decl = start_decl (synth_id_with_class_suffix (name, implementation_context), + decl = start_decl (synth_id_with_class_suffix (name, objc_implementation_context), decl_specs, 1, NULL_TREE); initlist = build_tree_list (NULL_TREE, build_int_2 (size, 0)); @@ -4122,7 +3919,7 @@ generate_dispatch_table (type, name, size, list) sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE); decl_specs = tree_cons (NULL_TREE, type, sc_spec); - decl = start_decl (synth_id_with_class_suffix (name, implementation_context), + decl = start_decl (synth_id_with_class_suffix (name, objc_implementation_context), decl_specs, 1, NULL_TREE); initlist = build_tree_list (NULL_TREE, build_int_2 (0, 0)); @@ -4155,7 +3952,7 @@ generate_dispatch_tables () variable_length_type = groktypename (cast); - chain = CLASS_CLS_METHODS (implementation_context); + chain = CLASS_CLS_METHODS (objc_implementation_context); if (chain) { size = list_length (chain); @@ -4167,7 +3964,7 @@ generate_dispatch_tables () UOBJC_CLASS_METHODS_decl = generate_dispatch_table (method_list_template, - ((TREE_CODE (implementation_context) + ((TREE_CODE (objc_implementation_context) == CLASS_IMPLEMENTATION_TYPE) ? "_OBJC_CLASS_METHODS" : "_OBJC_CATEGORY_CLASS_METHODS"), @@ -4177,7 +3974,7 @@ generate_dispatch_tables () else UOBJC_CLASS_METHODS_decl = 0; - chain = CLASS_NST_METHODS (implementation_context); + chain = CLASS_NST_METHODS (objc_implementation_context); if (chain) { size = list_length (chain); @@ -4187,7 +3984,7 @@ generate_dispatch_tables () initlist = build_dispatch_table_initializer (objc_method_template, chain); - if (TREE_CODE (implementation_context) == CLASS_IMPLEMENTATION_TYPE) + if (TREE_CODE (objc_implementation_context) == CLASS_IMPLEMENTATION_TYPE) UOBJC_INSTANCE_METHODS_decl = generate_dispatch_table (method_list_template, "_OBJC_INSTANCE_METHODS", @@ -4490,7 +4287,7 @@ generate_category (cat) decl_specs = tree_cons (NULL_TREE, objc_category_template, sc_spec); decl = start_decl (synth_id_with_class_suffix ("_OBJC_CATEGORY", - implementation_context), + objc_implementation_context), decl_specs, 1, NULL_TREE); initlist = build_category_initializer (TREE_TYPE (decl), @@ -4619,7 +4416,7 @@ synth_id_with_class_suffix (preamble, ctxt) || TREE_CODE (ctxt) == CLASS_INTERFACE_TYPE) { const char *const class_name - = IDENTIFIER_POINTER (CLASS_NAME (implementation_context)); + = IDENTIFIER_POINTER (CLASS_NAME (objc_implementation_context)); string = (char *) alloca (strlen (preamble) + strlen (class_name) + 3); sprintf (string, "%s_%s", preamble, IDENTIFIER_POINTER (CLASS_NAME (ctxt))); @@ -4629,9 +4426,9 @@ synth_id_with_class_suffix (preamble, ctxt) { /* We have a category. */ const char *const class_name - = IDENTIFIER_POINTER (CLASS_NAME (implementation_context)); + = IDENTIFIER_POINTER (CLASS_NAME (objc_implementation_context)); const char *const class_super_name - = IDENTIFIER_POINTER (CLASS_SUPER_NAME (implementation_context)); + = IDENTIFIER_POINTER (CLASS_SUPER_NAME (objc_implementation_context)); string = (char *) alloca (strlen (preamble) + strlen (class_name) + strlen (class_super_name) @@ -4819,8 +4616,8 @@ build_method_decl (code, ret_type, selector, add_args) #define METHOD_DEF 0 #define METHOD_REF 1 -/* Used by `build_message_expr' and `comp_method_types'. Return an - argument list for method METH. CONTEXT is either METHOD_DEF or +/* Used by `build_objc_method_call' and `comp_method_types'. Return + an argument list for method METH. CONTEXT is either METHOD_DEF or METHOD_REF, saying whether we are trying to define a method or call one. SUPERFLAG says this is for a send to super; this makes a difference for the NeXT calling sequence in which the lookup and @@ -4973,57 +4770,14 @@ build_message_expr (mess) tree mess; { tree receiver = TREE_PURPOSE (mess); - tree selector, self_object; - tree rtype, sel_name; + tree sel_name; tree args = TREE_VALUE (mess); tree method_params = NULL_TREE; - tree method_prototype = NULL_TREE; - tree retval; - int statically_typed = 0, statically_allocated = 0; - tree class_ident = 0; - - /* 1 if this is sending to the superclass. */ - int super; if (TREE_CODE (receiver) == ERROR_MARK) return error_mark_node; - /* Determine receiver type. */ - rtype = TREE_TYPE (receiver); - super = IS_SUPER (rtype); - - if (! super) - { - if (TREE_STATIC_TEMPLATE (rtype)) - statically_allocated = 1; - else if (TREE_CODE (rtype) == POINTER_TYPE - && TREE_STATIC_TEMPLATE (TREE_TYPE (rtype))) - statically_typed = 1; - else if ((flag_next_runtime - || (TREE_CODE (receiver) == CALL_EXPR && IS_ID (rtype))) - && (class_ident = receiver_is_class_object (receiver))) - ; - else if (! IS_ID (rtype) - /* Allow any type that matches objc_class_type. */ - && ! comptypes (rtype, objc_class_type)) - { - warning ("invalid receiver type `%s'", - gen_declaration (rtype, errbuf)); - } - - if (statically_allocated) - receiver = build_unary_op (ADDR_EXPR, receiver, 0); - - /* Don't evaluate the receiver twice. */ - receiver = save_expr (receiver); - self_object = receiver; - } - else - /* If sending to `super', use current self as the object. */ - self_object = self_decl; - /* Obtain the full selector name. */ - if (TREE_CODE (args) == IDENTIFIER_NODE) /* A unary selector. */ sel_name = args; @@ -5033,8 +4787,6 @@ build_message_expr (mess) abort (); /* Build the parameter list to give to the method. */ - - method_params = NULL_TREE; if (TREE_CODE (args) == TREE_LIST) { tree chain = args, prev = NULL_TREE; @@ -5058,9 +4810,58 @@ build_message_expr (mess) method_params = args; } + return finish_message_expr (receiver, sel_name, method_params); +} + +/* The 'finish_message_expr' routine is called from within + 'build_message_expr' for non-template functions. In the case of + C++ template functions, it is called from 'build_expr_from_tree' + (in decl2.c) after RECEIVER and METHOD_PARAMS have been expanded. */ + +tree +finish_message_expr (receiver, sel_name, method_params) + tree receiver, sel_name, method_params; +{ + tree method_prototype = NULL_TREE, class_ident = NULL_TREE; + tree selector, self_object, retval; + int statically_typed = 0, statically_allocated = 0; + + /* Determine receiver type. */ + tree rtype = TREE_TYPE (receiver); + int super = IS_SUPER (rtype); + + if (! super) + { + if (TREE_STATIC_TEMPLATE (rtype)) + statically_allocated = 1; + else if (TREE_CODE (rtype) == POINTER_TYPE + && TREE_STATIC_TEMPLATE (TREE_TYPE (rtype))) + statically_typed = 1; + else if ((flag_next_runtime + || (TREE_CODE (receiver) == CALL_EXPR && IS_ID (rtype))) + && (class_ident = receiver_is_class_object (receiver))) + ; + else if (! IS_ID (rtype) + /* Allow any type that matches objc_class_type. */ + && ! comptypes (rtype, objc_class_type)) + { + warning ("invalid receiver type `%s'", + gen_declaration (rtype, errbuf)); + } + if (statically_allocated) + receiver = build_unary_op (ADDR_EXPR, receiver, 0); + + /* Don't evaluate the receiver twice. */ + receiver = save_expr (receiver); + self_object = receiver; + } + else + /* If sending to `super', use current self as the object. */ + self_object = self_decl; + /* Determine operation return type. */ - if (IS_SUPER (rtype)) + if (super) { tree iface; @@ -5069,7 +4870,7 @@ build_message_expr (mess) iface = lookup_interface (CLASS_SUPER_NAME (implementation_template)); - if (TREE_CODE (method_context) == INSTANCE_METHOD_DECL) + if (TREE_CODE (objc_method_context) == INSTANCE_METHOD_DECL) method_prototype = lookup_instance_method_static (iface, sel_name); else method_prototype = lookup_class_method_static (iface, sel_name); @@ -5111,8 +4912,8 @@ build_message_expr (mess) /* `self' is now statically_typed. All methods should be visible within the context of the implementation. */ - if (implementation_context - && CLASS_NAME (implementation_context) == TYPE_NAME (ctype)) + if (objc_implementation_context + && CLASS_NAME (objc_implementation_context) == TYPE_NAME (ctype)) { method_prototype = lookup_instance_method_static (implementation_template, @@ -5124,11 +4925,11 @@ build_message_expr (mess) sel_name, 0); if (! method_prototype - && implementation_template != implementation_context) + && implementation_template != objc_implementation_context) /* The method is not published in the interface. Check locally. */ method_prototype - = lookup_method (CLASS_NST_METHODS (implementation_context), + = lookup_method (CLASS_NST_METHODS (objc_implementation_context), sel_name); } else @@ -5155,18 +4956,18 @@ build_message_expr (mess) } else if (class_ident) { - if (implementation_context - && CLASS_NAME (implementation_context) == class_ident) + if (objc_implementation_context + && CLASS_NAME (objc_implementation_context) == class_ident) { method_prototype = lookup_class_method_static (implementation_template, sel_name); if (!method_prototype - && implementation_template != implementation_context) + && implementation_template != objc_implementation_context) /* The method is not published in the interface. Check locally. */ method_prototype - = lookup_method (CLASS_CLS_METHODS (implementation_context), + = lookup_method (CLASS_CLS_METHODS (objc_implementation_context), sel_name); } else @@ -5284,12 +5085,12 @@ build_objc_method_call (super_flag, method_prototype, lookup_object, object, Clobber the data type of SENDER temporarily to accept all the arguments for this operation, and to return whatever this operation returns. */ - tree arglist = NULL_TREE; - tree retval; + tree arglist = NULL_TREE, retval, savarg, savret; + tree ret_type = groktypename (TREE_TYPE (method_prototype)); /* Save the proper contents of SENDER's data type. */ - tree savarg = TYPE_ARG_TYPES (TREE_TYPE (sender)); - tree savret = TREE_TYPE (TREE_TYPE (sender)); + savarg = TYPE_ARG_TYPES (TREE_TYPE (sender)); + savret = TREE_TYPE (TREE_TYPE (sender)); /* Install this method's argument types. */ arglist = get_arg_type_list (method_prototype, METHOD_REF, @@ -5297,8 +5098,7 @@ build_objc_method_call (super_flag, method_prototype, lookup_object, object, TYPE_ARG_TYPES (TREE_TYPE (sender)) = arglist; /* Install this method's return type. */ - TREE_TYPE (TREE_TYPE (sender)) - = groktypename (TREE_TYPE (method_prototype)); + TREE_TYPE (TREE_TYPE (sender)) = ret_type; /* Call SENDER with all the parameters. This will do type checking using the arg types for this method. */ @@ -5456,7 +5256,7 @@ tree build_ivar_reference (id) tree id; { - if (TREE_CODE (method_context) == CLASS_METHOD_DECL) + if (TREE_CODE (objc_method_context) == CLASS_METHOD_DECL) { /* Historically, a class method that produced objects (factory method) would assign `self' to the instance that it @@ -5474,12 +5274,7 @@ build_ivar_reference (id) return build_component_ref (build_indirect_ref (self_decl, "->"), id); } - -#define HASH_ALLOC_LIST_SIZE 170 -#define ATTR_ALLOC_LIST_SIZE 170 -#define SIZEHASHTABLE 257 - -/* make positive */ +/* Make the hash value positive. */ #define HASHFUNCTION(key) ((size_t) key & 0x7fffffff) static void @@ -5921,12 +5716,12 @@ is_public (expr, identifier) /* Important difference between the Stepstone translator: all instance variables should be public within the context of the implementation. */ - if (implementation_context - && (((TREE_CODE (implementation_context) + if (objc_implementation_context + && (((TREE_CODE (objc_implementation_context) == CLASS_IMPLEMENTATION_TYPE) - || (TREE_CODE (implementation_context) + || (TREE_CODE (objc_implementation_context) == CATEGORY_IMPLEMENTATION_TYPE)) - && (CLASS_NAME (implementation_context) + && (CLASS_NAME (objc_implementation_context) == TYPE_NAME (basetype)))) return ! is_private (decl); @@ -5937,7 +5732,7 @@ is_public (expr, identifier) } } - else if (implementation_context && (basetype == objc_object_reference)) + else if (objc_implementation_context && (basetype == objc_object_reference)) { TREE_TYPE (expr) = uprivate_record; warning ("static access to object of type `id'"); @@ -5975,14 +5770,14 @@ check_methods (chain, list, mtype) { if (first) { - if (TREE_CODE (implementation_context) + if (TREE_CODE (objc_implementation_context) == CLASS_IMPLEMENTATION_TYPE) warning ("incomplete implementation of class `%s'", - IDENTIFIER_POINTER (CLASS_NAME (implementation_context))); - else if (TREE_CODE (implementation_context) + IDENTIFIER_POINTER (CLASS_NAME (objc_implementation_context))); + else if (TREE_CODE (objc_implementation_context) == CATEGORY_IMPLEMENTATION_TYPE) warning ("incomplete implementation of category `%s'", - IDENTIFIER_POINTER (CLASS_SUPER_NAME (implementation_context))); + IDENTIFIER_POINTER (CLASS_SUPER_NAME (objc_implementation_context))); first = 0; } @@ -6068,16 +5863,16 @@ check_methods_accessible (chain, context, mtype) { if (first) { - if (TREE_CODE (implementation_context) + if (TREE_CODE (objc_implementation_context) == CLASS_IMPLEMENTATION_TYPE) warning ("incomplete implementation of class `%s'", IDENTIFIER_POINTER - (CLASS_NAME (implementation_context))); - else if (TREE_CODE (implementation_context) + (CLASS_NAME (objc_implementation_context))); + else if (TREE_CODE (objc_implementation_context) == CATEGORY_IMPLEMENTATION_TYPE) warning ("incomplete implementation of category `%s'", IDENTIFIER_POINTER - (CLASS_SUPER_NAME (implementation_context))); + (CLASS_SUPER_NAME (objc_implementation_context))); first = 0; } warning ("method definition for `%c%s' not found", @@ -6090,7 +5885,7 @@ check_methods_accessible (chain, context, mtype) } /* Check whether the current interface (accessible via - 'implementation_context') actually implements protocol P, along + 'objc_implementation_context') actually implements protocol P, along with any protocols that P inherits. */ static void @@ -6107,19 +5902,19 @@ check_protocol (p, type, name) if (flag_warn_protocol) { f1 = check_methods (PROTOCOL_CLS_METHODS (p), - CLASS_CLS_METHODS (implementation_context), + CLASS_CLS_METHODS (objc_implementation_context), '+'); f2 = check_methods (PROTOCOL_NST_METHODS (p), - CLASS_NST_METHODS (implementation_context), + CLASS_NST_METHODS (objc_implementation_context), '-'); } else { f1 = check_methods_accessible (PROTOCOL_CLS_METHODS (p), - implementation_context, + objc_implementation_context, '+'); f2 = check_methods_accessible (PROTOCOL_NST_METHODS (p), - implementation_context, + objc_implementation_context, '-'); } @@ -6148,7 +5943,7 @@ check_protocol (p, type, name) } /* Check whether the current interface (accessible via - 'implementation_context') actually implements the protocols listed + 'objc_implementation_context') actually implements the protocols listed in PROTO_LIST. */ static void @@ -6204,11 +5999,8 @@ start_class (code, class_name, super_name, protocol_list) if (code == CLASS_IMPLEMENTATION_TYPE) { { - static tree implemented_classes = 0; tree chain; - if (!implemented_classes) - ggc_add_tree_root (&implemented_classes, 1); for (chain = implemented_classes; chain; chain = TREE_CHAIN (chain)) if (TREE_VALUE (chain) == class_name) { @@ -6234,7 +6026,7 @@ start_class (code, class_name, super_name, protocol_list) /* Reset for multiple classes per file. */ method_slot = 0; - implementation_context = class; + objc_implementation_context = class; /* Lookup the interface for this implementation. */ @@ -6242,7 +6034,7 @@ start_class (code, class_name, super_name, protocol_list) { warning ("Cannot find interface declaration for `%s'", IDENTIFIER_POINTER (class_name)); - add_class (implementation_template = implementation_context); + add_class (implementation_template = objc_implementation_context); } /* If a super class has been specified in the implementation, @@ -6261,7 +6053,7 @@ start_class (code, class_name, super_name, protocol_list) else if (! super_name) { - CLASS_SUPER_NAME (implementation_context) + CLASS_SUPER_NAME (objc_implementation_context) = CLASS_SUPER_NAME (implementation_template); } } @@ -6317,7 +6109,7 @@ start_class (code, class_name, super_name, protocol_list) /* Reset for multiple classes per file. */ method_slot = 0; - implementation_context = class; + objc_implementation_context = class; /* For a category, class_name is really the name of the class that the following set of methods will be associated with. We must @@ -6405,18 +6197,18 @@ finish_class (class) { /* All code generation is done in finish_objc. */ - if (implementation_template != implementation_context) + if (implementation_template != objc_implementation_context) { /* Ensure that all method listed in the interface contain bodies. */ check_methods (CLASS_CLS_METHODS (implementation_template), - CLASS_CLS_METHODS (implementation_context), '+'); + CLASS_CLS_METHODS (objc_implementation_context), '+'); check_methods (CLASS_NST_METHODS (implementation_template), - CLASS_NST_METHODS (implementation_context), '-'); + CLASS_NST_METHODS (objc_implementation_context), '-'); if (CLASS_PROTOCOL_LIST (implementation_template)) check_protocols (CLASS_PROTOCOL_LIST (implementation_template), "class", - IDENTIFIER_POINTER (CLASS_NAME (implementation_context))); + IDENTIFIER_POINTER (CLASS_NAME (objc_implementation_context))); } } @@ -6436,14 +6228,14 @@ finish_class (class) { /* Ensure all method listed in the interface contain bodies. */ check_methods (CLASS_CLS_METHODS (category), - CLASS_CLS_METHODS (implementation_context), '+'); + CLASS_CLS_METHODS (objc_implementation_context), '+'); check_methods (CLASS_NST_METHODS (category), - CLASS_NST_METHODS (implementation_context), '-'); + CLASS_NST_METHODS (objc_implementation_context), '-'); if (CLASS_PROTOCOL_LIST (category)) check_protocols (CLASS_PROTOCOL_LIST (category), "category", - IDENTIFIER_POINTER (CLASS_SUPER_NAME (implementation_context))); + IDENTIFIER_POINTER (CLASS_SUPER_NAME (objc_implementation_context))); } } @@ -7042,7 +6834,7 @@ start_method_def (method) tree decl_specs; /* Required to implement _msgSuper. */ - method_context = method; + objc_method_context = method; UOBJC_SUPER_decl = NULL_TREE; /* Must be called BEFORE start_function. */ @@ -7050,7 +6842,7 @@ start_method_def (method) /* Generate prototype declarations for arguments..."new-style". */ - if (TREE_CODE (method_context) == INSTANCE_METHOD_DECL) + if (TREE_CODE (objc_method_context) == INSTANCE_METHOD_DECL) decl_specs = build_tree_list (NULL_TREE, uprivate_record); else /* Really a `struct objc_class *'. However, we allow people to @@ -7145,22 +6937,17 @@ static int comp_method_with_proto (method, proto) tree method, proto; { - static tree function_type = 0; - - /* Create a function_type node once. */ - if (!function_type) - { - function_type = make_node (FUNCTION_TYPE); - ggc_add_tree_root (&function_type, 1); - } + /* Create a function template node at most once. */ + if (!function1_template) + function1_template = make_node (FUNCTION_TYPE); /* Install argument types - normally set by build_function_type. */ - TYPE_ARG_TYPES (function_type) = get_arg_type_list (proto, METHOD_DEF, 0); + TYPE_ARG_TYPES (function1_template) = get_arg_type_list (proto, METHOD_DEF, 0); /* install return type */ - TREE_TYPE (function_type) = groktypename (TREE_TYPE (proto)); + TREE_TYPE (function1_template) = groktypename (TREE_TYPE (proto)); - return comptypes (TREE_TYPE (METHOD_DEFINITION (method)), function_type); + return comptypes (TREE_TYPE (METHOD_DEFINITION (method)), function1_template); } /* Return 1 if PROTO1 is consistent with PROTO2. */ @@ -7169,25 +6956,21 @@ static int comp_proto_with_proto (proto0, proto1) tree proto0, proto1; { - static tree function_type[2]; - - /* Create a couple function_type node's once. */ - if (!function_type[0]) - { - function_type[0] = make_node (FUNCTION_TYPE); - function_type[1] = make_node (FUNCTION_TYPE); - ggc_add_tree_root (function_type, 2); - } + /* Create a couple of function_template nodes at most once. */ + if (!function1_template) + function1_template = make_node (FUNCTION_TYPE); + if (!function2_template) + function2_template = make_node (FUNCTION_TYPE); /* Install argument types; normally set by build_function_type. */ - TYPE_ARG_TYPES (function_type[0]) = get_arg_type_list (proto0, METHOD_REF, 0); - TYPE_ARG_TYPES (function_type[1]) = get_arg_type_list (proto1, METHOD_REF, 0); + TYPE_ARG_TYPES (function1_template) = get_arg_type_list (proto0, METHOD_REF, 0); + TYPE_ARG_TYPES (function2_template) = get_arg_type_list (proto1, METHOD_REF, 0); /* Install return type. */ - TREE_TYPE (function_type[0]) = groktypename (TREE_TYPE (proto0)); - TREE_TYPE (function_type[1]) = groktypename (TREE_TYPE (proto1)); + TREE_TYPE (function1_template) = groktypename (TREE_TYPE (proto0)); + TREE_TYPE (function2_template) = groktypename (TREE_TYPE (proto1)); - return comptypes (function_type[0], function_type[1]); + return comptypes (function1_template, function2_template); } /* - Generate an identifier for the function. the format is "_n_cls", @@ -7211,11 +6994,11 @@ really_start_method (method, parmlist) decl_specs = chainon (sc_spec, ret_spec); sel_name = IDENTIFIER_POINTER (METHOD_SEL_NAME (method)); - class_name = IDENTIFIER_POINTER (CLASS_NAME (implementation_context)); - cat_name = ((TREE_CODE (implementation_context) + class_name = IDENTIFIER_POINTER (CLASS_NAME (objc_implementation_context)); + cat_name = ((TREE_CODE (objc_implementation_context) == CLASS_IMPLEMENTATION_TYPE) ? NULL - : IDENTIFIER_POINTER (CLASS_SUPER_NAME (implementation_context))); + : IDENTIFIER_POINTER (CLASS_SUPER_NAME (objc_implementation_context))); method_slot++; /* Make sure this is big enough for any plausible method label. */ @@ -7261,7 +7044,7 @@ really_start_method (method, parmlist) /* Check consistency...start_function, pushdecl, duplicate_decls. */ - if (implementation_template != implementation_context) + if (implementation_template != objc_implementation_context) { tree proto; @@ -7292,7 +7075,7 @@ continue_method_def () { tree parmlist; - if (METHOD_ADD_ARGS (method_context) == objc_ellipsis_node) + if (METHOD_ADD_ARGS (objc_method_context) == objc_ellipsis_node) /* We have a `, ...' immediately following the selector. */ parmlist = get_parm_info (0); else @@ -7303,7 +7086,7 @@ continue_method_def () self_decl = TREE_PURPOSE (parmlist); poplevel (0, 0, 0); - really_start_method (method_context, parmlist); + really_start_method (objc_method_context, parmlist); store_parm_decls (); } @@ -7336,7 +7119,7 @@ add_objc_decls () tree get_super_receiver () { - if (method_context) + if (objc_method_context) { tree super_expr, super_expr_list; @@ -7349,13 +7132,13 @@ get_super_receiver () super_expr = build_component_ref (UOBJC_SUPER_decl, get_identifier ("class")); - if (TREE_CODE (implementation_context) == CLASS_IMPLEMENTATION_TYPE) + if (TREE_CODE (objc_implementation_context) == CLASS_IMPLEMENTATION_TYPE) { /* [_cls, __cls]Super are "pre-built" in synth_forward_declarations. */ super_expr = build_modify_expr (super_expr, NOP_EXPR, - ((TREE_CODE (method_context) + ((TREE_CODE (objc_method_context) == INSTANCE_METHOD_DECL) ? ucls_super_ref : uucls_super_ref)); @@ -7378,7 +7161,7 @@ get_super_receiver () if (flag_next_runtime) { super_class = get_class_reference (super_name); - if (TREE_CODE (method_context) == CLASS_METHOD_DECL) + if (TREE_CODE (objc_method_context) == CLASS_METHOD_DECL) super_class = build_component_ref (build_indirect_ref (super_class, "->"), get_identifier ("isa")); @@ -7386,7 +7169,7 @@ get_super_receiver () else { add_class_reference (super_name); - super_class = (TREE_CODE (method_context) == INSTANCE_METHOD_DECL + super_class = (TREE_CODE (objc_method_context) == INSTANCE_METHOD_DECL ? objc_get_class_decl : objc_get_meta_class_decl); assemble_external (super_class); super_class @@ -7476,7 +7259,7 @@ encode_method_def (func_decl) static void objc_expand_function_end () { - METHOD_ENCODING (method_context) = encode_method_def (current_function_decl); + METHOD_ENCODING (objc_method_context) = encode_method_def (current_function_decl); } void @@ -7488,7 +7271,7 @@ finish_method_def () /* Required to implement _msgSuper. This must be done AFTER finish_function, since the optimizer may find "may be used before set" errors. */ - method_context = NULL_TREE; + objc_method_context = NULL_TREE; } #if 0 @@ -7496,10 +7279,10 @@ int lang_report_error_function (decl) tree decl; { - if (method_context) + if (objc_method_context) { fprintf (stderr, "In method `%s'\n", - IDENTIFIER_POINTER (METHOD_SEL_NAME (method_context))); + IDENTIFIER_POINTER (METHOD_SEL_NAME (objc_method_context))); return 1; } @@ -8256,20 +8039,18 @@ init_objc () { /* Add the special tree codes of Objective C to the tables. */ -#define LAST_CODE LAST_C_TREE_CODE - gcc_obstack_init (&util_obstack); util_firstobj = (char *) obstack_finish (&util_obstack); - memcpy (tree_code_type + (int) LAST_CODE, + memcpy (tree_code_type + (int) LAST_BASE_TREE_CODE, objc_tree_code_type, - (int) LAST_OBJC_TREE_CODE - (int) LAST_CODE); - memcpy (tree_code_length + (int) LAST_CODE, + (int) LAST_OBJC_TREE_CODE - (int) LAST_BASE_TREE_CODE); + memcpy (tree_code_length + (int) LAST_BASE_TREE_CODE, objc_tree_code_length, - (((int) LAST_OBJC_TREE_CODE - (int) LAST_CODE) * sizeof (int))); - memcpy (tree_code_name + (int) LAST_CODE, + (((int) LAST_OBJC_TREE_CODE - (int) LAST_BASE_TREE_CODE) * sizeof (int))); + memcpy (tree_code_name + (int) LAST_BASE_TREE_CODE, objc_tree_code_name, - (((int) LAST_OBJC_TREE_CODE - (int) LAST_CODE) * sizeof (char *))); + (((int) LAST_OBJC_TREE_CODE - (int) LAST_BASE_TREE_CODE) * sizeof (char *))); errbuf = (char *)xmalloc (BUFSIZE); hash_init (); @@ -8298,7 +8079,7 @@ finish_objc () if (objc_implementation_context) { warning ("`@end' missing in implementation context"); - finish_class (implementation_context); + finish_class (objc_implementation_context); objc_ivar_chain = NULL_TREE; objc_implementation_context = NULL_TREE; } @@ -8314,19 +8095,19 @@ finish_objc () if (objc_static_instances) generate_static_references (); - if (implementation_context || class_names_chain + if (objc_implementation_context || class_names_chain || meth_var_names_chain || meth_var_types_chain || sel_ref_chain) generate_objc_symtab_decl (); for (impent = imp_list; impent; impent = impent->next) { - implementation_context = impent->imp_context; + objc_implementation_context = impent->imp_context; implementation_template = impent->imp_template; UOBJC_CLASS_decl = impent->class_decl; UOBJC_METACLASS_decl = impent->meta_decl; - if (TREE_CODE (implementation_context) == CLASS_IMPLEMENTATION_TYPE) + if (TREE_CODE (objc_implementation_context) == CLASS_IMPLEMENTATION_TYPE) { /* all of the following reference the string pool... */ generate_ivar_lists (); @@ -8336,7 +8117,7 @@ finish_objc () else { generate_dispatch_tables (); - generate_category (implementation_context); + generate_category (objc_implementation_context); } } @@ -8348,7 +8129,7 @@ finish_objc () if (protocol_chain) generate_protocols (); - if (implementation_context || class_names_chain || objc_static_instances + if (objc_implementation_context || class_names_chain || objc_static_instances || meth_var_names_chain || meth_var_types_chain || sel_ref_chain) { /* Arrange for Objc data structures to be initialized at run time. */ @@ -8378,8 +8159,8 @@ finish_objc () if (flag_gen_declaration) { - add_class (implementation_context); - dump_interface (gen_declaration_file, implementation_context); + add_class (objc_implementation_context); + dump_interface (gen_declaration_file, objc_implementation_context); } if (warn_selector) @@ -8501,7 +8282,7 @@ handle_impent (impent) { char *string; - implementation_context = impent->imp_context; + objc_implementation_context = impent->imp_context; implementation_template = impent->imp_template; if (TREE_CODE (impent->imp_context) == CLASS_IMPLEMENTATION_TYPE) @@ -8593,7 +8374,6 @@ ggc_mark_hash_table (arg) static void objc_act_parse_init () { - ggc_add_tree_root (&objc_ellipsis_node, 1); ggc_add_tree_root (objc_global_trees, OCTI_MAX); ggc_add_root (&imp_list, 1, sizeof imp_list, ggc_mark_imp_list); ggc_add_root (&nst_method_hash_list, 1, sizeof nst_method_hash_list, ggc_mark_hash_table); diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h index e659f916525..2825970a3dc 100644 --- a/gcc/objc/objc-act.h +++ b/gcc/objc/objc-act.h @@ -46,6 +46,7 @@ tree get_class_reference PARAMS ((tree)); tree get_static_reference PARAMS ((tree, tree)); tree get_object_reference PARAMS ((tree)); tree build_message_expr PARAMS ((tree)); +tree finish_message_expr PARAMS ((tree, tree, tree)); tree build_selector_expr PARAMS ((tree)); tree build_ivar_reference PARAMS ((tree)); tree build_keyword_decl PARAMS ((tree, tree, tree)); @@ -53,10 +54,6 @@ tree build_method_decl PARAMS ((enum tree_code, tree, tree, tree)); tree build_protocol_expr PARAMS ((tree)); tree build_objc_string_object PARAMS ((tree)); -extern tree objc_ivar_chain; -extern tree objc_method_context; -extern tree objc_ellipsis_node; - void objc_declare_alias PARAMS ((tree, tree)); void objc_declare_class PARAMS ((tree)); void objc_declare_protocols PARAMS ((tree)); @@ -105,16 +102,254 @@ tree build_encode_expr PARAMS ((tree)); #define PROTOCOL_DEFINED(CLASS) TREE_USED (CLASS) #define TYPE_PROTOCOL_LIST(TYPE) ((TYPE)->type.context) +/* Set by `continue_class' and checked by `is_public'. */ + +#define TREE_STATIC_TEMPLATE(record_type) (TREE_PUBLIC (record_type)) +#define TYPED_OBJECT(type) \ + (TREE_CODE (type) == RECORD_TYPE && TREE_STATIC_TEMPLATE (type)) + /* Define the Objective-C or Objective-C++ language-specific tree codes. */ #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM, enum objc_tree_code { #ifdef OBJCPLUS - dummy_tree_code = LAST_CPLUS_TREE_CODE, + LAST_BASE_TREE_CODE = LAST_CPLUS_TREE_CODE, #else - dummy_tree_code = LAST_C_TREE_CODE, + LAST_BASE_TREE_CODE = LAST_C_TREE_CODE, #endif #include "objc-tree.def" LAST_OBJC_TREE_CODE }; #undef DEFTREECODE + +/* Hash tables to manage the global pool of method prototypes. */ + +typedef struct hashed_entry *hash; +typedef struct hashed_attribute *attr; + +struct hashed_attribute +{ + attr next; + tree value; +}; +struct hashed_entry +{ + attr list; + hash next; + tree key; +}; + +extern hash *nst_method_hash_list; +extern hash *cls_method_hash_list; + +#define HASH_ALLOC_LIST_SIZE 170 +#define ATTR_ALLOC_LIST_SIZE 170 +#define SIZEHASHTABLE 257 + +/* Objective-C/Objective-C++ @implementation list. */ + +struct imp_entry +{ + struct imp_entry *next; + tree imp_context; + tree imp_template; + tree class_decl; /* _OBJC_CLASS_<my_name>; */ + tree meta_decl; /* _OBJC_METACLASS_<my_name>; */ +}; + +extern struct imp_entry *imp_list; +extern int imp_count; /* `@implementation' */ +extern int cat_count; /* `@category' */ + +/* Objective-C/Objective-C++ global tree enumeration. */ + +enum objc_tree_index +{ + OCTI_STATIC_NST, + OCTI_STATIC_NST_DECL, + OCTI_SELF_ID, + OCTI_UCMD_ID, + OCTI_UNUSED_LIST, + OCTI_ELLIPSIS_NODE, + + OCTI_SELF_DECL, + OCTI_UMSG_DECL, + OCTI_UMSG_SUPER_DECL, + OCTI_GET_CLASS_DECL, + OCTI_GET_MCLASS_DECL, + OCTI_SUPER_TYPE, + OCTI_SEL_TYPE, + OCTI_ID_TYPE, + OCTI_CLS_TYPE, + OCTI_NST_TYPE, + OCTI_PROTO_TYPE, + + OCTI_CLS_CHAIN, + OCTI_ALIAS_CHAIN, + OCTI_INTF_CHAIN, + OCTI_PROTO_CHAIN, + OCTI_IMPL_CHAIN, + OCTI_CLS_REF_CHAIN, + OCTI_SEL_REF_CHAIN, + OCTI_IVAR_CHAIN, + OCTI_CLS_NAMES_CHAIN, + OCTI_METH_VAR_NAMES_CHAIN, + OCTI_METH_VAR_TYPES_CHAIN, + + OCTI_SYMBOLS_DECL, + OCTI_NST_VAR_DECL, + OCTI_CLS_VAR_DECL, + OCTI_NST_METH_DECL, + OCTI_CLS_METH_DECL, + OCTI_CLS_DECL, + OCTI_MCLS_DECL, + OCTI_SEL_TABLE_DECL, + OCTI_MODULES_DECL, + OCTI_STRG_DECL, + + OCTI_INTF_CTX, + OCTI_IMPL_CTX, + OCTI_METH_CTX, + OCTI_IVAR_CTX, + + OCTI_IMPL_TEMPL, + OCTI_CLS_TEMPL, + OCTI_CAT_TEMPL, + OCTI_UPRIV_REC, + OCTI_PROTO_TEMPL, + OCTI_SEL_TEMPL, + OCTI_UCLS_SUPER_REF, + OCTI_UUCLS_SUPER_REF, + OCTI_METH_TEMPL, + OCTI_IVAR_TEMPL, + OCTI_SYMTAB_TEMPL, + OCTI_MODULE_TEMPL, + OCTI_SUPER_TEMPL, + OCTI_OBJ_REF, + OCTI_METH_PROTO_TEMPL, + OCTI_FUNCTION1_TEMPL, + OCTI_FUNCTION2_TEMPL, + + OCTI_OBJ_ID, + OCTI_CLS_ID, + OCTI_ID_ID, + OCTI_CNST_STR_ID, + OCTI_CNST_STR_TYPE, + OCTI_CNST_STR_GLOB_ID, + OCTI_STRING_CLASS_DECL, + OCTI_SUPER_DECL, + + OCTI_MAX +}; + +extern tree objc_global_trees[OCTI_MAX]; + +/* List of classes with list of their static instances. */ +#define objc_static_instances objc_global_trees[OCTI_STATIC_NST] + +/* The declaration of the array administrating the static instances. */ +#define static_instances_decl objc_global_trees[OCTI_STATIC_NST_DECL] + +/* Some commonly used instances of "identifier_node". */ + +#define self_id objc_global_trees[OCTI_SELF_ID] +#define ucmd_id objc_global_trees[OCTI_UCMD_ID] +#define unused_list objc_global_trees[OCTI_UNUSED_LIST] +#define objc_ellipsis_node objc_global_trees[OCTI_ELLIPSIS_NODE] + +#define self_decl objc_global_trees[OCTI_SELF_DECL] +#define umsg_decl objc_global_trees[OCTI_UMSG_DECL] +#define umsg_super_decl objc_global_trees[OCTI_UMSG_SUPER_DECL] +#define objc_get_class_decl objc_global_trees[OCTI_GET_CLASS_DECL] +#define objc_get_meta_class_decl \ + objc_global_trees[OCTI_GET_MCLASS_DECL] + +#define super_type objc_global_trees[OCTI_SUPER_TYPE] +#define selector_type objc_global_trees[OCTI_SEL_TYPE] +#define id_type objc_global_trees[OCTI_ID_TYPE] +#define objc_class_type objc_global_trees[OCTI_CLS_TYPE] +#define instance_type objc_global_trees[OCTI_NST_TYPE] +#define protocol_type objc_global_trees[OCTI_PROTO_TYPE] + +/* Type checking macros. */ + +#define IS_ID(TYPE) \ + (TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (id_type)) +#define IS_PROTOCOL_QUALIFIED_ID(TYPE) \ + (IS_ID (TYPE) && TYPE_PROTOCOL_LIST (TYPE)) +#define IS_SUPER(TYPE) \ + (super_type && TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (super_type)) + +#define class_chain objc_global_trees[OCTI_CLS_CHAIN] +#define alias_chain objc_global_trees[OCTI_ALIAS_CHAIN] +#define interface_chain objc_global_trees[OCTI_INTF_CHAIN] +#define protocol_chain objc_global_trees[OCTI_PROTO_CHAIN] +#define implemented_classes objc_global_trees[OCTI_IMPL_CHAIN] + +/* Chains to manage selectors that are referenced and defined in the + module. */ + +#define cls_ref_chain objc_global_trees[OCTI_CLS_REF_CHAIN] /* Classes referenced. */ +#define sel_ref_chain objc_global_trees[OCTI_SEL_REF_CHAIN] /* Selectors referenced. */ +#define objc_ivar_chain objc_global_trees[OCTI_IVAR_CHAIN] + +/* Chains to manage uniquing of strings. */ + +#define class_names_chain objc_global_trees[OCTI_CLS_NAMES_CHAIN] +#define meth_var_names_chain objc_global_trees[OCTI_METH_VAR_NAMES_CHAIN] +#define meth_var_types_chain objc_global_trees[OCTI_METH_VAR_TYPES_CHAIN] + + +/* Backend data declarations. */ + +#define UOBJC_SYMBOLS_decl objc_global_trees[OCTI_SYMBOLS_DECL] +#define UOBJC_INSTANCE_VARIABLES_decl objc_global_trees[OCTI_NST_VAR_DECL] +#define UOBJC_CLASS_VARIABLES_decl objc_global_trees[OCTI_CLS_VAR_DECL] +#define UOBJC_INSTANCE_METHODS_decl objc_global_trees[OCTI_NST_METH_DECL] +#define UOBJC_CLASS_METHODS_decl objc_global_trees[OCTI_CLS_METH_DECL] +#define UOBJC_CLASS_decl objc_global_trees[OCTI_CLS_DECL] +#define UOBJC_METACLASS_decl objc_global_trees[OCTI_MCLS_DECL] +#define UOBJC_SELECTOR_TABLE_decl objc_global_trees[OCTI_SEL_TABLE_DECL] +#define UOBJC_MODULES_decl objc_global_trees[OCTI_MODULES_DECL] +#define UOBJC_STRINGS_decl objc_global_trees[OCTI_STRG_DECL] + +/* The following are used when compiling a class implementation. + implementation_template will normally be an interface, however if + none exists this will be equal to objc_implementation_context...it is + set in start_class. */ + +#define objc_interface_context objc_global_trees[OCTI_INTF_CTX] +#define objc_implementation_context objc_global_trees[OCTI_IMPL_CTX] +#define objc_method_context objc_global_trees[OCTI_METH_CTX] +#define objc_ivar_context objc_global_trees[OCTI_IVAR_CTX] + +#define implementation_template objc_global_trees[OCTI_IMPL_TEMPL] +#define objc_class_template objc_global_trees[OCTI_CLS_TEMPL] +#define objc_category_template objc_global_trees[OCTI_CAT_TEMPL] +#define uprivate_record objc_global_trees[OCTI_UPRIV_REC] +#define objc_protocol_template objc_global_trees[OCTI_PROTO_TEMPL] +#define objc_selector_template objc_global_trees[OCTI_SEL_TEMPL] +#define ucls_super_ref objc_global_trees[OCTI_UCLS_SUPER_REF] +#define uucls_super_ref objc_global_trees[OCTI_UUCLS_SUPER_REF] + +#define objc_method_template objc_global_trees[OCTI_METH_TEMPL] +#define objc_ivar_template objc_global_trees[OCTI_IVAR_TEMPL] +#define objc_symtab_template objc_global_trees[OCTI_SYMTAB_TEMPL] +#define objc_module_template objc_global_trees[OCTI_MODULE_TEMPL] +#define objc_super_template objc_global_trees[OCTI_SUPER_TEMPL] +#define objc_object_reference objc_global_trees[OCTI_OBJ_REF] +#define objc_method_prototype_template \ + objc_global_trees[OCTI_METH_PROTO_TEMPL] +#define function1_template objc_global_trees[OCTI_FUNCTION1_TEMPL] +#define function2_template objc_global_trees[OCTI_FUNCTION2_TEMPL] + +#define objc_object_id objc_global_trees[OCTI_OBJ_ID] +#define objc_class_id objc_global_trees[OCTI_CLS_ID] +#define objc_id_id objc_global_trees[OCTI_ID_ID] +#define constant_string_id objc_global_trees[OCTI_CNST_STR_ID] +#define constant_string_type objc_global_trees[OCTI_CNST_STR_TYPE] +#define constant_string_global_id \ + objc_global_trees[OCTI_CNST_STR_GLOB_ID] +#define string_class_decl objc_global_trees[OCTI_STRING_CLASS_DECL] +#define UOBJC_SUPER_decl objc_global_trees[OCTI_SUPER_DECL] + diff --git a/gcc/objc/objc-tree.def b/gcc/objc/objc-tree.def index dad4330b6d5..979556f0fa1 100644 --- a/gcc/objc/objc-tree.def +++ b/gcc/objc/objc-tree.def @@ -1,7 +1,8 @@ /* This file contains the definitions and documentation for the additional tree codes used in the Objective C front end (see tree.def for the standard codes). - Copyright (C) 1990, 1997 Free Software Foundation, Inc. + Copyright (C) 1990, 1997, 1998, 1999, 2000, 2001 + Free Software Foundation, Inc. This file is part of GNU CC. @@ -25,7 +26,7 @@ Boston, MA 02111-1307, USA. */ DEFTREECODE (CLASS_INTERFACE_TYPE, "class_interface_type", 't', 0) DEFTREECODE (CLASS_IMPLEMENTATION_TYPE, "class_implementation_type", 't', 0) DEFTREECODE (CATEGORY_INTERFACE_TYPE, "category_interface_type", 't', 0) -DEFTREECODE (CATEGORY_IMPLEMENTATION_TYPE,"category_implementation_type",'t',0) +DEFTREECODE (CATEGORY_IMPLEMENTATION_TYPE,"category_implementation_type", 't', 0) DEFTREECODE (PROTOCOL_INTERFACE_TYPE, "protocol_interface_type", 't', 0) /* Objective-C decls. */ |