Commit Graph

22765 Commits

Author SHA1 Message Date
Zoltan Somogyi
f6f06b5537 Fix incomplete comment. 2023-05-10 14:39:33 +10:00
Zoltan Somogyi
ab160f1124 Delete stray commented-out code. 2023-05-10 14:39:14 +10:00
Zoltan Somogyi
7b52bb2713 Carve indent.m out of parse_tree_out_misc.m.
compiler/indent.m:
compiler/parse_tree_out_misc.m:
    Move indent operations from parse_tree_out_misc.m to a new module,
    indent.m.

    Include a "2" in the names of these operations, because

    - these operations print two spaces per level of indentation, but
    - some other, similar operations in the compiler use four spaces per level,
      and they should be moved here later as well.

compiler/libs.m:
    Add the new module to the libs package.

compiler/notes/compiler_design.html:
    Document the new module, as well as some other modules in the libs
    package that weren't documented before.

compiler/hlds_out_goal.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_type_table.m:
    Try to use the indent2_string function instead of the write_indent2
    predicate, since this allows the indent to printed as part of a call
    to io.format.

    Fix the printing of loop control scope reasons. Make slight improvements
    in the format of some other parts of the output.

compiler/hlds_out_typeclass_table.m:
    Try to use the indent2_string function instead of the write_indent2
    predicate, since this allows the indent to printed as part of a call
    to io.format.

    Several fields of class and instance infos that contain lists of stuff
    (e.g. method_infos) were being written out on a single line, even though
    the lists could be quite long. Fix this by writing out each list item
    on its own line. Indent these lines, to separate them visually from
    the heading lines preceding them.

    Print more information about method_infos to help make sense of them.

compiler/hlds_out_util.m:
    Try to use the indent2_string function instead of the write_indent2
    predicate, since this allows the indent to printed as part of a call
    to io.format.

    Write each proof in a constraint proof map on its line.

compiler/parse_tree_out_sym_name.m:
    Add a function version of a predicate, which returns a string
    without writing it out.

compiler/hlds_out_mode.m:
    Improve variable names.

compiler/write_error_spec.m:
    Conform to the function renames in indent.m.
2023-05-09 20:14:55 +10:00
Zoltan Somogyi
a0b389b60d Move some predicates to before their callees. 2023-05-08 22:24:15 +10:00
Zoltan Somogyi
8df602b2da Simplify keeping track of test failures.
tools/bootcheck:
    If a directory named TEST_FAILS exists in the top level directory.
    copy tests/UNEXPECTED_FAILED_TESTS to that directory, with a name
    that contains (a) the grade, and (b) the date and time. A diff between
    two of these files with the same grade but different times will make
    it easy to see which test failures are *new*.
2023-05-08 22:09:24 +10:00
Zoltan Somogyi
fb4b23091a Don't pass Indent when it is always zero.
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
    Delete the Indent argument from the top level predicates
    which always get passed Indent=0. We are not likely to ever pass
    any other indent value.

    Inline a function that has only one call site.

    In mlds_to_java_file.m, write out the comment with the module name
    regardless of whether auto-comments are enabled.

    In mlds_to_java_file.m, put a blank line after the comment block
    listing all the imported modules.

compiler/ml_type_gen.m:
    Use // comments in sample C code.

compiler/mlds.m:
    Avoid some repeated deconstructs.

compiler/mlds_to_cs_util.m:
compiler/mlds_to_java_util.m:
    Always put a space after an inline comment.

    Make the name of the predicate writing out inline comments
    more descriptive.

compiler/mlds_to_cs_data.m:
compiler/mlds_to_java_data.m:
    Conform to the change above.
2023-05-08 22:02:10 +10:00
Zoltan Somogyi
39eb9e93b0 Fix/update comments in mlds_to_{cs,java}_stmt.m.
compiler/mlds_to_cs_data.m:
compiler/mlds_to_java_data.m:
    Fix comments about the handling of rvals representing enums,
    addressing Julien's review comments. In mlds_to_cs_data.m,
    simplify the code the comments are about.

    Separate out and simplify the code handling bitwise complements.

compiler/ml_type_gen.m:
    Fix some comments.

    Some comments were out-of-date. Update the ones I could update;
    mark the others as out-of-date to warn readers.

compiler/mlds.m:
    Expand some comments, and XXX about a possible improvement.

compiler/mlds_to_java_class.m:
    Make clear that updates to a global data structure are used only locally.

compiler/mlds_to_java_stmt.m:
    Use more standard variable names.
