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.
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.
... 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.
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.
... 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.
... instead of building a bunch of .c files.
Our tradition of adding an "s" at the end of a suffix to mean "all of the
files with the original suffix" had a problem when we added C# as a target
language. Until then, just as "os" stood for ".o files" when it occurred
as either a mmake target, mmc --make target, or mmake variable name component.
"cs" likewise stood for ".c files", but was now also needed to mean ".cs file".
We coped by keeping "cs" meaning ".c files", and adding "csharp" as a target
name synonym to mean ".cs file".
This diff keeps that synonym, but it changes
- the name needed to refer to ".c files" from "cs" to "all_cs"
- the name needed to refer to ".o files" from "os" to "all_os"
- the name needed to refer to ".pic_o files" from "pic_os" to "all_pic_os"
- the name needed to refer to ".cs files" from "css" to "all_css"
- the name needed to refer to ".java files" from "javas" to "all_javas"
- the name needed to refer to ".opt files" from "opts" to "all_opts"
- the name needed to refer to ".trans_opt files"
from "trans_opts" to "all_trans_opts"
It would be nice if we could apply this same change to all other similar
target names and mmake variable name suffixes, such as "ints" and "int3s",
but some of those names are already in use to mean semantically different
things. All of the names above that used to have the form "<ext>s" and
now have the form "all_<ext>s" stood for all the files with extension
".<ext>" that are prerequisites for building a linked target, i.e.
an executable or a library. But the mmake variable name suffixes
".all_mihs", ".all_mhs" and ".all_int0s" each stand for something subtly
different: the names of files that *may or may not exist", but which,
if they do exist, should be deleted by a clean or realclean target.
To make this breaking change easier to handle by users, this diff does
not simply redefine the meaning of ".all_int0s". (It does change the meaning
of the "cs" target, but the fact this will happen at some time has been
announced ages ago.) Instead, it defines three new mmake var suffixes,
".mihs_to_clean", ".mhs_to_clean" and ".int0s_to_clean", which are
synonyms for ".all_mihs", ".all_mhs" and ".all_int0s" respectively,
and announces that ".all_mihs", ".all_mhs" and ".all_int0s" are being
deprecated, and will have the above change of semantics applied to them
in the future.
NEWS.md:
Announce the breaking change.
compiler/make.top_level.m:
Stop treating the target "cs" as meaning "build all the .c files
for this program".
The code of classify_target_2 has long been semidet, but only in a way
that was not apparent to the compiler. Change the code to allow the
compiler to see its semidet nature while keeping the algorithm the same,
except for the change in the paragraph above.
This includes keeping e.g. "ints" as meaning "build all the .int/.int2
files needed by this program".
compiler/write_deps_file.m:
Stop generating mmake variables with suffixes ".cs", ".os", ".pic_os",
".javas" and ".css". The mmake variables with suffixes ".all_cs",
".all_os", ".all_pic_os", ".all_javas" and ".all_css" already existed.
All had the same value as the mmake variable without the "all",
with one exception: ".cs". However, in this case, the old (and still
current) value of ".all_cs" is what the value of ".cs" *should* have been.
Simplify some code.
The following changes in compiler/*.m are only cosmetic, but they helped me
rule out possible sources of problems with incomplete versions of this diff.
compiler/file_names.m:
Add a version of a fact_table_file_name_return_dirs which does not
return directories, since most of its callers don't need that info.
compiler/make.program_target.m:
Clarify code by making variable names more descriptive,
compiler/make.file_names.m:
compiler/make.module_target.m:
Conform to the changes above,
browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
grade_lib/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
mfilterjavac/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
Rename os to all_os, cs to all_cs, css to all_css, javas to all_javas,
and opts to all_opts. (There were no occurrences of trans_opts to rename.)
Replace [s as sh command names in actions.
scripts/Mmake.vars.in:
Specify the names of mmake variables holding the names of sets of files
with a given extension directly, since for some of them, adding an "s"
at the end of the name of the extension does not generate the name
of the corresponding mmake variable anymore.
scripts/Mmake.rules:
Use the directly specified mmake variable names from Mmake.vars.in
in the rule for installing lbraries. Temporarily add some debugging
output to make suree that the updated nested mmake variable references
work as intended.
tools/bootcheck:
Specify the names of mmake targets for making all the files in a program
with a given extension directly, since adding an "s" at the end of the
name of the extension does not generate the name of the corresponding
mmake target anymore.
Print timestamps around the action of checking namespace cleanliness,
to allow the time taken by that action to be measured. (I kept track
of bootchecks as they happened while working on this diff, and found
this time to be nontrivial.)
compiler/make.get_module_dep_info.m:
compiler/make.module_dep_file.m:
As above. make.module_dep_file now deals only with reading and writing
.module_dep files, as its name suggests, while make.get_module_dep_info.m,
which is significantly larger, manages the process of getting
module_dep_infos, which it can do either by finding .module_dep files,
or by building them if necessary.
compiler/make.m:
Include the new module.
compiler/notes/compiler_design.html:
Document the new module.
compiler/make.check_up_to_date.m:
compiler/make.dependencies.m:
compiler/make.file_names.m:
compiler/make.find_local_modules.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
Conform to the changes above.
Each of the new modules, and the old one, have improved cohesion.
compiler/make.check_up_to_date.m:
compiler/make.deps_cache.m:
compiler/make.find_local_modules.m:
Carve these new modules out of make.dependencies.m.
make.check_up_to_date.m contains code to test whether the other files
that the current target file depends on are up to date or not.
make.deps_cache.m contains the caches that make.dependecies.m uses,
which are also components of the make_info structure.
make.find_local_modules.m contains code to find the set of modules
in the current directory that a module (such as a module that
defines main/2) depends on.
compiler/make.m:
Include the new modules in the make package.
compiler/notes/compiler_design.html:
Document the new modules.
compiler/make.make_info.m:
Move two types here from make.dependencies.m, since they define
the type of one the pieces information stored in the make_info,
and they are also used by other modules.
compiler/make.dependencies.m:
Delete the code moved to other modules.
compiler/make.build.m:
compiler/make.deps_set.m:
compiler/make.file_names.m:
compiler/make.hash.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
compiler/make.top_level.m:
compiler/make.track_flags.m:
compiler/make.util.m:
Conform to the changes above.
compiler/make.program_target.m:
When --order-make-by-timestamp is specified, we were putting files
with lower timestamps *before* files with higher timestamps, which
directly contradicts the documented meaning of the option. Fix this.
When --order-make-by-timestamp is not specified, we used to compare
module names as sym_names, which (due the the "unqualified" function
symbol coming before the "qualified" symbol) meant that the order
consisted of
- unqualified(...) modules in alphabetic order
- qualified(unqualified(...), ...) modules in alphabetic order
- qualified(qualified(unqualified(...), ...), ...) modules
in alphabetic order
and so on.
This made it hard to know how the building of e.g. .cs files was
progressing, because after reaching the filenames near the end of
the alphabet, there could be another round of filenames that came from
modules with one more "qualified" wrapper.
Fix this by comparing module names by comparing their string versions,
not their raw sym_name.
compiler/make.build.m:
If the compiler has not yet written to a module's .err file, then direct
the output from processing that module directly there. Use the old
algorithm, which is to direct that output to a temp file, and then
appending that the contents of the temp file to the .err file later,
only if this compiler invocation *has* written to the .err file before.
This should save the cost of a file copy in such cases.
Change the interface of the predicates that open and close the module error
stream to make the above possible.
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the change in the interface.
compiler/make.build.m:
The redirect/unredirect predicates originally did do what their
names said, but that hasn't been true for a while. This diff gives
them names that describe their current functionality, and changes
them to use a bespoke type for their return value.
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changes in make.build.m.
In one place, add an XXX; in another, move an XXX.
compiler/make.build.m:
Replace one of the two remaining calls to io.output_stream
with an explicit stream passed from higher up in the call tree.
compiler/make.dependencies.m:
Replace many remaining calls to io.output_stream with an explicit stream
passed from higher up in the call tree, though some of these still get it
by calling io.output_stream themselves. Fixing these will require changes
to the same higher order predicate.
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/mercury_compile_main.m:
Pass the explicit stream that predicates exported from make.build.m
and make.dependencies.m now require.
compiler/make.file_names.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
Instead of getting streams by calling io.output_stream, get it from
higher up in the call tree. (There is still one place left in
make.program_target.m that does this, which may require further changes
elsewhere before it can be eliminated.)
compiler/make.build.m:
Add a version of an existing predicate that has its arguments reordered
to suit the requirements of another higher-order predicate.
compiler/make.module_dep_file.m:
compiler/make.timestamp.m:
Conform to the changes above.
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
Replace code that writes progress messages to the implicit current
output stream with code that writes to an explicitly specified
progress stream. Pass that stream explicitly down to the code
that needs it.
compiler/make.build.m:
Add an explicit stream (the progress stream) argument to the predicates
that fold over mmc --make actions, since the actions (mostly in
make.module_target.m and make.program_target.m) now have such arguments.
compiler/mercury_compile_main.m:
Pass a progress stream to the top of the code of mmc --make.
compiler/Mercury.options:
Stop specifying --no-warn-implicit-stream-calls for make.program_target.m
and make.top_level.m. (make.module_target.m contains some still-needed
stream redirection code that would get such a warning.)
compiler/make.build.m:
Require callers to specify an output stream to replace
a previously-implicit stream.
compiler/Mercury.options:
Stop specifying --no-warn-implicit-streams for make.build.m.
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Pass the stream now required by make.build.
compiler/write_error_spec.m:
As above.
compiler/find_module.m:
compiler/source_file_map.m:
Require the callers of predicates that call write_error_specs
to supply an explicit stream.
compiler/make.program_target.m:
compiler/mercury_compile_main.m:
Pass explicit streams where required.
compiler/make.module_dep_file.m:
Rename the main exported predicate, get_dependencies, to
get_maybe_module_dep_info, since while the latter expresses its purpose
much more precisely. Rename some of its subcontractor predicates
in a similar fashion.
Clarify the structure of a predicate by replacing a seeming three-way
switch with code that reflects its actual structure: one two-way switch
nested inside one arm of another two-way switch. Move code needed
only on some paths to be executed on just that path.
Update an example.
compiler/make.dependencies.m:
compiler/make.file_names.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
Conform to the changes above.
compiler/make.module_dep_file.m:
Replace all I/O done to implicit streams with I/O to explicit streams.
We cannot yet disable --no-warn-implicit-stream-calls for the module,
because it still contains code to change the current output stream.
compiler/make.dependencies.m:
compiler/make.file_names.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
compiler/mercury_compile_make_hlds.m:
Conform to the change in make.module_dep_file.m.
compiler/make.dependencies.m:
Replace all I/O done to implicit streams with I/O to explicit streams.
compiler/Mercury.options:
Stop specifying -no-warn-implicit-stream-calls for make.dependencies.m.
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changes in make.dependencies.m.
In make.module_target.m, reclassify some existing use of explicit streams
from debug to progress messages, because the messsages make sense only
when synchronized with actual progress messages.
compiler/make.util.m:
Delete the versions of maybe_write_msg and maybe_write_msg_locked
that wrote to the (implicit) current output stream. The versions
that write to an explicitly specified stream remain.
Change the old callers to the deleted predicates to pass an explicit
stream to the remaining versions. To make this possible, require *their*
callers to specify an explicit stream.
Give two predicates less-confusing names.
compiler/Mercury.options:
Stop specifying -no-warn-implicit-stream-calls for make.util.m.
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changes in make.util.m. In most places, we do still use
implicit streams, but moving such uses higher and higher in the call tree
gets us closer and closer to using only explicit streams.
Previosly, there were three places in the compiler that had code to compute
the name of the directory where .class files are stored. Replace two of
these with calls to the third.
compiler/file_names.m:
Compute the three components of files, that is
- the dir names list that together specify a relative path,
- the file's base name and
- the file's extension string
in three separate predicates. Export the new predicate doing just
the first job; the functions doing the second and third jobs were
already exported.
Make the code computing the dir names list for .java and .class files
call get_java_dir_path. This replacement of the old get_class_dir_name
predicate is now the place that every part of the compiler calls
for this info.
As part of this last change, add the "jmercury" component to the path
for .java and .class files separately, since we need the path both
with and without this extension. This change allows a simplification
of the make_grade_subdir_name function.
compiler/compile_target_code.m:
Call the new get_java_dir_path predicate in file_names.m instead of
including a duplicate copy of its logic.
compiler/make.program_target.m:
Add an XXX on code that *looks like* it should either be in
file_names.m or use code in file_names.m, but which cannot be easily
updated using either approach, because its purpose is undocumented.
compiler/mercury_compile_main.m:
compiler/module_cmds.m:
Conform to the changes in file_names.m.
... with --use-grade-subdirs.
compiler/file_names.m:
Move all the executable and library extensions to the ext_cur_gs group,
which means their files get put into grade-specific directories if
--use-grade-subdirs is set.
Comment out the enums representing the .lib and .so extensions,
because they are never specified specifically as those extensions;
they are only ever referred to though the options holding
those extensions.
Put all executable files into subdirs named "bin", and all libraries
into subdirs named "lib". Rename the subdirs for several other extensions
as well, as we agreed on m-rev.
compiler/make.program_target.m:
Conform to the change above.
Delete duplicate computation of the filename of an "mmc --make" target.
Use a direct test of filenames to see whether a file needs to be
linked-or-copied to the current directory.
If the action of generating an executable does not execute cleanly,
clean up not just the full pathname version of the file, but its
current directory copy as well (in case it was the copy that
got the error, due to e.g. the filesystem being full).
compiler/write_deps_file.m:
Conform to the change above.
Delete a repeated computation.
compiler/compile_target_code.m:
Conform to the change above.
compiler/file_names.m:
Replace the current groups of extensions, which are based on the
shared purpose of the files with those extensions, with a smaller
number of groups, which are based on the algorithm we use to decide
in what (sub)directories we want to place files with those extensions.
The old distinctions based on purpose still remain in the naming
convention for the enum values within each of the new groups.
compiler/analysis.file.m:
compiler/analysis.m:
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/fact_table.m:
compiler/file_kind.m:
compiler/generate_dep_d_files.m:
compiler/llds_out_file.m:
compiler/make.file_names.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mercury_compile_middle_passes.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/prog_foreign.m:
compiler/recompilation.used_file.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the changes above.
compiler/file_names.m:
Replace several groups of extensions that stood for semantically
different groups of extensions by one group, the "always in the
current directory" group. The enum type of the new type representing
the now larger group consists of the enum values from the types
representing the old, smaller groups. The old boundaries are thus
no longer expressed in types, but still remain in the naming schemes
of the enum values.
Once we have done the same for the six other groups of extensions,
with each group having its own pattern of where its extensions are put
under which circumstances, we can replace code that does multiple
modulename+extension to filename translations with code that does
one modulename+extension to DIRECTORY PATH translation, and then
constructs multiple filenames from that, repeating just the
"extension enum to extension string" part of the old translation
for each operand. We can do this because unlike the old extension
categories, the new ones will make clear which groups of extensions
are guarantee to map to the same directory path, and which have
no such guarantee.
compiler/compile_target_code.m:
compiler/export.m:
compiler/generate_dep_d_files.m:
compiler/make.build.m:
compiler/make.file_names.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/write_deps_file.m:
Conform to the changes above.
Each of the new modules, and the new make.util.m, has better cohesion
than the old make.util.m. (For example, the lists of modules they import
don't overlap all that much.)
compiler/make.file_names.m:
compiler/make.hash.m:
compiler/make.timestamp.m:
Carve these three modules out of make.util.m
- make.file_names.m does filename translations.
- make.hash.m does hashing.
- make.hash.m looks up and compares timestamps.
compiler/make.m:
Include the new modules.
compiler/notes/compiler_design.html:
Document the new modules.
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
compiler/make.util.m:
Update module imports.
compiler/globals.m:
Define a new enum type with three values, which represents the three
legal combination of the values of the use_subdir and use_grade_subdir
options.
Add a field of this type to the globals.
compiler/handle_options.m:
Set up the value of this field in the globals. This means initializing
it to a non-meaningful value when the globals is first created, and
filling it in with the final meaningful value when we finish the setup
of the global structure.
compiler/options.m:
Add a "setting_only_" to the internal names of the use_subdir and
use_grade_subdir options, to signal that their only valid use
from now on is in deciding the value of the new globals field.
(Their user-facing names remain unchanged.)
compiler/compile_target_code.m:
compiler/file_names.m:
compiler/make.program_target.m:
compiler/module_cmds.m:
compiler/write_deps_file.m:
Rewrite code that used to make decisions based on the values of
the use_subdir and use_grade_subdir options with code that makes
decisions based on the value of the new field. A field retrieval
followed by a three-way switch is simpler (and faster) than
two option lookups and one two-way switch inside another.
Consistently reorder the code so that the code of the simpler cases
come first.
Note a situation where we should be using an even simpler basis
for the decision.
compiler/file_names.m:
Up till now, every translation of a module_name+extension to a filename
returned a filename that always included the needed relative path.
But for some final products of compilation, such as executables
and libraries, after we have created the file under its fully
specified relative pathname, we also want to copy it to the
current directory.
We used to this in a roundabout way, by setting up a globals structure
that turned off the use_subdirs and use_grade_subdir options
(or, in some cases, just one of them), and redoing the
module_name+extension to filename translation using this modified globals.
This diff changes to a more direct approach: asking file_names.m
to return both the fully specified relative path of the filaname,
and just its local directory component, in *one* predicate call.
We do this by adding new versions that return this info
of those predicates whose callers need this info.
To make this possible, make the main translation predicate,
module_name_to_file_name_ext, return to its callers not
the list of directory components and the full relative path, but
the list of directory components and the local filename,
leaving it up to its callers to construct the full relative path
from them *without* precluding the possibility of returning
the local filename as well.
Move some comments to the place they apply to.
compiler/compile_target_code.m:
Rename the link_output_filename predicate to linked_target_file_name
and export it. linked_target_file_name was a predicate in make.util.m
that had a identical definition to linked_target_file_name, which
this diff deletes; by exporting the renamed predicate, we make it
available in make.util.m as well.
Provide a new version of linked_target_file_name,
linked_target_file_name_full_curdir, which also returns
both the full pathname and the local directory name
it gets from file_names.m.
Use the new facilities in file_names.m where relevant.
Factor out some common code.
compiler/make.program_target.m:
compiler/make.util.m:
Use the new facilities in file_names.m where relevant.
In make.util.m, delete the duplicate predicate definition.
compiler/handle_options.m:
The main predicate of this module, handle_given_options, used
to generate the default option table every time it was called,
and its callers couldn't prevent this by supplying it with that
default option table. Fix this by adding an argument for that info.
compiler/mercury_compile_main.m:
Create the default option table at the start of real_main_after_expansion.
Pass it to later invocations of handle_given_options.
compiler/globals.m:
Include the default option table, as well as the processed option table
(created by handle_given_options from the default table) in the globals
structure. This is so that the parts of the make package that want to
build a new globals structure "from scratch" don't have to redo
the part of the work that is independent of the set of actually specified
options.
compiler/make.build.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
Conform to the changes above.
In some cases, fix misleading variable names.
In make.track_flags.m, add an XXX outlining a possibly better approach
to hashing options for tracking.
library/Mmakefile:
Stop copying a part of getopt_io.m to geteopt.m, because it is
confusing as hell after an automatic edit.
library/getopt.m:
Expect the effect of the change to library/Mmakefile.
compiler/parse_tree_out_sym_name.m:
As a test, implement the output of sym_names, one of the smallest
nonatomic parse tree components, using string builders.
Change the name of the write_X version of the operation
from just write_sym_name to write_escaped_sym_name,
since every component of the sym_name is in fact escaped.
Change the name of the X_to_string version of the operation
from sym_name_to_escaped_string to escaped_sym_name_to_string,
to make the X identical to the write_X version. Change its implementation
to use string builders.
Implement both write_escaped_sym_name and escaped_sym_name_to_string
in terms of the new predicate format_escaped_sym_name.
Add an XXX about a potential problem.
compiler/parse_tree_out_info.m:
Since format_escaped_sym_name calls term_io.format_escaped_string,
it needs to comply with its typeclass constraint. This requires
making the typeclass in the constraint on format_escaped_sym_name,
the "output" typeclass in parse_tree_out_info.m, a superclass of
stream.writer.
However, giving parse_tree_out_info.m access to the stream.writer class
also gives it access to the stream.output class, since they are both
defined in library/stream.m. Avoiding a flood of ambiguity warnings
about output being either stream.output or parse_tree_out_info.output
requires either fully module qualifying all occurrences of the output
typeclass name, or renaming one of the typeclasses. The obvious one
to rename is parse_tree_out_info.output, so this diff renames it to
pt_output (pt being short for "parse tree").
compiler/higher_order.m:
compiler/hlds_out_mode.m:
compiler/hlds_out_module.m:
compiler/hlds_out_type_table.m:
compiler/hlds_out_util.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/parse_tree_out.m:
compiler/parse_tree_out_cons_id.m:
compiler/parse_tree_out_inst.m:
compiler/parse_tree_out_misc.m:
compiler/parse_tree_out_pragma.m:
compiler/parse_tree_out_pred_decl.m:
compiler/parse_tree_out_term.m:
compiler/parse_tree_out_type.m:
compiler/recompilation.check.m:
compiler/source_file_map.m:
compiler/write_deps_file.m:
Conform to the changes above.
compiler/file_names.m:
Take ext_src out of the ext type, because this allows us to delete
the I/O state pair of arguments out of every file translation predicate
other than module_name_to_source_file_name and the ones that create
directories.
compiler/file_kind.m:
Delete the ext output argument of file_kind_to_extension, because
we can't return ext_src for fk_src anymore.
compiler/write_deps_file.m:
Delete a test for ext_src which could never succeed, because the
predicate in question is never called with ext_src.
Undo an accidental change from the diff that introduced
module_name_to_lib_file_name_create_dirs.
Conform to the changes above.
compiler/compile_target_code.m:
compiler/fact_table.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mlds_to_c_file.m:
compiler/mmc_analysis.m:
compiler/module_cmds.m:
compiler/read_modules.m:
compiler/recompilation.used_file.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
compiler/file_names.m:
Split module_name_to_file_name into three versions.
- One corresponds to the old predicate's operation with do_not_create_dirs,
- one corresponds to the old predicate's operation with do_create_dirs, and
- one just returns the directory path, and lets the caller make those
directories if it wants to, using procedures that we now export.
Do the same for module_name_to_lib_file_name.
Do not do the same for fact_table_file_name, which has too few callers
to make it worthwhile.
The point is that the versions that do not create any dirs should NOT
need to take I/O state pairs as arguments, once we take ext_src
out of the ext type.
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/export.m:
compiler/fact_table.m:
compiler/generate_dep_d_files.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/make.util.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/read_modules.m:
compiler/recompilation.used_file.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Update calls to the affected predicates.
In some places, add XXXs about seemingly-strange choices about
what calls create directories and which don't.
compiler/file_names.m:
Delete the old code for doing filename translations, and use
just the new code.
Delete all the code that was needed only for comparing the old and
new code.
Delete the newext_other extension category, since it was also needed
only for that purpose. Delete all the code that supported it.
Switch the infrastructure for recording the demand for translations
to work with the new code.
compiler/analysis.file.m:
Delete functions that returned old-style extensions, which are
not useful anymore. The new-style extensions, by identifying
extensions via enums rather than strings, serve the purpose
for which these functions were created.
compiler/mercury_compile_main.m:
Move the code to call to write out the translation record
from just after a call to real_main_after_expansion to the
end of real_main_after_expansion. The reason is that the
predicate being called now needs access to a globals structure,
real_main_after_expansion has access to a globals structure,
but its caller does not.
Don't try to test the equivalence of the old and new algorithms
for file name translation, since that test code has been deleted.
compiler/analysis.m:
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/export.m:
compiler/fact_table.m:
compiler/file_kind.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/make.util.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_make_hlds.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/prog_foreign.m:
compiler/read_modules.m:
compiler/recompilation.used_file.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the changes in file_names.m.
compiler/make.util.m:
Add verbose_make_N_part_msg predicates, and the more general
option_set_make_N_part_msg predicates, to allow simpler code
to construct progress and informational messages.
Pass to debug_make_msg a message *generator*, instead of a predicate
that *writes out* a message. Make debug_make_msg return the message
(if debug_make is enabled) to be written out (hopefully) to an explicitly
specified stream.
compiler/make.dependencies.m:
Rename the dependency_status predicate to get_dependency_status.
Make it return the original dependency_file, and the filename it
corresponds to, alongside the status, because this is the simplest
way to avoid requiring its callers to reconstruct that information
after their calls to get_dependency_status.
Change the signature of check_dependency_timestamps to expect
the new output of get_dependency_status.
Replace code to write out debugging messages with code to just return
them as a string. Move one of these predicates to just after its caller.
Give some predicates more descriptive names.
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changes above.
In make.program_target.m, add XXXs about progress messages
that end with a period, unlike all the other progress messages.
compiler/make.util.m:
The predicates that handled progress messages in this module
- tested whether the progress message was needed, and if yes,
- first constructed the message,
- and then printed it.
The predicates that handled error messages were similar,
but error messages are always needed.
In most cases, the printing was done to the current *implicit* output
stream.
Code calling these predicates won't get warnings about implicit stream
calls unless every predicate has both implicit and explicit stream
variants.
Make all these predicates do just the first two of the above jobs,
and return a string that may be empty or not. Then require callers
to call one of four new predicates to print out the resulting string
if it is not empty. The four are distinguished along two axes:
implicit vs explicit stream, and locked/unlocked stdout.
Add XXXs about the problems of even this updated approach,
including the one with locking stdout when the output stream,
whether implicitly or explicitly specified, is *not* stdout.
Make the names of all the predicates affected by the above change
end in "_msg". Change some of the names to be more descriptive.
Delete one predicate whose code was identical to that of another.
compiler/make.build.m:
Export the lock/unlock stdout predicates for use by the new predicates
in make.util.m.
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
Conform to the changes above.
compiler/make.program_target.m:
Conform to the changes above.
Give a predicate a less misleading name.
Add an XXX in a place.
compiler/make.util.m:
As above.
compiler/compile_target_code.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
Conform to the changes in make.util.m.
This should allow profiling runs to collect information about the
number of accesses to each field.
compiler/make.make_info.m:
Move the definition of the make_info type from the interface section
to the implementation section. Add getter functions for all its fields,
setter predicates for its writeable fields, and an initialization
function.
Move all the readonly fields to the start of the structure.
Put related fields next to each other.
compiler/make.top_level.m:
Replace the explicit construction of the initial make_info value
with a call to its initialization function.
compiler/make.build.m:
compiler/make.dependencies.m:
compiler/make.deps_set.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/make.util.m:
Replace all accesses to the fields of make_info with calls to the
getter functions or the setter predicates.
... and start using their more descriptively-named synonyms.
In some cases, instead of getting and then reversing a list of sccs,
ask for the sccs in the needed order in the first place.
compiler/dependency_graph.m:
compiler/generate_dep_d_files.m:
compiler/make.program_target.m:
compiler/mlds_to_java_global.m:
compiler/mode_ordering.m:
compiler/rtti_to_mlds.m:
compiler/stratify.m:
As above.
compiler/prog_event.m:
As above.
Address an old and now-inaccurate XXX. When a synthesized attribute
depends on its value, either directly or through the values of other
synthesized attributes, include the names of the attributes involved
in the error message, instead of just saying that there is circular
dependency *somewhere* among the attributes.
tests/invalid/synth_attr_error.err_exp:
Expect the updated, more specific error messages.
tests/invalid/Mmakefile:
Enable the synth_attr_error test case, which wasn't enabled before
(though it does have an entry in Mercury.options.)
tests/invalid/invalid_event_spec:
tests/invalid/syntax_error_event_spec:
tests/invalid/synth_attr_error_spec:
Replace tabs with spaces.
compiler/options.m:
Delete the option.
doc/user_guide.texi:
Delete its documentation.
NEWS.md:
Announce the deletion.
compiler/file_names.m:
compiler/make.program_target.m:
Delete references to the option.
compiler/file_names.m:
Change the argument vectors of the predicates that compute filenames
by taking *two* arguments to specify the extension: adding an argument
value of the "newext" type right after the old "ext" type. To make this
possible, export the newext type.
By default, use the new argument to do every filename computation twice,
with the old and new algorithms, throwing an exception if their results
differ. (There is no easy way to test whether the "make-any-needed-dirs"
part was done the same way, but this is reasonably easy to check
visually in the code.)
In case an exception does get thrown, this can be suppressed (hopefully
after the exception being reported) by setting the environment variable
"NO_EXT_CHECKS" to any value.
Add representations of "get the value of this extension from this option"
style extensions to the newext type, for each of the options that the
compiler uses this way. The one exception is java_object_file_extension,
which was used in this way, but which had no code handling it in
file_names.m.
Add a representation of ".$(EXT_FOR_PIC_OBJECTS)" as a value
to the newext type.
Shorten some function symbol names in the newext type and its components,
to make them easier to fit without excessive line lengths in the modules
listed below.
compiler/analysis.file.m:
compiler/analysis.m:
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/export.m:
compiler/fact_table.m:
compiler/file_kind.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.track_flags.m:
compiler/make.util.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/prog_foreign.m:
compiler/read_modules.m:
compiler/recompilation.used_file.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Pass extensions as ext/newext pairs, not just as exts.
To make this possible, change functions and predicates that returned
just old-style extensions to return new-style extensions as well.
compiler/make.program_target.m:
Pass extensions as ext/newext pairs, not just as exts.
Add an XXX about java_object_file_extension for Julien, since he added
this option (in 2001 :-().
compiler/make.util.m:
Many operations in this module that operate on filenames did not take
those filenames as arguments; instead, they took an argument such as
a target_file from which they *computed* the filename. This meant that
any predicate that called more than one of these operations implicitly
computed the filename more than once. This could be a problem, because
- there are several predicates one can use to compute the filename, but
- there is no guarantee that different operations use the same predicate.
As a first step in fixing this, change the predicates that print
filenames in progress or error messages to take those filenames
as parameters. Delete one of them, target_file_error, because
after this change, it would have become identical to the existing
file_error predicate.
compiler/make.module_target.m:
Require the callers of record_made_target to supply the filename
as well as the target_file from which it is derived.
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
Compute the filename before calling the updated operations in make.util.m
and/or make.module_target.m.
Add "XXX MAKE_STREAM" to places in the code that operate on either
implicit or badly-chosed explicit streams.
compiler/file_names.m:
Document the meaning of the maybe_create_dirs and maybe_search types.
Delete long-obsolete references to .il files.
compiler/make.util.m:
Rename make_remove_target_file to remove_make_target_file, since this
predicate removes target files in Makefiles, and does not "make" anything.
Rename several other predicates in a similar manner, for the same reason.
Add an extra argument to get_file_name and some related predicates
that will allow future conditionally-enabled trace goals in the compiler
to track where the requests for file name translations come from.
compiler/write_deps_file.m:
Factor out some code.
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changes above.
tools/file_name_translation_stats:
Allow for large numbers of file name translations.
compiler/prog_foreign.m:
foreign_language_module_name and foreign_language_file_extension
were both functions with two modes, one of which was semidet.
Since semidet functions violate the law of least astonishment,
turn both into predicates.
Change the semidet mode into det (this has been possible ever since
we deleted the Erlang backend). Then comment out the other mode,
since it has no use left.
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
Update the calls to the affected functions (now predicates).