This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Java compiler patch: compile resource files into executables
- To: green at cygnus dot com
- Subject: Re: Java compiler patch: compile resource files into executables
- From: Alexandre Petit-Bianco <apbianco at cygnus dot com>
- Date: Thu, 6 Sep 2001 11:14:51 -0700 (PDT)
- Cc: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- References: <200109030045.RAA02010@fencer.cygnus.com>
- Reply-To: apbianco at cygnus dot com
Anthony Green writes:
> This is the compiler part of the patch. I'll send the runtime patch
> in another mail.
Here are my comments. The patch is good to go once corrected. Thank
you.
> Index: gcc/java/class.c
> ...
> +/* Generate a byte array representing the contents of FILENAME. The
> + array is assigned a unique local symbol. The array represents a
> + compiled Java resource, which is accessed by the runtime using
> + NAME.
> +*/
I think the comment should be laid out like this:
+/* Generate a byte array representing the contents of FILENAME. The
+ array is assigned a unique local symbol. The array represents a
+ compiled Java resource, which is accessed by the runtime using
+ NAME. */
> +void
> +compile_resource_file (char *name, char *filename)
I'd rather use:
+void
+compile_resource_file (name, filename)
+ char *name;
+ char *filename;
> + assemble_variable (decl, 1, 0, 0);
> +
> + {
> + extern tree get_file_function_name PARAMS ((int));
get_file_function_name's prototype appears in tree.h. Removing it
didn't generate any warning for me.
> + tree t;
This variable isn't used.
> + DECL_RESULT (init_decl) = build_decl(RESULT_DECL, NULL_TREE, void_type_node);
Formating:
+ DECL_RESULT (init_decl) =
+ build_decl (RESULT_DECL, NULL_TREE, void_type_node);
> Index: gcc/java/java-tree.h
You could add compile_resource_file's prototype in java-tree.h:
+ void compile_resource_file PARAMS ((char *, char *));
> Index: gcc/java/jcf-parse.c
> ...
> if (filename_count == 0)
> warning ("no input file specified");
> +
> + if (resource_name)
> + {
> + /* Only one resource file may be compiled at a time. */
> + assert (TREE_CHAIN (current_file_list) == NULL);
> +
> + input_filename = IDENTIFIER_POINTER (TREE_VALUE (current_file_list));
> + compile_resource_file (resource_name, input_filename);
input_filename is of the wrong type, better use a local:
+ char *resource_filename;
+
+ /* Only one resource file may be compiled at a time. */
+ assert (TREE_CHAIN (current_file_list) == NULL);
+
+ resource_filename = IDENTIFIER_POINTER (TREE_VALUE (current_file_list));
+ compile_resource_file (resource_name, resource_filename);
./A