This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Java,Committed] Replace build with buildN in parse.y


My previous patches to transition the java front-end from build to
buildN neglected files other than *.c.  It turns out that parse.y
is a major user of "build" and there are several uses in some of
the .h files.  This patch also corrects one or two recent changes.

The following patch has been tested on i686-pc-linux-gnu, with a full
"make bootstrap" including java, and regression tested with a top-level
"make -k check" with no new failures.  There should absolutely no
functional changes with this patch.

Committed to mainline CVS as obvious/pre-approved by Per.


2004-08-01  Roger Sayle  <roger@eyesopen.com>

	* decl.c (update_aliases, initialize_local_variable): Replace calls
	to build with calls to buildN.
	* java-gimplify.c (java_gimplify_modify_expr): Likewise.
	* java-tree.h (BUILD_MONITOR_ENTER, BUILD_MONITOR_EXIT): Likewise.
	* parse.h (BUILD_THROW): Likewise.
	* parse.y (switch_expression, synchronized_statement,
	catch_clause_parameter, array_creation_expression,
	conditional_expression, make_qualified_name,
	resolve_qualified_expression_name, patch_method_invocation,
	patch_invoke, build_method_invocation, build_new_invocation,
	build_assignment, patch_assignment, build_binop, patch_binop,
	build_string_concatenation, build_incdec, patch_unaryop,
	patch_cast, build_array_ref, build_newarray_node, patch_newarray,
	patch_return, build_if_else_statement, build_labeled_block,
	build_new_loop, build_loop_body, build_bc_statement,
	build_assertion, encapsulate_with_try_catch, build_try_statement,
	build_try_finally_statement, patch_synchronized_statement,
	emit_test_initialization): Likewise, replace build with buildN.


Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/decl.c,v
retrieving revision 1.192
diff -c -3 -p -r1.192 decl.c
*** decl.c	25 Jul 2004 17:54:37 -0000	1.192
--- decl.c	1 Aug 2004 15:01:50 -0000
*************** update_aliases (tree decl, int index, in
*** 153,160 ****
  	  tree src = build1 (NOP_EXPR, tmp_type, decl);
  	  if (LOCAL_VAR_OUT_OF_SCOPE_P (tmp))
  	    abort ();
! 	  java_add_stmt
! 	    (build (MODIFY_EXPR, tmp_type, tmp, src));
  	}
      }
  }
--- 153,159 ----
  	  tree src = build1 (NOP_EXPR, tmp_type, decl);
  	  if (LOCAL_VAR_OUT_OF_SCOPE_P (tmp))
  	    abort ();
! 	  java_add_stmt (build2 (MODIFY_EXPR, tmp_type, tmp, src));
  	}
      }
  }
*************** initialize_local_variable (tree decl, in
*** 196,203 ****
  	  /* At the point of its creation this decl inherits whatever
  	     is in the slot.  */
  	  tree src = build1 (NOP_EXPR, decl_type, tmp);
! 	  java_add_stmt
! 	    (build (MODIFY_EXPR, decl_type, decl, src));
  	}
      }
    else
--- 195,201 ----
  	  /* At the point of its creation this decl inherits whatever
  	     is in the slot.  */
  	  tree src = build1 (NOP_EXPR, decl_type, tmp);
! 	  java_add_stmt (build2 (MODIFY_EXPR, decl_type, decl, src));
  	}
      }
    else
*************** initialize_local_variable (tree decl, in
*** 216,225 ****
  		      && INTEGRAL_TYPE_P (decl_type)
  		      && TYPE_PRECISION (decl_type) <= 32
  		      && TYPE_PRECISION (tmp_type) <= 32
! 		      && TYPE_PRECISION (tmp_type) >= TYPE_PRECISION (decl_type))))
  	    {
! 	      java_add_stmt
! 		(build (MODIFY_EXPR, decl_type, decl, tmp));
  	      return;
  	    }
  	}
--- 214,223 ----
  		      && INTEGRAL_TYPE_P (decl_type)
  		      && TYPE_PRECISION (decl_type) <= 32
  		      && TYPE_PRECISION (tmp_type) <= 32
! 		      && TYPE_PRECISION (tmp_type)
! 			 >= TYPE_PRECISION (decl_type))))
  	    {
! 	      java_add_stmt (build2 (MODIFY_EXPR, decl_type, decl, tmp));
  	      return;
  	    }
  	}
