tests/hard_coded/*.m:
Rename modules as mentioned above.
In a few cases, where the main module's name itself had a suffix,
such as "_mod_a" or "_main", remove that suffix. This entails
renaming the .exp file as well. (In some cases, this meant that
the name of a helper module was "taken over" by the main module
of the test case.)
Update all references to the moved modules.
General updates to programming style, such as
- replacing DCG notation with state var notation
- replacing (C->T;E) with (if C then T else E)
- moving pred/func declarations to just before their code
- replacing io.write/io.nl sequences with io.write_line
- replacing io.print/io.nl sequences with io.print_line
- fixing too-long lines
- fixing grammar errors in comments
tests/hard_coded/Mmakefile:
tests/hard_coded/Mercury.options:
Update all references to the moved modules.
Enable the constant_prop_int test case. The fact that it wasn't enabled
before is probably an accident. (When constant_prop_int.m was created,
the test case was added to a list in the Mmakefile, but that list
was later removed due to never being referenced.)
tests/hard_coded/constant_prop_int.{m,exp}:
Delete the calls to shift operations with negative shift amounts,
since we have added a compile-time error for these since the test
was originally created.
tests/accumulator/*.m:
tests/analysis_*/*.m:
tests/benchmarks*/*.m:
tests/debugger*/*.{m,exp,inp}:
tests/declarative_debugger*/*.{m,exp,inp}:
tests/dppd*/*.m:
tests/exceptions*/*.m:
tests/general*/*.m:
tests/grade_subdirs*/*.m:
tests/hard_coded*/*.m:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the debugger tests,
specify the new line numbers in .inp files and expect them in .exp files.
Branches: main
The Java backend was sometimes generating code like this to initialise RTTI
data structures:
foo_type_info.init(...,
/* cast */ new TypeInfo_Struct(bar_type_ctor_info), ...);
bar_type_ctor_info.init(...);
where `bar_type_ctor_info' is actually a type_info.
The problem is that the fields of the non-initialised `bar_type_ctor_info'
would be copied into the new TypeInfo_Struct object. The "cast" is of course
also unnecessary as the bar is already a TypeInfo_Struct.
This patch attempts to fix the problem in two ways:
1. Don't allocate a new TypeInfo_Struct object to emulate the "cast" unless the
value is actually a TypeCtorInfo_Struct, avoiding the problem of copying
uninitialised fields. Currently this is implemented by a runtime check because
the MLDS `cast' operation doesn't record the original type of the value being
cast.
2. Instead of relying on mlds_to_rtti.m to return a list of RTTI data
structures where sub-structures appear before the structures that reference
them, explicitly perform a topological sort. This should be more robust.
Unrelated change: use pre-allocated PseudoTypeInfo instances for common
variable numbers (1 through 5).
compiler/rtti_to_mlds.m:
Add a function to order a list of RTTI definitions as above.
Use cons instead of list.append in some places now that we can.
compiler/mlds_to_java.m:
Call the function to order RTTI definitions before outputing
the initialisations.
Call TypeInfo_Struct.maybe_new instead of allocating new
TypeInfo_Structs.
Generate code that uses pre-allocated PseudoTypeInfo instances.
java/runtime/TypeInfo_Struct.java:
Add a `maybe_new' method for "casting" TypeCtorInfo_Structs to
TypeInfos or returning the argument unchanged.
Delete a copy constructor; now unused.
Add some assertions.
java/runtime/PseudoTypeInfo.java:
Add static instances of PseudoTypeInfo.
tests/hard_coded/Mmakefile:
tests/hard_coded/java_rtti_bug.exp:
tests/hard_coded/java_rtti_bug.m:
Add test case.