Patch to prototype/constify java dir part 2/2

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Tue Aug 24 11:09:00 GMT 1999


	This is part 2/2.  Bootstrapped on Irix6.  Okay to install?

		Thanks,
		--Kaveh

1999-08-24  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* jcf-write.c (jcf_handler, push_constant1, push_constant2,
	push_int_const, find_constant_wide, find_constant_index,
	push_long_const, field_op, maybe_wide, emit_dup, emit_pop,
	emit_iinc, emit_load_or_store, emit_load, emit_store, emit_unop,
	emit_binop, emit_reloc, emit_switch_reloc, emit_case_reloc,
	emit_if, emit_goto, emit_jsr, call_cleanups,
	make_class_file_name): Add static prototypes.
	(generate_bytecode_return, generate_bytecode_insns): Pass a
	NULL_PTR, not a NULL_TREE.

	* jv-scan.c: Include "jcf.h".
	(main): Declare using DEFUN macro.

	* jvspec.c (find_spec_file, lang_specific_pre_link,
	lang_specific_driver): Add prototypes.
	(find_spec_file): Constify a char*.

	* keyword.gperf (hash, java_keyword): Add prototypes.

	* lang.c (lang_print_error): Add static prototype.
	(lang_init): Prefer memcpy over bcopy to avoid casts.

	* lex.c (yylex): Add static prototype.

	* parse-scan.y: Include "lex.c" earlier.

	* parse.h: Remove redundant declaration for `yylex'.

	* parse.y (java_decl_equiv, binop_compound_p, search_loop,
	labeled_block_contains_loop_p): Add static prototypes.
	(not_accessible_p): Make static to match prototype.

	* verify.c (start_pc_cmp): Don't needlessly cast away const.


diff -rup orig/egcs-CVS19990820/gcc/java/jcf-write.c egcs-CVS19990820/gcc/java/jcf-write.c
--- orig/egcs-CVS19990820/gcc/java/jcf-write.c	Fri Jul 30 14:21:15 1999
+++ egcs-CVS19990820/gcc/java/jcf-write.c	Sat Aug 21 18:05:26 1999
@@ -299,7 +299,39 @@ static void init_jcf_state PROTO ((struc
 static void init_jcf_method PROTO ((struct jcf_partial *, tree));
 static void release_jcf_state PROTO ((struct jcf_partial *));
 static struct chunk * generate_classfile PROTO ((tree, struct jcf_partial *));
-
+static struct jcf_handler *alloc_handler PROTO ((struct jcf_block *,
+						 struct jcf_block *,
+						 struct jcf_partial *));
+static void push_constant1 PROTO ((int, struct jcf_partial *));
+static void push_constant2 PROTO ((int, struct jcf_partial *));
+static void push_int_const PROTO ((HOST_WIDE_INT, struct jcf_partial *));
+static int find_constant_wide PROTO ((HOST_WIDE_INT, HOST_WIDE_INT,
+				      struct jcf_partial *));
+static int find_constant_index PROTO ((tree, struct jcf_partial *));
+static void push_long_const PROTO ((HOST_WIDE_INT, HOST_WIDE_INT,
+				    struct jcf_partial *));
+static void field_op PROTO ((tree, int, struct jcf_partial *));
+static void maybe_wide PROTO ((int, int, struct jcf_partial *));
+static void emit_dup PROTO ((int, int, struct jcf_partial *));
+static void emit_pop PROTO ((int, struct jcf_partial *));
+static void emit_iinc PROTO ((tree, int, struct jcf_partial *));
+static void emit_load_or_store PROTO ((tree, int, struct jcf_partial *));
+static void emit_load PROTO ((tree, struct jcf_partial *));
+static void emit_store PROTO ((tree, struct jcf_partial *));
+static void emit_unop PROTO ((enum java_opcode, tree, struct jcf_partial *));
+static void emit_binop PROTO ((enum java_opcode, tree, struct jcf_partial *));
+static void emit_reloc PROTO ((HOST_WIDE_INT, int, struct jcf_block *,
+			       struct jcf_partial *));
+static void emit_switch_reloc PROTO ((struct jcf_block *,
+				      struct jcf_partial *));
+static void emit_case_reloc PROTO ((struct jcf_relocation *,
+				    struct jcf_partial *));
+static void emit_if PROTO ((struct jcf_block *, int, int,
+			    struct jcf_partial *));
+static void emit_goto PROTO ((struct jcf_block *, struct jcf_partial *));
+static void emit_jsr PROTO ((struct jcf_block *, struct jcf_partial *));
+static void call_cleanups PROTO ((struct jcf_block *, struct jcf_partial *));
+static char *make_class_file_name PROTO ((tree));
 
 /* Utility macros for appending (big-endian) data to a buffer.
    We assume a local variable 'ptr' points into where we want to
@@ -1334,7 +1366,7 @@ generate_bytecode_return (exp, state)
   if (returns_void)
     {
       op = OPCODE_return;
-      call_cleanups (NULL_TREE, state);
+      call_cleanups (NULL_PTR, state);
     }
   else
     {
@@ -1348,7 +1380,7 @@ generate_bytecode_return (exp, state)
 	      localvar_alloc (state->return_value_decl, state);
 	    }
 	  emit_store (state->return_value_decl, state);
-	  call_cleanups (NULL_TREE, state);
+	  call_cleanups (NULL_PTR, state);
 	  emit_load (state->return_value_decl, state);
 	  /* If we call localvar_free (state->return_value_decl, state),
 	     then we risk the save decl erroneously re-used in the
@@ -2264,7 +2296,7 @@ generate_bytecode_insns (exp, target, st
 
 	/* Handle exceptions. */
 	localvar_alloc (return_link, state);
-	handler = alloc_handler (start_label, NULL_TREE, state);
+	handler = alloc_handler (start_label, NULL_PTR, state);
 	handler->end_label = handler->handler_label;
 	handler->type = NULL_TREE;
 	localvar_alloc (exception_decl, state);
diff -rup orig/egcs-CVS19990820/gcc/java/jv-scan.c egcs-CVS19990820/gcc/java/jv-scan.c
--- orig/egcs-CVS19990820/gcc/java/jv-scan.c	Tue Aug 10 12:48:58 1999
+++ egcs-CVS19990820/gcc/java/jv-scan.c	Sat Aug 21 18:17:12 1999
@@ -29,6 +29,7 @@ void warning VPROTO((const char *s, ...)
 void gcc_obstack_init PROTO ((struct obstack *obstack));
 
 #define JC1_LITE
+#include "jcf.h"
 #include "parse.h"
 
 /* Current input file and output file IO streams.  */
@@ -47,9 +48,8 @@ int flag_list_filename = 0;
 
 /* jc1-lite main entry point */
 int
-main (argc, argv)
-  int argc;
-  char **argv;
+DEFUN (main, (argc, argv),
+       int argc AND char **argv)
 {
   int i = 1;
   const char *output_file = NULL;
diff -rup orig/egcs-CVS19990820/gcc/java/jvspec.c egcs-CVS19990820/gcc/java/jvspec.c
--- orig/egcs-CVS19990820/gcc/java/jvspec.c	Wed Jul 21 15:41:34 1999
+++ egcs-CVS19990820/gcc/java/jvspec.c	Sat Aug 21 20:18:14 1999
@@ -41,7 +41,11 @@ The Free Software Foundation is independ
 /* True if this arg is a .class input file name. */
 #define CLASS_FILE_ARG	(1<<4)
 
+static char *find_spec_file	PROTO ((const char *));
 extern int do_spec		PROTO((char *));
+extern int lang_specific_pre_link PROTO((void));
+extern void lang_specific_driver PROTO ((void (*) (const char *, ...),
+					 int *, char ***, int *));
 extern char *input_filename;
 extern size_t input_filename_length;
 
@@ -68,7 +72,7 @@ char jvgenmain_spec[] =
    not.  */
 static char *
 find_spec_file (dir)
-     char *dir;
+     const char *dir;
 {
   char *spec;
   int x;
@@ -89,7 +93,7 @@ find_spec_file (dir)
 
 void
 lang_specific_driver (fn, in_argc, in_argv, in_added_libraries)
-     void (*fn)();
+     void (*fn) PROTO ((const char *, ...));
      int *in_argc;
      char ***in_argv;
      int *in_added_libraries;
diff -rup orig/egcs-CVS19990820/gcc/java/keyword.gperf egcs-CVS19990820/gcc/java/keyword.gperf
--- orig/egcs-CVS19990820/gcc/java/keyword.gperf	Wed Mar 31 10:32:58 1999
+++ egcs-CVS19990820/gcc/java/keyword.gperf	Sat Aug 21 17:17:15 1999
@@ -26,6 +26,14 @@ The Free Software Foundation is independ
 
 %}
 struct java_keyword { const char *name; int token; };
+#ifdef __GNUC__
+__inline
+#endif
+static unsigned int hash		PARAMS ((const char *, unsigned int));
+#ifdef __GNUC__
+__inline
+#endif
+struct java_keyword *java_keyword	PARAMS ((const char *, unsigned int));
 %%
 abstract, ABSTRACT_TK
 default, DEFAULT_TK
diff -rup orig/egcs-CVS19990820/gcc/java/lang.c egcs-CVS19990820/gcc/java/lang.c
--- orig/egcs-CVS19990820/gcc/java/lang.c	Sat Aug 21 12:55:34 1999
+++ egcs-CVS19990820/gcc/java/lang.c	Sat Aug 21 18:13:27 1999
@@ -39,6 +39,7 @@ The Free Software Foundation is independ
 static void put_decl_string PROTO ((const char *, int));
 static void put_decl_node PROTO ((tree));
 static void java_dummy_print PROTO ((const char *));
+static void lang_print_error PROTO ((const char *));
 
 #ifndef OBJECT_SUFFIX
 # define OBJECT_SUFFIX ".o"
@@ -453,7 +454,7 @@ lang_printable_name (decl, v)
 /* Print on stderr the current class and method context.  This function
    is the value of the hook print_error_function, called from toplev.c. */
 
-void
+static void
 lang_print_error (file)
      const char *file;
 {
@@ -507,17 +508,17 @@ lang_init ()
 
   /* Append to Gcc tree node definition arrays */
 
-  bcopy (java_tree_code_type,
-	 tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
-	 (int)LAST_JAVA_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE);
-  bcopy ((char *)java_tree_code_length,
-	 (char *)(tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE),
-	 (LAST_JAVA_TREE_CODE - 
-	  (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
-  bcopy ((char *)java_tree_code_name,
-	 (char *)(tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
-	 (LAST_JAVA_TREE_CODE - 
-	  (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
+  memcpy (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
+	  java_tree_code_type,
+	  (int)LAST_JAVA_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE);
+  memcpy (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE,
+	  java_tree_code_length,
+	  (LAST_JAVA_TREE_CODE - 
+	   (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
+  memcpy (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE,
+	  java_tree_code_name,
+	  (LAST_JAVA_TREE_CODE - 
+	   (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
 
   using_eh_for_cleanups ();
 }
diff -rup orig/egcs-CVS19990820/gcc/java/lex.c egcs-CVS19990820/gcc/java/lex.c
--- orig/egcs-CVS19990820/gcc/java/lex.c	Wed Aug  4 09:17:23 1999
+++ egcs-CVS19990820/gcc/java/lex.c	Sat Aug 21 17:30:45 1999
@@ -517,7 +517,9 @@ java_parse_escape_sequence ()
     }
 }
 
-int
+static int yylex		PARAMS ((YYSTYPE *));
+
+static int
 #ifdef JC1_LITE
 yylex (java_lval)
 #else
diff -rup orig/egcs-CVS19990820/gcc/java/parse-scan.y egcs-CVS19990820/gcc/java/parse-scan.y
--- orig/egcs-CVS19990820/gcc/java/parse-scan.y	Wed Aug  4 09:17:23 1999
+++ egcs-CVS19990820/gcc/java/parse-scan.y	Sat Aug 21 17:47:40 1999
@@ -103,6 +103,10 @@ static void report_main_declaration PROT
   int value;			/* For modifiers */
 }
 
+%{
+#include "lex.c"
+%}
+
 %pure_parser
 
 /* Things defined here have to match the order of what's in the
@@ -1104,8 +1108,6 @@ constant_expression:
 
 %%
 
-#include "lex.c"
-
 /* Create a new parser context */
 
 void
diff -rup orig/egcs-CVS19990820/gcc/java/parse.h egcs-CVS19990820/gcc/java/parse.h
--- orig/egcs-CVS19990820/gcc/java/parse.h	Fri Aug 20 19:15:43 1999
+++ egcs-CVS19990820/gcc/java/parse.h	Sat Aug 21 17:24:55 1999
@@ -673,7 +673,6 @@ extern void java_parser_context_save_glo
 extern void java_parser_context_restore_global PROTO ((void));
 int yyparse PROTO ((void));
 extern int java_parse PROTO ((void));
-int yylex ();
 void yyerror PROTO ((const char *));
 extern void java_expand_classes PROTO ((void));
 #endif
diff -rup orig/egcs-CVS19990820/gcc/java/parse.y egcs-CVS19990820/gcc/java/parse.y
--- orig/egcs-CVS19990820/gcc/java/parse.y	Fri Aug 20 07:44:27 1999
+++ egcs-CVS19990820/gcc/java/parse.y	Sat Aug 21 17:36:46 1999
@@ -258,6 +258,10 @@ static char * operator_string PROTO ((tr
 static tree do_merge_string_cste PROTO ((tree, const char *, int, int));
 static tree merge_string_cste PROTO ((tree, tree, int));
 static tree java_refold PROTO ((tree));
+static int java_decl_equiv PROTO ((tree, tree));
+static int binop_compound_p PROTO ((enum tree_code));
+static tree search_loop PROTO ((tree));
+static int labeled_block_contains_loop_p PROTO ((tree, tree));
 
 /* Number of error found so far. */
 int java_error_count; 
@@ -6805,7 +6809,8 @@ resolve_qualified_expression_name (wfl, 
 /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl)
    can't be accessed from REFERENCE (a record type). */
 
-int not_accessible_p (reference, member, from_super)
+static int
+not_accessible_p (reference, member, from_super)
      tree reference, member;
      int from_super;
 {
diff -rup orig/egcs-CVS19990820/gcc/java/verify.c egcs-CVS19990820/gcc/java/verify.c
--- orig/egcs-CVS19990820/gcc/java/verify.c	Tue Aug 10 12:48:59 1999
+++ egcs-CVS19990820/gcc/java/verify.c	Sat Aug 21 18:14:25 1999
@@ -316,8 +316,8 @@ start_pc_cmp (xp, yp)
      const PTR xp;
      const PTR yp;
 {
-  struct pc_index *x = (struct pc_index *) xp;
-  struct pc_index *y = (struct pc_index *) yp;
+  const struct pc_index *x = (const struct pc_index *) xp;
+  const struct pc_index *y = (const struct pc_index *) yp;
   return x->start_pc - y->start_pc;
 }
 


More information about the Gcc-patches mailing list