Since du_type_layout.is_foreign_type_body_for_target is semidet,
we won't get any compilation error when adding a new target, and
it will fail at runtime. Fix this by marking the switch on Target
as complete.
Use the same variable (base) name for each field of the eqvclass
structure in all predicates. Make this base name match the name
of that field.
Delete redundant module qualifiers, except in the few cases where
it helps readability.
Add dividers to separate unrelated predicates.
Expand out deeply nested function calls, giving names
to the intermediate results.
compiler/ml_switch_gen.m:
The code for deciding how to implement switches on strings was
a convoluted nest of tests, which tested several different properties
of the target language. The flexibility this afforded could have been
useful in the past when the MLDS backend targeted MSIL and gcc asm,
but with today's three target languages, they are just overkill,
especially since several parts of the old code were unreachable.
Replace all that code with a simple switch on the target language.
Move the switch arm for C into its own predicate in order to reduce
the required indentation level.
Assume that all target languages support switches on (smaller-than-64-bit)
integers, because they all do.
Use Defns, not Decls, to refer to lists of local var definitions.
Fix an misleading old comment.
compiler/ml_target_util.m:
Delete the code testing whether a target language supports switches on
smaller-than-64-bit integers.
compiler/switch_util.m:
Simplify the interface of the find_switch_category predicate.
Instead of returning (a) a *smart switch category*, and (b) a flag
that says whether that category may be used, simply return
a *switch category*, which includes a non-smart switch category,
the if-then-else chain.
Give some data constructors in the switch_category type names that
clarify the differences between them.
Move the type_ctor_cat_to_switch_cat function just after its only caller.
compiler/ml_switch_gen.m:
compiler/switch_gen.m:
Flatten the switches on the return values of find_switch_category.
Merge arms of these switches that handle dumb switches and switches
on floats, because they are both implemented as if-then-else chains.
In ml_switch_gen.m, inline the ml_gen_smart_int64_switch predicate,
which made only one decision, at its only call site.
Add XXXs that point out opportunities for further simplification.
compiler/ml_lookup_switch.m:
Rename a predicate to conform to the new names of switch categories.
In the Java grade, the implementation of predicates used to create unique
temporary files and directories was not secure, due to the underlying Java API
methods not setting permissions correctly. Alternative methods were added in
Java 7, but we currently use the older insecure methods. This change switches
the Java implementations of temporary file and directory creation over to the
newer methods.
We have long provided a Mercury wrapper for secure temporary file / directory
creation in the extras/java_extra_libs. That will be redundant after this change
and I will remove it in a separate change.
library/io.file.m:
Use the secure temporary file and directory creation methods introduced
in Java 7.
Mention that for make_temp_directory/6, the Java implementation will now
ignore the Suffix argument.
Delete some that was used to generated temp file names; its use of
java.util.Random probably wasn't particularly secure either.
compiler/notes/coding_standards.html:
Document our usual initial comment block.
Document vim modelines a bit more extensively.
Document short %---% lines.
Fix bad formatting results caused by tabs in the HTML code.
Fix documentation rot.
compiler/notes/compiler_design.html:
Explain the terms HLDS, LLDS and MLDS just after their first occurrences.
Fix incorrect references to "passes".
Describe the components of the LLDS and MLDS backends the same way
where possible.
Fix documentation rot.
Fix bugs in English expression.
compiler/notes/developer_intro.html:
Fix documentation rot.
compiler/notes/glossary.html:
Explain that functions also have pred_infos.
compiler/notes/overall_design.html:
Fix bugs in English expression.
compiler/notes/reviews.html:
Fix documentation rot.
Fix bugs in English expression.
compiler/notes/work_in_progress.html:
Use a more accurate name for this page.
Building programs with --intermodule-optimization fails when using a library
containing submodules that was *not* installed with --intermodule-optimization
enabled. This is because the compiler is trying to find the .int0 files for the
library, but these are only installed when the library is built with
--intermodule-optimization enabled. The fix is to always install any .int0
files for a library.
compiler/make.program_target.m:
compiler/write_deps_file.m:
Always install the .int0 files for libraries.
tests/invalid/Mmakefile:
Some tests cases in this directory have target-specific make rules
if (and only if) the test flags include --intermod-opt. We used to include
these tests in the lists of tests that do not have target-specific rules,
which lead to messages about "overriding recipe for <target>" from make.
Fix this by including test cases in the list of tests that do not have
target-specific rules only if they belong there.
Delete inappropriate entries from REDIRECT_OPT_ERROR_MODULES, the list
of tests cases that have target-specific make rules if (and only if)
the test flags include --intermod-opt. Some of the modules that used
to be in this list have since been moved to the invalid_make_int directory,
where they don't need special handling (because what is special here
is standard there). Some other modules in this list either never existed
or have been deleted from the test suite as a whole. Delete both of these
kinds of test case names from that list.
Move the rules that figure out whether to enable a category of tests
(e.g. the trailed tests) just after the definition of the list of tests
in that category.
Delete an obsolete comment, whose up-to-date form has been nearby
for a while now.
Add an XXX.
tests/invalid_make_int/Mmakefile:
Note which test cases that have been moved here were included in
REDIRECT_OPT_ERROR_MODULES, in case that does turn out to be useful later.
compiler/hlds_error_util.m:
When converting lists of arguments mode to strings for error messages,
replace from/to pairs of insts that stand for standard modes with the
names of those standard modes.
compiler/prog_mode.m:
Add a utility function for doing that standardization.
tests/invalid/io_in_ite_cond.err_exp:
tests/invalid_manual/gh118.err_exp:
Expect the standard forms of modes.
tests/invalid_manual/Mmakefile:
Specify the grade for the test independently of the grade of the
workspace or of the last bootcheck. Make the Mercury compiler flags
specific to the test.
tests/invalid_manual/gh118.err_exp:
tests/invalid_manual/gh118.gh118_helper.m:
tests/invalid_manual/gh118.m:
As above. The invalid_manual directory is a new test directory.
Its tests are not executed by tools/bootcheck.
tests/invalid_manual/Mmakefile:
Add a make rule for executing the test.
tests/invalid_manual/Mercury.options:
Add this options file (currently empty).
compiler/det_report.m:
Redirect comments to the actual location of the test case.
compiler/det_analysis.m:
Implement determinism_check_proc using code that processes one procedure,
instead of code intended to process an entire module.
To make the above possible without code duplication, rearrange the code
around det_infer_proc. Instead of printing (if --debug-det is enabled)
the result of det_infer_proc in its caller, print it in a predicate that
det_infer_proc calls.
Fix argument order in a predicate.
compiler/det_report.m:
To make the above possible, export a predicate.
compiler/modes.m:
compiler/try_expand.m:
Conform to the new argument order in det_analysis.m.
Github issue #118 reports a compiler abort that happens when
table_gen.m attempts to perform that transformation that implements
the tabling of I/O actions for declarative debugging, and a sanity check
finds that the procedure's determinism is not model_det.
We could change table_gen.m to not transform the affected predicate
in such cases. This change could fix *this specific* compiler abort,
but it is better to fix the root cause, which is that our semantic analysis
passes have not detected and reported a violation of our semantic rules,
and have allowed the affected predicate to flow through to the middle end
to be processed.
compiler/det_analysis.m:
compiler/det_report.m:
We used to check whether predicates with I/O state arguments have
one of the permitted model_det determinisms as part of det_infer_proc.
Github issue #118 arose because det_infer_proc processes only
predicates defined in the current module. It was also strange that
some properties of mode declarations were checked by det_infer_proc
in det_analysis.m (which can be invoked on a procedure more than once
during mode inference), while others were checked by
check_determinism_of_procs in det_report.m (which is only ever invoked
on a procedure once, at the end of determinism analysis).
Move the checks on mode declarations all to det_report.m. Partly
this is to fix the above code smell, but mainly so that we can add
check_determinism_of_imported_procs, which performs the part of
the job of check_determinism_of_procs that is appropriate for
imported procedures.
Make the error message for invalid mode declarations more specific
by listing the given invalid determinism as well as the possible
valid determinisms.
To make the above possible without doing unnecessary checks on
compiler-constructed procedures that are "born correct", separate out
imported procedures from born-correct procedures. Previously, they
were lumped together as "no inference needed" procedures.
tests/invalid/ho_unique_error.err_exp:
tests/invalid/mostly_uniq1.err_exp:
tests/invalid/mostly_uniq2.err_exp:
Expect the extra detail in error messages.
tests/invalid/io_in_ite_cond.err_exp:
tests/invalid/magicbox.err_exp:
tests/invalid/try_detism.err_exp:
Expect an error message about the invalid determinism of a procedure
with I/O state args. Previously, we did not generate an error message
for these issues.
compiler/det_analysis.m:
Carve three separate predicates out of det_infer_proc. Besides improving
readability, one of the new predicates should be useful in the fix for
github issue #118.
Factor out the common initial and final parts of two related but
different long error messages.
Improve the wording of some error messages.
Replace two separate traversals of the list of pragma exported procedures
with one.
tests/invalid/ho_unique_error.err_exp:
tests/invalid/mostly_uniq1.err_exp:
tests/invalid/mostly_uniq2.err_exp:
tests/invalid/one_member.err_exp:
Expect the updated wording in error messages.
compiler/op_mode.m:
Add a field that specifies whether the compiler was invoked by
"mmc --make" to the opm_top_args top-level op_mode. This is the
class of op_modes for which we need that info.
Fill in this new field from the value of the --invoked-by-mmc-make
option.
compiler/options.m:
Add an "only_opmode_" prefix to the internal name of the
--invoked-by-mmc-make option. Move this option next to the --make option.
Improve the wording of some options' usage messages.
doc/user_guide.texi:
Make the same changes in wording here as well.
compiler/add_pragma.m:
compiler/add_type.m:
compiler/exception_analysis.m:
compiler/handle_options.m:
compiler/headvar_names.m:
compiler/hlds_module.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mode_errors.m:
compiler/op_mode.m:
compiler/options.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.versions.m:
compiler/structure_sharing.analysis.m:
compiler/tabling_analysis.m:
compiler/term_util.m:
compiler/trailing_analysis.m:
compiler/unused_args.m:
Conform to the changes above, either by finding out whether
the compiler was invoked by mmc --make using the op_mode instead
of the option, or by ignoring that info where not needed.