Commit Graph

271 Commits

Author SHA1 Message Date
Mark Brown
81ce3a3459 Tweak a comment.
library/list.m:
	Make the same change as was suggested elsewhere, where the
	comment was being quoted.
2023-03-25 01:06:56 +11:00
Zoltan Somogyi
5cbcfaa0ed Move X_to_doc functions to pretty_printer.m.
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.
2022-12-27 18:27:52 +11:00
Zoltan Somogyi
e9e5f5f799 Add inst_preserving_condense to list.m.
library/list.m:
    As above,

NEWS:
    Announce the addition.

    Fix some typos.
2022-12-10 11:20:53 +11:00
Peter Wang
ec74774218 Fix typo. 2022-08-22 15:07:30 +10:00
Zoltan Somogyi
3e2cde2c33 Don't abort compilation for unresolved overloading.
compiler/pred_table.m:
    When we find more than one match for a predicate or function signature,
    we used to generate an error message, print it, and then abort
    compilation. Fix this by returning the error message to be handled
    by our callers.

    The compiler now has to pick one of the matches to continue with.
    The compiler's pick (the first match) may not be the match intended
    by the programmer, and it is possible that the compiler will later generate
    some error messages that would not happen if we picked the match
    intended by the programmer. We therefore warn the programmer about
    this possibility.

compiler/purity.m:
compiler/resolve_unify_functor.m:
    Include the error messages now returned by pred_table.m among
    all the other error messages generated by the purity pass,
    which, amongst other things, does the last part of the job
    of the typechecker.

compiler/intermod.m:
    Ignore the errors caused by unresolved overloading when generating
    .opt files. They will be reported when the compiler tries to generate
    target language code.

library/list.m:
    Add three related utility predicates that we discussed earlier,
    each of which was needed by one version or another of the code
    for constructing the error message in pred_table.m.

NEWS:
    Announce the additions to list.m.

tests/invalid_submodules/unresolved_overloading.{m,err_exp}:
    Expect the updated error message, and the *absence* of a compiler abort.
2022-08-21 15:28:55 +10:00
Zoltan Somogyi
9473b939d7 Add more functionality to ra_list.m.
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.
2022-06-12 19:42:47 +10:00
Zoltan Somogyi
ef98e382da Carve mercury_compile_make_hlds.m out of mercury_compile_main.m.
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
    As above.

    Note some comment rot.

compiler/top_level.m:
compiler/Mercury.options:
    Add the new module.

compiler/notes/compiler_design.html:
    Document the new module.

library/list.m:
    Add a new variant of an existing utility predicate that can simplify
    some of the moved code, together with some variants (for symmetry
    with the existing code).

NEWS:
    Announce the additions to the library.
2022-04-21 19:28:10 +10:00
Zoltan Somogyi
313f1e6a35 Delete some duplicate code.
compiler/add_class.m:
    Delete a local function, and use a standard library function instead.
    Improve some variable names.

library/list.m:
    Improve some predicate and variable names related to that function.
2022-04-01 03:24:18 +11:00
Zoltan Somogyi
1db00c99aa Add gap_foldl, last_gap_foldl, chunk_foldl{,2,3,4}.
library/list.m:
    Add the above predicates to the list module.

NEWS:
    Announce the new predicates.

tests/hard_coded/fold_tests.{m,exp}:
    Test case for the new functionality.

tests/hard_coded/Mmakefile:
    Enable the new test case.
