The functions byte/2 and 'byte :='/2 both throw a bitmap_error/1 exception if
the given byte index is out of bounds. The error message returned as part of
the exception reports the byte index that is out of bounds but then gives the
valid bounds of *bit* indexes in the bitmap. There are two possible fixes:
1. report the out of bounds index as the bit index of the start of the byte.
2. report the valid bounds of the of byte indexes in the bitmap.
This change implements the latter.
Style and formatting fixes to the bitmap module.
library/bitmap.m:
Make the above fix.
Add separate predicates for reporting out of bounds bit and byte
indexes.
Do not provide erroneous functions that duplicate the functionality of,
or forward their work, to erroneous predicates of the same name.
Add the predicate is_empty/1.
Remove some unnecessary module qualification.
Use state variable notation in more spots.
tests/hard_coded/Mmakefile:
tests/hard_coded/bitmap_bytes.{m,exp}:
Add a new test for byte lookups in bitmaps -- this wasn't covered
by the existing test cases.
tests/hard_coded/bitmap_empty.exp:
tests/hard_coded/btimap_test.exp:
Conform to the above changes.
NEWS:
Announce the addition of bitmap.is_empty/1.
Estimated hours taken: 90
Branches: main
NEWS:
library/bit_buffer.m:
library/bit_buffer.read.m:
library/bit_buffer.write.m:
Add bit_buffers to the standard library. A bit_buffer
provides a bit-oriented interface to byte streams.
These will be used as a base for write_binary and read_binary.
library/stream.m:
Add class which supports reading multiple items at once into
a store.
Clarify the blocking behaviour of `put' and `get'.
Document the behaviour of subsequent calls to `get'
after a call returns eof or an error.
library/bitmap.m:
Add a shorthand for `new(N, no)'.
Add `shrink_without_copying' to destructively shrink a bitmap
without copying the data.
Add a function `append_list' to condense a list of bitmaps.
Improve bounds error messages.
Clean up the handling of zero-length bit ranges.
Add type `bitmap.slice' to represent a segment of a bitmap,
and functions to create slices.
library/io.m:
Change the interface of io.read_bitmap to conform to
the stream.bulk_reader interface, by not returning the
bitmap inside the return code. The bitmap is still
valid (although maybe not completely filled) no matter
what result is returned.
Add io.read_binary_file_as_bitmap/N.
library/library.m:
Add recent additions to the list of library modules.
library/Mercury.options:
Use "+=" rather than "=" when setting target-specific
options to allow them to be added to be Mmake.params.
tests/hard_coded/Mmakefile:
tests/hard_coded/bit_buffer_test.m:
tests/hard_coded/bit_buffer_test.exp:
Test case.
tests/hard_coded/bitmap_test.m:
tests/hard_coded/bitmap_simple.m:
tests/hard_coded/bitmap_test.exp:
Update for change to io.read_bitmap.
Test bounds error messages.
Estimated hours taken: 0.25
Branches: main
tests/hard_coded/bitmap_test.{m,exp}:
Test case for the comparison bug I fixed earlier. The
added tests would fail on 32 bit machines without that fix
(the original problem only occurred on 64 bit machines).
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.