browser/browse.m:
Add save_and_browse_browser_term_web to be called when
"browse --web" is entered at the mdb prompt.
Add browser_term_to_html_flat_string, a helper predicate for
term_to_html.
Make portray_flat_write_browser_term work take a stream parameter
instead of writing to the current output stream. It is called by
browser_term_to_html_flat_string, writing to a string builder
stream.
browser/browser_info.m:
Add web_browser_cmd field to browser_persistent_state.
browser/mdb.m:
browser/term_to_html.m:
Add new module to generate an HTML document. The document contains a
JavaScript represention of a Mercury term.
(The JavaScript string escaping code is adapted from Julien's
mercury-json project.)
browser/percent_encoding.m:
Add new module to perform percent-encoding.
scripts/mdb_term_browser.css:
scripts/mdb_term_browser.js:
Add JavaScript and CSS files referenced by the generated HTML file
to create a tree view of a Mercury term using jstree.
scripts/32px.png:
scripts/40px.png:
scripts/throbber.gif:
scripts/jstree.min.js:
scripts/jstree.style.min.css:
Add local copy of jstree files <https://www.jstree.com/>
scripts/jquery.slim.min.js:
Add local copy of jquery <https://jquery.com/>
scripts/Mmakefile:
Install the new files into the same directory as mdbrc and other
mdb-related files.
trace/mercury_trace_browse.c:
trace/mercury_trace_browse.h:
trace/mercury_trace_cmd_browsing.c:
trace/mercury_trace_cmd_parameter.c:
trace/mercury_trace_cmd_parameter.h:
trace/mercury_trace_internal.c:
Add "browse --web" and "web_browser_cmd" commands.
doc/user_guide.texi:
Document "browse --web" and "web_browser_cmd" commands.
configure.ac:
scripts/mdbrc.in:
Set a reasonable default command to launch a web browser from mdb.
(Only tested on Linux.)
NEWS:
Announce the new feature.
.README.in:
Mention jquery and jstree licensing.
tests/debugger/Mmakefile:
tests/debugger/completion.exp:
tests/debugger/mdb_command_test.inp:
tests/debugger/save.exp2:
Update debugger tests for new commands.
Many predicates that do their jobs via foreign_procs in C have a fallback
Mercury clause for non-C backends, which usually throws an exception.
When compiled in non-C grades, these often get a warning that their
determinism declaration could have been tigther, e.g. erroneous instead of det.
*.m:
Add no_determinism_warnings pragmas before such fallback clauses.
library/dir.m:
As above, but also remove the unnecessary "dir." prefix on many predicate
declarations and clause heads.
browser/browse.m:
browser/browser_info.m:
browser/collect_lib.m:
browser/debugger_interface.m:
browser/declarative_analyser.m:
browser/declarative_debugger.m:
browser/declarative_edt.m:
browser/declarative_execution.m:
browser/declarative_oracle.m:
browser/declarative_test.m:
browser/declarative_tree.m:
browser/declarative_user.m:
browser/diff.m:
browser/dl.m:
browser/frame.m:
browser/help.m:
browser/interactive_query.m:
browser/io_action.m:
browser/listing.m:
browser/mdb.m:
browser/mer_browser.m:
browser/name_mangle.m:
browser/term_rep.m:
browser/tree234_cc.m:
Fix inconsistencies between (a) the order in which functions and predicates
are declared, and (b) the order in which they are defined.
In most modules, either the order of the declarations or the order
of the definitions made sense, and I changed the other to match.
In some modules, neither made sense, so I changed *both* to an order
that *does* make sense (i.e. it has related predicates together).
In some places, put dividers between groups of related
functions/predicates, to make the groups themselves more visible.
In some places, fix comments or programming style.
browser/MDB_FLAGS.in:
Since all the modules in this directory are now free from any warnings
generated by --warn-inconsistent-pred-order-clauses, specify that option
by default in this directory to keep it that way.
browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_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:
Add --warn-unused-imports to the list of default compiler flags
for each directory.
compiler/ml_tailcall.m:
library/io.m:
Delete some unused imports.
The -install_name option broke building with mmake --use-mmake-make on
other operating systems.
browser/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
ssdb/Mmakefile:
As above.
library/pretty_printer.m:
Make the changes indicated by the NOTE_TO_IMPLEMENTORS notes
in my previous change.
NEWS:
Announce the changes.
browser/browse.m:
tests/hard_coded/test_pretty_printer.m:
Conform to the above change.
This fixes Mantis bug #412.
compiler/unused_imports.m:
Consider that an instance declaration makes a module "used" only if
it occurs in the module being compiled, not in an imported or ancestor
module. (Mantis bug 412 was caused by instance declarations in implicitly
imported modules.)
Fixing #412 also exposed another bug. When computing the set of modules
used by predicates, we considered (besides some non-type entities)
only the types of the predicate's arguments, not the types of non-argument
variables. In one case in the compiler (mmc_analysis.m), this lead to
some actually-used modules not being marked as such, which lead to
false unused-import warnings to be generated for them. Fix this by scanning
the types of all variables in all of a predicate's procedures, not just
the arguments.
Improve the infrastructure for debugging similar problems.
Note some possibilities for future improvement.
Change a predicate name to fit the naming scheme.
compiler/analysis.m:
Add an XXX about a possible improvement.
compiler/hlds_out_module.m:
Make the output we generate for instance methods more readable.
As part of this, fix an old bug in the printing of the instance table:
the first line of the first method of each concrete instance declaration
was accidentally commented out.
compiler/parse_tree_out.m:
Export a different utility predicate for hlds_out_module.m. Make its name
conform to the scheme used by related predicates.
browser/browse.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pred.m:
compiler/add_special_pred.m:
compiler/check_for_missing_type_defns.m:
compiler/check_promise.m:
compiler/exception_analysis.m:
compiler/handle_options.m:
compiler/inst_match.m:
compiler/mercury_to_mercury.m:
compiler/ml_tailcall.m:
compiler/module_qual.m:
compiler/op_mode.m:
compiler/parse_inst_mode_defn.m:
compiler/parse_tree_out_clause.m:
compiler/parse_tree_out_info.m:
compiler/parse_tree_out_inst.m:
compiler/parse_tree_out_pragma.m:
compiler/parse_tree_out_pred_decl.m:
compiler/parse_tree_out_term.m:
compiler/parse_type_defn.m:
compiler/parse_type_name.m:
compiler/parse_util.m:
compiler/parse_vars.m:
compiler/prog_ctgc.m:
compiler/recompilation.usage.m:
compiler/resolve_unify_functor.m:
compiler/term_constr_main.m:
compiler/term_constr_main_types.m:
compiler/write_deps_file.m:
library/bt_array.m:
Delete unused imports.
compiler/module_qual.qual_errors.m:
Import a module that the parent module_qual.m doesn't import anymore.
tests/warnings/bug412.{m,exp}:
The test case for this bug.
tests/warnings/Mmakefile:
tests/warnings/Mercury.options:
Enable the new test case.
tests/invalid/import_in_parent.err_exp:
Update the expected output for this test case. The parent module
does not use the imported module (bool) at all, so this is what the
error message says after this diff, though its submodule does use bool.
browser/browser_info.m:
Avoid using "output" (and "input", for the sake of symmetry)
as function symbols.
browser/debugger_interface.m:
Avoid using "pred" and "func" as function symbols by putting a prefix
before each function symbol in the affected type.
browser/dl.m:
Avoid using "local" (and "global", again for symbols) as function symbols.
profiler/output_prof_info.m:
Avoid using "output" as a type name and as a function symbol.
browser/browse.m:
browser/collect_lib.m:
browser/declarative_user.m:
browser/interactive_query.m:
profiler/generate_output.m:
profiler/output.m:
Conform to the changes above.
extras/morphine/source/browse.op:
extras/morphine/source/collect.op:
extras/morphine/source/current_arg.op:
extras/morphine/source/current_slots.op:
extras/morphine/source/exec_control.op:
extras/morphine/source/forward_move.op:
extras/morphine/source/interactive_queries.op:
Conform to the renames of the function symbols in debugger_interface.m.
Since this code is in Prolog, I cannot be sure that I changed all the
places that should be changed, but that does not matter much.
Since Morphine was designed to work with the Prolog dialects of 1999,
had its last update in 2002, and we never test it, it is very likely
that it hasn't worked in a long time. We keep it around because
(a) it may interest someone, and (b) it doesn't require significant
maintenance. The fact that it does not run may be regrettable, but
it is not actually regretted by many would-be users, or (even) any at all.
(I actually noticed and fixed a bug while doing the above change:
it was a typo in a function symbol name.)
Add new predicates and functions take_while and drop_while to the list
module.
Deprecate takewhile/4, replacing it with take_while/4.
library/list.m:
As above.
NEWS:
Announce this change.
browser/parse.m:
compiler/compute_grade.m:
compiler/deforest.m:
compiler/mercury_compile_main.m:
compiler/ml_optimize.m:
compiler/mode_robdd.equiv_vars.m:
compiler/options_file.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.domain.m:
compiler/structure_sharing.domain.m:
compiler/term_constr_data.m:
compiler/write_deps_file.m:
compiler/xml_documentation.m:
deep_profiler/read_profile.m:
deep_profiler/top_procs.m:
library/list.m:
Conform to above changes.
Estimated hours taken: 26
Implement the following improvements:
- Pass mdb variable bindings to the interactive query processor,
allowing queries to make use of live values.
- Catch exceptions thrown by queries, rather than crashing mdb.
- Write outputs using io.write_cc/3.
- Don't output underscore variables, avoiding spurious warnings.
- More protection of the user's namespace.
- Updated the cleanup code.
browser/interactive_query.m:
The interface now accepts corresponding lists of names and values,
which are matched up with variables occurring in the queries.
Replace the code generator with one that supports passing data
to and from the query, and catching exceptions from the query.
Pass the appropriate data at the time the query predicate is called.
Distinguish between failure of the query and failure of the dynamic
casts used to instantiate the query inputs.
Use module qualifiers to avoid clashing with user imports. (Should the
generated code use use_module, just in case?)
Perform I/O, failure handling and exception handling in the caller
instead of in the generated code. This is faster, more maintainable,
and means that errors are caught earlier.
Place source_file and line directives more carefully so as to ensure
more consistent error messages, and to help distinguish errors in the
template from errors in the query.
Factor out the query command parser to avoid double maintenance.
browser/debugger_interface.m:
Conform to above changes.
trace/mercury_trace_vars.[ch]:
Export MR_trace_return_bindings, which constructs Mercury lists
of the variable names and values in the current environment.
trace/mercury_trace_browse.c:
Pass bindings from trace/mercury_trace_vars through to the interactive
query processor.
tests/debugger/interactive.{m,inp,exp}:
Update for changes to existing functionality. Additionally test the
new functionality.
doc/user_guide.texi:
Document the new behaviour.
NEWS:
Announce the new behaviour.
The install names for Mercury shared libraries in the system were not being set
when building using --use-mmc-make. The existing code in the Mmakefiles that
does this only works for mmake, not mmc --make.
browser/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
ssdb/Mmakefile:
When using --use-mmc-make set up the options to set the dylib install
names in such a way that mmc --make can see them.
Don't hardcode the library names in the definitions that set the
library install names.
browser/browse.m:
Rename the version of the I/O state used inside a trace goal
in order to avoid a warning about it shadowing the version in
the enclosing scope.
browser/browse.m:
browser/declarative_edt.m:
compiler/continuation_info.m:
compiler/hlds_out_goal.m:
compiler/llds_out_file.m:
compiler/make.dependencies.m:
compiler/ml_closure_gen.m:
compiler/ml_elim_nested.m:
compiler/options_file.m:
compiler/prog_io_pragma.m:
deep_profiler/html_format.m:
Delete some dead predicates that won't be needed anymore.
compiler/hlds_goal.m:
compiler/jumpopt.m:
Comment out some dead predicates that may be needed later.
compiler/matching.m:
compiler/typecheck.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Convert some dead predicates into live predicates by adding calls to them
at their intended call sites. In some cases the missing call was a sort-of
bug (the code worked, but not as well as it should have). In others, the
call was intended only for debugging, and the new call is in a trace scope
that is disabled by default.
compiler/ml_foreign_proc_gen.m:
Add an XXX comment about a dead procedure.
Update the list of changes in the NEWS file that potentially break backwards
compatibility.
library/builtin.m:
Delete the builtin inst synonyms 'old' and 'new'.
Delete the builtin builtin modes 'oo' and 'no'.
Add a comment stating that the modes input/0 and output/0 are deprecated.
Add obsolete pragmas for promise_only_solution/1 and
promise_only_solution_io/4.
Shift the description of the 'any' inst into the comment describing
the other builtin insts. Add the higher-order 'any' insts to this
comment.
Fix a typo in the description of the builtin higher-order insts: the
determinism is not required to be det.
browser/term_rep.m:
Replace calls to promise_only_solutions/1 with promise_equivalent_solutions
goals.
mdbcomp/trace_counts.m:
Replace a call to promise_only_solution_io/4 with a
promise_equivalent_solutions goal.
Add an XXX comment about hardcoding executable names.
NEWS:
Announce the deletion of 'old', 'new', '
List the addition of the 'for' operator as a change that may break
backwards compatibility.
Announce that the compiler no longer allows builtin types, insts and
modes to be redefined.
Packages are modules whose only job is to serve as a container for submodules.
Modules like top_level.m, hlds.m, parse_tree.m and ll_backend.m are packages
in this (informal) sense.
Besides the include_module declarations for their submodules, most of the
packages in the compiler used to import some modules, mostly other packages
whose component modules their submodules may need. For example, ll_backend.m
used to import parse_tree.m. This meant that modules in the ll_backend package
did not have to import parse_tree.m before importing modules in the parse_tree
package.
However, this had a price. When we add a new module to the parse_tree package,
parse_tree.int would change, and this would require the recompilation of ALL
the modules in the ll_backend package, even the ones that did NOT import ANY
of the modules in the parse_tree package.
This happened even at one remove. Pretty much all modules in every one
of the backend have to import one or more modules in the hlds package,
and they therefore have import hlds.m. Since hlds.m imported transform_hlds.m,
any addition of a new middle pass to the transform_hlds package required
the recompilation of all backend modules, even in the usual case of the two
having nothing to do with each other.
This diff removes all import_module declarations from the packages,
and replaces them with import_module declarations in the modules that need
them. This includes only a SUBSET of their child modules and of the non-child
modules that import them.
compiler/module_qual.m:
The interface of a module A contains items (e.g. predicate declarations)
that refer to entities such as types, insts, modes etc. They may refer
to those entities if (a) they are defined in the interface of module A,
(b) in a parent module of module A, or (c) if they are imported from
another module, module B, which is imported into module A in the interface
of module A.
The old algorithm that attempted to enforce this requirement had a basic
design fault: it based the decision as to whether the use of an entity
in the interface was legal solely on the name of the module that defined
that entity. This correctly implements tests (b) and (c), but it does
not even attempt to implement the interface test part of (a).
It therefore allowed exported items to refer to nonexported entities.
This diff changes the whole design approach to the test. Instead of
keeping a list of modules *all* of whose entities may be used in the
interface of the current module, record for *every* entity whether
it may be used in the interface. Set the permissions differently
in the interface and implementation sections of the current module.
Improve the formatting of the ambiguity error message.
NEWS:
Announce the stricter enforcement of the documented language rules,
in a new section for potentially compatibility-breaking changes.
compiler/check_typeclass.m:
Delete a test for a special case of the situation that module_qual.m
now tests for. If this problem occurs, module_qual.m will pick it up,
and check_typeclass.m will never even be invoked, so this copy of the test
can never succeed.
library/hash_table.m:
Fix code that violated the language rules: we export a type that
includes another type, but didn't export the second type. We now do.
browser/declarative_analyser.m:
browser/declarative_edt.m:
compiler/coverage_profiling.m:
Fix code that violated the language rules. We used to export predicates
and functions whose argument types included nonexported types. As it
happens, none of those predicates and functions actually need to be
exported, so keep them private.
In coverage_profiling.m, don't abstract export a type that is not
used outside the module, and give a function a name that doesn't
clash with a type name.
tests/invalid/bug17.{m,err_exp}:
A new test case to test the error message we get if the module interface
refers to a nonexported type.
tests/invalid/bad_instance.err_exp:
This test case used to get two kinds of errors, one of which was
the illegal use of nonexported type in an exported abstract instance
declaration. We now discover this error earlier, and stop after we
do so. Update the expected error message.
tests/invalid/bad_instance2.{m,err_exp}:
New test case: a modified copy of bad_instance.m, testing the other
kind of error originally tested by bad_instance.m.
tests/invalid/instance_no_type.err_exp:
Update the expected error message.
tests/invalid/Mmakefile:
Enable the new test cases.
tests/benchmarks/query.m:
tests/hard_coded/unused_float_box_test.m:
tests/valid/bug300.m:
tests/valid/deforest_bug.m:
tests/valid/higher_order4.m:
tests/valid/lambda_recompute.m:
tests/valid/mert.m:
tests/valid/reuse_static.m:
tests/valid/switch_detection_bug2.m:
tests/valid/time_yaowl.m:
tests/warnings/unused_args_test.m:
Fix code that violated the language rules, typically by exporting
the type that previously, we illegally used in the module interface.
tests/recompilation/add_type_re.err_exp.2:
Expect the updated ambiguity error message.
browser/browser_info.m:
Replace the old "dir" type and "dir_no_parent" inst with
two distinct types: up_down_dir and down_dir.
browser/browse.m:
browser/declarative_user.m:
browser/parse.m:
Replace uses of the old dir type with one of the new types,
adding conversions as needed. The separate types make it much clearer
where ".." dir steps may appear and where they may not.
In one case, this extra clarity allows us to avoid calling simplify_dirs
(which eliminates ".." dir steps) twice in a row.
In some other cases, it allows us to replace three-way switches
in which the .. case contained a "this can't happen" assertions
with a two-way switch (between numbered and named child directories).
This should be faster as well as safer. We now allow ".." dir steps
only when the user types in directory paths, and we convert them to
downward-only directory paths immediately afterward.
Simplify the code that writes out directory paths.
The code that takes the function out of the term can use the function
as if it had the default signature. If it doesn't, this can lead to
This fixes Mantis bug 264.
compiler/mode_errors.m:
Provide a way to record such errors, and to print error messages for them.
compiler/modecheck_unify.m:
Look for such errors when constructing terms.
browser/declarative_user.m:
Don't put a function with a nondefault signature (it used a subtype)
into a term. Enforce the subtype with a runtime assertion instead.
doc/reference_manual.texi:
Document the new limitation.
tests/invalid/default_ho_inst.{m,err_exp}:
The test case for Mantis bug 264.
tests/invalid/Mmakefile:
Enable the new test case.
tests/valid/Mmakefile:
Disable the old ho_func_call test case, since it RELIES on putting
functions with nondefault modes into terms. It also uses I/O states
in ui modes.
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_managed.m:
compiler/il_peephole.m:
compiler/ilasm.m:
compiler/ilds.m:
Delete the modules making up the MLDS->IL code generator.
compiler/globals.m:
compiler/prog_data.m:
Delete IL as a target and foreign language.
compiler/prog_io_pragma.m:
Delete the max_stack_size/1 foreign proc attribute. This was only
ever required by the IL backend.
compiler/options.m
Delete options used for the IL backend.
compiler/write_deps_file.m:
Don't generate mmake targets for .il files etc.
compiler/*.m:
Conform to the above changes.
compiler/notes/compiler_design.html
compiler/notes/work_in_progress.html
Conform to the above changes.
library/*.m:
Delete IL foreign_proc and foreign_export pragmas.
README.DotNet:
Delete this file.
browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
mdbcomp/Mmakefile:
mfilterjavac/Mmakefile:
profiler/Mmakefile:
runtime/Mmakefile:
slice/Mmakefile:
Conform the above changes.
configure.ac:
Don't check that IL is a supported foreign language when performing the
up-to-date check.
Delete the '--enable-dotnet-grades' option.
scripts/Mmake.vars.in:
Delete variables used for the IL backend (and in on case by the Aditi
backend).
scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
scripts/Mmake.rules:
scripts/canonical_grade.sh-subr:
tools/bootcheck:
Delete stuff related to the 'il' and 'ilc' grades.
doc/reference_manual.texi:
Delete the documentation of the 'max_stack_size' option.
doc/user_guide.texi:
Delete stuff related to the IL backend.
tests/hard_coded/csharp_test.{m,exp}:
tests/invalid/foreign_type_missing.{m,err_exp}:
tests/valid/csharp_hello.m:
Delete these tests: they are no longer relevant.
tests/hard_coded/equality_pred_which_requires_boxing.m:
tests/hard_coded/foreign_import_module.m:
tests/hard_coded/foreign_import_module_2.m:
tests/hard_coded/foreign_type.m:
tests/hard_coded/foreign_type2.m:
tests/hard_coded/foreign_type3.m:
tests/hard_coded/intermod_foreign_type2.m:
tests/hard_coded/lp.m:
tests/hard_coded/user_compare.m:
tests/invalid/foreign_type_2.m:
tests/invalid/foreign_type_missing.{m,err_exp}:
tests/invalid/foreign_type_visibility.m:
tests/invalid/illtyped_compare.{m,err_exp}:
tests/submodules/external_unification_pred.m
tests/valid/big_foreign_type.m
tests/valid/solver_type_bug.m
tests/valid_seq/foreign_type_spec.m
tests/valid_seq/intermod_impure2.m
Delete IL foreign_procs where necessary.
tests/hard_coded/Mmakefile
tests/invalid/Mercury.options
tests/invalid/Mmakefile
tests/submodules/Mmakefile
tests/valid/Mercury.options
tests/valid/Mmake.valid.common
tests/valid/Mmakefile
tests/valid_seq/Mmakefile
tests/valid_seq/Mercury.options
Conform to the above changes.
browser/name_mangle.m:
Fix a problem that was preventing interactive queries (and dynamic
linking) from working in asm_fast grades on OS X. On OS X, the dlsym
function will add the underscore prefix to the symbol name for us,
so this module does not need to add to it to asm labels itself.
NEWS:
Announce that interactive queries now work on OS X.
If a module has two or more import_module or use_module declarations
for the same module, (typically, but not always, one being in its interface
and one in its implementation), generate an informational message about
each redundant declaration if --warn-unused-imports is enabled.
compiler/hlds_module.m:
We used to record the set of imported/used modules, and the set of
modules imported/used in the interface of the current module. However,
these sets
- did not record the distinction between imports and uses;
- did not allow distinction between single and multiple imports/uses;
- did not record the locations of the imports/uses.
The first distinction was needed only by module_qual.m, which *did*
pay attention to it; the other two were not needed at all.
To generate messages for imports/uses shadowing other imports/uses,
we need all three, so change the data structure storing such information
for *direct* imports to one that records all three of the above kinds
of information. (For imports made by read-in interface and optimization
files, the old set of modules approach is fine, and this diff leaves
the set of thus *indirectly* imported module names alone.)
compiler/unused_imports.m:
Use the extra information now available to generate a
severity_informational message about any import or use that is made
redundant by an earlier, more general import or use.
Fix two bugs in the code that generated warnings for just plain unused
modules.
(1) It did not consider that a use of the builtin type char justified
an import of char.m, but without that import, the type is not visible.
(2) It scanned cons_ids in goals in procedure bodies, but did not scan
cons_ids that have been put into the const_struct_db. (I did not update
the code here when I added the const_struct_db.)
Also, add a (hopefully temporary) workaround for a bug in
make_hlds_passes.m, which is noted below.
However, there are at least three problems that prevent us from enabling
--warn-unused-imports by default.
(1) In some places, the import of a module is used only by clauses for
a predicate that also has foreign procs. When compiled in a grade that
selects one of those foreign_procs as the implementation of the predicate,
the clauses are discarded *without* being added to the HLDS at all.
This leads unused_imports.m to generate an uncalled-for warning in such
cases. To fix this, we would need to preserve the Mercury clauses for
*all* predicates, even those with foreign procs, and do all the semantic
checks on them before throwing them away. (I tried to do this once, and
failed, but the task should be easier after the item list change.)
(2) We have two pieces of code to generate import warnings. The one in
unused_imports.m operates on the HLDS after type and mode checking,
while module_qual.m operates on the parse tree before the creation of
the HLDS. The former is more powerful, since it knows e.g. what types and
modes are used in the bodies of predicates, and hence can generate warnings
about an import being unused *anywhere* in a module, as opposed to just
unused in its interface.
If --warn-unused-imports is enabled, we will get two separate set of
reports about an interface import being unused in the interface,
*unless* we get a type or mode error, in which case unused_imports.m
won't be invoked. But in case we do get such errors, we don't want to
throw away the warnings from module_qual.m. We could store them and
throw them away only after we know we won't need them, or just get
the two modules to generate identical error_specs for each warning,
so that the sort_and_remove_dups of the error specs will do the
throwing away for us for free, if we get that far.
(3) The valid/bug100.m test case was added as a regression test for a bug
that was fixed in module_qual.m. However the bug is still present in
unused_imports.m.
compiler/make_hlds_passes.m:
Give hlds_module.m the extra information it now needs for each item_avail.
Add an XXX for a bug that cannot be fixed right now: the setting of
the status of abstract instances to abstract_imported. (The "abstract"
part is correct; the "imported" part may not be.)
compiler/intermod.m:
compiler/try_expand.m:
compiler/xml_documentation.m:
Conform to the change in hlds_module.m.
compiler/module_qual.m:
Update the documentation of the relationship of this module
with unused_imports.m.
compiler/hlds_data.m:
Document a problem with the status of instance definitions.
compiler/hlds_out_module.m:
Update the code that prints out the module_info to conform to the change
to hlds_module.m.
Print status information about instances, which was needed to diagnose
one of the bugs in unused_imports.m. Format the output for instances
nicer.
compiler/prog_item.m:
Add a convenience predicate.
compiler/prog_data.m:
Remove a type synonym that makes things harder to understand, not easier.
compiler/modules.m:
Delete an XXX that asks for the feature this diff implements.
Add another XXX about how that feature could be improved.
compiler/Mercury.options.m:
Add some more modules to the list of modules on which the compiler
should be invoked with --no-warn-unused-imports.
compiler/*.m:
library/*.m:
mdbcomp/*.m:
browser/*.m:
deep_profiler/*.m:
mfilterjavac/*.m:
Delete unneeded imports. Many of these shadow other imports, and some
are just plain unneeded, as shown by --warn-unused-imports. In a few
modules, there were a *lot* of unneeded imports, but most had just
one or two.
In a few cases, removing an import from a module, because it *itself*
does not need it, required adding that same import to those of its
submodules which *do* need it.
In a few cases, conform to other changes above.
tests/invalid/Mercury.options:
Test the generation of messages about import shadowing on the existing
import_in_parent.m test case (although it was also tested very thoroughly
when giving me the information needed for the deletion of all the
unneeded imports above).
tests/*/*.{m,*exp}:
Delete unneeded imports, and update any expected error messages
to expect the now-smaller line numbers.
browser/dice.m:
Delete this file; it hasn't been used since 2005 and was only still
around in case we wished to use the file again when we were using CVS.
browser/Mercury.options:
Delete MCFLAGS specific to the above file.
browser/interactive_query.m:
Use '.dylib' as the extension for the shared library we generate for
interactive queries when on OS X. (While '.so' would work in principle,
its use is unusual on OS X and the Mercury compiler will always use
'.dylib' anyway.)
Replace some sequences of I/O operations with single calls to io.format
so that message components are not spread over multiple lines.
Add an XXX comment about object file extensions.
Update comments that refer to 'libquery' rather than 'libmdb_query'.
README.MacOS:
Delete interactive queries from the list of unsupported features.
tests/debugger/interactive.exp:
Update this expected output. The changes are due to earlier
changes to the formatting and presentation of error messages.
Fix a mismatch in the mangling of symbol names between the name mangling
module in the browser / dynamic linking library and the MLDS->C code generator.
The former includes the function return argument in the arity, while the latter
does not.
Make the dynamic linking examples work in low-level C grades on OS X and mostly
work in high-level C grades. (I say "mostly", since the integer function test
returns an incorrect result on my machine.)
browser/name_mangle.m:
The arity for symbols corresponding to Mercury functions should not
include the return argument.
Add a comment mentioning that this module needs to be kept in sync
with the name mangling scheme used in compiler/mlds_to_c.m.
s/XXX/NOTE/ in a spot.
compiler/mlds_to_c.m:
Add a comment mentioning that the name mangling code here needs to be
kept in sync with the mlds version of the name mangling code
in browser/name_mangle.m.
extras/dynamic_linking/Mmakefile:
Use the variable EXT_FOR_SHARED_LIBS rather than assuming that the
shared library extension is .so.
extras/dynamic_linking/dl_test.m:
extras/dynamic_linking/dl_test2.m:
Open 'libhello.dylib' on OS X systems rather than 'libhello.so'.
library/list.m:
Switch to a more expressive and more consistent set of variable names.
Give many _2 helper predicates better names.
Convert (C->T;E) to (if C then T else E).
Note that nth_member_search is identical to index1_of_first_occurrence,
and nth_member_lookup is identical to det_index1_of_first_occurrence.
Make the former redirect to the latter.
browser/declarative_tree.m:
browser/term_rep.m:
compiler/dep_par_conj.m:
compiler/global_data.m:
compiler/polymorphism.m:
compiler/prog_foreign.m:
compiler/pseudo_type_info.m:
compiler/tupling.m:
compiler/type_ctor_info.m:
Replace calls to nth_member_{search,lookup} with
{det_,}index1_of_first_occurrence.
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the tests
that check compiler error messages, expect the new line numbers.
browser/cterm.m:
browser/tree234_cc.m:
Import only one module per line.
tests/hard_coded/boyer.m:
Fix something I missed.
*/*_FLAGS.in:
Specify that by default, the compiler should generate warnings
for unknown format strings and bad known format strings.
*/Mercury.options:
Override this default setting for a few modules that have legitimate
reasons for calling e.g. string.format with unknown format strings.
compiler/fact_table.m:
deep_profiler/html_format.m:
Minor changes to avoid calling string.format with unknown format strings.
This file-specific setting will override a default setting of expandtabs
in $HOME/.vimrc.
*/Makefile:
*/Mmakefile:
As above.
tests/hard_coded/.gitignore:
Don't ignore the purity subdir. This ignore must have been left over
from when purity.m was a test in hard_coded, not hard_coded/purity,
and it ignored an executable, not a directory.
The following changes are necessary to compile the code following an
upcoming change to the mode checker. Some of them are mode errors.
browser/declarative_oracle.m:
The result of `query_oracle_kb' should be specific
to avoid mode errors in callers.
compiler/accumulator.m:
Help the compiler infer the declared inst.
compiler/mode_robdd.tfeirn.m:
`zero' must be declared to return a normalised tfeirn value to
avoid mode errors. Change `one' for symmetry.
`var_restrict_true' and `var_restrict_false' may return
unnormalised tfeirn values (judging by the code).
Modify `normalise' to help the compiler infer
the declared inst.
compiler/tupling.m:
deep_profiler/autopar_find_best_par.m:
Delete final insts that the compiler cannot verify.
library/tree234.m:
Help the mode checker out using an explicit switch.
tests/hard_coded/bitmap_test.m:
tests/hard_coded/bitmap_tester.m:
Add missing modes.
mdbcomp/sym_name.m:
New module, containing the part of the old prim_data.m that
dealt with sym_names.
mdbcomp/builtin_modules.m:
New module, containing the part of the old prim_data.m that
dealt with builtin modules.
mdbcomp/prim_data.m:
Remove the things that are now in the two new modules.
mdbcomp/mdbcomp.m:
deep_proiler/Mmakefile:
slice/Mmakefile:
Add the two new modules.
browser/*.m:
compiler/*.m:
deep_proiler/*.m:
mdbcomp/*.m:
slice/*.m:
Conform to the above changes.
I/O tabling has two main purposes. The first and more important is to allow the
debugger to replay parts of the program execution for the programmer, which
requires making I/O operations idempotent (so that we get the same results on
the second, third etc "execution" as on the first). The second purpose is to
let the person using the debugger actually see a list of the I/O actions, and
their results.
The root of the problem here is that the compiler can do the second part
only if it has access to the type_infos describing the types of the arguments
of the I/O action. With the current infrastructure for representing typeclass
information, this is not always possible in the presence of typeclass
constraints on I/O action predicates. The reason is that polymorphism.m can
put the typeinfo for a type variable that is subject to a typeclass constraint
arbitrarily deep inside the typeclass_info for that constraint, but the RTTI
can encode such locations only up to a fixed depth (currently only the
shallowest embedded is encodable).
Before this fix, the test case for this bug got a compiler abort when the
I/O tabling transformation tried to figure out how to table the typeclass
info representing the typeclass constraint on a I/O action predicate.
We still cannot table typeclass infos. We could store them (I/O tabling
does not require anything more complicated), but the problem of deeply buried
typeinfos inside them would still remain. So this fix consists of two parts:
- for typeclass constrained I/O primitives, recording only enough information
to allow them to replayed (the first purpose above), and not to print them
out (the second purpose), and
- getting the runtime system to understand this, and not crash with a core dump
in the absence of the information required for the second purpose.
This second part requires changes to the RTTI used by I/O tabling. These
changes BREAK BINARY COMPATIBILITY in debug grades.
runtime/mercury_stack_layout.h:
Rename the MR_TableIoDecl structure as the MR_TableIoEntry structure,
since the I/O table entries that it describes are used not just for
declarative debugging, but also for printing out I/O actions.
Add a field to it that specifies whether the fields describing
the types of the I/O action's arguments are meaningful.
runtime/mercury_grade.h:
Bump the debug-only binary compatibility version number, since
the change to mercury_stack_layout.h requires it.
runtime/mercury_trace_base.[ch]:
When returning information about a tabled I/O action, return a boolean
that says whether the information abouts its arguments is actually
present or not. Do not return information about the arguments if
we cannot convert them into univs due to missing type information.
browser/io_action.m:
Pay attention to the new info returned by MR_trace_get_action,
and avoid a potential core dump by generating a description of the
requested I/O action only if the argument type information needed
to generate that description is actually available.
trace/mercury_trace_vars.c:
Pay attention to the new info returned by MR_trace_get_action.
When the argument type information needed to generate an accurate
description of the I/O action is not available, generate a
"description" that mentions this fact.
trace/mercury_trace_cmd_browsing.c:
Make the fix to mercury_trace_vars.c easier to test by adding a mechanism
to print out all existing I/O actions, as long as there aren't too many
of them.
compiler/hlds_pred.m:
compiler/layout.m:
compiler/prog_data.m:
Prepare for the possibility that we have cannot record the information
needed to reconstruct the runtime types of the arguments of a I/O tabled
predicate.
compiler/table_gen.m:
If an I/O tabled predicate has one or more typeclass constraints,
do not attempt to record the RTTI needed to reconstruct the types
of its arguments at runtime.
compiler/continuation_info.m:
compiler/hlds_data.m:
Rename some data structures that referred to the old MR_TableIoDecl
structure to refer to its replacement, the MR_TableIoEntry structure.
compiler/bytecode_gen.m:
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/dependency_graph.m:
compiler/erl_unify_gen.m:
compiler/export.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_out_mode.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/hlds_pred.m:
compiler/implementation_defined_literals.m:
compiler/inst_check.m:
compiler/layout.m:
compiler/layout_out.m:
compiler/llds.m:
compiler/llds_out_data.m:
compiler/llds_out_file.m:
compiler/llds_out_util.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_to_mercury.m:
compiler/ml_global_data.m:
compiler/ml_switch_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mode_util.m:
compiler/module_qual.m:
compiler/opt_debug.m:
compiler/proc_gen.m:
compiler/prog_data.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_type.m:
compiler/prog_util.m:
compiler/rbmm.execution_path.m:
compiler/stack_layout.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/type_ctor_info.m:
compiler/unify_gen.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
runtime/mercury_misc.h:
runtime/mercury_tabling.h:
Conform to the above changes.
tests/debugger/tabled_typeclass.{m,inp,exp,exp2}:
New test case to test that I/O actions that have typeclass constraints
on them can be printed in mdb.
tests/debugger/Mmakefile:
tests/debugger/Mercury.options:
Enable the new case.
This is a consecutive patch to my previous patch, it extends the .gitignore
files to work more thoroughly on Windows.
browser/.gitignore:
ignore .net .dll assemblies
compiler/.gitignore:
ignore *.obj
extras/.gitignore:
Ignore the tags directory
Ignore: *.bat, *.lib,
Ignore *.dll rather than lib*.dll because the .net assemblies are not
prefixed.
extras/dynamic_linking/.gitignore:
Ignore *.out (test output files)
extras/error/.gitignore:
Ignoring unix binary for the error utility
extras/lex/tests/.gitignore:
Ignore the test_regex binary
extras/moose/tests/.gitignore:
Ignore array_based.m because it is generated from array_based.moo
RESERVED_MACRO_NAMES:
*/RESERVED_MACRO_NAMES:
Add a macro, _FORTIFY_SOURCE, that gcc defines by default on some recent
versions of Linux.
I could have added it in SIX separate RESERVED_MACRO_NAMES files.
Instead, I moved the content common to all these files to a
RESERVED_MACRO_NAMES file in the top directory, leaving the
RESERVED_MACRO_NAMES files of the subdirectories containing only
macros that *don't* occur in all those subdirectories.
tools/bootcheck:
Copy the top-level RESERVED_MACRO_NAMES names to the stage 2 directory.
Mmake.common.in:
Filter out the contents of the top level RESERVED_MACRO_NAMES file,
as well as the RESERVED_MACRO_NAMES file in the current directory.
Library grade detection causes the library installation for the csharp grade
(and probably any grades that use mmc --make) to fail. (There is likely
a better solution than this, e.g. making --no-mercury-stdlib-dir imply
--no-detect-libgrades, but the handling of command line options in this
part of the compiler is pretty convoluted, so I will look into that
separately.)
browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_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:
As above.
browser/RESERVED_MACRO_NAMES:
library/RESERVED_MACRO_NAMES:
mdbcomp/RESERVED_MACRO_NAMES:
runtime/RESERVED_MACRO_NAMES:
ssdb/RESERVED_MACRO_NAMES:
trace/RESERVED_MACRO_NAMES:
Ignore the __USE_MINGW_ANSI_STDIO macro which we
need to define on MinGW64.
Ignore the __GCC_HAVE_DWARF2_CFI_ASM macro which
some versions of GCC define if -g is enabled.
compiler/.gitignore:
deep_profiler/.gitignore:
profiler/.gitignore:
slice/.gitignore:
util/.gitignore:
Have git ignore .exe files in these directories.