2023-05-08 11:11:32 +10:00
Zoltan Somogyi
3143060529 Get mlds_to_{cs,java}_type.m closer to each other ...
... and simplify them.

compiler/mlds_to_cs_type.m:
compiler/mlds_to_java_type.m:
    These two modules contain very similar code, because C# is a near-copy
    of Java, and therefore the MLDS->C# translator was created as a near-copy
    of the MLDS->Java translator. However, they have diverged over time.
    This diff makes them resemble each other more closely again. It does this
    partly by putting the contents of both files into the same order, and
    partly by fixing unnecessary differences between them (e.g. in what code
    is in auxiliary functions and what code is inline).

    It also simplifies things in several respects.

    First, it deletes the output_type_for_{csharp,java}_dims predicates
    after inlining them at their respective only call sites.

    Second, while it keeps the old predicate in each module that converted
    an MLDS type to a C#/Java type name and a list of array of dimensions
    (though in a renamed form), it also adds a function wrapper that returns
    the full type name, with the array dimensions applied, because this is
    what most of its callers actually want.

    Third, don't pass a type constructor category to the predicates now named
    mercury_user_type_to_string_and_dims_for_{csharp,java} when what they need
    is an mlds_class_kind; pass the mlds_class_kind directly.

    Fourth, type_is_array_for_{csharp,java} both used to be defined
    using if-then-else chains that tested for a few kinds of mlds_types,
    and treated the rest the same. This code was vulnerable to not being
    updated when new kinds of mlds_types were added. One of these predicates
    had one bug, while the other had two. The bug they shared was that both
    returned "not_array" for all mlds_tabling_types, even though some tabling
    types *are* arrays. This was inconsequential, since neither target
    supports tabling now. The other bug was that type_is_array_for_java
    also returned "not_array" for mlds_mostly_generic_array_type, which
    is always an array.

    Besides these actual bugs, these functions also demanded double
    maintenance, since their semantics required them to return "is_array"
    if and only if type_to_string_and_dims_for_{csharp,java} returned
    a nonempty list of array dimensions. Eliminate this maintenance burden
    by deleting both functions, and making all their callers call a new version
    of output_type_for_{csharp,java} instead. In all but one situation
    (repeated for C# and Java), the callers of type_is_array_for_{csharp,java}
    called output_type_for_{csharp,java} just before already, so this
    new version, besides printing the target-language type name, also returns
    the list of array dimensions that is one of its intermediate products.

compiler/mlds_to_target_util.m:
    Update init_arg_wrappers_cs_java to operate on a list of array dimensions,
    to conform to the change just above.

    Add a function to convert a list of array dimensions to a string,
    to allow mlds_to_{cs,java}_type.m to construct type names as strings
    without immediately writing out that string. Document the related
    functions.

    Add a predicate to fix the size of an array in one dimension. Its body
    is code that used to be repeated in mlds_to_{cs,java}_type.m.

    Simplify some other code.

compiler/mlds_to_cs_class.m:
compiler/mlds_to_cs_data.m:
compiler/mlds_to_cs_export.m:
compiler/mlds_to_cs_func.m:
compiler/mlds_to_cs_global.m:
compiler/mlds_to_cs_stmt.m:
compiler/mlds_to_java_class.m:
compiler/mlds_to_java_data.m:
compiler/mlds_to_java_export.m:
compiler/mlds_to_java_func.m:
compiler/mlds_to_java_global.m:
compiler/mlds_to_java_stmt.m:
    Conform to the changes above.

    These modules had several pieces of code that converted an MLDS type
    to a C#/Java type name and a list of array of dimensions, but then
    ignored the dimensions. In every case, this was ok, because the MLDS type
    being converted was one whose C#/Java form had no array dimensions,
    but it still looked strange. The replacement code calls the
    type_to_string_for_{csharp,java} functions, which does not have this
    problem.

    In mlds_to_java_stmt.m, replace two switches on the same value,
    with a block of code between them, with a single switch, in which
    each arm calls a predicate whose body used to be the sandwiched-between
    block. Unlike the old structure, the new structure makes it easy to see
    that the many parentheses in the generated code are balanced.

    Add XXXs about some dubious aspects of the code.

compiler/mlds.m:
    Add a table listing, for each Mercury builtin type, the name of the
    C, Java and C# types that we use to represent values of that type.
    The creation of this table was the initial impetus for the
    trip-down-the-rabbit-hole described above :-)

compiler/prog_type.m:
    Put related functors next to each other.
