... 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/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.
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.
configure.ac:
Require the installed compiler to support disable_warning scopes
for unknown_format_calls.
compiler/Mercury.options:
library/Mercury.options:
Do not disable unknown_format_call warnings in whole files.
compiler/parse_tree_out_info.m:
compiler/pd_debug.m:
library/io.m:
library/stream.string_writer.m:
library/string.m:
Disable unknown_format_call warnings for just the format calls
that need it.
library/ops.m:
We used to export just the op_table typeclass and its mercury_op_table
instance. This meant that even code that operated only on the Mercury
op table and no other had to go through the typeclass interface, including
the creation of a dummy mercury_op_table objects.
Fix this by exporting the mercury_op_table implementations of the
typeclass's methods in a form that does not require unnecessary arguments.
Give these predicates and functions names derived from the names of the
typeclass methods, just
- with a "mercury_op_table_" prefix, and
- with "lookup" replaced by "search" in the names of predicates
that do searches that can fail.
Factor the search of the op table out of the search predicates,
and export separate predicates that do their work on already-lookup-up
op_infos. This allows callers to avoid repeated work in some use cases.
NEWS:
Announce the new predicates and functions.
library/pretty_printer.m:
Exploit to the changes above, which were done with the use case in this
module in mind.
library/stream.string_writer.m:
Conform to the changes above.
library/io.m:
library/io.stream_db.m:
Move the data types describing the stream database, and the
predicates and functions managing and accessing it, to the new
submodule io.stream_db.m. Move the declarations and definitions
of the global variables holding the dabase accordingly.
library/MODULES_UNDOC:
library/library.m:
List the new module as an undocumented new module.
browser/browse.m:
browser/browser_info.m:
library/stream.string_writer.m:
Get stream information from the new module.
In the Mercury standard library, every exported predicate or function
has (or at least *should* have) a comment that documents it, including
the meanings of its arguments. About 35-40% of these modules put `'s
(left and right quotes) around the names of the variable representing
those arguments. Some tried to do it consistently (though there were spots
with unquoted or half quoted names), while some did it only a few places.
This is inconsistent: we should either do it everywhere, or nowhere.
This diff makes it nowhere, because
- this is what the majority of the standard library modules do;
- this is what virtually all of the modules in the compiler, profiler,
deep_profiler etc directories do;
- typing all those quotes when adding new predicates in modules that
follow this convention is a pain in the ass; and because
- on many modern terminals, `' looks non-symmetrical and weird.
Likewise, the comment explaining a predicate often started with
% `predname(arguments)' returns ...
This diff deletes these quotes as well, since they add nothing useful.
This diff does leave in place quotes around code fragments, both terms
and goals, where this helps delineate the boundaries of that fragment.
library/hash_table.m:
library/stream.string_writer.m:
Fix code where a mode specialization (i.e. the specification of
a particular input function symbol for an argument) was applied
to the wrong argument.
library/pprint.m:
library/stream.string_writer.m:
library/string.parse_runtime.m:
Avoid module qualifying the poly_type/0 type; it is only
defined by the string module now.
library/stream.string_writer.m:
When printing terms to a stream, we special case the handling
of a whole bunch of builtin types. We used to test for these one by one,
in sequence, which can be very slow.
Switch to an approach where we first get the identity of the term's type,
and we test for a type for one of these types *if, and only if*,
the identity says that it is one of the types we want to special-case
in one of the modules that has to-be-special-cased types.
This code is significantly longer than the original, but
(a) it should be significantly faster (it speeds up a microbenchmark
by a bit more than a third), and (b) it should not slow down
if we want to special-case the treatment of more types in the future.
tests/hard_coded/stream_string_writer_types.{m,exp}:
A test to ensure that the assumptions that the new code in
stream.string_writer.m makes about which builtin type is defined where
are still valid.
tests/hard_coded/Mmakefile:
Enable the new test case.
Also, throw software_error/1 exceptions rather than directly throwing strings
in a few spots.
Undo special Ralph-style formatting.
library/*.:
As above.
tests/hard_coded/array2d_from_array.exp:
tests/hard_coded/array2d.exp:
tests/hard_coded/test_injection.exp:
Update to conform with the above change.
The above predicates currently escape all of the C0 control characters (+
Delete). This change modifies them to escape all of the characters in the
Unicode category `Other,control' using backslash escapes when they exist and
octal escapes otherwise.
library/term_io.m:
Do not treat C1 control characters as Mercury source characters.
Re-order the list of Mercury punctuation characters by codepoint
order; it is difficult to check for completion otherwise.
Put a list of special characters escapes in order.
runtime/mercury_ml_expand_body.h:
library/rtti_implementation.m:
Update the implementations of functor/4 to escape all control
characters when returning the functor of a character.
library/deconstruct.m:
Specify that functor/4 should escape all control characters in
the value returned for characters and strings. (XXX TODO: it
currently doesn't implement the new behaviour for strings; I'll
add that separately.)
library/io.m:
library/stream.string_writer.m:
Similar to the above but for io.write etc.
tests/hard_coded/write.{m,exp}:
tests/hard_coded/deconstruct_arg.{m,exp,exp2}:
Extend these tests to cover the block of C1 control characters
and the boundaries around it.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.
COPYING.LIB:
Add a special linking exception to the LGPL.
*:
Update references to COPYING.LIB.
Clean up some minor errors that have accumulated in copyright
messages.
Replace placeholder types with int64 and uint64 as appropriate throughout the
system.
Enable support for 64-bit integer literals in the compiler.
Add initial library support for 64-bit integers.
configure.ac:
Check that the bootstrap compiler recognises int64 and uint64 as
builtins.
library/int64.m:
library/uint64.m:
Populate these two modules to the extent that we can now run
basic tests of 64-bit integer support.
Note that since the bootstrap compiler will not recognise
64-bit integer literals, any such literals are current written
as conversions from ints; this will be replaced once this change
has bootstrapped.
library/private_builtin.m:
Replace the placeholder definitions for builtin unification and
comparison of 64-bit integers with their actual definitions.
library/integer.m:
Add procedures for converting integers to- and from int64 and uint64.
library/string.m:
Add functions for converting 64-bit integers into strings.
library/io.m:
Add predicates for writing 64-bit integers to text streams.
(Support for 64-bit integers with binary streams will be done
separately.)
library/stream.string_writer.m:
Add put_int64/4 and put_uint/64.
Extend the implementations of print and write to cover int64 and
uint64.
library/pprint.m:
Make int64 and uint64 instances of the doc/1 type class.
library/erlang_rtti_implementation.m:
library/rtti_implementation.m:
Handle int64 and uint64 properly in deconstruct.
library/term.m:
Add functions for converting 64-bit integers into terms.
library/term_conversion.m:
Support int64 and uint64 in univ -> term conversion.
library/Mercury.options:
Avoid a warning about the import of the require being
unused in the int64 and uint64 modules. It *is* used,
but only in the definitions used by the Erlang backend.
compiler/superhomogeneous.m:
Accept 64-bit integer literals.
compiler/c_util.m:
In C, write out the value of the min_int64 as the symbolic
constant INT64_MIN. This expands in such a way as to avoid
generating warnings from the C compiler.
compiler/builtin_ops.m:
compiler/bytecode.m:
compiler/elds.m:
compiler/elds_to_erlang.m:
compiler/hlds_data.m:
compiler/hlds_out_util.m:
compiler/llds.m:
compiler/llds_out_data.m:
compiler/lookup_switch.m:
compiler/mercury_to_mercury.m:
compiler/mlds.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/opt_debug.m:
compiler/parse_tree_out_info.m:
compiler/parse_tree_to_term.m:
compiler/prog_data.m:
compiler/prog_out.m:
compiler/prog_rep.m:
Replace the use of int as a placeholder with int64 or uint64 as
appropriate.
tests/hard_coded/Mmakefile:
tests/hard_coded/arith_int64.{m,exp}:
tests/hard_coded/arith_uint64.{m,exp}:
tests/hard_coded/bitwise_int64.{m,exp}:
tests/hard_coded/bitwise_uint64.{m,exp}:
tests/hard_coded/cmp_int64.{m,exp}:
tests/hard_coded/cmp_uint64.{m,exp}:
tests/hard_coded/integer_int64_conv.{m,exp}:
tests/hard_coded/integer_uint64_conv.{m,exp}:
Add tests of basic operations on 64-bit integers.
tests/hard_coded/construct_test.{m,exp}:
Extend this test to cover 64-bit integers.
Enable support for literals of the new types.
Begin implementing library support for 8, 16, and 32 bit types.
Update the compiler to represent values of their own constants.
library/int8.m:
library/int16.m:
library/int32.m:
library/uint8.m:
library/uint16.m:
library/uint32.m:
Begin filling these modules out.
library/uint.m:
Unrelated change: add the predicates plus/2, minus/2 and
times/2 for uints.
library/integer.m:
Add predicates for converting integer/0 values into values
of the new types.
Add functions for converting values of the new types into
integer/0 values.
library/string.m:
Add functions for converting values of the new types to strings.
library/private_builtin.m:
Replace the placeholder definitions for the builtin unify and compare
predicates for the new types with their actual definitions.
library/erlang_rtti_implementation.m:
library/rtti_implementation.m:
Replace placeholder definitions for the new types with their
actual definitions.
library/io.m:
Add predicates for writing values of the new types to file streams.
library/stream.string_writer.m:
Implement generic write and print for values of the new types.
library/string.to_string.m:
Likewise for string/1.
library/term.m:
library/term_conversion.m:
Add predicates and functions for converting the new types to
and from terms.
compiler/builtin_ops.m:
compiler/elds.m:
compiler/hlds_data.m:
compiler/llds.m:
compiler/mlds.m:
compiler/prog_data.m:
Replace placeholders for the new types with the new types.
compiler/superhomogeneous.m:
Enable literals of the new types.
compiler/mlds_to_cs.m:
Avoid a warning from the C# compiler for bitwise-or operators
with sbyte operands.
compiler/c_util.m:
compiler/elds_to_erlang.m:
compiler/hlds_out_util.m:
compiler/llds_out_data.m:
compiler/lookup_switch.m:
compiler/mlds_to_c.m:
compiler/mlds_to_java.m:
compiler/opt_debug.m:
compiler/parse_tree_out_info.m:
compiler/parse_tree_to_term.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_util.m:
Replace placeholder code for the new types with code that uses the new
types.
tests/invalid/invalid_int.m:
tests/invalid/invalid_int.err_exp2:
Extend this test case to cover the fixed size integer types.
library/bimap.m:
library/bitmap.m:
library/calendar.m:
library/char.m:
library/cord.m:
library/deconstruct.m:
library/diet.m:
library/dir.m:
library/eqvclass.m:
library/map.m:
library/pprint.m:
library/pqueue.m:
library/stream.string_writer.m:
library/term_conversion.m:
library/time.m:
library/type_desc.m:
library/version_array.m:
library/version_array2d.m:
library/version_bitmap.m:
library/version_hash_table.m:
Fix inconsistencies between (a) the order in which functions and predicates
are declared, and (b) the order in which they are defined.
In most of these modules, either the order of the declarations
or the order of the definitions made sense, and I changed the other
to match. In a few modules, neither made sense, so I changed *both*
to an order that *does* make sense (i.e. it has related predicates
together).
In some places, put dividers between groups of related
functions/predicates, to make the groups themselves more visible.
In some places, fix comments or programming style, give some auxiliary
(non-exported) predicates better names, or delete some unneeded module
qualifications.
In some places, have the function form of a procedure forward
the work to the predicate form, instead of vice versa, where this is
more natural (usually because it allows the use of state variables).
However, this is the only kind of "algorithmic" change in this diff;
the rest is just moving code around.
Extend the lexer to recognise uint literals, optional signedness suffixes on
ints and the literals for all of the proposed fixed size integer types.
Fix XXX UINTs in the library and compiler.
library/lexer.m:
Uncomment the other alternatives in the integer_size/0 type.
Handle signedness and size suffixes in integer literals.
library/parser.m
library/term.m:
Conform to the above changes.
library/stream.string_writer.m:
Fix an XXX UINT: make write handle uints properly.
library/term_io.m:
Fix an XXX UINT: output integer signedness and size suffixes for
integers when appropriate.
compiler/superhomogeneous.m:
Print an error message if we encounter a fixed size integer literal
as the rest of the compiler does not yet support them.
compiler/hlds_out_util.m:
compiler/parse_tree_out_info.m:
Output the 'u' suffix on uint values.
test/hard_coded/lexer_zero.{m,inp,exp*}:
Extend this test to cover zeros of varying signedness and size.
Prefix each line of the output with the input line number of the
token -- this makes it easier to relate the output back to the
input.
tests/hard_coded/Mmakefile:
Add the new test case.
tests/hard_coded/lexer_ints.{m,inp,exp}:
Test the lexer on non-zero integer literals.
Begin implementing library support for uints.
Update the compiler to use the uint type.
library/uint.m:
Begin filling this module in.
library/private_builtin.m:
Use the proper argument type for builtin_{unify,compare}_uint
and provide actual implementations for them.
library/table_builtin.m:
Add tabling builtins for uints.
library/string.m:
Add a function to convert a uint to a decimal string.
(XXX NYI for Erlang).
library/io.m:
Add write_uint/[45].
Add the stream instance for uints and text output streams.
library/stream.string_writer.m:
Add put_uint/4.
Support uints in string_writer.write etc.
library/pprint.m:
Make uint an instance of the doc/1 type class.
library/pretty_printer.m:
Add a default formatter for uints.
library/int.m:
Unrelated change: fix formatting.
compiler/builtin_ops.m:
compiler/elds.m:
compiler/elds_to_erlang.m:
compiler/hlds_data.m:
compiler/llds.m:
compiler/llds_out_data.m:
compiler/mercury_to_mercury.m:
compiler/ml_lookup_switch.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/opt_debug.m
compiler/parse_tree_out.m:
compiler/parse_tree_out_info.m:
compiler/prog_data.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/hlds_out_util.m:
Use the uint type in places where we should.
compiler/mlds_to_java.m:
Fix a bug that causes us to generate badly typed Java.
For div and mod we need to cast the entire expression to
an int, not just the first operand.
compiler/c_util.m:
compiler/mlds_to_cs.m:
Add predicates for outputting unsigned integers in C and C#.
tests/hard_coded/test_pretty_printer_defaults.exp:
Conform to the above change to the pretty_printer module.
library/backjump.m:
library/exception.m:
library/getopt_io.m:
library/psqueue.m:
library/set_ctree234.m:
library/set_tree234.m:
library/tree234.m:
Avoid using implicit streams.
library/io.m:
Add a version of the write_cc predicate that allows callers
to specify an explicit stream.
Fix what seems like an old bug in read_binary_file_as_bitmap: it was not
reading from the file at all.
Use explicit module qualification in some places to make the code more
readable.
library/table_statistics.m:
Add a version of the write_table_stats predicate that allows callers
to specify an explicit stream.
Avoid using implicit streams inside the module as well.
library/term_io.m:
Add versions of the predicates that read terms that allow callers
to specify an explicit stream.
Avoid using implicit streams inside the module as well.
library/parser.m:
Add module qualifications that are needed after the new addition of new
predicates to term_io.m.
library/stream.m:
library/stream.string_writer.m:
Fix style.
Specifically, we now do three new checks:
BAD_DETISM: We now generate error messages for predicate declarations
that specify a determinism without also specifying argument modes.
BAD_PREDMODE: We now generate error messages for standalone mode declarations
for predicates whose predicate declaration includes modes for the arguments.
BAD_MODE_SECTION: We now generate error messages for standalone mode
declarations that are not in the same section as the predicate's (or
function's) type declaration.
compiler/hlds_pred.m:
Add a slot to the pred_sub_info. If the predicate is explicitly defined by
the user in the current module, this contains the id of the section that
contains its predicate declaration (for the BAD_MODE_SECTION check)
and whether that predicate declaration also had modes for the arguments
(for the BAD_PREDMODE check).
compiler/add_pred.m:
When adding adding new predicate declarations, perform the BAD_DETISM
check, and record the info needed for the BAD_PREDMODE and BAD_MODE_SECTION
checks.
When adding adding new mode declarations, perform the BAD_PREDMODE
and BAD_MODE_SECTION checks.
compiler/add_class.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_solver.m:
compiler/add_special_pred.m:
compiler/check_typeclass.m:
compiler/dep_par_conj.m:
compiler/higher_order.m:
compiler/make_hlds_passes.m:
compiler/table_gen.m:
compiler/unused_args.m:
Conform to the changes above.
mdbcomp/builtin_modules.m:
Add a utility predicate for use by new code in add_pred.m.
compiler/comp_unit_interface.m:
compiler/goal_util.m:
compiler/prog_rename.m:
compiler/quantification.m:
deep_profiler/program_representation_utils.m:
library/calendar.m:
library/mutvar.m:
library/pretty_printer.m:
library/random.m:
library/set_ctree234.m:
library/solutions.m:
library/stream.string_writer.m:
profiler/globals.m:
tests/accumulator/nonrec.m:
tests/accumulator/out_to_in.m:
tests/declarative_debugging/library_forwarding.m:
tests/dppd/applast_impl.m:
tests/dppd/grammar_impl.m:
tests/dppd/regexp.m:
tests/dppd/transpose_impl.m:
tests/hard_coded/copy_pred.m:
tests/hard_coded/ho_func_default_inst.m:
tests/recompilation/unchanged_pred_nr_2.m.1:
tests/recompilation/unchanged_pred_nr_2.m.2:
tests/valid/det_switch.m:
tests/valid/inlining_bug.m:
Delete determinism declarations from predicate and function declarations
that have no argument mode information, since the BAD_DETISM check
now makes these errors.
tests/valid/two_pragma_c_codes.m:
Move some mode declarations to the right section, since the
BAD_MODE_SECTION check now generates an error for the old code.
tests/invalid/typeclass_bad_method_mode.{m,err_exp}:
New test case to test for the BAD_PREDMODE check.
tests/invalid/mode_decl_in_wrong_section.{m,err_exp}:
New test case to test for the BAD_MODE_SECTION check.
tests/invalid/bad_detism.err_exp:
Add an expected output for this old, but never enabled test case,
which tests for new check BAD_DETISM.
tests/invalid/Mmakefile:
Enable the new test cases.
tests/invalid/typeclass_dup_method_mode.m:
This test case used to have two bugs. One is now by itself in the new
typeclass_bad_method_mode.m test case, so modify it to contain only
the other (indistinguishable modes).
tests/invalid/func_errors.err_exp:
tests/invalid/tc_err1.err_exp:
tests/invalid/undef_lambda_mode.err_exp:
tests/invalid/undef_type_mode_qual.err_exp:
Expect an extra error message from the BAD_DETISM check.
Change the io.print family of predicates to print out the formatted version of
dates and durations rather than their underlying representation.
library/io.m:
library/stream.string_writer.m:
As above.
Avoid a change of tense in the middle of the descriptive comment
for {io,stream.string_writer}.print.
tests/hard_coded/Mmakefile:
tests/hard_coded/print_date.{m,exp}:
Add a test for the above.
library/stream.string_writer.m:
Make the print family of predicates print the decimal representation
of integer/0 values instead of their underlying representation.
library/io.m:
Update the documentation of io.print to conform to the above change.
Fix a typo: s/hander/handler/
NEWS:
Announce the above change.
tests/hard_coded/Mmakefile:
tests/hard_coded/print_bigint.{m.exp}:
Test printing of integers with io.print.
Fix some errors in the documentation of {string_writer,io}.{print,write}.
Clean up the formatting of the same documentation.
library/stream.string_writer.m:
Fix a cut-and-paste errors: there is no string_writer.print/3
predicate.
s/pragma foreign_code/pragma foreign_type/ in a spot where
the latter was meant.
Refer to the destination stream as a string writer stream, rather
than an output stream.
library/io.m:
s/pragma foreign_code/pragma foreign_type/ in a spot where
the latter was meant.
Branches: main
Make io.write and the two pretty-printers in the standard library handle
version arrays in a similar way to normal arrays.
library/pprint.m:
library/pretty_printer.m:
library/stream.string_writer.m:
As above.
library/version_array.m:
Add a function for converting a version_array to a pretty_printer.doc
value.
tests/hard_coded/pretty_printing.{m,exp}:
tests/hard_coded/test_pretty_printer_defaults.{m,exp}:
tests/hard_coded/write.{m,exp}:
Include printing version_arrays in these tests.
Branches: main
Work on RTTI implementation for Java.
library/construct.m:
library/type_desc.m:
Properly distinguish between type_infos and type_descs. These are not
the same in Java grades (for now, at least).
Use special purpose conversion functions instead of unsafe_casts.
Don't call erlang_rtti_implementation.m predicates in other grades.
library/rtti_implementation.m:
Properly distinguish between type_infos and type_descs.
Use special purpose conversion functions instead of unsafe_casts.
Implement some stub predicates for Java.
Fix get_arg_type_info which assumed the usual low-level type_info
representation. In Java we have a TypeInfo_Struct class with a
distinct array for type_info arguments so all the indices to access
arguments were wrong.
Try to be consistent about how variables are numbered (start from 1).
Rename some predicates to make them less ambiguous.
Don't use field access to call functions as it is confusing.
Update unsafe_get_enum_value for an earlier change where I renamed the
`value' field in enumeration classes to `MR_value'.
library/stream.string_writer.m:
library/string.m:
Convert type_infos to type_descs properly.
library/erlang_rtti_implementation.m:
Unrelated: use private_builtin.unsafe_type_cast instead of a
foreign_proc.
library/io.m:
Unrelated: add Java implementation of io.stdout_stream_2/1.
java/runtime/TypeInfo_Struct.java:
Add a copy method.
Estimated hours taken: 80
Branches: main
Improvements for bitmap.m, to make it useable as a general container
for binary data.
library/bitmap.m:
runtime/mercury_bitmap.c:
runtime/mercury_bitmap.h:
Specialize the representation of bitmaps to an array of unsigned
bytes defined as a foreign type.
This is better than building on top of array(int) because it:
- is better for interfacing with foreign code
- has a more sensible machine-independent comparison order
(same as array(bool))
- avoids storing the size twice
- has more efficient copying, unification, comparison and tabling
(although we should probably specialize the handling of array(int)
and isomorphic types as well)
- uses GC_MALLOC_ATOMIC to avoid problems with bit patterns that look
like pointers (although we should do that for array(int) as well)
XXX The code for the Java and IL backends is untested.
Building the library in grade Java with Sun JDK 1.6 failed (but
at least passed error checking), and I don't have access to a
copy of MSVS.NET. The foreign code that needs to be tested is
trivial.
Add fields `bit', `bits' and `byte' to get/set a single bit,
multiple bits (from an int) or an 8 bit byte.
Add functions for converting bitmaps to hex strings and back,
for use by stream.string_writer.write and deconstruct.functor/4.
bitmap.intersect was buggy in the case where the input bitmaps
had a different size. Given that bitmaps are implemented with
a fixed domain (lookups out of range throw an exception), it
makes more sense to throw an exception in that case anyway,
so all of the set operations do that now.
The difference operation actually performed xor. Fix it and
add an xor function.
library/version_bitmap.m:
This hasn't been fully updated to be the same as bitmap.m.
The payoff would be much less because foreign code can't
really do anything with version_bitmaps.
Add a `bit' field.
Deprecate the `get/2' function in favour of the `bit' field.
Fix the union, difference, intersection and xor functions
as for bitmap.m.
Fix comparison of version_arrays so that it uses the same
method as array.m: compare size then elements in order.
The old code found version_arrays to be equal if one was
a suffix of the other.
library/char.m:
Add predicates for converting between hex digits and integers.
library/io.m:
library/stream.string_writer.m:
library/term.m:
Read and write bitmaps.
runtime/mercury_type_info.h:
runtime/mercury_deep_copy_body.h:
runtime/mercury_mcpp.h:
runtime/mercury_table_type_body.h:
runtime/mercury_tabling_macros.h:
runtime/mercury_unify_compare_body.h:
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_term_size.c:
runtime/mercury_string.h:
library/construct.m:
library/deconstruct.m
compiler/prog_type.m:
compiler/mlds_to_gcc.m:
compiler/rtti.m:
Add a MR_TypeCtorRep for bitmaps, and handle it in the library
and runtinme.
library/Mercury.options:
Compile bitmap.m with `--no-warn-insts-without-matching-type'.
runtime/mercury_type_info.h:
Bump MR_RTTI_VERSION.
NEWS:
Document the changes.
tests/hard_coded/Mmakefile:
tests/hard_coded/bitmap_test.m:
tests/hard_coded/bitmap_simple.m:
tests/hard_coded/bitmap_tester.m:
tests/hard_coded/bitmap_test.exp:
tests/tabling/Mmakefile:
tests/tabling/expand_bitmap.m:
tests/tabling/expand_bitmap.exp:
tests/hard_coded/version_array_test.m:
tests/hard_coded/version_array_test.exp:
Test cases.
Branches: main
Add initial support for parallel make functionality in `mmc --make', using
Mercury threads (not processes). Currently this is limited to running the
"compile target code to object code" step in parallel.
configure.in:
Require that the bootstrap compiler support the `thread_local'
attribute on mutables.
compiler/globals.m:
Use a thread-local mutable to hold the compiler's globals instead of
the globals facility in the io module.
Make the `extra_error_info' mutable thread-local.
compiler/options.m:
doc/user_guide.texi:
Add a `--jobs <n>' option, with shorthand '-j <n>'.
compiler/make.util.m:
Add a `foldl2_maybe_stop_at_error_maybe_parallel' predicate which is
like `foldl2_maybe_stop_at_error' but capable of running tasks in
parallel depending on the `--jobs' option.
compiler/make.program_target.m:
Use `foldl2_maybe_stop_at_error_maybe_parallel' for the "target code to
object code" step.
library/io.m:
Make the current input/output streams thread-local in C grades. This
uses the same underlying mechanisms as thread-local mutables. Direct
references to the current stream variables are replaced by calls to
functions which work with the thread-local current streams instead.
Add a mutex and locking predicates to protect the stream_db structure.
Mark `get_stream_db' and `set_stream_db' as thread-safe and protect
calls to those predicates with the locking predicates.
Rename the impure version of `get_stream_db' to
`get_stream_db_with_locking' and make it acquire and release the
stream_db mutex.
Add a mutex to protect the `ML_next_stream_id' counter.
Add a note about a thread-safety problem in `io.get_system_error'.
Mark `io.call_system_code' as `thread_safe'.
library/list.m:
Add the predicate `list.split_upto', which is to `list.split_list' as
`list.take_upto' is to `list.take'.
library/stream.string_writer.m:
Conform to the renaming of the impure `io.get_stream_db'.
library/thread.m:
Add a predicate `can_spawn', which succeeds if `spawn' is supported in
the current grade.
NEWS:
Announce parallel make support.
Announce `list.split_upto' and 'thread.can_spawn'.
Estimated hours taken: 0.1
Branches: main
library/stream.m:
library/stream.string_writer.m:
Fix some minor departures from our coding standard.
Delete some duplicate imports.
Estimated hours taken: 0.5
Branches: main
Fix failure of tests/debugger/declarative/io_stream_test.
library/stream.string_writer.m:
library/io.m:
Move code to check whether an arbitrary type is an io.stream back
into io.m. Handle unwrapped streams.
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.