parse.y (java_stabilize_reference): Return NODE when patching a COMPOUND_EXPR.

1999-03-12  Alexandre Petit-Bianco  <apbianco@cygnus.com>
	* parse.y (java_stabilize_reference): Return NODE when patching a
	COMPOUND_EXPR.
	(java_complete_lhs): Put parenthesis around truth values.
1999-03-12  Alexandre Petit-Bianco  <apbianco@cygnus.com>
	* class.c (layout_class_method): Don't make rtl for interface
	methods.
	* parse.h (GET_TYPE_NAME): New macro.
	* parse.y (if_then_statement:): Fixed indentation.
	(if_then_else_statement:): Likewise.
	(for_statement:): Fixed spacing.
	(try_statement:): Fixed indentation.
	(create_interface): Don't force interfaces to be abstract.
	(method_header): Abstract methods are OK in interfaces.
	(declare_local_variables): Fixed typo in comment.
	(java_complete_expand_method): Fixed indentation.
	(resolve_qualified_expression_name): Use GET_TYPE_NAME to report
	non accessible fields.
	(java_stabilize_reference): New function.
	(java_complete_lhs): Fixed indentation. Use
	java_stabilize_reference in compound assignement. Insert the
	cast. If not processing `+' fix string constants before processing
	binop.

From-SVN: r25733
This commit is contained in:
Alexandre Petit-Bianco 1999-03-12 10:19:04 -08:00
parent 8084bf81c7
commit 2aa11e9772
5 changed files with 417 additions and 300 deletions

View File

@ -1,3 +1,30 @@
1999-03-12 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (java_stabilize_reference): Return NODE when patching a
COMPOUND_EXPR.
(java_complete_lhs): Put parenthesis around truth values.
1999-03-12 Alexandre Petit-Bianco <apbianco@cygnus.com>
* class.c (layout_class_method): Don't make rtl for interface
methods.
* parse.h (GET_TYPE_NAME): New macro.
* parse.y (if_then_statement:): Fixed indentation.
(if_then_else_statement:): Likewise.
(for_statement:): Fixed spacing.
(try_statement:): Fixed indentation.
(create_interface): Don't force interfaces to be abstract.
(method_header): Abstract methods are OK in interfaces.
(declare_local_variables): Fixed typo in comment.
(java_complete_expand_method): Fixed indentation.
(resolve_qualified_expression_name): Use GET_TYPE_NAME to report
non accessible fields.
(java_stabilize_reference): New function.
(java_complete_lhs): Fixed indentation. Use
java_stabilize_reference in compound assignement. Insert the
cast. If not processing `+' fix string constants before processing
binop.
Fri Mar 12 19:42:55 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* constants.c (find_class_or_string_constant): Cast variable `j'
@ -37,6 +64,11 @@ Wed Mar 10 23:20:11 1999 Per Bothner <bothner@cygnus.com>
* jcf-write.c (generate_bytecode_insns): Handle __builtin_fmod, for %.
Tue Mar 9 11:52:08 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (method_header): Don't set ACC_ABSTRACT flags on
interfaces.
Fri Mar 5 15:17:29 1999 Per Bothner <bothner@cygnus.com>
* lex.c (java_parse_end_comment): Take extra parameter (next char).
@ -54,7 +86,7 @@ Fri Mar 5 15:17:29 1999 Per Bothner <bothner@cygnus.com>
* parse.y (find_expr_with_wfl): Optimize tail-calls.
(build_array_from_name): Re-order &index[string] to &string[index].
* parse.y (java_complete_tree): Don't call patch_assignment if rhs is
* parse.y (java_complete_lhs): Don't call patch_assignment if rhs is
error_mark (it might catch more errors, but it is more likely to lose).
Sat Mar 6 11:17:16 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>

View File

@ -1604,7 +1604,8 @@ layout_class_method (this_class, super_class, method_decl, dtable_count)
obstack_1grow (&temporary_obstack, '\0');
asm_name = obstack_finish (&temporary_obstack);
DECL_ASSEMBLER_NAME (method_decl) = get_identifier (asm_name);
if (! METHOD_ABSTRACT (method_decl))
if (! METHOD_ABSTRACT (method_decl)
&& ! CLASS_INTERFACE (TYPE_NAME (this_class)))
make_function_rtl (method_decl);
obstack_free (&temporary_obstack, asm_name);

File diff suppressed because it is too large Load Diff

View File

@ -129,6 +129,13 @@ extern tree stabilize_reference PROTO ((tree));
(TREE_CODE (DECL_NAME (METHOD)) == EXPR_WITH_FILE_LOCATION ? \
EXPR_WFL_NODE (DECL_NAME (METHOD)) : DECL_NAME (METHOD))
/* Get TYPE name string, regardless whether TYPE is a class or an
array. */
#define GET_TYPE_NAME(TYPE) \
(TREE_CODE (TYPE_NAME (TYPE)) == IDENTIFIER_NODE ? \
IDENTIFIER_POINTER (TYPE_NAME (TYPE)) : \
IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TYPE))))
/* Pedantic warning on obsolete modifiers. Note: when cl is NULL,
flags was set artificially, such as for a interface method */
#define OBSOLETE_MODIFIER_WARNING(cl, flags, modifier, format, arg) \

View File

@ -1320,7 +1320,10 @@ statement_expression:
if_then_statement:
IF_TK OP_TK expression CP_TK statement
{ $$ = build_if_else_statement ($2.location, $3, $5, NULL_TREE); }
{
$$ = build_if_else_statement ($2.location, $3,
$5, NULL_TREE);
}
| IF_TK error
{yyerror ("'(' expected"); RECOVER;}
| IF_TK OP_TK error
@ -1331,12 +1334,12 @@ if_then_statement:
if_then_else_statement:
IF_TK OP_TK expression CP_TK statement_nsi ELSE_TK statement
{ $$ = build_if_else_statement ($2.location, $3, $5, $7); }
{ $$ = build_if_else_statement ($2.location, $3, $5, $7); }
;
if_then_else_statement_nsi:
IF_TK OP_TK expression CP_TK statement_nsi ELSE_TK statement_nsi
{ $$ = build_if_else_statement ($2.location, $3, $5, $7); }
{ $$ = build_if_else_statement ($2.location, $3, $5, $7); }
;
switch_statement:
@ -1458,7 +1461,7 @@ do_statement:
for_statement:
for_begin SC_TK expression SC_TK for_update CP_TK statement
{ $$ = complete_for_loop (EXPR_WFL_LINECOL ($3), $3, $5, $7);}
{ $$ = complete_for_loop (EXPR_WFL_LINECOL ($3), $3, $5, $7); }
| for_begin SC_TK SC_TK for_update CP_TK statement
{
$$ = complete_for_loop (0, NULL_TREE, $4, $6);
@ -1621,10 +1624,10 @@ try_statement:
| TRY_TK block finally
{ $$ = build_try_finally_statement ($1.location, $2, $3); }
| TRY_TK block catches finally
{ $$ = build_try_finally_statement ($1.location,
build_try_statement ($1.location,
$2, $3),
$4); }
{ $$ = build_try_finally_statement
($1.location, build_try_statement ($1.location,
$2, $3), $4);
}
| TRY_TK error
{yyerror ("'{' expected"); DRECOVER (try_statement);}
;
@ -2937,7 +2940,7 @@ create_interface (flags, id, super)
decl = maybe_create_class_interface_decl (decl, q_name, id);
/* Set super info and mark the class a complete */
set_super_info (ACC_ABSTRACT | ACC_INTERFACE | flags, TREE_TYPE (decl),
set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl),
object_type_node, ctxp->interface_number);
ctxp->interface_number = 0;
CLASS_COMPLETE_P (decl) = 1;
@ -3297,7 +3300,8 @@ method_header (flags, type, mdecl, throws)
ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final");
ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native");
ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED,id, "Synchronized");
if (!CLASS_ABSTRACT (TYPE_NAME (this_class)))
if (!CLASS_ABSTRACT (TYPE_NAME (this_class))
&& !CLASS_INTERFACE (TYPE_NAME (this_class)))
parse_error_context
(id, "Class `%s' must be declared abstract to define abstract "
"method `%s'",
@ -5248,7 +5252,7 @@ declare_local_variables (modifier, type, vlist)
tree type_wfl = NULL_TREE;
int must_chain = 0;
/* Push a new block if statement were seen between the last time we
/* Push a new block if statements were seen between the last time we
pushed a block and now. Keep a cound of block to close */
if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)))
{
@ -6394,7 +6398,7 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
parse_error_context
(qual_wfl, "Can't access %s field `%s.%s' from `%s'",
java_accstring_lookup (get_access_flags_from_decl (decl)),
IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))),
GET_TYPE_NAME (type),
IDENTIFIER_POINTER (DECL_NAME (decl)),
IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
return 1;
@ -6455,9 +6459,9 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
if (field_decl == NULL_TREE)
{
parse_error_context
(qual_wfl, "No variable `%s' defined in class `%s'",
(qual_wfl, "No variable `%s' defined in type `%s'",
IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
GET_TYPE_NAME (type));
return 1;
}
if (field_decl == error_mark_node)
@ -6486,7 +6490,7 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
"Can't access %s field `%s.%s' from `%s'",
java_accstring_lookup
(get_access_flags_from_decl (field_decl)),
IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))),
GET_TYPE_NAME (type),
IDENTIFIER_POINTER (DECL_NAME (field_decl)),
IDENTIFIER_POINTER
(DECL_NAME (TYPE_NAME (current_class))));
@ -7517,6 +7521,22 @@ java_complete_tree (node)
return node;
}
static tree
java_stabilize_reference (node)
tree node;
{
if (TREE_CODE (node) == COMPOUND_EXPR)
{
tree op0 = TREE_OPERAND (node, 0);
tree op1 = TREE_OPERAND (node, 1);
TREE_OPERAND (node, 0) = build1 (SAVE_EXPR, TREE_TYPE (op0), op0);
TREE_OPERAND (node, 1) = java_stabilize_reference (op1);
return node;
}
else
return stabilize_reference (node);
}
/* Patch tree nodes in a function body. When a BLOCK is found, push
local variable decls if present.
Same as java_complete_tree, but does not resolve static finals to values. */
@ -7644,13 +7664,15 @@ java_complete_lhs (node)
case CLEANUP_POINT_EXPR:
COMPLETE_CHECK_OP_0 (node);
TREE_TYPE (node) = void_type_node;
CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
CAN_COMPLETE_NORMALLY (node) =
CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
return node;
case WITH_CLEANUP_EXPR:
COMPLETE_CHECK_OP_0 (node);
COMPLETE_CHECK_OP_2 (node);
CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
CAN_COMPLETE_NORMALLY (node) =
CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
TREE_TYPE (node) = void_type_node;
return node;
@ -7913,26 +7935,33 @@ java_complete_lhs (node)
if (COMPOUND_ASSIGN_P (wfl_op2))
{
tree lvalue;
tree other =
java_complete_tree (TREE_OPERAND (wfl_op2, 0));
tree lvalue = java_stabilize_reference (TREE_OPERAND (node, 0));
/* Hand stablize the lhs on both places */
lvalue = stabilize_reference (other);
TREE_OPERAND (node, 0) = lvalue;
TREE_OPERAND (TREE_OPERAND (node, 1), 0) = lvalue;
/* Now complete the RHS. We write it back later on. */
nn = java_complete_tree (TREE_OPERAND (node, 1));
/* The last part of the rewrite for E1 op= E2 is to have
E1 = (T)(E1 op E2), with T being the type of E1. */
nn = build_cast (EXPR_WFL_LINECOL (wfl_op2), TREE_TYPE (lvalue), nn);
}
/* If we're about to patch a NEW_ARRAY_INIT, we call a special
function to complete this RHS */
if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT)
else if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT)
nn = patch_new_array_init (TREE_TYPE (TREE_OPERAND (node, 0)),
TREE_OPERAND (node, 1));
/* Otherwise we simply complete the RHS */
else
nn = java_complete_tree (TREE_OPERAND (node, 1));
if (nn == error_mark_node)
return error_mark_node;
/* Write back the RHS as we evaluated it. */
TREE_OPERAND (node, 1) = nn;
/* In case we're handling = with a String as a RHS, we need to
@ -7981,17 +8010,23 @@ java_complete_lhs (node)
CAN_COMPLETE_NORMALLY (node) = 1;
/* Don't complete string nodes if dealing with the PLUS operand. */
if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1))
{
TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
if (TREE_OPERAND (node, 0) == error_mark_node)
return error_mark_node;
}
{
nn = java_complete_tree (wfl_op1);
if (nn == error_mark_node)
return error_mark_node;
if ((cn = patch_string (nn)))
nn = cn;
TREE_OPERAND (node, 0) = nn;
}
if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2))
{
TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
if (TREE_OPERAND (node, 1) == error_mark_node)
return error_mark_node;
}
{
nn = java_complete_tree (wfl_op2);
if (nn == error_mark_node)
return error_mark_node;
if ((cn = patch_string (nn)))
nn = cn;
TREE_OPERAND (node, 1) = nn;
}
return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2));
case INSTANCEOF_EXPR: