+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.
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));
#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;
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,
#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]
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.
/* & ((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);