Index: java-gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-gimplify.c,v
retrieving revision 1.8
diff -c -3 -p -r1.8 java-gimplify.c
*** java-gimplify.c	21 Jul 2004 16:03:43 -0000	1.8
--- java-gimplify.c	1 Aug 2004 15:01:50 -0000
*************** java_gimplify_modify_expr (tree modify_e
*** 174,181 ****
      {
        tree new_lhs = java_replace_reference (lhs, /* want_lvalue */ true);
        tree new_rhs = build1 (NOP_EXPR, TREE_TYPE (new_lhs), rhs);
!       modify_expr = build (MODIFY_EXPR, TREE_TYPE (new_lhs),
! 			   new_lhs, new_rhs);
        modify_expr = build1 (NOP_EXPR, lhs_type, modify_expr);
      }

--- 174,181 ----
      {
        tree new_lhs = java_replace_reference (lhs, /* want_lvalue */ true);
        tree new_rhs = build1 (NOP_EXPR, TREE_TYPE (new_lhs), rhs);
!       modify_expr = build2 (MODIFY_EXPR, TREE_TYPE (new_lhs),
! 			    new_lhs, new_rhs);
        modify_expr = build1 (NOP_EXPR, lhs_type, modify_expr);
      }

Index: java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.214
diff -c -3 -p -r1.214 java-tree.h
*** java-tree.h	21 Jul 2004 16:03:43 -0000	1.214
--- java-tree.h	1 Aug 2004 15:01:50 -0000
*************** while (0)
*** 1761,1781 ****
  #define BLOCK_EMPTY_P(NODE) \
    (TREE_CODE (NODE) == BLOCK && BLOCK_EXPR_BODY (NODE) == empty_stmt_node)

! #define BUILD_MONITOR_ENTER(WHERE, ARG)				\
!   {								\
!     (WHERE) = build (CALL_EXPR, int_type_node,			\
! 		     build_address_of (soft_monitorenter_node),	\
! 		     build_tree_list (NULL_TREE, (ARG)), 	\
! 		     NULL_TREE);				\
!     TREE_SIDE_EFFECTS (WHERE) = 1;				\
    }

  #define BUILD_MONITOR_EXIT(WHERE, ARG)				\
    {								\
!     (WHERE) = build (CALL_EXPR, int_type_node,			\
! 		     build_address_of (soft_monitorexit_node),	\
! 		     build_tree_list (NULL_TREE, (ARG)),	\
! 		     NULL_TREE);				\
      TREE_SIDE_EFFECTS (WHERE) = 1;				\
    }

--- 1761,1781 ----
  #define BLOCK_EMPTY_P(NODE) \
    (TREE_CODE (NODE) == BLOCK && BLOCK_EXPR_BODY (NODE) == empty_stmt_node)

! #define BUILD_MONITOR_ENTER(WHERE, ARG)					\
!   {									\
!     (WHERE) = build3 (CALL_EXPR, int_type_node,				\
! 		      build_address_of (soft_monitorenter_node),	\
! 		      build_tree_list (NULL_TREE, (ARG)),	 	\
! 		      NULL_TREE);					\
!     TREE_SIDE_EFFECTS (WHERE) = 1;					\
    }

  #define BUILD_MONITOR_EXIT(WHERE, ARG)				\
    {								\
!     (WHERE) = build3 (CALL_EXPR, int_type_node,			\
! 		      build_address_of (soft_monitorexit_node),	\
! 		      build_tree_list (NULL_TREE, (ARG)),	\
! 		      NULL_TREE);				\
      TREE_SIDE_EFFECTS (WHERE) = 1;				\
    }

Index: parse.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.h,v
retrieving revision 1.98
diff -c -3 -p -r1.98 parse.h
*** parse.h	10 Jul 2004 05:38:15 -0000	1.98
--- parse.h	1 Aug 2004 15:01:50 -0000
*************** typedef struct jdeplist_s jdeplist;
*** 664,672 ****
  #define BUILD_THROW(WHERE, WHAT)				\
    {								\
      (WHERE) = 							\
!       build (CALL_EXPR, void_type_node,				\
! 	     build_address_of (throw_node),			\
! 	     build_tree_list (NULL_TREE, (WHAT)), NULL_TREE);	\
      TREE_SIDE_EFFECTS ((WHERE)) = 1;				\
    }

--- 664,672 ----
  #define BUILD_THROW(WHERE, WHAT)				\
    {								\
      (WHERE) = 							\
!       build3 (CALL_EXPR, void_type_node,			\
! 	      build_address_of (throw_node),			\
! 	      build_tree_list (NULL_TREE, (WHAT)), NULL_TREE);	\
      TREE_SIDE_EFFECTS ((WHERE)) = 1;				\
    }

Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.496
diff -c -3 -p -r1.496 parse.y
*** parse.y	26 Jul 2004 11:15:09 -0000	1.496
--- parse.y	1 Aug 2004 15:01:53 -0000
*************** switch_statement:
*** 1585,1591 ****
  switch_expression:
  	SWITCH_TK OP_TK expression CP_TK
  		{
! 		  $$ = build (SWITCH_EXPR, NULL_TREE, $3, NULL_TREE, NULL_TREE);
  		  EXPR_WFL_LINECOL ($$) = $2.location;
  		}
  |	SWITCH_TK error
--- 1585,1592 ----
  switch_expression:
  	SWITCH_TK OP_TK expression CP_TK
  		{
! 		  $$ = build3 (SWITCH_EXPR, NULL_TREE, $3,
! 			       NULL_TREE, NULL_TREE);
  		  EXPR_WFL_LINECOL ($$) = $2.location;
  		}
  |	SWITCH_TK error
*************** assert_statement:
*** 1839,1845 ****
  synchronized_statement:
  	synchronized OP_TK expression CP_TK block
  		{
! 		  $$ = build (SYNCHRONIZED_EXPR, NULL_TREE, $3, $5);
  		  EXPR_WFL_LINECOL ($$) =
  		    EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK));
  		}
--- 1840,1846 ----
  synchronized_statement:
  	synchronized OP_TK expression CP_TK block
  		{
! 		  $$ = build2 (SYNCHRONIZED_EXPR, NULL_TREE, $3, $5);
  		  EXPR_WFL_LINECOL ($$) =
  		    EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK));
  		}
