compiler/add_foreign_proc.m:
Replace the ~220 line add_foreign_proc predicate with
eight smaller predicates here (and one in sym_name.m),
none of which exceed 55 lines.
mdbcomp/sym_name.m:
Add that one predicate, which will probably be useful
elsewhere as well.
Fix bad existing documentation.
mdbcomp/read_trace_counts.m:
Delete the mercury_trace_counts_list predicate, whose last
(and probably only) caller was deleted in 2006. Rename the types
and function symbols originally named after it.
Rename the read_trace_counts_source predicate to just
read_trace_counts_file, because the argument that specified
where it should get trace counts from (a single file, or a
list of files) was also deleted about two decaded ago.
The predicate originally named read_trace_counts, which this diff
renames to read_trace_counts_base, differed from the predicate
now named read_trace_counts_file only in the level of detail
they returned to their callers about any errors they found.
As it happens, the only call to read_trace_counts_base is from
read_trace_counts_file, because no callers need the extra info
about errors (which they can report, but cannot do anything about).
Therefore keep read_trace_counts_base private, and the mark it
for future merging with read_trace_counts_file.
mdbcomp/trace_counts.m:
Use an inst to encode an invariant in types for read_trace_counts.m.
compiler/tupling.m:
mdbcomp/slice_and_dice.m:
slice/mtc_diff.m:
Conform to the changes above.
mdbcomp/read_trace_counts.m:
mdbcomp/write_trace_counts.m:
Carve these two modules out of trace_counts.m.
Put the lowest-level building block, the read_trace_counts predicate,
last in read_trace_counts.m.
Stop exporting write_proc_label from write_trace_counts.m.
mdbcomp/trace_counts.m:
Delete the moved code, and export the trace_count_file_id function
to both new modules.
mdbcomp/mdbcomp.m:
Include the new modules.
deep_profiler/Mmakefile:
slice/Mmakefile:
Copy the new modules to these directories.
deep_profiler/.gitignore:
slice/.gitignore:
Ignore the newly-copied source files.
compiler/tupling.m:
mdbcomp/slice_and_dice.m:
slice/mcov.m:
slice/mtc_diff.m:
slice/mtc_union.m:
Update the set of imports needed.
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).
mdbcomp/feedback.feedback_info.m:
mdbcomp/feedback.m:
Move all the contents of feedback.m other than include_module items
into the new module feedback_info.m, leaving feedback.m a package.
mdbcomp/feedback.automatic_parallelism.m:
Group the types exported by this module into groups of related types.
Delete a totally unused type.
deep_profiler/Mmakefile:
slice/Mmakefile:
Copy the new module.
compiler/check_options.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/introduce_parallelism.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/mdprof_report_feedback.m:
Import the new module.
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.
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.
mdbcomp/prim_data.m:
Delete the pred_or_func_to_string function that used to be defined here,
and replace it with pred_or_func_to_str and pred_or_func_to_full_str
that used to be in parse_tree_out_misc.m. These two names make it
clear which one returns "pred" or "func", and which returns "predicate"
or "function".
compiler/parse_tree_out_misc.m:
Delete the functions moved to prim_data.m.
compiler/add_clause.m:
compiler/add_pred.m:
compiler/hlds_desc.m:
compiler/hlds_out_typeclass_table.m:
compiler/hlds_out_util.m:
compiler/make_hlds_error.m:
compiler/mlds_to_target_util.m:
compiler/mode_errors.m:
compiler/module_qual.qual_errors.m:
compiler/optimize.m:
compiler/parse_tree_out_sym_name.m:
compiler/polymorphism_lambda.m:
compiler/pred_name.m:
compiler/pred_table.m:
compiler/prog_type_test.m:
compiler/recompilation.check.m:
compiler/recompilation.used_file.m:
compiler/style_checks.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/write_error_spec.m:
Conform to the changes above, mostly by not importing
parse_tree_out_misc.m.
... and other minor fixes.
library/*.m:
library/LIB_FLAGS.in:
compiler/*.m:
mdbcomp/*.m:
Fix and update copyright notices.
Fix spelling.
Delete trailing whitespace.
mdbcomp/builtin_modules.m:
Rename mercury_std_lib_module_name to maybe_add_stdlib_wrapper,
since this better reflects its intended eventual purpose.
Add a companion predicate, maybe_remove_stdlib_wrapper, that acts
as its logical inverse.
Move related predicates next to each other.
Add an XXX about the inconsistent assumptions that many parts
of the Mercury implementation, including some parts of builtin_modules.m
itself, make about whether the eventually-to-be-added-wrapper can be
present in a module name, or not.
compiler/format_call.m:
compiler/get_dependencies.m:
Use the new predicate to help replace if-then-else chains testing
module names with switches. (It was the different assumptions made
by the original versions of these predicates that led to me changing
builtin_modules.m.)
compiler/add_pred.m:
compiler/builtin_lib_types.m:
compiler/prog_type.m:
compiler/simplify_goal_call.m:
compiler/type_util.m:
compiler/unused_imports.m:
Conform to the changes in builtin_modules.m.
library/string.builder.m:
Add the predicate string.builder.format. We already have
string.writer.format, one of whose instances, the one for
string.builder.{handle,state}, does a string.format and adds
the resulting string to the given string builder. The new predicate
allows this to be done directly, without the type class overhead
(both conceptual overhead, and compilation time overhead) in cases
where the generality of type class is not needed, and in a way that
allows format strings in direct calls to string.builder.format
to be parsed and interpreted at compile-time, the same way as we
already do for calls to e.g. io.format.
NEWS.md:
Announce the new predicate.
compiler/format_call.m:
Specialize calls to string.builder.format. Use the code that specializes
calls to io.format, after suitable generalization.
compiler/builtin_lib_types.m:
mdbcomp/builtin_modules.m:
Add convenience functions needed by new code in format_call.m.
compiler/get_dependencies.m:
In the presence of (potential) calls to string.builder.format,
implicitly import the modules that define the predicates that
format_call.m may now generate calls to.
compiler/introduced_call_table.m:
List string.builder.append_string as a predicate that format_call.m
may now introduce calls to.
tests/hard_coded/test_builder_format.{m,exp}:
A new test case to test the new functionality.
tests/hard_coded/Mmakefile:
Enable the new test case.
tests/warnings/format_call_warning.m:
Fix indentation.
This pragma, which has the form shown by this example,
:- pragma type_spec_constrained_preds(
[stream.line_oriented(Stream, State),
stream.unboxed_reader(Stream, char, State, Error),
stream.putback(Stream, char, State, Error)],
apply_to_superclasses,
[subst([Stream => io.text_input_stream,
State => io.state, Error => io.error])]).
allows programmers to ask the compiler to create type-specialized versions
of all predicates and functions, in a module and its submodules, that have
one or more of the specified typeclass constraints.
The first argument specifies these constraints, of which the example above
has three. The second argument specifies whether the request also applies
to predicates and functions whose signatures include superclasses of the
type classes involved (or *their* superclasses, and so on), not the named
type classes themselves. The third argument specifies the requested list
of one or more specializations, each of which consists of a substitution
that maps one or more type variables to a type. (A type that should not
itself be a type variable.) This example requests just one specialization
for each match.
compiler/prog_item.m:
Add a new kind of decl_pragma item to represent the new pragma.
Define the new types it needs.
Add some documentation of the invariants of existing item kinds.
compiler/prog_data.m:
Define ground_type, a subtype of mer_type, for use by prog_item.m.
compiler/prog_type_test.m:
Add a utility predicate for converting a type to a ground_type,
if it is indeed ground.
compiler/prog_data_pragma.m:
Change the definition of the type_subst type to use a purpose-specific
function symbol instead of the pair function symbol.
compiler/parse_pragma.m:
Add code to parse the new pragma, and to check the parsed form
to see whether it violates the requirements upon it.
Modify the code that parses plain old type_spec pragma to also allow
subst([State = io.state, Error = io.error]) syntax to be used
to specify type substitutions, as discussed on m-rev.
Modify the code that parses the old substitution syntax to use
the infrastructure of the new syntax, which can generate better
error messages.
Change this now-common code to allow the two sides of a substitution
to be separated by either an equal sign (such as "State = io.state")
or an arrow (such as "Error => io.error").
Improve the wording of some error messages.
Delete the code that accepted and then ignored a third argument
in type_spec pragmas. This code was needed only until a change committed
in July 2022 finished bootstrapping.
vim/syntax/mercury.vim:
Add the new pragma's name to the list of pragma keywords.
compiler/add_pragma.m:
compiler/add_pragma_type_spec.m:
Add code to process the new pragma. Add code to debug the processing
of the new pragma.
Change the code that processes the old type_spec pragma,
- to avoid using mode-specific clauses if the specialization applies
to the whole predicate and not just one procedure of it (this avoids
a bug that I reported on m-rev on 2024 feb 2), and
- to set the context of type-specialized predicates to match the original
predicates, instead of leaving them set to the default context, which
is a dummy context (this helps avoid error messages whose lack of context
can make it hard to figure out what exactly they are complaining about).
compiler/options.m:
doc/user_guide.texi:
Add an option that add_pragma_type_spec.m now consults to decide
whether to report the type_spec pragmas generated to implement each
type_spec_constrained_preds pragma. The documentation of this option
is commented out. It should be made visible to users once we have
(a) gathered sufficient experience with the new pragma to have confidence
in it, and (b) documented the pragma itself.
Add a way to check whether this diff exists in the compiler.
compiler/handle_options.m:
Automatically disable the new option for all invocations other than
those that generate code or check errors, since the output they generate
would be more distracting than useful e.g. when making .intN files.
compiler/parse_class.m:
Restructure the code that selects superclass constraints (constraints
on typeclass declarations) out of the whole set of constraints that
a predicate that is designed to parse constraints on *predicate*
declarations has parsed. The two use cases are different, because
neither inst constraints, nor typeclass constraints involving
partially-specified types, are allowed in typeclass declarations.
The restructure allows us to improve the error messages we generate
if and when any such disallowed constraints are found.
compiler/parse_tree_out_pragma.m:
Add code to output the new pragma.
Add code to try to avoid putting redundant parentheses around
name/arity pairs. It needs new code to be enabled in
parse_tree_out_sym_name.m to work.
compiler/parse_tree_out_type.m:
Generalize (and rename) an existing function.
compiler/parse_tree_out_sym_name.m:
Add code (commented out for now) that can avoid putting redundant
parentheses around name/arity pairs.
compiler/maybe_error.m:
Define maybeN for N = 6, to join N = {1,2,3,4,5}, for use by new code
above.
mdbcomp/sym_name.m:
Fix a misleading predicate name.
compiler/hlds_class.m:
Document an invariant.
compiler/hlds_module.m:
Replace a multi_map with a one_or_more_map, and give a name to the type.
compiler/parse_item.m:
Fix comments.
compiler/parse_tree_out_inst.m:
Add a new utility function needed by other code in this diff.
compiler/hlds_out_typeclass_table.m:
Clarify the typeclass table part of HLDS dumps.
compiler/check_import_accessibility.m:
compiler/check_typeclass.m:
compiler/convert_parse_tree.m:
compiler/equiv_type.m:
compiler/intermod.m:
compiler/item_util.m:
compiler/make_hlds_passes.m:
compiler/make_hlds_separate_items.m:
compiler/module_qual.qual_errors.m:
compiler/module_qual.qualify_items.m:
compiler/parse_type_name.m:
compiler/pred_name.m:
compiler/prog_item_stats.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
mdbcomp/slice_and_dice.m:
Conform to the changes above.
compiler/prog_type_unify.m:
Fix indentation.
tests/hard_coded/type_spec_modes.m:
Modify this test to see whether the code parsing type substitutions
in type_spec pragmas using the new syntax works.
tests/invalid_nodepend/typeclass_test_3.err_exp:
Expect the improved error message parse_class.m now generates.
tests/invalid_nodepend/bad_tscp.{m,exp}:
Add this test case to check the error messages generated by parse_pragma.m
to report the problems it detects in malformed type_spec_constrained_preds
pragmas.
tests/invalid_nodepend/Mmakefile:
Enable the new test case.
tests/warnings/test_tscp.{m,exp}:
Add a test case that checks whether, given a list of the new pragmas,
the compiler generates the expected set of type_spec pragmas.
tests/warnings/{Mmakefile,Mercury.options}:
Enable the new test case.
mdbcomp/mdbcomp.goal_path.m:
As above. Instead of using -1 to represent invalid goal_ids, 0 to
represent whole body goals, and higher values to represent subgoals,
use 0 to represent invalid goal_ids, 1 to represent whole body goals,
and higher values to represent subgoals.
Add a function to return invalid goal_ids, to avoid the need
for knowledge of this scheme outside this module.
compiler/build_mode_constraints.m:
compiler/closure_gen.m:
compiler/coverage_profiling.m:
compiler/goal_path.m:
compiler/hlds_goal.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_pred.m:
compiler/mode_constraint_robdd.m:
compiler/mode_constraints.m:
compiler/ordering_mode_constraints.m:
compiler/state_var.m:
compiler/unneeded_code.m:
deep_profiler/program_representation_utils.m:
Conform to the changes above.
configure.ac:
Require the installed compiler to support both the option,
and the Mmake rules that invoke it.
compiler/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
mfilterjavac/Mmakefile:
ssdb/Mmakefile:
Get the mmake depend to depend on prog.depend_ints, not prog.depend,
Give the prog.depend_ints targets themselves the same prerequisites
as the existing prog.depend targets.
In mfilterjavac/Mmakefile, fix what looks like an old problem
by making the depend target a prerequisite of the check and ints targets.
*/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.
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.
compiler/hlds_pred.m:
Replace the arity field in pred_infos with a pred_form_arity field.
Move the pred_info's pred_or_func field to its usual position
in predicate/function descriptions: at the front (pred/func name/arity).
compiler/hlds_pred.m:
Change two utility operations to return pred_form_arities instead of
just arities, since they get them from pred_infos.
compiler/inst_mode_type_prop.m:
compiler/llds.m:
compiler/rtti.m:
Change some fields whose types used to be arity (or int) to be
pred_form_arity.
In llds.m, include a pred_or_func field in c_procedures,
for use in procedure-start comments.
mdbcomp/prim_data.m:
mdbcomp/program_representation.m:
Add notes about two possible future improvements along similar lines.
compiler/prog_data.m:
Add a utility function to calculate the number of extra arguments
added to predicates/functions by compiler passes such as polymorphism.
compiler/add_pragma.m:
Conform to the changes above.
Fix a bug in an error message about ":- external" pragmas:
the message used the pred_form arity instead of the user arity.
(See the diff to external2.err_exp below.)
compiler/hlds_defns.m:
Conform to the changes above.
Include pred/func prefixes before name/arity pairs in the output
where relavnt. (The user guide does not need to be updated, because
its wording permits both the old and the new behavior.)
Fix two separate bugs that referred to functions in user-facing output
with the predicate form of their arity.
compiler/table_gen.m:
compiler/unused_args.m:
Conform to the changes above.
Fix a bug in each module that referred to functions in user-facing output
with the predicate form of their arity.
compiler/recompilation.usage.m:
compiler/xml_documentation.m:
Conform to the changes above.
Mark a probable bug in each module with an XXX.
compiler/direct_arg_in_out.m:
Conform to the changes above.
Improve the wording of an error message a bit.
(See the diff to gh72_errors.err_exp below.)
compiler/accumulator.m:
compiler/bytecode_gen.m:
compiler/complexity.m:
compiler/default_func_mode.m:
compiler/det_report.m:
compiler/distance_granularity.m:
compiler/equiv_type_hlds.m:
compiler/exception_analysis.m:
compiler/higher_order.m:
compiler/hlds_defns.m:
compiler/hlds_error_util.m:
compiler/hlds_module.m:
compiler/intermod.m:
compiler/intermod_order_pred_info.m:
compiler/introduce_exists_casts.m:
compiler/introduce_parallelism.m:
compiler/llds_out_file.m:
compiler/mercury_compile_llds_back_end.m:
compiler/ml_accurate_gc.m:
compiler/ml_args_util.m:
compiler/mode_errors.m:
compiler/modecheck_util.m:
compiler/modes.m:
compiler/old_type_constraints.m:
compiler/optimize.m:
compiler/polymorphism.m:
compiler/polymorphism_goal.m:
compiler/post_typecheck.m:
compiler/pre_typecheck.m:
compiler/pred_table.m:
compiler/proc_gen.m:
compiler/rbmm.region_transformation.m:
compiler/recompilation.usage.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/simplify_goal_call.m:
compiler/ssdebug.m:
compiler/table_gen.m:
compiler/tabling_analysis.m:
compiler/term_constr_initial.m:
compiler/termination.m:
compiler/trailing_analysis.m:
compiler/transform_llds.m:
compiler/tupling.m:
compiler/type_class_info.m:
compiler/typecheck.m:
compiler/typecheck_error_undef.m:
compiler/types_into_modes.m:
compiler/xml_documentation.m:
Conform to the changes above.
compiler/recompilation.m:
Add a note.
compiler/parse_tree_out_sym_name.m:
Improve variable names.
tests/invalid/external2.err_exp:
Expect the fixed arity in an error message.
tests/invalid/gh72_errors.err_exp:
Expect the expanded text of an error message.
mdbcomp/mdbcomp.goal_path.m:
Replace clauses with an explicit switch.
mdbcomp/mdbcomp.m:
Provide C# and Java definitions of the version predicate.
Mdb needs this library only in C grades, but the compiler
has access to it even in C# and Java grades.
mdbcomp/shared_utilities.m:
Fix style.
mdbcomp/slice_and_dice.m:
Replace if-then-else chains with switches.
mdbcomp/sym_name.m:
Document a predicate.
mdbcomp/feedback.m:
... by avoiding the overuse of higher order code and exceptions.
(The old code tried to catch exceptions, even though the code in the
try block shouldn't be able to throw any.)
Document a vulnerability in the use io.read/io.write on feedback files,
which was discussed on m-rev in 2008 July when this file was created.