Commit Graph

22913 Commits

Author SHA1 Message Date
Zoltan Somogyi
79d6142bc3 Simplify more code in mercury_compile_main.m.
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.)
2023-07-11 00:56:38 +02:00
Zoltan Somogyi
b1c0b42a34 Generate the default option_table just once.
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.
2023-07-10 19:40:56 +02:00
Zoltan Somogyi
786fc9d773 Improve variable names. 2023-07-10 13:46:55 +02:00
Zoltan Somogyi
fe1e78e126 Simplify some code.
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
2023-07-10 13:43:18 +02:00
Zoltan Somogyi
8b70437f3a Clarify that length means #code points. 2023-07-10 10:19:40 +02:00
Zoltan Somogyi
713f100508 Use string builder in the rest of parse_tree_out*.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.
2023-07-09 21:44:44 +02:00
Zoltan Somogyi
c414a99736 Make a test more efficient.
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.
2023-07-09 17:46:43 +02:00
Zoltan Somogyi
8e7c5dfbd1 Use string builder in more of parse_tree_out*.m.
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.
2023-07-09 16:47:48 +02:00
Julien Fischer
383c2c307f Fix failure of trailing/test_trail_reset on Windows.
tests/trailing/test_trail_reset.m:
     Fix mismatched conversion specifier and cast.
2023-07-10 00:11:29 +10:00
Julien Fischer
0e8ad1ea39 Fixes for the bootcheck script on Windows.
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.
2023-07-09 20:27:20 +10:00
Julien Fischer
f999105ad4 Fix the failure tests/hard_coded/write_xml on Windows.
tests/hard_coded/write_xml.m:
tests/hard_coded/write_xml.exp4:
     Add an expected output for the low-level C grades on Windows.
2023-07-09 13:23:31 +10:00
Julien Fischer
0e980917e1 Fix the failure tests/hard_coded/write_xml on Windows.
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.
2023-07-08 23:16:12 +10:00
Zoltan Somogyi
3a928fe1ea Start using the string builder in parse_tree_out*.m
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.
2023-07-08 14:42:26 +02:00
Zoltan Somogyi
f16af1123a Fix indentation. 2023-07-08 14:24:34 +02:00
Julien Fischer
837a677c37 Fix failure of test/hard_coded/nonascii on Windows.
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.
2023-07-08 21:30:45 +10:00
Julien Fischer
b1ebb1b35e Replace tabs with spaces.
tests/hard_coded/nonascii_gen.c:
    As above. Add the usual vim modeline.
2023-07-08 20:58:24 +10:00
Julien Fischer
67b4b12b2c Fix a test failure on Windows.
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.
2023-07-08 20:19:00 +10:00
Zoltan Somogyi
8bc9a8310f Put predicates into a standard order. 2023-07-08 11:36:52 +02:00
Julien Fischer
8a130986d5 Fix a test failure on Windows.
tests/invalid/foreign_include_file_missing.{m,err_exp2}:
    Handle the case where "\" is used as the directory separator.
2023-07-08 16:58:44 +10:00
Julien Fischer
c16f53c0a3 Fix some test failures on Windows.
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.
2023-07-08 16:49:20 +10:00
Peter Wang
5436a5c453 Fix module name in NEWS. 2023-07-08 11:25:28 +10:00
Zoltan Somogyi
bb695f455c Use term_io.m's stream writer predicates. 2023-07-08 02:38:40 +02:00
Zoltan Somogyi
78258146b2 Put related predicates next to each other. 2023-07-08 01:42:19 +02:00
Zoltan Somogyi
c09df50f64 Allow use of string builders in parse_tree_out_*.m ...
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.
2023-07-08 01:05:29 +02:00
Zoltan Somogyi
d944f70d61 Simplify some code. 2023-07-07 23:23:35 +02:00
Zoltan Somogyi
6eed4f7c72 Write out whole lines at a time in a C struct. 2023-07-07 23:23:01 +02:00
Julien Fischer
404c57907f Avoid a clash with a system header.
compiler/md5.m:
    Add a distinguishing prefix to a macro, which otherwise
    clashes with a system header on mingw-w64-ucrt-x86_64.
2023-07-07 23:37:33 +10:00
Zoltan Somogyi
5059d29256 Stop using char's stream.string_writer instance in term_io.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.
2023-07-07 13:05:16 +02:00
Zoltan Somogyi
2f41ee3851 Simplify some variable names. 2023-07-07 12:39:15 +02:00
Zoltan Somogyi
497f8b07ad Fix typos and not-quite-right comments. 2023-07-07 11:19:38 +02:00
Zoltan Somogyi
d5c54ce697 Take ext_src out of the ext type.
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.
2023-07-06 16:14:35 +02:00
Zoltan Somogyi
ef89c81527 Move two predicates. 2023-07-06 12:37:35 +02:00
Zoltan Somogyi
89979d681a Replace Mkdir parameters with predicate versions.
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.
2023-07-06 12:36:14 +02:00
Peter Wang
7ba2f4d5c4 Fix typo causing compilation failure. 2023-07-06 17:40:34 +10:00
Zoltan Somogyi
c72b3a8f97 Reorder the contents of file_names.m.
now that the new code has replaced the old, move it to the prime position.
2023-07-06 02:36:31 +02:00
Zoltan Somogyi
7f6bb059a0 Update comments in file_names.m.
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.
2023-07-06 02:29:03 +02:00
Zoltan Somogyi
6e795080ed Delete an unused argument. 2023-07-06 00:44:57 +02:00
Zoltan Somogyi
bd51efccea Address a review comment. 2023-07-05 13:26:20 +02:00
Zoltan Somogyi
6517982c87 s/newext/ext/g and s/NewExt/Ext/g. 2023-07-04 22:32:38 +02:00
Zoltan Somogyi
0b60f07c46 Cut over to the new code in file_names.m.
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.
2023-07-04 18:22:42 +02:00
Zoltan Somogyi
3d756f61cd Put varsets before vars in write_variable.
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.
2023-07-04 16:35:01 +02:00
Zoltan Somogyi
9874d1c8a8 Add X_to_string and format_X versions of remaining ops.
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.
2023-07-04 12:49:29 +02:00
Zoltan Somogyi
02f0054d0b Put term_io.m's contents into a logical order.
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.
2023-07-04 01:46:26 +02:00
Zoltan Somogyi
685eefa206 Move base of term_io.m to X_to_string, write_X, format_X.
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.
2023-07-04 00:00:09 +02:00
Zoltan Somogyi
cae40f0300 Fix typos. 2023-07-04 00:00:09 +02:00
Zoltan Somogyi
ff4298d7ff Address a review comment. 2023-07-03 23:57:02 +02:00
Zoltan Somogyi
b6ec42a132 Make some arities into pred_form_arities.
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.
2023-07-03 01:57:10 +02:00
Zoltan Somogyi
29b120dd3d Don't generate warnings for transformed predicates.
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.
2023-07-03 01:13:09 +02:00
Julien Fischer
dd85e44fd6 Adjust a comment.
compiler/Mmakefile:
    Document where we currently set the stack size for MSVC.
2023-07-02 15:59:00 +10:00
Zoltan Somogyi
f6e5a438c4 Allow underscores before exponents in floats.
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.
2023-07-02 02:20:39 +02:00