2023-05-04 02:22:33 +10:00
Zoltan Somogyi
9364d4cbc5 Replace tables with spaces. 2023-05-02 02:25:38 +10:00
Zoltan Somogyi
49c70a741b Improve formatting. 2023-05-02 02:24:01 +10:00
Zoltan Somogyi
3364b69e34 Simplify a test. 2023-05-02 02:22:46 +10:00
Zoltan Somogyi
556d9a4fea Improve variable names. 2023-05-02 01:32:22 +10:00
Zoltan Somogyi
b2ab9f8711 Wrap the test term in angle brackets.
tests/hard_coded/write_binary.{m,exp}:
    Wrap the test term in angle brackets, in order to make the presence
    of spaces, tabs and newlines apparent.
2023-04-27 21:27:21 +10:00
Zoltan Somogyi
810d95a7ea Update the hard_coded/write_binary test case.
tests/hard_coded/write_binary.m:
    Print the term whose write-out-and-read-back is being tested
    before the test, not after. Print the result of the test after this.

    If the test succeeds, don't print the term out again.

    Put blank lines between different kinds of tests, and between
    tests of different terms.

    Return error messages as strings, rather than as exceptions,
    where possible.

    Make the diagnostic for "read back term differs from original"
    more useful for debugging write_binary/read_binary.

    Put the declaration of a predicate just before the predicate.

tests/hard_coded/write_binary.exp:
    Expect the updated output.
2023-04-27 21:19:51 +10:00
Zoltan Somogyi
91782bd972 Put io.primitives_write.m into a logical order. 2023-04-27 17:34:03 +10:00
Zoltan Somogyi
5a3fa03843 Improve programming style in the mdbcomp directory.
mdbcomp/mdbcomp.goal_path.m:
    Replace clauses with an explicit switch.

mdbcomp/mdbcomp.m:
    Provide C# and Java definitions of the version predicate.
    Mdb needs this library only in C grades, but the compiler
    has access to it even in C# and Java grades.

mdbcomp/shared_utilities.m:
    Fix style.

mdbcomp/slice_and_dice.m:
    Replace if-then-else chains with switches.

mdbcomp/sym_name.m:
    Document a predicate.