2022-03-15 12:18:07 +11:00
Zoltan Somogyi
8ff61f8a4b Delete quotes from `VarNames' in stdlib comments.
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.
2022-03-07 11:49:00 +11:00
Julien Fischer
25b8172afc Fix some typos.
library/list.m:
library/map.m:
    As above.
2022-02-09 22:10:23 +11:00
Julien Fischer
093018109c Update references to LIMITATIONS file.
BUGS:
README.md:
bindist/Mmakefile:
compiler/notes/release_checklist.html:
compiler/prog_data.m:
doc/reference_manual.texi:
library/list.m:
runtime/mercury_type_desc.h:
    As above.
2022-01-01 15:53:34 +11:00
Zoltan Somogyi
2bf6260d0e Address review comments. 2021-12-23 19:13:22 +11:00
Zoltan Somogyi
3a18a46de5 Clarify comments. 2021-12-23 18:29:38 +11:00
Zoltan Somogyi
e5eb3c394b Document same_length's performance. 2021-10-30 21:04:54 +11:00
Zoltan Somogyi
814a357449 Improve diagnostics for subtype errors.
compiler/add_type.m:
    Provide more information in error messages for subtype errors.

library/list.m:
    Add a utility predicate needed by the new code in add_type.m.

NEWS:
    Announce the new predicate in list.m.

tests/invalid/subtype_invalid_supertype.{m,err_exp}:
    Add some errors to this test case to exercise new error messages.

tests/invalid/subtype_abstract.err_exp:
tests/invalid/subtype_circular.err_exp:
tests/invalid/subtype_ctor_arg.err_exp:
tests/invalid/subtype_eqv.err_exp:
tests/invalid/subtype_exist_constraints.err_exp:
tests/invalid/subtype_exist_vars.err_exp:
tests/invalid/subtype_ho.err_exp:
tests/invalid/subtype_user_compare.err_exp:
tests/invalid_submodules/subtype_submodule.err_exp:
    Update the expected outputs for the subtype errors in these test cases.
2021-06-30 19:19:32 +10:00
Zoltan Somogyi
2526e17001 Fix indentation. 2021-06-19 18:54:58 +10:00
Zoltan Somogyi
01d11b8d9b Carve two more modules out of polymorphism.m.
compiler/polymorphism_post_copy.m:
compiler/polymorphism_type_class_info.m:
    Those two new modules. The first contains the code of the part of the
    polymorphism transformation that is done as a separate pass, after
    copying code to procedures. The second builds and manipulates
    type_class_infos.

compiler/check_hlds.m:
    Include the new modules in the check_hlds package.

compiler/notes/compiler_design.html:
    Document the new modules.

compiler/builtin_lib_types.m:
    Move four utility predicates here from polymorphism.m, since
    (a) they are now needed by more than one polymorphism*.m module, and
    (b) they belong here. To match the functions already here, turn
    two of them into functions, and delete an unused argument from one.

compiler/make_goal.m:
    Move two utility predicates here from polymorphism.m, since
    (a) they are now needed by more than one polymorphism*.m module, and
    (b) they belong here. Give them names that follow the naming schemes
    of the predicates already here.

library/list.m:
    Move delete_nth here from polymorphism.m, to join the existing
    replace_nth.

NEWS:
    Announce delete_nth.

compiler/polymorphism.m:
    Delete the code moved elsewhere.

compiler/float_regs.m:
compiler/higher_order.m:
compiler/mercury_compile_front_end.m:
compiler/ml_type_gen.m:
compiler/saved_vars.m:
    Conform to the changes above.
2021-06-19 17:24:52 +10:00
Zoltan Somogyi
0d7c8a7654 Specify pred or func for all pragmas.
*/*.m:
    As above.

configure.ac:
    Require the installed compiler to support this capability.
2021-06-16 15:23:58 +10:00
Zoltan Somogyi
d5e6ddc256 Clarify a comment. 2021-06-07 16:44:47 +10:00
Zoltan Somogyi
9603d2f1f0 Add foldl7 and foldl8 to list.m.
library/list.m:
    As above.

NEWS:
    Announce the additions.

compiler/rbmm.live_region_analysis.m:
    Delete the local version of foldl8.
2021-05-23 22:04:33 +10:00
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
5457e1c772 Improve merge_var_insts.
Put its arguments into a standard order, avoid some repeated nil/cons tests,
and add a sanity check.
2020-07-01 18:27:40 +10:00
Zoltan Somogyi
36c2000516 Add the one_or_more and one_or_more_map modules to the library.
library/one_or_more.m:
    We used to have a type named one_or_more in the list module representing
    nonempty lists. It had literally just two predicates and two functions
    defined on it, three of which did conversions to and from lists, which
    limited their usefulness.

    This new module is the new home of the one_or_more type, together with
    a vastly expanded set of utility predicates and functions. Specifically,
    it implements every operation in list.m which makes sense for nonempty
    lists.

library/list.m:
    Delete the code moved over to one_or_more.m.

library/one_or_more_map.m:
    This new module is a near copy of multi_map.m, with the difference being
    that while the multi_map type defined in multi_map.m maps each key
    to a list(V) of values (a list that happens to always be nonempty),
    the one_or_more_map type defined in one_or_more_map.m maps each key
    to a one_or_more(V) of values (which enforces the presence of at least
    one value for each key in the type).

library/map.m:
    Mention the existence of one_or_more_map.m as well as multi_map.m.

library/MODULES_DOC:
library/library.m:
    List the new modules as belonging to the standard library.

NEWS:
    Mention the new modules, and the non-backwards-compatible changes to
    list.m.

compiler/*.m:
    Import the one_or_more module when needed.

tests/hard_coded/test_one_or_more_chunk.{m,exp}:
    Test the one predicate in one_or_more.m that is non-trivially different
    from the corresponding predicate in list.m: the chunk predicate.

tests/hard_coded/Mmakefile:
    Enable the new test case.
2020-02-28 14:29:05 +11:00
Zoltan Somogyi
d302810ecf Add some utility predicates, and make some cleanups.
library/list.m:
    Add a predicate version of map_corresponding3.

    Move a predicate next to its only call site.

    Use more meaningful variable names.

library/map.m:
library/tree234.m:
    Add several predicates: foldl4_values, foldl5_values, filter_map_values
    and filter_map_values_only.

library/multi_map.m:
    Embed an implicit assertion in a call.

library/set_ordlist.m:
    Give a predicate a better name.

library/NEWS:
    Announce the new additions.

    Put the list of updated library modules back into alphabetical order.

tests/hard_coded/test_map_filter.{m,exp}:
    Test the one wholly new utility predicate.
2020-02-27 19:23:17 +11:00
Zoltan Somogyi
95f8f56716 Delete unneeded $module args from calls to expect/unexpected. 2019-07-03 22:37:19 +02:00
Zoltan Somogyi
e9430b115a Prep for recording simple type representations in .int3 files.
compiler/decide_type_repn.m:
    New module for computing the set of type representation items
    to put into the interface files of a module. For now, it generates
    this information only for .int3 files.

compiler/parse_tree.m:
compiler/notes/compiler_design.html:
    Add the new module to the parse_tree package.

compiler/comp_unit_interface.m:
    Invoke the new module to add type representation items to .int3 files
    if the experiment option has the right value. Give it the information
    it needs to do its job.

compiler/add_foreign_enum.m:
    Export a predicate for use by decide_type_repn.m. Maybe eventually
    it should be *moved* to decide_type_repn.m.

compiler/hlds_data.m:
compiler/prog_data.m:
    Change the representation of lists of constructors in a type
    from lists, which can be empty, with one_or_more, which cannot.
    This encodes the invariant that a type constructor cannot have
    zero data constructors in the structure of the type.

compiler/prog_item.m:
    Change the representation of lists of constructors in a type
    from lists, which can be empty, with one_or_more, which cannot.
    This encodes the invariant that a type constructor cannot have
    zero data constructors in the structure of the type.

    Include information about assertions in type representation items
    about foreign types.

    Do not record whether a type whose representation item says its values
    are guaranteed to be word aligned is a Mercury type or a foreign type.
    We generate such items only for Mercury types; for foreign types,
    their assertions will contain that information. We need this separation
    because when we generate .int3 files, we don't the backend that we will
    eventually generate code for, and thus do not know whether a given
    foreign type declaration is in effect on that backend or not.

compiler/parse_tree_out.m:
    Fix the printing of type representation items.

compiler/prog_type.m:
    Conform to the changes above, and delete an unused predicate.

compiler/parse_type_repn.m:
    Factor out some common code.

    Fix an old bug about yes/no vs du_repn/no_du_repn.

    Conform to the changes above.

compiler/parse_pragma.m:
    Export a predicate for parse_type_repn.m.

    Note a possible improvement.

    Conform to the changes above.

compiler/add_special_pred.m:
compiler/add_type.m:
compiler/check_typeclass.m:
compiler/det_report.m:
compiler/du_type_layout.m:
compiler/equiv_type.m:
compiler/hlds_out_module.m:
compiler/inst_check.m:
compiler/intermod.m:
compiler/mode_util.m:
compiler/module_qual.qualify_items.m:
compiler/parse_tree_out_pragma.m:
compiler/parse_type_defn.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/resolve_unify_functor.m:
compiler/special_pred.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_norm.m:
compiler/type_util.m:
compiler/untupling.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
    Conform to the changes above.

compiler/simplify_goal_ite.m:
    Add a comment.

compiler/canonicalize_interface.m:
compiler/get_dependencies.m:
    Do not abort when seeing type representation items.

compiler/mmakefiles.m:
    Delete a predicate that this diff adds to list.m.

library/list.m:
    Add new predicates to convert from one_or_more to list
    and vice versa.

NEWS:
    Announce the new predicates.

library/bimap.m:
library/map.m:
library/tree234.m:
    Expand a comment.
2019-05-27 11:45:10 +02:00
JeffreyBenjaminBrown
c066d6be18 correct some comments 2018-12-28 13:40:23 +11:00
Peter Wang
3cf72e496a Add list.any_true/2 and list.any_false/2.
list.any_true/2 is a trivial predicate but a goal

    any_true(Pred, List)

would usually be clearer to the reader than any of these alternatives:

    find_first_match(Pred, List, _)
    not all_false(Pred, List)
    some [X] ( member(X, List), Pred(X) )

library/list.m:
    Add list.any_true/2, and list.any_false/2 for symmetry.

NEWS:
    Announce the additions.
2018-10-19 17:20:47 +11: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
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
Zoltan Somogyi
74a7a8345c Fix too-long lines. 2017-12-30 19:59:59 +11:00
Zoltan Somogyi
d9e576a2b2 Specify the type for inst definitions.
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
library/*.m:
mdbcomp/*.m:
ssdb/*.m:
    Specify the type constructor for every inst definition that lists
    the functors that values of that type may be bound to.

    In library/maybe.m, delete the inst maybe_errors/1, because
    (a) its name is misleading, since it is for the maybe_error/1 type (no s),
    and (b) there is already an inst with the non-misleading name maybe_error
    which had an identical definition.

    In compiler/dep_par_conj.m, delete two insts that were duplicates
    of insts defined in hlds_goal.m, and replace references to them
    accordingly.
2017-11-08 16:54:18 +11:00
Peter Wang
4af0c874af Clarify meaning of "abort" in library documentation.
library/assoc_list.m:
library/bag.m:
library/bimap.m:
library/calendar.m:
library/char.m:
library/digraph.m:
library/list.m:
library/map.m:
library/multi_map.m:
library/psqueue.m:
library/rbtree.m:
library/string.m:
library/term.m:
library/tree234.m:
library/type_desc.m:
library/univ.m:
library/varset.m:
    Replace most occurrences of "abort" with "throw an exception".

    Slightly improve the documentation for map.search, map.lookup,
    map.inverse_search.

library/deconstruct.m:
    Replace "abort" with "runtime abort" where that is meant.
2017-10-09 21:48:29 +11:00
Peter Wang
8bb3eee738 Clarify behaviour of list.find_index_of_match.
library/list.m:
    Clarify meaning of Index0 parameter in list.find_index_of_match.
2017-06-16 14:48:07 +10:00
Zoltan Somogyi
79fb502ea2 Fix more warnings from --warn-inconsistent-pred-order-clauses.
Group predicates into meaningful groups. Put the predicates into
a sensible order within their group, and put the groups themselves
into an order from simpler to more complex.

Fix unnecessary inconsistencies between related predicates when
those inconsistencies were revealed by being brought together.
2017-05-04 20:55:01 +10:00
Zoltan Somogyi
ab9234dc63 Speed up merge sort. 2016-07-27 12:11:26 +02:00
Julien Fischer
018d05ea45 Make list.split_upto and list.take_upto abort for N < 0.
library/list.m:
   Make split_upto/4 and take_upto/{2,3} abort for N < 0.

tests/hard_coded/take_split_upto.{m,exp}:
   Update this test case to test the for new behaviour.

tests/hard_coded/Mmakefile:
   Do not run the take_split_upto test case in deep profiling
   grades since it now requires catching exceptions to be supported.

NEWS:
	Announce the above change.
2016-06-09 11:36:00 +10:00
Julien Fischer
9961043a2c Make split_list/4, drop/3 and take/3 consistent.
Improve documentation and test coverage for the same.

library/list.m:
    Change the behaviour of take/3 and drop/3 so they fail if their
    first argument is negative.  This makes them consistent with
    the behaviour of split_list/4 and is arguably less surprising than
    their current behaviour.

    Make split_list/4 more efficient by not doing two comparison
    operations per recursive call.

    Re-implement det_drop/3 in terms of drop/3.

    Fix the documentation of the failure condition of split_list/4,
    take/3 and drop/3; all three omitted the description of what
    happens if their first argument is negative.

    Use 'N' rather than 'Len' for the name of the first argument
    in the comments describing the above predicates; the latter
    is ambiguous.

NEWS:
    Announce the change in behaviour of take/3 and drop/3.

tests/hard_coded/list_split_take_drop.{m,exp}:
     Test the behaviour of the above predicates and also check that the
     expected relationships between them hold.

tests/hard_coded/Mmakefile:
      Add the new test.
2016-06-04 23:02:38 +10:00
Julien Fischer
53db329949 Make list.m easier to search.
library/list.m:
    Strip redundant module qualifiers from clause heads.
    This simplifies searching for the clauses for a specific predicate
    or function.
2016-06-03 10:50:16 +10:00
Paul Bone
652d89cf38 Add take_while and drop_while to the list module
Add new predicates and functions take_while and drop_while to the list
module.

Deprecate takewhile/4, replacing it with take_while/4.

library/list.m:
    As above.

NEWS:
    Announce this change.

browser/parse.m:
compiler/compute_grade.m:
compiler/deforest.m:
compiler/mercury_compile_main.m:
compiler/ml_optimize.m:
compiler/mode_robdd.equiv_vars.m:
compiler/options_file.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.domain.m:
compiler/structure_sharing.domain.m:
compiler/term_constr_data.m:
compiler/write_deps_file.m:
compiler/xml_documentation.m:
deep_profiler/read_profile.m:
deep_profiler/top_procs.m:
library/list.m:
    Conform to above changes.
2016-04-22 21:27:03 +10:00
Julien Fischer
4701c9cd07 Delete unused foreign exports from the list module.
library/list.m:
    Delete some unused foreign exports from this module.  These were
    originally intended for use by IL backend; now they just duplicate
    functionality available in the runtime.
2015-12-14 14:55:08 +11:00
Julien Fischer
94535ec121 Fix spelling and formatting throughout the system.
configure.ac:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
library/*.m:
ssdb/*.m:
runtime/mercury_conf.h.in:
runtime/*.[ch]:
scripts/Mmake.vars.in:
trace/*.[ch]:
util/*.c:
	Fix spelling and doubled-up words.

	Delete trailing whitespace.

	Convert tabs into spaces (where appropriate).
2015-12-02 18:46:14 +11:00
Zoltan Somogyi
ef6d68a88d Add items to the HLDS by kinds, not in passes.
There are several reasons for this change.

First, it is more flexible than the previous arrangement of adding items
to the HLDS in three passes. Since adding a fourth pass would have had
significant performance implications, we refrained from making changes
that would have required a fourth pass in a pass-based algorithm.
With the new structure, such changes do not lead to any detectable slowdown,
so there is no reason why we should avoid making them.

In fact, the immediate motivation for this diff is to make such a change.
This is a fix for Mantis bug 318, which requires adding abstract and/or
non-foreign definitions for types before foreign definitions for those types
*regardless* of their relative order in the source code.

This diff also has the side effect that e.g. the mode declarations for
a predicate don't have to follow the declaration of the (type of) the predicate
itself. Pred and mode declarations used to be processed in the same pass,
but now, all pred declaration are processed before all mode declarations.

Second, as identified earlier, the new structure is conceptually cleaner than
the old one, and the constraints on when different kinds of items have to be
added to the HLDS can documented next to the code that does the adding,
since that code is no longer mixed with code that adds other kinds of items
at the same time.

Third, the code we used to use to detect invalid type definitions
was only a crude approximation. With the new setup, it is trivial to use
an exact computation. We now proceed to later compiler passes in many cases
that previously led us to stop before type checking because we (erroneously)
believed that the program had an invalid type definition.

Fourth, my benchmarking shows a speedup on tools/speedtest -l -m of about
1.2% to 1.5%. The new approach does allocate a bit more memory (a pair
and a cons cell per item), but it traverses most items just once, not
three times. A few kinds of items (e.g. pred declarations) do have to be
processed more than once, e.g. both before and after some other kinds
of items are added to the HLDS, but four of the five most frequent items
in bootchecks (the pragmas recording the results of the termination and
exception analyses, mode declarations, and clauses) are processed just once.
Evidently, the speedup from traversing fewer items, and avoiding the
switches on item kinds that those traversals involve, is greater than
the extra cost of the additional memory allocations, including their effect
on garbage collection times.

compiler/make_hlds_passes.m:
    Make the change described above.

    Remove "shim" code, i.e. code that serves only to unpack the pairing
    of an item with other info such as a status, and code that tests
    that status, e.g. to see whether the item is defined in the module
    being compiled. Move that shim code to the other submodules of
    make_hlds.m. (We used to have add_xyz predicate in make_hlds_passes.m
    and module_add_xyz predicates in those submodules, in which add_xyz
    contained only shim code and a call to the corresponding module_add_xyz
    predicate.)

compiler/add_class.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pred.m:
compiler/add_solver.m:
    Move shim code here from make_hlds_passes.m.

    Give some predicates better names.

    In a few cases, remove unneeded arguments from predicates. For example,
    most predicates that do only checks don't need write access to the
    module_info.

compiler/add_pragma.m:
    Use subtypes to make the code a bit more efficient.

    Add specialized fold predicates that can handle those subtypes.

compiler/add_type.m:
    Add documentation for an old design decision.

compiler/make_hlds.m:
    Add some utility types for use by make_hlds_passes.m and the various
    add_xyz.m.

compiler/check_typeclass.m:
    Improve an error message. We now get this error message even for modules
    on which the compiler previously stopped before getting to typechecking.

compiler/modes.m:
    Don't generate redundant error messages for mode errors in mutables' aux
    preds. (Previously, the mode checker wouldn't have been invoked if
    make_hlds_passes.m found the original problem.)

compiler/prog_item_stats.m:
    Delete an unneeded import.

library/list.m:
    Add an inst-preserving version of reverse, since make_hlds_passes.m
    now needs one.

tests/debugger/solver_test.exp:
    We add predicates to the HLDS in a different order now (auxiliary
    predicates for solver types are added *after* used-defined predicates).
    This test prints the raw order of those predicates, so expect the new
    order.

tests/invalid/typeclass_test_9.err_exp:
tests/invalid_purity/purity_nonsense2.err_exp:
    Expect error messages we didn't used to get, because the compiler
    stopped before typechecking due to (incorrectly) believing that it found
    an invalid type definition.

    For typeclass_test_9, expect the updated error message from
    check_typeclass.m. (This newly printed error message was the reason
    *why* I improved the message from check_typeclass.m.)

tests/invalid/tc_err1.err_exp:
tests/invalid/tc_err2.err_exp:
tests/invalid/typeclass_bogus_method.err_exp:
tests/invalid/typeclass_missing_mode_2.err_exp:
tests/invalid/typeclass_test_10.err_exp:
tests/invalid/typeclass_test_3.err_exp:
tests/invalid/typeclass_test_4.err_exp:
    Expect the updated error message from check_typeclass.m.

tests/valid/bug318.m:
    A test case for Mantis bug 318.

tests/valid/Mmakefile:
    Enable the new test case.
2015-10-29 14:13:46 +11:00
Zoltan Somogyi
93b1060cbf Improve variable names. 2015-10-26 07:21:36 +11:00
Peter Wang
4a84bb5c7f Add list.reverse_prepend.
reverse_prepend is the helper for non-naive reverse.
It is useful in its own right so we export it here.

library/list.m:
	Add predicate `reverse_prepend/3' and function `reverse_prepend/2'.

