[m-dev.] for review: compiler options for Java backend

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jan 25 14:43:45 AEDT 2001


On 25-Jan-2001, Julien Fischer <juliensf at students.cs.mu.oz.au> wrote:
> 
> Added new compiler options to support the Java backend and
> updated documentation to reflect this.
> 
> compiler/globals.m:
> 	Removed comment about Java backend not being implemented.
> 	Replaced it by one say that it is work in progress.
> compiler/mercury_compile.m:
> 	If Target = java then call the Java backend.
> compiler/options.m:
> 	Added new options for compiling Java files:
> 	`--java'
> 	`--java-only'
> 	`--java-compiler' ('--javac')
> 	`--java-flags'
> 	`--java-classpath'
> 	`--java-object-file-extension'
> compiler/handle_options.m:
> 	If compiling to Java then don't link.
> 	Added "java" grade.
> doc/user_guide.texi:
> 	Documented new options for compiling Java files.
> scripts/init_grade_options.sh-subr:
> scripts/parse_grade_options.sh-subr:
> scripts/final_grade_options.sh-subr:
> 	Added support for "java" grade.

Please put a blank line in between each set of files,
e.g.

	foo:
		whatever
					<------- blank line here
	bar:
	baz:
		yada yada yada

rather than

	foo:
		whatever
	bar:
	baz:
		yada yada yada

> Index: compiler/handle_options.m
> +	% Generating Java implies high-level code, turning off nested functions,
> +	% using copy-out for both det and nondet output arguments,
> +	% using no tags, boxing enums, disabling no_tag_types and no
> +	% static ground terms.

The last three (boxing enums, disabling no_tag_types,
and no static ground terms) should hopefully be eliminated
in a future version.  Please either eliminate them or
put an XXX comment saying that they ought to be eliminated.

> +	( { Target = java } ->
> +		globals__io_set_option(highlevel_code, bool(yes)),
> +		globals__io_set_option(gcc_nested_functions, bool(no)),
> +		globals__io_set_option(nondet_copy_out, bool(yes)),
> +		globals__io_set_option(det_copy_out, bool(yes)),
> +		globals__io_set_option(num_tag_bits, int(0)),
> +		globals__io_set_option(line_numbers, bool(no)),
> +		globals__io_set_option(static_ground_terms, bool(no))

The code here still doesn't match the comment.
It disables line_numbers and it doesn't box enums.
Probably the code is right and the comment should be fixed.

It would help to have comments explaining why each of these must be set. 

In particular, why do you need to disable line numbers?
I guess that is done because Java doesn't have `#line',
but wouldn't it be better to have mlds_to_java.m not spit
out #line directives, and leave the option unchanged?
That way, if you use foreign code (e.g. `pragma c_code'),
and that gets compiled to a separate file, it will have
the right line numbers.

> Index: compiler/options.m
> @@ -1874,17 +1913,28 @@
>  		"-s <grade>, --grade <grade>",
>  		"\tSelect the compilation model. The <grade> should be one of",
>  		"\t`none', `reg', `jump', `asm_jump', `fast', `asm_fast', `hlc'",
> -		"--target {c, il}",
> -		"\tSpecify the target language: C or IL (default: C).",
> -		"\tThe IL target implies `--high-level-code' (see below).",
> +		"--target {c, il, java}",
> +		"\tSpecify the target language: C, IL or Java (default: C).",
> +		"\tThe IL and Java targets imply `--high-level-code' (see below).",
>  		"--il",
>  		"\tAn abbreviation for `--target il'.",
>  		"--il-only",
>  		"\tAn abbreviation for `--target il --intermediate-code-only'.",
> -		"\tGenerate IL code in `<module>.il', but do not generate object code.",
> +		"\tGenerate IL code in `<module>.il', but do not generate",
> +		"\tobject code.",
> +		
> +		"--java",
> +		"\tAn abbreviation for `--target java'.",
> +		"--java-only",
> +		"\tAn abbreviation for `--target java --intermediate-code-only'.",
> +		"\tGenerate Java code in `<module>.java', but do not generate",
> +		"\tobject code.",
> +		
>  		"--compile-to-c",
>  		"\tAn abbreviation for `--target c --intermediate-code-only'.",
>  		"\tGenerate C code in `<module>.c', but do not generate object code.",

All occurrences of `--intermediate-code-only' should be changed
to `--target-code-only'. (That was a bug in the existing help message
for `--il-only' and `--compile-to-c'.)

> @@ -2119,6 +2169,20 @@
>  		"\tEnable debugging of the generated C code.",
>  		"\t(This has the same effect as",
>  		"\t`--cflags ""-g"" --link-flags ""--no-strip""'.)",
> +
> +		"--javac",
> +		"--java-compiler",
> +		"\tSpecify which Java compiler to use.",

I suggest adding

	The default is `javac'.

> Index: doc/user_guide.texi
> +
> + at sp 1
> + at item --javac @var{compiler-name}
> + at item --java-compiler @var{compiler-name}
> +Specify which Java compiler to use.

Likewise here:

	The default is @samp{javac}.

> + at sp 1
> + at item --java-object-file-extension @var{extension}
> +Specify an extension for Java object (bytecode) files.  By default this
> +is `.class'. 

s/`.class'/@samp{.class}/

Otherwise, that looks good.  I'd like to see a relative diff when you
have addressed the issues mentioned above.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list