*************** catch_clause_parameter:
*** 1911,1917 ****
                        ccpb = enter_block ();
                        init = build_assignment
                          (ASSIGN_TK, $2.location, TREE_PURPOSE ($3),
!                          build (JAVA_EXC_OBJ_EXPR, ptr_type_node));
                        declare_local_variables (0, TREE_VALUE ($3),
                                                 build_tree_list
  					       (TREE_PURPOSE ($3), init));
--- 1912,1918 ----
                        ccpb = enter_block ();
                        init = build_assignment
                          (ASSIGN_TK, $2.location, TREE_PURPOSE ($3),
!                          build0 (JAVA_EXC_OBJ_EXPR, ptr_type_node));
                        declare_local_variables (0, TREE_VALUE ($3),
                                                 build_tree_list
  					       (TREE_PURPOSE ($3), init));
*************** array_creation_expression:
*** 2124,2131 ****
  		    obstack_grow (&temporary_obstack, "[]", 2);
  		  obstack_1grow (&temporary_obstack, '\0');
  		  sig = obstack_finish (&temporary_obstack);
! 		  $$ = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
! 			      $2, get_identifier (sig), $4);
  		}
  |	NEW_TK primitive_type dims array_initializer
  		{
--- 2125,2132 ----
  		    obstack_grow (&temporary_obstack, "[]", 2);
  		  obstack_1grow (&temporary_obstack, '\0');
  		  sig = obstack_finish (&temporary_obstack);
! 		  $$ = build3 (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
! 			       $2, get_identifier (sig), $4);
  		}
  |	NEW_TK primitive_type dims array_initializer
  		{
*************** array_creation_expression:
*** 2133,2140 ****
  		  tree type = $2;
  		  while (osb--)
  		    type = build_java_array_type (type, -1);
! 		  $$ = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
! 			      build_pointer_type (type), NULL_TREE, $4);
  		}
  |	NEW_TK error CSB_TK
  		{yyerror ("'[' expected"); DRECOVER ("]");}
--- 2134,2141 ----
  		  tree type = $2;
  		  while (osb--)
  		    type = build_java_array_type (type, -1);
! 		  $$ = build3 (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
! 			       build_pointer_type (type), NULL_TREE, $4);
  		}
  |	NEW_TK error CSB_TK
  		{yyerror ("'[' expected"); DRECOVER ("]");}
*************** conditional_expression:		/* Error handli
*** 2581,2587 ****
  	conditional_or_expression
  |	conditional_or_expression REL_QM_TK expression REL_CL_TK conditional_expression
  		{
! 		  $$ = build (CONDITIONAL_EXPR, NULL_TREE, $1, $3, $5);
  		  EXPR_WFL_LINECOL ($$) = $2.location;
  		}
  |	conditional_or_expression REL_QM_TK REL_CL_TK error
--- 2582,2588 ----
  	conditional_or_expression
  |	conditional_or_expression REL_QM_TK expression REL_CL_TK conditional_expression
  		{
! 		  $$ = build3 (CONDITIONAL_EXPR, NULL_TREE, $1, $3, $5);
  		  EXPR_WFL_LINECOL ($$) = $2.location;
  		}
  |	conditional_or_expression REL_QM_TK REL_CL_TK error
*************** static tree
*** 9204,9210 ****
  make_qualified_name (tree left, tree right, int location)
  {
  #ifdef USE_COMPONENT_REF
!   tree node = build (COMPONENT_REF, NULL_TREE, left, right, NULL_TREE);
    EXPR_WFL_LINECOL (node) = location;
    return node;
  #else
--- 9205,9211 ----
  make_qualified_name (tree left, tree right, int location)
  {
  #ifdef USE_COMPONENT_REF
!   tree node = build3 (COMPONENT_REF, NULL_TREE, left, right, NULL_TREE);
    EXPR_WFL_LINECOL (node) = location;
    return node;
  #else
*************** resolve_qualified_expression_name (tree
*** 9591,9598 ****
  	     forcoming function's argument. */
  	  if (previous_call_static && is_static)
  	    {
! 	      decl = build (COMPOUND_EXPR, TREE_TYPE (*where_found),
! 			    decl, *where_found);
  	      TREE_SIDE_EFFECTS (decl) = 1;
  	    }
  	  else
--- 9592,9599 ----
  	     forcoming function's argument. */
  	  if (previous_call_static && is_static)
  	    {
! 	      decl = build2 (COMPOUND_EXPR, TREE_TYPE (*where_found),
! 			     decl, *where_found);
  	      TREE_SIDE_EFFECTS (decl) = 1;
  	    }
  	  else
*************** patch_method_invocation (tree patch, tre
*** 10595,10602 ****
  	 initialization statement and build a compound statement along
  	 with the super constructor invocation. */
        CAN_COMPLETE_NORMALLY (patch) = 1;
!       patch = build (COMPOUND_EXPR, void_type_node, patch,
! 		     java_complete_tree (finit_call));
      }
    return patch;
  }
--- 10596,10603 ----
  	 initialization statement and build a compound statement along
  	 with the super constructor invocation. */
        CAN_COMPLETE_NORMALLY (patch) = 1;
