--no-ansi (mgnuc) and --no-ansi-c (mmc) have not actually done anything for
many years now. Deprecate these options and remove their "use" throughout most
of the Mercury system. (The remaining uses are in the Makefiles for the Boehm
GC, which need to be updated separately.)
Also deprecate the internal compiler option --cflags-for-ansi.
compiler/options.m:
Document that --no-ansi-c is now deprecated.
Document that the internal option --cflags-for-ansi is now
deprecated.
compiler/compile_target_code.m:
Do not pass the ANSI options to the C compiler.
scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
Deprecate the --no-ansi option; delete code that no longer does
anything useful.
configure.ac:
Delete the configuration variable CFLAGS_FOR_ANSI; it is only ever
set to be empty. (The comment talks about --no-ansi doing other things
in the mgnuc script. It used to also cause some preprocessor macros
to be defined for compatibility with the system headers on some
platforms -- that has not been the case since 2013.)
doc/user_guide.texi:
Document that --no-ansi-c is deprecated.
bytecode/Mmakefile:
compiler/Mercury.options:
library/Mercury.options:
extras/odbc/odbc.m:
runtime/Mmakefile:
scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
tests/hard_coded/Mercury.options:
tests/valid/Mercury.options:
trace/Mmakefile:
util/Mmakefile:
Conform to the above change.
NEWS.md:
Announce the above.
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.
... 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.
library/fatter_sparse_bitset.m:
Add this version of fat_sparse_bitset.m, which stores *two* words
worth of bits in each cell, not one. This word would otherwise be unused,
because the Boehm-Demers-Weiser allocator rounds up requests for three
word cells to four.
library/MODULES_DOC:
library/library.m:
Add the new module to the list of library modules.
library/fat_sparse_bitset.m:
library/sparse_bitset.m:
library/tree_bitset.m:
Update the documentation of all these other bitset modules. Copy
the same basic introduction to all the relevant modules. Add documentation
of the differences to tree_bitset.m and fatter_sparse_bitset.m, with
a pointer in fat_sparse_bitset.m to fatter_sparse_bitset.m.
library/test_bitset.m:
Test the new module as well as the others.
tests/hard_coded/speedtest_bitset.m:
Extend the benchmarking of list_to_set operations to the new module.
To allow the benchmarking to be tough enough to be informative, comment
out the benchmarking of the old_list_to_set operations.
... by using the algorithm now in sparse_bitset.list_to_set.
Keep the old list_to_set algorithm around in both modules for a short while
to allow comparative benchmarking.
library/fat_sparse_bitset.m:
library/sparse_bitset.m:
As above.
tests/hard_coded/speedtest_bitset.m:
A benchmark program to compare the old and new list_to_set algorithms,
both versus each other, and between sparse_bitset and fat_sparse_bitset.
library/test_bitset.m:
Instead of comparing just one bitset module (tree_bitset by default)
against set_ordlist, compare all of them (tree_bitset, sparse_bitset,
and fat_sparse_bitset) against set_ordlist.
tests/hard_coded/test_bitsets.{m,exp}:
Rename this test case from test_tree_bitset to test_bitsets, since
(through library/test_bitset.m) we now test ALL bitset implementations,
not just tree_bitset.
tests/hard_coded/Mmakefile:
Refer to the test by its new name.
The current implementation of the unsigned conversion specifiers (i.e. %x, %X,
%o, %u) for fixed-size 8-, 16- and 32-bit signed integers works by casting
theses values into (word-sized) ints and then using the existing code for
formatting ints as unsigned values. This does not work for negative values as
they are being sign extended when converted to ints. For example,
io.format("%x", [i8(min_int8)], !IO)
prints:
ffffffffffffff80 (on a 64-bit machine)
rather than just:
80
Fix the above problem by casting ints, int8s, int16s etc. that are being
formatted as unsigned values to uints and using the uint formatting code.
NOTE: the formatting code for 64-bit integers follows a different code path
and is not affected by any of this.
library/string.format.m:
Implement unsigned conversion specifiers for non-64-bit signed
integers by casting to uint and using the uint formatting code.
Add predicates for converting signed integers into uints.
The format_unsigned_int_* predicates can be deleted after this change
is installed.
compiler/format_call.m:
Implement unsigned conversion specifiers for non-64-bit signed
integers by casting to uint and using the uint formatting code.
compiler/introduced_call_table.m:
Update the table of introduced predicates.
compiler/options.m:
Add an option that can be used to test whether this fix is
installed.
tests/hard_coded/Mmakefile:
tests/hard_coded/Mercury.options:
tests/hard_coded/opt_format_sign_extend.{m,exp}:
Test that formatting code introduced by the compiler does not
accidentally sign-extend negative values.
tests/string_format/string_format_{o,x,u}.{m,exp,exp2}:
Make these tests much more comprehensive then they previously
were.
Implement two transitive closure algorithms in the digraph module:
- Basic_TC by Yannis Ioannidis et al.
- STACK_TC by Esko Nuutila, a refinement of the SIMPLE_TC algorithm
previously implemented
On 450 graphs randomly generated by tests/hard_coded/digraph_tc.m,
ranging from 100 to 3000 vertices:
- basic_tc ran from 0.79 to 1.66 times as fast as simple_tc
(mean 1.139, stdev 0.136)
- basic_tc ran from 0.83 to 1.81 times as fast as stack_tc
(mean 1.131, stdev 0.160)
Therefore, after this commit, I will delete the simple_tc and stack_tc
implementations, but they will be available in the version history.
library/digraph.m:
Implement Basic_TC and STACK_TC.
Use map.transform_value in key_set_map_union to replace a search
followed by update.
tests/hard_coded/digraph_tc.m:
Test and benchmark the new algorithms.
Also compare inverse graphs to check that predecessor maps are
maintained properly.
library/sparse_bitset.m:
library/fat_sparse_bitset.m:
Speed up the remove_leq and remove_gt operations by moving a
loop invariant computation, the conversion of the boundary item's index
into an <offset,bitposn> pair, out of the loop.
Eliminate some unnecessary differences between the two modules,
e.g. clear_bit being a predicate rather than a function.
library/test_bitset.m:
Add facilities to test the remove_leq and remove_gt operations
of sparse_bitset.m, fat_sparse_bitset.m, and tree_bitset.m
against the same operations on plain old set_ordlists.
Bring this module up to date by requiring set elements to be
members of the uenum typeclass, not the enum typeclass.
Make the test_bitset type a bespoke type.
library/tree_bitset.m:
Add predicate versions of the remove_leq and remove_gt operations
alongside the existing function versions, to allow the new code
in test_bitset.m to work the same way regardless of which bitset module
it is testing.
For uniformity with the other bitset modules, require set elements to be
members of the uenum typeclass, not the enum typeclass.
Change the other integers, such as level numbers, to be unsigned
as well, to avoid the need for casts.
NEWS:
Announce the new additions and changes.
tests/hard_coded/test_tree_bitset.{m,exp}:
Use those new facilities to test those operations, and add some
test sets designed for that purpose.
Add a comment about the limitations of this testing strategy.
tests/hard_coded/bitset_tester.m:
Delete this long-unused module. (It was the original basis of
the test_bitset.m module in the library directory, but it became unused
when test_tree_bitset.m switched to using that module a long time ago.)
library/digraph.m:
Delete digraph.old_tc, digraph.old_rtc and digraph.slow_rtc.
tests/hard_coded/digraph_tc.m:
tests/hard_coded/digraph_tc.exp:
Delete comparisons using old_tc, old_rtc and slow_rtc.
Implement transitive closure using the simple_tc algorithm from
Esko Nuutila's doctoral thesis.
On a sample of graphs randomly generated by tests/hard_coded/digraph_tc.m,
ranging from 100 to 3000 vertices, the simple_tc implementation ran
from 2.33 to 93 times as fast as the old implementation on my machine.
library/digraph.m:
Rename digraph.tc and digraph.rtc to digraph.old_tc and
digraph.old_rtc. They are kept around for benchmarking,
and will be deleted soon.
Use the simple_tc algorithm to implement digraph.tc.
Use digraph.tc to implement digraph.rtc.
Let key_set_map_add call sparse_bitset.insert_new instead of
sparse_bitset.contains followed by sparse_bitset.insert.
tests/hard_coded/digraph_tc.m:
Add code to benchmark the new and old TC implementations.
library/std_util.m:
Make std_util.pow/3 throw an exception if it is called with a negative
integer as its second argument.
tests/hard_coded/Mmakefile:
tests/hard_coded/func_exp.{m,exp}:
Add a test of pow/3.
NEWS:
Announce the above change.
The implementation of digraph.rtc was incorrect (as demonstrated in the
new test case), which meant that digraph.tc was also incorrect.
library/digraph.m:
Fix the implementation of rtc (reflexive transitive closure):
- Following the algorithm used in digraph.cliques, it needs to
traverse the graph G in *reverse* depth-first order.
- To find the clique containing a vertex X, it needs to do a DFS on
the *reversed* graph to find the vertices with a path to X.
The vertices that were previously unvisited will be members of
the same clique as X.
- Previously it found the "followers" of the elements of the clique,
and the followers of those followers, then added edges from the
members of the current clique to those followers. However, that
only includes vertices two steps removed from the clique.
I have fixed it to add edges to *all* vertices reachable from
members of the clique.
Add straightforward implementations of tc and rtc for comparison.
Add some comments.
tests/hard_coded/Mmakefile:
tests/hard_coded/digraph_tc.exp:
tests/hard_coded/digraph_tc.inp:
tests/hard_coded/digraph_tc.m:
Add test case.
NEWS:
Announce the fixes.
library/array.m:
library/char.m:
library/float.m:
library/int.m:
library/int16.m:
library/int32.m:
library/int64.m:
library/int8.m:
library/list.m:
library/one_or_more.m:
library/string.m:
library/tree234.m:
library/uint.m:
library/uint16.m:
library/uint32.m:
library/uint64.m:
library/uint8.m:
library/version_array.m:
Mark the X_to_doc function in each of these modules as obsolete,
and make it a forwarding function to the actual implementation
in pretty_printer.m. The intention is that when these forwarding
functions are eventually removed, this will also remove the dependency
of these modules on pretty_printer.m. This should help at least some
of these modules escape the giant SCC in the library's dependency graph.
(It does not make sense that a library module that adds code to increment
an int thereby becomes dependent on pretty_printer.m through int.m.)
library/pretty_printer.m:
Move all the X_to_doc functions from the above modules here.
Fix the one_or_more_to_doc function, which was
- missing the comma between the two arguments of the one_or_more
function symbol, and
- would print "..., ...]" instead of just "...]" at the end of the
tail list when that list exceeded the limits of the specified pp_params.
Rename one of the moved types along with its function symbols,
to reduce ambiguity.
Put arrays before their indexes in the argument lists of some of
the moved functions.
Some of the moved X_to_doc functions for compound types returned
a doc that had an indent wrapper. These indents differed between the
various X_to_doc functions without any visible reason, but they are
also redundant. The callers can trivially add such wrappers if they
want to, but taking them off, if they want them off, is harder.
Eliminate the problem by deleting all such indent wrappers.
Add formatters for the intN, uintN and one_or_more types to the
default formatter map. Their previous absence was an oversight.
Add a function, get_formatter_map_entry_types, that returns the ids
of the types in the formatter_map given to the function. It is intended
for tests/hard_coded/test_pretty_printer_defaults.m, but is exported
for anyone to use.
tests/hard_coded/test_pretty_printer_defaults.{m,exp}:
Use get_formatter_map_entry_types to print the default formatter map
in a format that is much more easily readable.
NEWS:
Announce all the user-visible changes above.
The recent change to sparse_bitsets broke the lex library in extras.
Specifically, we now now need to make characters an instance of the
uenum typeclass. This diff does so.
library/char.m:
Add predicates and functions for converting between unsigned integers
and characters.
Make characters an instance of the uenum typeclass.
tests/hard_coded/Mmakefile:
tests/hard_coded/char_uint_conv.{m,exp,exp2}:
Add a test of the above conversions.
NEWS:
Announce the additions.
extras/lex/lex.m:
Conform to recent changes.
... along with their unchecked equivalents. These differ from <<, >> and
their unchecked equivalents in that they take the shift amount as a uint,
instead of an int.
library/int.m:
library/int16.m:
library/int32.m:
library/int64.m:
library/int8.m:
library/uint.m:
library/uint16.m:
library/uint32.m:
library/uint64.m:
library/uint8.m:
As above. The unchecked versions have only declarations, since
these operations have been recognized as builtins for a while now.
NEWS:
Document the new operations, and the recent change to recognize
<<u and >>u as single tokens, and fix a typo in a recent addition.
configure.ac:
Require the compiler to be sufficiently recent to be able to parse
<<u and >>u as operators.
compiler/options.m:
Provide a way for a later change to configure.ac to detect the presence
of this change.
tests/hard_coded/bitwise_int.exp:
tests/hard_coded/bitwise_int.exp2:
tests/hard_coded/bitwise_int.m:
tests/hard_coded/bitwise_int16.exp:
tests/hard_coded/bitwise_int16.m:
tests/hard_coded/bitwise_int32.exp:
tests/hard_coded/bitwise_int32.m:
tests/hard_coded/bitwise_int64.exp:
tests/hard_coded/bitwise_int64.m:
tests/hard_coded/bitwise_int8.exp:
tests/hard_coded/bitwise_int8.m:
tests/hard_coded/bitwise_uint.exp:
tests/hard_coded/bitwise_uint.exp2:
tests/hard_coded/bitwise_uint.m:
tests/hard_coded/bitwise_uint16.exp:
tests/hard_coded/bitwise_uint16.m:
tests/hard_coded/bitwise_uint32.exp:
tests/hard_coded/bitwise_uint32.m:
tests/hard_coded/bitwise_uint64.exp:
tests/hard_coded/bitwise_uint64.m:
tests/hard_coded/bitwise_uint8.exp:
tests/hard_coded/bitwise_uint8.m:
Check that <<u and >>u compute the same results as << and >> respectively.
tests/hard_coded/bitwise_int.m:
tests/hard_coded/bitwise_int16.m:
tests/hard_coded/bitwise_int32.m:
tests/hard_coded/bitwise_int64.m:
tests/hard_coded/bitwise_int8.m:
tests/hard_coded/bitwise_uint.m:
tests/hard_coded/bitwise_uint16.m:
tests/hard_coded/bitwise_uint32.m:
tests/hard_coded/bitwise_uint64.m:
tests/hard_coded/bitwise_uint8.m:
Most of the expected output files of these test cases were
easily readable already, but there were some exceptions caused
by unnecessary differences between their source codes.
The main problem was with bitwise_uint.m (uint_bitwise.m until recently),
whose .exp file contained very long lines of the form A op B = C
where A, B and C could each be 64 bits (and chars) long. Fix this
by adopting the format used by the other modules:
A op
B =
C
The other problem was that in some test cases, the indentation had
an off-by-one bug. They generated output such as
\ aaaa =
bbbb
instead of the much-easier-to-visually-check
\ aaaa =
bbbb
A third, much less important change is the deletion of unnecessary
blank lines.
tests/hard_coded/bitwise_int.exp:
tests/hard_coded/bitwise_int16.exp:
tests/hard_coded/bitwise_int32.exp:
tests/hard_coded/bitwise_int64.exp:
tests/hard_coded/bitwise_int8.exp:
tests/hard_coded/bitwise_uint.exp:
tests/hard_coded/bitwise_uint16.exp:
tests/hard_coded/bitwise_uint32.exp:
tests/hard_coded/bitwise_uint64.exp:
tests/hard_coded/bitwise_uint8.exp:
Conform to the changes in codes of the tests.
NEWS:
Mention all the user-visible changes below.
library/enum.m:
Add the typeclass uenum, which is a version of the existing enum typeclass
that maps items to uints, not ints. It also uses a semidet predicate,
not a semidet function, to get back to the item from the uint.
library/sparse_bitset.m:
library/fat_sparse_bitset.m:
Make these modules operate on uints, which means requiring the items
in the sets to be instances of uenum, not enum.
If a few places, improve loops by doing previously-repeated conversions
of [u]ints into <offset, bit-to-set> pairs just once.
library/counter.m:
Define ucounters, which allocate uints. Improve documentation.
library/digraph.m:
Change digraph_keys from ints to uints, since we put them into
sparse_bitsets.
library/int.m:
Make int an instance of the uenum typeclass. This can help users
who currently put ints into sparse_bitsets.
library/pprint.m:
Prettyprint sparse_bitsets as lists of uints.
library/term.m:
Make vars instances of uenum as well as enum.
library/uint.m:
Make uint an instance of the uenum typeclass.
Add the ubits_per_uint function, which allows some casts to be avoided.
compiler/make.deps_set.m:
Change the indexes we put into sparse_bitsets from ints to uints.
compiler/make.make_info.m:
Change the source of those indexes from ints to uints.
compiler/make.top_level.m:
compiler/make.util.m:
Conform to the changes above.
compiler/pre_quantification.m:
Change zones from ints to uints, since we put them into sparse_bitsets.
tests/hard_coded/int_uenum.{m,exp}:
tests/hard_coded/Mmakefile:
Enable the new test case.
tests/valid/use_import_only_for_instance.m:
Update this extract from library/digraph.m the same way as
library/digraph.m itself.
We don't need to prevent building the 'parse' test on platforms that
don't support static linking any more, as the static linking aspect of
that test case was disabled in commit fd088a4f6.
tests/hard_coded/Mmakefile:
Delete conditions to avoid static linking on some platforms.
Rename STATIC_LINK_PROGS to DEBUG_PROGS.
Since the compiler now refuses to allow debugging in parallel grades,
tests that require debugging need to be skipped over in low-level
parallel grades or deleted.
tests/hard_coded/Mmakefile:
Disable 'parse' test in parallel grades as it happens to link with
debug libraries.
tests/par_conj/Mercury.options:
tests/par_conj/Mmakefile:
tests/par_conj/par_ddeath.exp:
tests/par_conj/par_ddeath.m:
tests/par_conj/par_ddeath_2.exp:
tests/par_conj/par_ddeath_2.m:
Delete par_ddeath and par_ddeath_2 tests that once triggered a
compiler abort with --trace deep in parallel grades.
I don't think there is much value in keeping them around.
tests/valid/Mmake.valid.common:
Skip LLDS_PROGS (i.e. test cases that required debugging) in
parallel grades.
tests/valid/Mercury.options:
tests/valid/Mmakefile:
tests/valid/untuple_bug.m:
Delete untuple_bug. It tests an old bug in the untupling
transformation, which was more a programming exercise than something
that should be used anyway.
library/ops.m:
Instead of an op_table mapping a string to a list of one or more op_infos,
make it map the string to a single structure, the op_infos, which has
four slots, one each for infix, binary prefix, prefix and postfix
op information. This allows parsers and unparsers to go directly to
the kind of operator (e.g. infix or prefix) that they are interested in.
NEWS:
Announce the change.
compiler/parse_tree_out_term.m:
library/mercury_term_parser.m:
library/pretty_printer.m:
library/stream.string_writer.m:
library/string.to_string.m:
samples/calculator2.m:
tests/hard_coded/bug383.m:
Conform to the change. In several places, the new operator representation
allows the replacement of loops with direct lookups, and the replacement
of if-then-else chains with switches.
Add reminders about keeping two predicates in sync.
library/io.m:
Delete the set_io_table predicate, which did nothing and was never
called from anywhere, and the get_io_table predicate, which always
returned the same op_table. They were in io.m's interface, but in the
not-publicly-visible part of the interface.
library/ops.m:
Rename the lookup_op method to is_op.
Delete references to the predicates deleted from io.m.
NEWS:
Announce the lookup_op->is_op rename.
compiler/parse_tree_out_term.m:
library/mercury_term_parser.m:
library/string.to_string.m:
library/term_io.m:
samples/calculator2.m:
tests/hard_coded/bug383.m:
Conform to the lookup_op->is_op rename.
Replace calls to get_io_table with code that directly gets
the Mercury op table.
In parse_tree_out_term.m, call the predicates operating on the
Mercury op table directly, not through the op_table type class.
In mercury_term_parser.m, update some comments.
In term_io.m, use OpTable to refer to op_tables.
tests/hard_coded/stdlib_init.{m,exp}:
Don't test get_io_table.
Mercury inherited its original system of operator priorities from Prolog,
because during its initial development, we wanted to be able execute
the Mercury compiler using NU-Prolog and later SICStus Prolog.
That consideration has long been obsolete, and now we may fix the
design error that gifted Prolog with its counter-intuitive system
of operator priorities, in which higher *numerical* operator priorities
mean lower *actual* priorities. This diff does that.
library/ops.m:
Change the meaning of operator priorities, to make higher numerical
priorities mean also higher actual priorities.
This semantic change requires corresponding changes in any other module
that uses ops.m. To force this change to occur, change the type
representing priorities from being a synonym for a bare int to being
a notag wrapper around an uint.
The old "assoc" type had a misleading name, since it is related to
associativity but is not itself a representation of associativity.
Its two function symbols, which used to be just "x" and "y", meant that
the priority of an argument must be (respectively) greater than,
or greater than equal to, the priority of the operator. So rename
x to arg_gt, y to arg_ge, and assoc to arg_prio_gt_or_ge.
Rename the old adjust_priority_for_assoc predicate to min_priority_for_arg,
which better expresses its semantics. Turn it into a function, since
some of its users want it that way, and move its declaration to the
public part of the interface.
Add a method named tightest_op_priority to replace the use of 0
as a priority.
Rename the max_priority method as the loosest_op_priority method.
Add a method named universal_priority to replace the use of
max_priority + 1 as a priority.
Add a function to return the priority of the comma operator,
to allow other modules to stop hardcoding it.
Add operations for comparing priorities and for incrementing/decrementing
priorities.
Change the prefix on the names of the predicates that take op_infos
as inputs from "mercury_op_table_" to "op_infos_", since the old prefix
was misleading.
Add a note on an significant old problem with an exported type synonym.
library/mercury_term_parser.m:
Conform to the changes above.
Delete unnecessary module qualifiers, since they were just clutter.
Add "XXX OPS" to note further opportunities for improvement.
library/pprint.m:
Conform to the changes above.
Rename a function to avoid ambiguity.
library/pretty_printer.m:
library/stream.string_writer.m:
library/string.to_string.m:
library/term_io.m:
Conform to the changes above.
library/string.m:
Add a note on an significant old problem.
NEWS:
Announce the user-visible changes.
tests/hard_coded/bug383.m:
Update this test case to use the new system of operator priorities.
tests/hard_coded/term_io_test.{m,inp}:
Fix white space.
extras/old_library_modules/old_mercury_term_parser.m:
extras/old_library_modules/old_ops.m:
The old contents of the mercury_term_parser and ops modules,
in case anyone wants to continue using them instead of updating
their code to use their updated equivalents.
samples/calculator2.m:
Import the old versions of mercury_term_parser and ops.
tests/hard_coded/.gitignore:
tests/hard_coded/Mmakefile:
tests/hard_coded/getopt_maybe_option.exp:
tests/hard_coded/getopt_maybe_option.m:
Add test case for preceding fix for maybe_string options.
library/pretty_printer.m:
Replace the indent_stack data structure with one that
- can represent deep indentation in a compact data structure,
as long as that indentation consists only of standard indents, and
- can tell you how many code points the current indent stack consists of
*without* counting the code points in all the individual indent pieces
every time.
This yields a big speedup, because the code used to spend a very large
fraction of its time (between 40 and 50%) just counting the code points
in indentation. This was on stress test data which had very deep
indentation, but the cost would have been substantial even on moderately
indented docs.
Now that the indent_stack can represent more than one level of indentation
in one data structure, print up to 30 levels of standard indentation
with just one call to stream.put. By amortizing the overheads of stream.put
over a must larger part of the output, this also yields a significant
speedup.
Move the indent_stack type and its (significantly expanded) set of
operations to after the code that outputs docs, since it is just an
implementation detail (though as explained above, an important detail).
tests/hard_coded/pretty_printer_stress_test.{m,data,exp}:
A stress test for the pretty_printer whose profiling lead to the
identification of the performance problems fixed above.
tests/hard_coded/Mmakefile:
Enable the new test case, now that it is not too expensive to run
on every bootcheck.
Implement the error handling proposals from February 2022 on the
mercury-users list, and August 2022 on the mercury-reviews list.
We add io.system_error to the public interface of io.m
and document what its foreign representation is for each backend.
We allow io.error to optionally contain an io.system_error value,
and provide predicates to retrieve the io.system_error from an io.error.
The user may then inspect the system error via foreign code.
We also provide a predicate that takes an io.error and returns a name
for the system error it contains (if any). This makes it relatively easy
for Mercury programs to check for specific error conditions.
By returning platform-specific (actually, implementation-dependent)
error names, we are pushing the responsibility of mapping strings to
error conditions onto the application programmer. On the other hand, it
is not practical for us to map all possible system-specific error codes
to some common set of values. We could do it for a small set of common
error codes/exceptions, perhaps.
The standard library will construct io.error values containing
io.system_errors. However, we do not yet provide a facility for user
code to do the same.
library/io.m:
Move io.system_error to the public interface.
Change the internal representation of io.error to support containing
a io.system_error. An io.system_error may originate from an errno
value or a Windows system error code; the constructor distinguishes
those cases.
Add predicates to retrieve a system_error from io.error.
Add predicate to return the name of the system error in an io.error.
Replace make_err_msg with make_io_error_from_system_error.
Replace make_maybe_win32_err_msg with
make_io_error_from_maybe_win32_error.
Delete ML_make_err_msg and ML_make_win32_err_msg macros.
browser/listing.m:
library/bitmap.m:
library/dir.m:
library/io.call_system.m:
library/io.environment.m:
library/io.file.m:
library/io.text_read.m:
mdbcomp/program_representation.m:
Conform to changes.
Leave comments for followup work.
tools/generate_errno_name:
tools/generate_windows_error_name:
Add scripts to generate mercury_errno_name.c and
mercury_windows_error_name.c.
runtime/Mmakefile:
runtime/mercury_errno_name.c:
runtime/mercury_errno_name.h:
runtime/mercury_windows_error_name.c:
runtime/mercury_windows_error_name.h:
Add MR_errno_name() and MR_win32_error_name() functions,
used by io.m to convert error codes to string names.
tests/hard_coded/null_char.exp:
Update expected output.
library/string.m:
Fix string.all_match to fail if the string being tested contains
any ill-formed code unit sequences.
Fix the Mercury implementation of string.contains_char to continue
searching for the character past any ill-formed code unit sequences.
The foreign code implementations already did so.
Fix unsafe_index_next_repl and unsafe_prev_index_repl in C grades.
We indexed the C string with `ReplacedCodeUnit = Str[Index]' but
since Mercury strings have the C type `char *', ReplacedCodeUnit
could take on a negative value. When ReplacedCodeUnit == -1,
the caller would assume there is a valid encoding of a code point
beginning at Index, and therefore return `not_replaced' instead of
`replaced_code_unit(255)'.
Add casts to `unsigned char' in other places where we index C
strings.
Clarify documentation.
Document that string.duplicate_char may throw an exception.
tests/hard_coded/string_all_match.m:
tests/hard_coded/string_all_match.exp:
tests/hard_coded/string_all_match.exp2:
Add test for string.all_match.
tests/hard_coded/contains_char_2.m:
tests/hard_coded/contains_char_2.exp:
Delete older test case for string.contains_char.
tests/hard_coded/string_contains_char.m:
tests/hard_coded/string_contains_char.exp:
tests/hard_coded/string_contains_char.exp2:
Add better test for string.contains_char.
tests/hard_coded/Mmakefile:
Enable the tests.
NEWS:
Announce the changes.
tests/hard_coded/type_spec_modes.{m,exp}:
Add a test of type specialization pragmas for functions, since
none of our other tests of type_spec pragmas does so.
Add a new predicate that tests if string contains any characters that succeed
for a given test predicate.
library/string.m:
Add the new predicate.
compiler/options.m:
Replace the predicate string_contains_whitespace/1 defined here
with a call to the new library predicate.
NEWS:
Announce the new predicate.
tests/hard_coded/Mmakefile:
tests/hard_coded/string_contains_match.{m,exp}:
Add a test of the new predicate.
tests/hard_coded/test_pretty_printer.m:
tests/hard_coded/test_pretty_printer_helper.m:
This test checks the operation of the library's pretty_printer module
- on several docs, and
- with several parameters.
With the old organization of this test case, the output consisted of
- all docs with the first set of parameter values,
- all docs with the next set of parameter values,
and so on.
This diff reorders the output so that it now consists of
- the first doc with all sets of parameter values,
- the next doc with all sets of parameter values,
and so on.
This makes it much easier to check the output.
The new approach also
- gives a name to each doc,
- prints the doc using the largest parameter values (longest lines,
most lines allowed, etc) first, which allows all the later outputs
for the same doc with smaller parameters values to be checked against
it more easily.
This diff also moves the code that serves as the infrastructure
of the test case to the new module test_pretty_printer_helper.m,
leaving test_pretty_printer.m to contain just the code that
constructs the docs whose prettyprinting is to be tested. (Previously,
these two classes of code were interleaved in the source code.)
tests/hard_coded/test_pretty_printer.exp:
Expect the output in the updated order.
The changes to cord.m and list.m are to reduce unnecessary differences
between cord.m, list.m, and ra_list.m.
library/ra_list.m:
Add new procedures singleton, is_empty, is_not_empty, is_singleton,
length, list_to_ra_list, map, foldl and foldr.
Make ra_list_to_list operate without unnecessary memory allocations.
library/cord.m:
Add a semidet predicate head as a synonym for get_first.
library/list.m:
Add a semidet predicate is_singleton.
Add semidet predicates head and tail next to their semidet function
versions (which should be deprecated). Document them.
Add det predicates det_head and det_tail next to their det function
versions.
Avoid the overhead of calling a closure used for func-to-pred conversion
once for each list element in the function versions of foldl and foldr.
Fix some other documentation.
NEWS:
Mention the new additions to standard library.
library/term_to_xml.m:
tests/hard_coded/construct_packed.m:
Avoid ambiguities between function and predicate forms.
tests/hard_coded/ra_list_test.{m,exp}:
Add tests of length, list_to_ra_list, map, foldl and foldr.
library/ra_list.m:
As above.
Rename ra_list_lookup to ra_list_search, since it fails if the item
to be accessed does not exist. Add a version, ra_list_lookup, which
aborts in that case.
Add predicates to append two ra_lists, and to convert ra_lists
to just plain lists.
Change the argument order of some predicates to be more
state variable friendly.
Add some documentation.
library/bt_array.m:
Delete the moved code, and update the references to the changed predicates.
library/Mercury.options:
Now that the ra_list predicates have been moved to their own module,
stop giving bt_array.m a free pass on inconsistent predicate order.
library/MODULES_DOC:
library/library.m:
Add ra_list.m as a documented module of the Mercury standard library.
library/array.m:
Delete a predicate that served as a test for an ancient bug fix.
NEWS:
Announce both the new ra_list module, and the deletion of the predicate
from array.m.
tests/hard_coded/array_sort.m:
Don't call the predicate deleted from array.m.
tests/hard_coded/ra_list_test.{m,exp}:
A new test case to test operations on ra_lists.
tests/hard_coded/Mmakefile:
Enable the new test case.
library/cord.m:
Add is_singleton/2, foldr2/6 and foldr3/8.
NEWS:
Announce the above additions.
tests/hard_coded/Mmakefile:
tests/hard_coded/test_cord3.{m,exp}:
Add a test of is_singleton/2 (and is_empty/1).
There is an issue on Linux/aarch64 with older versions of gcc where a
commit performed on a thread using the gcc __builtin_longjmp function
causes an assertion failure in pthread_create() if the Mercury runtime
is dynamically linked:
pthread_create.c:430: start_thread: Assertion `freesize < pd->stackblock_size' failed.
or a crash if the Mercury runtime is statically linked:
*** Mercury runtime: caught segmentation violation ***
cause: address not mapped to object
The gcc versions tested are:
BAD - gcc version 6.3.0 20170516 (Debian 6.3.0-18) from Debian 9
BAD - gcc version 8.3.0 (Debian 8.3.0-2) from Debian 10
OK - gcc version 10.2.1 20210110 (Debian 10.2.1-6) from Debian 11
on Debian with glibc.
runtime/mercury.h:
Define MR_USE_GCC_BUILTIN_SETJMP_LONGJMP if we decide to use gcc's
__builtin_setjmp and __builtin_longjmp functions instead of the
standard functions.
Use standard setjmp/longjmp on aarch64 if gcc version is < 10.
Update the comment for MR_builtin_jmp_buf to refer to the GCC manual
instead of the GCC source code. Use an array of 'intptr_t's instead
of 'void *'s, to match the manual.
tests/hard_coded/Mmakefile
tests/hard_coded/thread_commit.m:
tests/hard_coded/thread_commit.exp:
tests/hard_coded/thread_commit.exp2:
Add test case.
to allow even very long disjunctions to be parsed in constant stack space.
This fixes Mantis bug #559.
compiler/prog_item.m:
We used to represent a disjunction like ( GoalA ; GoalB ; GoalC ; GoalD )
in the parse tree as
disj_expr(ContextA, GoalA,
disj_expr(ContextB, GoalB,
disj_expr(ContextC, GoalC,
GoalD)))
To enable the changes in parse_goal.m and parse_dcg_goal.m, switch over
to representing them as
disj_expr(ContextA, GoalA, GoalB, [GoalC, GoalD])
The type of this term enforces the invariant that a disjunction
must have at least two disjuncts.
The fact that this throws away ContextB and ContextC is not a problem;
they were never used, being thrown away when converting the parse tree
to the HLDS.
compiler/parse_goal.m:
compiler/parse_dcg_goal.m:
After seeing the first comma in the above disjunction, these parsers
used to (1) parse its left operand, GoalA, (2) parse its right operand,
( GoalB ; GoalC ; GoalD), and then (3) check for errors. This code
was prevented from being tail recursive both by the presence of step 3,
and the fact that step 2 indirectly invokes another predicate that
(until my previous change to parse_goal.m) had a different determinism.
Fix the first issue by having the new predicate parse_goal_disjunction,
and its DCG variant, accumulate errors *alongside* disjuncts,
to be checked just once, at the end, outside the loop. Fix the second
issue by having parse_goal_disjunction test whether the right operand
of the semicolon has the form of a disjunction, and if it does,
recursing on it directly. This makes parse_goal_disjunction
self-tail-recursive, which should allow it to process disjunctions
of arbtrary length using fixed stack space (in grades that support
tail recursion, that is).
Move the code to flatten disjunctions from goal_expr_to_goal.m to
these modules, because it is simpler to get the right result this way
in DCG clauses (for non-DCG clauses, it works simply either way).
compiler/goal_expr_to_goal.m:
Convert the updated parse tree representation of disjunctions to HLDS,
and don't flatten disjunctions here anymore.
compiler/parse_item.m:
Add some infrastructure for debugging changes like this.
compiler/add_clause.m:
Improve the infrastructure of debugging changes like this, by making it
more selective.
To make this possible, pass the predicate name to a predicate
that did not need it before. Fix the argument order of that predicate.
compiler/make_hlds_warn.m:
Don't flatten parse tree disjunctions, since the code constructing them
has done it already.
compiler/get_dependencies.m:
compiler/module_qual.collect_mq_info.m:
compiler/parse_tree_out_clause.m:
compiler/prog_item_stats.m:
compiler/prog_util.m:
Conform to the change in prog_item.m.
compiler/instance_method_clauses.m:
Conform to the change in add_clause.m.
tests/hard_coded/flatten_disjunctions.{m,exp}:
A new test case both testing and documenting the need for flattening
disjunctions.
tests/hard_coded/Mmakefile:
Enable the new test case.
tests/invalid/require_switch_arms_detism.err_exp:
Expect updated numbers for anonymous variables. This is due to
goal_expr_to_goal.m now processing disjuncts in a different order
than before.
The test hard_coded/parse tests two separate things:
1. for the presence of a bug, reported in Mercury 0.9, that occurred when a
local module name shadowed that of a browser module.
2. static linking.
Specifically, the latter tests whether statically linking against the system
libraries works. As most operating systems these days do not ship with static
versions of their system libraries installed by default, this test fails more
often than not. (Indeed, it will never pass on macOS since executables are
required to use the libSystem dylib.)
Delete the static linking aspect of this test, since it is failing almost
everywhere anyway.
tests/hard_coded/Mercury.options:
Do not link the parse test case with --static.