summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorshebs <shebs@138bc75d-0d04-0410-961f-82ee72b054a4>2001-05-02 21:51:54 +0000
committershebs <shebs@138bc75d-0d04-0410-961f-82ee72b054a4>2001-05-02 21:51:54 +0000
commit4d4b71d3a3882d64749cf5ac25928d008e551bd2 (patch)
tree9aee520c00a22ccb73b7a416682acfa048a92540 /gcc
parentf3ccb8f1cadfa345c32183efe2cd3038b1599fc0 (diff)
downloadgcc-4d4b71d3a3882d64749cf5ac25928d008e551bd2.tar.gz
* objc/objc-act.c (STRING_OBJECT_CLASS_NAME): Default to
NSConstantString for NeXT-style runtimes. (STRING_OBJECT_GLOBAL_NAME): New macro. (enum objc_tree_index): Add values OCTI_CNST_STR_GLOB_ID and OCTI_STRING_CLASS_DECL. (constant_string_global_id): New macro. (string_class_decl): Ditto. (setup_string_decl): New function. (build_objc_string_object): Use it to build a NeXT runtime compatible string initializer. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@41776 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/objc/objc-act.c52
2 files changed, 64 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 301de81d4c3..a2dee76ffda 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2001-05-02 Stan Shebs <shebs@apple.com>
+
+ * objc/objc-act.c (STRING_OBJECT_CLASS_NAME): Default to
+ NSConstantString for NeXT-style runtimes.
+ (STRING_OBJECT_GLOBAL_NAME): New macro.
+ (enum objc_tree_index): Add values OCTI_CNST_STR_GLOB_ID and
+ OCTI_STRING_CLASS_DECL.
+ (constant_string_global_id): New macro.
+ (string_class_decl): Ditto.
+ (setup_string_decl): New function.
+ (build_objc_string_object): Use it to build a NeXT runtime
+ compatible string initializer.
+
2001-05-02 Jakub Jelinek <jakub@redhat.com>
* tradcpp.c (do_define): Make sure we don't walk past limit.
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index a96a2cea80a..5936e2ea7f3 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -289,6 +289,7 @@ static tree lookup_method_in_protocol_list PARAMS ((tree, tree, int));
static tree lookup_protocol_in_reflist PARAMS ((tree, tree));
static tree create_builtin_decl PARAMS ((enum tree_code,
tree, const char *));
+static void setup_string_decl PARAMS ((void));
static tree my_build_string PARAMS ((int, const char *));
static void build_objc_symtab_template PARAMS ((void));
static tree init_def_list PARAMS ((tree));
@@ -375,7 +376,15 @@ static void ggc_mark_hash_table PARAMS ((void *));
#define UTAG_METHOD_PROTOTYPE "_objc_method_prototype"
#define UTAG_METHOD_PROTOTYPE_LIST "_objc__method_prototype_list"
+#ifdef NEXT_OBJC_RUNTIME
+#define STRING_OBJECT_CLASS_NAME "NSConstantString"
+#else
#define STRING_OBJECT_CLASS_NAME "NXConstantString"
+#endif
+/* Note that the string object global name is only needed for the
+ NeXT runtime. */
+#define STRING_OBJECT_GLOBAL_NAME "_NSConstantStringClassReference"
+
#define PROTOCOL_OBJECT_CLASS_NAME "Protocol"
static const char *constant_string_class_name = NULL;
@@ -455,6 +464,8 @@ enum objc_tree_index
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,
@@ -576,6 +587,8 @@ static int cat_count = 0; /* `@category' */
#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]
@@ -1243,6 +1256,24 @@ create_builtin_decl (code, type, name)
return decl;
}
+/* Find the decl for the constant string class. */
+
+static void
+setup_string_decl ()
+{
+ if (!string_class_decl)
+ {
+ if (!constant_string_global_id)
+ {
+ constant_string_global_id =
+ get_identifier (STRING_OBJECT_GLOBAL_NAME);
+ if (constant_string_global_id == NULL_TREE)
+ return;
+ }
+ string_class_decl = lookup_name (constant_string_global_id);
+ }
+}
+
/* Purpose: "play" parser, creating/installing representations
of the declarations that are required by Objective-C.
@@ -1432,7 +1463,26 @@ build_objc_string_object (strings)
/* & ((NXConstantString) {0, string, length}) */
- initlist = build_tree_list (NULL_TREE, build_int_2 (0, 0));
+ if (flag_next_runtime)
+ {
+ /* For the NeXT runtime, we can generate a literal reference
+ to the string class, don't need to run a constructor. */
+ setup_string_decl ();
+ if (string_class_decl == NULL_TREE)
+ {
+ error ("Cannot find reference tag for class `%s'",
+ IDENTIFIER_POINTER (constant_string_id));
+ return error_mark_node;
+ }
+ initlist = build_tree_list
+ (NULL_TREE,
+ copy_node (build_unary_op (ADDR_EXPR, string_class_decl, 0)));
+ }
+ else
+ {
+ initlist = build_tree_list (NULL_TREE, build_int_2 (0, 0));
+ }
+
initlist
= tree_cons (NULL_TREE, copy_node (build_unary_op (ADDR_EXPR, string, 1)),
initlist);