!       patch = build2 (COMPOUND_EXPR, void_type_node, patch,
! 		      java_complete_tree (finit_call));
      }
    return patch;
  }
*************** patch_invoke (tree patch, tree method, t
*** 10797,10812 ****
        alloc_node =
  	(class_has_finalize_method (class) ? alloc_object_node
  		  			   : alloc_no_finalizer_node);
!       new = build (CALL_EXPR, promote_type (class),
! 		     build_address_of (alloc_node),
! 		     build_tree_list (NULL_TREE, build_class_ref (class)),
! 		     NULL_TREE);
        saved_new = save_expr (new);
        c1 = build_tree_list (NULL_TREE, saved_new);
        TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
        TREE_OPERAND (original_call, 1) = c1;
        TREE_SET_CODE (original_call, CALL_EXPR);
!       patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
      }

    /* If CHECK is set, then we are building a check to see if the object
--- 10798,10813 ----
        alloc_node =
  	(class_has_finalize_method (class) ? alloc_object_node
  		  			   : alloc_no_finalizer_node);
!       new = build3 (CALL_EXPR, promote_type (class),
! 		    build_address_of (alloc_node),
! 		    build_tree_list (NULL_TREE, build_class_ref (class)),
! 		    NULL_TREE);
        saved_new = save_expr (new);
        c1 = build_tree_list (NULL_TREE, saved_new);
        TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
        TREE_OPERAND (original_call, 1) = c1;
        TREE_SET_CODE (original_call, CALL_EXPR);
!       patch = build2 (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
      }

    /* If CHECK is set, then we are building a check to see if the object
*************** patch_invoke (tree patch, tree method, t
*** 10816,10823 ****
        /* We have to call force_evaluation_order now because creating a
   	 COMPOUND_EXPR wraps the arg list in a way that makes it
   	 unrecognizable by force_evaluation_order later.  Yuk.  */
!       patch = build (COMPOUND_EXPR, TREE_TYPE (patch), check,
!  		     force_evaluation_order (patch));
        TREE_SIDE_EFFECTS (patch) = 1;
      }

--- 10817,10824 ----
        /* We have to call force_evaluation_order now because creating a
   	 COMPOUND_EXPR wraps the arg list in a way that makes it
   	 unrecognizable by force_evaluation_order later.  Yuk.  */
!       patch = build2 (COMPOUND_EXPR, TREE_TYPE (patch), check,
! 		      force_evaluation_order (patch));
        TREE_SIDE_EFFECTS (patch) = 1;
      }

*************** patch_invoke (tree patch, tree method, t
*** 10839,10851 ****
        tree save = force_evaluation_order (patch);
        tree type = TREE_TYPE (patch);

!       patch = build (COMPOUND_EXPR, type, save, build_java_empty_stmt ());
        list = tree_cons (method, patch,
  			DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND (fndecl));

        DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND (fndecl) = list;

!       patch = build (COMPOUND_EXPR, type, patch, save);
      }

    return patch;
--- 10840,10852 ----
        tree save = force_evaluation_order (patch);
        tree type = TREE_TYPE (patch);

!       patch = build2 (COMPOUND_EXPR, type, save, build_java_empty_stmt ());
        list = tree_cons (method, patch,
  			DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND (fndecl));

        DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND (fndecl) = list;

!       patch = build2 (COMPOUND_EXPR, type, patch, save);
      }

    return patch;
