Commit ba179f9f by Alexandre Petit-Bianco Committed by Alexandre Petit-Bianco

class.c (maybe_layout_super_class): Fixed returned value.

Wed Jan 13 01:24:54 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>
	* class.c (maybe_layout_super_class): Fixed returned value.
	* lex.c: Added 1999 to the copyright.
	(java_init_lex): Initialize java_lang_imported.
	* lex.h: Added 1999 to the copyright.
	* parse.h: Added 1999 to the copyright.
	(REGISTER_IMPORT): Fixed typo in trailing macro.
	(CURRENT_OSB): New macro.
	(struct parser_ctxt): New fields osb_depth, osb_limit.
	* parse.y (java_lang_id): New global variable.
	(type_import_on_demand_declaration): Don't import java.lang.* twice.
	(array_creation_expression:): Use CURRENT_OSB.
	(dims:): Uses a stack to keep track of array dimensions.
	(cast_expression:): Use CURRENT_OSB.
	(find_expr_with_wfl): Return NULL if node found doesn't meet the
 	conditions.
	(register_fields): Fixed typos in comment.
	(check_method_redefinition): Fixed comment indentation.
	(java_check_regular_methods): Set saved found wfl to NULL after
 	having reinstalled it in the previously found DECL_NAME.
Fix an array dimension counting bug and some random other ones.

