aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/jcf-parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/java/jcf-parse.c')
-rw-r--r--gcc/java/jcf-parse.c95
1 files changed, 31 insertions, 64 deletions
diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c
index e85b5781f83..b7478c5e801 100644
--- a/gcc/java/jcf-parse.c
+++ b/gcc/java/jcf-parse.c
@@ -96,6 +96,7 @@ static void parse_zip_file_entries PARAMS ((void));
static void process_zip_dir PARAMS ((FILE *));
static void parse_source_file_1 PARAMS ((tree, FILE *));
static void parse_source_file_2 PARAMS ((void));
+static void parse_source_file_3 PARAMS ((void));
static void parse_class_file PARAMS ((void));
static void set_source_filename PARAMS ((JCF *, int));
static void ggc_mark_jcf PARAMS ((void**));
@@ -291,10 +292,10 @@ get_constant (jcf, index)
}
case CONSTANT_Long:
{
- jint num = JPOOL_INT (jcf, index);
+ unsigned HOST_WIDE_INT num = JPOOL_UINT (jcf, index);
HOST_WIDE_INT lo, hi;
lshift_double (num, 0, 32, 64, &lo, &hi, 0);
- num = JPOOL_INT (jcf, index+1) & 0xffffffff;
+ num = JPOOL_UINT (jcf, index+1);
add_double (lo, hi, num, 0, &lo, &hi);
value = build_int_2 (lo, hi);
TREE_TYPE (value) = long_type_node;
@@ -321,9 +322,9 @@ get_constant (jcf, index)
HOST_WIDE_INT num[2];
REAL_VALUE_TYPE d;
HOST_WIDE_INT lo, hi;
- num[0] = JPOOL_INT (jcf, index);
+ num[0] = JPOOL_UINT (jcf, index);
lshift_double (num[0], 0, 32, 64, &lo, &hi, 0);
- num[0] = JPOOL_INT (jcf, index+1);
+ num[0] = JPOOL_UINT (jcf, index+1);
add_double (lo, hi, num[0], 0, &lo, &hi);
/* Since ereal_from_double expects an array of HOST_WIDE_INT
@@ -362,16 +363,12 @@ get_constant (jcf, index)
tree name = get_name_constant (jcf, JPOOL_USHORT1 (jcf, index));
const char *utf8_ptr = IDENTIFIER_POINTER (name);
int utf8_len = IDENTIFIER_LENGTH (name);
- unsigned char *str_ptr;
- unsigned char *str;
const unsigned char *utf8;
- int i, str_len;
+ int i;
- /* Count the number of Unicode characters in the string,
- while checking for a malformed Utf8 string. */
+ /* Check for a malformed Utf8 string. */
utf8 = (const unsigned char *) utf8_ptr;
i = utf8_len;
- str_len = 0;
while (i > 0)
{
int char_len = UT8_CHAR_LENGTH (*utf8);
@@ -380,48 +377,10 @@ get_constant (jcf, index)
utf8 += char_len;
i -= char_len;
- str_len++;
}
- /* Allocate a scratch buffer, convert the string to UCS2, and copy it
- into the new space. */
- str_ptr = (unsigned char *) alloca (2 * str_len);
- str = str_ptr;
- utf8 = (const unsigned char *)utf8_ptr;
-
- for (i = 0; i < str_len; i++)
- {
- int char_value;
- int char_len = UT8_CHAR_LENGTH (*utf8);
- switch (char_len)
- {
- case 1:
- char_value = *utf8++;
- break;
- case 2:
- char_value = *utf8++ & 0x1F;
- char_value = (char_value << 6) | (*utf8++ & 0x3F);
- break;
- case 3:
- char_value = *utf8++ & 0x0F;
- char_value = (char_value << 6) | (*utf8++ & 0x3F);
- char_value = (char_value << 6) | (*utf8++ & 0x3F);
- break;
- default:
- goto bad;
- }
- if (BYTES_BIG_ENDIAN)
- {
- *str++ = char_value >> 8;
- *str++ = char_value & 0xFF;
- }
- else
- {
- *str++ = char_value & 0xFF;
- *str++ = char_value >> 8;
- }
- }
- value = build_string (str - str_ptr, str_ptr);
+ /* Allocate a new string value. */
+ value = build_string (utf8_len, utf8_ptr);
TREE_TYPE (value) = build_pointer_type (string_type_node);
}
break;
@@ -607,6 +566,7 @@ read_class (name)
fatal_io_error ("can't reopen %s", input_filename);
parse_source_file_1 (file, finput);
parse_source_file_2 ();
+ parse_source_file_3 ();
if (fclose (finput))
fatal_io_error ("can't close %s", input_filename);
}
@@ -669,20 +629,20 @@ load_class (class_or_name, verbose)
saved = name;
while (1)
{
- char *dollar;
+ char *separator;
if ((class_loaded = read_class (name)))
break;
/* We failed loading name. Now consider that we might be looking
- for a inner class but it's only available in source for in
- its enclosing context. */
- if ((dollar = strrchr (IDENTIFIER_POINTER (name), '$')))
+ for a inner class. */
+ if ((separator = strrchr (IDENTIFIER_POINTER (name), '$'))
+ || (separator = strrchr (IDENTIFIER_POINTER (name), '.')))
{
- int c = *dollar;
- *dollar = '\0';
+ int c = *separator;
+ *separator = '\0';
name = get_identifier (IDENTIFIER_POINTER (name));
- *dollar = c;
+ *separator = c;
}
/* Otherwise, we failed, we bail. */
else
@@ -940,6 +900,12 @@ parse_source_file_2 ()
int save_error_count = java_error_count;
java_complete_class (); /* Parse unsatisfied class decl. */
java_parse_abort_on_error ();
+}
+
+static void
+parse_source_file_3 ()
+{
+ int save_error_count = java_error_count;
java_check_circular_reference (); /* Check on circular references */
java_parse_abort_on_error ();
java_fix_constructors (); /* Fix the constructors */
@@ -1049,9 +1015,6 @@ yyparse ()
int len = strlen (list);
- if (*list != '/' && filename_count > 0)
- obstack_grow (&temporary_obstack, "./", 2);
-
obstack_grow0 (&temporary_obstack, list, len);
value = obstack_finish (&temporary_obstack);
@@ -1108,10 +1071,7 @@ yyparse ()
resource_filename = IDENTIFIER_POINTER (TREE_VALUE (current_file_list));
compile_resource_file (resource_name, resource_filename);
-
- java_expand_classes ();
- if (!java_report_errors ())
- emit_register_classes ();
+
return 0;
}
@@ -1192,6 +1152,13 @@ yyparse ()
input_filename = ctxp->filename;
parse_source_file_2 ();
}
+
+ for (ctxp = ctxp_for_generation; ctxp; ctxp = ctxp->next)
+ {
+ input_filename = ctxp->filename;
+ parse_source_file_3 ();
+ }
+
for (node = current_file_list; node; node = TREE_CHAIN (node))
{
input_filename = IDENTIFIER_POINTER (TREE_VALUE (node));