*************** build_this_super_qualified_invocation (i
*** 12355,12361 ****
  static tree
  build_method_invocation (tree name, tree args)
  {
!   tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
    TREE_SIDE_EFFECTS (call) = 1;
    EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
    return call;
--- 12356,12362 ----
  static tree
  build_method_invocation (tree name, tree args)
  {
!   tree call = build3 (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
    TREE_SIDE_EFFECTS (call) = 1;
    EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
    return call;
*************** build_method_invocation (tree name, tree
*** 12366,12372 ****
  static tree
  build_new_invocation (tree name, tree args)
  {
!   tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
    TREE_SIDE_EFFECTS (call) = 1;
    EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
    return call;
--- 12367,12373 ----
  static tree
  build_new_invocation (tree name, tree args)
  {
!   tree call = build3 (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
    TREE_SIDE_EFFECTS (call) = 1;
    EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
    return call;
*************** build_assignment (int op, int op_locatio
*** 12386,12392 ****
        rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
        COMPOUND_ASSIGN_P (rhs) = 1;
      }
!   assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
    TREE_SIDE_EFFECTS (assignment) = 1;
    EXPR_WFL_LINECOL (assignment) = op_location;
    return assignment;
--- 12387,12393 ----
        rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
        COMPOUND_ASSIGN_P (rhs) = 1;
      }
!   assignment = build2 (MODIFY_EXPR, NULL_TREE, lhs, rhs);
    TREE_SIDE_EFFECTS (assignment) = 1;
    EXPR_WFL_LINECOL (assignment) = op_location;
    return assignment;
*************** patch_assignment (tree node, tree wfl_op
*** 12640,12647 ****
          base = lvalue;

        index_expr = TREE_OPERAND (base, 1);
!       TREE_OPERAND (base, 1) = build (COMPOUND_EXPR, TREE_TYPE (index_expr),
! 	  			      store_check, index_expr);
      }

    /* Final locals can be used as case values in switch
--- 12641,12648 ----
          base = lvalue;

        index_expr = TREE_OPERAND (base, 1);
!       TREE_OPERAND (base, 1) = build2 (COMPOUND_EXPR, TREE_TYPE (index_expr),
! 				       store_check, index_expr);
      }

    /* Final locals can be used as case values in switch
*************** patch_assignment (tree node, tree wfl_op
*** 12682,12688 ****
  				   TREE_TYPE (new_rhs));
  	    tree block = make_node (BLOCK);
  	    tree assignment
! 	      = build (MODIFY_EXPR, TREE_TYPE (new_rhs), tmp, fold (new_rhs));
  	    DECL_CONTEXT (tmp) = current_function_decl;
  	    TREE_TYPE (block) = TREE_TYPE (new_rhs);
  	    BLOCK_VARS (block) = tmp;
--- 12683,12689 ----
  				   TREE_TYPE (new_rhs));
  	    tree block = make_node (BLOCK);
  	    tree assignment
! 	      = build2 (MODIFY_EXPR, TREE_TYPE (new_rhs), tmp, fold (new_rhs));
  	    DECL_CONTEXT (tmp) = current_function_decl;
  	    TREE_TYPE (block) = TREE_TYPE (new_rhs);
  	    BLOCK_VARS (block) = tmp;
*************** valid_method_invocation_conversion_p (tr
*** 13005,13011 ****
  static tree
  build_binop (enum tree_code op, int op_location, tree op1, tree op2)
  {
!   tree binop = build (op, NULL_TREE, op1, op2);
    TREE_SIDE_EFFECTS (binop) = 1;
    /* Store the location of the operator, for better error report. The
       string of the operator will be rebuild based on the OP value. */
--- 13006,13012 ----
  static tree
  build_binop (enum tree_code op, int op_location, tree op1, tree op2)
  {
!   tree binop = build2 (op, NULL_TREE, op1, op2);
    TREE_SIDE_EFFECTS (binop) = 1;
    /* Store the location of the operator, for better error report. The
       string of the operator will be rebuild based on the OP value. */
*************** patch_binop (tree node, tree wfl_op1, tr
*** 13320,13330 ****

        /* Shift int only up to 0x1f and long up to 0x3f */
        if (prom_type == int_type_node)
! 	op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
! 			   build_int_2 (0x1f, 0)));
        else
! 	op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
! 			   build_int_2 (0x3f, 0)));

        /* The >>> operator is a >> operating on unsigned quantities */
        if (code == URSHIFT_EXPR && ! flag_emit_class_files)
--- 13321,13331 ----

        /* Shift int only up to 0x1f and long up to 0x3f */
        if (prom_type == int_type_node)
! 	op2 = fold (build2 (BIT_AND_EXPR, int_type_node, op2,
! 			    build_int_2 (0x1f, 0)));
        else
! 	op2 = fold (build2 (BIT_AND_EXPR, int_type_node, op2,
! 			    build_int_2 (0x3f, 0)));

        /* The >>> operator is a >> operating on unsigned quantities */
        if (code == URSHIFT_EXPR && ! flag_emit_class_files)
*************** build_string_concatenation (tree op1, tr
*** 13697,13703 ****
    int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);

    if (flag_emit_xref)
!     return build (PLUS_EXPR, string_type_node, op1, op2);

    /* Try to do some static optimization */
    if ((result = string_constant_concatenation (op1, op2)))
--- 13698,13704 ----
    int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);

    if (flag_emit_xref)
!     return build2 (PLUS_EXPR, string_type_node, op1, op2);

    /* Try to do some static optimization */
    if ((result = string_constant_concatenation (op1, op2)))
*************** build_incdec (int op_token, int op_locat
*** 13843,13850 ****
        { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
        { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
      };
!   tree node = build (lookup [is_post_p][(op_token - DECR_TK)],
! 		     NULL_TREE, op1, NULL_TREE);
    TREE_SIDE_EFFECTS (node) = 1;
    /* Store the location of the operator, for better error report. The
       string of the operator will be rebuild based on the OP value. */
--- 13844,13851 ----
        { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
        { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
      };
!   tree node = build2 (lookup [is_post_p][(op_token - DECR_TK)],
! 		      NULL_TREE, op1, NULL_TREE);
    TREE_SIDE_EFFECTS (node) = 1;
    /* Store the location of the operator, for better error report. The
       string of the operator will be rebuild based on the OP value. */
*************** patch_unaryop (tree node, tree wfl_op)
*** 14034,14041 ****
  	  if (outer_field_flag)
  	    {
  	      /* We re-generate an access to the field */
! 	      value = build (PLUS_EXPR, TREE_TYPE (op),
! 			     build_outer_field_access (wfl_op, decl), value);

  	      /* And we patch the original access$() into a write
                   with plus_op as a rhs */
--- 14035,14042 ----
  	  if (outer_field_flag)
  	    {
  	      /* We re-generate an access to the field */
! 	      value = build2 (PLUS_EXPR, TREE_TYPE (op),
! 			      build_outer_field_access (wfl_op, decl), value);

  	      /* And we patch the original access$() into a write
                   with plus_op as a rhs */
*************** patch_cast (tree node, tree wfl_op)
*** 14230,14240 ****
  	}

        /* The cast requires a run-time check */
!       return build (CALL_EXPR, promote_type (cast_type),
! 		    build_address_of (soft_checkcast_node),
! 		    tree_cons (NULL_TREE, build_class_ref (cast_type),
! 			       build_tree_list (NULL_TREE, op)),
! 		    NULL_TREE);
      }

    /* Any other casts are proven incorrect at compile time */
--- 14231,14241 ----
  	}

        /* The cast requires a run-time check */
!       return build3 (CALL_EXPR, promote_type (cast_type),
! 		     build_address_of (soft_checkcast_node),
! 		     tree_cons (NULL_TREE, build_class_ref (cast_type),
! 				build_tree_list (NULL_TREE, op)),
! 		     NULL_TREE);
      }

    /* Any other casts are proven incorrect at compile time */
*************** build_null_of_type (tree type)
*** 14260,14266 ****
  static tree
  build_array_ref (int location, tree array, tree index)
  {
!   tree node = build (ARRAY_REF, NULL_TREE, array, index, NULL_TREE, NULL_TREE);
    EXPR_WFL_LINECOL (node) = location;
    return node;
  }
--- 14261,14268 ----
  static tree
  build_array_ref (int location, tree array, tree index)
  {
!   tree node = build4 (ARRAY_REF, NULL_TREE, array, index,
! 		      NULL_TREE, NULL_TREE);
    EXPR_WFL_LINECOL (node) = location;
    return node;
  }
*************** patch_array_ref (tree node)
*** 14330,14338 ****
  static tree
  build_newarray_node (tree type, tree dims, int extra_dims)
  {
!   tree node =
!     build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims),
! 	   build_int_2 (extra_dims, 0));
    return node;
  }

--- 14332,14339 ----
  static tree
  build_newarray_node (tree type, tree dims, int extra_dims)
  {
!   tree node = build3 (NEW_ARRAY_EXPR, NULL_TREE, type,
! 		      nreverse (dims), build_int_2 (extra_dims, 0));
    return node;
  }

*************** patch_newarray (tree node)
*** 14426,14437 ****

    /* Can't reuse what's already written in expr.c because it uses the
       JVM stack representation. Provide a build_multianewarray. FIXME */
!   return build (CALL_EXPR, array_type,
! 		build_address_of (soft_multianewarray_node),
! 		tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)),
! 			   tree_cons (NULL_TREE,
! 				      build_int_2 (ndims, 0), dims )),
! 		NULL_TREE);
  }

  /* 10.6 Array initializer.  */
