mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-22 21:03:53 +00:00
de8f79cac3272dbabddd2e072b94de54612276bc
70 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
823de2d37b |
Require warning/info messages to specify an option.
The objective of this step is two-fold:
- to fix --inhibit-warnings, making it shut up all warning
and informational messages; and
- to ensure that it *stays* fixed, even when after new diagnostics
are added.
As part of this fix, this diff adds a whole bunch of new warning
options, in order to control the warnings that previously were
not controlled by any option. (There was no need for new
informational options.)
As it happens, we have long used severity_informational for messages
that did not report any information about the code being compiled,
but to report actions that the compiler was taking. Create a new
option category, oc_report, for the new options that now control
those diagnostics.
---------------------
compiler/error_spec.m:
Change severity_warning and severity_informational to take an option
as as argument. The semantics is that the diagnostic in which
the severity occurs is conditional on that option, meaning that
it is printed only if that option is set to "yes".
Delete the severity_conditional function symbol from the severity
type, since the mechanism just above handles its only use case.
Define subtypes to represent error_specs in a standard form.
compiler/error_sort.m:
Provide operations to convert error specs into their standard form.
Make the sorting operation itself operate on the standard form.
compiler/write_error_spec.m:
Convert error_specs to standard form before writing them out,
in order to avoid duplicating the code for their standardization.
Change the code that writes out error_specs to operate on the
standard form. Implement the test implicit in the warning and
and informational severities in this code.
compiler/error_util.m:
compiler/compiler_util.m:
Delete operations that do not make sense with the new severity type.
---------------------
compiler/options.m:
Add new options to control all the previously-uncontrolled
warning and informational messages.
NEWS.md:
Announce the *public* new options.
compiler/option_categories.m:
compiler/print_help.m:
Add the new option category, and fake-include it in the help text
and the user guide. (The inclusion is fake because none of the
options in the new category are user visible, meaning the section
containing them is not visible either.)
---------------------
compiler/det_infer_goal.m:
Start a severity warning diagnostic with "Warning:"
instead of "Error:".
compiler/mark_trace_goals.m:
Fix an incorrect error message.
compiler/purity.m:
Replace a correct/incorrect color pair with two inconsistent colors,
because there is a reasonable probability of each one being right.
---------------------
compiler/accumulator.m:
compiler/add_clause.m:
compiler/add_mode.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/check_module_interface.m:
compiler/check_type_inst_mode_defns.m:
compiler/check_typeclass.m:
compiler/color_schemes.m:
compiler/common.m:
compiler/convert_import_use.m:
compiler/convert_parse_tree.m:
compiler/dead_proc_elim.m:
compiler/det_check_proc.m:
compiler/det_check_switch.m:
compiler/det_infer_goal.m:
compiler/du_type_layout.m:
compiler/format_call_errors.m:
compiler/grab_modules.m:
compiler/hlds_call_tree.m:
compiler/inst_check.m:
compiler/introduce_parallelism.m:
compiler/make_hlds_error.m:
compiler/make_hlds_warn.m:
compiler/mark_tail_calls.m:
compiler/mark_trace_goals.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mode_errors.m:
compiler/modes.m:
compiler/module_qual.qual_errors.m:
compiler/opt_deps_spec.m:
compiler/options_file.m:
compiler/parse_goal.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/pre_typecheck.m:
compiler/purity.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/simplify_goal.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/split_parse_tree_src.m:
compiler/state_var.m:
compiler/stratify.m:
compiler/style_checks.m:
compiler/superhomogeneous.m:
compiler/table_gen.m:
compiler/term_constr_errors.m:
compiler/term_errors.m:
compiler/termination.m:
compiler/typecheck_clauses.m:
compiler/typecheck_error_overload.m:
compiler/typecheck_error_undef.m:
compiler/typecheck_errors.m:
compiler/typecheck_msgs.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/warn_unread_modules.m:
compiler/write_module_interface_files.m:
Conform to the changes above, mostly by either
- adding an option to all warning and informational messages,
sometimes using existing warning options and sometimes new ones,
or
- turning already explicitly-conditional-on-an-option messages
into implicitly-conditional-on-that-option messages.
---------------------
tests/invalid/one_member.m:
Conform to the change in det_infer_goal.m.
tests/invalid/require_tailrec_1.err_exp:
tests/invalid/require_tailrec_2.err_exp:
Actually obey the options for these modules in Mercury.options.
tests/invalid_purity/purity.err_exp:
tests/warnings/purity_warnings.err_exp:
Conform to the change in purity.m.
tests/warnings/moved_trace_goal.err_exp:
Conform to the change in mark_trace_goals.m.
tests/warnings/help_text.err_exp:
Expect the documentation of all the new options.
|
||
|
|
7034a07641 |
Improve source_file_map.m.
compiler/source_file_map.m:
Ensure that the source_file_map is a bijection both
- when we construct Mercury.modules, and
- when we read it in (after possible modifications by the user).
Report any errors instead of ignoring them, as best we can.
Do not leave that job to our callers, which have less info.
Leave the old Mercury.modules (if any) unchanged if the construction
of its new version finds problems.
Document the fact that the names of nested submodules won't ever
be stored in source file maps.
compiler/file_names.m:
compiler/mercury_compile_main.m:
compiler/read_modules.m:
compiler/xml_documentation.m:
Conform to the changes above.
compiler/parse_module.m:
Fix accidentally-doubled-up word.
compiler/error_spec.m:
Rename some fields to avoid double-defining "error_phase".
|
||
|
|
c43225fc66 |
Stop ignoring errors in the parser.
compiler/read_modules.m:
All the predicates exported by this module for reading in various kinds of
files took an argument that could be used to tell them to ignore fatal
errors. Delete these arguments, and never ignore fatal errors, for
two reasons.
- For all but one of those predicates, all callers always passed
do_not_ignore_errors as the value of this argument anyway.
- For the one predicate where a caller did pass ignore_errors as this
argument, the caller can (and after this diff, does) handle the errors
in a more nuanced and useful fashion.
compiler/deps_map.m:
That one caller is here, and it passed ignore_errors when trying to
read in source files when implementing "mmc --generate-dependencies".
It ignored errors because a module A in the current directory
importing a module B that is NOT in the current directory is not
an error: it can be in another directory of the project, or it can be
in an installed library.
However, the old code also ignored one error it shouldn't have: the
inability to read the module *whose dependencies it was trying to make*.
This is why "mmc --generate-dependencies nonexistent.m" would not
generate any diagnostics. This diff fixes that.
Also, delete an exported predicate that was not called from anywhere.
compiler/module_baggage.m:
Stop nuking error messages before deps_map.m can decide whether to
print them or not. The predicate involved is called from several
places in the compiler, not just deps_map.m, but all those places
*do* want to preserve and print any error messages (I checked).
compiler/make.get_module_dep_info.m:
compiler/mercury_compile_main.m:
compiler/recompilation.check.m:
Conform to the changes above.
|
||
|
|
b9ab5be0a7 |
Document the rest of the PROPOSED search options ...
... and rename "normal" to "interface" in the compiler's code.
doc/user_guide.texi:
Document the rest of the PROPOSED search options.
compiler/options.m:
Change the user-facing names of the PROPOSED search options
to the now-documented names.
Change "normal" to "interface" in these option names.
compiler/file_names.m:
compiler/find_module.m:
compiler/globals.m:
Change "normal" to "interface" in search specifications.
compiler/generate_dep_d_files.m:
compiler/handle_options.m:
compiler/make.get_module_dep_info.m:
compiler/read_modules.m:
Conform to the name changes above.
|
||
|
|
79bfb1247f |
Carve prog_parse_tree.m out of prog_item.m.
compiler/prog_item.m:
compiler/prog_parse_tree.m:
Split prog_item.m into two modules, with the new module prog_parse_tree.m
containing the definitions of the file-kind-specific parse trees,
and prog_item.m continuing to contain the definitions of the items
that occur in those parse trees. Specialize the top-of-module comment
to the current contents of each module.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new module.
compiler/*.m:
Conform to the changes above.
|
||
|
|
2ef23c5c31 |
Start on search paths for PROPOSED dir structures.
The new code added by this diff is not yet used.
compiler/options.m:
Add three new options that do for the PROPOSED directory structure
what the existing --intermod-directories option does for the LEGACY
directory structure. Once the approach they represent (which is documented
in handle_options.m) is agreed, we will apply the same approach
to the other options that specify directory search paths for mmc
(as opposed to e.g. the C compiler).
compiler/globals.m:
While the legacy approach uses a single search path for files with
several different extensions, and appends extension-specific subdir paths
to each directory in the search path on demand, the proposed approach
effectively precomputes the results of such appends for each extension
that uses each given kind of search path. Add a slot to the globals
structure for storing these paths.
compiler/handle_options.m:
Fill in the this new field of the globals structure with
extension-specific directory lists, initially only for the options
that replace --intermod-directories.
compiler/file_names.m:
Export two predicates for use by the new code in handle_options.m.
They are here because their code needs to be maintained together with
other predicates in this module.
Delete the option_table field from search dir specifications.
They turn out not to be needed, because every place in the compiler
that processes values of this type already has access to that info.
compiler/find_module.m:
Record both the globals structure and the extension to be searched for
in the intermod and related search authorizations, since both of these
are now needed to select the right directory list from the new field
in the globals structure.
compiler/make.get_module_dep_info.m:
compiler/mercury_compile_front_end.m:
compiler/mmc_analysis.m:
compiler/read_modules.m:
compiler/write_deps_file.m:
Conform to the changes above.
|
||
|
|
86fc0e526e |
Check what files can be searched for where ...
... (mostly) in one place.
compiler/file_names.m:
Change the module_name_to_search_file_name predicate to
- take as input a specification of where the caller intends to search for
the file name returned by this predicate (the new search_which_dirs
input argument),
- use insts to check, at compile time, whether this specification
is compatible with the extension of the file (by intentionally causing
the call to have a mode error if they are not compatible),
- if they are compatible, return a "search authorization" that contains
the information in the search_which_dirs argument in a form that
should be known *only* to file_names.m (which issues the authorization)
and find_module.m (which acts on such authorizations).
To make the above possible, move the search_which_dirs type here
from find_module.m, move many insts on the ext type here from several
other modules, and add some new insts on that type.
Improve documentation.
compiler/find_module.m:
Delete the search_which_dirs type that this diff moves to file_names.m.
Add in its place the search_auth_dirs type, which represents search
authorizations. Make all predicates in this module take search
authorizations instead of search specifications as inputs.
The difference is that only the module_name_to_search_file_name
predicate in file_names.m, and a few functions in this module,
generate search authorizations that involve references to the
various options containing lists of directory names.
compiler/make.file_names.m:
Replace predicates that take a maybe_for_search argument with two
predicates each, one for not for search and one for search. This is
because the for search versions now take two extra arguments:
a search_which_dirs input argument and a search_auth_dirs output argument.
Factor out the common code from the resulting predicate pairs
where this is worth while.
Improve documentation.
compiler/make.timestamp.m:
Replace predicates that take a maybe_for_search argument with two
predicates each, one for not for search and one for search. This is
because the for search versions and the not_for_search versions
now call different predicates, and two separate predicates ends up
being less code that tests around all the calls.
Factor out the common code from the resulting predicate pairs
where this is worth while.
Delete the code that specifies the default list of directories
in which to search for files with given extensions, since it is now
in file_names.m (in a modified form).
compiler/analysis.framework.m:
Delete the inst definitions that this diff moves to file_names.m.
compiler/compile_target_code.m:
compiler/file_kind.m:
Provide more precise insts for the outputs of some predicates.
This is because some of their callers need those insts to satisfy
the new requirements of module_name_to_search_file_name.
compiler/make.top_level.m:
Add a note.
compiler/read_modules.m:
Conform to the changes above. Split the handling of source files
(which do not require search) from the handling of .int* and .*opt files
(which do).
compiler/analysis.file.m:
compiler/check_libgrades.m:
compiler/make.check_up_to_date.m:
compiler/make.get_module_dep_info.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/mercury_compile_front_end.m:
compiler/mmc_analysis.m:
compiler/options_file.m:
compiler/write_deps_file.m:
Conform to the changes above.
|
||
|
|
38e8789dda |
First steps towards checking file searches.
For any given extension, only one or two kinds of searches (meaning,
sources of list of directories to search) make sense. We want the type system
to help us ensure that we never ask for a combination that does not make
sense. This diff is a step towards that.
compiler/analysis.framework.m:
compiler/mmc_analysis.m:
Specify an inst for the extensions used by analysis framework.
Restrict the operations of the framework to work on just these extensions.
compiler/analysis.file.m:
compiler/analysis.operations.m:
Restrict read and write operations to just the extensions
used by the analysis framework.
Add an XXX.
compiler/file_names.m:
Add a predicate to return just the base filename (i.e. the filename
in the current directory) corresponding to a module name + extension.
compiler/mercury_compile_llds_back_end.m:
compiler/mlds_to_c_file.m:
Use that predicate to avoid calling module_name_to_search_file_name
with extensions that *always* would get the base name returned anyway.
compiler/find_module.m:
Add an inst for the set of search kinds that make sense for
a significant number of extensions.
compiler/make.get_module_dep_info.m:
Use that new inst to restrict some search operations to just those
search kinds.
compiler/read_modules.m:
Fix bitrot in a comment.
|
||
|
|
31f9d5034e |
Move a predicate next to its only call site.
compiler/source_file_map.m:
Move a predicate here from find_module.m. Give it a more meaningful name.
Replace a bool with a more appropriate type.
compiler/find_module.m:
Delete the predicate moved to source_file_map.m.
compiler/generate_mmakefile_fragments.m:
compiler/read_modules.m:
Conform to the changes above.
|
||
|
|
fbec9830a9 |
Centralize file searches in find_module.m.
The aim is to move all to this one place almost all the code that will
have to be updated to handle searches in the PROPOSED installed library
structure, first alongside and later in place of, searches in the LEGACY
structure. (Some code in handle_options.m, options.m and check_libgrades.m
will need to be updated as well.)
compiler/find_module.m:
Change the predicates of this module to take as input not a list of
directories to be searched, but a *specification* of how that list
should be computed. (Eventually, it should be possible to derive
this specification from the extension of the file name in most or
possibly even all cases, but that is future work.)
compiler/options.m:
Fix a misleading internal option name. (The user-facing name is
not misleading.)
compiler/maybe_error.m:
Add another purpose-specific synonym for bool, for use in changes below.
compiler/check_libgrades.m:
compiler/compile_target_code.m:
compiler/generate_dep_d_files.m:
compiler/handle_options.m:
compiler/make.check_up_to_date.m:
compiler/make.get_module_dep_info.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_main.m:
compiler/mmc_analysis.m:
compiler/options_file.m:
compiler/read_modules.m:
compiler/source_file_map.m:
compiler/write_deps_file.m:
Instead of computing lists of directories to pass to the predicates
of find_module.m, pass a specification.
Add "XXX SEARCH_ERROR" markers to code that should include more info
in error messages about failed searches.
|
||
|
|
3b3b543a84 |
Return both legacy and proposed file names.
compiler/file_names.m:
Change the predicates that return file names to return as their result
both the current, legacy filename, and the proposed filename.
For ext_cur extensions, the legacy and the proposed filenames
will always be identical. Add a predicate for these that returns
just this one filename.
compiler/comp_unit_interface.m:
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/export.m:
compiler/fact_table.m:
compiler/generate_dep_d_files.m:
compiler/generate_mmakefile_fragments.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.check_up_to_date.m:
compiler/make.clean.m:
compiler/make.dependencies.m:
compiler/make.file_names.m:
compiler/make.get_module_dep_info.m:
compiler/make.library_install.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
compiler/make.track_flags.m:
compiler/make.util.m:
compiler/make_module_file_names.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:
Conform to the changes above. In most places, this means ignoring
the proposed filename for now, but marking such places with "XXX LEGACY",
to make them easier to find when we *do* start to make use of the proposed
file names (first alongside the legacy names, and then without them).
In some places, make variable names more descriptive.
library/set.m:
Add utility predicate for use by a diff to one of the modules above.
NEWS.md:
Announce the new library predicate.
|
||
|
|
386160f937 |
s/dont/do_not/ in the compiler directory.
compiler/*.m:
Standardize on the do_not spelling over the dont contraction
in the compiler directory. (We used to have a lot of both spellings.)
|
||
|
|
8267c2cc22 |
Move actually_read_module_X to read_modules.m.
compiler/parse_module.m:
compiler/read_modules.m:
As above. The original versions of actually_read_module_{src,int,opt}
interleaved reading in characters from a file with parsing the file,
which is why keeping them in parse_module.m made sense. But now that
those predicates just read the whole file into a string, and hand
that string off to be parsed, that is not true anymore.
Export parse_src_file, since the move of actually_read_module_src
now requires this. Simplify its interface.
Stop exporting a type that does not need to be exported.
|
||
|
|
dc12878708 |
Shorten function symbols in error_specs.
compiler/error_spec.m:
Replace simplest_spec with spec, and simplest_no_context_spec with
no_ctxt_spec. These are now the most frequently used function symbols
to create error specs, so their name should not make them out to be
the exception.
Replace simplest_msg with msg, and simplest_no_context_msg with
no_ctxt_msg for the same reason.
Abbreviate some of the long phase names.
compiler/*.m:
Conform to the changes above. Most of these changes were done by a script,
with minor manual tidying up, which consisted mostly of fitting code
constructing error specs onto fewer lines than before.
|
||
|
|
4cd5c17f61 |
Fix more copyright notices ...
... and other minor fixes.
library/*.m:
library/LIB_FLAGS.in:
compiler/*.m:
mdbcomp/*.m:
Fix and update copyright notices.
Fix spelling.
Delete trailing whitespace.
|
||
|
|
d8a78ef682 |
Separate reading in a file from parsing it.
compiler/parse_module.m:
Replace do_actually_read_module, which read in a file from a stream
and immediately parsed the resulting string with a supplied parser,
with do_actually_read_file, which just reads in the file and returns
the resulting string, leaving the parsing to its callers. We will
need this separation to allow the string we read in from the current
version of a .intN or .*opt file to be compared against the string form
of the intended *next* version.
Move the responsibility of closing the stream from do_actually_read_file
to its ancestor which actually opened the stream.
Add a comment about a possible improvement on UTF-16 platforms.
compiler/read_modules.m:
Add the code to close streams in the predicates that open them.
Merge two switches on the same variable into one.
compiler/find_module.m:
Replace two types that could contain *either* a full path filename
*or* a directory name, but *without* saying which it contains, with
three types that each say explicitly which they contain. Replace
all uses of the old types with the appropriate new type.
The new code in parse_module.m now gets the file name from a slot
that is now certain to contain the file name we want, and not just
its directory part.
compiler/make.get_module_dep_info.m:
Conform to the change in find_module.m.
|
||
|
|
d394cfc7a5 |
Rename have_read_module_maps to have_parse_tree_maps ...
... 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.
|
||
|
|
191eb9eb64 |
Make --generate-dependencies-ints more practical.
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.
|
||
|
|
e1e5480f16 |
Eliminate calls to io.output_stream in read_modules.m.
compiler/read_modules.m:
When invoked to read a file specified by file name (as opposed to
by module name), the code of this module wrote out progress messages
to the current output stream, as returned by io.output_stream.
Fix this by consistently requiring the ancestors of the predicates involved
to pass an explicit stream to write progress messages to.
The interfaces of some of the exported predicates allowed their callers
to either pass a progress stream or not; if they didn't, this prevented
the generation of any progress messages with -v and the generation of
any statistics with -S. Most callers did specify the progress stream;
the main parts of the compiler that did not were
- the code that read the old versions of interface files in order to see
whether the new version was identical to it, or not, and
- the intermodule analysis framework.
This diff requires callers to always pass a progress stream, because
we *always* want to write out any error messages about nonexistent
or unreadable files, and we don't want to write these to an implicitly
specified file. We *could* add a parameter to the affected predicates
to shut up progress messages and statistics for use at the call sites
that previously passed us "no" as the maybe progress stream argument,
but I see no reason why one wouldn't want -v and -S to work as usual
in these above circumstances. If anyone ever finds such a reason,
there is a simpler fix anyway: turning off -v and -S in the globals
passed along next to the progress stream.
compiler/module_cmds.m:
Stop requiring an error stream and as well as a progress stream
when touching files. If the two streams were ever different, the
output would have looked strange, as the error message would NOT follow
the progress message announcing the operation that failed.
compiler/analysis.m:
compiler/deps_map.m:
compiler/generate_dep_d_files.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/recompilation.check.m:
compiler/write_module_interface_files.m:
Conform to the changes above, mostly by passing along
an explicit progress stream.
|
||
|
|
8688aeed25 |
Don't print parse errors separately.
compiler/read_modules.m:
Instead of printing out all parse errors immediately after parsing,
return them to the caller to be printed later, possibly with other
errors.
This should avoid the need to pass the error stream to read_modules.m.
|
||
|
|
87177049bf | Reorder exported preds to put callers before callees. | ||
|
|
d5c54ce697 |
Take ext_src out of the ext type.
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.
|
||
|
|
89979d681a |
Replace Mkdir parameters with predicate versions.
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.
|
||
|
|
6517982c87 | s/newext/ext/g and s/NewExt/Ext/g. | ||
|
|
0b60f07c46 |
Cut over to the new code in file_names.m.
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.
|
||
|
|
edeb58bc16 |
Start using the new code in file_names.m.
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 :-().
|
||
|
|
6f82724091 |
Pass streams explicitly at the top levels.
compiler/mercury_compile_main.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:
Pass progress and error streams explicitly in these top modules
of the compiler. Use "XXX STREAM" to mark places where we could switch
from using stderr for both the progress and error streams to using
module-specific files as the progress and/or error streams.
compiler/passes_aux.m:
Add a "maybe_" prefix to the names of the predicates that print progress
messages at the appropriate verbosity levels, as their printing of those
messages is conditional.
Provide versions of those predicates that take explicitly specified
streams to write to, and mark the versions that write to the current
output stream as obsolete.
The predicate that wrote progress messages for procedures
used to have two versions, one taking a pred_proc_id, and one taking
a pred_id/proc_id pair. Delete the latter, because the arity difference
that differentiated the two versions is now needed for the difference
between supplying and not supplying an explicit stream.
compiler/file_util.m:
compiler/hlds_error_util.m:
compiler/write_error_spec.m:
Delete several predicates that wrote to the current output stream,
since all their callers now use the versions that specify an explicit
output stream.
compiler/check_promise.m:
compiler/check_typeclass.m:
compiler/closure_analysis.m:
compiler/complexity.m:
compiler/cse_detection.m:
compiler/deforest.m:
compiler/delay_construct.m:
compiler/delay_partial_inst.m:
compiler/deps_map.m:
compiler/direct_arg_in_out.m:
compiler/grab_modules.m:
compiler/handle_options.m:
compiler/hhf.m:
compiler/inlining.m:
compiler/make.module_dep_file.m:
compiler/ml_proc_gen.m:
compiler/ml_top_gen.m:
compiler/mode_constraints.m:
compiler/modes.m:
compiler/polymorphism.m:
compiler/purity.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/saved_vars.m:
compiler/simplify_proc.m:
compiler/size_prof.m:
compiler/stack_opt.m:
compiler/switch_detection.m:
compiler/typecheck.m:
compiler/unique_modes.m:
compiler/unneeded_code.m:
compiler/write_module_interface_files.m:
Get these modules to take an explicitly specified stream to which
to write progress messages when they are invoked from mercury_compile_*.m.
For predicates in these modules that can be invoked both directly
by mercury_compile_*.m *and* by other modules, the latter effectively
as a subcontractor, make them take a maybe(stream), with the intention
being that all the other modules that use the predicate as a subcontractor
would pass a "no". This avoids the need to pass progress streams
down to the internals of other passes, and also avoids overwhelming
the user invoking the compiler with unnecessary details.
As above, and also delete a progress message that shouldn't be needed
anymore.
Move a test of option value compatibility from
mercury_compile_middle_passes.m to handle_options.m, where it belongs.
compiler/float_regs.m:
Write a debug message to the debug stream.
compiler/pd_info.m:
Include the progress stream in the pd_info structure, because this is
the simplest way to ensure that all parts of the partial deduction pass
have access to it.
compiler/make.build.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
Make the minimal changes needed to conform to the changes above.
The rest can be done when the make package is converted to consistently
use explicit streams.
compiler/bytecode_gen.m:
compiler/structure_reuse.direct.m:
compiler/structure_reuse.versions.m:
compiler/structure_sharing.analysis.m:
Make the minimal changes needed to conform to the changes above.
The rest can be done when these modules start being maintained again.
compiler/Mercury.options:
Stop specifying --no-warn-implicit-stream-calls for mercury_compile_*.m,
since this diff makes that unnecessary.
Start specifying --no-warn-implicit-stream-calls for some modules that
are not currently being actively maintained, because the addition of
progress-reporting predicates that take explicitly specified streams
would otherwise cause the generation of such warnings for them.
|
||
|
|
307b1dc148 |
Split up error_util.m into five modules.
compiler/error_spec.m:
This new module contains the part of the old error_util.m that defines
the error_spec type, and some functions that can help construct pieces
of error_specs. Most modules of the compiler that deal with errors
will need to import only this part of the old error_util.m.
This change also renames the format_component type to format_piece,
which matches our long-standing naming convention for variables containing
(lists of) values of this type.
compiler/write_error_spec.m:
This new module contains the part of the old error_util.m that
writes out error specs, and converts them to strings.
This diff marks as obsolete the versions of predicates that
write out error specs to the current output stream, without
*explicitly* specifying the intended stream.
compiler/error_sort.m:
This new module contains the part of the old error_util.m that
sorts lists of error specs and error msgs.
compiler/error_type_util.m:
This new module contains the part of the old error_util.m that
convert types to format_pieces that generate readable output.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new modules.
compiler/error_util.m:
The code remaining in the original error_util.m consists of
general utility predicates and functions that don't fit into
any of the modules above.
Delete an unneeded pair of I/O states from the argument list
of a predicate.
compiler/file_util.m:
Move the unable_to_open_file predicate here from error_util.m,
since it belongs here. Mark another predicate that writes
to the current output stream as obsolete.
compiler/hlds_error_util.m:
Mark two predicates that wrote out error_spec to the current output
stream as obsolete, and add versions that take an explicit output stream.
compiler/Mercury.options:
Compile the modules that call the newly obsoleted predicates
with --no-warn-obsolete, for the time being.
compiler/*.m:
Conform to the changes above, mostly by updating import_module
declarations, and renaming format_component to format_piece.
|
||
|
|
7b6bace9ec |
Don't return dummy parse_trees for missing files.
The predicates that read a Mercury source, interface or optimization file
used to return four things:
- the name of the file (for callers who specified only a module name),
- the timestamp, if requested and available,
- a parse tree, and
- a representation of any errors (sets of error categories, and error_specs).
However, these four things were not independent. Some combinations of their
values were not allowed, but (a) there was no documentation of what these
combinations were, and (b) code that processed these four things had to be
prepared to handle illegal as well as legal combinations.
This diff makes these predicates return only one result, which contains
- all four of the above things, when the file could be opened, but
- only the file name and a representation of the error if the file
could not be opened,
- only the file name and a representation of *no* errors, if the caller
asked the predicate to read the file only if its timestamp did not match
a specified value, and it does match that value.
We use a somewhat modified version of an existing type, have_read_module,
for this. It is modified both by including information that its users
now need that they did not need before, and shortening the names of its
function symbols, which now occur in many more places than before.
compiler/read_modules.m:
Make the change to the output arguments described above.
Making this change requires having the affected predicates deal with
the case where we either cannot find or cannot open the relevant file.
(The two are effectively the same thing in this module, since we search
by attempting to open.) Passing that task off to parse_modules.m
was always inelegant.
Simplify the have_read_module_map type by making the key always
be a module_name. We deleted the only use of have_read_module_maps
with another kind of key a while ago.
Delete some no-longer-needed predicates.
compiler/parse_module.m:
Delete the code dealing with the absence of a file stream to parse.
Replace code that used to construct dummy parse trees with code
that simply returns *no* parse tree if the file could be opened
but could not be read, or if its timestamp indicated that reading it
would have been redundant.
Delete some utility predicates moved to parse_error.m, so that
read_modules.m could also use them.
Fix comment rot.
compiler/parse_error.m:
Add some utility predicates for use by read_modules.m and parse_module.m.
compiler/deps_map.m:
Conform to the changes above.
Document the dubious effects of an old design decision.
Fix a misleading predicate name.
Fix comment rot.
compiler/grab_modules.m:
Conform to the changes above.
Some predicates used to return parse trees that could be dummies.
Change them to return just the parts of the parse tree that the
caller was interested in, which was usually a tiny part, and which
can be constructed trivially even when we don't have a parse tree.
Delete an unneeded type.
compiler/recompilation.check.m:
Conform to the changes above.
Represent the operations we need to test version numbers in interface files
as a typeclass, and rewrite the checking operation in terms of that
typeclass, with one instance for each kind of interface file.
Move some repeated code into a predicate.
Shorten some long names.
compiler/mercury_compile_main.m:
Conform to the changes above.
Break up a large predicate.
compiler/generate_dep_d_files.m:
compiler/make.module_dep_file.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
compiler/prog_item.m:
Delete the parse_tree_some_int type. The change in recompilation.check.m,
deleted its last few uses there, and allowed the deletion of the last
uses in read_modules.m.
tests/recompilation/two_module_debug:
Extend this script to help deal with problems in all stages of the
execution of a test case, since that was required while debugging
this diff.
Document which parts of this script correspond to which parts of
two_module_test.
tests/recompilation/test_functions:
tests/recompilation/two_module_test:
Simplify the logic of the main test function, by testing a condition
once instead of three times.
Specify whether a recompilation test is expected to succeed or fail
directly, using alternatives that model a bespoke type, instead
of alternatives that mimic a boolean answer to a question, which
does not help readers who don't remember the question.
Always put shell variable names in braces.
Note a problem that makes one of the shell functions ineffective.
tests/recompilation/Mmakefile:
Tell two_module_test what to do using its updated interface.
|
||
|
|
94affaec76 |
Separate fatal and nonfatal module reading errors, ...
... and bundle sets of error kinds and their associated lists of error_specs
into a single structure.
compiler/parse_error.m:
Use separate types to represent fatal errors and nonfatal errors,
because those two kinds of errors are often treated differently.
Change the read_module_errors type, which used to be just a set of errors,
to being a set of fatal errors, a set of nonfatal errors, the error
message for each, and error messages for warnings. This preserves
distinctions that we should be able to use in the future to improve
error handling.
Provide utility routines for operating on this now-structured type.
compiler/parse_types.m:
Change the definition of the item_or_marker type slighly to preserve
distinctions that the read_module_errors type now cares about.
compiler/parse_module.m:
Thread the new read_module_errors structure through the predicates
that parse source, interface and optimization files.
Treat the failure of reading the contents of a file as a fatal error.
Previously, we treated it as a nonfatal error.
Delete some fields from types when those field were always set to the
same value, and therefore contained no useful information.
compiler/module_baggage.m:
Switch to using the new read_module_errors structure in module baggage.
compiler/grab_modules.m:
Conform to the changes above.
Use a bespoke type to represent the absence/presence of errors
when reading in optimization files.
compiler/mercury_compile_make_hlds.m:
Conform to the changes above.
Delete a call to pre_hlds_write_out_errors that duplicates
another call a few lines above.
compiler/deps_map.m:
compiler/generate_dep_d_files.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile_main.m:
compiler/parse_item.m:
compiler/parse_pragma.m:
compiler/parse_type_defn.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
|
||
|
|
d5a1ca5902 |
Report an error using an error_spec.
Make a nested switch explicit. |
||
|
|
b9908ddaf6 |
Standardize messages about reading files.
compiler/read_modules.m:
When reading in Mercury source files, interface files or optimization
files, we optionally generate progress messages of the form
% Reading module xyz... done.
But the form of these messages has not been consistent, so that
when reading .opt files, we got messages of the form
% Reading xyz.opt...
% Done.
And we sometimes got messages such as
% Reading .int file for module xyz.int... done.
This is mostly because responsibility for constructing these messages
has been dispersed; different parts of it were generated in different
places, and sometimes when one place switches to a new scheme, not all
the corresponding places where updated accordingly.
This diff changes that by constructing these messages in two predicates
(output_read_msg and output_read_done_msg) in this module, leaving to
callers only a choice between a set of four message forms.
To make this possible, move the read_module_{plain,trans}_opt predicates
here from grab_modules.m. Their equivalents for reading Mercury source
files and interface files were here already, so here is where they belong.
Add several "XXX CLEANUP" markers for future changes.
compiler/parse_module.m:
Do not expect callers to compute the filenames containing .opt
and .trans_opt files, since the code here already does that.
compiler/grab_modules.m:
Delete the predicates moved to read_modules.m (under new names, to fit in
with the predicates already there).
Delete some obsolete comments.
Fix some old variable names.
compiler/deps_map.m:
compiler/generate_dep_d_files.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile_main.m:
compiler/recompilation.check.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
|
||
|
|
3a1d21cc3a |
Move parse_tree_opt to convert_parse_tree.m.
compiler/prog_item.m:
compiler/convert_parse_tree.m:
Move the parse_tree_opt type from prog_item.m to convert_parse_tree.m,
because it is now used only as an intermediate step in parse_module.m.
compiler/read_modules.m:
Delete an unused field that used to contain parse_tree_opts.
compiler/mercury_compile_main.m:
Delete a now-unneeded import.
|
||
|
|
6622e5fbb9 |
Process parse_tree_int[012], not parse_tree_int.
compiler/recompilation.version.m:
Compute version numbers for parse_tree_int[012], not parse_tree_int.
Group gathered items and gathered instances into a single type.
Change argument lists to consistently put old things (gathered items,
gathered instances, version numbers) before new.
compiler/write_module_interface_files.m:
Compare new version numbers vs old for parse_tree_int[012],
not parse_tree_int.
compiler/prog_item.m:
Move the parse_tree_int type to convert_parse_tree.m, since now
it is used only by the parser, which them immediately converts
the generic parse_tree_int to parse_tree_intN for the required N.
compiler/convert_parse_tree.m:
Move the parse_tree_int type here.
Delete the predicates that convert parse_tree_int[0123] to parse_tree_int,
since they are not needed anymore.
compiler/parse_module.m:
compiler/read_modules.m:
Delete the predicates that read in parse_tree_int,
since they are not needed anymore.
|
||
|
|
f1927afe0b |
Break a source file info parse_tree_module_srcs ...
... instead of into raw_compilation_units. Besides being more convenient to
work on, a parse_tree_module_src encodes in its type a significant number
of invariants that a raw_compilation unit does not.
compiler/split_parse_tree_src.m:
Immediately after creating a raw_compilation_unit for one of the modules
in a potentially multi-module source file, convert it to a
parse_tree_module_src.
Fix an old problem that can come up in contrived erroneous code.
Specifically, when a submodule is both nested inside its parent module,
*and* it also has an explicit include_module declaration, we used to
record the contexts of both "inclusions", after generating an error
message. The more rigorous checking that later code now does on the
resulting inclusion map would look at this "duplicate inclusion"
and generate *another* error message. To avoid this redundant message,
do not record the contexts of erroneous inclusions for which a message
has already been generated.
compiler/grab_modules.m:
Operate on parse_tree_module_srcs instead of raw_compilation_units.
This allows us to avoid having code for doing what converting the
raw_compilation_unit to a parse_tree_module_src has already done.
In fact, that conversion code does a better job. The old code assumed
that all implicitly available modules are used in the interface,
whereas in fact only some should be used in the interface, with
the rest being used in the implementation section.
compiler/module_imports.m:
Make the predicates that create module_and_imports structures
take a parse_tree_module_src instead of a raw_compilation_unit
as input. For now, we convert the parse_tree_module_src back to
a raw_compilation_unit for further processing, but I intend
a later diff to change this. Nevertheless, one immediate change
is that init_module_and_imports now stores the *actual*
parse_tree_module_src in the module_and_imports structure,
not a dummy.
compiler/prog_item.m:
Do not include a list of foreign_enum items in the interface section
of a parse_tree_module_src, since such items are not allowed to occur
in interface sections.
For the same reason, delete the field for foreign_enums in the interface
sections of .int0 and .int files.
compiler/check_raw_comp_unit.m:
Operate on parse_tree_module_srcs instead of raw_compilation_units.
compiler/comp_unit_interface.m:
Operate on parse_tree_module_srcs instead of raw_compilation_units.
Do not expect any foreign_enum items in interface sections, since
they are not allowed there.
compiler/read_modules.m:
Provide a mechanism to remember having read a parse_tree_module_src.
compiler/write_module_interface_files.m:
Operate on parse_tree_module_srcs instead of raw_compilation_units.
compiler/get_dependencies.m:
Add a new version of an existing utility predicate. The old one operated
on raw item lists, the new one operates on parse_tree_module_srcs.
To make this possible, factor out the code pieces that operate on
each non-ignored kind of item.
compiler/item_util.m:
Add some new utility predicates/functions.
compiler/convert_parse_tree.m:
Conform to the change in prog_item.m. (We already generated an error
message for a foreign_enum item in the interface, but still passed around
a list of foreign_enum items that was guaranteed to be stay empty.)
compiler/make.module_dep_file.m:
Conform to the changes above.
Use explicit streams in one place.
Do not pass an unneeded argument.
compiler/check_parse_tree_type_defns.m:
compiler/equiv_type.m:
compiler/make_hlds_separate_items.m:
Conform to the change in prog_item.m.
compiler/mercury_compile_main.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.qualify_items.m:
compiler/parse_tree_out.m:
Conform to the changes above.
library/map.m:
library/tree234.m:
Add foldl6, foldl6_values and foldr6 predicates. An earlier version
of this diff needed foldl6, and I added the others for symmetry.
NEWS:
Announce the new library predicates.
tests/invalid/bad_mutable.m:
Export something, to avoid a warning about not exporting anything.
tests/invalid_submodules/duplicate_module.m:
tests/invalid_submodules/duplicate_module_test.m:
Update programming style.
|
||
|
|
ff67e2a757 |
Don't use parse_tree_int in recompilation.check.m.
We would strongly prefer representing interface files using
file-kind-specific parse trees, but smart recompilation has not yet been
converted to use them. This diff is a start on fixing that.
compiler/prog_item.m:
Define a type that can represent the parse tree of any kind of interface
file *without* losing any file-kind-specific information.
compiler/read_modules.m:
Define a predicate that can read in any kind of interface file
and return its contents using the new representation.
compiler/recompilation.check.m:
Start using the above new functionality. While the old code required
e.g. wrapping up each type definition item in an interface file parse tree
in a generic item wrapper, putting it in an item list, putting that
into an item block, and then later traversing a list of item blocks,
traversing lists of items, and switching on the kind of each item.
Almost all of that work was wasted. The new code is much more direct,
and traverses only the relevant kinds of items.
|
||
|
|
bd8569fffb | Clarify the relationship between two predicates. | ||
|
|
2e951421dd |
Replace some bools with bespoke types.
compiler/globals.m:
compiler/write_module_interface_files.m:
As above.
compiler/error_util.m:
compiler/handle_options.m:
compiler/mercury_compile_main.m:
compiler/read_modules.m:
Conform to the changes in globals.m.
In mercury_compile_main.m, add an XXX.
|
||
|
|
c2f92d5454 |
Partition extensions into ".m" and "all others".
This is a first step towards a much finer grained partition.
compiler/file_names.m:
Split the ext type into ext_src and ext_other, as mentioned above.
Add the first predicate for checking whether a string falls into
a given category of extensions.
Add an XXX proposing a better solution for an old problem that does not
actually arise in practice.
compiler/compile_target_code.m:
Split the two-moded predicate maybe_pic_object_file_extension into
two separate one-mode predicates, one for each old mode. The
implementations of the two modes were already separate, because
the two modes already did different jobs: while one went from PIC
to an "extension", the other went from an "extension string" to PIC.
Until now, "extension" and "extension string" were equivalent;
after this diff, they aren't anymore.
Delete an unused argument.
compiler/make.util.m:
Split the two-moded predicate target_extension into
two separate one-mode predicates, one for each old mode,
for the same reason as maybe_pic_object_file_extension above:
the fact that "extension" and "extension string" are now distinct.
compiler/options_file.m:
Move debug infrastructure here from mercury_compile_main.m, to help
debug possible problems with options files. (I had such a problem
while writing this diff.)
Improve how progress messages are printed.
compiler/options.m:
Make an error message more useful.
compiler/mercury_compile_main.m:
Add infrastructure for debugging possible problems with command lines.
(I had such a problem while writing this diff.)
compiler/analysis.m:
Conform to the changes above. Put the arguments of some methods
into the same order as similar predicates in file_names.m.
compiler/find_module.m:
Conform to the changes above. Delete an unused argument,
compiler/analysis.file.m:
compiler/du_type_layout.m:
compiler/elds_to_erlang.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.deps_set.m:
compiler/make.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.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.check.m:
compiler/recompilation.usage.m:
compiler/source_file_map.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
|
||
|
|
52c0919975 |
Make filename extensions a separate type, ...
... to allow later changes to its definition.
compiler/file_names.m:
We used to represent filename extensions simply as strings. This meant
all calls to the predicates in file_names.m that convert module names
to file names with various suffixes had to go through a complicated
sequence of tests that effectively partition the extensions into
several classes, with all extensions in a class being treated the same
but different classes being treated differently. And since this general
translation process is quite convoluted (which is not helped by it
being spread across several predicates), it is very hard to construct
a correctness argument for it.
It would be better to represent the different classes of extensions
explicitly, in a du type, with each function symbol of that type
representing all the extensions in the corresponding class (in the sense
of the paragraph above). However, getting there in one diff would make
that diff far too hard to test and to review. So this first diff
starts by simply making extension a notag type.
The above is the first step in implementing one old XXX. This diff
fully implements another old XXX, which is to make the argument order
of several predicates friendly to higher order code.
Add infrastructure for profiling how often this code makes directories.
Delete an unused type.
Add comments outlining proposed future improvements.
compiler/analysis.file.m:
compiler/analysis.m:
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/elds_to_erlang.m:
compiler/export.m:
compiler/fact_table.m:
compiler/file_kind.m:
compiler/find_module.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.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_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/module_imports.m:
compiler/parse_tree_out.m:
compiler/prog_foreign.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the change to file_names.m.
Consistently use "Ext" for the abstract representation of extensions
and "ExtStr" for their string representation.
In a few places, add "XXX EXT" where the code manipulates extensions
as strings in a way that potentially inferferes with the partition
of extensions into classes.
In a few places, rename predicates to avoid ambiguities. factor out
common code, delete unneeded arguments, replace bools with bespoke types,
and make similar minor improvements.
In a few places, remove rafe-isms, such as the use ^elem.
|
||
|
|
733d20ba36 | Fix bit-rot in comments. | ||
|
|
ac466a3531 |
Avoid almost all conversions to parse_tree_int.
For a while now, we have been generating interface files into
file-kind-specific parse trees, but we then converted those into
the generic parse_tree_int type for further processing, because
the old code for doing that further processing operated on
parse_tree_ints. This diff replaces most of that "further processing"
code with code that operates on int-file-kind-specific parse trees,
thus avoiding the cost of conversion. The main cost is not performance
(the effect of this change on compiler speed is negligible), but loss
of code clarity through the loss of invariants.
compiler/comp_unit_interface.m:
After generating a parse_tree_intN for N in {0,1,2,3}, do NOT convert it
to a generic parse_tree_int.
When constructing a parse_tree_int3 from a raw_compilation_unit,
guard against a situation where we could unintentionally create
a duplicate of an abstract type definition. The solution here
is not the most elegant possible, but a better one requires other
changes that don't really fit in this diff.
compiler/canonicalize_interface.m:
Put two large blocks of code (dealing with the canonicalization
of pred and mode declarations respectively) into their own predicates.
Expose a mechanism to standardize not the contents of a whole
interface file, but just the predicate and mode declarations in it.
(These are the tricky kinds of items to canonicalize, because sorting
a set of mode declarations can change the meaning of the program.)
This mechanism is just a specialized version of the existing machinery.
Since this diff leaves the existing machinery unused, the next diff
will delete it, and since that will probably leave a too-small module,
delete the whole module, after moving the remaining small piece of code
to the only module that uses it, parse_tree_out.m.
compiler/parse_module.m:
Instead of implementing actually_read_module_intN in terms of
actually_read_module_int, do the reverse, which avoids the unnecessary
conversion from parse_tree_intN to parse_tree_int.
compiler/parse_tree_out.m:
Provide predicates, output_parse_tree_intN, to write out parse_tree_intN,
not just a generic parse_tree_int.
Change the existing service routines, mercury_output_parse_tree_intN,
that do all the work of the above new predicates to write out the contents
of each parse tree in the canonical order, using the newly exposed
functionality in canonicalize_interface.m where needed. (Previously,
write_module_interface_files.m invoked canonicalize_interface.m to do this
before calling parse_tree_out.m.)
These service routines were originally written for debugging; make them
suitable for creating proper .intN files by removing unneeded output.
compiler/write_module_interface_files.m:
Call the newly provided predicates in parse_tree_out.m to output
interface files. To make this possible, break up the old predicate
actually_write_interface_file into smaller predicates, so that the
new predicates actually_write_interface_fileN can each call whichever
of these are relevant for the given interface-file-kind. (Some pieces
are relevant to only a subset of these kinds.)
compiler/convert_parse_tree.m:
Note the reason why this diff is not deleting the functions that convert
parse_tree_intN to parse_tree_int.
compiler/read_modules.m:
Note the reason why this diff is not deleting the functions that read in
generic parse_tree_ints.
|
||
|
|
9789375cc5 |
Make pre-HLDS passes use file-kind-specific parse trees.
Replacing item blocks file-kind-specific kinds of section markers with
file-kind-specific parse trees has several benefits.
- It allows us to encode the structural invariants of each kind of file
we read in within the type of its representation. This makes the detection
of any accidental violations of those invariants trivial.
- Since each file-kind-specific parse tree has separate lists for separate
kinds of items, code that wants to operate on one or a few kinds of items
can just operate on those kinds of items, without having to traverse
item blocks containing many other kinds of items as well. The most
important consequence of this is not the improved efficiency, though
that is nice, but the increased clarity of the code.
- The new design is much more flexible. For example, it should be possible
to record that e.g. an interface file we read in as a indirect dependency
(i.e. a file we read not because its module was imported by the module
we are compiling, but because its module was imported by *another* imported
module) should be used *only* for the purpose it was read in for. This should
avoid situations where deleting an import of A from a module, because it
is not needed anymore, leads the compiler to generate an error message
about a missing import of module B. This can happen if (a) module B
always *should* have been imported, since it is used, but (b) module A's
import of module B lead to module B's interface being available *without*
an import of B.
Specifically, this flexibility should enable us to establish each module's
.int file as the single source of truth about how values of each type
defined in that module should be represented. When compiling each source
file, this approach requires the compiler to read in that module's .int file
but using only the type_repn items from that .int file, and nothing else.
- By recording a single parse tree for each file we have read, instead of
a varying number of item blocks, it should be significantly easier to
derive the contents of .d files directly from the records of those
parse trees, *without* having to maintain a separate set of fields
in the module_and_imports structure for that purpose. We could also
trivially avoid any possibility of inconsistencies between these two
different sources of truth. (We currently fill in the fields used to
drive the generation of .d files using two different pieces of code,
one used for --generate-dependencies and one used for all other invocations,
and these two *definitely* generate inconsistent results, as the significant
differences in .d files between (a) just after an invocation of
--generate-dependencies and (b) just after any other compiler invocation
can witness.)
This change is big and therefore hard to review. Therefore in many files,
this change adds "XXX CLEANUP" comments to draw attention to places that
have issues that should be fixed, but whose fixes should come later, in
separate diffs.
compiler/module_imports.m:
The compiler uses the module_and_imports structure defined here
to go from a raw compilation unit (essentially a module to be compiled)
to an augmented compilation unit (a raw compilation unit together
with all the interface and optimization files its compilation needs).
We used to store the contents of both the source file and of
the interface and optimization files in the module_and_imports structure
as item blocks. This diff replaces all those item blocks with
file-kind-specific parse trees, for the reasons mentioned above.
Separate out the .int0 files of ancestors modules from the .intN
files for N>0 of directly imported modules. (Their item blocks
used to be stored in the same list.)
Maintain a database of the source, interface and optimization files
we have read in so far. We use it to avoid reading in interface files
if we have already read in a file for the same module that contains
strictly more information (either an interface file with a smaller
number as a suffix, or the source file itself).
Shorten some field names.
compiler/prog_item.m:
Define data structures for storing information about include_module,
import_module and use_module declarations, both in a form that allows
the representation of possibly erroneous code in actual source files,
and in checked-and-cleaned-up form which is guaranteed to be free
of the relevant kinds of errors. Add a block comment at the start
of the module about the need for this distinction.
Define parse_tree_module_src, a data structure for representing
the source code of a single module. This is different from the existing
parse_tree_src type, which represents the contents of a single source file
but which may contain *more* than one module, and also different from
a raw_compilation_unit, which is based on item blocks and is thus
unable to express to invariants such as "no clauses in the interface".
Modify the existing parse_tree_intN types to express the distinction
mentioned just above, and to unify them "culturally", i.e. if they
store the same information, make them store it using the same types.
Fix a mistake by allowing promises to appear in .opt files.
I originally ruled them out because the code that generates .opt files
does not have any code to write out promises, but some of the predicates
whose clauses it writes out have goal_type_promise, which means that
they originated as promises, and get written out as promises.
Split the existing pragma item kind into three item kinds, which have
different invariants applying to them.
- The decl (short for declarative) pragmas give the compiler some
information, such as that a predicate is obsolete or that we
want to type specialize some predicate or function, that is in effect
part of the module's interface. Decl pragmas may appear in module
interfaces, and the compiler may put them into interface files;
neither statement is true of the other two kinds of pragmas.
- The impl (short for implementation) pragmas are named so
precisely because they may appear only in implementation sections.
They give the compiler information that is private to that module.
Examples include foreign_decls, foreign_codes, foreign_procs,
and promises of clause equivalence, and requests for inlining,
tabling etc. These will never be put into interface files,
though some of them can affect the compilation of other modules
by being included in .opt files.
- The gen (short for generated) pragmas can never (legally) appear
in source files at all. They record the results of compiler
analyses e.g. about which arguments of a predicate are unused,
or what exceptions a function can throw, and accordingly they
should only ever occur in compiler-generated interface files.
Use the new type differences between the three kinds of pragmas
to encode the above invariants about which kinds of pragmas can appear
where into the various kinds of parse trees.
Make the augmented compilation unit, which is computed from
the final module_and_imports structure, likewise switch from
storing item blocks to storing the whole parse trees of the
files that went into its construction. With each such parse tree,
record *why* we read it, since this controls what permissions
the source module being compiled has for access to the entities
in the parse tree.
Simplify the contains_foreign_code type, since one of three
function symbols was equivalent to one possible use of another
function symbol.
Provide a way to record which method of which class a compiler-generated
predicate is for. (See hlds_pred.m below.)
Move the code of almost all utility operations to item_util.m
(which is imported by many fewer modules than prog_item.m),
keeping just the most "popular" ones.
compiler/item_util.m:
Move most of the previously-existing utility operations here from
prog_item.m, most in a pretty heavily modified form.
Add a whole bunch of other utility operations that are needed
in more than one other module.
compiler/convert_parse_tree.m:
Provide predicates to convert from raw compilation units to
parse_tree_module_srcs, and vice versa (though the reverse
shouldn't be needed much longer).
Update the conversion operations between the general parse_tree_int
and the specific parse_tree_intN forms for the changes in prog_item.m
mentioned above. In doing so, use a consistent approach, based on
new operations in item_util.m, to detect errors such as duplicate
include_module and import/use_module declarations in all kinds
of parse trees.
Enforce the invariants that the types of parse trees of various kinds
can now express in types, generating error messages for their violations.
Delete some utility operations that have been moved to item_util.m
because now they are also needed by other modules.
compiler/grab_modules.m:
Delete code that did tests on raw compilation units that are now done
when that raw compilation unit is converted to a parse_tree_module_src.
Use the results of the checks done during that conversion to decide
which modules are imported/used and in which module section.
Record a single reason for why we reading in each interface and
optimization file. The code of make_hlds_separate_items.m will use
this reason to set up the appropriate permissions for each item
in those files.
Use separate code for handling different kinds of interface and
optimization files. Using generic traversal code was acceptable economy
when we used the same data structure for every kind of interface file,
but now that we *can* express different invariants for different kinds
of interface and optimization file, we want to execute not just different
code for each kind of file, but the data structures we want to work on
are also of different types. Using file-kind-specific code is a bit
longer, but it is significantly simpler and more robust, and it is
*much* easier to read and understand.
Delete the code that separates the parts of the implementation section
that are exported to submodules, and the part that isn't, since that task
is now done in make_hlds_separate_items.m.
Pass a database of the files we have read through the relevant predicates.
Give some predicates more meaningful names.
compiler/notes/interface_files.html:
Note a problem with the current operation of grab_modules.
compiler/get_dependencies.m:
Add operations to gather implicit references to builtin modules
(which have to be made available even without an explicit import_module
or use_module declaration) in all kinds of parse trees. These have
more code overall, but will be at runtime, since we need only look at
the item kinds that may *have* such implicit references.
Add a mechanism to record the result of these gathering operations
in import_and_or_use_maps.
Give some types, function symbols, predicates and variables
more meaningful names.
compiler/make_hlds_separate_items.m:
When we stored the contents of the source module and the
interface and optimization files we read in to augment it
in the module_and_imports structure as a bunch of item blocks,
the job of this module was to separate out the different kinds of items
in the item blocks, returning a single list of each kind of item,
with each such item being packaged up with its status (which encodes
a set of permissions saying what the source module is allowed
to do with it).
Now that the module_and_imports structure stores this info in
file-kind-specific parse trees, all of which have separate lists
for each kind of item and none of which contain item blocks,
the job of this module has changed. Now its job is to convert
the reason why each file was read in into the (one or more) statuses
that apply to the different kinds of items stored in it, wrap up
each item with its status, and return the resulting overall list
of status/item pairs for each kind of item.
compiler/read_modules.m:
Add predicates that, when reading an interface file, return its contents
in the tightest possible file-kind-specific parse tree.
Refine the database of files we have read to allow us to store
more file-kind-specific parse trees.
Don't require that files in the database have associated timestamps,
since in some cases, we read files we can put into the database
*without* getting their timestamps.
Allow the database to record that an attempt to read a file failed.
compiler/split_parse_tree_src.m:
Rearchitect how this module separates out nested submodules from within
the main module in a file.
Another of the jobs of this module is to generate error messages for
when module A includes module B twice, whether via nesting or via
include_module declarations, with one special exception for the case
where A's interface contains nested submodule A.B's interface,
and A's implementation contains nested submodule A.B's implementation.
The problem ironically was that while it reported duplicate include_module
declarations as errors, split_parse_tree_src.m also *generated*
duplicate include_module declarations. Since it replaced each nested
submodule occurrence with an include_module declaration, in the scenario
above, it generated two include_module declarations for A.B. Even worse,
the interface incarnation of submodule A.B could contain
(the interface of) its own nested submodule A.B.C, while its
implementation incarnation could contain (the implementation section of)
A.B.C. Each occurrence of A.B.C would be its only occurrence in the
including part of its parent A.B, which means local tests for duplicates
do not work. (I found this out the hard way.)
The solution we now adopt adds include_module declarations to the
parents of any submodule only once the parse tree of the entire
file has been processed, since only then do we know all the
includer/included relationships among nested modules. Until then,
we just record such relationships in a database as we discover them,
reporting duplicates when needed (e.g. when A includes B twice
*in the same section*), but not reporting duplicates when not needed
(e.g. when A.B includes A.B.C in *different* sections).
compiler/prog_data.m:
Add a new type, pf_sym_name_and_arity, that exactly specifies
a predicate or function. It is a clone of the existing simple_call_id
type, but its name does NOT imply that the predicate or function
is being called.
Add XXXs that call for some other improvements in type names.
compiler/prog_data_foreign.m:
Give a type, and the operations on that type, a more specific name.
compiler/error_util.m:
Add an id field to all error_specs, which by convention should be
filled in with $pred. Print out the value in this field if the compiler
is invoked with the developer-only option --print-error-spec-id.
This allows a person debugging the compiler find out where in the code
an undesired error message is coming from significantly easier
than was previously possible.
Most of the modules that have changes only "to conform to the changes
above" will be for this change. In many cases, the updated code
will also simplify the creation of the affected error_specs.
Fix a bug that looked for a phase in only one kind of error_spec.
Add some utility operations needed by other parts of this change.
Delete a previously internal function that has been moved to
mdbcomp/prim_data.m to make it accessible in other modules as well.
compiler/Mercury.options:
Ask the compiler to warn about dead predicates in every module
touched by this change (at least in one its earlier versions).
compiler/add_foreign_enum.m:
Replace a check for an inappropriately placed foreign_enum declaration
with a sanity check, since with this diff, the error should be caught
earlier.
compiler/add_mutable_aux_preds.m:
Delete a check for an inappropriately placed mutable declaration,
since with this diff, the error should be caught earlier.
compiler/add_pragma.m:
Instead of adding pass2 and pass3 pragmas, add decl and impl and
generated pragmas.
Delete the tests for generated pragma occurring anywhere except
.opt files, since those tests are now done earlier.
Shorten some too-long predicate names.
compiler/comp_unit_interface.m:
Operate on as specific kinds of parse trees as the interface of this
module will allow. (We could operate on more specific parse trees
if we changed the interface, but that is future work).
Use the same predicates for handling duplicate include_module,
import_module and use_module declarations as everywhere else.
Delete the code of an experiment that shouldn't be needed anymore.
compiler/equiv_type.m:
Replace code that operated on item blocks with code that operates
on various kinds of parse trees.
Move a giant block of comments to the front, where it belongs.
compiler/hlds_module.m:
Add a field to the module_info that lets us avoid generating
misleading error messages above missing definitions of predicates
or functions when those definitions were present but were not
added to the HLDS because they had errors.
Give a field and its access predicates a more specific name.
Mark a spot where an existing type cannot express everything
it is supposed to.
compiler/hlds_pred.m:
For predicates which the compiler creates to represent a class method
(the virtual function, in OOP terms), record not just this fact,
but the id of the class and of the method. Using this extra info
in progress messages (with mmc -V) prevents the compiler from printing e.g.
% Checking typeclass constraints on class method
% Checking typeclass constraints on class method
% Checking typeclass constraints on class method
when checking three such predicates.
compiler/make.m:
Provide a slot in the make_info structure to allow the database
of the files we have read in to be passed around.
compiler/make_hlds_error.m:
Delete predicates that are needed in just one other module,
and have therefore been moved there.
compiler/make_hlds_passes.m:
Add decl, impl and generated pragma separately, instead of adding
pass2 and pass3 pragmas separately.
Do not generate error messages for clauses, initialises or finalises
in module interfaces, since with this diff, such errors should be
caught earlier.
compiler/mercury_compile_main.m:
compiler/recompilation.check.m:
Explicitly pass around the expanded database of parse trees
of files that have been read in.
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.m:
compiler/module_qual.qualify_items.m:
Collect module qualification information, and do module qualification
respectively on parse trees of various kinds, not item blocks.
Take information about what the module may do with the contents
of each interface or optimization file from the record of why
we read that file, not from the section markers in item blocks.
Break up some too-large predicates by carving smaller ones out of them.
compiler/options.m:
Add an option to control whether errors and/or warnings detecting
when deciding what should go into a .intN file be printed,
thus (potentially) preventing the creation of that file.
Add commented-out documentation for a previously totally undocumented
option.
doc/user_guide.texi:
Document the new option.
NEWS:
Announce the new option.
Mention that we now generate warnings for unused import_module and
use_module declarations in the interface even if the module has
submodules.
compiler/write_module_interface_files.m:
Let the new option control whether we filter out any messages generated
when deciding what should go into a .intN file.
compiler/parse_item.m:
Delete actually_read_module_opt, since it is no longer needed;
its callers now call actually_read_module_{plain,trans}_opt instead.
Delete unneeded arguments from some predicates.
compiler/parse_module.m:
Delete some long unused predicates.
compiler/parse_pragma.m:
When parsing pragmas, wrap them up in the new decl, impl or generated
pragma kinds.
compiler/parse_tree_out.m:
Add predicates to write out each of the file-kind-specific parse trees.
compiler/parse_tree_out_pragma.m:
Add predicates to write out decl, impl and generated pragmas.
compiler/polymorphism.m:
Add a conditionally-enabled progress message, which can be useful
in tracking down problems.
compiler/prog_item_stats.m:
Conform NOT to the changes above beyond what is needed to let this module
compile. Let that work be done the next time the functionality of
this module is needed, by which time the affected data structures
maybe have changed further.
compiler/typecheck.m:
Fix a performance problem. With intermodule optimization, we read in
.opt files, some of which (e.g. list.opt and int.opt) contain promises.
These promises are read in as predicates with goal_type_promise,
but they do not have declarations of the types of their arguments
(since promises do not have declarations as such). Those argument types
therefore have to be inferred. That inference replaces the original
"I don't know" argument types with their actual types.
The performance problem is that when we change the recorded argument types
of a predicate, we require another loop over all the predicates in the
module, so that any calls to this predicate can be checked against
the updated types. This is as it should be for callable predicates,
but promises are not callable. So if all the *only* predicates whose
recorded argument types change during the first iteration to fixpoint
are promises, then a second iteration is not needed, yet we used to do it.
The fix is to replace the "Have the recorded types of this predicate
changed?" boolean flag with a bespoke enum that says "Did the checking
of this predicate discover a need for another iteration", and not
setting it when processing predicates whose type is goal_type_promise.
compiler/typecheck_errors.m:
Do not generate an error message for a predicate missing its clauses
is the clauses existed but were not added to the HLDS because they were
in the interface section.
When reporting on ambiguities (when a call can match more than one
predicate or function), sort the possible matches before reporting
them.
compiler/accumulator.m:
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_mode.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/canonicalize_interface.m:
compiler/check_for_missing_type_defns.m:
compiler/check_parse_tree_type_defns.m:
compiler/check_promise.m:
compiler/check_raw_comp_unit.m:
compiler/check_typeclass.m:
compiler/common.m:
compiler/compile_target_code.m:
compiler/compiler_util.m:
compiler/dead_proc_elim.m:
compiler/deps_map.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/du_type_layout.m:
compiler/field_access.m:
compiler/find_module.m:
compiler/float_regs.m:
compiler/format_call.m:
compiler/goal_expr_to_goal.m:
compiler/handle_options.m:
compiler/hlds_out_module.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/inst_check.m:
compiler/intermod.m:
compiler/introduce_parallelism.m:
compiler/layout_out.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make_hlds_warn.m:
compiler/mark_tail_calls.m:
compiler/mercury_compile_llds_back_end.m:
compiler/ml_top_gen.m:
compiler/mmakefiles.m:
compiler/mode_errors.m:
compiler/mode_robdd.equiv_vars.m:
compiler/modes.m:
compiler/module_qual.qual_errors.m:
compiler/oisu_check.m:
compiler/old_type_constraints.m:
compiler/options_file.m:
compiler/parse_class.m:
compiler/parse_dcg_goal.m:
compiler/parse_goal.m:
compiler/parse_inst_mode_defn.m:
compiler/parse_inst_mode_name.m:
compiler/parse_mutable.m:
compiler/parse_sym_name.m:
compiler/parse_type_defn.m:
compiler/parse_type_name.m:
compiler/parse_type_repn.m:
compiler/parse_types.m:
compiler/parse_util.m:
compiler/parse_vars.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/prog_event.m:
compiler/prog_mode.m:
compiler/purity.m:
compiler/qual_info.m:
compiler/recompilation.version.m:
compiler/resolve_unify_functor.m:
compiler/simplify_goal.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/simplify_proc.m:
compiler/state_var.m:
compiler/stratify.m:
compiler/style_checks.m:
compiler/superhomogeneous.m:
compiler/table_gen.m:
compiler/term_constr_errors.m:
compiler/term_errors.m:
compiler/termination.m:
compiler/trace_params.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/write_deps_file.m:
compiler/xml_documentation.m:
Conform to the changes above.
mdbcomp/prim_data.m:
Move a utility function on pred_or_funcs here from a compiler module,
to make it available to other compiler modules as well.
scripts/compare_s1s2_lib:
A new script that helped debug this diff, and may help debug
similar diffs the future. It can compare (a) .int* files, (b) .*opt
files, (c) .mh/.mih files or (d) .c files between the stage 1 and
stage 2 library directories. The reason for the restriction
to the library directory is that any problems affecting the
generation of any of these kinds of files are likely to manifest
themselves in the library directory, and if they do, the bootcheck
won't go on to compile any of the other stage 2 directories.
tests/debugger/breakpoints.a.m:
tests/debugger/breakpoints.b.m:
Move import_module declarations to the implementation section
when they are not used in the interface. Until now, the compiler
has ignored this, but this diff causes the compiler to generate
a warning for such misplaced import_module declarations even modules
that have submodules. The testing of such warnings is not the point
of the breakpoints test.
tests/invalid/Mercury.options:
Since the missing_interface_import test case tests error messages
generated during an invocation of mmc --make-interface, add the
new option that *allows* that invocation to generate error messages.
tests/invalid/ambiguous_overloading_error.err_exp:
tests/invalid/max_error_line_width.err_exp:
tests/warnings/ambiguous_overloading.exp:
Expect the updated error messages for ambiguity, in which
the possible matches are sorted.
tests/invalid/bad_finalise_decl.m:
tests/invalid/bad_initialise_decl.m:
Fix programming style.
tests/invalid/bad_item_in_interface.err_exp:
Expect an error message for a foreign_export_enum item in the interface,
where it should not be.
tests/invalid/errors.err_exp:
Expect the expanded wording of a warning message.
tests/invalid/foreign_enum_invalid.err_exp:
Expect a different wording for an error message. It is more "standard"
but slightly less informative.
tests/invalid_submodules/children2.m:
Move a badly placed import_module declaration, to avoid having
the message the compiler now generates for it from affecting the test.
tests/submodules/parent2.m:
Move a badly placed import_module declaration, to avoid having
the message the compiler now generates for it from affecting the test.
Update programming style.
|
||
|
|
c0293832b7 |
Allow "mmc -C foo.m" when file.m contains module bar ...
... provided the source file map in Mercury.modules records this fact.
compiler/read_modules.m:
When asked to compile a given file, look up the name of the module
that we expect to find in that file in Mercury.modules, if it exists,
instead of just assuming that it corresponds *exactly* to the filename.
compiler/source_file_map.m:
Provide a predicate to provide the filename-to-modulename lookup
now needed by read_modules.m. (Previously, we had only modulename-to-
filename lookup.)
Make the code constructing some error messages easier to read.
tools/make_arena:
Copy compiler/Mercury.modules to the arena along with compiler/*.m.
(The motivation for this change was that I wanted to profile the
.profdeep compiler in workspace N by simply invoking "lmcN -C *.m"
in the arena directory.)
|
||
|
|
2dbf279ff9 |
Only search for source file matching fully qualified module name.
Delete now-obsolete code to search for a module in files matching
partially qualified versions of the module name.
compiler/find_module.m:
As above.
compiler/read_modules.m:
compiler/write_deps_file.m:
Conform to changes.
tests/invalid/bad_module_name.err_exp
tests/invalid/bad_module_name.m
tests/invalid/bad_module_name_sub.m -> tests/invalid/bad_module_name.sub.m:
Rename sub-module and its source file so that the source file will
be found.
|
||
|
|
44d2436556 | Delete an obsolete test, and move related code next to each other. | ||
|
|
615d2795c8 |
Take foreign_import_modules out of the item type.
compiler/prog_item.m:
Even though we express foreign import module declarations syntactically
as pragmas, semantically, they are much closer to import_module
declarations. This means that the treatment they require in most places
in the compiler is similar to the treatment of import_module declarations,
and quite different from the treatment of other kinds of items.
Therefore this diff takes foreign_import_module declarations (FIMs
for short) out of item type. From now on, in parse trees and their
components, FIMs are stored in data structures of their own, next to
import_module declarations.
compiler/parse_types.m:
Provide a mechanism for the parser to return FIMs as an entity kind
of its own, not as an item.
compiler/comp_unit_interface.m:
Conform to the changes above, and give a predicate a more specific name.
compiler/module_qual.m:
Conform to the changes above, and require .int3 files to contain no FIMs.
compiler/canonicalize_interface.m:
compiler/check_raw_comp_unit.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/grab_modules.m:
compiler/hlds_module.m:
compiler/item_util.m:
compiler/make_hlds_passes.m:
compiler/make_hlds_separate_items.m:
compiler/module_imports.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.qualify_items.m:
compiler/parse_module.m:
compiler/parse_pragma.m:
compiler/parse_tree_out.m:
compiler/prog_item_stats.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/split_parse_tree_src.m:
Conform to the changes above.
|
||
|
|
fef3a0cd18 |
Move all callers of init_module_and_imports to module_imports.m.
compiler/module_imports.m:
The predicate init_module_and_imports is one of the two principal ways
to construct a module_and_imports structure from scratch. Instead of
exporting *it*, export predicates at a higher level of abstraction,
so that later changes can change their implementation. The code
of these predicates come from init_module_and_imports' old call sites.
Since many of the old call sites did (minor variations of) the same thing
around those calls, this diff also factors out some of that common code.
compiler/read_modules.m:
Get the callers of the predicate that reads source files to give it
filenames both with and without the .m suffix. Without this, both the
predicate and its callers have to add the suffix.
compiler/deps_map.m:
compiler/generate_dep_d_files.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile_main.m:
Replace calls to init_module_and_imports, and surrounding code,
with calls to the new higher level predicates now exported by
module_imports.m.
Conform to the changes to read_modules.m as well.
|
||
|
|
d29183e5fb |
Improve error messages about unexpected module names.
When you get this message, the error may be in the module name that it
reports to be wrong, but it may be in the places that set the compiler's
expectations of what the name of the module should be. This latter is
very likely the case when one moves a module of the Mercury compiler
from one package to another. In such cases, the problems are the old modules
that continue to refer to the renamed module by its old name.
This diff includes in the error message the identities of the modules
that refer to the old name; these are the modules that establish the
expectation that is not met.
compiler/deps_map.m:
When tracing references from module A to module B.C (either because
A imports B.C, or because A = B and A includes C), record A as a source
of the expectation that any file that contains module C will have
B.C as module C's fully qualified name. Since a module is usually imported
by more than one other module, there may be several sources of such
expectations.
compiler/parse_module.m:
Require callers of the functions that read in modules from files
to specify the contexts of the places that establish the expectation
of the module's fully qualified name.
When the expectation is not met, include the contexts in the error message.
compiler/read_modules.m:
Pass those contexts through to parse_module.m.
compiler/find_module.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile_main.m:
compiler/modules.m:
compiler/recompilation.check.m:
Conform to the changes above.
tests/invalid/bad_module_name.err_exp:
Expect the updated error message.
|
||
|
|
1af5bcf2f1 |
Make module_name_to_file_name currying-friendly.
compiler/file_names.m:
Change the order of arguments of module_name_to_file_name and related
predicates to make it easier to construct closures from them. Delete
the previous higher-order-friendly versions, which the previous step
has made unnecessary.
compiler/compile_target_code.m:
compiler/elds_to_erlang.m:
compiler/export.m:
compiler/find_module.m:
compiler/generate_dep_d_files.m:
compiler/intermod.m:
compiler/llds_out_file.m:
compiler/make.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_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/modules.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the change above. In several places, this means replacing
explicit lambda expressions with simple partial application of the
relevant predicates.
|