2023-04-25 19:57:02 +10:00
Zoltan Somogyi
ecf7afcb8b Fix indentation. 2023-04-25 02:33:04 +10:00
Zoltan Somogyi
ec2c7fad76 Simplify the code reading/writing feedback files ...
mdbcomp/feedback.m:
    ... by avoiding the overuse of higher order code and exceptions.
    (The old code tried to catch exceptions, even though the code in the
    try block shouldn't be able to throw any.)

    Document a vulnerability in the use io.read/io.write on feedback files,
    which was discussed on m-rev in 2008 July when this file was created.
2023-04-25 01:42:23 +10:00
Zoltan Somogyi
eec676aeee Move a specialized type next its general version. 2023-04-25 01:22:51 +10:00
Zoltan Somogyi
a47de48c4d s/input_stream/text_input_stream/ ...
... and the same for output streams.
2023-04-24 14:59:20 +10:00
Zoltan Somogyi
12985941ad Make old/new MercuryFile structs easily comparable ...
... by putting the macros that operate on both of them into the same order,
and documenting which macros are specific to just one version.
2023-04-24 14:00:13 +10:00
Zoltan Somogyi
4281a28f73 Make text_{input,output}_stream standalone types ...
... and make {input,output}_stream synonyms for them, rather than vice versa.

library/io.m:
    As above.

library/bitmap.m:
library/dir.m:
library/io.primitives_read.m:
library/io.stream_db.m:
library/io.text_read.m:
library/mercury_term_lexer.m:
library/stream.string_writer.m:
    Conform to the change above.

tests/hard_coded/stream_string_writer_types.exp:
    Expect the new type_ctor for text streams.
2023-04-24 13:52:10 +10:00
Zoltan Somogyi
79b65ff650 Fully initialize C# MR_MercuryFileStructs at open ...
... by setting up their reader or writer fields then, instead of
testing at each input or output operation whether the relevant field is null,
and filling it in if it is.

library/io.primitives_read.m:
library/io.primitives_write.m:
    Delete the test-and-fill-if-needed code from the read and write operations.

library/io.stream_ops.m:
    Initialize the reader and writer fields of each MR_MercuryFileStruct
    as it is created an file open time.

    Document when each field of the MR_MercuryFileStruct is meaningful.

    Add an XXX about binary vs text files.

    Add an XXX proposing a new arrangement of stream types.
2023-04-24 11:43:50 +10:00
Zoltan Somogyi
8de0a1351a Fix comments. 2023-04-23 15:30:24 +10:00
Julien Fischer
199bd81ee6 Fix standard library compilation the C# grade.
library/string.m:
    As above.
2023-04-21 23:41:46 +10:00
Zoltan Somogyi
6bdd8b84ee Move maybe_changed to maybe_succeeded.m and rename it.
compiler/maybe_util.m:
    Move the maybe_changed type from several modules of the compiler
    to maybe_succeeded.m, and rename it to maybe_util.m.

compiler/libs.m:
compiler/notes/compiler_design.html:
    Implement and document the rename.

compiler/common.m:
compiler/compile_target_code.m:
compiler/decide_type_repn.m:
compiler/det_analysis.m:
compiler/det_util.m:
compiler/equiv_type.m:
compiler/equiv_type_hlds.m:
compiler/file_util.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
compiler/make.track_flags.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_c_type.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/module_cmds.m:
compiler/parse_tree_out.m:
compiler/process_util.m:
compiler/recompilation.version.m:
compiler/write_module_interface_files.m:
    Conform to the changes above.
2023-04-21 17:24:30 +10:00
Zoltan Somogyi
2a12732260 Improve well-formedness checks on UTF strings.
library/io.m:
    Add the predicates

        read_named_file_as_string_wf
        read_named_file_as_lines_wf
        read_file_as_string_wf
        read_file_as_string_and_num_code_units_wf

    which extend their base predicates (without the _wf suffix) by checking
    whether the string read from the file is well formed, and returning
    an error if it is not.

library/io.stream_op.m:
    Fix and expand a comment.

library/io.text_read.m:
    Add a comment.

library/string.m:
    Add check_well_formedness, a predicate that checks whether a string
    is well formed, and (if relevant) specifies the offset of the first
    non-well-formed character.

    Make the documentation of index_next and index_next_repl more detailed.

runtime/mercury_string.[ch]:
    Define MR_utf8_find_ill_formed_char, a version of MR_utf8_verify
    that returns the offset of the first ill-formed UTF-8 char in the
    given string, if there is one. This is used in the implementation of
    check_well_formedness for C.

NEWS.md:
    Announce the new library predicates.

    Sort some lists of pred names.
2023-04-21 15:55:23 +10:00
Zoltan Somogyi
169e8a22d1 Fix documentation rot. 2023-04-20 19:52:46 +10:00
Zoltan Somogyi
6d184346d5 Fix indentation. 2023-04-20 19:49:05 +10:00
Julien Fischer
a9a27a5404 Use integer.two/0 in a few spots.
compiler/int_emu.m:
    As above.
2023-04-19 21:57:22 +10:00
Zoltan Somogyi
00e1a62ab4 Fix a misleading error message.
compiler/det_report.m:
    In some cases described in the new test case, the error message
    we print for a missing switch inside an arm of a larger switch
    is misleading unless we print *which* arm of the larger switch
    we are complaining about, so print that information.

tests/invalid/require_complete_nested_switch.{m,err_exp}:
    A test case derived from the real-life error that motivated this diff.

tests/invalid/Mmakefile:
    Enable the new test case.
2023-04-19 19:57:51 +10:00
Zoltan Somogyi
2cf96eee4b Factor out common code when evaluating tests.
compiler/const_prop.m:
    Replace ten blocks of code, one each for {int,uint}{,8,16,32,64},
    with just two blocks, one for signed and one for unsigned integers,
    each of which works for all operand sizes.
2023-04-19 17:38:31 +10:00
Zoltan Somogyi
2e06c9abe8 Extend constant propagation to sized integers.
compiler/int_emu.m:
    Give the emulation predicates for arithmetic predicates their inputs
    as two arbitrary-precision integers, and then check whether the results
    fit into the representable range of their expected type.

    Give the emulation predicates for shift predicates their inputs
    as an arbitrary-precision integer (the value to be shifted) and as
    an int (the shift amount) and then check whether the results fit into
    the representable range of their expected type.

    In both cases, the caller (const_prop.m) will convert the inputs
    to the above types. In both cases, the original code of int_emu.m
    worked by doing the operation on arbitrary precision integers.
    This approach emulates operations on fives times as many types
    using less code (which includes just a bit more than half the
    original number of predicates).

    Add predicates to emulate the logical operations AND, OR, XOR and NOT.

    Split a convenience function into two, for two distinct use cases.

compiler/const_prop.m:
    Replace the parts of this module which used separate code paths
    for doing constant propagation on ints and on uints, with code using
    one code path that works for all of {int,uint}{,8,16,32,64}.

    In some places, this required changing the structure of the code
    to switch on procedure names first, and the shape of the operands second,
    when the old code did things the other way around. Some tests for
    the safety of the propagation on bitwise negation was also shifted
    into int_emu.m.

compiler/simplify_goal_call.m:
    Conform to the changes above.
2023-04-19 16:34:39 +10:00
Zoltan Somogyi
67bb8fce33 Move uint_emu.m's contents into int_emu.m ...
... as a preliminary for extending the emulation to sized ints and uints.

compiler/int_emu.m:
    Move all the emulation operations from uint_emu.m to int_emu.m,
    moving each uint operation next to its int equivalent. To make this
    possible without naming conflicts, add a distinguishing prefix
    to the name of each emulation predicate. (The emulations of each op
    for signed and unsigned ints are related though somewhat different,
    and both the similarities and differences are easily visible and checkable
    when their code is next to each other.)

    On the other hand, the emulation code for an operation for e.g.
    int/int8/int16/int32/int64 can be *identical* when the number of bits
    is a parameter of that code, and the next diff will exploit this fact.

    Unify the target_bits_per_int predicate from int_emu.m and the
    target_bits_per_uint predicate from uint_emu.m, which had exactly
    the same logic, and call it target_word_bits.

compiler/uint_emu.m:
    Delete this module.

compiler/libs.m:
    Delete both int_emu.m and uint_emu as a submodule of this package.

compiler/parse_tree.m:
    Move int_emu.m to become a submodule of this package, to allow the next
    change to it to use the some_int_const type in prog_data.m.

compiler/notes/compiler_design.html:
    Generalize the description of int_emu.m. Note that the description
    of uint_emu.m cannot be deleted, because it didn't exist :-(

compiler/const_prop.m:
compiler/simplify_goal_call.m:
    Conform to the changes above.
2023-04-18 12:59:55 +10:00
Zoltan Somogyi
713d541ada Small improvements in the code simplifying calls.
compiler/const_prop.m:
    Replace pairs and maybes with a semantically meaningful type.
    Restrict this type to the part we actually use.

    Optimize ubits_per_{int,uint} the same way we have long optimized
    bits_per_{int,uint}.

compiler/simplify_goal_call.m:
    Improve the wording of some warnings.

    When constructing those warnings, don't test the value of warn_simple_code
    twice.

compiler/uint_emu.m:
    Fix copy-and-paste typo.

tests/warnings/unsigned_zero_cmp.exp:
    Expect the updated text of the above warnings.
2023-04-17 17:35:25 +10:00
Zoltan Somogyi
4f9eb3e450 Update programming style. 2023-04-16 15:27:22 +10:00
Zoltan Somogyi
b6178ef723 Delete prog_out.m, moving its code to other modules.
compiler/parse_tree_out_cons_id.m:
    Move the predicates and functions in prog_out.m that deal with cons_ids
    to this module.

compiler/parse_tree_out_sym_name.m:
    Move the predicates and functions in prog_out.m that deal with sym_names
    and similar entities to this module.

compiler/parse_tree_out_type.m:
    Move the predicates and functions in prog_out.m that deal with types
    to this module.

compiler/parse_tree_out_misc.m:
    Move the predicates and functions in prog_out.m that deal with simple
    types to this module.

    Delete mercury_output_det and mercury_format_det, replacing all their
    uses with calls to mercury_det_to_string.

compiler/prog_out.m:
    Delete this module.

compiler/parse_tree.m:
    Delete prog_out from the parse_tree package.

compiler/Mercury.options:
compiler/notes/compiler_design.html:
    Delete references to prog_out.m.

compiler/*.m:
    Update imports and any explicit module qualifications to account
    for the moved code.

tools/filter_sort_imports:
    Automatically filter out any repeated imports. This can help with
    changes like this that redistribute the contents of one module to other
    modules. In this case, after a global replacement of prog_out's import
    with the import of parse_tree_out_misc, this updated script could
    remove this changed import from modules that already imported
    parse_tree_out_misc.
2023-04-09 16:23:13 +10:00
Zoltan Somogyi
cf66008788 Stop using exceptions in the analysis package.
compiler/analysis.m:
compiler/analysis.file.m:
    Instead of throwing an exception when we find an unexpected version
    number or an unrecognized item in a file, construct an error_spec
    describing the problem, add it to the list, and continue processing,
    if this is possible.

    In some places, pass around the information needed for the construction
    of meaningful error messages.

    Note a limitation of the new approach to error handling (that it inherits
    from the old approach).

    Instead of reading in each item in analysis request/result files
    separately, read in their whole files all at once, and just parse it
    item by item.

    Stop marking module_cmds as an unwanted dependency; it defines
    undate_interface_return_changed, which is required for this module's job.

    Give some predicates more meaningful names.

compiler/error_spec.m:
    Fix some documentation rot.

compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
    Act on the error_specs that the analysis package can now return.
2023-04-09 13:41:06 +10:00
Julien Fischer
ec9cd386db Fix spelling.
compiler/trailing_analysis.m:
    As above.
2023-04-08 15:27:33 +10:00
Zoltan Somogyi
7c145ba274 Document a library predicate.
library/mercury_term_lexer.m:
    Clarify that the documentation of string_get_token_list applies
    to its linestr version too.

library/mercury_term_parser.m:
    Fix the comment for a predicate.
2023-04-08 10:47:31 +10:00
Julien Fischer
8a3be4eaea Avoid a warning from make on Windows.
scripts/Mmake.vars.in:
    The cygpath utility prints a warning if it is invoked with an empty
    argument.
2023-04-07 19:14:34 +10:00
Julien Fischer
69af254126 Shift a NEWS entry.
NEWS.md:
    Shift the announcement of the documentation fixes in the term_io
    module to the 22.01.6 section (since the fixes themselves have been
    merged on to the 22.01 branch).
2023-04-07 17:13:02 +10:00
Julien Fischer
0f0df8bd03 Fix spelling.
library/stream:
    As above.

library/term_io.m:
    Bump year in copyright notice.
2023-04-07 16:36:08 +10:00
Zoltan Somogyi
f019787c20 Avoid contractions. 2023-04-07 14:48:55 +10:00
Zoltan Somogyi
8eda3b065f Replace more rafe-isms in analysis.m. 2023-04-07 06:42:14 +10:00
Zoltan Somogyi
4fc654143f Improve style. 2023-04-07 04:31:53 +10:00
Zoltan Somogyi
1659e9e2cb Use explicit streams in analysis*.m.
compiler/analysis.m:
compiler/analysis.file.m:
    Switch to using explicit streams.

    Use io.format when relevant.

    Give some fields, predicates and variables more meaningful names.

    Replace some rafe-isms with code in our usual coding style.

    Add XXXs for possible future improvements.

    Replace the flag that says whether debug is enabled with a maybe
    wrapped around the stream where debug output should go.

compiler/handle_options.m:
    Initialize the maybe debug stream.

compiler/Mercury.options:
    Stop disabling the warning for the use of implicit streams
    for analysis.m and analysis.file.m.
2023-04-07 01:08:56 +10:00
Zoltan Somogyi
9c91bae4c9 Fix user-visible documentation in term_io.m.
library/term_io.m:
    Four predicates that wrote to the current output stream were documented
    as writing to stdout, which may, or *may not*, be stdout. Fix this.

    Make the code of escaped_string more readable.

    Delete unneeded explicit module qualifications.

NEWS.md:
    Announce the fix.
2023-04-07 00:57:43 +10:00
Zoltan Somogyi
5c8e430c78 Improve formatting. 2023-04-07 00:42:51 +10:00
Zoltan Somogyi
e2a8a8cbfa Break up mercury_to_mercury.m.
compiler/mercury_to_mercury.m:
    Delete this module, and replace it with ...

compiler/parse_tree_out_cons_id.m:
compiler/parse_tree_out_sym_name.m:
compiler/parse_tree_out_type.m:
compiler/parse_tree_out_misc.m:
    ... these four modules. The first three write out the entities
    in their names: cons_ids, sym_names, and types. The fourth contains
    the rest of the old mercury_to_mercury.m, plus a few predicates
    moved there from prog_out.m that deal with indentation.

compiler/parse_tree.m:
    Include the four new modules, and stop including the deleted module.

compiler/notes/compiler_design.html:
    Document the new modules.

compiler/prog_out.m:
    Delete the code moved to parse_tree_out_misc.m.

compiler/*.m:
    Adjust the imports as needed. Most modules need only one, maybe two
    of mercury_to_mercury's four successor modules.
2023-04-06 15:32:48 +10:00