/* Functions related to building classes and their related objects.
- Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1996, 97-98, 1999 Free Software Foundation, Inc.
This file is part of GNU CC.
#include "jcf.h"
#include "obstack.h"
#include "toplev.h"
+#include "output.h"
+#include "parse.h"
static tree mangle_class_field PROTO ((tree class));
tree
mangled_classname (prefix, type)
- char *prefix;
- tree type;
+ const char *prefix;
+ tree type;
{
tree ident = TYPE_NAME (type);
if (TREE_CODE (ident) != IDENTIFIER_NODE)
ident = DECL_NAME (ident);
- return identifier_subst (ident, prefix, '/', '_', "");
+ return identifier_subst (ident, prefix, '.', '_', "");
}
tree
add_interface_do (basetype_vec, interface_class, i);
}
+#if 0
/* Return the address of a pointer to the first FUNCTION_DECL
in the list (*LIST) whose DECL_NAME is NAME. */
list = &TREE_CHAIN (*list);
return list;
}
+#endif
tree
build_java_method_type (fntype, this_class, access_flags)
buf_ptr = &buf[strlen (buf)];
while (--name_len >= 0)
{
- char c = *name_ptr++;
+ unsigned char c = *name_ptr++;
if (c & 0x80)
continue;
- if (!isalpha(c) && !isdigit(c))
+ if (!ISALPHA(c) && !ISDIGIT(c))
c = '_';
*buf_ptr++ = c;
if (buf_ptr >= buf + 50)
{
char *name;
char buffer[25];
+ if (flag_emit_class_files)
+ {
+ const char *prim_class_name;
+ tree prim_class;
+ if (type == char_type_node)
+ prim_class_name = "java.lang.Character";
+ else if (type == boolean_type_node)
+ prim_class_name = "java.lang.Boolean";
+ else if (type == byte_type_node)
+ prim_class_name = "java.lang.Byte";
+ else if (type == short_type_node)
+ prim_class_name = "java.lang.Short";
+ else if (type == int_type_node)
+ prim_class_name = "java.lang.Integer";
+ else if (type == long_type_node)
+ prim_class_name = "java.lang.Long";
+ else if (type == float_type_node)
+ prim_class_name = "java.lang.Float";
+ else if (type == double_type_node)
+ prim_class_name = "java.lang.Double";
+ else if (type == void_type_node)
+ prim_class_name = "java.lang.Void";
+ else
+ fatal ("internal error - bad type to build_class_ref");
+ prim_class = lookup_class (get_identifier (prim_class_name));
+ return build (COMPONENT_REF, NULL_TREE,
+ prim_class, TYPE_identifier_node);
+ }
decl_name = TYPE_NAME (type);
if (TREE_CODE (decl_name) == TYPE_DECL)
decl_name = DECL_NAME (decl_name);
if (resolved)
type = build_class_ref (type);
else
- type = build_utf8_ref (build_java_signature (type));
+ {
+ tree signature = build_java_signature (type);
+ type = build_utf8_ref (unmangle_classname
+ (IDENTIFIER_POINTER(signature),
+ IDENTIFIER_LENGTH(signature)));
+ }
PUSH_FIELD_VALUE (finit, "type", type);
flags = get_access_flags_from_decl (fdecl);
if (! resolved)
build_utf8_ref (DECL_CONSTRUCTOR_P (mdecl) ?
init_identifier_node
: DECL_NAME (mdecl)));
- PUSH_FIELD_VALUE (minit, "signature",
- build_utf8_ref (build_java_signature (TREE_TYPE (mdecl))));
+ {
+ tree signature = build_java_signature (TREE_TYPE (mdecl));
+ PUSH_FIELD_VALUE (minit, "signature",
+ (build_utf8_ref
+ (unmangle_classname
+ (IDENTIFIER_POINTER(signature),
+ IDENTIFIER_LENGTH(signature)))));
+ }
PUSH_FIELD_VALUE (minit, "accflags", build_int_2 (accflags, 0));
PUSH_FIELD_VALUE (minit, "ncode", code);
FINISH_RECORD_CONSTRUCTOR (minit);
START_RECORD_CONSTRUCTOR (temp, object_type_node);
#if 0
- PUSH_FIELD_VALUE (temp, "dtable", NULL_TREE);
+ PUSH_FIELD_VALUE (temp, "vtable", NULL_TREE);
#else
- PUSH_FIELD_VALUE (temp, "dtable",
+ PUSH_FIELD_VALUE (temp, "vtable",
build1 (ADDR_EXPR, dtable_ptr_type, class_dtable_decl));
#endif
PUSH_FIELD_VALUE (temp, "sync_info", null_pointer_node);
START_RECORD_CONSTRUCTOR (cons, class_type_node);
PUSH_SUPER_VALUE (cons, temp);
PUSH_FIELD_VALUE (cons, "next", null_pointer_node);
-#if 0
- /* Need to fix _Jv_FindClassFromSignature. */
PUSH_FIELD_VALUE (cons, "name", build_utf8_ref (DECL_NAME (type_decl)));
-#else
- PUSH_FIELD_VALUE (cons, "name",
- build_utf8_ref (build_internal_class_name (type)));
-#endif
PUSH_FIELD_VALUE (cons, "accflags",
build_int_2 (get_access_flags_from_decl (type_decl), 0));
- PUSH_FIELD_VALUE (cons, "superclass", super);
+ PUSH_FIELD_VALUE (cons, "superclass",
+ CLASS_INTERFACE (type_decl) ? null_pointer_node : super);
PUSH_FIELD_VALUE (cons, "constants", constant_pool_constructor);
PUSH_FIELD_VALUE (cons, "methods",
build1 (ADDR_EXPR, method_ptr_type_node, methods_decl));
PUSH_FIELD_VALUE (cons, "method_count", build_int_2 (method_count, 0));
- PUSH_FIELD_VALUE (cons, "dtable_method_count", TYPE_NVIRTUALS (type));
+ PUSH_FIELD_VALUE (cons, "vtable_method_count", TYPE_NVIRTUALS (type));
PUSH_FIELD_VALUE (cons, "fields",
fields_decl == NULL_TREE ? null_pointer_node
: build1 (ADDR_EXPR, field_ptr_type_node, fields_decl));
PUSH_FIELD_VALUE (cons, "field_count", build_int_2 (field_count, 0));
PUSH_FIELD_VALUE (cons, "static_field_count",
build_int_2 (static_field_count, 0));
- PUSH_FIELD_VALUE (cons, "dtable",
+ PUSH_FIELD_VALUE (cons, "vtable",
dtable_decl == NULL_TREE ? null_pointer_node
: build1 (ADDR_EXPR, dtable_ptr_type, dtable_decl));
PUSH_FIELD_VALUE (cons, "interfaces", interfaces);
load_class (name, 1);
super_class = IDENTIFIER_CLASS_VALUE (name);
if (!super_class)
- return;
+ return NULL_TREE; /* FIXME, NULL_TREE not checked by caller. */
super_class = TREE_TYPE (super_class);
}
if (!TYPE_SIZE (super_class))
tree this_class, super_class, method_decl, dtable_count;
{
char *ptr;
- char buf[8];
char *asm_name;
tree arg, arglist, t;
int method_name_needs_escapes = 0;
else
DECL_NAME (method_decl) = get_identifier (p);
DECL_CONSTRUCTOR_P (method_decl) = 1;
+ build_java_argument_signature (TREE_TYPE (method_decl));
}
else if (! METHOD_STATIC (method_decl) && !DECL_ARTIFICIAL (method_decl))
{