This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This time, I fixed C++ template support, methods with variable number of arguments (in _both_ ObjC and ObjC++!),
and protocol qualifiers:
Cheers, David Ayers
2004-06-24 David Ayers <d.ayers@inode.at> * c-parse.in: Unify Objective-C token names. * objc/objc-act.h (super_type): Rename to objc_super_type. (selector_type): Rename to objc_selector_type. (instance_type): Rename to objc_instance_type. (protocol_type): Rename to objc_protocol_type. * objc/objc-act.c (lookup_method_in_protocol_list): Rename class_meth to is_class. Add documentation. (objc_finish_message_expr): Rename is_class to class_tree. (synth_module_prologue, objc_build_protocol_expr) (start_protocol): Update references to protocol_type. (synth_module_prologue, build_objc_symtab_template) (build_selector_reference_decl, build_selector_table_decl) (build_selector, build_selector_translation_table) (build_typed_selector_reference, get_arg_type_list) (synth_self_and_ucmd_args): Update references to selector_type. (build_private_template, build_ivar_reference):Update references to instance_type. (synth_module_prologue, get_arg_type_list, build_objc_method_call): Update references to super_type. * objc/objc-tree.def: Add C mode identifier sequence. Index: gcc/c-parse.in =================================================================== RCS file: /cvs/gcc/gcc/gcc/c-parse.in,v retrieving revision 1.170.2.13 diff -u -r1.170.2.13 c-parse.in --- gcc/c-parse.in 23 Jun 2004 19:43:51 -0000 1.170.2.13 +++ gcc/c-parse.in 24 Jun 2004 11:39:50 -0000 @@ -171,8 +171,9 @@ /* The Objective-C keywords. These are included in C and in Objective C, so that the token codes are the same in both. */ -%token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE -%token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS +%token AT_INTERFACE AT_IMPLEMENTATION AT_END AT_SELECTOR AT_DEFS AT_ENCODE +%token CLASSNAME AT_PUBLIC AT_PRIVATE AT_PROTECTED AT_PROTOCOL +%token OBJECTNAME AT_CLASS AT_ALIAS %token AT_THROW AT_TRY AT_CATCH AT_FINALLY AT_SYNCHRONIZED %token OBJC_STRING @@ -1761,7 +1762,7 @@ pedwarn ("extra semicolon in struct or union specified"); } @@ifobjc /* foo(sizeof(struct{ @defs(ClassName)})); */ - | DEFS '(' CLASSNAME ')' + | AT_DEFS '(' CLASSNAME ')' { $$ = nreverse (objc_get_class_ivars ($3)); } @@end_ifobjc ; @@ -2710,7 +2711,7 @@ | aliasdecl | protocoldef | methoddef - | END + | AT_END { objc_finish_implementation (); } @@ -2725,14 +2726,14 @@ ; classdecl: - CLASS identifier_list ';' + AT_CLASS identifier_list ';' { objc_declare_class ($2); } ; aliasdecl: - ALIAS identifier identifier ';' + AT_ALIAS identifier identifier ';' { objc_declare_alias ($2, $3); } @@ -2749,7 +2750,7 @@ ; classdef: - INTERFACE identifier superclass protocolrefs + AT_INTERFACE identifier superclass protocolrefs { objc_start_class_interface ($2, $3, $4); } @@ -2757,12 +2758,12 @@ { objc_continue_interface (); } - methodprotolist END + methodprotolist AT_END { objc_finish_interface (); } - | IMPLEMENTATION identifier superclass + | AT_IMPLEMENTATION identifier superclass { objc_start_class_implementation ($2, $3); } @@ -2771,28 +2772,28 @@ objc_continue_implementation (); } - | INTERFACE identifier '(' identifier ')' protocolrefs + | AT_INTERFACE identifier '(' identifier ')' protocolrefs { objc_start_category_interface ($2, $4, $6); } - methodprotolist END + methodprotolist AT_END { objc_finish_interface (); } - | IMPLEMENTATION identifier '(' identifier ')' + | AT_IMPLEMENTATION identifier '(' identifier ')' { objc_start_category_implementation ($2, $4); } ; protocoldef: - PROTOCOL identifier protocolrefs + AT_PROTOCOL identifier protocolrefs { objc_pq_context = 1; objc_start_protocol ($2, $3); } - methodprotolist END + methodprotolist AT_END { objc_pq_context = 0; objc_finish_interface (); @@ -2800,7 +2801,7 @@ /* The @protocol forward-declaration production introduces a reduce/reduce conflict on ';', which should be resolved in favor of the production 'identifier_list -> identifier'. */ - | PROTOCOL identifier_list ';' + | AT_PROTOCOL identifier_list ';' { objc_declare_protocols ($2); } @@ -2830,9 +2831,9 @@ ; visibility_spec: - PRIVATE { objc_set_visibility (2); } - | PROTECTED { objc_set_visibility (0); } - | PUBLIC { objc_set_visibility (1); } + AT_PRIVATE { objc_set_visibility (2); } + | AT_PROTECTED { objc_set_visibility (0); } + | AT_PUBLIC { objc_set_visibility (1); } ; ivar_decls: @@ -3130,14 +3131,14 @@ ; objcselectorexpr: - SELECTOR '(' selectorarg ')' + AT_SELECTOR '(' selectorarg ')' { $$ = $3; } ; objcprotocolexpr: - PROTOCOL '(' identifier ')' + AT_PROTOCOL '(' identifier ')' { $$ = $3; } @@ -3146,7 +3147,7 @@ /* extension to support C-structures in the archiver */ objcencodeexpr: - ENCODE '(' typename ')' + AT_ENCODE '(' typename ')' { $$ = groktypename ($3); } @@ -3402,23 +3403,23 @@ /* Objective C */ /* RID_ID */ OBJECTNAME, - /* RID_AT_ENCODE */ ENCODE, - /* RID_AT_END */ END, - /* RID_AT_CLASS */ CLASS, - /* RID_AT_ALIAS */ ALIAS, - /* RID_AT_DEFS */ DEFS, - /* RID_AT_PRIVATE */ PRIVATE, - /* RID_AT_PROTECTED */ PROTECTED, - /* RID_AT_PUBLIC */ PUBLIC, - /* RID_AT_PROTOCOL */ PROTOCOL, - /* RID_AT_SELECTOR */ SELECTOR, + /* RID_AT_ENCODE */ AT_ENCODE, + /* RID_AT_END */ AT_END, + /* RID_AT_CLASS */ AT_CLASS, + /* RID_AT_ALIAS */ AT_ALIAS, + /* RID_AT_DEFS */ AT_DEFS, + /* RID_AT_PRIVATE */ AT_PRIVATE, + /* RID_AT_PROTECTED */ AT_PROTECTED, + /* RID_AT_PUBLIC */ AT_PUBLIC, + /* RID_AT_PROTOCOL */ AT_PROTOCOL, + /* RID_AT_SELECTOR */ AT_SELECTOR, /* RID_AT_THROW */ AT_THROW, /* RID_AT_TRY */ AT_TRY, /* RID_AT_CATCH */ AT_CATCH, /* RID_AT_FINALLY */ AT_FINALLY, /* RID_AT_SYNCHRONIZED */ AT_SYNCHRONIZED, - /* RID_AT_INTERFACE */ INTERFACE, - /* RID_AT_IMPLEMENTATION */ IMPLEMENTATION + /* RID_AT_INTERFACE */ AT_INTERFACE, + /* RID_AT_IMPLEMENTATION */ AT_IMPLEMENTATION }; static void Index: gcc/objc/objc-act.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v retrieving revision 1.179.2.28 diff -u -r1.179.2.28 objc-act.c --- gcc/objc/objc-act.c 23 Jun 2004 19:43:53 -0000 1.179.2.28 +++ gcc/objc/objc-act.c 24 Jun 2004 11:39:53 -0000 @@ -608,9 +608,14 @@ return decl; } +/* Return the first occurrence of a method declaration corresponding + to SEL_NAME in RPROTO_LIST. Search RPROTO_LIST recursively. + If IS_CLASS is 0, search for instance methods, otherwise for class + methods. */ + static tree lookup_method_in_protocol_list (tree rproto_list, tree sel_name, - int class_meth) + int is_class) { tree rproto, p; tree fnd = 0; @@ -621,13 +626,13 @@ if (TREE_CODE (p) == PROTOCOL_INTERFACE_TYPE) { - if ((fnd = lookup_method (class_meth + if ((fnd = lookup_method (is_class ? PROTOCOL_CLS_METHODS (p) : PROTOCOL_NST_METHODS (p), sel_name))) ; else if (PROTOCOL_LIST (p)) fnd = lookup_method_in_protocol_list (PROTOCOL_LIST (p), - sel_name, class_meth); + sel_name, is_class); } else { @@ -1332,19 +1337,19 @@ type = get_identifier (PROTOCOL_OBJECT_CLASS_NAME); objc_declare_class (tree_cons (NULL_TREE, type, NULL_TREE)); - protocol_type = build_pointer_type (xref_tag (RECORD_TYPE, - type)); + objc_protocol_type = build_pointer_type (xref_tag (RECORD_TYPE, + type)); /* Declare type of selector-objects that represent an operation name. */ if (flag_next_runtime) /* `struct objc_selector *' */ - selector_type + objc_selector_type = build_pointer_type (xref_tag (RECORD_TYPE, get_identifier (TAG_SELECTOR))); else /* `const struct objc_selector *' */ - selector_type + objc_selector_type = build_pointer_type (build_qualified_type (xref_tag (RECORD_TYPE, get_identifier (TAG_SELECTOR)), @@ -1353,8 +1358,8 @@ /* Declare receiver type used for dispatching messages to 'super'. */ /* `struct objc_super *' */ - super_type = build_pointer_type (xref_tag (RECORD_TYPE, - get_identifier (TAG_SUPER))); + objc_super_type = build_pointer_type (xref_tag (RECORD_TYPE, + get_identifier (TAG_SUPER))); if (flag_next_runtime) { @@ -1370,7 +1375,8 @@ type = build_function_type (objc_object_type, tree_cons (NULL_TREE, objc_object_type, - tree_cons (NULL_TREE, selector_type, + tree_cons (NULL_TREE, + objc_selector_type, NULL_TREE))); umsg_decl = builtin_function (TAG_MSGSEND, type, 0, NOT_BUILT_IN, @@ -1389,8 +1395,9 @@ /* id objc_msgSendSuper_stret (struct objc_super *, SEL, ...); */ type = build_function_type (objc_object_type, - tree_cons (NULL_TREE, super_type, - tree_cons (NULL_TREE, selector_type, + tree_cons (NULL_TREE, objc_super_type, + tree_cons (NULL_TREE, + objc_selector_type, NULL_TREE))); umsg_super_decl = builtin_function (TAG_MSGSENDSUPER, type, 0, NOT_BUILT_IN, @@ -1408,14 +1415,16 @@ = build_pointer_type (build_function_type (objc_object_type, tree_cons (NULL_TREE, objc_object_type, - tree_cons (NULL_TREE, selector_type, + tree_cons (NULL_TREE, + objc_selector_type, NULL_TREE)))); /* IMP objc_msg_lookup (id, SEL); */ type = build_function_type (IMP_type, tree_cons (NULL_TREE, objc_object_type, - tree_cons (NULL_TREE, selector_type, + tree_cons (NULL_TREE, + objc_selector_type, OBJC_VOID_AT_END))); umsg_decl = builtin_function (TAG_MSGSEND, type, 0, NOT_BUILT_IN, @@ -1424,8 +1433,9 @@ /* IMP objc_msg_lookup_super (struct objc_super *, SEL); */ type = build_function_type (IMP_type, - tree_cons (NULL_TREE, super_type, - tree_cons (NULL_TREE, selector_type, + tree_cons (NULL_TREE, objc_super_type, + tree_cons (NULL_TREE, + objc_selector_type, OBJC_VOID_AT_END))); umsg_super_decl = builtin_function (TAG_MSGSENDSUPER, type, 0, NOT_BUILT_IN, @@ -1717,7 +1727,7 @@ /* SEL *refs; */ - field_decl = create_field_decl (build_pointer_type (selector_type), + field_decl = create_field_decl (build_pointer_type (objc_selector_type), "refs"); chainon (field_decl_chain, field_decl); @@ -2231,7 +2241,7 @@ ident = get_identifier (buf); - decl = build_decl (VAR_DECL, ident, selector_type); + decl = build_decl (VAR_DECL, ident, objc_selector_type); DECL_EXTERNAL (decl) = 1; TREE_PUBLIC (decl) = 0; TREE_USED (decl) = 1; @@ -2258,7 +2268,7 @@ temp = build_array_type (objc_selector_template, NULL_TREE); } else - temp = build_array_type (selector_type, NULL_TREE); + temp = build_array_type (objc_selector_type, NULL_TREE); UOBJC_SELECTOR_TABLE_decl = build_decl (VAR_DECL, @@ -2285,7 +2295,7 @@ if (flag_typed_selectors) return expr; else - return build_c_cast (selector_type, expr); /* cast! */ + return build_c_cast (objc_selector_type, expr); /* cast! */ } static void @@ -2335,7 +2345,7 @@ sc_spec = build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC]); /* static SEL _OBJC_SELECTOR_REFERENCES_n = ...; */ - decl_specs = tree_cons (NULL_TREE, selector_type, sc_spec); + decl_specs = tree_cons (NULL_TREE, objc_selector_type, sc_spec); var_decl = name; @@ -2440,7 +2450,7 @@ build_array_ref (UOBJC_SELECTOR_TABLE_decl, build_int_2 (index, 0)), 1); - return build_c_cast (selector_type, expr); + return build_c_cast (objc_selector_type, expr); } static tree @@ -3597,7 +3607,7 @@ TREE_STATIC_TEMPLATE (uprivate_record) = 1; } - instance_type + objc_instance_type = groktypename (build_tree_list (build_tree_list (NULL_TREE, uprivate_record), build1 (INDIRECT_REF, NULL_TREE, @@ -5630,14 +5640,14 @@ /* Receiver type. */ if (flag_next_runtime && superflag) - arglist = build_tree_list (NULL_TREE, super_type); + arglist = build_tree_list (NULL_TREE, objc_super_type); else if (context == METHOD_DEF) arglist = build_tree_list (NULL_TREE, TREE_TYPE (self_decl)); else arglist = build_tree_list (NULL_TREE, objc_object_type); /* Selector type - will eventually change to `int'. */ - chainon (arglist, build_tree_list (NULL_TREE, selector_type)); + chainon (arglist, build_tree_list (NULL_TREE, objc_selector_type)); /* No actual method prototype given -- assume that remaining arguments are `...'. */ @@ -5883,7 +5893,7 @@ objc_finish_message_expr (tree receiver, tree sel_name, tree method_params) { tree method_prototype = NULL_TREE, rprotos = NULL_TREE, rtype; - tree selector, retval, is_class; + tree selector, retval, class_tree; int self, super, have_cast; /* Extract the receiver of the message, as well as its type @@ -5905,14 +5915,14 @@ /* If the receiver is a class object, retrieve the corresponding @interface, if one exists. */ - is_class = receiver_is_class_object (receiver, self, super); + class_tree = receiver_is_class_object (receiver, self, super); /* Now determine the receiver type (if an explicit cast has not been provided). */ if (!have_cast) { - if (is_class) - rtype = lookup_interface (is_class); + if (class_tree) + rtype = lookup_interface (class_tree); /* Handle `self' and `super'. */ else if (super) { @@ -5934,7 +5944,7 @@ if (!rtype || objc_is_id (rtype)) { if (!rtype) - rtype = xref_tag (RECORD_TYPE, is_class); + rtype = xref_tag (RECORD_TYPE, class_tree); else if (IS_ID (rtype)) { rprotos = TYPE_PROTOCOL_LIST (rtype); @@ -5942,18 +5952,18 @@ } else { - is_class = objc_class_name; - OBJC_SET_TYPE_NAME (rtype, is_class); + class_tree = objc_class_name; + OBJC_SET_TYPE_NAME (rtype, class_tree); } if (rprotos) method_prototype = lookup_method_in_protocol_list (rprotos, sel_name, - is_class != NULL_TREE); + class_tree != NULL_TREE); if (!method_prototype && !rprotos) method_prototype = lookup_method_in_hash_lists (sel_name, - is_class != NULL_TREE); + class_tree != NULL_TREE); } else { @@ -5985,7 +5995,7 @@ in the published @interface for the class (and its superclasses). */ method_prototype - = lookup_method_static (rtype, sel_name, is_class != NULL_TREE); + = lookup_method_static (rtype, sel_name, class_tree != NULL_TREE); /* If the method was not found in the @interface, it may still exist locally as part of the @implementation. */ @@ -5994,7 +6004,7 @@ == OBJC_TYPE_NAME (rtype)) method_prototype = lookup_method - ((is_class + ((class_tree ? CLASS_CLS_METHODS (objc_implementation_context) : CLASS_NST_METHODS (objc_implementation_context)), sel_name); @@ -6004,7 +6014,7 @@ if (!method_prototype && rprotos) method_prototype = lookup_method_in_protocol_list (rprotos, sel_name, - is_class != NULL_TREE); + class_tree != NULL_TREE); } else { @@ -6021,11 +6031,11 @@ if (rtype) warning ("`%s' may not respond to `%c%s'", IDENTIFIER_POINTER (OBJC_TYPE_NAME (rtype)), - (is_class ? '+' : '-'), + (class_tree ? '+' : '-'), IDENTIFIER_POINTER (sel_name)); if (rprotos) warning ("`%c%s' not implemented by protocol(s)", - (is_class ? '+' : '-'), + (class_tree ? '+' : '-'), IDENTIFIER_POINTER (sel_name)); if (!warn_missing_methods) { @@ -6072,7 +6082,7 @@ (!flag_next_runtime || flag_nil_receivers ? umsg_decl : umsg_nonnil_decl)); - tree rcv_p = (super_flag ? super_type : objc_object_type); + tree rcv_p = (super_flag ? objc_super_type : objc_object_type); /* If a prototype for the method to be called exists, then cast the sender's return type and arguments to match that of the method. @@ -6194,9 +6204,9 @@ expr = build_unary_op (ADDR_EXPR, PROTOCOL_FORWARD_DECL (p), 0); - /* ??? Ideally we'd build the reference with protocol_type directly, + /* ??? Ideally we'd build the reference with objc_protocol_type directly, if we have it, rather than converting it here. */ - expr = convert (protocol_type, expr); + expr = convert (objc_protocol_type, expr); /* The @protocol() expression is being compiled into a pointer to a statically allocated instance of the Protocol class. To become @@ -6214,7 +6224,7 @@ if (! flag_next_runtime) { /* This type is a struct containing the fields of a Protocol - object. (Cfr. protocol_type instead is the type of a pointer + object. (Cfr. objc_protocol_type instead is the type of a pointer to such a struct). */ tree protocol_struct_type = xref_tag (RECORD_TYPE, get_identifier (PROTOCOL_OBJECT_CLASS_NAME)); @@ -6327,7 +6337,7 @@ paradigm. */ warning ("instance variable `%s' accessed in class method", IDENTIFIER_POINTER (id)); - TREE_TYPE (self_decl) = instance_type; /* cast */ + TREE_TYPE (self_decl) = objc_instance_type; /* cast */ } return build_component_ref (build_indirect_ref (self_decl, "->"), id); @@ -7747,7 +7757,7 @@ build1 (INDIRECT_REF, NULL_TREE, self_id)), unused_list)); - decl_specs = build_tree_list (NULL_TREE, TREE_TYPE (selector_type)); + decl_specs = build_tree_list (NULL_TREE, TREE_TYPE (objc_selector_type)); push_parm_decl (build_tree_list (build_tree_list (decl_specs, build1 (INDIRECT_REF, NULL_TREE, ucmd_id)), Index: gcc/objc/objc-act.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.h,v retrieving revision 1.16.4.10 diff -u -r1.16.4.10 objc-act.h --- gcc/objc/objc-act.h 23 Jun 2004 19:43:54 -0000 1.16.4.10 +++ gcc/objc/objc-act.h 24 Jun 2004 11:39:53 -0000 @@ -264,12 +264,12 @@ #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 objc_super_type objc_global_trees[OCTI_SUPER_TYPE] +#define objc_selector_type objc_global_trees[OCTI_SEL_TYPE] #define objc_object_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] +#define objc_instance_type objc_global_trees[OCTI_NST_TYPE] +#define objc_protocol_type objc_global_trees[OCTI_PROTO_TYPE] /* Type checking macros. */ Index: gcc/objc/objc-tree.def =================================================================== RCS file: /cvs/gcc/gcc/gcc/objc/objc-tree.def,v retrieving revision 1.7.8.1 diff -u -r1.7.8.1 objc-tree.def --- gcc/objc/objc-tree.def 23 Jul 2003 19:05:54 -0000 1.7.8.1 +++ gcc/objc/objc-tree.def 24 Jun 2004 11:39:53 -0000 @@ -37,3 +37,9 @@ /* Objective-C expressions. */ DEFTREECODE (MESSAGE_SEND_EXPR, "message_send_expr", 'e', 3) DEFTREECODE (CLASS_REFERENCE_EXPR, "class_reference_expr", 'e', 1) + +/* +L ocal variables: +m ode:c +E nd: +*/
Attachment:
objc.patch.gz
Description: application/gunzip
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |