mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 01:43:35 +00:00
In the Java grade, the standard streams were not being entered into the stream
database and the I/O globals were not being initialized. For executables,
generate a call to library.std_library_init/2 before main/2 is invoked. There
is still a problem for Mercury libraries called from Java programs and for
predicates specified in `:- initialise' declarations. For the latter, Mercury
requires that all standard library initialization be performed *before* any
user specified initialize predicates, but because we currently implement all of
this in Java using static initializers we can't guarantee that the order things
occur in.
The same issue affects the C# grade; I'll add a workaround for it separately.
library/io.m:
In the predicate io.init_state/2, in the Java grade do not
bother setting the current stream since for the standard text
streams we do so as part of class initialization and
library/library.m:
Export std_library_init/2 to Java.
compiler/mlds_to_java.m:
Generate a call to library.std_library_init/2 before main/2 is called.
XXX TODO we should roll the call that initializes the benchmarking module
into the same.
tests/hard_coded/Mmakefile:
tests/hard_coded/stdlib_init.{m,exp}:
Test that the stream database and globals in the io module are
initialized before main/2 is called.
6 lines
132 B
Plaintext
6 lines
132 B
Plaintext
"<globals>"
|
|
mercury_op_table
|
|
stream(0, input, preopen, stdin)
|
|
stream(1, output, preopen, stdout)
|
|
stream(1, output, preopen, stderr)
|