Estimated hours taken: 50
Branches: main
Add support for foreign enumerations to Mercury. These allow the
programmer to assign foreign language values as the representation of
enumeration constructors.
e.g.
:- type status
---> optimal
; infeasible
; unbounded
; unknown.
:- pragma foreign_enum("C", status/0, [
optimal - "STATUS_OPTIMAL",
infeasible - "STATUS_INFEASIBLE",
unbounded - "STATUS_UNBOUNDED",
unknown - "STATUS_UNKNOWN"
]).
The advantage of this is that when values of type status/0 are passed to
foreign code (C in this case) no translation is necessary. This should
simplify the task of writing bindings to foreign language libraries.
Unification and comparison for foreign enumerations are the usual
unification and comparison for enumeration types, except that the default
ordering on them is determined by the foreign representation of the
constructors. User-defined equality and comparison also work for foreign
enumeration types.
In order to implement foreign enumerations we have to introduce two
new type_ctor representations. The existing ones for enum type do not
work since they use the value of an enumeration constructor to perform
table lookups in the RTTI data structures. For foreign enumerations
we need to perform a linear search at the corresponding points. This
means that some RTTI operations related to deconstruction are more
expensive.
The dummy type optimisation is not applied to foreign enumerations as
the code generators currently initialise the arguments of non-builtin
dummy type foreign_proc arguments to zero. For unit foreign enumerations
they should be initialised to the correct foreign value. (This is could be
implemented but in practice it's probably not going to be worth it.)
Currently, foreign enumerations are only supported by the C backends.
compiler/prog_io_pragma.m:
Parse foreign_enum pragmas.
Generalise the code used to parse association lists of sym_names
and strings since this is now used by the code to parse foreign_enum
pragmas as well as that for foreign_export_enum pragmas.
Fix a typo: s/foreign_expor_enum/foreign_export_enum/
compiler/prog_item.m:
Represent foreign_enum pragmas in the parse tree.
compiler/prog_type.m:
Add a new type category for foreign enumerations.
compiler/modules.m:
Add any foreign_enum pragmas for enumeration types defined in the
interface of a module to the interface files.
Output foreign_import_module pragmas in the interface file
if any foreign_enum pragmas are included in it. This ensures that
the contents that any foreign declarations that are needed by the
foreign_enum pragmas are visible.
compiler/make_hlds_passes.m:
compiler/add_pragma.m:
Add pragma foreign_enum items to the HLDS after all the types
have been added. As they are added, error check them.
Change the constructor tag values of foreign enum types to their
foreign values.
compiler/module_qual.m:
Module qualify pragma foreign_enum items.
compiler/mercury_to_mercury.m:
Output foreign_enum pragmas.
Generalise some of the existing code for writing out association
lists in foreign_export_enum pragmas for use with foreign_enum
pragmas as well.
compiler/hlds_data.m:
Add the alternative `is_foreign_type' to the type enum_or_dummy/0.
Add new type of cons_tag, foreign_tag, whose values are directly
embedded in the target language.
compiler/intermod.m:
Write out any foreign_enum pragmas for opt_exported types.
(The XXX concerning attaching language information to foreign tags
will be addressed in a subsequent change.)
compiler/llds.m:
compiler/mlds.m:
Support new kinds of rval constants: llconst_foreign and
mlconst_foreign respectively. Both of these represent tag values
as strings that are intended to be directly embedded in the target
language.
compiler/llds_out.m:
Add code to write out the new kind of rval_const.
s/Integer/MR_Integer/ in a spot.
s/Float/MR_Float/ in a spot.
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/type_ctor_info.m:
Add support the RTTI required by foreign enums.
compiler/switch_util.m:
Handle switches on foreign_enums as-per normal enumerations.
compiler/table_gen.m:
Tabling of foreign_enums is also like normal enumerations.
compiler/type_util.m:
Add a predicate that tests whether a type is a foreign enumeration.
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/ml_unify_gen.m:
Handle unification and comparison of foreign enumeration values.
They are treated like normal enumerations for the purposes of
implementing these operations.
compiler/ml_type_gen.m:
Handle foreign enumerations when generating the MLDS representation
of enumerations.
compiler/ml_util.m:
Add a function to create an initializer for an object with a
foreign tag.
compiler/mlds_to_c.m:
Handle mlconst_foreign/1 rval constants.
compiler/bytecode_gen.m:
compiler/dupproc.m:
compiler/erl_rtti.m:
compiler/exception_analysis.m:
compiler/export.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/hlds_out.m:
compiler/higher_order.m:
compiler/inst_match.m:
compiler/jumpopt.m:
compiler/llds_to_x86_64.m:
compiler/ml_code_util.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/polymorphism.m:
compiler/recompilation.version.m:
compiler/term_norm.m:
compiler/trailing_analysis.m:
Conform to the above changes.
doc/reference_manual.texi:
Document the new pragma.
Fix some typos: s/pramga/pragma/, s/behavior/behaviour/
library/construct.m:
Handle the two new type_ctor reps.
Break an over-long line.
library/rtti_implementation.m:
Support the two new type_ctor reps.
(XXX The Java versions of some of this cannot be implemented until
support for foreign enumerations is added to mlds_to_java.m.)
Reformat the inst usereq/0 and extend it to include foreign enums.
runtime/mercury_type_info.h:
Add two new type_ctor reps. One for foreign enumerations and
another for foreign enumerations with user equality.
Define new types (and extend existing ones) in order to support
RTTI for foreign enumerations.
runtime/mercury_unify_compare_body.h:
Implement generic unify and compare for foreign enumerations.
(It is the same as that for regular enumerations.)
runtime/mercury_construct.[ch]:
runtime/mercury_deconstruct.h:
Handle (de)construction of foreign enumeration values.
runtime/mercury_deep_copy_body.h:
Implement deep copy for foreign enumerations.
runtime/mercury_table_type_body.h:
runtime/mercury_term_size.c:
Handle the new type_ctor representations.
java/runtime/ForeignEnumFunctorDesc.java:
Add a Java version of the MR_ForeignEnumFuntorDesc structure.
(Note: this is untested, as the java grade runtime doesn't work
anyway.)
java/runtime/TypeFunctors.java:
Add a constructor method for foreign enumerations.
(Likewise, untested.)
NEWS:
Announce pragma foreign_enum.
vim/syntax/mercury.vim:
Highlight the new pragma appropriately.
tests/hard_coded/.cvsignore:
Ignore executables generated by the new tests.
Ignore a bunch of other files create by the Mercury compiler.
tests/hard_coded/Mmakefile:
tests/hard_coded/foreign_enum_rtti.{m,exp}:
Test RTTI for foreign enumerations.
tests/hard_coded/foreign_enum_dummy.{m,exp}:
Check that dummy type optimisation is disabled for foreign
enumerations.
tests/hard_coded/Mercury.options:
tests/hard_coded/foreign_enum_mod1.{m,exp}:
tests/hard_coded/foreign_enum_mod2.m:
Test that foreign_enum pragmas are hoisted into interface files
and that they are handled correctly in optimization interfaces.
tests/invalid/Mercury.options:
tests/invalid/Mmakefile:
tests/invalid/foreign_enum_import.{m,err_exp}:
tests/invalid/foreign_enum_invalid.{m,err_exp}:
Test that errors in foreign_enum pragmas are reported.
tests/tabling/Mmakefile:
tests/hard_coded/table_foreign_enum.{m,exp}:
Test case for tabling of foreign enumerations.
Estimated hours taken: 1
Branches: main
Let benchmark.report_stats/0 report real times on POSIX platforms.
configure.in:
Check for time.h and gettimeofday().
runtime/mercury_conf.h.in:
Add MR_HAVE_TIME_H, MR_HAVE_GETTIMEOFDAY.
Unrelated change: add MR_HAVE_PTHREAD_H.
runtime/mercury_timing.c:
runtime/mercury_timing.h:
Add `MR_get_real_milliseconds'.
runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
Rename MR_time_* globals to MR_user_time_*.
Add and initialise MR_real_time_* globals.
library/benchmarking.m:
Output real times in ML_report_stats().
Correct spelling of milliseconds.
java/runtime/Native.c:
java/runtime/Native.java.in:
trace/mercury_trace_declarative.c:
Correct spelling of milliseconds.
Estimated hours taken: 30
Branches: main
Consider types of the form
:- type x ---> f.
to be dummy types, since they contain no information. Optimize them the same
way we currently optimize io.state and store.store.
runtime/mercury_type_info.h:
Add a new type_ctor_rep for dummy types.
runtime/mercury_tabling.h:
Add a representation for "tabled" dummy types, which don't actually
have a level in the trie, so that the runtime system can handle that
fact.
runtime/mercury_ml_expand_body.h:
When deconstructing a value of a dummy type, ignore the actual value
(since it will contain garbage) and instead return the only possible
value of the type.
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.c:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
library/rtti_implementation.m:
Handle the type_ctor_rep of dummy types.
runtime/mercury_builtin_types.c:
Provide a place to record profiling information about unifications and
comparisons for dummy types.
runtime/mercury_mcpp.h:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
Add a new type_ctor_rep for dummy types, and fix some previous
discrepancies in type_ctor_reps.
mdbcomp/prim_data.m:
Move a bunch of predicates for manipulating special_pred_ids here from
the browser and compiler directories.
Rename the function symbols of the special_pred_id type to avoid the
need to parenthesize the old `initialise' function symbol.
Convert to four-space indentation.
mdbcomp/rtti_access.m:
Don't hardcode the names of special preds: use the predicates in
prim_data.m.
Convert to four-space indentation.
browser/declarative_execution.m:
Delete some predicates whose functionality is now in
mdbcomp/prim_data.m.
compiler/hlds_data.m:
Replace the part of du type that says whether a type an enum, which
used to be a bool, with something that also says whether the type is a
dummy type.
Convert to four-space indentation.
compiler/make_tags.m:
Compute the value for the new field of du type definitions.
compiler/hlds_out.m:
Write out the new field of du type definitions.
compiler/rtti.m:
Modify the data structures we use to create type_ctor_infos to allow
for dummy types.
Convert to four-space indentation.
compiler/type_ctor_info.m:
Modify the code that generates type_ctor_infos to handle dummy types.
compiler/type_util.m:
Provide predicates for recognizing dummy types.
Convert to four-space indentation.
compiler/unify_proc.m:
Generate the unify and compare predicates of dummy types using a new
code scheme that avoids referencing arguments that contain garbage.
When generating code for unifying or comparing other types, ignore
any arguments of function symbols that are dummy types.
Don't use DCG style access predicates.
compiler/higher_order.m:
Specialize the unification and comparison of values of dummy types.
Break up an excessively large predicate, and factor out common code
from the conditions of a chain of if-then-elses.
compiler/llds.m:
For each input and output of a foreign_proc, include a field saying
whether the value is of a dummy type.
compiler/pragma_c_gen.m:
Fill in the new fields in foreign_proc arguments.
compiler/hlds_goal.m:
Rename some predicates for constructing unifications to avoid
unnecessary ad-hoc overloading. Clarify their documentation.
Rename a predicate to make clear the restriction on its use,
and document the restriction.
Add a predicate for creating simple tests.
Add a utility predicate for setting the context of a goal directly.
compiler/modules.m:
Include dummy types interface files, even if they are private to the
module. This is necessary because with the MLDS backend, the generated
code inside the module and outside the module must agree whether a
function returning a value of the type returns a real value or a void
value, and this requires them to agree on whether the type is dummy
or not.
The impact on interface files is minimal, since very few types are
dummy types, and changing a type from a dummy type to a non-dummy type
or vice versa is an ever rarer change.
compiler/hlds_pred.m:
Provide a representation in the compiler of the trie step for dummy
types.
compiler/layout_out.m:
Print the trie step for dummy types.
compiler/table_gen.m:
Don't table values of dummy types, and record the fact that we don't
by including a dummy trie step in the list of trie steps.
compiler/add_pragma.m:
compiler/add_special_pred.m:
compiler/add_type.m:
compiler/aditi_builtin_ops.m:
compiler/bytecode.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/cse_detection.m:
compiler/det_report.m:
compiler/exception_analysis.m:
compiler/inst_match.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_il.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/opt_util.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/qual_info.m:
compiler/rl.m:
compiler/rl_exprn.m:
compiler/rl_key.m:
compiler/rtti_out.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/term_constr_initial.m:
compiler/term_constr_util.m:
compiler/term_norm.m:
compiler/termination.m:
compiler/trace.m:
compiler/typecheck.m:
compiler/unify_gen.m:
Conform to the changes above.
compiler/export.m:
compiler/exprn_aux.m:
compiler/foreign.m:
compiler/polymorphism.m:
compiler/proc_label.m:
compiler/rtti_to_mlds.m:
compiler/special_pred.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/state_var.m:
compiler/switch_util.m:
compiler/trace_params.m:
Conform to the changes above.
Convert to four-space indentation.
compiler/mlds_to_java.m:
compiler/var_locn.m:
Conform to the changes above, which requires threading the module_info
through the module.
Convert to four-space indentation.
compiler/mercury_compile.m:
Pass the module_info to mlds_to_java.m.
compiler/ml_util.m:
compiler/polymorphism.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
Delete some previously missed references to the temporary types used
to bootstrap the change to the type_info type's arity.
compiler/polymorphism.m:
Turn back on an optimization that avoids passing parameters (such as
type_infos) to foreign_procs if they are not actually referred to.
compiler/prog_data.m:
Convert to four-space indentation.
library/svvarset.m:
Add a missing predicate.
trace/mercury_trace.c:
Delete the unused function that used to check for dummy types.
tests/debugger/field_names.{m,inp,exp}:
Add to this test case a test of the handling of dummy types. Check that
their values can be printed out during normal execution, and that the
debugger doesn't consider them live nondummy variables, just as it
doesn't consider I/O states live nondummy variables.
Estimated hours taken: 4
Branches: main
Provide a mechanism for declaring foreign types that can be operated on by
compare_representation. The intended use of the mechanism is to declare
a foreign type to represent proc_layouts in the declarative debugger,
as part of the representation of atoms; since atoms are keys in maps
in the oracle, they are input to compare_representation.
Since we don't want the result of compare_representation to change as
execution proceeds, we require an assertion that the foreign value is
stable, i.e. that the value of the foreign type variable completely
determines the data it points to, directly and indirectly. Proc_layouts
are static, so this is not a problem. Being able to do the comparison
requires the foreign type to be an integral type or a pointer, which
is what the existing can_pass_as_mercury_type assertion promises.
The stability is promised by a new assertion.
For foreign types that have both assertions, we use a new type_ctor_rep,
which differs from the existing type_ctor_rep for foreign types by doing
a real comparison instead of an abort in compare_representation.
doc/reference_manual.texi:
Document the new kind of assertion.
compiler/prog_data.m:
Add the new kind of assertion.
compiler/prog_io_pragma.m:
Parse the new kind of assertion.
compiler/rtti.m:
Add the representation of the new type_ctor_rep. Factor out the
stability of c_pointers as well as foreign types.
compiler/type_ctor_info.m:
Generate the new type_ctor_rep for types with both assertions.
compiler/foreign.m:
Export a predicate for use by type_ctor_info.m.
compiler/mercury_to_mercury.m:
Print the new assertion.
compiler/*.m:
Minor changes to conform to the diffs above.
Use state variable notation.
library/rtti_implementation.m:
Handle the new type_ctor_rep.
runtime/mercury_mcpp.h:
runtime/mercury_type_info.h:
java/runtime/TypeCtorRep.java:
Add the new type_ctor_rep to the runtime.
runtime/mercury_mcpp.h:
runtime/mercury_type_info.h:
compiler/type_ctor_info.m:
Increment the rtti version number.
When we rely on the availability of this new capability,
we should add a test for the new rtti version number to configure.in.
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_term_size.h:
Handle stable foreign types the same way as other foreign types.
runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.h:
runtime/mercury_unify_compare_body.h:
Handle stable foreign types in a useful manner, relying on the
assertions behind them.
tests/hard_coded/stable_foreign.{m,exp}:
A test case for the handling of values of a stable foreign type.
tests/hard_coded/Mmakefile:
Enable the new test case.
Estimated hours taken: 0.1
Branches: main
Remove the library stub files that we formerly
used for developing the Java backend.
java/Mmakefile:
java/library/*.java:
Delete the library stub files in this directory.
We no longer need them now that the real library
compiles.
Estimated hours taken: 0.1
Branches: main
Have CVS ignore various files generated by the java grade and
some other bits and pieces in the browser directory.
browser/.cvsignore:
library/.cvsignore:
java/runtime/.cvsignore:
Update these files.
Estimated hours taken: 30
Branches: main
Implement RTTI for the Java-backend (incomplete)
java/runtime/PseudoTypeInfo.java:
java/runtime/TypeCtorInfo_Struct.java:
java/runtime/TypeInfo_Struct.java:
Implement the `unify' operation for these classes. This implementation
actually just compares them.
library/rtti_implementation.m:
Document a bug in notag_functor_arg_type/1
Define the foreign type of `type_layout' as `TypeLayout' in Java.
Correct an off-by-one error in type_ctor_and_args/3.
Implement deconstruct/8 for TypeCtorRep = enum.
Implement the following predicates in Java:
get_var_arity_typeinfo_arity/1
get_pti_from_arg_types/2
typeinfo_is_variable/2
get_type_ctor_info/1
get_primary_tag/1
get_remote_secondary_tag/1
ptag_index/2
sectag_locn/1
du_sectag_alternatives/2
type_info_index/2
type_ctor_arity/1
type_ctor_rep/1
type_ctor_module_name/1
type_ctor_name/1
type_ctor_functors/1
type_layout/1
unsafe_cast/1
du_functor_desc/3
du_functor_name/1
du_functor_arity/1
du_functor_arg_type_contains_var/1
du_functor_sectag_locn/1
du_functor_primary/1
du_functor_secondary/1
du_functor_ordinal/1
du_functor_arg_types/1
du_functor_arg_names/1
du_functor_exist_info/1
enum_functor_desc/3
enum_functor_name/1
enum_functor_ordinal/1
notag_functor_desc/3
notag_functor_name/1
notag_functor_arg_type/1
notag_functor_arg_name/1
null/1
null_string/0
unsafe_get_enum_value/1
library/type_desc.m:
Implement the following procedures for Java:
type_of/1
has_type/1
type_ctor_and_args/3
type_ctor_name_and_arity/4
Implement the Java classes `type_desc_0' and `type_ctor_desc_0'.
Estimated hours taken: 0.2
Branches: main
Fix a type error in a Java RTTI class.
java/runtime/DuFunctorDesc.java:
Changed representation of `du_functor_exist_info' from `DuExistInfo[]'
to `DuExistInfo' (single), in keeping with the conventions elsewhere.
Estimated hours taken: 0.25
Branches: main
java/runtime/TypeClassConstraint.java:
Add a new constructor which takes a PseudoTypeInfo[] array, and
also a variant which takes an Object[] array. These are needed
because the compiler sometimes generates calls to them.
Estimated hours taken: 4
Branches: main
Bug fixes and code simplifications in the RTTI handling
for the Java back-end.
compiler/rtti.m:
For Java, map all the different C representations for TypeInfos
to a single Java type "java.runtime.TypeInfo_Struct".
Likewise map all the different C representations for type class
constraints to a single Java type "java.runtime.TypeInfo_Struct".
java/runtime/FA_PseudoTypeInfo_Struct1.java:
java/runtime/FA_PseudoTypeInfo_Struct2.java:
java/runtime/FA_TypeInfo_Struct1.java:
java/runtime/FA_TypeInfo_Struct2.java:
java/runtime/VA_PseudoTypeInfo_Struct0.java:
java/runtime/VA_PseudoTypeInfo_Struct1.java:
java/runtime/VA_PseudoTypeInfo_Struct2.java:
java/runtime/VA_PseudoTypeInfo_Struct3.java:
java/runtime/VA_PseudoTypeInfo_Struct4.java:
java/runtime/VA_PseudoTypeInfo_Struct8.java:
java/runtime/TypeclassInfo.java:
Deleted these stub files, since they should no longer be needed.
java/runtime/TypeInfo_Struct.java:
Add two new constructors, corresponding to the constructors for
the deleted FA_* and VA_*.java files.
java/runtime/PseudoTypeInfo.java:
Add some comments. Make the nullary constructor protected,
to ensure that it is only used by derived classes, since it
is only intended to be used for TypeInfo_Struct.
Estimated hours taken: 2
Branches: main
Implement some library procedures for the Java back-end.
library/time.m:
Implement c_clk_tck/0 for Java. Also changed the C implementation to
use the same macro as that used in Native.c.
java/runtime/Native.java.in:
Add new function clk_tck() to be called by c_clk_tck/0.
java/runtime/Native.c:
Add corresponding implementation for clk_tck().
Estimated hours taken: 0.1
Branches: main
Get configure to add a comment to Constants.java and Native.java
saying that they are automatically generated.
Update the java/runtime/.cvsignore.
java/runtime/Constants.java.in:
java/runtime/Native.java.in:
Get configure to add a comment saying that these files
are automatically generated.
java/runtime/.cvsignore:
Ignore the automatically generated file Native.java.
Estimated hours taken: 1.5
Branches: main
Implement some library procedures for Java.
library/benchmarking.m:
Implement the following predicates in Java:
report_stats/0
report_full_memory_stats/0
java/runtime/Native.java.in:
Record whether or not there has yet been an attempt to load the
library.
Add the side effect of loading the library to isAvailable(), in case
the static code for benchmarking.java is run before the static code
for Native.java.
Estimated hours taken: 0.25
Branches: main
java/runtime/ReservedAddrFunctorDesc.java:
New file. This corresponds to the C type MR_ReservedAddrFunctorDesc
in runtime/mercury_type_info.h. It will be needed if compiling
to Java with the reserved tag options (--num-reserved-objects
or --num-reserved-addresses) enabled.
Estimated hours taken: 3
Branches: main
Some fixes to the Java back-end, to make it work again after
Zoltan's recent type class RTTI changes.
java/runtime/DuExistInfo.java:
Add a new field "exist_constraints" to the DuExistInfo type
and a corresponding argument to the constructor, to match
Zoltan's recent changes.
java/runtime/TypeClassId.java:
java/runtime/TypeClassMethod.java:
java/runtime/TypeClassDeclStruct.java:
java/runtime/TypeClassConstraint.java:
New files. These correspond to the C types MR_TypeClassId,
MR_TypeClassMethod, MR_TypeClassDeclStruct,
and MR_TypeClassConstraint in the C runtime.
java/runtime/TypeCtorInfo_Struct.java:
Add a comment.
compiler/rtti_to_mlds.m:
Don't cast null pointers to mlds__generic_type; they should have
the right type already. Casting to mlds__generic_type here causes
type errors for the Java back-end, because in Java there are no
implicit conversions from Object (unlike C, which allows implicit
conversions from `void *').
compiler/rtti.m:
Change tc_rtti_name_java_type so that it maps the new typeclass-related
RTTI types to the appropriate Java types.
library/private_builtin.m:
Define MR_PREDICATE and MR_FUNCTION.
java/runtime/PredFunc.java:
Fix a bug in my previous change:
s/MR_PRED/MR_PREDICATE/
s/MR_FUNC/MR_FUNCTION/
Estimated hours taken: 13
Branches: main
Implement some library predicates for Java using JNI.
java/runtime/Native.java.in:
A new class which uses JNI to provide any native functionality
required by predicates of the standard library in Java.
So far it only provides methods relating to timing.
java/runtime/Native.c:
Source code, written in C, which implements all the native methods of
mercury.runtime.Native. Note that this implementation makes use of the
existing C implementation of the equivalent functions.
java/runtime/Mmakefile:
Rules for compiling a shared object from Native.c.
library/time.m:
Implement the following predicates for Java using Native interface:
time__c_clock/3
time__clocks_per_sec/1
time__times/7
library/benchmarking.m:
Implement the following predicates for Java using Native interface:
get_user_cpu_miliseconds/1
library/Mmakefile:
Renamed to library/Mmakefile.in, so as to have access to FULLARCH
constant.
library/Mmakefile.in:
Added rules for incorporating the Native shared object.
Estimated hours taken: 2
Branches: main
Implement library version for Java.
library/library.m:
Implement library__version in Java.
java/runtime/Constants.java.in:
File from which Constants.java is to be generated, which is the source
for a class to hold mercury-related constants, such as the library
version.
configure.in:
Added java/runtime/Constants.java to the list of files to generate.
Estimated hours taken: 5
Branches: main
Implement some library procedures for the Java back end.
library/std_util.m:
Defined the type mutvar(T) as an array of java.lang.Objects (which
will always be size 1)
Implemented the following procedures in Java:
get_registers/3
check_for_floundering/1
discard_trail_ticket/0
swap_heap_and_solutions_heap/0
partial_deep_copy/3
reset_solutions_heap/1
new_mutvar/2
get_mutvar/2
set_mutvar/2
java/runtime/VA_PseudoTypeInfo_Struct0.java:
This new file is a workaround which allows std_util.m to successfully
compile in grade Java.
Estimated hours taken: 4
Branches: main
Implement some library procedures for the Java back end.
library/dir.m:
Updated the imports so interface includes string and io, and altered
style to that of one import per line.
Defined the dir__stream foreign_type as an java.util.Iterator.
Implemented the following procedures in Java:
dir__directory_separator/0
can_implement_make_directory/0
dir__make_single_directory_2/5
dir__open_2/4
dir__close_2/5
dir__read_entry_2/6
java/runtime/VA_PseudoTypeInfo_Struct8.java:
This new file is a workaround which allows dir.m to successfully
compile in grade Java.
Estimated hours taken: 3
Branches: main
Added support for progname and exit status in grade Java.
compiler/mlds_to_java.m:
Added code to maybe_write_main_driver/5 to store the main class's name
and exit status in mercury.runtime.JavaInternal's static variables.
Also, main() now calls java.lang.System.exit() instead of returning,
since Java insists that main must have void return type.
java/runtime/JavaInternal.java:
Added static variables "progname" and "exit_status".
Estimated hours taken: 6
Branches: main
More work on the Java back-end. The standard library now compiles
in grade `java', and hello world (the version using io__write_string,
and linked against the standard library in library/*.m, not the
hand-coded one in java/library/*.java) now works!
compiler/make_hlds.m:
Ignore `pragma type_spec' declarations for the Java back-end.
This works around a problem where javac was failing to compile
some of our generated code due to it overflowing limits on
file name length for the names of the .class files for some
nested classes.
compiler/mlds_to_java.m:
Add some comments. Add myself to the "main authors" list.
library/string.m:
Provide Java definitions of string__first_char and
string__unsafe_index. (These are needed for string.append,
which is used by private_builtin.sorry.)
library/io.m:
Provide Java definitions of io__write_{string,int,char,float}/3.
java/runtime/TypeCtorInfo_Struct.java:
Fix a cut-and-paste error.
java/runtime/TypeInfo_Struct.java:
Improve the implementation of the TypeInfo_Struct(Object)
constructor so that it doesn't throw exceptions during
the initialization of the standard library.
java/runtime/FA_TypeInfo_Struct1.java:
Make this type inherit from TypeInfo_Struct.
Estimated hours taken: 10
Branches: main
Bug fixes for the Java back-end.
The standard library now almost compiles in grade java.
compiler/mlds_to_java.m:
Output Java foreign declarations before any other code,
to fix a problem with references to the TYPE_CTOR_REP
constants in library/private_builtin.m.
Fix some bugs where we were not being consistent about mangling
the module name when naming the classes used to simulate taking
procedure addresses. This bug broke Java compilation of library/char.m.
Fix some bugs where the compiler was getting confused about
which types map to array types in Java.
For MLDS casts that cast to type_info or pseudo_type_info,
generate Java constructor calls, not Java casts.
This fixes type errors in the generated Java code.
Simplify the code for hand_defined_type.
compiler/rtti.m:
Fix a bug in tc_rtti_name_java_type: map typeclass_infos to
the Java type "java.lang.Object[]", not "java.lang.Integer[]".
The latter didn't work because the elements which hold the method
addresses do not have type java.lang.Integer.
java/runtime/DuExistInfo.java:
java/runtime/NotagFunctorDesc.java:
Define constructors for these types.
java/runtime/TypeInfo_Struct.java:
Define some additional constructors for this type.
library/builtin.m:
Provide Java stub definitions of
- classes for the types func/0 and c_pointer/0;
- unify/compare preds for func, c_pointer, tuple, and void;
Define Java definitions for the additional modes of compare/3
(they just call the first mode).
library/exception.m:
Define Java versions of make_io_state and consume_io_state,
and Java stubs for throw_impl and catch_impl.
Change try_all so that it calls catch_impl, like try does,
rather than calling builtin_catch directly. This is needed
since the .NET and Java back-ends only define catch_impl,
not builtin_catch.
library/io.m:
Provide Java `pragma foreign_type' declarations for the types
array.array(T) and io.system_error. This is needed to avoid
compilation errors when building in grade `java'.
library/private_builtin.m:
Delete the Java definition of the type_info for type_info/1,
because that is generated automatically now,
after petdr's recent bug fix.
Provide Java stubs definitions of the unify/compare preds
for ref/1, heap_pointer/0, type_ctor_info, type_info,
base_typeclass_info, and typeclass_info.
Provide Java definition of dummy_var.
library/type_desc.m:
Provide Java stub definitions of
- classes for type_desc/0 and type_ctor_desc/0
- unify/compare preds for those types
library/store.m:
Define unification and comparison predicates for the store(S)
type. This is needed because the automatically generated ones
might not have the right semantics, but also because the Java
back-end generates some invalid code for the automatically
generated unification and compare predicates (the generated
code has some invalid references to "dummy_var").
Estimated hours taken: 2
Branches: main
Runtime fixes for the Java back-end.
java/runtime/DuExistLocn.java:
java/runtime/DuFunctorDesc.java:
java/runtime/DuPtagLayout.java:
Define constructors for these types.
java/runtime/MaybeResAddrFunctorDesc.java:
New file (corresponds to MR_MaybeResAddrFunctorDesc type in C).
java/runtime/MaybeResFunctorDesc.java:
New file (corresponds to MR_MaybeResFunctorDesc type in C).
java/runtime/PseudoTypeInfo.java:
Define constructors.
Make non-abstract (XXX temp work-around only).
java/runtime/TypeCtorInfo_Struct.java:
XXX Pass some parameters of the constructor as "Object",
to work around type errors in invocations of those constructors.
java/runtime/TypeFunctors.java:
java/runtime/TypeLayout.java:
Model the C unions better; use a single field, with accessor
functions that convert to each alternative, not several fields.
java/runtime/TypeclassInfo.java:
Implement as stub (previous code was just copy of TypeInfo.java).
java/runtime/VA_PseudoTypeInfo_Struct*.java:
Fix a bug: change the order of the constructor parameters
to match the way we generate code which invokes those constructors.
Estimated hours taken: 0.1
Branches: main
This change fixes a problem which caused some programs to not compile
in grade `java'.
java/library/prolog.java:
New file. Just a stub, like most of the other *.java files in
this directory.
Estimated hours taken: 18
Branches: main
Some fixes to the Java back-end to make it support RTTI
better. The aim is to at least be able to *compile* code
that makes use of polymorphism (e.g. the Mercury standard
library!), although that aim is not yet achieved with this diff.
Getting code which actually *uses* the RTTI to work is still
a long way off...
compiler/rtti.m:
compiler/mlds_to_java.m:
Fix some bugs in the code to output RTTI type names.
compiler/mlds_to_java.m:
Output the RTTI definitions. This is needed to avoid errors
in code which references them.
Handle initializers better; in particular deal with nested
initializers properly.
Pass the current module name down to output_lval, so that we can
module-qualify data names only if they occur in a different
module. This is needed to ensure that static data defined
in other modules gets module-qualified, but local variables don't.
This also required change some places which were incorrectly
calling output_fully_qualified_name to instead call output_name.
Add comments in the generated output code when generating
"java.lang.Object", so that it is clearer what kind of object
is involved.
Add some special treatment for the types with hand-defined RTTI.
java/runtime/*.java:
Add some definitions of RTTI types, and some new constructors
for the RTTI types that were already defined.
These are currently all just stubs.
Estimated hours taken: 2
Branches: main
Delete the univ type_ctor_rep, since we haven't used it in a long time,
and add two new type_ctor_reps: one for subgoals, so that they won't have
to be treated specially when deconstructed, and one for a future type,
stable_c_pointer, which is the same as c_pointer except that it guarantees
that the entire data structure it points to, directly and indirectly is
read only, which means that its values can be tabled. The intention is
to use stable_c_pointers to represent robdds.
runtime/mercury_type_info.h:
Make the change above.
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
Handle the two new type_ctor_reps, and delete the code handling univs.
compiler/mlds_to_gcc.m:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
runtime/mercury_mcpp.h:
runtime/mercury_mcpp.cpp:
Update the list of type_ctor_reps, including fixing some old errors
in some files.
library/rtti_implementation.m:
Update the list of type_ctor_reps, and modify the routines that
interpret the RTTI accordingly.
Estimated hours taken: 4
Branches: main
Add some more code to the temporary, partial Java versions of the
Mercury library modules. This allows us to test the Java back-end
on a few extra test cases and could help prevent regression errors.
mercury/java/library/array.java:
mercury/java/library/benchmarking.java:
mercury/java/library/bintree.java:
mercury/java/library/bintree_set.java:
mercury/java/library/construct.java:
mercury/java/library/dir.java:
mercury/java/library/exception.java:
mercury/java/library/lexer.java:
mercury/java/library/math.java:
mercury/java/library/parser.java:
mercury/java/library/random.java:
mercury/java/library/rtti_implementation.java:
mercury/java/library/set_ordlist.java:
mercury/java/library/set_unordlist.java:
mercury/java/library/store.java:
mercury/java/library/table_builtin.java:
mercury/java/library/term_io.java:
mercury/java/library/varset.java:
Added these files. They are partial (or empty) versions of
the Mercury library modules written in Java.
mercury/java/library/bool.java:
mercury/java/library/builtin.java:
mercury/java/library/io.java:
mercury/java/library/mr_int.java:
mercury/java/library/private_builtin.java:
mercury/java/library/std_util.java:
mercury/java/library/string.java:
Add additional code to these files.
Estimated hours taken: 0.5
Branches: main
java/library/builtin.java:
Define stubs for the generic unify and compare, to avoid errors
from the Java compiler when compiling automatically-generated
type-specific unify and compare procedures for polymorphic types.
Estimated hours taken: 6
Branches: main
Fix test case failures involving type_ctor_descs in .rt grades.
The cause of the failures was that the type_ctor_rep for type_ctor_descs (which
happens to be 35) does not fit into a signed 8-bit integer in .rt grades,
since those grade require 2 bits for a primary tag (3 bits on 64-bit machines).
The fix is to make the type_ctor_rep field in type_ctor_infos 16 bits in size.
To maintain alignment, this requires swapping that field with the num_ptags
field.
The second part of this change will remove the bootstrapping code and raise
the binary compatibility version number. That part cannot be committed until
this part has been installed on all our machines.
runtime/mercury_type_info.h:
Define a new version of the type_ctor_info structure with this swap
and size increase. Provide backward compatibility for bootstrapping.
runtime/mercury_mcpp.h:
library/rtti_implementation.m:
java/runtime/TypeCtorInfo_Struct.m:
Make the same change.
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/mlds_to_gcc.m:
Generate the new type_ctor_info structure.
compiler/llds_out.m:
compiler/mlds_to_c.m:
Generate a macro that selects the new version of the type_ctor_info
structure.
compiler/type_ctor_info.m:
Update the type_ctor_info version number.
Estimated hours taken: 40
Branches: main
Fix the RTTI of type_descs and type_ctor_descs. Make comparisons between
type_ctor_descs and type_ctor_infos (and therefore between type_descs and
type_infos) more predictable and consistent across backends by basing them
on programmer-visible attributes instead of accident of location in the
executable.
runtime/mercury_type_desc.[ch]:
Implement unification and comparison functions for type_ctor_descs.
(The unification and comparison functions for type_infos also double
as the unification and comparison functions for type_descs.)
Make the comparison function work on the module name, type name and
arity instead of the address of the type_ctor_info structure. This
ensures consistency across back ends.
Add some useful macros.
runtime/mercury_type_info.[ch]:
Make the comparison function on type_ctor_infos also work on module
name, type name and arity. Since this makes comparison slower, add
specialized unification functions for type_infos and type_ctor_infos.
runtime/mercury_type_info.h:
runtime/mercury_mcpp.{h,cpp}:
runtime/mercury.h:
library/private_builtin.m:
library/rtti_implementation.m:
java/runtime/TypeCtorRep.java:
compiler/mlds_to_gcc.m:
Add type_ctor_reps for type_descs and type_ctor_descs. Type_ctor_descs
definitely need it, since their representation is very low level and
not shared with anything else. Type_descs could use the type_ctor_rep
of type_infos, since type_descs and type_infos share the same
representation at the moment. However, we add a new one because
profiling cares about the conceptual distinction between type_infos
and type_descs.
library/type_desc.m:
Delete the Mercury "definition" of type_desc, because it is misleading.
Implement it as a builtin type.
runtime/mercury.[ch]:
Implement type_ctor_desc as a builtin type.
Add missing implementations of unify/compare on type_ctor_infos.
runtime/mercury_deconstruct.c:
runtime/mercury_ml_expand_body.h:
Implement deconstruction for type_descs and type_ctor_descs.
runtime/mercury_ho_call.c:
runtime/mercury_unify_compare_body.h:
Implement unify and compare for type_descs and type_ctor_descs.
Implement unify for type_infos, type_ctor_infos, type_descs and
type_ctor_descs by calling the relevant unification function,
not the relevant comparison function, since the unification
function will be faster.
runtime/mercury_deep_copy_body.h:
runtime/mercury_construct.c:
runtime/mercury_tabling.c:
Minor changes to handle type_descs and type_ctor_descs.
trace/mercury_trace_vars.c:
Enable the printing of type_descs and type_ctor_descs.
tests/debugger/type_desc_test.{m,inp,exp,exp2}:
New test case to check the printing of type_descs and type_ctor_descs.
tests/debugger/Mmakefile:
Enable the new test case.
tests/hard_coded/type_ctor_desc_manip.{m,exp}:
New test case to check the deconstruction and comparison of type_descs
and (especially) type_ctor_descs. Before this change, we got different
results for comparisons of type_ctor_descs, results that were
inconsistent with the results of comparisons of the type_descs
that the type_ctor_descs were derived from.
tests/hard_coded/Mmakefile:
Enable the new test case.
Estimated hours taken: 0.5
Branches: main
mercury/java/Makefile:
Renamed to `Mmakefile'.
mercury/Mmakefile:
Invoke mmake in the mercury/java directory to create symbolic
links for java class directories at build time.
Estimated hours taken: 3
Branches: main
This change introduces some (partial) Java versions of the mercury library
which are currently needed to compile some .java files generated by the
mercury compiler for the tests/benchmarks test cases.
These additions are required temporarily for testing purposes until the
mercury library can be compiled in grade java.
mercury/java/Commit.java:
mercury/java/DuExistInfo.java:
mercury/java/DuExistLocn.java:
mercury/java/DuFunctorDesc.java:
mercury/java/DuPtagLayout.java:
mercury/java/EnumFunctorDesc.java:
mercury/java/JavaInternal.java:
mercury/java/MethodPtr.java:
mercury/java/NotagFunctorDesc.java:
mercury/java/PseudoTypeInfo.java:
mercury/java/Sectag_Locn.java:
mercury/java/TypeCtorInfo_Struct.java:
mercury/java/TypeCtorRep.java:
mercury/java/TypeFunctors.java:
mercury/java/TypeLayout.java:
mercury/java/UnreachableDefault.java:
All files that were located in the mercury/java directory have been
moved to mercury/java/runtime.
mercury/java/Makefile:
A simple Makefile to set up a couple of symbolic links so we can
just include the mercury/java directory in our CLASSPATH.
mercury/java/library/assoc_list.java:
mercury/java/library/bool.java:
mercury/java/library/builtin.java:
mercury/java/library/deconstruct.java:
mercury/java/library/enum.java:
mercury/java/library/integer.java:
mercury/java/library/io.java:
mercury/java/library/list.java:
mercury/java/library/map.java:
mercury/java/library/mer_int.java:
mercury/java/library/mr_char.java:
mercury/java/library/mr_float.java:
mercury/java/library/mr_int.java:
mercury/java/library/ops.java:
mercury/java/library/private_builtin.java:
mercury/java/library/require.java:
mercury/java/library/set.java:
mercury/java/library/std_util.java:
mercury/java/library/string.java:
mercury/java/library/term.java:
mercury/java/library/time.java:
mercury/java/library/tree234.java:
mercury/java/library/type_desc.java:
These are partial Java versions of mercury library modules. They are
very rough but will currently allow for most of the tests/benchmark
directory to run in Java.
Estimated hours taken: 50
Branches: main
Bug fixes and additions to the Java back-end so that it will now successfully
compile and run mercury programs which contain higher order code as well as
non-deterministic code.
With some hacked up Mercury library code (in Java) I am able to compile 10 of
the 11 files in the tests/benchmarks directory into Java and run them to
receive the correct output.
mercury/compiler/mlds_to_java.m:
Many small bug fixes.
Disabled current (incomplete) name mangling code. All class, package
and method names apart from java.* and mercury.runtime.* will be
output as lowercase for the moment.
Added code to prefix some classes/packages so we don't run into the
problem of having a class or package name which is also a Java reserved
word. This is the case with the mercury library modules int and char.
Added code to implement commits.
mercury/compiler/java_util.m:
Added a few missing Java reserved words.
mercury/compiler/ml_code_util.m:
A small change so that in one case where they weren't, multiple return
values are now generated in the MLDS.
mercury/java/Commit.java:
Added this file, a throwable class used for the implementation of
commits.
mercury/java/ProcAddr.java:
mercury/java/Compare.java:
mercury/java/Unify.java:
Removed these files, they're now obsolete as they all use the standard
interface for method pointers provided by MethodPtr.java.
mercury/java/TypeCtorInfo_Struct.java:
Altered to reference mercury.runtime.MethodPtr instead of
mercury.runtime.[Unify|Compare].
Estimated hours taken: 8
Branches: main
Move the RTTI-related parts of std_util.m to three new modules in the standard
library, and (in the case of embedded C code) to new modules in the runtime.
The main reason for this is to allow a reorganization of some of the
RTTi-related functionality without breaking backward compatibility. However,
the new arrangement should also be easier to maintain.
Use a separate type_ctor_rep for functions, to distinguish them from predicates
for RTTI code. (At one point, I thought this could avoid the need for the
change to the initialization files mentioned below. It can't, but it is a good
idea in any case.)
library/std_util.m:
Remove the functionality moved to the new modules, and replace them
with type equivalences and forwarding code. There are no changes in
the meanings of the user-visible predicates, with two exceptions.
- First, the true, equivalence-expanded names of what used to be
std_util:type_desc and std_util:type_ctor_desc are now
type_desc:type_desc and type_desc: type_ctor_desc.
- Second, deconstructing a function term now yields
"<<function>>" instead of "<<predicate>>".
The intention is that the RTTI predicates in std_util.m will continue
to work in a backwards-compatible manner for the near future, i.e. as
the new modules are updated, the code in std_util will be updated to
maintain the same functionality, modulo improvements such as avoiding
unwanted exceptions. When the RTTI functionality in the other modules
has stabilised, the RTTI predicates in std_util.m should be marked
obsolete.
The exported but non-documented functionality of std_util has been
moved to one of the new modules without forwarding code, with one
of the moved predicates being turned into the function it should have
been in the first place.
library/construct.m:
library/deconstruct.m:
library/type_desc.m:
Three new modules for the code moved from std_util.m.
library/library.m:
compiler/modules.m:
Record the names of the three new library modules.
runtime/mercury.[ch]:
compiler/mlds_to_il.m:
Record that type_desc is now in type_desc.m, not std_util.m.
compiler/static_term.m:
Import the deconstruct module, since we are using its undocumented
facilities.
runtime/Mmakefile:
Mention the two new modules.
runtime/mercury_construct.[ch]:
runtime/mercury_type_desc.[ch]:
Two new modules holding the C functions that used to be in foreign_code
in std_util, now using MR_ instead of ML_ prefixes, and being more
consistent about indentation.
runtime/mercury_type_info.h:
Add a new type_ctor_rep for functions, separate from predicates.
(It reuses the EQUIV_VAR type_ctor_rep, which hasn't been used
in ages.)
Use type_ctor_reps to distinguish between the type_ctor_infos of
pred/0 and func/0. However, to create higher order typeinfos, we
still need to know the addresses of the type_ctor_infos for
pred/0 and func/0, and we still need to know the address of the
type_ctor_info for tuples to create typeinfos for tuples. Since
these three type_ctor_infos are defined in the library,
we cannot access them directly from the runtime. We therefore need
to access them indirectly in the usual manner, via address_of
variables initialized by mkinit-generated code.
library/builtin.m:
library/private_builtin.m:
library/rtti_implementation.m:
runtime/mercury.c:
runtime/mercury_mcpp.{h,cpp}:
java/TypeCtorRep.java:
Updates to accommondate the new function type_ctor_rep.
runtime/mercury_type_info.[ch]:
Add some functions from foreign_code in std_util that fit in best here.
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.h:
runtime/mercury_unify_compare_body.h:
Delete the code for handling EQUIV_VAR, and add code for handling
functions.
runtime/mercury_init.h:
runtime/mercury_wrapper.[ch]:
Add three variables holding the address of the type_ctor_infos
representing functions, predicates and tuples.
util/mkinit.c:
Fill in these three variables.
tests/general/accumulator/construct.{m,exp}:
tests/general/accumulator/deconstruct.{m,exp}:
tests/hard_coded/construct.{m,exp}:
Rename these tests by adding a _test at the ends of their names,
in order to avoid collisions with the names of the new standard library
modules. The test cases have not changed, with the exception of the :-
module declaration of course.
tests/general/accumulator/Mmakefile:
tests/general/accumulator/INTRODUCED:
tests/hard_coded/Mmakefile:
Record the name changes.
tests/hard_coded/existential_float.exp:
Updated the expected output to reflect that deconstructions now print
"<<function>>" instead of "<<predicate>>" when appropriate.
tests/hard_coded/higher_order_type_manip.exp:
Updated the expected output to reflect the new name of what used to be
std_util:type_desc.
trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
#include type_desc.h instead of std_util.h, since the C functions
we want to call are now defined there.
trace/mercury_trace_vars.c:
Update to account for the movement of type_desc from std_util to
type_desc, and ensure that we don't refer to any type_ctor_infos
in MLDS grades.
Estimated hours taken: 12
Branches: main
Fix a bug by distinguishing the type_ctor_reps of type_infos and
type_ctor_infos. The type_ctor_infos of types with nonzero arity
cannot be printed, copied etc like type_infos; any attempt to do so
causes a core dump.
For similar reasons, add a separate type_ctor_rep for
base_typeclass_infos separate from typeclass_infos.
runtime/mercury_type_info.h:
runtime/mercury_mcpp.h:
compiler/mlds_to_gcc.m:
library/rtti_implementation.m:
java/TypeCtorRep.java:
Add new type_ctor_reps for type_ctor_infos and base_typeclass_infos.
library/private_builtin.m:
runtime/mercury.c:
Use the new type_ctor_reps in the type_ctor_infos of the builtin types
type_ctor_info and base_typeclass_info.
runtime/mercury_type_info.[ch]:
Add a function for comparing type_ctor_infos.
Move some interface documentation from the source file to the header
file.
runtime/mercury_deep_copy_body.h:
Add code to handle the new type_ctor_reps.
Simplify some code.
Make the whole file use 4-space indentation.
library/std_util.m:
runtime/mercury_ml_expand_body.h:
runtime/mercury_unify_compare_body.h:
runtime/mercury_ho_call.c:
runtime/mercury_tabling.c:
Add code to handle the new type_ctor_reps.
Estimated hours taken: 0.1
Branches: main
java/TypeCtorInfo_Struct.java:
Update the TypeCtorInfo structure to reflect the recent bootstrapping
changes.
Branches: main
Estimated hours taken: 0.5
With this change, the files in the `java' directory now all compile
fine with `javac' (after `mkdir mercury; ln -s .. mercury/runtime')
except for the reference to `mercury.Builtin.builtin_comparison_result_0'
in Compare.java.
java/Sectag_Locn.java:
Fix typos.
Estimated hours taken: 90
Branches: main
Changes and additions to the Java back-end so that:
o While tags shouldn't be generated, they do get generated in some cases
and are now handled correctly.
o The Java back-end now generates class constructors.
o The Java back-end is now able to simulate the behaviour of function
pointers, which are used for closures, continuations, as well as unify
and compare.
mercury/compiler/mlds_to_java.m:
Extensive changes to existing code to implement tags and class
constructors. Also, addition of code to search MLDS for uses of
function pointers and to generate MLDS for wrapper classes. As well
as many small bug fixes.
Removed some (unfinished) code for dealing with Unify and Compare, this
code was redundant now that function pointers have been implemented.
mercury/compiler/java_util.m:
Updated to return noops for most tag operators.
mercury/java/MethodPtr.java:
New file. This is the interface which the wrapper classes used for
function pointers extend.
Estimated hours taken: 10.
Classes used by the Java backend, particularly in the implementation
of RTTI.
java/Compare.java:
java/Unify.java:
New files. Java classes for implementation of wrapper classes
around the builtin `unify'and `compare' predicates.
java/JavaInternal.java:
New file. Java class for storing runtime information such
as command line arguments.
java/DuExistInfo.java:
java/DuExistLocn.java:
java/DuFunctorDesc.java:
java/DuPtagLayout.java:
java/EnumFunctorDesc.java:
java/NotagFunctorDesc.java:
java/ProcAddr.java:
java/PseudoTypeInfo.java:
java/Sectag_Locn.java:
java/TypeCtorInfo_Struct.java
java/TypeCtorRep.java:
java/TypeFunctors.java:
java/TypeLayout.java:
New files. Java classes for implementing Mercury RTTI.
java/UnreachableDefault.java:
New file. Runtime exception that signals that unreachable
default case in a switch statement has been reached.
runtime/mercury_type_info.h:
Update comments to mention that Java runtime classes will
need to be altered if structures in this file are.