compiler/comp_unit_interface.m:
When we cannot generate a .int0/.int/.int2 file because of file access
issues, the reason is *usually* that we can't read a .int3 file.
However, it is also possible that the reason is that we can't read
a .int0 file, so include that possibility in the overall error message.
(The "can't read this file" message, with the specifics of the file
that couldn't be read, would have been printed earlier.)
tests/invalid_make_int/missing_parent_import.int_err_exp:
tests/invalid_make_int/sub_c.int_err_exp:
tests/invalid_make_int/test_nested.int_err_exp:
Expect the updated error message.
compiler/check_typeclass.m:
Don't module qualify the names of type constructors in which are
reporting a problem regarding typeclass constraints.
tests/invalid_make_int/bad_detism_category.{m,int_err_exp}:
tests/invalid_make_int/bad_end_module.{m,int_err_exp}:
tests/invalid_make_int/bad_existential_data_type.{m,int_err_exp}:
Move these test cases here from tests/invalid_nodepend, since
most of the errors they report are now diagnosed when making .int files.
Delete the code leading to the two errors that do not fall into this
category. One of those errors is still exercised by a remnant of the
old moved test case, which is now undetermined_existential_data_type.m
in tests/invalid_make_int; the other is exercised by other test cases
that this diff does not touch.
tests/invalid_make_int/Mercury.options:
tests/invalid_make_int/Mmakefile:
Add the moved test cases to the list of test case in this directory.
tests/invalid_nodepend/fundeps_unbound_in_ctor.err_exp:
tests/invalid_nodepend/type_vars.err_exp:
Update these files to expect an unqualified type constructor name.
tests/invalid_nodepend/undetermined_existential_data_type.{m,err_exp}:
Construct this copy by deleting from the old bad_existential_data_type.m
all the code moved to tests/invalid_make_int.
tests/invalid_nodepend/Mmakefile:
Delete the moved test case, and update the name of the remaining test case.
compiler/det_analysis.m:
Improve an error message about foreign_procs by printing it with
the context of the foreign_proc itself, not the context of the
procedure it is for. Also, make the wording more specific.
compiler/prog_event.m:
Reading event sets is currently implemented when the compiler
is compiled for the C backend (because its parser uses lex/flex
and yacc/bison). However, that is no reason for crashing the compiler if
- someone asks it to read an event set
- while the compiler is compiled to a target language other than C.
Fix this by returning an apology message instead of crashing.
tests/invalid/pragma_c_code_no_det.m:
tests/invalid/test_may_duplicate.m:
tests/invalid/test_may_export_body.m:
Add foreign procs for Java and C# as well as for C.
tests/invalid/pragma_c_code_no_det.err_exp{,2,3}:
tests/invalid/test_may_duplicate.err_exp{,2,3}:
tests/invalid/test_may_export_body.err_exp{,2,3}:
Add expected output files for Java and C#. Update the line numbers
in the expected file for C.
tests/invalid/test_type_spec.m:
Delete the parts of this test case that contain errors that we now report
when creating .int files. We now test for those errors using the new test
case tests/invalid_make_int/test_type_spec_int.
tests/invalid/test_type_spec.err_exp:
Delete the messages for the deleted errors, expect verbose errors
(see the update of Mercury.options below), and update the line numbers.
tests/invalid/try_detism.m:
Explain the reason for the need for the new .err_exp2 file.
tests/invalid/try_detism.err_exp{,2}:
Add the new .err_exp2 file for C#, which differs from the .err_exp file
only in the variable number of a compiler-generated variable.
Update the line numbers in the .err_exp file.
tests/invalid/undef_type.m:
Fix the one problem in this test case that we now report when we create
.int files. The handling of that problem is now tested in the new
tests/invalid_make_int/undef_type_int test case.
tests/invalid/undef_type.err_exp:
Don't expect a report for the fixed error.
tests/invalid/Mercury.options:
Run the test_type_spec test case with verbose errors.
tests/invalid/Mmakefile:
Don't try to execute the test cases that this diff moves to
tests/invalid_make_int.
Execute the test cases that try to read event set specifications
only when targeting C. This is not the exact condition we want,
but it is the closest to that condition that we can actually get.
tests/invalid_make_int/bad_instance.{m,int_err_exp}:
tests/invalid_make_int/type_arity.{m,int_err_exp}:
tests/invalid_make_int/undef_inst.{m,int_err_exp}:
tests/invalid_make_int/undef_mode.{m,int_err_exp}:
tests/invalid_make_int/undef_type_mod_qual.{m,int_err_exp}:
Move these tests here from tests/invalid.
tests/invalid_make_int/test_type_spec_int.{m,int_err_exp}:
tests/invalid_make_int/undef_type_int.{m,int_err_exp}:
The parts of the test_type_spec and undef_type test cases in tests/invalid
that get error messages generarated for them while making .int files.
tests/invalid_make_int/Mercury.options:
tests/invalid_make_int/Mmakefile:
Add the tests moved here, in whole or in part, from tests/invalid.
compiler/add_foreign_proc.m:
Don't module qualify the named of predicates/functions
defined by foreign_procs when generating an error message
about that foreign_proc, since
- you can add foreign_procs only for local predicates/functions, and
- even if you one for a NON-local predicate/function, the context will
tell you exactly which foreign_proc is being complained about.
Also, improve the wording of the error message.
tests/invalid/instances_pc.instances_pc_helper_1.err_exp2:
tests/invalid/instances_pc.m:
Add a new expected output file for bootchecks in C# and Java grades,
and document the new expected output file.
tests/invalid/pragma_c_code_dup_var.{err_exp2,err_exp3}:
tests/invalid/pragma_c_code_dup_var.{m,err_exp}:
Add two new expected output files for bootchecks in C# and Java grades.
Note the role of each expected output file, and apply the resulting
line number changes to the expected output file for C.
tests/invalid_make_int/instance_no_type.{m,int_err_exp}:
Move this test case from tests/invalid to tests/invalid_make_int,
since the compiler now diagnoses the bug it tests for
during the creation of the .int file.
tests/invalid_make_int/pragma_export_int.{m,err_exp}:
Move half of the pragma_export test case here from tests/invalid,
since the compiler now diagnoses the bug it tests for
during the creation of the .int file.
tests/invalid_nodepend/pragma_export.{m,err_exp}:
Move the other half of the pragma_export test case here from tests/invalid.
With mmc --make, the diagnosable-at-.int-file-creation-time errors
prevent the compiler from ever getting to the errors that are not
diagnosable at that time, so delete the code that gives rise to those
diagnosable-at-that-time errors from this version of the test case..
tests/invalid/Mmakefile:
Delete the tests moved to other test directories.
tests/invalid_make_int/Mercury.options:
tests/invalid_make_int/Mmakefile:
tests/invalid_nodepend/Mmakefile:
Add the tests moved to these directories from tests/invalid.
compiler/make.program_target.m:
All the multimodule tests in tests/invalid_make_int have been failing
in C# grades. The script for these tests has two main steps:
- build all the .int3 files involved, and then
- build the .int file.
The second step is expected to fail, with its error messages being tested,
but the first step is expected to succeed. The test cases were failing
because mmc --make built the .int files as part of the FIRST stage.
The cause was code that built all interface files (.int3, .int0,
.int/.int2 and even .opt) as a preliminary first step before actually
trying to act on *any* build-all target. The fix is to make this
preliminary step build only the interface files that come before
the build-all target's file kind in the build order. In this case,
that means not building anything in the preliminatu step of the
build-all-int3s target before building all the .int3s, thus leaving
the construction of the .int file for the second step, which is
*expected* to fail.
tests/invalid/exported_unify_helper_1.m:
Rename exported_unify2.m to exported_unify_helper_1.m in accordance
with our usual scheme.
tests/invalid/exported_unify.{m.err_exp,err_exp2}:
Update both expected error files for the rename. Since the .err_exp2 file
was ancient, this update fixed the test case failure for C# (and almost
certainly for Java) bootchecks. Note the role of each expected output
file in the source code.
tests/invalid/foreign_procs_exist_type.err_exp2:
tests/invalid/foreign_procs_exist_type.err_exp3:
Add these files containing the expected outputs for Java and C#.
tests/invalid/foreign_procs_exist_type.m:
Add a note about the role of each expected output file.
tests/invalid/foreign_procs_exist_type.err_exp:
Update the line numbers for this file containing the C expected output.
tests/invalid/foreign_purity_mismatch.m:
tests/invalid/fp_dup_bug.m:
For each C foreign proc being tested, add C# and Java foreign_procs
as well.
Add a note about the role of each expected output file.
tests/invalid/foreign_purity_mismatch.err_exp2:
tests/invalid/foreign_purity_mismatch.err_exp3:
tests/invalid/fp_dup_bug.err_exp2:
tests/invalid/fp_dup_bug.err_exp3:
Add these files containing the expected outputs for Java and C#.
tests/invalid/foreign_purity_mismatch.err_exp:
tests/invalid/fp_dup_bug.err_exp:
Update the line numbers for this file containing the C expected output.
tests/invalid/gh72_errors.m:
This test case tests an error message from the direct arg transformation.
This transform does not apply to C# and Java grades, so in those grades,
the compiler does not generate those messages. In those grades, this
test case failed because the compilation succeeds, instead of failing
(with the expected message, or not).
Fix this failure by adding to gh72_errors.m C# and Java foreign_procs
that do get error messages.
tests/invalid/gh72_errors.err_exp2:
tests/invalid/gh72_errors.err_exp3:
Expect these error messages in C# and Java grades respectively.
tests/invalid/gh72_errors.err_exp:
Update the line numbers in the error messages during C compilations.
compiler/options.m:
doc/user_guide.texi:
Add a new developer-only option, --std-int-file-not-written-msgs,
which, if specified, calls for the "file not written" messages
we generate when we want to write interface files but can't
to be written out in a standard form that deletes the directory
path component from the names of the files not written out.
In the long term, it is less work to add this option once
than to add a separate .err_exp file for each affected test case.
compiler/write_module_interface_files.m:
Obey the new option.
tests/invalid/ee_invalid.m:
Add C# and Java foreign_types next to the C foreign_type.
tests/invalid/erroneous_throw_promise.m:
Add C# foreign_procs next to the C and Java foreign_procs.
tests/invalid/exist_foreign_error.m:
Add C# and Java foreign_procs next to a C foreign_proc.
tests/invalid/exist_foreign_error.err_exp:
tests/invalid/exist_foreign_error.err_exp2:
tests/invalid/exist_foreign_error.err_exp3:
Update the line number in the expected error output file for C,
and add expected error output files for Java and C#.
tests/invalid_make_int/bug17.{m,int_err_exp}:
tests/invalid_make_int/builtin_int.{m,int_err_exp}:
Move these test cases here from tests/invalid, since all the errors
we test for are reported when making the .int file.
tests/invalid/Mmakefile:
Delete the tests moved to tests/invalid_make_int.
tests/invalid_make_int/Mercury.options:
tests/invalid_make_int/Mmakefile:
Add the tests moved from tests/invalid. Specify the new option
for all the test cases.
compiler/write_module_interface_files.m:
compiler/comp_unit_interface.m:
Move the predicates that generate the parse trees of interface files
from write_module_interface_files.m to comp_unit_interface.m.
Move the types they need with them, and document them.
Rename the predicates involved to make clear whether they generate
parse trees, write them out, or both.
In comp_unit_interface.m keep private the previously exported predicates,
because their only callers are the moved predicates, so all calls them
are now local to the module.
compiler/make.get_module_dep_info.m:
compiler/mercury_compile_main.m:
Conform to the changes above.
compiler/write_module_interface_files.m:
Put the code that writes out parse_tree_intNs in separate predicates
from the code that generates them.
This separation is useful in situations in which
- we need to generate several .intN files as fast as possible, and
- later operations will need access to the contents of those files.
With the current setup, we can call e.g. write_short_interface_file_int3
on several parse_tree_module_srcs in parallel, but this comes at the cost
of each worker process building up only its own have_parse_tree_maps
"database" of parse trees. This means if worker process A generates
an interface file, another worker process B will need to read that
interface file to get access to its contents.
With the setup created by this diff, we can generate all the parse trees
for the interface files in the main process, keeping *all* their parse
trees in its have_parse_tree_maps structure, and hand off each parse tree
as it is constructed to a worker process for writing out.
compiler/globals.m:
Add to the globals a new structure that maps extension strings
(such as ".o", ".a" or ".all_picos) to a representation of what
mmc --make target they represent.
compiler/handle_options.m:
Build up this map by processing the values of the options
object_file_extension
pic_object_file_extension
executable_extension
library_extension
shared_library_extension
checking them for collisions both with each other's values,
and with the fixed ".install" extension.
compiler/make.top_level.m:
Use the new map to simplify the code that converts extensions
to mmc --make targets.
These are issues I encountered while working on my previous commit
involving grab_modules.m.
compiler/make.make_info.m:
Give a name to the type that implements the data structure
that we usually use variables named DepStatusMap to refer to.
Rename the make_info field holding this data structure
from mki_dependency_status, which could mean any of several things,
to mki_dep_file_status_map, which pretty clearly says it maps
dependency_files to status information. (mki_dependency__file_status_map
would have been too long.) Rename the getter/setter predicates
accordingly.
compiler/make.check_up_to_date.m:
Do a similar clarifying rename on a predicate.
Convert an if-then-else to a switch.
Add a long XXX describing a problem I found while investigating
with some temporarily-failing test cases. Those test cases now succeed
despite the presence of this bug.
compiler/make.get_module_dep_info.m:
Delete code to write out error_specs that later code is guaranteed
to also write out on all possible execution paths. This resulted
in double-printed error messages in some test cases, which succeeded
despite this, because this problem occurred during compilation tasks
(such as the creation of .int3 files) that the test cases do NOT involve.
Speed up a search/insert operation pair.
compiler/mercury_compile_main.m:
Fix a sort-of bug that that included some error_specs in a list of
error_specs twice. The code writing out the error_specs would have
deleted the duplicates, but still, it is better to avoid adding
the duplicates in the first place.
compiler/make.program_target.m:
Merge two pairs of adjacent switches.
compiler/make.module_target.m:
Conform to the changes above.
compiler/grab_modules.m:
grab_{qual,unqual}_imported_modules_*, the two main predicates
of this module, have for a while now taken as input both a
parse_tree_module_src, and several separate arguments each describing
part of the origin of that parse_tree_module_src. They then created
a new module_baggage structure, filling some of its fields using
those arguments, but filling other fields with default values,
which were no more than guesses at what the right value might be.
This has obviously worked, but it could work only because
the guessed-at fields are either not used or were guessed well.
However, this may change in the future. After this diff, we now require
the caller to pass to these predicates a fully-and-correctly-filled-in
module_baggage structure instead, which guards against that
possibility, and leads to cleaner and more understandable code
to boot.
We do throw away any errors in the initial module_baggage
in order to prevent parts of the compiler that aren't set up
to handle any errors there from causing additional test failures
in C# (and probably Java) grades. This preserves old behavior,
at least for now.
compiler/write_module_interface_files.m:
Make the versions of write_private_interface_file_int0 and
write_interface_file_int1_int2 that took a burdened_module
as an argument the *only* versions of those operations,
since the burdened_module contains the module_baggage structure
we now want to pass to grab_modules.m.
Replace the parse_tree_module_src argument of
write_short_interface_file_int3 with a burdened_module.
This is only for "cultural compatibility" with the neighboring
predicates; unlike those two, this predicate does not need access
to the module_baggage.
compiler/make.get_module_dep_info.m:
compiler/mercury_compile_main.m:
Conform to the changes above.
compiler/module_baggage.m:
Fix a misleading variable name.
compiler/split_parse_tree_src.m:
Rename split_into_compilation_units_perform_checks to
split_into_component_modules_perform_checks. The type of the returned
data structures was changed from raw_compilation_units to
parse_tree_module_srcs a while ago.
Perform the same rename for some internal predicates as well.
Factor out some common code.
compiler/mercury_compile_main.m:
compiler/module_baggage.m:
Conform to the changes above.
... instead of ErrorStream, in more places.
compiler/compile_target_code.m:
compiler/file_util.m:
compiler/handle_options.m:
compiler/mercury_compile_front_end.m:
As above.
compiler/make.program_target.m:
compiler/mercury_compile_main.m:
compiler/xml_documentation.m:
Don't pass ErrorStream to predicates that don't need it anymore.
... to account for the fact that they now contain constructed parse trees,
as well as read-in parse trees.
compiler/read_modules.m:
Make the rename described above.
Make it possible to differentiate between constructed and read-in
parse trees, in case this becomes necessary in the future.
compiler/deps_map.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/make.get_module_dep_info.m:
compiler/make.make_info.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/recompilation.check.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
In make.get_module_dep_info.m, add an XXX.
configure.ac:
Require the installed compiler to support both the option,
and the Mmake rules that invoke it.
compiler/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
mfilterjavac/Mmakefile:
ssdb/Mmakefile:
Get the mmake depend to depend on prog.depend_ints, not prog.depend,
Give the prog.depend_ints targets themselves the same prerequisites
as the existing prog.depend targets.
In mfilterjavac/Mmakefile, fix what looks like an old problem
by making the depend target a prerequisite of the check and ints targets.
.. that failed because the "For more information, recompile with `-E'
message was missing.
This diff takes the number of failed test cases in these grades
from 228-ish to 171.
compiler/make.module_target.m:
Stop calling the predicate that outputs that message outside
of the part of mmc --make's machinery that can fork the compiler process,
and ...
compiler/mercury_compile_main.m:
... ensure that it is called *inside* the forked process, in such cases.
Do this by ensuring that
- each switch arm in do_process_compiler_arg gathers up the error_specs
generated by code executed along that switch arm, and
- after the switch, do_process_compiler_arg prints both these
error_specs, *and* the "For more information, recompile with `-E'
message if warranted.
Previously, the last of those points happened on some execution paths,
but not all.
... instead of ErrorStream.
compiler/parse_tree_out.m:
As above.
compiler/make.get_module_dep_info.m:
compiler/mercury_compile_main.m:
compiler/write_module_interface_files.m:
Don't pass ErrorStream to predicates that don't need it anymore.
compiler/check_typeclass.m:
Delete the verbose_only part of an error message, because it duplicated
almost exactly the always-printed part of the same error message.
tests/invalid/instance_var_bug.err_exp:
Don't expect the verbose part.
tests/invalid/bad_instance2.err_exp:
tests/invalid/invalid_instance_declarations.err_exp:
Don't expect a reminder about the existence of the verbose part.
compiler/Mercury.options:
Stop specifying --no-warn-implicit-stream-calls for make.module_target.m.
compiler/make.module_target.m:
Use explicit streams when invoking mmc recursively for a target.
Add a call to maybe_print_delayed_error_messages. It does not fix
the problem it looks like it *should* fix, but it is almost certainly
a required step for that fix.
compiler/mercury_compile_main.m:
Take the explicit streams that make.module_target.m now passes.
compiler/write_error_spec.m:
Make the mutables consulted by maybe_print_delayed_error_messages
thread local. This should help, but it does not solve the problem.
compiler/make.build.m:
... as opposed to what you get from io.output_stream.
Change argument order to reflect our usual style.
compiler/make.get_module_dep_info.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changes above.
... so that the following code can write to an *explicitly*, as opposed
to *implicitly*, specified stream.
compiler/code_gen.m:
compiler/code_info.m:
Include the stream to which debug output should be written in the
code_info structure. Move the predicate that tests whether we should
generate debug output from code_loc_dep.m to code_info.m, since it
belongs there.
compiler/code_loc_dep.m:
compiler/ite_gen.m:
compiler/proc_gen.m:
Conform to the changes above.
compiler/typecheck_info.m:
Include the stream to which debug output should be written in the
relevant field of the typecheck_info structure.
compiler/unneeded_code.m:
Include the stream to which debug output should be written in the
uc_option_values structure.
compiler/dep_par_conj.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_middle_passes.m:
compiler/stack_opt.m:
compiler/typecheck.m:
compiler/typecheck_debug.m:
Replace calls to io.output_stream with explicitly passed streams.
... and almost all calls to get_error_output_stream. Replace them
with ProgressStreams and ErrorStreams passed down from higher in the
call tree.
Use ProgressStreams, not ErrorStreams, to write out error messages about
any failures of filesystem operations. These are not appropriate to put
into a module's .err file, since they are not about an error in the
Mercury code of the module.
compiler/globals.m:
Delete the predicates that return progress streams, and the mutable
behind them.
compiler/passes_aux.m:
Delete the predicates that return progress streams. Delete the
versions of the progress-message-writing predicates that didn't get
the progress stream from their caller.
compiler/*.m:
Pass around ProgressStreams and/or ErrorStreams explicitly,
as mentioned at the top of log message.
In a few places, don't write out error_specs to ErrorStream,
returning it to be printed by our caller, or its caller etc instead.
In some of those places, this allowed the deletion an existing
ErrorStream argument.
Given that get_{progress,error}_output_stream took a ModuleName input,
deleting some of the calls to those predicates left ModuleName unused.
Delete such unused ModuleNames.
In a few places, change argument orders to conform to our usual
programming style.
Fix too-long lines.
compiler/make.top_level.m:
Put the code for recognizing the single module targets, the build-all
module targets, and the misc targets into a single giant switch.
That leaves the if-then-else chain handling only the dynamic extensions,
i.e. those whose values are specified by option values. Put the ones
dealing with executables before the ones dealing with libraries.
compiler/make.top_level.m:
Add a new way to test whether an extension string specifies
a build-all target type. The new code is a single switch,
while the old code is an if-then-else chain on top of other code.
Don't make the new code live yet. Instead, add a predicate to compare
the outputs of the old and new algorithms both for the extensions
that are intended to recognize, and some extensions that they shouldn't
recognize. This predicate reports that the new algorithm agrees with
the old for all the tested extension strings.
They turned out to have a zero hit rate, making them useless.
compiler/make.dependencies.m:
Add code to use the two new caches, indirect_imports_non_intermod
and anc0_dir1_indir2_non_intermod. I got statistics on their
performance while they were enabled, but since their hit rate was zero,
this diff includes them only in a commented-out form.
Note that adding the second cache required adding a new dep_spec,
which remains, since it shouldn't affect performance at all.
compiler/make.deps_cache.m:
Disable the those two caches.
Fix an issue where the original statistics-gathering code
mixed up hits and misses.
Include the statistics gathered in course of implementing this diff.
tools/make_deps_cache_stats:
Update this script to fix the hit/miss issue, and to print more info.
compiler/make.top_level.m:
Move the predicates extension_to_target_type and target_extension_synonym
here from make.file_names.m, since they were used only in this module.
Separate the extension_to_target_type into its two parts, the switch,
and the test, at both its call sites. Merge the code of
target_extension_synonym into the switch part, which is now called
just_ext_to_module_target_type.
Convert a series of if-then-elses in the middle of an if-then-else chain
into a switch.
compiler/make.file_names.m:
Delete the code moved to make.top_level.m.
scripts/Mmake.rules:
Add a rule for the pattern target %.depend_ints which invokes mmc
with --generate-dependencies-ints, just as %.depend invokes mmc
with --generate-dependencies.
Document the reason why this addition requires yet more code duplication.
scripts/Mmake.vars.in:
Add the make variable definitions needed by the new code in Mmake.rules.
compiler/mercury_compile_main.m:
Make it practical to use --generate-dependencies-ints in a multi-directory
project like the Mercury implementation, in which some directories
may use --generate-dependencies-ints as the target of "mmake depend",
while other directories, which come earlier in the build process,
still do "mmake depend" using just --generate-dependencies.
In such cases, mmc --generate-dependencies-ints in the later directory
may fail to generate .int0, .int or .int2 files simply because
the .int3 file of a module they import (from an earlier directory
in which "mmake depend" uses just --generate-dependencies) hasn't been
made yet. (This is what would happen if someone executed "mmake depend"
at the top level in a freshly checked out workspace.)
The practical fix is to simply report this fix using an error message
that still allows the compiler to exit with an exit status that
indicates success.
Most of the rest of this diff is there to make this possible.
compiler/error_spec.m:
Add a new phase, phase_find_files, that specifically indicates
that we couldn't read a file because we couldn't find it.
Give it a string argument naming the file, to allow mercury_compile_main.m
to replace several error_specs that each report not being able to find
one file with a single error_spec that reports not being able to find
many files.
Add a utility function for use by mercury_compile_main.m to construct
that error message.
Add another new phase, phase_make_int, that indicates a problem
we discovered in the code of a Mercury source file while trying
to decide what should got into one of the that module's interface files.
compiler/parse_error.m:
Here also use separate function symbols in the fatal_module_read_error
type for the situations "couldn't find a file" and "couldn't read a file".
Update the predicates constructing error_specs to handle this distinction
(which the callers make using the new function symbol in the above type).
compiler/compile_target_code.m:
compiler/error_util.m:
compiler/grab_modules.m:
compiler/options_file.m:
compiler/parse_module.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
compiler/options.m:
Add a way to detect the presence of this diff in an installed compiler.
compiler/make.deps_cache.m:
Add conditionally-compiled code to count the search and addition
operations on each cache, as well as code to write out these counts.
Where a cache has two versions, one for intermod and non-intermod
operations, put the non-intermod version first, since it is more basic.
Add two new non-intermod cache versions that are not used yet,
but whose intermod versions are used: one for non-intermod
indirect imports, and one for non-intermod anc0_dir1_indir2.
For the latter, include "intermod" in the name of the old cache,
which uses intermodule information.
compiler/make.make_info.m:
Add those two caches, and follow the updated order and names of the caches.
compiler/mercury_compile_main.m:
Call make.deps_cache.m to dump out its cache, it it was enabled
and gathered any info.
compiler/make.m:
Make make.deps_cache.m visible from outside the make package,
in order to make possible the change top mercury_compile_main.m above.
compiler/make.dependencies.m:
Conform to the changes above.
tools/make_deps_cache_stats:
A new script to summarize the information recorded by the new code.
compiler/make.dependencies.m:
... through all the relevant predicates in this module. This fixes
all the "XXX MAKE_STREAM"s in the module.
compiler/make.module_target.m:
Pass ProgressStream to make.dependencies.m.
compiler/make.dependencies.m:
compiler/make.deps_cache.m:
compiler/make.make_info.m:
Rename predicates, fields and function symbols using the scheme
direct_imports -> direct_imports_intermod
non_intermod_direct_imports -> direct_imports_non_intermod
This reflects the fact that the direct_imports dep_spec returns a
set of modules (in the form of module indexes) that includes
the sets of modules returned by the non_intermod_direct_imports dep_spec
as a subset, and adds to it the direct imports of the modules
returned by get_intermod_imports, whose comment says it returns
"the set of modules whose .opt files we should read"
Do similar renames for indirect imports and for foreign language imports
as well, for the same reason.
The new names convey the semantic differences between the affected
dep_specs, and the predicates that implement them, much more clearly
than the old names.
compiler/make.deps_cache.m:
Delete a field containing no information from the key of one of the
caches. Its future role of identifying the info associated with
the rest of the key can be handled more simply by using separate fields
in make_infos.
Several of the caches that this module looks after map the same type
of keys to the same type of values. Use a single type to describe
the type of all these caches, replacing several identical earlier types.
Name these types after their structure, not their purpuse.
compiler/make.make_info.m:
Put the caches with identical types next to each other.
Improve the names of the caches' getter and setter predicates,
making some shorter, and others more meaningful. (The diff makes
the same changes to the names of the search and update predicates
in make.deps_cache.m.)
compiler/make.dependencies.m:
compiler/make.find_local_modules.m:
Conform to the changes above.
compiler/make.deps_cache.m:
For each cache that this module looks after, add a predicate
to search the cache and another to add a new entry to the cache.
This centralization should make it easier to gather stats about
the caches.
Shorten some unnecessarily-long names.
compiler/make.dependencies.m:
compiler/make.find_local_modules.m:
Replace the inline code for searching and update caches
with calls to the new predicates in make.deps_cache.m.
This makes the code easier to read.
Add to the new machinery in make.dependencies.m the one cache
that it lacked that the old machinery had. All the other caches
are used by code in the infrastructure used by both the old and the new
machineries.
compiler/make.deps_cache.m:
compiler/make.find_local_modules.m:
Move the definition of the cache of transitive dependencies
from make.find_local_modules.m to make.deps_cache.m.
Rename some types for consistency.
compiler/make.make_info.m:
Conform to the change above.
compiler/generate_dep_d_files.m:
Document the reason for the split between .dep and .dv files.
Fix typo.
scripts/mmake.in:
Delete code that was only needed for bootstrapping that split
(in 1999!).
Document an incorrect comment.
compiler/write_deps_file.m:
Don't pass the deps_map argument to generate_dependencies_write_d_files,
since that argument has been ignored for a long time now (at least
five years).
Make that same predicate take a list of burdened modules instead of
a list of deps, since it uses only the burdened module field
of the deps structure.
compiler/generate_dep_d_files.m:
Conform to the changes above.
Move a piece of code to where it conceptually belongs.
This new option extends --generate-dependencies to take advantage of the
opportunity afforded by the fact that "mmc --generate-dependencies prog.m"
reads in every Mercury source file in the current directory that is
part of "prog". It does this by
- generating the .int3 file of all local-directory modules of the program;
- generating the .int0 file for each these modules that has submodules;
- generating the .int and .int2 files of all local-directory modules
of the program.
Normally, the process of creating .int0, .int and .int3 files would
need to read in .int0 and .int3 files, but in every one of these cases,
we have just written out those files, so simply holding onto their
parse trees, we can skip this step. On my laptop, on a directory
containing library/*.m, mdbcomp/*.m and compiler/*.m, generating
the dependencies and generating all the .int3/.int0/.int/.int2 files
takes just over 25 seconds. Using the new option, the same process
takes less than 10 seconds.
compiler/options.m:
Add the new option.
compiler/op_mode.m:
Add a new variant of the existing op_mode for --generate-dependencies,
which we select in the presence of the new option.
compiler/mercury_compile_main.m:
Implement the new op_mode.
Fix an old issue, which is that "mmc --make-private-interface x.m"
generated a .int0 file for *every* module in x.m, even the modules
that don't have any submodules.
compiler/deps_map.m:
The code implementing the new option needs to know which modules
of the program are in the current directory. The deps_map structure
built by the code shared with the implementation of --generate-dependencies
has not needed that info until now, so add a new field to the deps
structure of each module to provide this info.
compiler/generate_dep_d_files.m:
Return the deps_map created by the code that implements both
--generate-dependencies and the new option to mercury_compile_main.m.
compiler/write_module_interface_files.m:
Add a flag to the predicates that first construct the parse trees of,
and then write out, .int3/.int0/.int/.int2 files, that
mercury_compile_main.m can use to tell them to record the parse trees
in the have read module maps.
Add new variants of two of those predicates that take some of their
arguments from burdened_module structures, since that is the form
in which mercury_compile_main.m has that info.
compiler/module_baggage.m:
The predicates in write_module_interface_files.m that generate
.int0/.int/.int2 files take an argument that should be the timestamp
of the source file they are being derived from, if that timestamp
is needed for smart recompilation. Until now, we only ever invoked
those predicates when we have just read in the source file,
and this timestamp was readily available. The code implementing
the new option needs to store this info for a short time, and
the module baggage is the obvious place to store it, so add this field
to the baggage.
compiler/error_spec.m:
An invocation of the compiler with new option may report errors that
prevent the construction of interface files for several modules.
The new code in mercury_compile.m prints the error_specs that have
contexts in the order of those contexts, but we want to print
the messages without contexts (which in this case report that
certain files could not be written or copied) to have a useful
order too. Make this possible by allowing the invisible pieces
we use for ordering to specify that order via a string (in this case,
the name of the file that e.g. could not be written), rather than
the only previous option, an integer.
compiler/grab_modules.m:
compiler/make.get_module_dep_info.m:
compiler/make.module_dep_file.m:
Fill in the new field in the module baggage.
compiler/check_module_interface.m:
compiler/handle_options.m:
compiler/make_hlds_error.m:
compiler/parse_module.m:
compiler/prog_foreign_enum.m:
compiler/typecheck_error_util.m:
compiler/typecheck_msgs.m:
compiler/write_deps_file.m:
compiler/write_error_spec.m:
Conform to the changes above.