compiler/c_util.m:
	Delete own copy of the same predicate.

NEWS:
	Announce addition.
2015-10-19 10:49:44 +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
618e34a9ba Address Julien's review comments on bag.m.
library/bag.m:
    Obsolete to_set_without_duplicates.

    Remove the list skeleton insts.

library/list.m:
    Add an empty list inst.

NEWS:
    Announce the changes in bag.m.
2015-09-17 21:38:39 +10:00
Zoltan Somogyi
5efc277801 Improve list.m.
library/list.m:
    Switch to a more expressive and more consistent set of variable names.

    Give many _2 helper predicates better names.

    Convert (C->T;E) to (if C then T else E).

    Note that nth_member_search is identical to index1_of_first_occurrence,
    and nth_member_lookup is identical to det_index1_of_first_occurrence.
    Make the former redirect to the latter.

browser/declarative_tree.m:
browser/term_rep.m:
compiler/dep_par_conj.m:
compiler/global_data.m:
compiler/polymorphism.m:
compiler/prog_foreign.m:
compiler/pseudo_type_info.m:
compiler/tupling.m:
compiler/type_ctor_info.m:
    Replace calls to nth_member_{search,lookup} with
    {det_,}index1_of_first_occurrence.
2015-08-18 14:42:42 +10:00