My commit afe2887882 broke the ability
to run the test suite outside of a bootcheck by executing "mmake runtests"
in the tests directory. This diff fixes that.
tests/Mmake.common:
Don't define "TESTS_DIR = ..". While every single tests/*/Mmakefile
defined it as such, I overlooked the fact that tests/Mmakefile itself
defined it ".", referring to the same directory from a different starting
point. Document this easily-overlooked fact.
Rename the old runtests target, which after afe2887 runs the tests
in a single directory, as runtests_dir, to leave the target name
"runtests" itself free for tests/Mmakefile to use.
tests/Mmakefile:
Define "TESTS_DIR = .", and add a target "runtests" which invokes
"mmake runtests_dir" in each test directory.
tools/bootcheck:
Invoke "mmake runtests_dir" instead of "mmake runtests" in each
test directory.
Initialize a variable just before it is used.
tests/*/Mmakefile:
Add back the definition "TESTS_DIR = .."
A long time ago, test directories such as hard_coded had subdirectories
such as hard_coded/typeclasses. These have since been flattened out
(e.g. hard_coded/typeclasses is now just typeclasses), but there were
still remnants of the old approach. This diff deletes those remnants.
tests/*/Mmakefile:
Delete the TESTS_DIR and the SUBDIRS mmake variables; TESTS_DIR
was always set to "..", and SUBDIRS to the empty string.
Delete any references to the make variable NOT_WORKING, since
it is never used.
tests/Mmake.common:
Document that Mmakefiles in test directories don't have to set
TESTS_DIR and SUBDIRS anymore. Fix the formatting of the documentation
of the make variables they do still have to set.
Delete the targets and actions for handling subdirectories of
test directories, since there aren't any.
tests/Mmakefile:
Simplify some code.
tests/Mmake.common:
Don't invoke any actions in the clean_local and realclean_local
targets, since if using mmc --make, the builtin mmake rules
have actions for those targets as well, and make can't handle
more than one action for a target having actions. Replace those
actions with dependencies on other, unique targets that have
the actions instead.
tests/*/Mmakefile:
Avoid actions in clean_local and realclean_local targets the same way.
Sort the test names in some directories that didn't already do so.
Delete some obsolete comments.
Fix style.
tests/valid/Mmake.valid.common:
As for the Mmakefiles above, and also move the definition of a make
variable before it is needed.
The parts of the compiler that run before the HLDS is constructed used to use
a raw list of items to represent source files (.m), interface files (.int0,
.int3, .int2 and .int) and optimization files (.opt, and .trans_opt).
These lists had structure, but this structure was implicit, not explicit,
and its invariants were never really documented.
This diff changes that. It replaces the item list with FIVE separate types.
Three of these each represent the unprocessed content of one file:
- parse_tree_int represents the contents of one interface file;
- parse_tree_opt represents the contents of one optimization file;
- parse_tree_src represents the contents of one source file.
Two of these each represent the processed contents of one or more files:
- raw_compilation_unit represents the contents of one module in a source file.
(The source file may contain several nested modules; the compilation unit
represents just one.)
- aug_compilation_unit represents the contents of one module in a source file,
just like raw_compilation_unit, but it is augmented with the contents of the
interface and optimization files of the other modules imported (directly or
indirectly) by the original module.
These five separate concepts all used to be represented by the same type,
list(item), but different invariants applied to the structure of those lists.
The most important of those invariants at least are now explicit in the types.
I think it is entirely possible that there are other invariants I haven't
discovered and documented (for example, .int3 files must have stricter
invariants on what can appear in them than .int files), but discovering
and documenting these should be MUCH easier after this change.
I have marked many further opportunities for improvements with "XXX ITEM_LIST".
Some of these include moving code between modules, and the creation of new
modules. However, I have left acting on those XXXs until later, in order to
keep the size of this diff down as much as possible, for easier reviewing.
compiler/prog_item.m:
Define the five new AST types described above, and utility predicates
that operate on them.
In the rest of this change, I tried, as much as possible, to change
predicates that used to take item lists as arguments to make them change
one of these types instead. In many cases, this required putting
the argument lists of those predicates into a more consistent order.
(Often, predicates that operated on the contents of the module
took the name of the module and the list of items in the module
not just as separate arguments, but as separate arguments that
weren't even next to each other.)
Define types that identify the different kinds of interface and
optimization files (.int, .int2 etc). These replace the string suffixes
we used to use to identify file types. Predicates that used to take strings
representing suffixes as arguments now have to specify whether they can
handle all these file types (source, interface and optimization),
or just (e.g.) all interface file types.
We used to have items corresponding to `:- module' and `:- end_module'.
Delete these; this information is now implicit in the structure of the
relevant AST. The parser handles the corresponding terms as markers,
not items; these markers are live only during parsing.
We used to have module_defns corresponding to `:- interface' and
`:- implementation'. Delete these; this information is now also implicit
in the structure of the relevant AST. Delete also, for the same reason,
the module_defns used to mark the starts of sublists in the overall lists
of items whose items came from the interface files or optimization files
of other modules. The former are now markers during parsing. The latter
are never parsed, but are created directly, after parsing has been done.
Delete the pragma type for `:- pragma source_file'. This is never
needed later; it is now a marker during parsing.
Change the internal representation of `:- import' and `:- use'.
It used to store a list of module names, but that list was an actual list
only during parsing; after that, it always had exactly one element.
It now stores one module name, and the parser has a mechanism to convert
one read-in term to more than one item, for use with terms such as
`:- import_module a, b'.
Delete the internal representation of `:- export', which was never
implemented, since if it IS ever implemented, it will almost certainly
be in a different form, which will need different support.
Document some further opportunities for simplification, later.
(This diff is already more than big enough.)
compiler/prog_io_item.m:
Rewrite the top-level part of this module. Instead of returning an item
for every parsed term, distinguish between parsing items that end up
in item lists inside ASTs, and parsing markers that end up creating
the STRUCTURE of those ASTs.
compiler/prog_io.m:
Rewrite the meat of this module. Instead of reading in a simple item list,
we now have to read in three different parse trees with three different
grammars, each of which is more complex than a simple list.
compiler/read_modules.m:
We used to have a map that mapped file names to the contents of those
files. We now need three separate maps, for interface files, optimization
files and source files, due to their separate types.
(We don't actually use the map for optimization files, which seems
to be a potential performance bug. The root cause of that problem
us that while intermod.m and the grab_*modules part of modules.m do
similar jobs, they don't use the same mechanisms.)
Replace the read_module predicate with the predicates read_module_src
and read_module_int, since these now return different types.
To avoid having to create AST-type-specialized variants of
read_module_ignore_errors and read_module_if_changed, give each of
read_module_{src,int} arguments that optionally tell them to ignore errors
and/or to read the module only if changed (though the "and" part of
"and/or" should not be needed.) These options already existed, but
they weren't exported.
compiler/timestamp.m:
Define the type we use for this option in read_modules.
compiler/status.m:
New module, containing mostly
- stuff carved out of hlds_pred.m, which defines the import_status type,
and the predicates that operate on it;
- stuff carved out of make_hlds_passes.m, which defines the item_status
type and the predicates that operate on that; and
- stuff carved out prog_data.m, which defines the section (now
module_section) and import_locn types.
It also contains the new section kinds we now use to represent item blocks
that were imported from interface and optimization files.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Add status.m to the parse_tree package.
compiler/hlds_pred.m:
compiler/prog_data.m:
Remove the stuff now in status.m.
compiler/error_util.m:
Provide a mechanism to control the order of messages with respect to
ALL other messages, not just those that also specify ordering.
compiler/mercury_to_mercury.m:
Provide predicates for printing out parse_tree_* and *_compilation_unit,
since printing out a simple item list is no longer enough for debugging.
Pretty-print type definitions nicely.
Replace a boolean with a purpose-specific enum.
compiler/modules.m:
Rewrite virtually all this module to make it work on the new AST
representations. Generate more detailed error messages for duplicate
module inclusions. Note lots of possibilities for further improvements,
including in the documentation. Mark places I am still not sure about,
especially places where I am not sure *why* the code is doing
what it is doing.
compiler/module_imports.m:
This module stores the data structure in which we accumulate the stuff
imported into a compilation unit, i.e. it is in these data structures
that a raw_compilation_unit becomes an aug_compilation_unit. Modify
the data structure and the predicates that operate on it to work on the
new AST representations, not on an (apparently) simple list of items.
Avoid ambiguities by adding a prefix to field names.
Add some convenience predicates.
compiler/module_qual.m:
Perform module qualification on both raw lists of items (for use when
generating .int3 files) but also on item blocks (for use pretty much
in every other situation).
Generate warnings about module imports that are unnecessarily in the
module interface using the module's context (the context of the `:- module'
declaration), not line 1 of the relevant file.
compiler/prog_io_error.m:
Split some error categories more finely, since some error kinds here
actually used to be reported for more than one distinct situation.
compiler/prog_io_util.m:
Provide utility predicates that operate on nonempty lists.
compiler/recompilation.version.m:
Make the comparison of the old and new contents of the interface file
work on two parse_tree_ints, not on two raw sequences of items.
Delete a boolean option that was always `yes', never 'no'.
compiler/recompilation.m:
Turn some functions into predicates to allow the use of state variable
notation.
Avoid ambiguities by adding a prefix to field names.
compiler/write_module_interface_files.m:
Besides updating the code in this module to work on the new parse tree
representations, also use cords instead of reversed lists in several cases.
Note many possibilities for further improvements.
library/list.m:
Move the type one_or_more here from the compiler directory, since
we now use it in more than one compiler module, and this is its natural
home.
mdbcomp/sym_name.m:
Rename "match_sym_name" to "partial_sym_name_matches_full", since this
better describes its job.
Add a det version of sym_name_get_module_name.
compiler/equiv_type.m:
Rename some types to make them more expressive.
compiler/accumulator.m:
compiler/add_class.m:
compiler/add_foreign_enum.m:
compiler/add_foreign_proc.m:
compiler/add_mode.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_pred.m:
compiler/add_solver.m:
compiler/add_special_pred.m:
compiler/add_type.m:
compiler/assertion.m:
compiler/base_typeclass_info.m:
compiler/check_typeclass.m:
compiler/ctgc.util.m:
compiler/dead_proc_elim.m:
compiler/dep_par_conj.m:
compiler/dependency_graph.m:
compiler/deps_map.m:
compiler/det_report.m:
compiler/elds_to_erlang.m:
compiler/equiv_type_hlds.m:
compiler/erl_code_gen.m:
compiler/export.m:
compiler/format_call.m:
compiler/higher_order.m:
compiler/hlds_data.m:
compiler/hlds_module.m:
compiler/hlds_out_pred.m:
compiler/inst_check.m:
compiler/intermod.m:
compiler/item_util.m:
compiler/lambda.m:
compiler/lco.m:
compiler/make.module_dep_file.m:
compiler/make_hlds.m:
compiler/make_hlds_error.m:
compiler/make_hlds_passes.m:
compiler/make_tags.m:
compiler/mercury_compile.m:
compiler/ml_proc_gen.m:
compiler/ml_type_gen.m:
compiler/mode_errors.m:
compiler/oisu_check.m:
compiler/par_loop_control.m:
compiler/polymorphism.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/pred_table.m:
compiler/prog_io_dcg.m:
compiler/prog_io_find.m:
compiler/prog_io_pragma.m:
compiler/prog_io_sym_name.m:
compiler/prog_io_type_defn.m:
compiler/prog_io_typeclass.m:
compiler/prop_mode_constraints.m:
compiler/push_goals_together.m:
compiler/qual_info.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/simplify_proc.m:
compiler/smm_common.m:
compiler/special_pred.m:
compiler/ssdebug.m:
compiler/stm_expand.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.direct.m:
compiler/structure_reuse.indirect.m:
compiler/structure_reuse.versions.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
compiler/table_gen.m:
compiler/term_constr_initial.m:
compiler/term_constr_main.m:
compiler/termination.m:
compiler/trace_params.m:
compiler/trans_opt.m:
compiler/type_class_info.m:
compiler/type_ctor_info.m:
compiler/typecheck.m:
compiler/typecheck_errors.m:
compiler/typecheck_info.m:
compiler/unify_proc.m:
compiler/untupling.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/write_deps_file.m:
compiler/xml_documentation.m:
Conform to the changes above.
tests/hard_coded/higher_order_func_test.m:
tests/hard_coded/higher_order_syntax.m:
Avoid a warning about importing a module in the interface, not the
implementation.
tests/invalid/after_end_module.err_exp:
tests/invalid/any_mode.err_exp:
tests/invalid/bad_end_module.err_exp:
tests/invalid/bigtest.err_exp:
tests/invalid/bug113.err_exp:
tests/invalid/duplicate_modes.err_exp:
tests/invalid/errors.err_exp:
tests/invalid/errors1.err_exp:
tests/invalid/errors2.err_exp:
tests/invalid/funcs_as_preds.err_exp:
tests/invalid/inst_list_dup.err_exp:
tests/invalid/invalid_main.err_exp:
tests/invalid/missing_interface_import2.err_exp:
tests/invalid/no_exports.err_exp:
tests/invalid/occurs.err_exp:
tests/invalid/predmode.err_exp:
tests/invalid/prog_io_erroneous.err_exp:
tests/invalid/type_inf_loop.err_exp:
tests/invalid/typeclass_missing_det_3.err_exp:
tests/invalid/typeclass_test_11.err_exp:
tests/invalid/types.err_exp:
tests/invalid/undef_inst.err_exp:
tests/invalid/undef_mode.err_exp:
tests/invalid/undef_type.err_exp:
tests/invalid/unicode1.err_exp:
tests/invalid/unicode2.err_exp:
tests/invalid/vars_in_wrong_places.err_exp:
tests/warnings/unused_import.exp:
tests/warnings/unused_interface_import.exp:
Update the expected outputs in the invalid and warnings directories
to account for one or more of the following five changes.
Error messages that warn about a module not exporting anything
used to always refer to line 1 of the module's source file.
Now expect these messages to refer to the actual context of the module,
which is the context of its `:- module' declaration.
Expect a similarly updated context for messages that warn about
unnecessarily importing modules in the interface, not in the
implementation.
Expect a similarly updated context for messages that warn about
importing a module via both `:- import_module' and `:- use_module'.
For the modules that follow the `:- module' declaration directly with code,
also expect an error message about the missing section marker.
For modules that have terms after the `:- end_module' declaration,
replace "end_module" with "`:- end_module'" in the error message.
tests/invalid/func_class.{m,err_exp}:
New test case. It is a copy of the old tests/valid/func_class.m, which
is missing more than one module marker. The expected output is what I think
we should generate. The test case currently fails, because we currently
print only a subset of the expected errors. I am pretty sure the reason
for that is that old code I have not modified simply throws away the
missing error messages. Fixing this is work for the near future.
tests/invalid/Mmakefile:
Enable the new test case.
tests/misc_tests/pretty_print_test.exp:
Expect the pretty-printed output to use four-space indentation,
per our current style guide, since the compiler now generates such output.
tests/misc_tests/pretty_print_test.m:
Clean up the source code of the test as well.
tests/valid/complicated_unify.m:
tests/valid/det_switch.m:
tests/valid/easy_nondet_test.m:
tests/valid/error.m:
tests/valid/func_class.m:
tests/valid/func_int_bug_main.m:
tests/valid/higher_order.m:
tests/valid/higher_order2.m:
tests/valid/implied_mode.m:
tests/valid/indexing.m:
tests/valid/multidet_test.m:
tests/valid/nasty_func_test.m:
tests/valid/semidet_disj.m:
tests/valid/stack_alloc.m:
tests/valid/switches.m:
Add missing section markers to these modules. They used to follow
the `:- module' declaration directly with code.
tests/Mmake.common:
Replace the -j1 in the runtests_local target used by all the test
directories with $(MAYBE_J1).
tests/*/Mmakefile:
Define MAYBE_J1 it as the empty string in test directories in which
different tests don't share source files.
Define MAYBE_J1 as -j1 in test directories in which
different tests do share source files.
tests/submodules/sub2_a.m:
Add this copy of sub_a.m to allow tests in the submodules directory
to be done in parallel.
tests/submodules/accessibility2.m:
Import sub2_a.m instead of sub_a.m.
tests/warnings/ambig_types_high_level.m:
Add this copy of ambig_types.m to allow tests in the warnings directory
to be done in parallel.
tests/warnings/ambig_high_level.m:
Import ambig_types_high_level.m instead of ambig_types.m.
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
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 tests
that check compiler error messages, expect the new line numbers.
browser/cterm.m:
browser/tree234_cc.m:
Import only one module per line.
tests/hard_coded/boyer.m:
Fix something I missed.
This file-specific setting will override a default setting of expandtabs
in $HOME/.vimrc.
*/Makefile:
*/Mmakefile:
As above.
tests/hard_coded/.gitignore:
Don't ignore the purity subdir. This ignore must have been left over
from when purity.m was a test in hard_coded, not hard_coded/purity,
and it ignored an executable, not a directory.
Branches: main, 11.07
Make the none.gc.memprof grade work with MSVC again.
Avoid more warnings when compiling with MSVC.
compiler/layout_out.m:
Avoid an incomplete type in the declaration of the alloc_sites
array. (Similar changes need to be made for the layout structures
related to debugging and deep profiling - I am in the process of
testing the former, the latter doesn't currently work on Windows
any way.)
browser/listing.m:
Use don't-care variables in some foreign_procs.
This avoids warnings about assignments from uninitialized
variables with MSVC.
*/.cvsignore:
Update cvsignore entries.
Ignore files generated by mprof.
Branches: main
compiler/mercury_to_mercury.m:
Don't write an outer pair of brackets when formatting terms with '.'
or ':' as the functor, which made module-qualified types in error
messages unnecessarily ugly.
tests/hard_coded/impl_def_literal.exp:
tests/invalid/actual_expected.err_exp:
tests/invalid/bad_instance.err_exp:
tests/invalid/errors2.err_exp:
tests/invalid/ext_type.err_exp:
tests/invalid/ext_type_bug.err_exp:
tests/invalid/funcs_as_preds.err_exp:
tests/invalid/illtyped_compare.err_exp:
tests/invalid/instance_dup_var.err_exp:
tests/invalid/invalid_instance_declarations.err_exp:
tests/invalid/method_impl.err_exp:
tests/invalid/mixed_up_streams.err_exp:
tests/invalid/mpj4.err_exp:
tests/invalid/nullary_ho_func_error.err_exp:
tests/invalid/overloading.err_exp:
tests/invalid/purity/impure_func_t5.err_exp:
tests/invalid/purity/impure_pred_t1.err_exp:
tests/invalid/purity/impure_pred_t1_fixed.err_exp:
tests/invalid/purity/impure_pred_t2.err_exp:
tests/invalid/record_syntax_errors.err_exp:
tests/invalid/tc_err1.err_exp:
tests/invalid/tc_err2.err_exp:
tests/invalid/try_bad_params.err_exp:
tests/invalid/type_error_ambiguous.err_exp:
tests/misc_tests/pretty_print_test.exp:
tests/warnings/inference_test.exp:
Update test cases.
Estimated hours taken: 0.2
Branches: main
tests/*/.cvsignore:
tests/*/.nocopyright:
Update or add these files. In particular, CVS should ingore
.mgnuc* files.
Estimated hours taken: 30
Branches: main
Change the representation of types in the compiler.
We also add some support for handling kinds, which will be used later when we
have a kind system. There are a number of places where kinds are not yet
handled correctly -- we assume that all kinds will be `star'. Each of these
locations is flagged with a comment that contains "XXX kind inference:".
compiler/prog_data.m:
Implement the new version of type (type).
Change the definition of type_param to be a variable instead of a
term, since all parameters must be variables anyway.
Implement versions of varset.merge_* which work with tvarsets and
produce renamings instead of substitutions. Renamings are more
convenient than substitutions because we don't need to know the
kinds of type variables in order to build the renaming, and in any
case the substitutions shouldn't have anything other than variables
in the range so renamings will be more efficient and safe.
Define the type of kinds, and provide a couple of utility predicates
to operate on them.
compiler/prog_io.m:
Parse type definition heads as a sym_name and list of type_params,
rather than a functor. Handle this change in other predicates.
Allow parse errors to be returned by get_with_type/3, and handle
these errors.
Remove parse_type/2. This predicate didn't do any processing, it
just forwarded handling to convert_type/2.
compiler/prog_io_typeclass.m:
Change type_is_functor_and_vars to handle the new representation
of types. In doing so, we retain the old behaviour that pure
predicates pass this test, but no other pred or func types. This
behaviour is arguably incorrect, but there is little point changing
the behaviour at the moment. Instead we should remove these kind of
restrictions entirely, but that should be done later.
compiler/prog_io_util.m:
Provide predicates to both parse and unparse types. We need to
unparse types before printing them out, since we do a lot of special
case handling when printing out terms and we don't want to duplicate
this functionality for types.
compiler/module_qual.m:
Remove report_invalid_type. We now report ill-formed types during
parsing.
compiler/superhomogeneous.m:
Handle errors from the parsing of type expressions.
compiler/prog_out.m:
Provide a predicate to convert builtin_types to their string names,
and vice-versa.
compiler/prog_type.m:
Add a bunch of simple tests to use on types which may have kind
annotations present. In such cases, types do not have a canonical
representation so the simple handling of these tests is not what we
want. (Note that these are only required in early phases. The kind
annotations -- when they are implemented -- will be removed before
type checking.)
Consistently handle the application of renamings, substitutions and
recursive substitutions to various data structures.
compiler/mercury_to_mercury.m:
Implement mercury_output_type, mercury_format_type and
mercury_type_to_string. These convert the type to a term before
formatting -- the reason for this is so that appropriate parentheses
are used when formatting operators. This results in some slight
changes to error messages, which are reflected in changes to the
expected output files in the tests.
Remove the old version of mercury_type_to_string.
Change the argument ordering of mercury_format_var to be consistent
with mercury_format_type. (Other predicates in this module should
probably be changed in a similar way, since this argument ordering
is more amenable to higher-order programming. But that can be left
for another change.)
compiler/type_util.m:
Implement type unification. The behaviour is much the same as the
previous behaviour, except that we now handle apply/N types properly,
and we also allow for kind annotations.
Implement an occurs check for types.
Remove the example definition of replace_eqv_type. It isn't used and
would no longer work anyway even if it would have worked before.
Add a tvar_kind_map field to ctor_defn.
The functions type_info_type and type_ctor_info_type now return
types with `void' as their argument, rather than the type that the
type_info or type_ctor_info was for.
Remove type_util.real_vars/2, since it no longer does anything
different from prog_type.vars/2.
Remove the commented out implementation of type_to_ctor_and_args/3.
Its implementation is in prog_type.m, and has changed significantly
in any case.
compiler/add_clause.m:
Move parse_purity_annotation/3 to prog_io_util.m.
compiler/check_typeclass.m:
Remove apply_substitution_to_var_list/3, since we now have predicates
in prog_type.m to handle such things.
compiler/continuation_info.m:
compiler/trace.m:
Use prog_type.vars/2 instead of type_util.real_vars/2. The two
predicates have the same meaning now since type_infos don't contain
any type variables.
compiler/hlds_data.m:
Add tvar_kind_map fields to hlds_type_defn and hlds_class_defn.
compiler/hlds_pred.m:
Add a tvar_kind_map field to pred_info.
compiler/polymorphism.m:
Add a tvar_kind_map field to poly_info.
Remove unify_corresponding_types, which is no longer used.
compiler/hlds_out.m:
Use mercury_output_type/5 instead of term_io__write_term/4 and
mercury_output_term/5.
compiler/post_typecheck.m:
Build the void substitution directly rather than building intermediate
lists.
compiler/recompilation.version.m:
Use term__list_subsumes instead of type_list_subsumes, which now
operates only on types. This follows up on what was suggested in
an XXX comment.
compiler/typecheck_errors.m:
Use unparse_type/2 to format error messages.
compiler/typecheck_info.m:
Don't export write_type_with_bindings/5. It is no longer used
outside of this module.
compiler/*.m:
Conform to the above changes.
library/rtti_implementation.m:
Fix a syntax error that went undetected in our previous
implementation, and amazingly enough was compiled correctly anyway.
library/term.m:
Move the versions of term__unify, term__unify_list and
term__list_subsumes that were implemented specifically for types
to here. The version of term_unify that takes a list of bound
variables (i.e., variables that should not be bound any further)
is used by the subsumption check, which in turn is used by
recompilation.version.m.
tests/invalid/kind.err_exp:
tests/invalid/tc_err1.err_exp:
tests/invalid/tc_err2.err_exp:
tests/misc_tests/pretty_print_test.exp:
Update the expected output of these tests to match what we now do.
Estimated hours taken: 0.25
Branches: main
tests/misc_tests/pretty_print_test.exp:
Updated to reflect recent change to mercury_to_mercury.m
to print a space after data constructors with no args.
Estimated hours taken: 3
Branches: main
Bugfixes (mostly) related to the recent solver types changes.
compiler/type_util.m:
Having the compiler assume that type variables denote solver types
causes the compiler to throw an exception when it tries to compile the
initialisation forwarding predicate for exported abstract type foo(T)
defined as foo(T) == T.
The right solution at some point is to introduce a solver type class.
type_util__is_solver_type no longer assumes that type variables
denote solver types.
compiler/prog_io.m:
Fixed a bug in make_maybe_where_details where a solver type without
user defined equality or comparison would get a
`yes(unify_compare(no, no))' result rather than just `no'.
tests/invalid/partial_implied_mode.err_exp2:
Copy of partial_implied_mode.err_exp, but with different temporary
variable names in the expected compiler errors.
tests/invalid/any_mode.m:
tests/invalid/any_mode.err_exp:
tests/invalid/any_should_not_match_bound.m:
tests/invalid/any_should_not_match_bound.err_exp:
Updated code and expected error.
tests/misc_tests/pretty_print_test.exp:
Corrected expected error.
Estimated hours taken: 14
Branches: main
Change the compiler and tools so that `.' and not `:' is now used as the
module separator in all output.
Infix `.' now has associativity yfx and priority 10.
NEWS:
Report the change.
configure.in:
Amend the test for an up-to-date Mercury compiler to check whether
it recognises `.' as a module qualifier.
compiler/code_gen.m:
compiler/error_util.m:
compiler/hlds_out.m:
compiler/prog_out.m:
compiler/prog_util.m:
compiler/rl_exprn.m:
compiler/rl_gen.m:
compiler/source_file_map.m:
compiler/unused_args.m:
library/io.m:
library/rtti_implementation.m:
library/type_desc.m:
runtime/mercury_debug.c:
runtime/mercury_deconstruct.c:
runtime/mercury_stack_trace.c:
Change `:' to `.' as module separator for output.
compiler/mercury_to_mercury.m:
compiler/prog_io_typeclass.m:
As above.
Fixed a bug where `.' was not being recognised as a module separator.
doc/reference_manual.texi:
Report the change.
library/term_io.m:
Ensure that infix `.' is written without surrounding spaces.
tests/hard_coded/dot_separator.m:
tests/hard_coded/dot_separator.exp:
tests/hard_coded/Mmakefile:
Test case added.
Estimated hours taken: 0.1
Branches: main
tests/misc_tests/Mmakefile:
Use an MDEMANGLE variable, rather than hard-coding `mdemangle'.
This makes it easier to run the tests using profiler/demangle_test
rather than util/mdemangle.
Estimated hours taken: 16
Branches: main
util/mdemangle.c:
profiler/demangle.m:
Add support for demangling code produced by the MLDS back-end.
XXX util/mdemangle.c it doesn't handle internal labels yet
tests/misc_tests/Mmakefile:
tests/misc_tests/mdemangle_test_hl.inp:
tests/misc_tests/mdemangle_test_hl.exp:
Add a test case.
The test is not enabled, since we don't yet pass it;
demangling works OK for many cases, but fails
for cases involving internal labels.
Estimated hours taken: 30
Branches: main
Improve the test framework to make it easier to find out which tests
failed and to reduce disk usage (important in debug grades).
Allow the tests to be run with `mmc --make' (still some failures).
Allow the user to run only the failing tests from a previous
run by using `mmake ERROR_FILE=runtests.errs', where runtests.errs
is the log file from the previous run.
tests/Mmake.common:
tests/*/Mmakefile:
Move common code (such as the code to deal with subdirectories)
to Mmake.common.
Run the tests using `mmake runtests' rather than using slightly
different runtests scripts in each directory.
Add to the output from `mmake runtests' to make it easier to
identify which tests failed in which grades.
Move per-module options into Mercury.options files so they
can be read by `mmc --make'.
Remove the last of the NU-Prolog support.
Consistently use the main module name when listing tests.
Some directories (e.g. invalid) were using the source file
name.
tests/process_log.awk:
Collect the parts of the output relating to failing tests.
tests/generate_exp:
tests/handle_options:
tests/subdir_runtests:
tests/startup:
tests/shutdown:
tests/*/runtests:
tests/recompilation/TESTS:
Removed.
tests/recompilation/test_functions:
Make sure the old result file is removed before starting
each test.
Put the mmake output for tests which are supposed to fail
into a different file for each test.
tests/warnings/Mmakefile:
Use %.c rather than $(cs_subdir)%.c in a rule.
The $(cs_subdir) part doesn't work with `mmc --make',
and isn't necessary any more (modules.m generates a rule
`module.c: $(cs_subdir)module.c').
tests/README:
Updated.
tools/bootcheck:
tools/test_mercury:
Use `mmake runtests' instead of the `runtests' script.
Add a `-f' (`--failing-tests') option to bootcheck which
runs only the failing tests from the last run.
tools/test_mercury:
tools/run_all_tests_from_cron:
Use the new framework to summarize test failures.
Estimated hours taken: 1
Reduce the size of the generated interface files by not printing
unnecessary module qualifiers. This change reduces the total size
of {compiler,library}/{*.int,*.int2,*.int3} (with smart recompilation)
by about 10%.
compiler/mercury_to_mercury.m:
Don't qualify declarations where the qualifier is implied
by a previous `:- module' declaration.
Never output module qualifiers on constructors or class methods.
The qualifier is implied by the qualifier on the type or typeclass
declaration.
Put the `.' at the end of a discriminated union definition
on a separate line. This avoids problems with types like
`:- type t --> += .'.
tests/misc_tests/pretty_print_test.exp:
Update expected output.
Estimated hours taken: 25
Branches: main
Improvements for higher-order specialization.
WARNING: This changes the order and number of extra arguments
added to specialized versions, including the type-specialized
procedures in the library. Recompile everything.
compiler/higher_order.m:
Improve the termination check on specialization of recursive
calls to allow parser combinator programs such as extras/xml
to be specialized fully. The old check just stopped on any
recursive specialization.
Construct constant higher-order and type-info arguments in the goal
for the specialized version, and remove them from the argument list.
This increases the chance that terms in the specialized version
which contain the constant terms will also be constant.
Attempt to match specialized versions occurring in higher-order
predicate constants.
Use record syntax throughout the code.
Add a version number to the names for type specialized versions
so that instead of segmentation faults or other program errors
users get link errors when the argument convention for specialized
versions changes.
compiler/options.m:
Add an option `--higher-order-arg-limit' (default 10)
to control the size of the higher-order arguments for
which specialization is allowed. Without this,
extras/xml/xml.parse.chars.m takes too much time
and memory to compile.
doc/user_guide.texi:
Document the new option.
tests/hard_coded/Mmakefile:
tests/hard_coded/type_spec_ho_term.m:
tests/hard_coded/type_spec_ho_term.exp:
Test case.
profiler/demangle.m:
util/mdemangle.c:
tests/misc_tests/mdemangle_test.{inp,exp}:
Update the documentation and test cases for the symbols
produced by type specialization.
Estimated hours taken: 2
Branches: main
profiler/demangle.m:
util/mdemangle.c:
Fix a bug that broke profiling at `-O5':
include the __ho<n> sequence number or the __ua<n> mode number
when demangling procedures created by higher-order specialization
or unused argument elimination (respectively).
This avoids a problem where we were demangling distinct symbols
onto the same mangled name.
tests/misc_tests/mdemangle_test.inp:
tests/misc_tests/mdemangle_test.exp:
Update to reflect the new demangling algorithm.
Estimated hours taken: 0.5
Add support to the test suite for testing the GCC back-end
(`--target asm') version of the compiler.
tests/handle_options:
Add a `-t <target>' / `--target <target>' option.
If this is set, include `--target <target>' in $mmakeopts,
so that it gets passed to mmake.
tests/*/runtests:
tests/*/*/runtests:
Put `-k' after $mmakeopts, since `-k' is a `make' option,
not an `mmake' option, and `mmake' options (in particular
`--target') must precede all make options.
Estimated hours taken: 2
Implement demangling of predicate names introduced by type
specialization. This still doesn't work when the compiler adds
multiple prefixes to a predicate name.
profiler/demangle.m:
util/mdemangle.c:
When demangling of a compiler-generated predicate name fails, just
treat the predicate as an ordinary predicate. This is a temporary
work-around for the problem of demangling names with multiple
compiler-generated prefixes.
Change the printing of names in the profiler to match those generated
by the compiler (module:'p'/3 becomse `module:p/3').
tests/misc_tests/mdemangle_test.inp:
tests/misc_tests/mdemangle_test.exp:
Test case.
Estimated hours taken: 1
tools/bootcheck:
If the new --test-params option is given, copy the stage 2 Mmake.params
file to the tests directory. This capability is required to test
changes such as compiling the library without special preds and
the test cases with special preds. You get a lot of spurious errors
if a test case assumes that since it was compiled with special
preds, all other modules it is linked with are also compiled with
special preds, and thus makes calls to non-existent special preds
for the types defined in the library.
tests/*/Mmakefile:
tests/*/*/Mmakefile:
Include Mmake.params from the top level tests directory if it exists.
Estimated hours taken: 1
Add support for setting MLFLAGS to tests/runtests.
This is needed if you want to run the tests with
static linking when the default is shared linking,
or vice versa.
tests/handle_options:
Add a new option for setting MLFLAGS.
Define variables `mmakeopts' and `runtestopts' containing all the
options needed for running mmake and runtests (respectively).
tests/subdir_runtests:
Use $runtestopts rather than $jfactor $cflag $gflag $fflag.
tests/runtests:
tests/*/runtests:
tests/*/*/runtests:
Use $mmakeopts rather than $jfactor $gradeopt $flagsopt $cflagsopt.
tests/hard_coded/exceptions/runtests:
New file. This directory was missing a `runtests' script.
Estimated hours taken: 0.5
Fix bugs that were stopping *.res and *.out files being cleaned up properly.
tests/Mmake.common:
tests/general/accumulator/Mmakefile:
tests/invalid/Mmakefile:
tests/misc_tests/Mmakefile:
tests/tabling/Mmakefile:
tests/term/Mmakefile:
tests/valid/Mmakefile:
tests/warnings/Mmakefile:
Make cleaning tasks depend on (real)clean_local rather than
(real)clean. This is because tests/startup and tests/shutdown
use the *_local targets.
tests/general/Mmakefile:
Fix bugs in the recursive mmake calls.
Estimated hours taken: 0.2
tests/misc_tests/Mmakefile:
Explicitly specify --no-line-numbers for the pretty_print_test,
since my recent change made --line-numbers the default.
Estimated hours taken: 0.25
tests/debugger/.cvsignore:
tests/tabling/.cvsignore:
tests/misc_tests/.cvsignore:
tests/warnings/.cvsignore:
Tell cvs to ignore the `CLEAN' files produced by the
tests/{startup,shutdown} scripts.
Estimated hours taken: 0.2
tests/misc_tests/mdemangle_test.inp:
tests/misc_tests/mdemangle_test.exp:
Update the demangler test case to use type_ctor_* rather than
base_type_*.
Estimated hours taken: 6
compiler/mercury_to_mercury.m:
compiler/mode_errors.m:
Make the code a little bit more readable:
use specific types rather than `bool' in a few places.
compiler/mercury_to_mercury.m:
Fix bugs in the generation of interface files where it was
outputting certain graphic tokens incorrectly. In particular,
it was outputting things like `module:?' without any parentheses,
space, or quotes to separate the `:' as module qualifier from
the symbol name.
tests/hard_coded/Mmakefile:
tests/hard_coded/quoting_bug.m:
tests/hard_coded/quoting_bug_test.m:
tests/hard_coded/quoting_bug_test.exp:
Add some tests for the above-mentioned bug fix.
tests/term/*.trans_opt_exp:
tests/misc_tests/pretty_print_test.exp:
Update expected output for these tests to reflect the
above changes.
Estimated hours taken: 0.5
Avoid about half of the slow "mmake realclean"s required by a bootcheck.
tests/*/runtests:
Concentrate all the actions performed before the test and after
a successful tests (both of which involve an "mmake realclean")
into two scripts, tests/{startup,shutdown}.
tests/shutdown:
Clean up the directory, and touch the file CLEAN.
tests/startup:
If the file CLEAN exists and is the most recent file in the directory,
consider the directory clean to beging with. Otherwise, run mmake
realclean.
Estimated hours taken: 0.5
tests/misc_tests/Mmakefile:
tests/misc_tests/pretty_print_test.exp:
Update the expected output for the pretty_print_test
test case to reflect the actual output, and re-enable
that test case. Arguably the extra parentheses in
the output are undesirable, but they're needed to
protect against the parser getting confused by
the relative precedence of `:' and `/' for
module-qualified symbols (e.g. in `.int' files).
Also arguably the precedence of `:' is wrong,
but it's probably not worth fixing this now since
we plan to replace `:' with `.'.
Also change the rule for `clean_ugly' to avoid hard-coding
the path name `/bin/rm' and to instead use just `rm'.
In some environments (e.g. Windows with gnu-win32),
`rm' might not be in `/bin'.
Estimated hours taken: 2
Mmakefile:
Remove .ugly files as part of the clean rule. Without this,
the .ugly file does not get remade, and the test is useless
(it does not invoke the compiler at all).
Temporarily disable the test (pretty_print_test) that uses a
.ugly file, since it does not work.
Estimated hours taken: 400
Deforestation.
This increases the code size of the compiler by ~80k when compiling
with --intermodule-optimization --deforestation.
The improvement from deforestation is not measurable for mmc -C make_hlds.m.
Compile time for make_hlds.m increased from 50.7 seconds to 52.2 seconds
when running deforestation.
compiler/simplify.m
compiler/common.m
Provide a nicer interface for simplifying a goal,
not an entire procedure.
Rework the interface to avoid manipulating lots of booleans.
Return an estimate of the improvement in cost from simplification.
Remove failing cases and disjuncts.
Add an option to optimize common structures even across calls.
Remove code to merge branched goals, since that is now
done by deforestation.
Fix a bug: the code to collect instmap_deltas for cases was not
including the switched-on variable in the instmap_delta,
which caused an abort in merge_instmap_delta if the switched
on variable was further instantiated in the switch.
This came up while compiling the compiler with --deforestation.
compiler/det_report.
Output duplicate call warnings even if --warn-simple-code is not set.
XXX fix the same problem with `:- pragma obsolete'.
compiler/code_aux.m
Update code_aux__cannot_loop to use termination information.
compiler/hlds_pred.m
compiler/dnf.m
Pass the type_info_varmap and typeclass_info_varmap
into hlds_pred__define_new_pred.
Restrict the variables of the new procedure onto the variables
of the goal.
Make sure all relevant type_infos are passed into the new
procedure if --typeinfo-liveness is set.
compiler/modes.m
compiler/unique_modes.m
compiler/mode_info.m
compiler/modecheck_unify.m
Put `how_to_check_goal' into the mode_info, rather
than passing it around.
Add a field to the `check_unique_modes' case which
controls whether unique modes is allowed to choose
a different procedure. For deforestation, this is
not allowed, since it could result in choosing a less
efficient procedure after generalisation.
compiler/options.m
New options:
--deforestation
--deforestation-depth-limit
Safety net for termination of the algorithm.
--deforestation-cost-factor
Fudge factor for working out whether deforestation
was worthwhile.
--deforestation-vars-threshold
Like --inline-vars-threshold.
Enable deforestation at -O3.
Removed an unnecessary mode for option_defaults_2, since it
resulted in a warning about disjuncts which cannot succeed.
compiler/handle_options.m
--no-reorder-conj implies --no-deforestation.
compiler/inlining.m
Separate code to rename goals into inlining__do_inline_call.
compiler/hlds_goal.m
Added predicates goal_list_nonlocals, goal_list_instmap_delta
and goal_list_determinism to approximate information about
conjunctions.
compiler/hlds_module.m
Added module_info_set_pred_proc_info to put an updated
pred_info and proc_info back into the module_info.
compiler/hlds_out.m
Exported hlds_out__write_instmap for debugging of deforestation.
Bracket module names on constructors where necessary.
compiler/mercury_compile.m
Call deforestation.
Use the new interface to simplify.m.
compiler/intermod.m
Put recursive predicates with a top-level branched goal
into `.opt' files.
goal_util.m
Added goal_calls_pred_id to work out if a predicate is
recursive before mode analysis.
Export goal_util__goals_goal_vars for use by deforestation.
Give a better message for a missing variable in a substitution.
compiler/instmap.m
Give a better message for inst_merge failing.
compiler/notes/compiler_design.m
Document the new modules.
library/varset.m
Add varset__select to project a varset's names and values
onto a set of variables.
doc/user_guide.texi
Document deforestation.
Remove a reference to a non-existent option, --no-specialize.
util/mdemangle.c
profiler/demangle.m
tests/misc_tests/mdemangle_test.{exp,inp}
Handle the `DeforestationIn__' predicate names introduced by
deforestation, similar to the `IntroducedFrom__' for lambda goals.
New files:
deforest.m Deforestation.
pd_cost.m Cost estimation.
pd_debug.m Debugging output.
pd_info.m State type and version control.
pd_term.m Termination checking.
pd_util.m Utility predicates
Estimated hours taken: 0.2
tests/runtests:
tests/*/runtests:
When reporting the results, print the options that controlled
the tests, so you don't have to search for them.
tests/*/runtests:
Clean up the directory if the tests are successful, in order
to reduce disk space usage.
Estimated hours taken: 0.1
tests/misc_tests/debugger_test.exp:
Update the expected debugger output to reflect my recent change
to library/io.m which changed the way io__write prints out values
of type `c_pointer'.
Estimated hours taken: 1.5
compiler/mercury_to_mercury.m:
Tidy up the output of typeclass and instance declarations.
Previously there were a number of minor problems (instance
declarations not implemented, unnecessary parentheses,
newlines in wrong places).
tests/misc_tests/Mmakefile:
tests/misc_tests/pretty_print_test.m:
tests/misc_tests/pretty_print_test.exp:
Add a test case for pretty-printing.
Estimated hours taken: 0.5
tests/misc_tests/Mmakefile:
Turn off tracing tests in `fast' and `jump' grades. The
stack_layouts they rely on don't yet work in these grades.
Estimated hours taken: 0.2
tests/misc_tests/debugger_test.exp:
Update the expected output after my recent change to the
formatting of the output of the tracer.
Estimated hours taken: 1.5
This change fixes a bug in the tracer's handling of the virtual registers
that are not real registers.
runtime/mercury_regs.h:
Make the saved_reg macro refer only to the given save area,
not to the machine registers or to the fake_reg array.
runtime/mercury_trace.c:
Make sure we save both real and fake registers in the save area.
Make the internal functions and variables static, and make sure
everything is prefixed by MR_. Use string concatenation in several
places to make the code shorter.
tests/misc_tests/debugger_regs.{m,inp,exp}:
A regression test case to make sure the tracer is handling high
register numbers properly.
Estimated hours taken: 20
Use stack layout tables to transmit information to the tracer, to allow
the tracer to print the names and values of variables at CALL and EXIT ports.
Extend stack layout tables to permit this.
For the time being the tables do not contain information about how to fill
in pseudo-typeinfos, so printing only works for monomorphic procedures.
compiler/llds.m:
Allow space for variable names in the information we gather about live
variables at given labels.
compiler/llds_out.m:
Print out variable names in the information we gather about live
variables at given labels in comments.
compiler/continuation_info.m:
Include variable names in the information we gather about live
variables at given labels.
Record the determinism of each procedure, not its code model.
compiler/{call_gen,code_gen,code_info}.m:
Include the names of variables in the data given to
continuation_info.m.
compiler/options.m:
Add a new developer-only option, --procid-stack-layout, whose effect
is to extend stack_layout structures with static info identifying the
procedure. This is used by execution tracing, and could (should) be
used by stack tracing and profiling.
Rename --alternate-liveness as --typeinfo-liveness. This is more
expressive. Later we should add a new option --trace-liveness, which
preserves every variable until the end of the clause for use by
the trace debugger.
compiler/handle_options.m:
Handle the option implications of --procid-stack-layout.
compiler/stack_layout.m:
Include the encoded determinism instead of the code model in stack
layout tables.
Include variable names in the live data section of stack layout tables
if they are available.
Include procedure identification information in the stack layout tables
if --procid-stack-layout is set.
compiler/trace.m:
Use the new interface to MR_trace.
compiler/*.m:
Trivial changes following from the renaming of --alternate-liveness.
runtime/mercury_accurate_gc.h:
Add macros to decode encoded determinisms.
Define structs for accessing the stack layout tables.
runtime/mercury_regs.h:
Define a macro similar to virtual_reg, except in that it can refer
to an arbitrary memory area, not just fake_reg.
runtime/{mercury_string,mercury_types}.h:
Move the typedefs of Char, UnsignedChar, String and ConstString
from mercury_string.h to mercury_types.h to avoid problems with
circular #includes.
runtime/mercury_trace.[ch]:
Revise the interface to MR_trace so that it takes the layout table
of the procedure as an argument. From the layout table, we can get
to the module name, predicate name, arity, mode number, and
determinism of the procedure, so we don't need to pass these any more,
reducing parameter passing overhead. We can also get to information
about where the input and output arguments are. We now use this
information to allow the user to print out the value of the arguments
at the CALL and EXIT ports.
Change the prompt to a less intrusive "mtrace> ".
runtime/mercury_wrapper.[ch]:
Add a new global variable, MR_library_trace_browser. We reserve space
for this variable in mercury_wrapper.c. It will be initialized by the
automatically generated xxx_init.c file to point to the procedure
that the tracer will invoke to let the user browse the values of
variables. This mechanism allows the runtime to maintain its current
ignorance about the contents of the standard library.
util/mkinit.c:
Generate additional code in the xxx_init.c files to fill in the value
of MR_library_trace_browser.
tests/misc_tests/debugger_test.{inp,exp}:
Add a few printing commands into the input for this test case, and
update the expected output.
Estimated hours taken: 0.1
tests/misc_tests/Mmakefile:
A small bug fix: add `./' at the start of the invocation of
debugger_test, so that it works even if you don't have `.'
in your PATH.
Estimated hours taken: 0.5
tests/misc_tests/Mmakefile:
tests/misc_tests/debugger_test.m:
tests/misc_tests/debugger_test.inp:
tests/misc_tests/debugger_test.exp:
Add a test case for the `--generate-trace' debugger.
Estimated hours taken: 1
Fix a bug that caused problems with profiling.
util/mdemangle.c:
profiler/demangle.m:
When demangling lambda goals, include the sequence number
and module name in the demangled name.
The profiler requires that the mapping between mangled
and demangled names must be one-to-one.
tests/misc_tests/mdemangle_test.inp:
tests/misc_tests/mdemangle_test.exp:
Update the tests to reflect the new demangling algorithm.