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.
Move the functions that convert between the UTF-8 and wide encodings of a
string on Windows from the library into the runtime. Upcoming changes will
require their presence in the runtime.
library/io.m:
Move ML_utf8_to_wide() and ML_wide_to_utf8() from here ...
runtime/mercury_string.[ch]:
... to here and s/ML_/MR_/.
library/dir.m:
library/io.call_system.m:
library/io.environment.m:
library/io.file.m:
library/io.stream_ops.m:
Conform to the above change.
... 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.)
compiler/typecheck_error_undef.m:
If we are reporting an error for a reference to an undefined predicate,
check whether any predicates exist whose names are "close enough"
to the name of the referenced predicate, and if yes, add to the
error message a line containing "(Did you mean x, y or z?)".
(Doing the same for references to undefined functions is future work.
The two are separate because things that look like function references
can also refer to e.g. data constructors.)
library/edit_distance.m:
Add this new module to implement the "close enough" check.
This new module is similar to the existing edit_seq.m module,
but it is designed to serve different requirements, and it seems to me
to be far from trivial to write code to meet both sets of requirements
at once.
library/library.m:
library/MODULES_DOC:
Include the new module in the standard library.
NEWS.md:
Announce the new library module.
tests/hard_coded/edit_distance_test_closest.{m,exp}:
tests/hard_coded/edit_distance_test_cost.{m,exp}:
Two new test cases, each of which tests one of the two predicates
exported by the new library module.
tests/hard_coded/Mmakefile:
Enable the new test cases.
tests/invalid/qual_basic_test2.err_exp:
tests/invalid/types2.err_exp:
tests/invalid/undef_symbol.err_exp:
tests/invalid_submodules/undef_mod_qual.err_exp:
Expect the new "did you mean" additions to error messages.
library/version_hash_table.m:
As above.
Implement function versions of operations in terms of their
predicate versions, instead of vice versa.
Add explicit module qualification where this clarifies the code.
library/library.m:
Add finer-grained functions for returning configuration information.
Implement the existing version/2 predicate using these new functions.
compiler/handle_options.m:
profiler/mercury_profile.m:
slice/mcov.m:
Use the new functions.
NEWS.md:
Announce the new functions.
library/dir.m:
Factor out common code in the code that canonicalizes filenames
by defining and using is_directory_separator_return_canon.
Improve the variable names used in the canonicalization predicates
(which previously used different names for the same concepts).
Add a predicate that tests whether a dirname or filename is already
in its canonical form. and if so, skip the canonicalization process.
Clarify the code of the / predicate by moving some parts of it
to separate predicates whose names describe their purpose.
Some of these predicates are called more than once, so they also
factor out common code.
Switch from using unsafe to safe code to test whether filenames
name a drive letter on Windows.
Add a new configure option, ---with-pkgversion, that allows those packaging
Mercury to include additional version information specific to their package in
the output of mmc --version etc.
Omit version and copyright information from the short usage messages for mmc, mprof
and mcov. The result is less cluttered and more direct.
Omit version information from the long usage (i.e. --help) message for the
above programs. This is to save space on the first line of the output and also
brings the man pages for mmc, mprof and mcov into line with the other man
pages, which do *not* have version information in their NAME section.
configure.ac:
Add the new --with-pkgversion option.
runtime/mercury_conf.h.in:
runtime/mercury_dotnet.cs.in:
java/runtime/Constants.java.in:
Define a constant for the package version.
library/library.m:
Add the function package_version/0, which returns the package
version string.
compiler/handle_options.m:
profiler/mercury_profile.m:
slice/mcov.m:
Include a non-empty package version in the output of --version.
Make the above changes to the short and long usage messages.
Add an XXX about mprof's short usage message.
library/dir.m:
Use state variables to implement accumulators. Convert the function
concerned to a predicate, and move the initial and final processing
of the accumulator to a new predicate.
Rearrange the structure of the code to avoid doing the same test
on the same character twice.
compiler/write_deps_file.m:
Move the filename creation code to the end of the file. Expand it
with conditionally-enabled code that gathers statistics about the
hit rate of the file name cache for each extension, and document
its result, which validates the existing approach.
Document an approach that looks like would speed up the file name
creation process, but does not.
compiler/mercury_compile_main.m:
Call a new predicate in write_deps_file.m to dump out the statistics
it gathered, if there are any.
tools/write_deps_file_stats:
A new script to summarize the raw data dumped out by write_deps_file.m.
library/dir.m:
Improve indentation.
This is a generalisation of the write_tabbed_lines predicate that mmc
and mcov use to print their usage messages. (In a later change other
programs in the Mercury system will be changed to use it as well.)
library/io.m:
Add the new predicates.
compiler/options.m:
slice/mcov.m:
Use write_prefixed_lines in place of write_tabbed lines
and delete the latter.
NEWS.md:
Announce the addition.
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/list.m:
Document why the definitions of the subtypes empty_list and non_empty_list
are commented out.
compiler/prog_item.m:
Document a place that *should* use the empty_list subtype when it becomes
available.
compiler/accumulator.m:
library/term_conversion.m:
Add some explicit type qualifications that would be needed in the presence
of those subtypes. Their presence now is redundant, but non-harmful.
compiler/prog_data.m:
Define a subtype of the typeclass interface type for abstract typeclasses.
compiler/prog_item.m:
Change the types of the fields representing
- implementation section typeclasses in .int files, and
- interface section typeclasses in .int3 files
to a subtype that allows the definition of only abstract typeclasses.
The interface section typeclasses in .int3 files have more invariants
than just being abstract, but these cannot currently be expressed
using subtypes.
library/list.m:
Add a comment (which is visible only to Mercury developers)
about why this is so.
compiler/comp_unit_interface.m:
compiler/convert_parse_tree.m:
compiler/equiv_type.m:
compiler/make_hlds_separate_items.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.qualify_items.m:
compiler/parse_tree_out.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
Conform to the changes above.
compiler/error_util.m:
compiler/handle_options.m:
compiler/hlds_clauses.m:
compiler/live_vars.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile_make_hlds.m:
compiler/parse_tree_out_type.m:
compiler/typecheck_error_overload.m:
compiler/typecheck_error_type_assign.m:
Move module imports from the interface to the implementation section,
when the imported module is not used in the interface.
library/io.error_util.m:
library/io.m:
library/rtti_implementation.m:
library/type_desc.m:
Add no_determinism_warning pragmas for det/semidet predicates and functions
that
- have foreign_proc definitions for some target languages, but
- a Mercury definition for other target languages which always aborts.
(These predicates/functions are not intended to be called at all
in grades where this definition is the active definition.)
Replace separate pred and mode declarations with combined predmode
declarations.
Delete a function that had an idential definition, and almost-identical
name, to anoher function.
When a version hash table expanded its underlying version array,
it would always create a concurrency-safe version array even if the
hash table itself was originally created with a
version_hash_table.unsafe_init* functions.
This change makes it so that when an "unsafe" version hash table
expands, it will create an "unsafe" version array internally.
library/version_array.m:
Export a predicate has_lock/1 for use by version_hash_table.m
Replace occurrences of max(VA) with size(VA) - 1. The latter makes
it more obvious that an index may start out negative.
Other minor style changes.
Fix typos.
library/version_hash_table.m:
When expanding a hash table, create a new version array with
version_array.init or version_array.unsafe_init
depending on whether the old version array had an internal lock.
Replace field access expressions with predicate calls.
compiler/handle_options.m:
The main predicate of this module, handle_given_options, used
to generate the default option table every time it was called,
and its callers couldn't prevent this by supplying it with that
default option table. Fix this by adding an argument for that info.
compiler/mercury_compile_main.m:
Create the default option table at the start of real_main_after_expansion.
Pass it to later invocations of handle_given_options.
compiler/globals.m:
Include the default option table, as well as the processed option table
(created by handle_given_options from the default table) in the globals
structure. This is so that the parts of the make package that want to
build a new globals structure "from scratch" don't have to redo
the part of the work that is independent of the set of actually specified
options.
compiler/make.build.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
Conform to the changes above.
In some cases, fix misleading variable names.
In make.track_flags.m, add an XXX outlining a possibly better approach
to hashing options for tracking.
library/Mmakefile:
Stop copying a part of getopt_io.m to geteopt.m, because it is
confusing as hell after an automatic edit.
library/getopt.m:
Expect the effect of the change to library/Mmakefile.
library/string.builder.m:
Add a predicate that tests whether the total length of the string
implicit in a string builder is within a limit, or not.
Add a function that returns that total length.
NEWS.md:
Announce the new predicate and function.
compiler/parse_tree_out_term.m:
Use the new predicate to optimize a test.
compiler/parse_tree_out_info.m:
... by making string builders instances of the "output" typeclass,
whose operations are the base level of the code of parse_tree_out*.m.
Strings were already instances of "output", but the use of this instance
was problematic for large structures such as entire files. This is because
if the final string was constructed by adding together N atomic strings,
then the construction of the final string involves copying each of those
atomic strings about N/2 times on average.
With the string builder instance, each string is copied just twice:
when it is added to the string builder state, and when that state is
converted to the final string.
library/string.builder.m:
Add three new predicates, append_char, append_string and append_strings.
The first two are copied from existing instance methods; making them
separate predicates allows them to be invoked using a first order call,
instead of a method call. The third is just for convenience. All three
are used by the new code in parse_tree_out_info.m.
NEWS.md:
Announce the new predicates in string.builder.m.
library/term_io.m:
library/stream.string_writer.m:
Many predicates in these two modules have long had two typeclass
constraints:
stream.writer(Stream, string, State)
stream.writer(Stream, char, State)
This diff eliminates the second constraint, for two reasons.
The first is ergonomics; writing one constraint is faster than writing two,
and likewise for reading. The second is efficiency: we have to pass around
just one typeclass info, not two.
There is a tradeoff, which is that to output characters, we now
have to call char_to_string. For the string.builder instance of
stream.writer, this has no efficiency downside, because the char instance
of stream.string_writer itself calls char_to_string. For the I/O state
instance of stream.string_writer, there is a downside because io.write_char
does not need to convert the character to a string, but the downside
is negligible compared to the overall cost of I/O. And in any case,
most of the places where the code of either of these modules wrote out
characters, it wrote out character *constants*, which this diff converts
to string constants, eliminating the runtime conversion and its cost.
library/string.builder.m:
Use string.char_to_string, instead of its older synonym string.from_char,
in the char instance of stream.string_writer.
library/term_io.m:
Put the varset before the variable, the item to be written out,
in the various versions of the write_variable operation.
The new argument order
- fits in better with the versions of write_term, which also put
the varset before the item to be written out, and
- allows the convenient use of fold operations that write out
several variables.
NEWS.md:
Announce the change, though only for the versions that existed
before yesterday :-)
compiler/inst_graph.m:
extras/moose/mercury_syntax.m:
Conform to the change.
library/term_io.m:
Add X_to_string and format_X versions of the operations that did not
yet have such versions, i.e. the operations that output terms and
variables. Reimplement the existing write_X versions in terms of
the format_X versions.
Move type_spec pragmas next to the predicates they apply to;
next to their declaration, if it is in the implementation section,
next to their definition, if their declaration is in the interface.
This allows a simple scan to check whether all the predicates
that *should* have such pragmas *actually* have them.
Add type_spec pragmas for the string builder as well as the I/O state
instances of stream.writer.
NEWS.md:
Announce the new predicates and functions.
library/term_io.m:
Put related predicates next to each other. Put the groups of related
predicates into descending order on the size of the entity being output.
We have two groups of predicates that both output atoms, with one group
taking an adjacent_to_graphic_token argument, and one group not taking
such an argument. The second group is publicly exported; the first group
is exported but not publicly documented.
Until now, we arranged the "exported but not publicly documented" part
by declaring these predicates in a second interface section. However,
this is incompatible with them being next to second group. Switch
to using the new mechanism in doc/Mmakefile to achieve the same
objective.
doc/Mmakefile:
Do not include any lines between lines containing the strings
UNDOC_PART_START and UNDOC_PART_END in library/*.m in the library's
documentation.
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.
library/mercury_term_lexer.m:
As above.
NEWS.md:
Announce the change.
doc/reference_manual.texi:
Document the change.
tests/hard_coded/parse_number_from_string.exp:
tests/invalid_nodepend/invalid_float_literal.err_exp:
Update these expected outputs after the change.
library/term_io.m:
Replace the !N threaded through the code writing out terms, which was
used only in commented-out code, with a value of a new type,
anon_var_info, being threaded through. The two values of this type
each choose one of two ways to write out unnamed variables.
This capability is not yet exposed to users.