diff options
-rw-r--r-- | gcc/ChangeLog | 30 | ||||
-rw-r--r-- | gcc/objc/Make-lang.in | 11 | ||||
-rw-r--r-- | gcc/objc/config-lang.in | 4 | ||||
-rw-r--r-- | gcc/objc/objc-act.c | 103 | ||||
-rw-r--r-- | gcc/objc/objc-act.h | 6 | ||||
-rw-r--r-- | gcc/objc/objc-lang.c | 79 |
6 files changed, 163 insertions, 70 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e24faea..a88fb18 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,33 @@ +2001-12-02 Ziemowit Laski <zlaski@apple.com> + + * objc/Make-lang.in: Update copyright. + (OBJC_OBJS): Add objc-lang.o. + (objc-lang.o): New rule. + * objc/config-lang.in: Fix file description and update + copyright. + * objc/objc-act.c: Do not include langhooks.h and + langhooks-def.h + (lang_hooks): Move (along with LANG_HOOKS...) to objc-lang.c. + (objc_post_options): Move to objc-lang.c. + (objc_init_options): Move to objc-lang.c. + (objc_init): Make non-static. + (objc_decode_option): Make non-static. + (HASHFUNCTION): Remove macro. + (hash_func): New function. + (hash_enter): Replace HASHFUNCTION with hash_func. + (hash_lookup): Replace HASHFUNCTION with hash_func. + (maybe_objc_tree_codes): New function. + (init_objc): Move ObjC tree code initialization to + maybe_objc_tree_codes(). + * objc/objc-act.h (GCC_OBJC_ACT_H): New include guard. + (objc_init): New public prototype. + (objc_decode_option): New public prototype. + (maybe_add_objc_tree_codes): New public prototype. + * objc/objc-lang.c: New file. + (lang_hooks): Moved from objc-act.c. + (objc_post_options): Moved from objc-act.c. + (objc_init_options): Moved from objc-act.c. + 2001-12-03 Geoff Keating <geoffk@redhat.com> * emit-rtl.c (gen_lowpart_common): Avoid unwanted sign-extension diff --git a/gcc/objc/Make-lang.in b/gcc/objc/Make-lang.in index 910f1c6..6f48a91 100644 --- a/gcc/objc/Make-lang.in +++ b/gcc/objc/Make-lang.in @@ -1,5 +1,5 @@ # Top level makefile fragment for GNU Objective-C -# Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. +# Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc. #This file is part of GNU CC. @@ -48,13 +48,20 @@ OBJECTIVE-C objective-c: cc1obj$(exeext) objc-warn = $(STRICT_WARN) # Language-specific object files for Objective C. -OBJC_OBJS = objc-parse.o objc-act.o $(C_AND_OBJC_OBJS) +OBJC_OBJS = objc-lang.o objc-parse.o objc-act.o $(C_AND_OBJC_OBJS) cc1obj$(exeext): $(OBJC_OBJS) $(BACKEND) $(LIBDEPS) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(OBJC_OBJS) $(BACKEND) $(LIBS) # Objective C language specific files. +objc-lang.o : $(srcdir)/objc/objc-lang.c \ + $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(srcdir)/c-tree.h \ + $(srcdir)/c-common.h $(srcdir)/toplev.h $(srcdir)/objc/objc-act.h \ + $(srcdir)/langhooks.h $(srcdir)/langhooks-def.h + $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -I$(srcdir)/objc \ + -c $(srcdir)/objc/objc-lang.c $(OUTPUT_OPTION) + objc-parse.o : $(srcdir)/objc/objc-parse.c \ $(CONFIG_H) $(TREE_H) $(srcdir)/toplev.h $(srcdir)/ggc.h \ $(srcdir)/c-lex.h $(srcdir)/c-tree.h $(srcdir)/c-common.h \ diff --git a/gcc/objc/config-lang.in b/gcc/objc/config-lang.in index d1c5957..9155d9d 100644 --- a/gcc/objc/config-lang.in +++ b/gcc/objc/config-lang.in @@ -1,5 +1,5 @@ -# Top level configure fragment for the GNU Objective-C Runtime Library. -# Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. +# Top level configure fragment for GNU Objective-C +# Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc. #This file is part of GNU CC. diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index ff449c7..a04f631 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -59,8 +59,6 @@ Boston, MA 02111-1307, USA. */ #include "debug.h" #include "target.h" #include "varray.h" -#include "langhooks.h" -#include "langhooks-def.h" /* This is the default way of generating a method name. */ /* I am not sure it is really correct. @@ -157,10 +155,6 @@ char *util_firstobj; static void init_objc PARAMS ((void)); static void finish_objc PARAMS ((void)); -static const char *objc_init PARAMS ((const char *)); -static void objc_init_options PARAMS ((void)); -static int objc_decode_option PARAMS ((int, char **)); -static void objc_post_options PARAMS ((void)); /* Code generation. */ @@ -214,6 +208,7 @@ static void objc_expand_function_end PARAMS ((void)); hash *nst_method_hash_list = 0; hash *cls_method_hash_list = 0; +static size_t hash_func PARAMS ((tree)); static void hash_init PARAMS ((void)); static void hash_enter PARAMS ((hash *, tree)); static hash hash_lookup PARAMS ((hash *, tree)); @@ -276,6 +271,7 @@ static void dump_interface PARAMS ((FILE *, tree)); /* Everything else. */ +static void add_objc_tree_codes PARAMS ((void)); static tree define_decl PARAMS ((tree, tree)); static tree lookup_method_in_protocol_list PARAMS ((tree, tree, int)); static tree lookup_protocol_in_reflist PARAMS ((tree, tree)); @@ -452,45 +448,8 @@ static int generating_instance_variables = 0; static int print_struct_values = 0; -#undef LANG_HOOKS_NAME -#define LANG_HOOKS_NAME "GNU Objective-C" -#undef LANG_HOOKS_INIT -#define LANG_HOOKS_INIT objc_init -#undef LANG_HOOKS_FINISH -#define LANG_HOOKS_FINISH c_common_finish -#undef LANG_HOOKS_INIT_OPTIONS -#define LANG_HOOKS_INIT_OPTIONS objc_init_options -#undef LANG_HOOKS_DECODE_OPTION -#define LANG_HOOKS_DECODE_OPTION objc_decode_option -#undef LANG_HOOKS_POST_OPTIONS -#define LANG_HOOKS_POST_OPTIONS objc_post_options -#undef LANG_HOOKS_PRINT_IDENTIFIER -#define LANG_HOOKS_PRINT_IDENTIFIER c_print_identifier -#undef LANG_HOOKS_SET_YYDEBUG -#define LANG_HOOKS_SET_YYDEBUG c_set_yydebug -/* Inlining hooks same as the C front end. */ -#undef LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN -#define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \ - c_cannot_inline_tree_fn -#undef LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS -#define LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS \ - c_disregard_inline_limits -#undef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P -#define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P \ - anon_aggr_type_p - -/* Each front end provides its own. */ -const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; - static varray_type deferred_fns; -/* Post-switch processing. */ -static void -objc_post_options () -{ - c_common_post_options (); -} - /* Some platforms pass small structures through registers versus through an invisible pointer. Determine at what size structure is the transition point between the two possibilities. */ @@ -554,17 +513,12 @@ generate_struct_by_value_array () exit (0); } -static void -objc_init_options () -{ - c_common_init_options (clk_objective_c); -} - -static const char * +const char * objc_init (filename) const char *filename; { filename = c_objc_common_init (filename); + add_objc_tree_codes (); decl_printable_name = objc_printable_name; @@ -647,7 +601,7 @@ finish_file () fclose (gen_declaration_file); } -static int +int objc_decode_option (argc, argv) int argc; char **argv; @@ -5314,9 +5268,22 @@ build_ivar_reference (id) return build_component_ref (build_indirect_ref (self_decl, "->"), id); } -/* Make the hash value positive. */ -#define HASHFUNCTION(key) ((size_t) key & 0x7fffffff) + +/* Compute a hash value for a given method SEL_NAME. */ +static size_t +hash_func (sel_name) + tree sel_name; +{ + const unsigned char *s + = (const unsigned char *)IDENTIFIER_POINTER (sel_name); + size_t h = 0; + + while (*s) + h = h * 67 + *s++ - 113; + return h; +} + static void hash_init () { @@ -5337,7 +5304,7 @@ hash_enter (hashlist, method) static hash hash_alloc_list = 0; static int hash_alloc_index = 0; hash obj; - int slot = HASHFUNCTION (METHOD_SEL_NAME (method)) % SIZEHASHTABLE; + int slot = hash_func (METHOD_SEL_NAME (method)) % SIZEHASHTABLE; if (! hash_alloc_list || hash_alloc_index >= HASH_ALLOC_LIST_SIZE) { @@ -5360,7 +5327,7 @@ hash_lookup (hashlist, sel_name) { hash target; - target = hashlist[HASHFUNCTION (sel_name) % SIZEHASHTABLE]; + target = hashlist[hash_func (sel_name) % SIZEHASHTABLE]; while (target) { @@ -8074,23 +8041,27 @@ objc_printable_name (decl, kind) return objc_demangle (IDENTIFIER_POINTER (DECL_NAME (decl))); } +/* Adds the tree codes specific to the ObjC/ObjC++ front end to the + list of all tree codes. */ + static void -init_objc () +add_objc_tree_codes () { - /* Add the special tree codes of Objective C to the tables. */ - - gcc_obstack_init (&util_obstack); - util_firstobj = (char *) obstack_finish (&util_obstack); + int add = (int) LAST_OBJC_TREE_CODE - (int) LAST_BASE_TREE_CODE; memcpy (tree_code_type + (int) LAST_BASE_TREE_CODE, - objc_tree_code_type, - (int) LAST_OBJC_TREE_CODE - (int) LAST_BASE_TREE_CODE); + objc_tree_code_type, add); memcpy (tree_code_length + (int) LAST_BASE_TREE_CODE, - objc_tree_code_length, - (((int) LAST_OBJC_TREE_CODE - (int) LAST_BASE_TREE_CODE) * sizeof (int))); + objc_tree_code_length, add * sizeof (int)); memcpy (tree_code_name + (int) LAST_BASE_TREE_CODE, - objc_tree_code_name, - (((int) LAST_OBJC_TREE_CODE - (int) LAST_BASE_TREE_CODE) * sizeof (char *))); + objc_tree_code_name, add * sizeof (char *)); +} + +static void +init_objc () +{ + gcc_obstack_init (&util_obstack); + util_firstobj = (char *) obstack_finish (&util_obstack); errbuf = (char *)xmalloc (BUFSIZE); hash_init (); diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h index 2825970..72b8b3e 100644 --- a/gcc/objc/objc-act.h +++ b/gcc/objc/objc-act.h @@ -18,9 +18,14 @@ along with GNU CC; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef GCC_OBJC_ACT_H +#define GCC_OBJC_ACT_H /*** Public Interface (procedures) ***/ +const char *objc_init PARAMS ((const char *)); +int objc_decode_option PARAMS ((int, char **)); + /* used by yyparse */ void finish_file PARAMS ((void)); @@ -353,3 +358,4 @@ extern tree objc_global_trees[OCTI_MAX]; #define string_class_decl objc_global_trees[OCTI_STRING_CLASS_DECL] #define UOBJC_SUPER_decl objc_global_trees[OCTI_SUPER_DECL] +#endif /* GCC_OBJC_ACT_H */ diff --git a/gcc/objc/objc-lang.c b/gcc/objc/objc-lang.c new file mode 100644 index 0000000..33d2cde --- /dev/null +++ b/gcc/objc/objc-lang.c @@ -0,0 +1,79 @@ +/* Language-dependent hooks for Objective-C. + Copyright 2001 Free Software Foundation, Inc. + Contributed by Ziemowit Laski <zlaski@apple.com> + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "config.h" +#include "system.h" +#include "tree.h" +#include "c-tree.h" +#include "c-common.h" +#include "toplev.h" +#include "objc-act.h" +#include "langhooks.h" +#include "langhooks-def.h" + +static void objc_init_options PARAMS ((void)); +static void objc_post_options PARAMS ((void)); + +#undef LANG_HOOKS_NAME +#define LANG_HOOKS_NAME "GNU Objective-C" +#undef LANG_HOOKS_INIT +#define LANG_HOOKS_INIT objc_init +#undef LANG_HOOKS_FINISH +#define LANG_HOOKS_FINISH c_common_finish +#undef LANG_HOOKS_INIT_OPTIONS +#define LANG_HOOKS_INIT_OPTIONS objc_init_options +#undef LANG_HOOKS_DECODE_OPTION +#define LANG_HOOKS_DECODE_OPTION objc_decode_option +#undef LANG_HOOKS_POST_OPTIONS +#define LANG_HOOKS_POST_OPTIONS objc_post_options +#undef LANG_HOOKS_PRINT_IDENTIFIER +#define LANG_HOOKS_PRINT_IDENTIFIER c_print_identifier +#undef LANG_HOOKS_SET_YYDEBUG +#define LANG_HOOKS_SET_YYDEBUG c_set_yydebug +/* Inlining hooks same as the C front end. */ +#undef LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN +#define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \ + c_cannot_inline_tree_fn +#undef LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS +#define LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS \ + c_disregard_inline_limits +#undef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P +#define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P \ + anon_aggr_type_p + +/* Each front end provides its own hooks, for toplev.c. */ +const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; + +static void +objc_init_options () +{ + c_common_init_options (clk_objective_c); +} + +/* Post-switch processing. */ + +static void +objc_post_options () +{ + c_common_post_options (); +} + + |