aboutsummaryrefslogtreecommitdiff
path: root/gcc/objc/objc-act.c
diff options
context:
space:
mode:
authorZiemowit Laski <zlaski@apple.com>2001-12-04 00:25:20 +0000
committerZiemowit Laski <zlaski@gcc.gnu.org>2001-12-04 00:25:20 +0000
commit4e089a757d0e64a243ab54969d2dcb094f88e3a6 (patch)
treed7559bc52fc1fa75f1a70224b1c1db1fc1998772 /gcc/objc/objc-act.c
parent9904592eca02e2525bc70247c25b1aa54a5b3b99 (diff)
downloadgcc-4e089a757d0e64a243ab54969d2dcb094f88e3a6.zip
gcc-4e089a757d0e64a243ab54969d2dcb094f88e3a6.tar.gz
gcc-4e089a757d0e64a243ab54969d2dcb094f88e3a6.tar.bz2
Make-lang.in: Update copyright.
* 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. (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. From-SVN: r47575
Diffstat (limited to 'gcc/objc/objc-act.c')
-rw-r--r--gcc/objc/objc-act.c103
1 files changed, 37 insertions, 66 deletions
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 ();