compiler/mercury_compile_main.m:
Simplify the code interpreting the result of calls to lookup_mmc_options.
Eliminate the one remaining redundant computation of the
default option table.
compiler/options_file.m:
Expand the documentation of the predicates that read options files.
Document that the predicates that only look things up in the data
structures representing already-read-in options files can return
only errors, not warnings.
Delete a long-obsolete comment.
compiler/maybe_error.m:
Add a utility predicate that could be useful later. (I thought it
would be useful in this diff, but it wasn't.)
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.
compiler/mercury_compile_main.m:
Simplify the interface of two predicates by moving to their (only) callers
code that belongs better in those callers.
Inline the only call to a predicate.
compiler/handle_options.m:
Delete the predicate inlined in mercury_compile_main.m
compiler/parse_tree_out_pragma.m:
compiler/parse_tree_out_pred_decl.m:
Use the string builder instance of pt_output instead of the plain string
instance, due to its better worst case behavior.
Add format_X versions of some operations that did not have them.
Implement write_X and format_X in terms of X_to_string where X_to_string
is trivial, and (mostly) returns existing strings.
Delete the maybe with_type argument from some predicates, because
they were always set to "no".
compiler/parse_tree_out_info.m:
Delete the plain string instance of pt_output, since it is no longer
needed.
compiler/hlds_out_mode.m:
compiler/hlds_out_pred.m:
Conform to the changes above.
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_sym_name.m:
Use the string builder instance of pt_output instead of the plain string
instance, due to its better worst case behavior.
Rename sym_name_arity_to_string to unescaped_sym_name_arity_to_string,
to make it clear that it does not escape the sym_names it is given.
Rename write_sym_name_arity in the same way.
Add format_X versions of some operations that did not have them.
Delete the write_quoted_sym_name predicate, because it was used only
once, so it is not worth generalizing.
Delete the escaped_module_name_to_string function, because it was
unused.
compiler/parse_tree_out.m:
compiler/parse_tree_out_cons_id.m:
compiler/parse_tree_out_inst.m:
compiler/parse_tree_out_misc.m:
compiler/parse_tree_out_sym_name.m:
compiler/parse_tree_out_term.m:
compiler/parse_tree_out_type.m:
Use the string builder instance of pt_output instead of the plain string
instance, due to its better worst case behavior.
Add format_X versions of some operations that did not have them.
Implement write_X and format_X in terms of X_to_string where X_to_string
is trivial, and (mostly) returns existing strings.
compiler/add_clause.m:
compiler/add_type.m:
compiler/analysis.file.m:
compiler/complexity.m:
Conform to the changes above.
tools/bootcheck:
Fix the setting of the WORKSPACE variable when running the tests.
Due to incorrect use of pwd it was actually pointing back at stage 1.
If we are running under MSYS2, then set --windows automatically.
(It's too easy to forget to do this otherwise.)
Mention this in the documentation for the --windows option. Also,
the --windows option does not imply anything about the library
extension -- despite what the usage message has claimed for many
years.
tests/hard_coded/write_xml.m:
Update the comment at the head of this module that explains the
differences between the expected outputs.
tests/hard_coded/write_xml.exp3:
Expected output for this test on in a high-level C grade on Windows.
compiler/parse_tree_out_sym_name.m:
As a test, implement the output of sym_names, one of the smallest
nonatomic parse tree components, using string builders.
Change the name of the write_X version of the operation
from just write_sym_name to write_escaped_sym_name,
since every component of the sym_name is in fact escaped.
Change the name of the X_to_string version of the operation
from sym_name_to_escaped_string to escaped_sym_name_to_string,
to make the X identical to the write_X version. Change its implementation
to use string builders.
Implement both write_escaped_sym_name and escaped_sym_name_to_string
in terms of the new predicate format_escaped_sym_name.
Add an XXX about a potential problem.
compiler/parse_tree_out_info.m:
Since format_escaped_sym_name calls term_io.format_escaped_string,
it needs to comply with its typeclass constraint. This requires
making the typeclass in the constraint on format_escaped_sym_name,
the "output" typeclass in parse_tree_out_info.m, a superclass of
stream.writer.
However, giving parse_tree_out_info.m access to the stream.writer class
also gives it access to the stream.output class, since they are both
defined in library/stream.m. Avoiding a flood of ambiguity warnings
about output being either stream.output or parse_tree_out_info.output
requires either fully module qualifying all occurrences of the output
typeclass name, or renaming one of the typeclasses. The obvious one
to rename is parse_tree_out_info.output, so this diff renames it to
pt_output (pt being short for "parse tree").
compiler/higher_order.m:
compiler/hlds_out_mode.m:
compiler/hlds_out_module.m:
compiler/hlds_out_type_table.m:
compiler/hlds_out_util.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/parse_tree_out.m:
compiler/parse_tree_out_cons_id.m:
compiler/parse_tree_out_inst.m:
compiler/parse_tree_out_misc.m:
compiler/parse_tree_out_pragma.m:
compiler/parse_tree_out_pred_decl.m:
compiler/parse_tree_out_term.m:
compiler/parse_tree_out_type.m:
compiler/recompilation.check.m:
compiler/source_file_map.m:
compiler/write_deps_file.m:
Conform to the changes above.
The Substitute character (U+001A) is treated as EOF for text mode files on
Windows. Omit that character from the test.
tests/hard_coded/nonascii_gen.c:
Do not emit U+001A in the set of test characters.
tests/hard_coded/nonascii.m:
Conform to the above change.
Update syntax in a spot.
tests/hard_coded/nonascii.exp:
Conform to the above change.
tests/invalid_nodepend/fact_table_in_interface.err_exp2:
Add an expected output for systems where the .exe executable
extension is used.
tests/invalid_nodepend/fact_table_in_interface.m:
Document what the different expected outputs are for.
tests/invalid_nodepend/fact_table_in_interface.err_exp:
Conform to line number changes.
tests/invalid_options_file/inf_incl_direct.err_exp2:
tests/invalid_options_file/inf_incl_indirect.err_exp2:
tests/invalid_options_file/nonexistent_file.err_exp2:
Handle the case where "\" is used as the directory separator.
tests/invalid_options_file/inf_incl_direct.m:
tests/invalid_options_file/inf_incl_indirect.m:
tests/invalid_options_file/nonexistent_file.m:
Document what each of the .err_exp files corresponds to.
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.
compiler/file_names.m:
Take ext_src out of the ext type, because this allows us to delete
the I/O state pair of arguments out of every file translation predicate
other than module_name_to_source_file_name and the ones that create
directories.
compiler/file_kind.m:
Delete the ext output argument of file_kind_to_extension, because
we can't return ext_src for fk_src anymore.
compiler/write_deps_file.m:
Delete a test for ext_src which could never succeed, because the
predicate in question is never called with ext_src.
Undo an accidental change from the diff that introduced
module_name_to_lib_file_name_create_dirs.
Conform to the changes above.
compiler/compile_target_code.m:
compiler/fact_table.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mlds_to_c_file.m:
compiler/mmc_analysis.m:
compiler/module_cmds.m:
compiler/read_modules.m:
compiler/recompilation.used_file.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
compiler/file_names.m:
Split module_name_to_file_name into three versions.
- One corresponds to the old predicate's operation with do_not_create_dirs,
- one corresponds to the old predicate's operation with do_create_dirs, and
- one just returns the directory path, and lets the caller make those
directories if it wants to, using procedures that we now export.
Do the same for module_name_to_lib_file_name.
Do not do the same for fact_table_file_name, which has too few callers
to make it worthwhile.
The point is that the versions that do not create any dirs should NOT
need to take I/O state pairs as arguments, once we take ext_src
out of the ext type.
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/export.m:
compiler/fact_table.m:
compiler/generate_dep_d_files.m:
compiler/llds_out_file.m:
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:
compiler/make.util.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/read_modules.m:
compiler/recompilation.used_file.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Update calls to the affected predicates.
In some places, add XXXs about seemingly-strange choices about
what calls create directories and which don't.
compiler/file_names.m:
Delete now-obsolete comments. Move their still-relevant parts
next to the entity that they apply to.
List the string form, if any, of each enum representing an extension.
Explain the meaning of _gs, _ngs and _opt suffixes.
Delete obsolete commented-out code.
Delete an obsolete, unused type definition.
compiler/options.m:
doc/user_guide.texi:
Fix two bugs that a comment that this diff pointed to.
First, since 2017, the --dump-hlds option has output C code
only if the target language is C, but the documentation
of that option did not mention this. Fix this omission.
Second, ever since we split .mh and .mih files, the header
part of MLDS dumps in C form were output to .mih_dump file.
However, the documentation of the --dump-hlds option said that
it was output to a .h_dump file. Fix this as well.
compiler/file_names.m:
Delete the old code for doing filename translations, and use
just the new code.
Delete all the code that was needed only for comparing the old and
new code.
Delete the newext_other extension category, since it was also needed
only for that purpose. Delete all the code that supported it.
Switch the infrastructure for recording the demand for translations
to work with the new code.
compiler/analysis.file.m:
Delete functions that returned old-style extensions, which are
not useful anymore. The new-style extensions, by identifying
extensions via enums rather than strings, serve the purpose
for which these functions were created.
compiler/mercury_compile_main.m:
Move the code to call to write out the translation record
from just after a call to real_main_after_expansion to the
end of real_main_after_expansion. The reason is that the
predicate being called now needs access to a globals structure,
real_main_after_expansion has access to a globals structure,
but its caller does not.
Don't try to test the equivalence of the old and new algorithms
for file name translation, since that test code has been deleted.
compiler/analysis.m:
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/export.m:
compiler/fact_table.m:
compiler/file_kind.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/llds_out_file.m:
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:
compiler/make.util.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_make_hlds.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/prog_foreign.m:
compiler/read_modules.m:
compiler/recompilation.used_file.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the changes in file_names.m.
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.
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.
compiler/simplify_goal_call.m:
Don't generate "reference to obsolete predicate" warnings in predicates
that are created by the compiler, not the user, by transforming another
predicate. Any such warning should properly be emitted for the *base*
predicate of the transformation.
We have traditionally not generated "reference to obsolete predicate"
warnings in predicates that are themselves marked obsolete. This is
to allow a cluster of predicates in some members are implemented
using calls to other members to be obsoleted together.
Without this diff, a type_spec pragma for a predicate p1 that is
marked obsolete that calls another obsolete predicate p2 would get
a warning for the call, because the context of the pragma is used
as the context of the compiler-generated type-specialized version of p1,
and this version is NOT itself marked obsolete. (It *cannot* be marked
obsolete, because even if the programmer knew the eventual
compiler-generated name of the type specialized predicate and
added a obsolete pragma for it, that predicate does not yet exist
when its pragma would be processed.)
We *could* copy the obsolete marker from base to transformed predicates,
but the blanked rule given at the top is a more robust solution.
compiler/options.m:
Add a new name for the compiler_sufficiently_recent option
that can be used to detect the presence of thid diff in the
installed compiler.
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.