From-SVN: r24648
parent 3c9a0f78
Wed Jan 13 01:24:54 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
* class.c (maybe_layout_super_class): Fixed returned value.
* lex.c: Added 1999 to the copyright.
(java_init_lex): Initialize java_lang_imported.
* lex.h: Added 1999 to the copyright.
* parse.h: Added 1999 to the copyright.
(REGISTER_IMPORT): Fixed typo in trailing macro.
(CURRENT_OSB): New macro.
(struct parser_ctxt): New fields osb_depth, osb_limit.
* parse.y (java_lang_id): New global variable.
(type_import_on_demand_declaration): Don't import java.lang.* twice.
(array_creation_expression:): Use CURRENT_OSB.
(dims:): Uses a stack to keep track of array dimensions.
(cast_expression:): Use CURRENT_OSB.
(find_expr_with_wfl): Return NULL if node found doesn't meet the
conditions.
(register_fields): Fixed typos in comment.
(check_method_redefinition): Fixed comment indentation.
(java_check_regular_methods): Set saved found wfl to NULL after
having reinstalled it in the previously found DECL_NAME.
Sun Jan 10 13:36:14 1999 Richard Henderson <rth@cygnus.com> Sun Jan 10 13:36:14 1999 Richard Henderson <rth@cygnus.com>
* gjavah.c (java_float_finite): Use a union to do type punning. * gjavah.c (java_float_finite): Use a union to do type punning.
......
...@@ -1411,7 +1411,7 @@ maybe_layout_super_class (super_class) ...@@ -1411,7 +1411,7 @@ maybe_layout_super_class (super_class)
load_class (name, 1); load_class (name, 1);
super_class = IDENTIFIER_CLASS_VALUE (name); super_class = IDENTIFIER_CLASS_VALUE (name);
if (!super_class) if (!super_class)
return; return NULL_TREE; /* FIXME, NULL_TREE not checked by caller. */
super_class = TREE_TYPE (super_class); super_class = TREE_TYPE (super_class);
} }
if (!TYPE_SIZE (super_class)) if (!TYPE_SIZE (super_class))
......
...@@ -80,10 +80,13 @@ java_init_lex () ...@@ -80,10 +80,13 @@ java_init_lex ()
int java_lang_imported = 0; int java_lang_imported = 0;
#ifndef JC1_LITE #ifndef JC1_LITE
if (!java_lang_id)
java_lang_id = get_identifier ("java.lang");
if (!java_lang_imported) if (!java_lang_imported)
{ {
tree node = build_tree_list tree node = build_tree_list
(build_expr_wfl (get_identifier ("java.lang"), NULL, 0, 0), NULL_TREE); (build_expr_wfl (java_lang_id, NULL, 0, 0), NULL_TREE);
read_import_dir (TREE_PURPOSE (node)); read_import_dir (TREE_PURPOSE (node));
TREE_CHAIN (node) = ctxp->import_demand_list; TREE_CHAIN (node) = ctxp->import_demand_list;
ctxp->import_demand_list = node; ctxp->import_demand_list = node;
......
...@@ -569,7 +569,7 @@ static jdeplist *reverse_jdep_list (); ...@@ -569,7 +569,7 @@ static jdeplist *reverse_jdep_list ();
ctxp->deprecated = 0; \ ctxp->deprecated = 0; \
} }
/* Register an impor */ /* Register an import */
#define REGISTER_IMPORT(WHOLE, NAME) \ #define REGISTER_IMPORT(WHOLE, NAME) \
{ \ { \
IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P ((NAME)) = 1; \ IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P ((NAME)) = 1; \
...@@ -577,6 +577,9 @@ static jdeplist *reverse_jdep_list (); ...@@ -577,6 +577,9 @@ static jdeplist *reverse_jdep_list ();
TREE_CHAIN (node) = ctxp->import_list; \ TREE_CHAIN (node) = ctxp->import_list; \
ctxp->import_list = node; \ ctxp->import_list = node; \
} }
/* Macro to access the osb (opening square bracket) count */
#define CURRENT_OSB(C) (C)->osb_number [(C)->osb_depth]
/* Parser context data structure. */ /* Parser context data structure. */
struct parser_ctxt { struct parser_ctxt {
...@@ -592,7 +595,9 @@ struct parser_ctxt { ...@@ -592,7 +595,9 @@ struct parser_ctxt {
int first_ccb_indent1; /* First { at ident level 1 */ int first_ccb_indent1; /* First { at ident level 1 */
int last_ccb_indent1; /* Last } at ident level 1 */ int last_ccb_indent1; /* Last } at ident level 1 */
int parser_ccb_indent; /* Keep track of {} indent, parser */ int parser_ccb_indent; /* Keep track of {} indent, parser */
int osb_number; /* Keep track of ['s */ int osb_depth; /* Current depth of [ in an expression */
int osb_limit; /* Limit of this depth */
int *osb_number; /* Keep track of ['s */
int minus_seen; /* Integral literal overflow */ int minus_seen; /* Integral literal overflow */
int lineno; /* Current lineno */ int lineno; /* Current lineno */
int java_error_flag; /* Report error when true */ int java_error_flag; /* Report error when true */
......
...@@ -281,6 +281,9 @@ static tree wfl_append = NULL_TREE; ...@@ -281,6 +281,9 @@ static tree wfl_append = NULL_TREE;
/* The "toString" identifier used for String `+' operator. */ /* The "toString" identifier used for String `+' operator. */
static tree wfl_to_string = NULL_TREE; static tree wfl_to_string = NULL_TREE;
/* The "java.lang" import qualified name. */
static tree java_lang_id = NULL_TREE;
%} %}
%union { %union {
...@@ -591,10 +594,14 @@ type_import_on_demand_declaration: ...@@ -591,10 +594,14 @@ type_import_on_demand_declaration:
IMPORT_TK name DOT_TK MULT_TK SC_TK IMPORT_TK name DOT_TK MULT_TK SC_TK
{ {
tree name = EXPR_WFL_NODE ($2); tree name = EXPR_WFL_NODE ($2);
tree node = build_tree_list ($2, NULL_TREE); /* Don't import java.lang.* twice. */
read_import_dir ($2); if (name != java_lang_id)
TREE_CHAIN (node) = ctxp->import_demand_list; {
ctxp->import_demand_list = node; tree node = build_tree_list ($2, NULL_TREE);
read_import_dir ($2);
TREE_CHAIN (node) = ctxp->import_demand_list;
ctxp->import_demand_list = node;
}
} }
| IMPORT_TK name DOT_TK error | IMPORT_TK name DOT_TK error
{yyerror ("'*' expected"); RECOVER;} {yyerror ("'*' expected"); RECOVER;}
...@@ -1760,9 +1767,9 @@ array_creation_expression: ...@@ -1760,9 +1767,9 @@ array_creation_expression:
| NEW_TK class_or_interface_type dim_exprs | NEW_TK class_or_interface_type dim_exprs
{ $$ = build_newarray_node ($2, $3, 0); } { $$ = build_newarray_node ($2, $3, 0); }
| NEW_TK primitive_type dim_exprs dims | NEW_TK primitive_type dim_exprs dims
{ $$ = build_newarray_node ($2, $3, ctxp->osb_number); } { $$ = build_newarray_node ($2, $3, CURRENT_OSB (ctxp));}
| NEW_TK class_or_interface_type dim_exprs dims | NEW_TK class_or_interface_type dim_exprs dims
{ $$ = build_newarray_node ($2, $3, ctxp->osb_number); } { $$ = build_newarray_node ($2, $3, CURRENT_OSB (ctxp));}
/* Added, JDK1.1 anonymous array. Initial documentation rule /* Added, JDK1.1 anonymous array. Initial documentation rule
modified */ modified */
| NEW_TK class_or_interface_type dims array_initializer | NEW_TK class_or_interface_type dims array_initializer
...@@ -1800,9 +1807,33 @@ dim_expr: ...@@ -1800,9 +1807,33 @@ dim_expr:
dims: dims:
OSB_TK CSB_TK OSB_TK CSB_TK
{ ctxp->osb_number = 1; } {
int allocate = 0;
/* If not initialized, allocate memory for the osb
numbers stack */
if (!ctxp->osb_limit)
{
allocate = ctxp->osb_limit = 32;
ctxp->osb_depth = -1;
}
/* If capacity overflown, reallocate a bigger chuck */
else if (ctxp->osb_depth+1 == ctxp->osb_limit)
allocate = ctxp->osb_limit << 1;
if (allocate)
{
allocate *= sizeof (int);
if (ctxp->osb_number)
ctxp->osb_number = (int *)xrealloc (ctxp->osb_number,
allocate);
else
ctxp->osb_number = (int *)xmalloc (allocate);
}
ctxp->osb_depth++;
CURRENT_OSB (ctxp) = 1;
}
| dims OSB_TK CSB_TK | dims OSB_TK CSB_TK
{ ctxp->osb_number++; } { CURRENT_OSB (ctxp)++; }
| dims OSB_TK error | dims OSB_TK error
{ yyerror ("']' expected"); RECOVER;} { yyerror ("']' expected"); RECOVER;}
; ;
...@@ -1960,8 +1991,9 @@ cast_expression: /* Error handling here is potentially weak */ ...@@ -1960,8 +1991,9 @@ cast_expression: /* Error handling here is potentially weak */
OP_TK primitive_type dims CP_TK unary_expression OP_TK primitive_type dims CP_TK unary_expression
{ {
tree type = $2; tree type = $2;
while (ctxp->osb_number--) while (CURRENT_OSB (ctxp)--)
type = build_java_array_type (type, -1); type = build_java_array_type (type, -1);
ctxp->osb_depth--;
$$ = build_cast ($1.location, type, $5); $$ = build_cast ($1.location, type, $5);
} }
| OP_TK primitive_type CP_TK unary_expression | OP_TK primitive_type CP_TK unary_expression
...@@ -1971,8 +2003,9 @@ cast_expression: /* Error handling here is potentially weak */ ...@@ -1971,8 +2003,9 @@ cast_expression: /* Error handling here is potentially weak */
| OP_TK name dims CP_TK unary_expression_not_plus_minus | OP_TK name dims CP_TK unary_expression_not_plus_minus
{ {
char *ptr; char *ptr;
while (ctxp->osb_number--) while (CURRENT_OSB (ctxp)--)
obstack_1grow (&temporary_obstack, '['); obstack_1grow (&temporary_obstack, '[');
ctxp->osb_depth--;
obstack_grow0 (&temporary_obstack, obstack_grow0 (&temporary_obstack,
IDENTIFIER_POINTER (EXPR_WFL_NODE ($2)), IDENTIFIER_POINTER (EXPR_WFL_NODE ($2)),
IDENTIFIER_LENGTH (EXPR_WFL_NODE ($2))); IDENTIFIER_LENGTH (EXPR_WFL_NODE ($2)));
...@@ -2513,6 +2546,7 @@ find_expr_with_wfl (node) ...@@ -2513,6 +2546,7 @@ find_expr_with_wfl (node)
if (((code == '1') || (code == '2') || (code == 'e')) if (((code == '1') || (code == '2') || (code == 'e'))
&& EXPR_WFL_LINECOL (node)) && EXPR_WFL_LINECOL (node))
return node; return node;
return NULL_TREE;
} }
} }
return NULL_TREE; return NULL_TREE;
...@@ -3130,9 +3164,9 @@ register_fields (flags, type, variable_list) ...@@ -3130,9 +3164,9 @@ register_fields (flags, type, variable_list)
{ {
/* We include the field and its initialization part into /* We include the field and its initialization part into
a list used to generate <clinit>. After <clinit> is a list used to generate <clinit>. After <clinit> is
walked, fields initialization will be processed and walked, field initializations will be processed and
fields initialized with know constants will be taken fields initialized with known constants will be taken
out of <clinit> and have ther DECL_INITIAL set out of <clinit> and have their DECL_INITIAL set
appropriately. */ appropriately. */
TREE_CHAIN (init) = ctxp->static_initialized; TREE_CHAIN (init) = ctxp->static_initialized;
ctxp->static_initialized = init; ctxp->static_initialized = init;
...@@ -4395,8 +4429,8 @@ check_method_redefinition (class, method) ...@@ -4395,8 +4429,8 @@ check_method_redefinition (class, method)
tree redef, name; tree redef, name;
tree cl = DECL_NAME (method); tree cl = DECL_NAME (method);
tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method)); tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
/* decl name of artificial <clinit> and $finit$ doesn't need to be fixed and /* decl name of artificial <clinit> and $finit$ doesn't need to be
checked */ fixed and checked */
/* Reset the method name before running the check. If it returns 1, /* Reset the method name before running the check. If it returns 1,
the method doesn't need to be verified with respect to method the method doesn't need to be verified with respect to method
...@@ -4454,7 +4488,10 @@ java_check_regular_methods (class_decl) ...@@ -4454,7 +4488,10 @@ java_check_regular_methods (class_decl)
/* If we previously found something and its name was saved, /* If we previously found something and its name was saved,
reinstall it now */ reinstall it now */
if (found && saved_found_wfl) if (found && saved_found_wfl)
DECL_NAME (found) = saved_found_wfl; {
DECL_NAME (found) = saved_found_wfl;
saved_found_wfl = NULL_TREE;
}
/* Check for redefinitions */ /* Check for redefinitions */
if (check_method_redefinition (class, method)) if (check_method_redefinition (class, method))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment