Commit Graph

240 Commits

Author SHA1 Message Date
Peter Wang
0d3fcbaae3 Delete Erlang code from library/mdbcomp/browser directories.
library/*.m:
    Delete Erlang foreign code and foreign types.

    Delete documentation specific to Erlang targets.

library/deconstruct.m:
    Add pragma no_determinism_warning to allow functor_number_cc/3
    to compile for now.

library/Mercury.options:
    Delete workaround only needed when targetting Erlang.

browser/listing.m:
mdbcomp/rtti_access.m:
    Delete Erlang foreign code and foreign types.
2020-10-28 14:10:56 +11:00
Zoltan Somogyi
58ea6ffff2 Delete old obsolete predicates and functions.
library/*.m:
    Specifically, delete any predicates and functions whose `pragma obsolete'
    dates from 2018 or before. Keep the ones that were obsoleted
    only this year or last year.

NEWS:
    Announce the changes.

tests/debugger/io_tab_goto.m:
tests/debugger/tabled_read.m:
tests/declarative_debugger/io_stream_test.m:
tests/declarative_debugger/tabled_read_decl.m:
tests/declarative_debugger/tabled_read_decl_goto.m:
tests/general/array_test.m:
tests/hard_coded/mutable_init_impure.m:
tests/hard_coded/remove_file.m:
tests/tabling/mercury_java_parser_dead_proc_elim_bug.m:
tests/tabling/mercury_java_parser_dead_proc_elim_bug2.m:
tests/valid/mercury_java_parser_follow_code_bug.m:
    Replace references to predicates and functions that this diff deletes
    with their suggested replacements.

    In several test cases, bring the programming style up to date.

tests/hard_coded/shift_test.{m,exp}:
    Most of this test case tested the now-deleted legacy shift operations.
    Replace these with tests of their non-legacy versions, including
    testing for the expected exceptions.

tests/hard_coded/shift_test.{m,exp}:
    Don't pass --no-warn-obsolete when compiling shift_test.m anymore.
2020-08-18 11:57:47 +10:00
Zoltan Somogyi
a6228a9e1a Fix too-long lines. 2020-04-10 03:22:40 +10:00
Julien Fischer
86a767095f Fix a bug in the C# implementation of array.shrink/3.
library/array.m:
   Workaround the fact that C#'s 'is' operator has some fairly surprising
   behaviour with arrays of integer types.

tests/hard_coded/array_primitives.{m,exp}:
tests/hard_coded/array_shrinks.{m,exp}:
   Improve the coverage of these tests.
2019-09-05 17:06:24 +10:00
Julien Fischer
65f683e6f2 Fix arrays with fixed size integer elements for C#.
library/array.m
    Handle all integer types in the methods for creating and resizing arrays in
    the C# grades.
2019-08-29 22:08:26 +10:00
Zoltan Somogyi
a3786d4402 Expand two comments. 2019-08-16 13:07:46 +10:00
Julien Fischer
e876db7873 Adjust bounds checking behaviour of array.fetch_items/4.
Change array.fetch_items/4 to return an empty list for an empty range in the
case where the endpoints of that range are not within the array bounds.

library/array.m:
   As above.

deep_profiler/autopar_types.m:
   Undo Zoltan's recent workaround for the above behaviour.

tests/hard_coded/array_fetch_items.{m,ex}:
   Add tests for this behaviour.
2019-08-16 12:40:36 +10:00
Zoltan Somogyi
95f8f56716 Delete unneeded $module args from calls to expect/unexpected. 2019-07-03 22:37:19 +02:00
Julien Fischer
3a7254bca2 Improve the documentation for array.fetch_items.
Change the behaviour of the above predicate in the following ways:
- throw an index_out_of_bounds/0 exception instead of a software_error/0
  exception if either index is out of bounds.
- perform the out of bounds check before checking if the third argument is
  less than the second.

Add an more comprehensive test of fetch_items/4.

library/array.m:
    Make it clear that the range of indexes passed to fetch_items is
    inclusive.

    Throw an index_out_of_bounds/0 exception instead of a software_error/1
    exception if either of the indexes is out of bounds.

    Perform the array bounds check first, before checking if the third
    argument is less than the second.

    Document what happens if the upper index is less than the lower one.

    Fix a typo in the documentation of fill_range/4.

    Update the definition of to_list/2 to conform with the above change
    to the array bounds checks.

NEWS:
    Announce the above change to the semantics of fetch_items/0.

tests/hard_coded/Mmakefile:
tests/hard_coded/array_fetch_items.{m,exp}:
    Add a more comprehensive
2018-12-24 06:15:23 +00:00
Julien Fischer
8d89c9ff37 Add array.swap/4 and array.unsafe_swap/4.
Report out-of-bounds errors more precisely for array.fill_range/5.

library/array.m:
    As above.

NEWS:
    Announce the addition.

tests/hard_coded/Mmakefile:
tests/hard_coded/array_swap.{m,exp}:
    Add a test for array.swap/4.

tests/hard_coded/array_fill.exp:
    Conform to the second change above.
2018-11-12 06:40:46 +00:00
Julien Fischer
b049a5c3db Fix a problem with array.resize.
array.resize/4 has inconsistent behaviour across backends if its first argument
is negative; make it throw an exception if the first argument is negative.

library/array.m:
    As above.

NEWS:
    Announce the change.

tests/hard_coded/Mmakefile:
tests/hard_coded/array_resize.{m,exp}:
    Add a more extensive test case for array.resize.
2018-11-12 03:52:32 +00:00
Julien Fischer
71a78fa98c Fix problems with array.shrink/3.
The behaviour of array.shrink/3 was not defined if its first argument was
negative.  If this occurred, the C backends would return an empty array, while
the non-C backends would abort.  This diff changes the behaviour of shrink/3 so
that it throws an exception if its first argument is negative.

The implementation of shrink/3 for the Java backend did not handle the case
where the array's element type was represented by the one the following Java
primitive types: byte, short, long and float.  Handle those cases.

library/array.m:
   Make the above fixes.

   Fix a typo in my previous commit.

NEWS:
   Note the change in behaviour if the first argument of shrink/3 is
   negative.

tests/hard_coded/Mmakefile:
tests/hard_coded/array_shrink.{m,exp}:
   Add a test case.
2018-11-11 04:24:55 +00:00
Julien Fischer
4eda536190 Document exception conditions for array.init/3 and array.generate/2.
library/array.m:
    Document that the above will throw an exception if their first
    argument is < 0.
2018-11-09 12:21:51 +11:00
Julien Fischer
2b47521daa Fix an abort in the Java implementation of array.copy/2.
library/array.m:
     Handle all Java primitive types in the implementation of
     array.copy/2.

tests/hard_coded/Mmakefile:
tests/hard_coded/array_copy.{m,exp}:
     Add a test case.
2018-11-09 11:55:45 +11:00
Julien Fischer
ee5f7f621d Add array.fill/3, array.fill_range/5 and array2d.fill/3.
library/array.m:
library/array2d.m:
    Add the new predicates.

    Add a note a likely problem with another predicate.

NEWS:
    Announce them.

tests/hard_coded/Mmakfile:
tests/hard_coded/array_fill.{m,exp}:
    Add a test case.
2018-11-08 10:15:03 +00:00
Zoltan Somogyi
c7f8ebbe2f Avoid warnings from --warn-non-contiguous-{clauses,foreign-procs}.
browser/collect_lib.m:
browser/declarative_execution.m:
browser/dl.m:
browser/io_action.m:
compiler/make.util.m:
compiler/pickle.m:
compiler/process_util.m:
compiler/prog_event.m:
library/array.m:
library/benchmarking.m:
library/bit_buffer.m:
library/builtin.m:
library/char.m:
library/deconstruct.m:
library/dir.m:
library/erlang_rtti_implementation.m:
library/int.m:
library/int16.m:
library/int32.m:
library/int64.m:
library/int8.m:
library/io.m:
library/math.m:
library/mutvar.m:
library/private_builtin.m:
library/profiling_builtin.m:
library/rtti_implementation.m:
library/store.m:
library/string.format.m:
library/string.m:
library/table_builtin.m:
library/term_size_prof_builtin.m:
library/thread.m:
library/time.m:
library/type_desc.m:
library/uint16.m:
library/uint32.m:
library/uint64.m:
library/uint8.m:
ssdb/ssdb.m:
    As above. This mostly involved two things.

    The first was grouping foreign_procs by predicate instead of by language.
    In a few cases, this revealed that some predicates *had* no foreign_proc
    for a language, while related predicates did have one that just aborted
    if called. This diff adds similar aborting foreign_procs to predicate/
    language combinations that were missing them, when this seemed obviously
    the right thing to do.

    The second was moving pragmas about a predicate from the middle of the
    block of clauses of that predicate to the start of that block.
2018-10-19 11:01:33 +11:00
Julien Fischer
d51e2a5bbb Fix the modes of array.map.
library/array.m:
    The current modes for array.map do not match what the implementation
    actually does: specifically, map does not destructively update its
    input array argument.

    Call unsafe_init/3 in a few spots where it is safe to do so.

tests/hard_coded/ho_array_ops.{m,exp}:
    Extend this test to cover array.map.
2018-08-16 16:17:13 +10:00
Julien Fischer
c32c99b269 Minor improvement to equality and comparison for arrays.
library/array.m:
    Use unsafe lookups in the implementation of equality and
    comparison.  In these cases the lookups are safe since
    the necessary bounds checks are done by the caller.

    Avoid unnecessary module qualification.

tests/hard_coded/Mmakefile:
tests/hard_coded/array_unify_compare.{m,exp}:
    Add a systematic test for array equality and comparison.
2018-08-15 09:46:49 +10:00
Julien Fischer
a3efc705a9 Change semantics of array.map_corresponding_foldl/6.
library/array.m:
    Make array.map_corresponding_foldl/6 throw an exception if the input
    arrays differ in size.   This brings its behaviour into line with that of
    the other "corresponding" predicates.  It also avoids the unsafe behaviour
    that can currently result when the second input array has fewer elements
    than the first.

    Add some additional modes to array.map_corresponding_foldl/6.

    Replace calls to error/1 with calls to unexpected/2 throughout this
    module.

NEWS:
    Announce the above change.

tests/hard_coded/ho_array_ops.{m,exp}:
    Extend this test to cover map_corresponding_foldl/6.
2018-08-14 11:08:49 +10:00
Julien Fischer
0dc0834973 Add foldl_corresponding/5 and foldl2_corresponding/7 for arrays.
library/array.m:
    Add the above predicates.

NEWS:
    Announce the additions.

tests/hard_coded/Mmakefile:
tests/hard_coded/ho_array_ops.{m,exp}:
    Add tests of the new predicates.
2018-08-14 11:08:49 +10:00
Zoltan Somogyi
a12692a0de Replace /* */ comments with // in the library.
Keep the old style comments where they do not go to the end of the line,
or where it is important that the comment line not have a // on it.
2018-06-21 18:55:08 +02:00
Julien Fischer
f54fe5f846 Update references to the IL backend.
browser/Mmakefile:
compiler/options.m:
library/array.m:
    As above.
2018-06-15 07:48:56 -04:00
Mark Brown
d465fa53cb Update the COPYING.LIB file and references to 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.
2018-06-09 17:43:12 +10:00
Peter Wang
41e2470633 Deprecate array least_index/greatest_index functions and add replacements.
library/array.m:
    Add det_least_index, semidet_least_index, det_greatest_index,
    semidet_greatest_index functions.

    Deprecate least_index, greatest_index with the intention of making
    them semidet eventually.

NEWS:
    Announce changes.
2018-04-08 13:57:52 +10:00
Peter Wang
6df99209b9 Improve documentation for array bounds predicates.
library/array.m:
library/bt_array.m:
    Do not assume that the lower bound is zero in the documentation for
    array.max.

    Make explicit the argument order of bounds/3 predicates
    and document behaviour on empty arrays.
2017-12-03 09:57:28 +11:00
Peter Wang
d7d1471881 Clarify behaviour of upper bounds functions for array types.
library/array.m:
library/bt_array.m:
library/version_array.m:
    As above.
2017-12-01 17:36:20 +11:00
Peter Wang
148891de0d Delete unused foreign exported procedures.
library/array.m:
library/bool.m:
library/exception.m:
library/type_desc.m:
    As above.
2016-10-06 11:45:30 +11:00
Julien Fischer
a369cef8af Allow foreign types to be Java primitive types.
Currently we only allow non-primitive Java types to used with foreign_type
pragmas.  This means that for foreign types that map on to Java primitive types
we have to use their boxed form (e.g. java.lang.Long, java.lang.Float etc) in
the foreign_type pragma.  Doing so results in unnecessary boxing and is a
source of errors (e.g. accidently comparing for reference equality instead of
value equality).

This change causes the MLDS->Java code generator to recognise primitive
foreign_types and generate code that works for them directly.   (In effect
their handling is not really different to how the builtin types are handled.)

doc/reference.texi:
     Change the language so Java foreign types are allowed to be a
     primitive Java types.

compiler/mlds_to_java.m:
     Recognise foreign types that are defined as primitive types in Java and
     generate code that avoids the need for (some) boxing of them.

library/array.m:
     Handle arrays of Java bytes, shorts, longs and floats specially.
     (boolean, char, int and double were already handled thus.)

NEWS:
     Announce the above.

tests/hard_coded/Mmakefile:
tests/hard_coded/test_java_foreign_primitive.{m,exp}:
     Test that foreign types work with primitive types in Java.
2016-04-13 16:37:29 +10:00
Julien Fischer
5054ccbe31 Fix spelling.
deep_profiler/dump.m:
deep_profiler/recursion_patterns.m:
library/array.m:
library/type_desc.m:
    As above.
2016-01-23 14:03:37 +11:00
Julien Fischer
3dd02876a5 Delete the MLDS->IL backend.
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_managed.m:
compiler/il_peephole.m:
compiler/ilasm.m:
compiler/ilds.m:
    Delete the modules making up the MLDS->IL code generator.

compiler/globals.m:
compiler/prog_data.m:
    Delete IL as a target and foreign language.

compiler/prog_io_pragma.m:
    Delete the max_stack_size/1 foreign proc attribute.  This was only
    ever required by the IL backend.

compiler/options.m
    Delete options used for the IL backend.

compiler/write_deps_file.m:
    Don't generate mmake targets for .il files etc.

compiler/*.m:
    Conform to the above changes.

compiler/notes/compiler_design.html
compiler/notes/work_in_progress.html
    Conform to the above changes.

library/*.m:
    Delete IL foreign_proc and foreign_export pragmas.

README.DotNet:
    Delete this file.

browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
mdbcomp/Mmakefile:
mfilterjavac/Mmakefile:
profiler/Mmakefile:
runtime/Mmakefile:
slice/Mmakefile:
    Conform the above changes.

configure.ac:
    Don't check that IL is a supported foreign language when performing the
    up-to-date check.

    Delete the '--enable-dotnet-grades' option.

scripts/Mmake.vars.in:
    Delete variables used for the IL backend (and in on case by the Aditi
    backend).

scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
scripts/Mmake.rules:
scripts/canonical_grade.sh-subr:
tools/bootcheck:
    Delete stuff related to the 'il' and 'ilc' grades.

doc/reference_manual.texi:
     Delete the documentation of the 'max_stack_size' option.

doc/user_guide.texi:
     Delete stuff related to the IL backend.

tests/hard_coded/csharp_test.{m,exp}:
tests/invalid/foreign_type_missing.{m,err_exp}:
tests/valid/csharp_hello.m:
	Delete these tests: they are no longer relevant.

tests/hard_coded/equality_pred_which_requires_boxing.m:
tests/hard_coded/foreign_import_module.m:
tests/hard_coded/foreign_import_module_2.m:
tests/hard_coded/foreign_type.m:
tests/hard_coded/foreign_type2.m:
tests/hard_coded/foreign_type3.m:
tests/hard_coded/intermod_foreign_type2.m:
tests/hard_coded/lp.m:
tests/hard_coded/user_compare.m:
tests/invalid/foreign_type_2.m:
tests/invalid/foreign_type_missing.{m,err_exp}:
tests/invalid/foreign_type_visibility.m:
tests/invalid/illtyped_compare.{m,err_exp}:
tests/submodules/external_unification_pred.m
tests/valid/big_foreign_type.m
tests/valid/solver_type_bug.m
tests/valid_seq/foreign_type_spec.m
tests/valid_seq/intermod_impure2.m
    Delete IL foreign_procs where necessary.

tests/hard_coded/Mmakefile
tests/invalid/Mercury.options
tests/invalid/Mmakefile
tests/submodules/Mmakefile
tests/valid/Mercury.options
tests/valid/Mmake.valid.common
tests/valid/Mmakefile
tests/valid_seq/Mmakefile
tests/valid_seq/Mercury.options
    Conform to the above changes.
2015-09-21 11:34:46 +10:00
Zoltan Somogyi
0e368eba13 Convert (C->T;E) to (if C then T else E).
Also remove unnecessary module qualification from clause heads and recursive
calls, and replace some use of ^ elem(I) notation with explicit calls to
lookup and set predicates.
2015-08-31 15:32:47 +10:00
Julien Fischer
74e3d35ae9 Fixes for library documentation.
library/pretty_printer.m:
library/getopt_io.m:
library/getopt.m:
	Fix typos.

library/array.m:
library/list.m:
library/queue.m:
library/version_array.m:
	s/Nth/N'th/ etc.
2015-01-14 13:49:44 +11:00
Zoltan Somogyi
8410473315 Prevent overflow when computing Mid in binary searches.
library/array.m:
library/bt_array.m:
    As above.
2014-12-21 21:12:37 +11:00
Zoltan Somogyi
793aecc405 Fix an issue with potential code reordering. 2014-12-06 19:43:25 +11:00
Zoltan Somogyi
4658b3f019 Remove some unnecessary XXXs. 2014-12-05 22:37:23 +11:00
Zoltan Somogyi
6cf10d14a0 Mark array.bsearch as obsolete. 2014-12-04 16:35:21 +11:00
Zoltan Somogyi
35fe4814ce Fix Mantis bug #367.
library/array.m:
    When doing a binary search using a user-supplied comparison function,
    do not use the builtin term comparison operation to compare elements.

    Use separate loops for binary_search and approx_binary_search, since
    using the loop for approx_binary_search in the implementation of
    binary_search executes some unnecessary extra tests.

    Improve the documentation of both binary_search and approx_binary_search.

tests/general/array_binsearch.{m,exp}:
    Rewrite this test case to make it much tougher, testing the operation
    of binary_search and approx_binary_search with both the builtin and
    user-supplied comparison operations, and in the presence of repeated
    elements, and with automatic verification of the results.
2014-12-03 18:20:36 +11:00
Zoltan Somogyi
7f9791aa26 Standardize divider line lengths in the library.
library/*.m:
    As above.

tool/stdlines:
    A new shell script to do the job.
2014-11-23 22:05:34 +11:00
Zoltan Somogyi
15abab79de Wrap some too-long lines in the library. 2014-11-03 21:03:26 +11:00
Peter Wang
856692110f Merge branch 'version-14_01-branch' 2014-10-15 14:50:00 +11:00
Peter Wang
22d31d95b1 Fix array.sort.
array.sort was broken since 2001 when the implementation was changed
from merge sort to SAM sort.

library/array.m:
	Fix the confusion as to which output argument of samsort_up is
	sorted.

	Add optional runtime checks of the pre- and post-conditions
	of samsort_up and samsort_down when built with a trace flag.

	Add array.sort_fix_2014.

tests/hard_coded/Mmakefile:
tests/hard_coded/array_sort.exp:
tests/hard_coded/array_sort.m:
	Add test program.

NEWS:
	Announce the fix.
2014-10-10 16:11:12 +11:00
Julien Fischer
bed96b93ff Avoid module qualification in library interfaces where possible.
NOTE: this change does not affect the io module -- I've left that for a
separate change.

library/*.m:
	As per the recent change to the coding standard, avoid module
	qualification in library interfaces where possible.

	Reformat declarations and descriptive comments to better utilise
	any space freed up by the above.
2014-10-10 15:08:24 +11:00
Zoltan Somogyi
e70fbb2e9d Fix some comments in array.m. 2014-09-08 12:13:56 +10:00
Zoltan Somogyi
a2afa0fdbc Fix some comments in array.m. 2014-09-06 19:22:07 +02:00
Julien Fischer
6ffec8a4af Add all_{true,false}/2 and is_empty/1 to array and version_array.
library/array.m:
library/version_array.m:
	Add the above predicates.

NEWS:
	Announce the new predicates.

tests/hard_coded/Mmakefile:
tests/hard_coded/array_all_tf.{m,exp}:
	Test the new predicates.

tests/hard_coded/version_array_test.{m,exp}:
	Extend this test case to cover the new predicates.
2013-07-22 15:45:23 +10:00
Julien Fischer
92ddfdcf11 Delete obsolete procedures and modules from the standard library.
library/array.m:
library/array2d.m:
library/bitmap.m:
library/store.m:
library/thread.semaphore.m:
library/version_array2d.m:
library/version_bitmap.m:
library/version_hash_table.m:
library/version_store.m:
	Delete predicates that were deprecated in Mercury 13.05 and before.

library/version_array.m
	Delete the deprecated function new/2.

	Deprecate unsafe_new/2	and unsafe_init/2 to replace it.
	(We had overlooked this previously.)

library/string.m:
	Delete the deprecated function set_char_char/3.
	(We will leave the other deprecated procedures in this module
	for at least another release.)

library/svlist.m:
library/svpqueue.m:
library/svstack.m:
	Delete these modules: they were only ever needed as a transitional
	mechanism.

library/library.m:
	Conform to the above changes.

doc/Mmakefile:
	Unrelated change: delete references to files that have been
	deleted since we moved to git.

tests/hard_coded/*/*.m
tests/tabling/*.m:
	Update test cases where they made use of predicates that have
	now been deleted from the standard library.
2013-05-16 17:50:15 +10:00
Zoltan Somogyi
25df09dd06 Fix white space.
Estimated hours taken: 0.1
Branches: main

library/array.m:
	Fix white space.
2012-03-29 03:50:11 +00:00
Julien Fischer
694559c2e2 Changes to array module.
Branches: main, 11.07 (documentation fix for array.bsearch/4 only)

Changes to array module.

library/array.m:
	Omit the header comment regarding the use of
	ML_OMIT_ARRAY_BOUNDS_CHECKS.  Beside being specific to the
	C backends, requiring users to recompile the library (or
	parts thereof) is just awkward.  In any case, the array
	module now exports "unsafe" versions of the relevant
	operations that omit the bounds checking, so the old
	approach should be unnecessary.

	Mark array.svset/4 and array.unsafe_svset/4 as obsolete.
	They will be deleted after the next release.

	Fix the documentation of array.bsearch/4.  It does _not_
	fail if the element being searched for is not present.

mdbcomp/mdbcomp.goal_path.m:
	Conform to the above change.

compiler/llds_out_data.m:
	Fix some formatting.
2012-01-12 04:57:12 +00:00
Julien Fischer
ba4803fcf9 Add an unsafe version of field update for arrays,
Branches: 11.07, main

library/array.m:
	Add an unsafe version of field update for arrays,
	'unsafe_elem :='/3.

	Support foldl and foldr over arrays with 3-5 accumulators.

	Privately export the predicate dynamic_cast_to_array/2 from
	this module.  Previously, there were several definitions of
	this scattered throughout the library.

	Use unsafe operations (which are more efficient) in several places
	where it is safe to do so.

	Use state variable notation in more places.

library/int.m:
	Add an additional mode to each of int.fold_up2/7 and int.fold_down2/7
	with the modes (array_di, array_uo).

library/hash_table.m:
library/pprint.m:
library/version_hash_table.m:
	Delete duplicate definitions of dynamic_cast_to_array/2 and use
	the definition exported from the array module instead.

NEWS:
	Announce the above.
2011-08-13 16:19:58 +00:00
Julien Fischer
135767ac74 Fix some documentation bugs (#205 and #206 in Mantis).
Branches: main, 11.07

Fix some documentation bugs (#205 and #206 in Mantis).

doc/user_guide.texi:
	Fix an incorrect option for mtc.

library/array.m:
	Replace the description of foldr2 which refers to
	a predicate that doesn't exist.
2011-07-23 08:02:51 +00:00