Extend the operations that perform formatted conversion, such as
string.format/2, to be able to handle values of type uint directly. We have
always supported formatting values of type int as unsigned values, but
currently the only way to format uint values is by explicitly casting them to
an int. This addresses Mantis issue #502.
library/string.m:
Add a new alternative to the poly_type/0 type that wraps uint
values.
Update the documentation for string.format. uint values may
now be formatted using the u, x, X, o or p conversion specifiers.
library/string.format.m:
Add the necessary machinery for handling formatting of uint values.
library/string.parse_runtime.m:
library/string.parse_util.m:
Handle uint poly_types.
library/io.m:a
Handle uint values in the write_many predicates.
library/pprint.m:
Handle uint values in the poly/1 function.
compiler/format_call.m:
compiler/parse_string_format.m:
Conform to the above changes.
compiler/options.m:
Add a way to detect if a compiler supports this change.
NEWS:
Announce the above changes.
tests/hard_coded/stream_format.{m,exp}:
Extend this test to cover uints.
tests/invalid/string_format_bad.m:
tests/invalid/string_format_unknown.m:
Conform to the above changes.
tests/string_format/Mmakefile:
tests/string_format/string_format_uint_o.{m,exp,exp2}:
tests/string_format/string_format_uint_u.{m,exp,exp2}:
tests/string_format/string_format_uint_x.{m,exp,exp2}:
Add tests of string.format with uints.
tests/accumulator/*.m:
tests/analysis_*/*.m:
tests/benchmarks*/*.m:
tests/debugger*/*.{m,exp,inp}:
tests/declarative_debugger*/*.{m,exp,inp}:
tests/dppd*/*.m:
tests/exceptions*/*.m:
tests/general*/*.m:
tests/grade_subdirs*/*.m:
tests/hard_coded*/*.m:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the debugger tests,
specify the new line numbers in .inp files and expect them in .exp files.
Estimated hours taken: 25
Branches: main
Implement io.write for arbitrary streams. With type specialization
this is only slightly slower than the original.
library/stream.string_writer.m:
library/library.m:
A module containing predicates for writing to streams
which accept strings.
library/stream.m:
Move stream.format to stream.string_writer.m.
Add stream.put_list, which is like io.write_list.
library/io.m:
Move io.write and io.print to stream.string_writer.m.
library/term_io.m:
Add stream versions of predicates used by io.write.
library/ops.m:
Move io.adjust_priority_for_assoc to here (private
predicate used only by library modules).
Export ops.mercury_max_priority for use by
stream.string_writer.write.
Mmake.common.in:
compiler/modules.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/prog_util.m:
compiler/format_call.m:
mdbcomp/prim_data.m:
Allow sub-modules in the standard library.
compiler/polymorphism.m:
Fix a bug which caused tests/hard_coded/print_stream.m to
fail with this change. The wrong argument type_info would
be extracted from a typeclass_info if the constraints of the
typeclass-info were not all variables.
browser/browse.m:
tests/hard_coded/stream_format.m:
tests/hard_coded/test_injection.m:
tests/invalid/string_format_bad.m:
tests/invalid/string_format_unknown.m:
Updated for predicates moved between library modules.
util/mdemangle.c:
The demangler doesn't properly handle the arguments MR_DECL_LL*
and various other recently added macros for type specialized
procedures. It's still broken (it doesn't handle mode and label
suffixes properly), but the output is at least more readable.
Estimated hours taken: 2
Branches: main
Add some new utility predicates for use with streams.
library/stream.m:
Add the predicate stream.format/5, an analogue of io.format,
that writes formatted output using an arbitrary string writer.
Add a predicate stream.ignore_whitespace/4 that can be used
to skip past whitespace in a putback char reader stream.
library/Mercury.options:
Don't warn about unknown format calls in the stream module.
Unrelated change: remove a workaround that was put in place
before the addition of the `--no-warn-obsolete' option.
compiler/format_call.m:
Also analyse calls to stream.format/5.
tests/hard_coded/Mmakefile:
tests/hard_coded/stream_format.{m,exp}:
tests/hard_coded/stream_ignore_ws.{m,exp,data}:
Test stream.format/5 and stream.ignore_whitespace/3.
tests/invalid/string_format_bad.{m,exp}:
tests/invalid/string_format_unknown.{m,exp}:
Check that we emit messages for bad/unknown calls to stream.format/5.