When set, this option tells the compiler to generate warnings
about locally-defined types that are neither used in the module
nor exported to any other module.
compiler/options.m:
Add the new option.
compiler/unused_types.m:
New module to implement the new option.
compiler/mercury_compile_front_end.m:
Invoke the new module, unless the presence of previous errors
would make its warnings just a distraction.
compiler/check_hlds.m:
Include the new module.
compiler/notes/compiler_design.html:
Document the new module.
compiler/typecheck_error_wrong_type.m:
Simplify some code.
browser/declarative_tree.m:
compiler/accumulator.m:
compiler/du_type_layout.m:
compiler/intermod.m:
compiler/mode_errors.m:
compiler/parse_inst_mode_defn.m:
compiler/polyhedron.m:
compiler/split_parse_tree_src.m:
compiler/tag_switch_util.m:
compiler/typecheck_error_unify.m:
compiler/unneeded_code.m:
deep_profiler/mdprof_test.m:
library/getopt.m:
library/getopt_io.m:
Delete unused types reported by the new option.
library/rtti_implementation.m:
Comment out unused type reported by the new option. This type was exported
to both Java and C#, but this diff comments it out because neither language
the Java or the C# runtime system seems to use the exported versions
either. (Bootcheck in both java and csharp grades worked, with the
same number of test case failures as before.) We do not delete it,
because it may be useful in the future.
tests/warnings/help_text.err_exp:
Expect the documentation of the new option.
tests/invalid_nodepend/Mmakefile:
Specify --warn-unused-types for two test cases to test that the compiler
does NOT generate warnings about unused types in the presence of previous
errors.
tests/warnings/abstract_type_decl.err_exp:
tests/warnings/bug412.err_exp:
tests/warnings/warn_dead_procs.err_exp:
Expect the new warnings for unused types.
tests/warnings/Mmakefile:
Specify --warn-unused-types for the three test cases listed above.
deep_profiler/var_use_analysis.m:
Pass never-varying and slower-varying input arguments first.
Consistently pass goal lists before the position of the first goal
in the overall list.
browser/declarative_analyser.m:
browser/declarative_edt.m:
deep_profiler/analysis_utils.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_types.m:
deep_profiler/program_representation_utils.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/timeout.m:
deep_profiler/top_procs.m:
deep_profiler/util.m:
Minor improvements in programming style.
Commit 781d827ca added Mercury clauses that call unexpected/2 to use a stubs in
non-C grades for predicates that are implemented using foreign_procs in C
grades. Calling unexpected/2 requires the require module to be imported, which
(a) wasn't done and (b) causes warning about unused imports in C grades.
Fix this by calling private_builtin.sorry/1 instead.
browse/*.m:
Call private_builtin.sorry/1 instead of unexpected/2.
Add some missing no_determinism_warning pragmas.
browser/Mmakefile:
Do not specify --allow-stubs.
browser/*.m:
We used to use --allow-stubs to allow us to get away with
predicate definitions containing a foreign_proc for C and
no definition for Java or C#.
Stop relying on --allow-stubs by providing a Mercury clause
(which throws an exception) for every predicate defined by
a foreign_proc in C.
Put short lines around predicates defined in this way,
to make clear which blocks of text are related.
Delete old Java and sometimes C# foreign_procs that throw
an exception in those languages, since the Mercury version
is shorter, simpler, and works for both languages.
In a few cases, fix formatting.
Before this diff,
- the .d filed generated by "mmc --generate-dependencies mer_std.m", and
- the .d files generated by compiling all the modules in the library
had *two*-way differences: the first set of .d files contained dependencies
that the second did not, and *vice versa*. The latter differences were bugs.
Now, as far as I can tell from the deluge of data,
"mmc --generate-dependencies" generates a superset of the dependencies
generated by code generating compiler invocations, which is a safe
overapproximation of the actual dependencies.
compiler/generate_mmakefile_fragments.m:
Flatten the d_file_deps structure by effectively inlining the std_deps
structure inside it, and putting the resulting fields into a meaningful
order. Document the resulting structure as well as I can.
Use notag types to record the intended semantics of some fields
into their values, with the intention of making them harder to misuse.
They were misused before this diff; in particular, a missing module
name in one of these fields would reliably lead to the failure
of the hard_coded/foreign_import_module test case in hlc grades,
though only with a sequential invocation of mmake. (The bug was
that after "mmc --generate-dependencies foreign_import_module.m",
foreign_import_module.d was missing the dependency of
foreign_import_module.o on foreign_import_module_helper_1.mh,
and therefore the compilation foreign_import_module.c got a gcc abort
complaining about this .mh file being missing. The reason for
the bug being intermittent was that the mmc invocation that created
foreign_import_module.c would add the missing dependency, so *later*
mmake invocations, though not existing ones, would know
to build that .mh file.)
Generate rules for object files depending on .mh files that
account for both foreign_import_module declarations, and for
foreign type definitions. Add an XXX about the absence of the
information we need to properly handle the latter in the presence
of intermodule optimization.
Generate just one rule for object files depending on .mh files,
instead of generating two (one for the dependencies that exist
without intermodule optimization, and for one those that exist only
with intermodule optimization.)
Flatten the intermod_deps structure as well. It used to have two
components that encoded the outcomes of two *almost* identical tests,
but a change to d_file_deps.m below makes them actually identical,
so they do not need to be recorded twice.
Inline the old (and misnamed) gather_foreign_import_deps predicate
at its only call site, for greater clarity.
Simplify the code constructing some actions.
Use more specifically descriptive predicate and variable names.
compiler/d_file_deps.m:
Stop requiring the caller of construct_d_file_deps_gendep to pass
an aug_compilation_unit; get it to pass instead two of its components,
the only ones that are meaningful and also the only ones we actually need:
the parse_tree of the module in question and its baggage.
Eliminate some unnecessary differences between compute_d_file_deps_gendep
and compute_d_file_deps_hlds by replacing some existing tests for just
--intermod-opt with tests for *either* --intermod-opt *or* --use-opt-files,
which is the test used elsewhere for the same purpose in the rest of this
module. The two tests are equivalent for now, because handle_options.m
force-sets --no-use-opt-files. And even when we undo that force-set,
the new test will actually be what we want.
Completely redo the code that computes the dependencies that
generate_mmakefile_fragments.m converts into the dependencies
of object files on .mh files.
Give some predicates more meaningful names.
compiler/mmakefiles.m:
Add a mechanism to allow the simplification of some codes
creating actions.
compiler/module_deps_graph.m:
Give a type a more descriptive name.
Document a predicate.
Add an XXX.
compiler/make.program_target.m:
compiler/write_deps_file.m:
Conform to the changes above.
compiler/intermod.m:
Fix comment rot.
compiler/parse_tree_out_item.m:
Generate more readable output for foreign_enum pragmas.
library/digraph.m:
Put the predicates/functions of this file into meaningful groups.
We have several operations that have two names, one old and short,
and one newer, longer and more descriptive. Implement the short named
versions in terms of the longer named versions, not vice versa.
Give some internal predicates more meaningful names.
There are no algorithmic changes in this module.
browser/Mmakefile:
Update a comment.
scripts/mmake.in:
Allow $MMAKE_DEBUG to specify what debug flags to invoke gmake with.
When enabled, the compiler emits a warning for modules that contain
both include_module declarations, and other constructs. In other words,
it warns about modules that include submodules but are not "packages".
compiler/make_hlds_passes.m:
Implement the new option.
compiler/options.m:
Add the new option.
NEWS.md:
Announce the new option.
compiler/option_categories.m:
Add a new subcategory for the new option.
compiler/print_help.m:
Print the new option in the new category.
tests/warnings/help_text.err_exp:
Expect the documentation of the new option.
browser/Mercury.options:
compiler/Mercury.options:
library/Mercury.options:
mdbcomp/Mercury.options:
Add commented-out-for-now lines that disable the new option
for modules that include submodules but are intentionally
not packages. The three reasons for the latter are
- that the only thing in the module other than include_module
declarations is a predicate to print a version id, so a package
wouldn't improve things (browser, mdb, library/library.m),
- that changing the module into a package is not worthwhile
because the module is obsolete (compiler), and
- that changing the module into a package would cause significant
disruption for our users (the other modules in the library).
browser/declarative_debugger.m:
browser/dl.m:
compiler/process_util.m:
library/io.error_util.m:
Avoid triggering the unneeded final statevars warning in some
clauses that are only used in non-C grades.
compiler/Mercury.options:
library/Mercury.options:
Turn of the same warning for some other modules.
compiler/add_heap_ops.m:
compiler/check_import_accessibility.m:
compiler/comp_unit_interface.m:
compiler/convert_import_use.m:
compiler/deforest.m:
compiler/dep_par_conj.m:
compiler/distance_granularity.m:
compiler/equiv_type.m:
compiler/generate_dep_d_files.m:
compiler/generate_mmakefile_fragments.m:
compiler/get_dependencies.m:
compiler/grab_modules.m:
compiler/higher_order.specialize_unify_compare.m:
compiler/jumpopt.m:
compiler/layout_out.m:
compiler/lco.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.get_module_dep_info.m:
compiler/make.library_install.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/make_hlds_passes.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_middle_passes.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_disj_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_foreign_proc_gen.m:
compiler/ml_lookup_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen_deconstruct.m:
compiler/ml_unify_gen_test.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_target_util.m:
compiler/module_cmds.m:
compiler/opt_deps_spec.m:
compiler/optimize.m:
compiler/parse_dcg_goal.m:
compiler/parse_goal.m:
compiler/parse_item.m:
compiler/parse_module.m:
compiler/parse_string_format.m:
compiler/proc_gen.m:
compiler/prop_mode_constraints.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.region_analysis.m:
compiler/rbmm.region_transformation.m:
compiler/simplify_goal_disj.m:
compiler/ssdebug.m:
compiler/stack_opt.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/term_constr_build.m:
compiler/trace_gen.m:
compiler/tupling.m:
compiler/untupling.m:
compiler/write_deps_file.m:
deep_profiler/autopar_calc_overlap.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/html_format.m:
deep_profiler/startup.m:
profiler/mercury_profile.m:
profiler/propagate.m:
Act on the new warnings. In a few cases, conform to the changes
resulting from acting on the warnings in other modules.
browser/Mercury.options:
compiler/Mercury.options:
library/Mercury.options:
mdbcomp/Mercury.options:
ssdb/Mercury.options:
Specify options for disabling the new warnings for modules
where we (probably) won't want them.
configure.ac:
Require the installed compiler to understand the options that
we now reference in the Mercury.options files above.
tests/debugger/tailrec1.exp:
Expect variable names for the middle versions of state vars
using the new naming scheme.
tests/invalid/Mercury.options:
Fix references to obsolete test names.
tests/warnings/Mercury.options:
Avoid a test failure with intermodule optimization.
The new --warn-unneeded-initial-statevar option asks the compiler
to warn about code such as
pred_a(!.X, ...) :-
... code that uses !.X, but does not update it ...
In this case, the preferred fix is to just replace all occurrences
of !.X with X.
The new --warn-unneeded-final-statevar option asks the compiler
to warn about code such as
pred_a(!X, ...) :-
... code that maybe uses !.X, but does not update it ...
In this case, the preferred fix also involves replacing all occurrences
of !.X with X, but it also involves either deleting the argument
containing !:X (the best option), or, if there is some reason why
the predicate's signature must stay unchanged, to replace !:X with X as well.
And if the clause body does not actually refer to either !.X or !:X, then
*both* arguments represented by !X should be deleted.
The first option is a style warning; the second option, due to the
signature change it may call for, is a non-style warning.
Both options have a version whose name adds a "-lambda" suffix, and which
does the same warnings for the heads of lambda expressions, not clauses.
Note that several of the modules below, including some that help to implement
the warnings, also contain code changes that result from *acting* on
the new warnings, e.g. by deleting unneeded statevar arguments.
Other, similar changes will also come after this diff is committed.
compiler/options.m:
doc/user_guide.texi:
Document the new options.
compiler/state_var.m:
Gather the information needed to decide what code merits the new warnings.
Do so in three stages:
- when processing the head of a clause or of a lambda expression,
- when processing the body goal of that clause or lambda expression,
- when finishing up the processing of the clause or lambda expression.
Add a predicate to generate the warnings for lambda expressions.
Do not generate the warnings for clauses. This is because whether or not
we want to warn about state vars in some clauses depends on the properties
of *other* clauses of the same predicate, and state_var.m has access
to only one clause at a time. Instead,
- return the info needed by the warning-generating code in pre_typecheck.m
(one of the first passes we execute after adding all clauses
to the HLDS), and
- we export some functionality for use by that code.
Switch to a convention for naming the program variables corresponding
to the middle (non-initial, non-final) versions of state variables
whose output is affected by changes in the code of the clause body goal
only if they involve that specific state variable.
Give some predicates more descriptive names.
compiler/make_hlds.m:
Make state_var.m and its new functionality visible from outside
the make_hlds package.
compiler/add_clause.m:
Record the information gathered by state_var.m in each clause.
compiler/hlds_clauses.m:
Add a slot to each clause for this information.
Give some predicates more descriptive names.
compiler/headvar_names.m:
Use the contents of the new slots to detect whether any clauses
have unused state vars, and if so, return the chosen consensus names
of the head vars to the code of pre_typecheck.m, which uses this info
as part of the implementation of the new warnings.
compiler/pre_typecheck.m:
Implement the new warnings.
compiler/mercury_compile_front_end.m:
Record the warnings that pre_typecheck.m can now return.
compiler/error_spec.m:
compiler/write_error_spec.m:
Add unsigned versions of the format pieces involving ints, for use
by the new code in pre_typecheck.m, and implement them.
compiler/hlds_out_util.m:
compiler/maybe_util.m:
Move two related types from hlds_out_util.m to maybe_util.m,
in order to allow pre_typecheck.m to use one of them.
compiler/hlds_args.m:
Add a new utility function for use by the new code above.
compiler/foreign.m:
Act on the new warnings by deleting the long-unused predicates
being warned about.
compiler/post_typecheck.m:
Speed up this traversal. (I originally thought to implement
the new warnings in this pass.)
compiler/add_foreign_proc.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/build_mode_constraints.m:
compiler/call_gen.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/code_loc_dep.m:
compiler/delay_info.m:
compiler/delay_partial_inst.m:
compiler/dense_switch.m:
compiler/det_check_goal.m:
compiler/det_infer_goal.m:
compiler/disj_gen.m:
compiler/du_type_layout.m:
compiler/format_call.m:
compiler/goal_expr_to_goal.m:
compiler/hlds_dependency_graph.m:
compiler/hlds_out_pred.m:
compiler/hlds_pred.m:
compiler/hlds_rtti.m:
compiler/inst_merge.m:
compiler/instance_method_clauses.m:
compiler/intermod.m:
compiler/interval.m:
compiler/ite_gen.m:
compiler/lookup_switch.m:
compiler/make_hlds_passes.m:
compiler/mark_tail_calls.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mode_errors.m:
compiler/parse_string_format.m:
compiler/passes_aux.m:
compiler/polymorphism.m:
compiler/polymorphism_info.m:
compiler/polymorphism_type_info.m:
compiler/pragma_c_gen.m:
compiler/prop_mode_constraints.m:
compiler/purity.m:
compiler/quantification.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_conj.m:
compiler/string_switch.m:
compiler/superhomogeneous.m:
compiler/switch_gen.m:
compiler/tag_switch.m:
compiler/type_constraints.m:
compiler/typecheck.m:
compiler/typecheck_clauses.m:
compiler/typecheck_coerce.m:
compiler/typecheck_error_unify.m:
compiler/unify_gen_deconstruct.m:
compiler/unify_proc.m:
compiler/var_origins.m:
Conform to the changes above, and/or act on the new warnings.
browser/diff.m:
library/bit_buffer.m:
library/getopt.m:
library/getopt_io.m:
library/io.error_util.m:
library/io.file.m:
library/mercury_term_lexer.m:
library/parsing_utils.m:
library/pretty_printer.m:
library/robdd.m:
library/rtti_implementation.m:
library/string.builder.m:
library/string.parse_runtime.m:
mdbcomp/feedback.m:
Act on the new warnings.
tests/hard_coded/sv_nested_closures.m:
Change this test's code to avoid the new warnings, since
(if --halt-at-warn is ever enabled) the warnings would interfere
with its job .
tests/invalid/bug197.err_exp:
tests/invalid/bug487.err_exp:
tests/invalid/nullary_ho_func_error.err_exp:
tests/invalid/try_detism.err_exp:
tests/warnings/singleton_test_state_var.err_exp:
Expect variable names for the middle versions of state vars
using the new naming scheme.
compiler/options.m:
doc/user_guide.texi:
NEWS.md:
Add, document and announce the new option. It is off by default,
but of course I tested its behavior when turned on. Most of this
diff deals with the consequences.
compiler/item_util.m:
Add code to generate the new warnings if requested.
compiler/convert_parse_tree.m:
Request the new warning if the new option is set when processing
source files..
compiler/handle_options.m:
Disable all style warnings, including the new one, when generating
.int* files or .*opt files.
compiler/mercury_compile_main.m:
Fix an unrelated bug I noticed while working on this diff:
report the "unfindability" of a given file at most once.
browser/dl.m:
browser/io_action.m:
compiler/mercury_compile_augment.m:
compiler/mercury_compile_llds_back_end.m:
compiler/unused_args.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/dump.m:
deep_profiler/html_format.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/profile.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
library/array2d.m:
library/bit_buffer.read.m:
library/construct.m:
library/edit_distance.m:
library/library.m:
library/mercury_term_lexer.m:
library/one_or_more_map.m:
library/private_builtin.m:
library/set_bbbtree.m:
library/string.parse_runtime.m:
library/thread.future.m:
library/univ.m:
library/version_array.m:
library/version_bitmap.m:
mdbcomp/program_representation.m:
profiler/call_graph.m:
profiler/demangle.m:
profiler/output.m:
profiler/process_file.m:
profiler/propagate.m:
slice/mdice.m:
slice/mslice.m:
Fix unsorted import blocks pointed out by the new option.
tests/invalid/ambiguous_overloading_error.err_exp:
tests/invalid/bad_tscp.err_exp:
tests/invalid/bug10.err_exp:
tests/invalid/gh72_errors.err_exp:
tests/invalid/ho_default_func_2.err_exp:
tests/invalid/require_scopes.err_exp:
tests/invalid/type_error_use_module.err_exp:
tests/invalid/types.err_exp:
tests/invalid_nodepend/errors_2.err_exp:
tests/invalid_nodepend/funcs_as_preds.err_exp:
tests/warnings/ambiguous_overloading.err_exp:
tests/warnings/save.err_exp:
tests/warnings/singleton_test.err_exp:
tests/warnings/unused_interface_import.err_exp:
Update the expected outputs of these test cases to expect the new warning
for unsorted import blocks in their source files.
tests/invalid/Mercury.options:
tests/invalid_nodepend/Mercury.options:
tests/warnings/Mercury.options:
Execute those test cases with the warning enabled.
tests/invalid_nodepend/require_tailrec_invalid.m:
tests/invalid_nodepend/specified.m:
tests/recompilation/pragma_type_spec_r.m.1:
tests/recompilation/type_qual_re.m.1:
tests/recompilation/type_qual_re_2.m.1:
tests/recompilation/type_spec_unname_var_r.m.1:
tests/recompilation/type_spec_unname_var_r_2.m.1:
tests/recompilation/type_spec_unname_var_r_2.m.2:
tests/recompilation/unchanged_pred_nr.m.1:
tests/recompilation/with_type_re.m.1:
Sort the import blocks in these test cases, and where relevant,
import only one module per line.
tests/recompilation/with_type_re.err_exp.2:
Expect updated line numbers after splitting a line that imported
two modules.
tests/warnings/unsorted_import_blocks.{m,err_exp}:
New test case to exercise one nontrivial part of the sortedness check,
numerical non-sortedness. (The other affected test cases already exercise
all the other parts.)
tests/warnings/Mmakefile:
Enable the new test case.
browser/MDB_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
grade_lib/GRADE_LIB_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
Stop specifying --no-warn-inferred-erroneous as the default for
every module in these directories, most of which did not even need it
(the result of blind copying in the absence of STANDARD_MCFLAGS).
browser/Mercury.options:
library/Mercury.options:
Specify --no-warn-inferred-erroneous for the modules that
actually do need it.
STANDARD_MCFLAGS:
Make --warn-dead-preds and --warn-implicit-stream-calls the defaults.
Previously, these were the defaults in some directories, but not all.
browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
grade_lib/GRADE_LIB_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
Delete option settings that are now in STANDARD_MCFLAGS.
deep_profiler/autopar_calc_overlap.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/coverage.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/mdprof_test.m:
deep_profiler/measurements.m:
deep_profiler/program_representation_utils.m:
deep_profiler/read_profile.m:
deep_profiler/startup.m:
deep_profiler/var_use_analysis.m:
profiler/generate_output.m:
profiler/process_file.m:
profiler/snapshots.m:
Avoid warnings about dead code by
- deleting it (if it is trivial recreate if ever needed again,
or is obviously never going to be needed again,
- commenting out the dead predicates, if the module concerned already
has such code, or
- adding consider_used pragmas for the dead predicates.
grade_lib/choose_grade.m:
grade_lib/grade_setup.m:
grade_lib/grade_solver.m:
grade_lib/test_grades.m:
grade_lib/try_all_grade_structs.m:
library/edit_distance.m:
Use explicit streams.
deep_profiler/canonical.m:
deep_profiler/Mercury.options:
Disable --warn-dead-preds for the canonical module, which was
never finished. Document this fact.
library/Mercury.options:
Disable --warn-implicit-stream-calls for the modules that export
predicates that do I/O to implicitly specified streams, since
they cannot be fixed without breaking backwards compatibility.
ssdb/ssdb.m:
Document the fact that this module requires nontrivial changes
(storing the ids of the input/stream streams in the debugger state)
to avoid warnings from --warn-implicit-stream-calls.
Document why --warn-dead-preds must be disabled for (the current code of)
this module.
Change a type from an equivalence type to a notag type, for additional
type safety.
Add some documentation.
Delete a dead predicate.
ssdb/Mercury.options:
Disable --warn-dead-preds and --warn-implicit-stream-calls for ssdb.m.
STANDARD_MCFLAGS:
Put the mmc options that are common to either
- all of the dir/DIR_FLAGS.in files, or
- all but one of them,
into this new file.
(MFILTERJAVAC_FLAGS did not specify --warn-suspicious-foreign-code;
after this diff, it does.)
configure.ac:
Enable replacing @STANDARD_MCFLAGS@ with the new file's contents.
browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
grade_lib/GRADE_LIB_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
Include STANDARD_MCFLAGS instead of listing each option in it
individually, making future global changes to options easier.
library/array.m:
library/assoc_list.m:
library/bimap.m:
library/bitmap.m:
library/construct.m:
library/deconstruct.m:
library/dir.m:
library/hash_table.m:
library/injection.m:
library/io.stream_db.m:
library/kv_list.m:
library/list.m:
library/map.m:
library/robdd.m:
library/stream.string_writer.m:
library/term_conversion.m:
library/term_to_xml.m:
library/tree234.m:
library/type_desc.m:
library/version_hash_table.m:
For nearly every ordinary function in this directory that can fail in its
primary mode (all of which were semidet functions),
- provide a semidet predicate as an alternative, if it did not
already exist,
- implement the function in terms of the predicate, instead of vice versa,
- mark the semidet function as obsolete in favor of the semidet predicate
version,
- fix all the resulting warnings, and then
- comment out the obsolete pragmas (at least for now).
Note that this diff does not touch the semidet function in the
enum typeclass, or the functions that implement that method
in instances.
NEWS.md:
Announce the new predicates in the (documented) modules of the library.
browser/term_rep.m:
compiler/lp_rational.m:
compiler/mcsolver.m:
compiler/mode_ordering.m:
compiler/mode_robdd.equiv_vars.m:
compiler/mode_robdd.implications.m:
compiler/old_type_constraints.m:
compiler/pickle.m:
compiler/prog_event.m:
compiler/type_ctor_info.m:
compiler/var_table.m:
tests/hard_coded/bitmap_empty.m:
tests/hard_coded/construct_mangle.m:
tests/hard_coded/construct_packed.m:
tests/hard_coded/construct_test.m:
tests/hard_coded/dummy_type_construct.m:
tests/hard_coded/expand.m:
tests/hard_coded/foreign_enum_rtti.m:
tests/hard_coded/subtype_rtti.m:
tests/hard_coded/term_to_univ_test.m:
tests/hard_coded/type_to_term.m:
tests/hard_coded/type_to_term_bug.m:
Stop calling the semidet functions from the library that were temporarily
marked obsolete.
In a few places, add explicit type qualification to avoid warnings
about unresolved polymorphism.
tests/hard_coded/test_injection.exp:
Expect an abort message from the predicate version of a semidet function.
tests/declarative_debugger/ho_2.exp2:
Update this .exp file for a previous commit.
compiler/options.m:
Add new compiler option --warn-can-fail-function.
compiler/det_report.m:
Implement the new option.
doc/user_guide.texi:
Document the new option.
NEWS.md:
Announce the new option.
browser/declarative_execution.m:
browser/declarative_tree.m:
compiler/analysis.operations.m:
compiler/llds_out_data.m:
compiler/matching.m:
compiler/par_conj_gen.m:
compiler/polyhedron.m:
compiler/rbmm.live_region_analysis.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.points_to_info.m:
compiler/structure_reuse.dead_cell_table.m:
compiler/structure_reuse.direct_choose_reuse.m:
compiler/structure_reuse.domain.m:
compiler/structure_sharing.domain.m:
compiler/trace_params.m:
compiler/tupling.m:
mdbcomp/trace_counts.m:
Replace functions that can fail with predicates that can fail.
Put .mh files into a Mercury/mhs subdirectory when --use-subdirs
or --use-grade-subdirs is used.
compiler/file_names.m:
Replace ext_cur_mh with ext_cur_ngs_max_cur_mh, in the new category
ext_cur_ngs_max_cur. The new category is similar to that for .mih
files, except that .mh files are never placed in grade-specific
subdirectories.
compiler/handle_options.m:
Add Mercury/mhs subdirs to list of C include directories
when --use-subdirs or --use-grade-subdirs is in effect.
compiler/write_deps_file.m:
Add $(mhs_subdir) prefix before %.mh patterns.
Create a Mercury/mhs -> .. symlink when installing.
This is required by mmc --make and mmake --use-subdirs.
Conform to the changes above.
compiler/export.m:
compiler/make.file_names.m:
compiler/make.program_target.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mlds_to_c_file.m:
Conform to the changes above.
scripts/Mmake.vars.in:
Define the variable mhs_subdir.
scripts/Mmake.rules:
Add -I option to find .mh files when --use-subdirs is used.
browser/.mgnuc_copts:
browser/MDB_FLAGS.in:
compiler/.mgnuc_copts:
compiler/COMP_FLAGS.in:
deep_profiler/.mgnuc_copts:
deep_profiler/DEEP_FLAGS.in:
extras/EXTRAS_FLAGS.in:
grade_lib/.mgnuc_copts:
grade_lib/GRADE_LIB_FLAGS.in:
library/.mgnuc_copts:
mdbcomp/.mgnuc_copts:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/.mgnuc_copts:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/.mgnuc_copts:
profiler/PROF_FLAGS.in:
slice/.mgnuc_copts:
slice/SLICE_FLAGS.in:
ssdb/.mgnuc_copts:
ssdb/SSDB_FLAGS.in:
tests/.mgnuc_copts.ws:
tests/WS_FLAGS.ws:
trace/.mgnuc_copts:
tools/lmc.in:
Add -I options to find .mh files when the workspace is built
with mmake --use-subdirs.
samples/c_interface/standalone_c/Makefile:
Add option to let the C compiler find the .mh file.
NEWS.md:
Announce change.
Delete trailing whitespace.
*/Mercury.options:
Specify module-specific Mercury compiler flags using
MCFLAGS-modulename += options
instead of
MCFLAGS-modulename = options
because unlike the latter, the former allows Mmake.params files
to add other options.
... instead of building a bunch of .c files.
Our tradition of adding an "s" at the end of a suffix to mean "all of the
files with the original suffix" had a problem when we added C# as a target
language. Until then, just as "os" stood for ".o files" when it occurred
as either a mmake target, mmc --make target, or mmake variable name component.
"cs" likewise stood for ".c files", but was now also needed to mean ".cs file".
We coped by keeping "cs" meaning ".c files", and adding "csharp" as a target
name synonym to mean ".cs file".
This diff keeps that synonym, but it changes
- the name needed to refer to ".c files" from "cs" to "all_cs"
- the name needed to refer to ".o files" from "os" to "all_os"
- the name needed to refer to ".pic_o files" from "pic_os" to "all_pic_os"
- the name needed to refer to ".cs files" from "css" to "all_css"
- the name needed to refer to ".java files" from "javas" to "all_javas"
- the name needed to refer to ".opt files" from "opts" to "all_opts"
- the name needed to refer to ".trans_opt files"
from "trans_opts" to "all_trans_opts"
It would be nice if we could apply this same change to all other similar
target names and mmake variable name suffixes, such as "ints" and "int3s",
but some of those names are already in use to mean semantically different
things. All of the names above that used to have the form "<ext>s" and
now have the form "all_<ext>s" stood for all the files with extension
".<ext>" that are prerequisites for building a linked target, i.e.
an executable or a library. But the mmake variable name suffixes
".all_mihs", ".all_mhs" and ".all_int0s" each stand for something subtly
different: the names of files that *may or may not exist", but which,
if they do exist, should be deleted by a clean or realclean target.
To make this breaking change easier to handle by users, this diff does
not simply redefine the meaning of ".all_int0s". (It does change the meaning
of the "cs" target, but the fact this will happen at some time has been
announced ages ago.) Instead, it defines three new mmake var suffixes,
".mihs_to_clean", ".mhs_to_clean" and ".int0s_to_clean", which are
synonyms for ".all_mihs", ".all_mhs" and ".all_int0s" respectively,
and announces that ".all_mihs", ".all_mhs" and ".all_int0s" are being
deprecated, and will have the above change of semantics applied to them
in the future.
NEWS.md:
Announce the breaking change.
compiler/make.top_level.m:
Stop treating the target "cs" as meaning "build all the .c files
for this program".
The code of classify_target_2 has long been semidet, but only in a way
that was not apparent to the compiler. Change the code to allow the
compiler to see its semidet nature while keeping the algorithm the same,
except for the change in the paragraph above.
This includes keeping e.g. "ints" as meaning "build all the .int/.int2
files needed by this program".
compiler/write_deps_file.m:
Stop generating mmake variables with suffixes ".cs", ".os", ".pic_os",
".javas" and ".css". The mmake variables with suffixes ".all_cs",
".all_os", ".all_pic_os", ".all_javas" and ".all_css" already existed.
All had the same value as the mmake variable without the "all",
with one exception: ".cs". However, in this case, the old (and still
current) value of ".all_cs" is what the value of ".cs" *should* have been.
Simplify some code.
The following changes in compiler/*.m are only cosmetic, but they helped me
rule out possible sources of problems with incomplete versions of this diff.
compiler/file_names.m:
Add a version of a fact_table_file_name_return_dirs which does not
return directories, since most of its callers don't need that info.
compiler/make.program_target.m:
Clarify code by making variable names more descriptive,
compiler/make.file_names.m:
compiler/make.module_target.m:
Conform to the changes above,
browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
grade_lib/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
mfilterjavac/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
Rename os to all_os, cs to all_cs, css to all_css, javas to all_javas,
and opts to all_opts. (There were no occurrences of trans_opts to rename.)
Replace [s as sh command names in actions.
scripts/Mmake.vars.in:
Specify the names of mmake variables holding the names of sets of files
with a given extension directly, since for some of them, adding an "s"
at the end of the name of the extension does not generate the name
of the corresponding mmake variable anymore.
scripts/Mmake.rules:
Use the directly specified mmake variable names from Mmake.vars.in
in the rule for installing lbraries. Temporarily add some debugging
output to make suree that the updated nested mmake variable references
work as intended.
tools/bootcheck:
Specify the names of mmake targets for making all the files in a program
with a given extension directly, since adding an "s" at the end of the
name of the extension does not generate the name of the corresponding
mmake target anymore.
Print timestamps around the action of checking namespace cleanliness,
to allow the time taken by that action to be measured. (I kept track
of bootchecks as they happened while working on this diff, and found
this time to be nontrivial.)
configure.ac:
Require the installed compiler to support --allow-insts-as-modes
(and therefore its negation).
*/*_FLAGS.in:
Add -no-allow-ho-insts-as-modes as a default option.
compiler/bytecode_data.m:
compiler/deforest.m:
compiler/inst_graph.m:
compiler/introduce_parallelism.m:
compiler/mode_constraint_robdd.m:
compiler/mode_constraints.m:
compiler/mode_robdd.equiv_vars.m:
compiler/mode_robdd.implications.m:
compiler/mode_robdd.tfeirn.m:
compiler/parse_util.m:
compiler/recompilation.version.m:
compiler/set_of_var.m:
compiler/term_constr_fixpoint.m:
deep_profiler/array_util.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/dump.m:
deep_profiler/interface.m:
deep_profiler/program_representation_utils.m:
mdbcomp/program_representation.m:
Add in() wrappers around higher order insts used as modes.
Use simply "in" as the mode of functions with the default mode
and determinism.
Fix a few style issues.
Each of the new modules, and the updated browse.m, have significantly more
cohesion than the original browse.m.
browser/print_term.m:
A new module containing the parts of the old browse.m that dealt with
printing out terms or their components.
This module exports its services to the updated browse.m and
to trace/mercury_trace_vars.c.
browser/save_term.m:
A new module containing the parts of the old browse.m that dealt with
dumping terms to files.
This module exports its services to trace/mercury_trace_browse.c.
browser/term_paths.m:
A new module containing the parts of the old browse.m that dealt with
operations on paths in terms.
This module exports its services to the updated browse.m,
declarative_user.m, and print_term.m.
browser/browse.m:
Delete the code moved to the new modules.
browser/mdb.m:
Include the three new modules.
browser/term_to_html.m:
Add module qualifiers to some calls to reduce ambiguity.
browser/declarative_user.m:
ssdb/ssdb.m:
trace/mercury_trace_browse.c:
trace/mercury_trace_vars.c:
Conform to the changes above.
browser/browse.m:
Group related predicates together,
Give predicates that implement browser commands a name that
reflects this fact.
Use state variables where this helps.
Stop exporting predicates that are used only in this module.
Add consider_used pragmas for unused predicates.
browser/MDB_FLAGS.in:
Enable --warn-dead-preds by default for all modules in this directory.
browser/browser_info.m:
Stop exporting predicates that are used only in this module.
Add consider_used pragmas for unused predicates.
browser/parse.m:
Add consider_used pragmas for unused predicates.
browser/browse.m:
Instead of passing a maybe(format) value to override a (to be calculated)
default value to the portray predicate and its variants, pass just
the selected format value.
The baffling bug was this:
mdb> p *
...
STATE_VARIABLE_Specs_0 (arg 4)
STATE_VARIABLE_Specs (arg 5) [conditional_spec("predicate `parse_tree.module_qual.qual_errors.warn_unused_interface_import'/4", warn_unused_interface_imports, yes, severity_warning, phase_parse_tree_to_hlds, [simplest_msg/2])]
mdb> p 4
STATE_VARIABLE_Specs_0 (arg 4)
[]
The baffling part was that "print *" did NOT print the value of !.Specs,
but "print 4" did.
browser/browse.m:
Fix this ancient bug. The problem was that "print *" DID in fact
print the value of !.Specs, but it printed it to the current output
stream in the program being debugged, which was NOT stdout at the time.
(This is quite rare, and it must be why this bug hasn't been fixed,
or probably even encountered, before now.)
The reason for the difference in the behavior of "print *" and "print 4"
is that
- the bug existed only in the code the implementation of the "flat"
format, which wrote to the current output stream; the code implementing
the other three formats (verbose, pretty and raw_pretty) write to
the selected debugger stream, which is set up correctly, and
- by default, "print *" selects the flat format, and "print 4" selects
one of the other formats.
The fix is to make the "flat" format write to the selected debugger
stream as well.
browser/io_action.m:
Use don't-care variables to handle the I/O state in a foreign_proc.
This avoids a warning about using an uninitialized variable from MSVC.
library/term_io.m:
Move the base operations of term_io.m to the structure we use
in parse_tree_out*.m in the compiler, where for every type X,
there is a function X_to_string, and two predicates write_X and format_X,
with the former operating on I/O states, and the latter operating on
arbitrary streams. The idea is to apply the "don't repeat yourself"
principle by having both X_to_string and write_X just call format_X.
Apply that principle here as well, with one minor exception,
which is that for some values of X, both write_X and format_X are
implemented in terms of X_to_string.
Impose the X_to_string, write_X, format_X naming scheme. The ancient code
already in term_io.m had (each for some values of X) had
- some of these functions/predicates missing
- inconsistent names, in that write_X/N did I/O while write_X/(N+1)
wrote to arbitrary streams
- names that were inconsistent in another way, in that write_X/N did
I/O of values of type X, but the function to convert X to string
was NOT named X_to_string.
Keep some of the misnamed functions around permanently, because
some of the names for fitting into the new scheme, such as
"escaped_string_to_string", would be strange.
Keep the rest of the misnamed functions and all the misnamed predicates
around temporarily, with commented-out obsolete pragmas. I expect
to make these pragmas active when the rest of term_io.m is converted
to this scheme.
To prepare for that, use string.builder, not string, as the
stream.writer instance to implement X_to_string, because of its
better algorithmic complexity, which is needed mainly for terms
of nontrivial size.
Consistently put operations on each X in the order X_to_string,
write_X and format_X.
NEWS.md:
List all the new predicates and functions.
configure.ac:
Require the installed compiler to contain the fix which allows
a typespec pragma for an obsolete predicate or function.
browser/interactive_query.m:
compiler/hlds_out_util.m:
compiler/parse_tree_out_clause.m:
compiler/parse_tree_out_cons_id.m:
compiler/parse_tree_out_info.m:
compiler/parse_tree_out_pragma.m:
compiler/parse_tree_out_sym_name.m:
compiler/parse_tree_out_type_repn.m:
library/pretty_printer.m:
library/stream.string_writer.m:
library/string.builder.m:
mdbcomp/trace_counts.m:
Update all references to the newly-obsolete predicates and functions.
library/string.to_string.m:
Improve variable names.
The usual mdb "dump" command puts every function symbol on its own line.
This guarantees that we generate any line that is too long to be displayed
on terminals, but it also generates output that is too stretched out
vertically for its structure to be readily apparent. Dumping the term
as a doc allows pretty_printer.m to put as many function symbols on a line
as would fit, without exceeding the maximum line length.
browser/browse.m:
Add save_term_to_file_doc, a way to save a (possibly synthetic)
browser term in a file, using an interface that works the same way
the predicate that saves browser terms as XML.
Inline a predicate at its only call site. Improve variable names.
trace/mercury_trace_browse.[ch]:
Add MR_trace_save_term_as_doc, as an interface function between
save_term_to_file_doc and the code of mercury_trace_cmd_browsing.c.
trace/mercury_trace_cmd_browsing.c:
Add support for a new -p/--prettyprint flag to the mdb "dump" command,
which asks for the given term to be dumped as a pretty_printer doc.
doc/user_guide.texi:
NEWS:
Document the new option.
library/pretty_printer.m:
NEWS:
Rename write_as_doc to write_doc_formatted, and fix its argument type.
tests/debugger/browser_test.inp:
Dump a term that we already dumped with "dump" with "dump -x" and
"dump -p" as well.
tests/debugger/browser_test.m:
Put the code to remove the files we are going to dump to
and then later to print the files we have dumped to into separate
predicates. This keeps most (but not all) line numbers unchanged
even though we now dump to more files.
tests/debugger/browser_test.exp3:
Update this file to account both for the extra output from the just-added
dump commands, and for the changes in line numbers.
Implement the error handling proposals from February 2022 on the
mercury-users list, and August 2022 on the mercury-reviews list.
We add io.system_error to the public interface of io.m
and document what its foreign representation is for each backend.
We allow io.error to optionally contain an io.system_error value,
and provide predicates to retrieve the io.system_error from an io.error.
The user may then inspect the system error via foreign code.
We also provide a predicate that takes an io.error and returns a name
for the system error it contains (if any). This makes it relatively easy
for Mercury programs to check for specific error conditions.
By returning platform-specific (actually, implementation-dependent)
error names, we are pushing the responsibility of mapping strings to
error conditions onto the application programmer. On the other hand, it
is not practical for us to map all possible system-specific error codes
to some common set of values. We could do it for a small set of common
error codes/exceptions, perhaps.
The standard library will construct io.error values containing
io.system_errors. However, we do not yet provide a facility for user
code to do the same.
library/io.m:
Move io.system_error to the public interface.
Change the internal representation of io.error to support containing
a io.system_error. An io.system_error may originate from an errno
value or a Windows system error code; the constructor distinguishes
those cases.
Add predicates to retrieve a system_error from io.error.
Add predicate to return the name of the system error in an io.error.
Replace make_err_msg with make_io_error_from_system_error.
Replace make_maybe_win32_err_msg with
make_io_error_from_maybe_win32_error.
Delete ML_make_err_msg and ML_make_win32_err_msg macros.
browser/listing.m:
library/bitmap.m:
library/dir.m:
library/io.call_system.m:
library/io.environment.m:
library/io.file.m:
library/io.text_read.m:
mdbcomp/program_representation.m:
Conform to changes.
Leave comments for followup work.
tools/generate_errno_name:
tools/generate_windows_error_name:
Add scripts to generate mercury_errno_name.c and
mercury_windows_error_name.c.
runtime/Mmakefile:
runtime/mercury_errno_name.c:
runtime/mercury_errno_name.h:
runtime/mercury_windows_error_name.c:
runtime/mercury_windows_error_name.h:
Add MR_errno_name() and MR_win32_error_name() functions,
used by io.m to convert error codes to string names.
tests/hard_coded/null_char.exp:
Update expected output.
Most modules that imported the old term.m need only a small subset
of its functionality. After this diff, most modules that used to import
term.m will need to import just one more module, and will import many
fewer predicates and functions in total.
library/term_int.m:
A new module carved out of term.m containing the predicates
that recognize terms containing integers, and the functions
that construct such terms.
While this job has *some* similarity to the job of the existing
term_conversion.m module, most modules in the compiler use only one
of those two modules, so merging them would not be a good idea.
library/term_subst.m:
A new module carved out of term.m containing code to do
substitutions and renames of various kinds.
Rename the occurs predicate as var_occurs_in_subst_term,
and occurs_list as var_occurs_in_subst_terms, since the latter
are much more descriptive. Change the argument order to match
the new names (var, subst, term/terms), as the old one did not
even have the term/terms and the substitution next to each other,
even though neither makes sense without the other.
library/term_unify.m:
A new module carved out of term.m containing code to do unifications.
Give all the predicates more meaningful names:
unify_term -> unify_terms
unify_term_list -> unify_term_lists
unify_term_dont_bind -> unify_terms_dont_bind
unify_term_list_dont_bind -> unify_term_lists_dont_bind
list_subsumes -> first_term_list_subsumes_second
library/term_vars.m:
A new module carved out of term.m containing code that find variables
in terms.
Give all the predicates more meaningful names:
vars -> vars_in_term
vars_2 -> vars_in_term_acc
vars_list -> vars_in_terms
contains_var -> term_contains_var
contains_var_list -> terms_contain_var
Don't move the function version of vars_2 to term_vars.m, effectively
deleting it, since operations that update an accumulator are awkward
for functions.
library/term.m:
Keep the moved predicates and functions in term.m, but
- change their implementation to simply call the moved copy, and
- obsolete the original in favor of the moved copy.
Eventually, after either the next release or the release after the next,
we should delete the obsoleted predicates and functions.
library/MODULES_DOC:
library/library.m:
Add the new modules as documented parts of the standard library.
browser/interactive_query.m:
compiler/analysis.file.m:
compiler/det_util.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/intermod.m:
compiler/make.module_dep_file.m:
compiler/make_hlds_passes.m:
compiler/parse_class.m:
compiler/parse_inst_mode_defn.m:
compiler/parse_item.m:
compiler/parse_mutable.m:
compiler/parse_pragma.m:
compiler/parse_pragma_analysis.m:
compiler/parse_sym_name.m:
compiler/parse_tree_to_term.m:
compiler/parse_type_defn.m:
compiler/parse_util.m:
compiler/prog_ctgc.m:
compiler/prog_util.m:
compiler/recompilation.used_file.m:
compiler/recompilation.version.m:
compiler/superhomogeneous.m:
compiler/switch_detection.m:
compiler/typecheck.m:
library/io.m:
library/term_conversion.m:
library/varset.m:
Conform to the changes above.
browser/declarative_analyser.m:
browser/declarative_debugger.m:
browser/declarative_oracle.m:
browser/declarative_tree.m:
browser/declarative_user.m:
browser/interactive_query.m:
browser/listing.m:
browser/parse.m:
browser/util.m:
Rename some predicates to avoid ambiguity.
Factor out common code.
If some versions of a field of a structure have names in a predicate
(by being stored in a named variable), then give all *other* versions
of that field in that structure names in that predicate as well.
If a field of a structure is used more than once in a predicate,
then again, store it in a named variable.
Reorder predicate arguments to put state variables last.
Use io.format instead of sequences of calls to io.write_string.
In declarative_user.m, note a probable bug (in a position where
it is probably rarely stumbled upon).
In listing.m, use a consistent naming scheme to differentiate
between Mercury streams and their C counterparts.
Replace if-then-else chains with switches where possible.
browser/name_mangle.m:
Note bit rot.
browser/browse.m:
Conform to the changes above.
library/io.m:
Improve predicate and variable names.
browser/mdb.m:
browser/mer_browser.m:
browser/percent_encoding.m:
browser/term_rep.m:
browser/tree234_cc.m:
library/library.m:
Improve comments.
browser/declarative_oracle.m:
Optimize table lookups when checking whether a procedure is trusted.
Instead of doing three separate lookups to test
- whether the module in which the procedure is in is trusted,
- whether the Mercury standard library is trusted, and this module
is in the Mercury standard library, and
- whether the predicate or function the procedure is in is trusted,
look up the module the procedure is in just once, then
- replace both of the first two lookups above with testing a single flag
each, and then
- look up the procedure in a map of trusted predicate or function names.
The last test should be faster than its old equivalent, because the map
it searches will be local to the module, whereas it used to be global.
Print the list of trusted entities (which this module calls trusted
"objects") in the same order regardless of whether we are printing
for users or as commands. The order will be the order in which they were
trusted.
Undo an unnecessary capitalization in the list of trusted objects.
browser/declarative_debugger.m:
Improve the style of some related code.
tests/debugger/save.exp:
tests/declarative_debugger/skip.exp:
tests/declarative_debugger/trust.exp:
Expect the changes described above in the list of trusted objects.
browser/declarative_oracle.m:
The code that checks whether the declarative debugger should trust
a module because it is a standard library module was apparently written
before any of module in the standard library had submodules, because
it checked the unqualified name of the module in question against
the *qualified* module names returned by the mercury_std_library_module
predicate.
For a long time after we had submodules such as thread.mvar.m in the
standard library, this caused no test failures, because our tests
did not execute code in those submodules. This changed with the breakup
of io.m. The move of the output_stream_2 predicate from io.m, which
this code recognized as trusted, to io.stream_ops.m, which it did not,
caused the declarative debugger to ask questions about the validity
of calls to it, which the caused the failure of the declarative_debugger/
all_trusted test case, due to its .inp file containing something other
than the corresponding answers.
Fix this for the case of module names of the forms a.b and a.b.c.
library/library.m:
Add a note to the mercury_std_library_module predicate to update
the code in declarative_oracle.m if we ever add a library module
whose fully qualified name has the form a.b.c.d.
tests/debugger/user_event_shallow.exp:
Update the expected output of this test for some ancient change.
tests/debugger/Mercury.options:
Specify the optimization level for the user_event_shallow test,
which eliminates one source of variability in the output.
Another source is intermodule optimization, which this diff does *not*
eliminate.
tests/debugger/all_solutions.exp:
tests/debugger/all_solutions.exp2:
tests/debugger/all_solutions.exp3:
tests/debugger/all_solutions.exp4:
tests/debugger/all_solutions.m:
The output of this test case in debug grades with intermodule optimization
did not match any of the .exp* files, though it differed from .exp2 only
in the text of an error message. (The difference was not a bug.)
Instead of adding this expected output as .exp5, use it to replace
the .exp3 file. This expected output file could not have been matched
in the last seven years, because it expects main/2 to be on line 16,
and that predicate's context has been line 20 since 2015.
Document the fact that .exp3 is the expected output for debug grade
bootchecks with intermodule optimization. This documentation changes
line numbers yet again, so update the line numbers in all the *other*
.exp* files as well.
tests/declarative_debugger/Mmakefile:
Fix indentation.
library/io.m:
library/io.stream_db.m:
Move the data types describing the stream database, and the
predicates and functions managing and accessing it, to the new
submodule io.stream_db.m. Move the declarations and definitions
of the global variables holding the dabase accordingly.
library/MODULES_UNDOC:
library/library.m:
List the new module as an undocumented new module.
browser/browse.m:
browser/browser_info.m:
library/stream.string_writer.m:
Get stream information from the new module.
library/io.call_system.m:
library/io.m:
As above.
browser/listing.m:
compiler/process_util.m:
Conform to the change above.
library/io.environment.m:
Delete stray ZZZ.
library/io.call_system.m:
Move the code in the "system access predicates" section of io.m
to this new module.
library/io.environment.m:
Move the predicates dealing with environment variables in io.m
to this new module.
library/io.m:
Delete the code moved to the new modules.
Leave behind in io.m "forwarding predicates", predicates that do nothing
except call the moved predicates in the new modules, to provide backward
compatibility. But do mark the forwarding predicates as obsolete,
to tell people to update their (at their leisure, since the obsoleteness
warning can be turned off).
Also leave behind in io.m the definitions of the types used
by some parameters of some of the moved predicates.
library/MODULES_DOC:
List the new modules among the documented modules.
library/library.m:
List the new modules, including io.file.m (added in a previous change)
among the documented standard library modules.
NEWS:
Announce the changes.
browser/browse.m:
browser/interactive_query.m:
compiler/fact_table.m:
compiler/handle_options.m:
compiler/make.module_target.m:
compiler/mercury_compile_main.m:
compiler/module_cmds.m:
compiler/optimize.m:
compiler/options_file.m:
deep_profiler/conf.m:
deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_test.m:
library/io.file.m:
mdbcomp/trace_counts.m:
ssdb/ssdb.m:
tests/general/environment.m:
tests/hard_coded/closeable_channel_test.m:
tests/hard_coded/setenv.m:
tests/hard_coded/system_sort.m:
Call the moved predicates directly in their new modules,
not indirectly through io.m.