--- 14427,14439 ----

    /* Can't reuse what's already written in expr.c because it uses the
       JVM stack representation. Provide a build_multianewarray. FIXME */
!   return build3 (CALL_EXPR, array_type,
! 		 build_address_of (soft_multianewarray_node),
! 		 tree_cons (NULL_TREE,
! 			    build_class_ref (TREE_TYPE (array_type)),
! 			    tree_cons (NULL_TREE,
! 				       build_int_2 (ndims, 0), dims )),
! 		 NULL_TREE);
  }

  /* 10.6 Array initializer.  */
*************** patch_return (tree node)
*** 14667,14673 ****
        if ((patched = patch_string (exp)))
  	exp = patched;

!       modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
        EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
        modify = java_complete_tree (modify);

--- 14669,14675 ----
        if ((patched = patch_string (exp)))
  	exp = patched;

!       modify = build2 (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
        EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
        modify = java_complete_tree (modify);

*************** build_if_else_statement (int location, t
*** 14693,14699 ****
    tree node;
    if (!else_body)
      else_body = build_java_empty_stmt ();
!   node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
    EXPR_WFL_LINECOL (node) = location;
    node = build_debugable_stmt (location, node);
    return node;
--- 14695,14701 ----
    tree node;
    if (!else_body)
      else_body = build_java_empty_stmt ();
!   node = build3 (COND_EXPR, NULL_TREE, expression, if_body, else_body);
    EXPR_WFL_LINECOL (node) = location;
    node = build_debugable_stmt (location, node);
    return node;
*************** build_labeled_block (int location, tree
*** 14761,14767 ****
      }

    label_decl = create_label_decl (label_name);
!   node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
    EXPR_WFL_LINECOL (node) = location;
    TREE_SIDE_EFFECTS (node) = 1;
    return node;
--- 14763,14769 ----
      }

    label_decl = create_label_decl (label_name);
!   node = build2 (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
    EXPR_WFL_LINECOL (node) = location;
    TREE_SIDE_EFFECTS (node) = 1;
    return node;
*************** finish_labeled_statement (tree lbe, /* L
*** 14788,14794 ****
  static tree
  build_new_loop (tree loop_body)
  {
!   tree loop =  build (LOOP_EXPR, NULL_TREE, loop_body);
    TREE_SIDE_EFFECTS (loop) = 1;
    PUSH_LOOP (loop);
    return loop;
--- 14790,14796 ----
  static tree
  build_new_loop (tree loop_body)
  {
!   tree loop = build1 (LOOP_EXPR, NULL_TREE, loop_body);
    TREE_SIDE_EFFECTS (loop) = 1;
    PUSH_LOOP (loop);
    return loop;
*************** build_loop_body (int location, tree cond
*** 14819,14825 ****
  {
    tree first, second, body;

!   condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
    EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
    condition = build_debugable_stmt (location, condition);
    TREE_SIDE_EFFECTS (condition) = 1;
--- 14821,14827 ----
  {
    tree first, second, body;

!   condition = build1 (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
    EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
    condition = build_debugable_stmt (location, condition);
    TREE_SIDE_EFFECTS (condition) = 1;
*************** build_loop_body (int location, tree cond
*** 14827,14836 ****
    body = build_labeled_block (0, continue_identifier_node);
    first = (reversed ? body : condition);
    second = (reversed ? condition : body);
!   return
!     build (COMPOUND_EXPR, NULL_TREE,
! 	   build (COMPOUND_EXPR, NULL_TREE, first, second),
! 		  build_java_empty_stmt ());
  }

  /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
--- 14829,14837 ----
    body = build_labeled_block (0, continue_identifier_node);
    first = (reversed ? body : condition);
    second = (reversed ? condition : body);
!   return build2 (COMPOUND_EXPR, NULL_TREE,
! 		 build2 (COMPOUND_EXPR, NULL_TREE, first, second),
! 		 build_java_empty_stmt ());
  }

  /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
*************** build_bc_statement (int location, int is
*** 14978,14985 ****
      }
    /* Unlabeled break/continue will be handled during the
       break/continue patch operation */
!   break_continue
!     = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);

    IS_BREAK_STMT_P (break_continue) = is_break;
    TREE_SIDE_EFFECTS (break_continue) = 1;
--- 14979,14986 ----
      }
    /* Unlabeled break/continue will be handled during the
       break/continue patch operation */
!   break_continue = build2 (EXIT_BLOCK_EXPR, NULL_TREE,
! 			   label_block_expr, NULL_TREE);

    IS_BREAK_STMT_P (break_continue) = is_break;
    TREE_SIDE_EFFECTS (break_continue) = 1;
*************** build_assertion (int location, tree cond
*** 15186,15193 ****

    if (! enable_assertions (klass))
      {
!       condition = build (TRUTH_ANDIF_EXPR, NULL_TREE,
! 			 boolean_false_node, condition);
        if (value == NULL_TREE)
  	value = build_java_empty_stmt ();
        return build_if_else_statement (location, condition,
--- 15187,15194 ----

    if (! enable_assertions (klass))
      {
!       condition = build2 (TRUTH_ANDIF_EXPR, NULL_TREE,
! 			  boolean_false_node, condition);
        if (value == NULL_TREE)
  	value = build_java_empty_stmt ();
        return build_if_else_statement (location, condition,
*************** build_assertion (int location, tree cond
*** 15210,15216 ****

        /* Call CLASS.desiredAssertionStatus().  */
        id = build_wfl_node (get_identifier ("desiredAssertionStatus"));
!       call = build (CALL_EXPR, NULL_TREE, id, NULL_TREE, NULL_TREE);
        call = make_qualified_primary (classdollar, call, location);
        TREE_SIDE_EFFECTS (call) = 1;

--- 15211,15217 ----

        /* Call CLASS.desiredAssertionStatus().  */
        id = build_wfl_node (get_identifier ("desiredAssertionStatus"));
!       call = build3 (CALL_EXPR, NULL_TREE, id, NULL_TREE, NULL_TREE);
        call = make_qualified_primary (classdollar, call, location);
        TREE_SIDE_EFFECTS (call) = 1;

*************** build_assertion (int location, tree cond
*** 15222,15228 ****
        DECL_INITIAL (field) = call;

        /* Record the initializer in the initializer statement list.  */
!       call = build (MODIFY_EXPR, NULL_TREE, field, call);
        TREE_CHAIN (call) = CPC_STATIC_INITIALIZER_STMT (ctxp);
        SET_CPC_STATIC_INITIALIZER_STMT (ctxp, call);
        MODIFY_EXPR_FROM_INITIALIZATION_P (call) = 1;
--- 15223,15229 ----
        DECL_INITIAL (field) = call;

        /* Record the initializer in the initializer statement list.  */
!       call = build2 (MODIFY_EXPR, NULL_TREE, field, call);
        TREE_CHAIN (call) = CPC_STATIC_INITIALIZER_STMT (ctxp);
        SET_CPC_STATIC_INITIALIZER_STMT (ctxp, call);
        MODIFY_EXPR_FROM_INITIALIZATION_P (call) = 1;
*************** build_assertion (int location, tree cond
*** 15239,15245 ****
    node = make_qualified_name (node, build_wfl_node (get_identifier ("AssertionError")),
  			      location);

!   node = build (NEW_CLASS_EXPR, NULL_TREE, node, value, NULL_TREE);
    TREE_SIDE_EFFECTS (node) = 1;
    /* It is too early to use BUILD_THROW.  */
    node = build1 (THROW_EXPR, NULL_TREE, node);
--- 15240,15246 ----
    node = make_qualified_name (node, build_wfl_node (get_identifier ("AssertionError")),
  			      location);

!   node = build3 (NEW_CLASS_EXPR, NULL_TREE, node, value, NULL_TREE);
    TREE_SIDE_EFFECTS (node) = 1;
    /* It is too early to use BUILD_THROW.  */
    node = build1 (THROW_EXPR, NULL_TREE, node);
*************** build_assertion (int location, tree cond
*** 15250,15259 ****
    condition = build1 (TRUTH_NOT_EXPR, NULL_TREE, condition);
    /* Check $assertionsDisabled.  */
    condition
!     = build (TRUTH_ANDIF_EXPR, NULL_TREE,
! 	     build1 (TRUTH_NOT_EXPR, NULL_TREE,
! 		     build_wfl_node (get_identifier ("$assertionsDisabled"))),
! 	     condition);
    node = build_if_else_statement (location, condition, node, NULL_TREE);
    return node;
  }
--- 15251,15260 ----
    condition = build1 (TRUTH_NOT_EXPR, NULL_TREE, condition);
    /* Check $assertionsDisabled.  */
    condition
!     = build2 (TRUTH_ANDIF_EXPR, NULL_TREE,
! 	      build1 (TRUTH_NOT_EXPR, NULL_TREE,
! 		      build_wfl_node (get_identifier ("$assertionsDisabled"))),
! 	      condition);
    node = build_if_else_statement (location, condition, node, NULL_TREE);
    return node;
  }
*************** encapsulate_with_try_catch (int location
*** 15291,15298 ****
    catch_block = build_expr_block (NULL_TREE, catch_clause_param);

    /* Initialize the variable and store in the block */
!   catch = build (MODIFY_EXPR, NULL_TREE, catch_clause_param,
! 		 build (JAVA_EXC_OBJ_EXPR, ptr_type_node));
    add_stmt_to_block (catch_block, NULL_TREE, catch);

    /* Add the catch statements */
--- 15292,15299 ----
    catch_block = build_expr_block (NULL_TREE, catch_clause_param);

    /* Initialize the variable and store in the block */
!   catch = build2 (MODIFY_EXPR, NULL_TREE, catch_clause_param,
! 		  build0 (JAVA_EXC_OBJ_EXPR, ptr_type_node));
    add_stmt_to_block (catch_block, NULL_TREE, catch);

    /* Add the catch statements */
*************** encapsulate_with_try_catch (int location
*** 15307,15313 ****
  static tree
  build_try_statement (int location, tree try_block, tree catches)
  {
!   tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
    EXPR_WFL_LINECOL (node) = location;
    return node;
  }
--- 15308,15314 ----
  static tree
  build_try_statement (int location, tree try_block, tree catches)
  {
!   tree node = build2 (TRY_EXPR, NULL_TREE, try_block, catches);
    EXPR_WFL_LINECOL (node) = location;
    return node;
  }
*************** build_try_statement (int location, tree
*** 15315,15321 ****
  static tree
  build_try_finally_statement (int location, tree try_block, tree finally)
  {
!   tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
    EXPR_WFL_LINECOL (node) = location;
    return node;
  }
--- 15316,15322 ----
  static tree
  build_try_finally_statement (int location, tree try_block, tree finally)
  {
!   tree node = build2 (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
    EXPR_WFL_LINECOL (node) = location;
    return node;
  }
*************** patch_synchronized_statement (tree node,
*** 15488,15498 ****
    BUILD_MONITOR_EXIT (exit, expr_decl);
    CAN_COMPLETE_NORMALLY (enter) = 1;
    CAN_COMPLETE_NORMALLY (exit) = 1;
!   assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
    TREE_SIDE_EFFECTS (assignment) = 1;
!   node = build (COMPOUND_EXPR, NULL_TREE,
! 		build (COMPOUND_EXPR, NULL_TREE, assignment, enter),
! 		build (TRY_FINALLY_EXPR, NULL_TREE, block, exit));
    node = build_expr_block (node, expr_decl);

    return java_complete_tree (node);
--- 15489,15499 ----
    BUILD_MONITOR_EXIT (exit, expr_decl);
    CAN_COMPLETE_NORMALLY (enter) = 1;
    CAN_COMPLETE_NORMALLY (exit) = 1;
!   assignment = build2 (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
    TREE_SIDE_EFFECTS (assignment) = 1;
!   node = build2 (COMPOUND_EXPR, NULL_TREE,
! 		 build2 (COMPOUND_EXPR, NULL_TREE, assignment, enter),
! 		 build2 (TRY_FINALLY_EXPR, NULL_TREE, block, exit));
    node = build_expr_block (node, expr_decl);

    return java_complete_tree (node);
*************** emit_test_initialization (void **entry_p
*** 16097,16103 ****

    /* Now simply augment the compound that holds all the assignments
       pertaining to this method invocation. */
!   init = build (MODIFY_EXPR, boolean_type_node, decl, boolean_true_node);
    TREE_SIDE_EFFECTS (init) = 1;
    TREE_VALUE (l) = add_stmt_to_compound (TREE_VALUE (l), void_type_node, init);
    TREE_SIDE_EFFECTS (TREE_VALUE (l)) = 1;
--- 16098,16104 ----

    /* Now simply augment the compound that holds all the assignments
       pertaining to this method invocation. */
!   init = build2 (MODIFY_EXPR, boolean_type_node, decl, boolean_true_node);
    TREE_SIDE_EFFECTS (init) = 1;
    TREE_VALUE (l) = add_stmt_to_compound (TREE_VALUE (l), void_type_node, init);
    TREE_SIDE_EFFECTS (TREE_VALUE (l)) = 1;


Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]