library/varset.m:
We have long had two versions of the lookup_name function, and of
the equivalent lookup_name predicate, with the difference being
that one version had an extra argument that specified to prefix
for the names to be constructed for not-explicitly-named variables.
Obsolete the function and the predicate with this extra argument
in favor of a new function/predicate pair, whose shared name is
lookup_name_default_prefix.
Act on an old sortof-XXX by changing the order of arguments of the
set_bindings predicate to make it state-variable-friendly.
Improve some comments.
NEWS.md:
Document the above changes.
library/term.m:
Document the var and var_supply types at their definitions.
Don't intersperse obsolete pragmas together with predicate/function
declarations.
Update some old comments.
compiler/lp_rational.m:
compiler/mlds_to_target_util.m:
Replace calls to the newly-obsoleted function and predicate.
NEWS:
Mention all the user-visible changes below.
library/enum.m:
Add the typeclass uenum, which is a version of the existing enum typeclass
that maps items to uints, not ints. It also uses a semidet predicate,
not a semidet function, to get back to the item from the uint.
library/sparse_bitset.m:
library/fat_sparse_bitset.m:
Make these modules operate on uints, which means requiring the items
in the sets to be instances of uenum, not enum.
If a few places, improve loops by doing previously-repeated conversions
of [u]ints into <offset, bit-to-set> pairs just once.
library/counter.m:
Define ucounters, which allocate uints. Improve documentation.
library/digraph.m:
Change digraph_keys from ints to uints, since we put them into
sparse_bitsets.
library/int.m:
Make int an instance of the uenum typeclass. This can help users
who currently put ints into sparse_bitsets.
library/pprint.m:
Prettyprint sparse_bitsets as lists of uints.
library/term.m:
Make vars instances of uenum as well as enum.
library/uint.m:
Make uint an instance of the uenum typeclass.
Add the ubits_per_uint function, which allows some casts to be avoided.
compiler/make.deps_set.m:
Change the indexes we put into sparse_bitsets from ints to uints.
compiler/make.make_info.m:
Change the source of those indexes from ints to uints.
compiler/make.top_level.m:
compiler/make.util.m:
Conform to the changes above.
compiler/pre_quantification.m:
Change zones from ints to uints, since we put them into sparse_bitsets.
tests/hard_coded/int_uenum.{m,exp}:
tests/hard_coded/Mmakefile:
Enable the new test case.
tests/valid/use_import_only_for_instance.m:
Update this extract from library/digraph.m the same way as
library/digraph.m itself.
library/term.m:
library/term_context.m:
As above.
Rename the term.context type as term_context.term_context, with
term.context now being defined as an equivalence type.
Replace the context_init function and predicate and the dummy_context_init
function with just one function: dummy_context. This name includes
the important part (the fact that it return a *dummy* context) and deletes
the nonimportant part (dummy contexts are just about never updated,
so the function does not really "initialize" them).
Reduce function/predicate pairs that do the same thing to just a function.
library/MODULES_DOC:
library/library.m:
Add the new module to the list of standard library modules.
NEWS:
Mention the new module, and the obsoleting of the moved predicates
and functions in term.m.
compiler/*.m:
library/*.m:
Conform to the changes above.
Most modules that imported the old term.m need only a small subset
of its functionality. After this diff, most modules that used to import
term.m will need to import just one more module, and will import many
fewer predicates and functions in total.
library/term_int.m:
A new module carved out of term.m containing the predicates
that recognize terms containing integers, and the functions
that construct such terms.
While this job has *some* similarity to the job of the existing
term_conversion.m module, most modules in the compiler use only one
of those two modules, so merging them would not be a good idea.
library/term_subst.m:
A new module carved out of term.m containing code to do
substitutions and renames of various kinds.
Rename the occurs predicate as var_occurs_in_subst_term,
and occurs_list as var_occurs_in_subst_terms, since the latter
are much more descriptive. Change the argument order to match
the new names (var, subst, term/terms), as the old one did not
even have the term/terms and the substitution next to each other,
even though neither makes sense without the other.
library/term_unify.m:
A new module carved out of term.m containing code to do unifications.
Give all the predicates more meaningful names:
unify_term -> unify_terms
unify_term_list -> unify_term_lists
unify_term_dont_bind -> unify_terms_dont_bind
unify_term_list_dont_bind -> unify_term_lists_dont_bind
list_subsumes -> first_term_list_subsumes_second
library/term_vars.m:
A new module carved out of term.m containing code that find variables
in terms.
Give all the predicates more meaningful names:
vars -> vars_in_term
vars_2 -> vars_in_term_acc
vars_list -> vars_in_terms
contains_var -> term_contains_var
contains_var_list -> terms_contain_var
Don't move the function version of vars_2 to term_vars.m, effectively
deleting it, since operations that update an accumulator are awkward
for functions.
library/term.m:
Keep the moved predicates and functions in term.m, but
- change their implementation to simply call the moved copy, and
- obsolete the original in favor of the moved copy.
Eventually, after either the next release or the release after the next,
we should delete the obsoleted predicates and functions.
library/MODULES_DOC:
library/library.m:
Add the new modules as documented parts of the standard library.
browser/interactive_query.m:
compiler/analysis.file.m:
compiler/det_util.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/intermod.m:
compiler/make.module_dep_file.m:
compiler/make_hlds_passes.m:
compiler/parse_class.m:
compiler/parse_inst_mode_defn.m:
compiler/parse_item.m:
compiler/parse_mutable.m:
compiler/parse_pragma.m:
compiler/parse_pragma_analysis.m:
compiler/parse_sym_name.m:
compiler/parse_tree_to_term.m:
compiler/parse_type_defn.m:
compiler/parse_util.m:
compiler/prog_ctgc.m:
compiler/prog_util.m:
compiler/recompilation.used_file.m:
compiler/recompilation.version.m:
compiler/superhomogeneous.m:
compiler/switch_detection.m:
compiler/typecheck.m:
library/io.m:
library/term_conversion.m:
library/varset.m:
Conform to the changes above.
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/term.m:
Document the fact that terms built by parser.m never have integers,
floats, strings or implementation defined constants applied to a nonempty
list of arguments.
library/parser.m:
Document the same fact at every place where we construct terms with
such functors.
library/lexer.m:
Fix typo in comment.
compiler/parse_inst_mode_name.m:
compiler/superhomogeneous.m:
Instead of code that generates error messages if an integer has args,
add assertions that integers won't have args. Add similar assertions
for the other kinds of term functors for which is also true.
Add commented
tests/invalid/invalid_int.m:
Fix an irritation when reading this code: a repeated "bug" that is
orthogonal to the problems that this test case is designed for.
library/varset.m:
Add a faster implementation of merge_renaming and related predicates,
with a heuristic selecting between it and the old implementation.
The new implementation targets three sources of overhead when
merging two varsets of size M and N.
- First, the old code does an O(log N) lookup on the name of each var
in the second varset. Total complexity: O(N log N).
- Second, for each var in the second varset that does have a name,
the old code then does an O(log (M+N)) insert into the updated name map.
Total complexity: O(N log (N+M)), though with a smaller constant factor.
- Third, the old code does an O(log N) insert into the renaming map
for each var in the second varset. Total complexity: O(N log N).
The new code avoids all the O(log N) lookups and all the
individual O(log N) inserts. It avoids the lookups by flattening
the second varset's name map (total complexity: O(N)).
It replaces the individual inserts into the renaming map by constructing
the renaming map as a sorted assoc list (total complexity: O(N)),
and then constructing a map from that: (total complexity: again O(N)).
It replaces the individual inserts into the updated name map by
constructing the new entries in the name map as a sorted assoc list,
appending it to the sorted assoc list of the old name map,
and then constructing updated name map from that. Again, the complexity
is again linear, though the second and third steps are in O(M + N),
not O(N), since they also involve the entries in the name map of the
*first* varset.
Delete some unnecessary module qualifications.
Update some documentation.
library/term.m:
Add some service functions to the undocumented part of the module
interface. These are needed by the new code in varset.m.
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.
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.
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.
The improvements take two forms.
The first is that when the mode checker tries to schedule a unification
of the form X = curried_pred(A1, ... An), but fails, perhaps because
curried_pred has more than one declared mode matching the current insts
of the Ai, we record this fact in the mode_info. Then, if later we find
that X is insufficiently instantiated, we print the message we originally
generated for the X = curried_pred(A1, ... An) unification (but which we
threw away when the scheduling attempt failed) as a possible explanation
of this insufficient instantiation.
The second is that when scheduling X = curried_pred(A1, ... An) but fails,
we record more information about the reason, to print it later in the hope that
it may help the user diagnose the problem.
compiler/mode_errors.m:
Change the representation of the errors resulting for not being able
to schedule rhs_lambda unifications of the form X = curried_pred(Ai).
Merge the previous two separate errors into one, and add a parameter
that that distinguishes the three (not two) possible different causes
of the error. Print better diagnostics for all three, based on a common
template.
Change the representation of the errors that say a variable is not
sufficiently instantiated, to make it possible (but of course not
compulsory) to record what error of the X = curried_pred(Ai) kind
may be responsible for it. Include the error message for this cause
in the error message about the insufficiently instantiated variable.
compiler/mode_info.m:
Add a field to the mode_info that allows a failed attempt to schedule
X = curried_pred(Ai) to record the error it generates as a possible
cause of the later insufficient instantiation of X.
compiler/modecheck_unify.m:
Gather the extra information now needed by the representation of mode
errors for failed attempts to schedule X = curried_pred(Ai).
Record the errors for such attempts in the new mode_info field.
compiler/modecheck_util.m:
When generating "variable is not sufficiently instantiated" errors,
see if the new mode_info field say that the insufficiently instantiated
variable was, in a previous conjunct, involved in a failed
X = curried_pred(Ai) unification, and if yes, record this fact
as a possible cause of the error.
compiler/modecheck_goal.m:
Reset the new field at the start of every branched control structure,
to prevent us from using information about X = curried_pred(Ai)
unifications in one branch in other, parallel branches.
Avoid allocating a context at every goal.
library/term.m:
Add a utility predicate to enable that avoidance.
NEWS:
Mention the new utility predicate.
Fix some no-longer-valid entries.
compiler/modecheck_call.m:
Make some code need less stack space.
Fix some comments.
compiler/modecheck_conj.m:
Clarify some code.
tests/invalid/uint_bitwise_xor_mode.{m,err_exp}:
A new test case for both improvements. It is a version of
tests/hard_coded/uint_bitwise.m cut down to contain just the bug
that previously we generate only a misleading error message for.
tests/invalid/Mmakefile:
Enable the new test.
tests/invalid/multimode_addr_problems.err_exp:
Update this expected output to account for the second improvement.
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.
In preparation for supporting uint literals and literals for the fixed size
integer types, generalise the representation of integers in the term module, so
that for every integer literal we record its base, value (as an arbitrary
precision integer), signedness and size (the latter two based on the literal's
suffix or lack thereof).
Have the lexer attach information about the integer base to machine sized ints;
we already did this for the 'big_integer' alternative but not the normal one.
In conjunction with the first change, this fixes a problem where the compiler
was accepting non-decimal integers in like arity specifications. (The
resulting error messages could be improved, but that's a separate change.)
Support uints in more places; mark other places which require further work with
XXX UINT.
library/term.m:
Generalise the representation of integer terms so that we can store
the base, signedness and size of a integer along with its value.
In the new design the value is always stored as an arbitrary precision
integer so we no longer require the big_integer/2 alternative; delete it.
Add some utility predicates that make it easier to work with integer terms.
library/term_conversion.m:
library/term_io.m:
Conform to the above changes,
Add missing handling for uints in some spots; add XXX UINT comments
in others -- these will be addressed later.
library/lexer.m:
Record the base of word sized integer literals.
library/parser.m:
compiler/analysis_file.m:
compiler/fact_table.m:
compiler/get_dependencies.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_util.m:
compiler/intermod.m:
compiler/make.module_dep_file.m:
compiler/parse_class.m:
compiler/parse_inst_mode_name.m:
compiler/parse_item.m:
compiler/parse_pragma.m:
compiler/parse_sym_name.m:
compiler/parse_tree_out_term.m:
compiler/parse_tree_to_term.m:
compiler/parse_type_defn.m:
compiler/parse_util.m:
compiler/prog_ctgc.m:
compiler/prog_util.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/superhomogeneous.m:
mdbcomp/trace_counts.m:
samples/calculator2.m:
extras/moose/moose.m:
Conform to the above changes.
tests/hard_coded/impl_def_lex.exp:
tests/hard_coded/impl_def_lex_string.exp:
tests/hard_coded/lexer_bigint.exp*:
tests/hard_coded/lexer_zero.exp*:
tests/hard_coded/parse_number_from_string.exp*:
tests/hard_coded/term_to_unit_test.exp:
Update these expected outputs.
If a module has two or more import_module or use_module declarations
for the same module, (typically, but not always, one being in its interface
and one in its implementation), generate an informational message about
each redundant declaration if --warn-unused-imports is enabled.
compiler/hlds_module.m:
We used to record the set of imported/used modules, and the set of
modules imported/used in the interface of the current module. However,
these sets
- did not record the distinction between imports and uses;
- did not allow distinction between single and multiple imports/uses;
- did not record the locations of the imports/uses.
The first distinction was needed only by module_qual.m, which *did*
pay attention to it; the other two were not needed at all.
To generate messages for imports/uses shadowing other imports/uses,
we need all three, so change the data structure storing such information
for *direct* imports to one that records all three of the above kinds
of information. (For imports made by read-in interface and optimization
files, the old set of modules approach is fine, and this diff leaves
the set of thus *indirectly* imported module names alone.)
compiler/unused_imports.m:
Use the extra information now available to generate a
severity_informational message about any import or use that is made
redundant by an earlier, more general import or use.
Fix two bugs in the code that generated warnings for just plain unused
modules.
(1) It did not consider that a use of the builtin type char justified
an import of char.m, but without that import, the type is not visible.
(2) It scanned cons_ids in goals in procedure bodies, but did not scan
cons_ids that have been put into the const_struct_db. (I did not update
the code here when I added the const_struct_db.)
Also, add a (hopefully temporary) workaround for a bug in
make_hlds_passes.m, which is noted below.
However, there are at least three problems that prevent us from enabling
--warn-unused-imports by default.
(1) In some places, the import of a module is used only by clauses for
a predicate that also has foreign procs. When compiled in a grade that
selects one of those foreign_procs as the implementation of the predicate,
the clauses are discarded *without* being added to the HLDS at all.
This leads unused_imports.m to generate an uncalled-for warning in such
cases. To fix this, we would need to preserve the Mercury clauses for
*all* predicates, even those with foreign procs, and do all the semantic
checks on them before throwing them away. (I tried to do this once, and
failed, but the task should be easier after the item list change.)
(2) We have two pieces of code to generate import warnings. The one in
unused_imports.m operates on the HLDS after type and mode checking,
while module_qual.m operates on the parse tree before the creation of
the HLDS. The former is more powerful, since it knows e.g. what types and
modes are used in the bodies of predicates, and hence can generate warnings
about an import being unused *anywhere* in a module, as opposed to just
unused in its interface.
If --warn-unused-imports is enabled, we will get two separate set of
reports about an interface import being unused in the interface,
*unless* we get a type or mode error, in which case unused_imports.m
won't be invoked. But in case we do get such errors, we don't want to
throw away the warnings from module_qual.m. We could store them and
throw them away only after we know we won't need them, or just get
the two modules to generate identical error_specs for each warning,
so that the sort_and_remove_dups of the error specs will do the
throwing away for us for free, if we get that far.
(3) The valid/bug100.m test case was added as a regression test for a bug
that was fixed in module_qual.m. However the bug is still present in
unused_imports.m.
compiler/make_hlds_passes.m:
Give hlds_module.m the extra information it now needs for each item_avail.
Add an XXX for a bug that cannot be fixed right now: the setting of
the status of abstract instances to abstract_imported. (The "abstract"
part is correct; the "imported" part may not be.)
compiler/intermod.m:
compiler/try_expand.m:
compiler/xml_documentation.m:
Conform to the change in hlds_module.m.
compiler/module_qual.m:
Update the documentation of the relationship of this module
with unused_imports.m.
compiler/hlds_data.m:
Document a problem with the status of instance definitions.
compiler/hlds_out_module.m:
Update the code that prints out the module_info to conform to the change
to hlds_module.m.
Print status information about instances, which was needed to diagnose
one of the bugs in unused_imports.m. Format the output for instances
nicer.
compiler/prog_item.m:
Add a convenience predicate.
compiler/prog_data.m:
Remove a type synonym that makes things harder to understand, not easier.
compiler/modules.m:
Delete an XXX that asks for the feature this diff implements.
Add another XXX about how that feature could be improved.
compiler/Mercury.options.m:
Add some more modules to the list of modules on which the compiler
should be invoked with --no-warn-unused-imports.
compiler/*.m:
library/*.m:
mdbcomp/*.m:
browser/*.m:
deep_profiler/*.m:
mfilterjavac/*.m:
Delete unneeded imports. Many of these shadow other imports, and some
are just plain unneeded, as shown by --warn-unused-imports. In a few
modules, there were a *lot* of unneeded imports, but most had just
one or two.
In a few cases, removing an import from a module, because it *itself*
does not need it, required adding that same import to those of its
submodules which *do* need it.
In a few cases, conform to other changes above.
tests/invalid/Mercury.options:
Test the generation of messages about import shadowing on the existing
import_in_parent.m test case (although it was also tested very thoroughly
when giving me the information needed for the deletion of all the
unneeded imports above).
tests/*/*.{m,*exp}:
Delete unneeded imports, and update any expected error messages
to expect the now-smaller line numbers.
Make base_string_to_int check for overflow and underflow when converting
from strings in all bases, not only base 10. Fixes bug #376.
Previously it was stated that "numbers not in base 10 are assumed to
denote bit patterns and are not checked for overflow." Though not a
safe assumption in general, in Mercury source files it is useful to be
able to write values with the high bit set, e.g. 0x80000000 on 32-bit
machines, that would be greater than max_int if interpreted as a
positive integer.
The changed behaviour of base_string_to_int would reject such literals
from Mercury sources, so additional changes are required to maintain
that usage. However, unlike before, the compiler will report an
error if some non-zero bits of the literal would be discarded.
library/string.m:
Enable overflow/underflow checking for base_string_to_int for
any base.
Update documentation.
library/lexer.m:
Allow `big_integer' token functor to represent non-base 10
literals as well.
Add `integer_base' type.
library/term.m:
Add `big_integer' term functor.
Add `integer_base' type.
library/term_io.m:
Add private helper functions `integer_base_int' and
`integer_base_prefix'.
Conform to changes.
library/parser.m:
Pass through `big_integer' tokens as `big_integer' terms.
Conform to changes.
compiler/prog_util.m:
Add predicate to convert integer terms to ints with the
aforementioned concession for bit patterns.
`make_functor_cons_id' can now fail due to integer tokens
exceeding the range of `int'.
compiler/superhomogeneous.m:
Make `unravel_var_functor_unification' convert `big_integer'
tokens on the RHS to a simple `int' with the aforementioned
concession for bit patterns, or add an error message if any
significant bits would be discarded.
compiler/fact_table.m:
compiler/mercury_to_mercury.m:
compiler/module_imports.m:
compiler/prog_io_util.m:
Conform to changes.
compiler/make.util.m:
Delete unused predicate.
tests/general/test_string_to_int_overflow.m:
tests/general/test_string_to_int_overflow.exp:
tests/general/test_string_to_int_overflow.exp2:
tests/general/test_string_to_int_overflow.exp3:
Rewrite test case.
tests/hard_coded/lexer_bigint.exp:
tests/hard_coded/lexer_bigint.exp2:
tests/hard_coded/read_min_int.exp:
tests/hard_coded/read_min_int.exp2:
Update expected outputs due to the lexer and term module changes.
tests/invalid/Mmakefile:
tests/invalid/invalid_int.err_exp:
tests/invalid/invalid_int.err_exp2:
tests/invalid/invalid_int.m:
Add new test case.
NEWS:
Announce the changes.
library/term.m:
Add commented-out obsolete pragmas for the to-be-obsoleted predicates
in term.m. (The rest of this diff was done by fixing what broke
when this was NOT commented out.)
Avoid calling the to-be-obsoleted predicates.
library/varset.m:
compiler/*.m:
Avoid calling the to-be-obsoleted predicates. Delete some unused
predicates.
library/term_conversion.m:
A new library module that contains old code, to wit, the parts of term.m
that deal with conversions of values of arbitrary types to and from terms.
library/term.m:
Remove the code that is now in term_conversion.m.
Put the remaining types and predicates into a logical order. These have
several problems.
- Many have argument orders that predate state var notation and
don't work well with it.
- Some have names that are simply not very meaningful.
- And some predicates duplicate the functionality of other predicates.
Fix these problems by
- introducing new predicates with meaningful names that have
state-var-friendly argument orders,
- make the old predicates forward to the new ones, and
- add comments urging users to use these in preference to the old,
problematic predicates.
After branching the next release, these comments should be augmented with
obsolete pragmas.
library/library.m:
library/MODULES_DOC:
Mention the new module.
library/io.m:
compiler/structure_reuse.analysis.m:
compiler/structure_sharing.analysis.m:
compiler/unused_args.m:
Import term_conversion.m.
tests/hard_coded/ground_dd.m:
tests/hard_coded/term_to_univ_test.m:
tests/hard_coded/tuple_test.m:
tests/hard_coded/type_to_term.m:
tests/hard_coded/type_to_term_bug.m:
Import term_conversion.m, and bring the programming style of these modules
up to date.
compiler/prog_item.m:
The parse tree's goal type used to be defined as a pair of a goal_expr
and a context. This diff moves the context into each function symbol of
the goal_expr type, which it also renames the goal type, since it now
contains all the information that the old goal type did.
This reduces both the number of memory cells allocated (from two to one
for each goal) and the total amount of memory allocated (since we don't
need a pointer from the goal to the goal_expr), though the effect on
performance is in the noise on tools/speedtest. The effect on performance
when the compiler is just generating interface files should be bigger
(since in such cases parsing takes a bigger proportion of the overall
runtime), but (a) we don't have tools to measure that, and (b) each
such invocation is plenty fast already, and they take nontrivial amounts
of time only when invoked en masse.
Add a utility predicate to get a goal's context, since we need it
in a few cases.
compiler/goal_expr_to_goal.m:
Conform to the change in the goal type.
Generate HLDS goals with the right contexts from the start, instead
of creating them with dummy contexts and then setting the right context
later. In a few pathological cases (such as conjunction containing
explicit "true" goals), this leads to goals with different contexts than
before, but in the cases I found, the new contexts are more appropriate.
Make the code handling conjunctions easier to understand by using
cords (which were not available when that code was written). The old
code mixed reversed and double-reversed lists.
When processing unifications like !X = f, don't just generate an error
message; also pretend that !:X has been defined, to avoid later misleading
error messages.
Avoid situations in which Goal0 represents a parse tree goal and Goal
a HLDS goal. Make the switch of representations obvious by switching
to a different name (e.g. Goal to HLDSGoal), not just to a different
numeric suffix.
compiler/state_var.m:
Conform to the change in the goal type.
Provide a utility predicate to do the "pretending" part just above.
compiler/*.m:
Conform to the change in the goal type. In some cases, create new
HLDS goals with the right context.
library/term.m:
Add a function to apply a singleton renaming (a renaming of just one
variable) to a term, since some of the above changes can use this.
Clean up the code in this module a bit: use meaningful variable names,
and put the function versions of predicates next to those predicates.
The order of predicates is still haphazard.
tests/invalid/bad_sv_unify_msg.err_exp:
Expect an error message at the correct context, and don't expect
the redundant message we now don't generate.
library/varset.m:
Mark merge_subst and merge_subst_without_names with `pragma obsolete'.
The comments on them have been requesting people to use merge_renaming
and merge_renaming_without_names instead for about seven years, which
I think is enough warning :-)
Avoid using the obsolete predicates in varset.m itself.
library/term.m:
To make it possible to avoid using the obsolete predicates in varset.m
itself, add predicates that apply renamings, not substitutions, to a
term or a list of terms. Provide a renaming type to make this more
convenient.
Note that when term.apply_renaming actually does a renaming, the context
on the new term will be the original context, while term.apply_substitution
would have replaced this with the context on the replacement term.
I expect that in the vast majority of cases, the context does not matter.
In cases where it does, I expect that which context is better depends
on the situation; both choices have points in favor and against.
compiler/inst_graph.m:
compiler/prog_mode.m:
compiler/recompilation.version.m:
Use merge_renaming instead of merge_subst, and thus avoid shenanigans
with converting general terms back to variables.
compiler/rbmm.region_resurrection_renaming.m:
Add an "rbmm_" prefix to some types, to avoid the type "renaming"
being defined both by this module and (now) by library/term.m.
compiler/rbmm*.m:
Conform to the type name changes in rbmm.region_resurrection_renaming.m..
Branches: main
Address some old XXXs in the library.
library/term.m:
Delete an ancient comment regarding the choice of type
qualification operator; it's been ':' for quite some time
now.
library/ops.m:
Not being able to modify the table of Mercury operators
is a good thing, not an XXX.
library/term_io.m:
Delete an ancient comment regarding user-defined operators
for the term parser being NYI. We aren't likely to ever
implement them in the way described in the comment since
the op_table/1 type class provides an alternative way
of dealing with the problem.
Delete a comment in the interface that says we are
in the interface. For the source code this is obvious,
it occurs directly below the interface declaration
and for the library reference manual it is redundant clutter
since everyting in the manual is an interface.
Estimated hours taken: 2
Branches: main
compiler/liveness.m:
Do not delay the death of variables in debug grades if the number
of variables in the procedure exceeds a configurable threshold.
Delaying the death of variables means that at later and later calls,
there are more and more variables whose values need to be saved on the
stack. This has several bad consequences in large procedures:
- some data structures, such as the livevals instructions we generate
before calls, have size that is linear in both the number of calls
and the number of variables, and therefore they tend to be quadratic
overall in size;
- computing these data structures will take time that is at least
quadratic, and maybe worse;
- since we generate both more and bigger live sets, the stack slot
allocation pass will take time that seems to be at least qubic;
- the algorithm for trying to compress the pseudo-typeinfo array
describing all the stack slots at all the call sites will definitely
take qubic time;
- it will also generate HUGE arrays, leading to HUGE .c files
(almost one GIGABYTE for zm_enums.m);
- these huge files will take a long time to write out, and to compile
and link.
The impact of this change on debuggability should be small, since
the first step in debugging such huge procedures do is almost
certainly breaking them up into small, understandable pieces.
compiler/options.m:
Add an option, --delay-death-max-vars=N, to control the cutoff in
liveness.m. Set the default value to 1000. This affects only a few
predicates in the compiler, such as the huge switches in options.m,
and the many-page predicate in handle_options.m.
doc/user_guide.texi:
Document the new option.
Fix the formatting of the text for a nearby existing option.
library/term.m:
library/varset.m:
Add utility functions now needed by liveness.m.
Branches: main
Further library consistency improvements.
library.term.m:
Change the argument ordering of the predicate create_var/3.
(This breaks backwards compatibility but that should be okay
as most code uses the varset module rather than calling this
directly.)
Fix the layout in a spot.
library/string.m:
library/type_desc.m:
Change predicates and functions that use a "_det" suffix in
their name to use a "det_" prefix as in the rest of the library
modules. Deprecate the suffix versions.
library/varset.m:
Delete a reference to the graph module.
NEWS:
Announce the above changes.
library/construct.m:
library/varset.m:
library/term_to_xml.m:
compiler/passes_aux.m:
tests/hard_coded/construct_test.m:
tests/hard_coded/deep_copy.m:
tests/hard_coded/write.m:
tests/hard_coded/write_binary.m:
tests/hard_coded/write_reg1.m:
Conform to the above changes.
Branches: main
Make io.read, term_to_type and type_to_term support version arrays.
library/term.m:
Implement conversion of terms to version arrays and vice versa.
tests/hard_coded/Mmakefile:
tests/hard_coded/type_to_term.{m,exp}:
Add a test for the above and also test the special cases
for term_to_type and type_to_term more thoroughly than we
were.
Branches: main
Change the argument order of many of the predicates in the map, bimap, and
multi_map modules so they are more conducive to the use of state variable
notation, i.e. make the order the same as in the sv* modules.
Prepare for the deprecation of the sv{bimap,map,multi_map} modules by
removing their use throughout the system.
library/bimap.m:
library/map.m:
library/multi_map.m:
As above.
NEWS:
Announce the change.
Separate out the "highlights" from the "detailed listing" for
the post-11.01 NEWS.
Reorganise the announcement of the Unicode support.
benchmarks/*/*.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
extras/*/*.m:
mdbcomp/*.m:
profiler/*.m:
tests/*/*.m:
ssdb/*.m:
samples/*/*.m
slice/*.m:
Conform to the above change.
Remove any dependencies on the sv{bimap,map,multi_map} modules.
Estimated hours taken: 16
Branches: main
Add support for "implementation-defined literals" $file, $line, $module,
$pred, $grade which are replaced constants by the compiler.
library/lexer.m:
Add a new type of token.
Read "$foo" as a `implementation_defined' token instead of two name
tokens.
library/term.m:
library/term_io.m:
Add a new type of constant, `implementation_defined'.
library/parser.m:
Handle `implementation_defined' tokens from the lexer.
compiler/check_hlds.m:
compiler/implementation_defined_literals.m:
compiler/mercury_compile.m:
Add a new pass to replace implementation-defined literals in program
clauses.
Call the new pass.
compiler/notes/compiler_design.html:
Document the new module.
compiler/prog_data.m:
Add a new option to `cons_id', namely `implementation_defined_const'.
compiler/typecheck.m:
Tell the typechecker the types of the supported implementation-defined
literals.
compiler/prog_io_util.m:
Make `convert_bound_inst' fail if implementation-defined literals
appear in inst definitions so that an error will be issued.
compiler/bytecode_gen.m:
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/dependency_graph.m:
compiler/erl_unify_gen.m:
compiler/fact_table.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_out.m:
compiler/inst_check.m:
compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/module_qual.m:
compiler/prog_rep.m:
compiler/prog_type.m:
compiler/prog_util.m:
compiler/rbmm.execution_path.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
Conform to addition of `implementation_defined_const'.
doc/reference_manual.texi:
Document implementation-defined literals.
NEWS:
Announce the new feature.
tests/hard_coded/Mmakefile:
tests/hard_coded/impl_def_lex.exp:
tests/hard_coded/impl_def_lex.m:
tests/hard_coded/impl_def_lex_string.exp:
tests/hard_coded/impl_def_lex_string.m:
tests/hard_coded/impl_def_literal.exp:
tests/hard_coded/impl_def_literal.m:
tests/invalid/Mmakefile:
tests/invalid/impl_def_literal_syntax.err_exp:
tests/invalid/impl_def_literal_syntax.m:
tests/invalid/undef_impl_def_literal.err_exp:
tests/invalid/undef_impl_def_literal.m:
Add test cases.
Estimated hours taken: 80 by zs, and lots more by lmika
Branches: main
Provide compiler support for Software Transactional Memory through the new
atomic goal. This work was done by Leon Mika; I merely brought it up to date,
resolved conflicts, and cleaned up a few things. There are still several
aspects that are as yet incomplete.
library/ops.m:
Add the operators needed for the syntax of atomic scopes.
library/stm_builtin.m:
Add the builtin operations needed for the implementation of atomic
goals.
compiler/hlds_goal.m:
Add a new HLDS goal type, which represents an atomic goal and its
possible fallbacks (in case an earlier goal throws an exception).
Rename the predicate goal_is_atomic as goal_expr_has_subgoals,
since now its old name would be misleading.
compiler/prog_data.m:
compiler/prog_item.m:
Add a parse tree representation of the new kind of goal.
compiler/prog_io_goal.m:
Parse the new kind of goal.
compiler/add_clause.m:
Translate atomic goals from parse tree form to HLDS.
compiler/typecheck.m:
compiler/typecheck_errors.m:
Do type checking of atomic goals.
compiler/modes.m:
Do mode checking of atomic goals, and determine whether they are nested
or not.
compiler/unique_modes.m:
Do unique mode checking of atomic goals.
compiler/stm_expand.m:
New module to expand atomic goals into sequences of simpler goals.
library/stm_builtin.m:
Add the primitives needed by the transformation.
Improve the existing debugging support.
mdbcomp/prim_data.m:
Add utility functions to allow stm_expand.m to refer to modules in the
library.
mdbcomp/program_representation.m:
Expand the goal_path type to allow the representation of components of
atomic goals.
compiler/notes/compiler_design.html:
Document the new module.
compiler/transform_hlds.m:
Include the new module in the compiler.
compiler/mercury_compile.m:
Invoke the STM transformation.
compiler/hlds_module.m:
Add an auxiliary counter used by the STM transformation.
compiler/hlds_pred.m:
Add a new predicate origin: the STM transformation.
compiler/modules.m:
Import the STM builtin module automatically if the module contains any
atomic goals.
compiler/assertion.m:
compiler/bytecode_gen.m:
compiler/clause_to_proc.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/code_util.m:
compiler/constraint.m:
compiler/cse_detection.m:
compiler/deep_profiling.m:
compiler/code_util.m:
compiler/delay_construct.m:
compiler/delay_partial_inst.m:
compiler/dep_par_conj.m:
compiler/dependency_graph.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/distance_granularity.m:
compiler/equiv_type_hlds.m:
compiler/erl_code_gen.m:
compiler/exception_analysis.m:
compiler/follow_code.m:
compiler/format_call.m:
compiler/goal_form.m:
compiler/goal_path.m:
compiler/goal_util.m:
compiler/granularity.m:
compiler/hlds_out.m:
compiler/implicit_parallelism.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/layout_out.m:
compiler/lco.m:
compiler/lookup_switch.m:
compiler/make_hlds_warn.m:
compiler/mark_static_terms.m:
compiler/mercury_to_mercury.m:
compiler/middle_rec.m:
compiler/ml_code_gen.m:
compiler/mode_constraint_robdd.m:
compiler/mode_constraints.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/mode_util.m:
compiler/ordering_mode_constraints.m:
compiler/pd_cost.m:
compiler/pd_util.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/prog_rep.m:
compiler/prog_type.m:
compiler/prop_mode_constraints.m:
compiler/rbmm.actual_region_arguments.m:
compiler/rbmm.add_rbmm_goal_info.m:
compiler/rbmm.condition_renaming.m:
compiler/rbmm.execution_path.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.region_transformation.m:
compiler/saved_vars.m:
compiler/simplify.m:
compiler/size_prog.m:
compiler/smm_common.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.indirect.m:
compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
compiler/structure_reuse.versions.m:
compiler/structure_sharing.analysis.m:
compiler/switch_detection.m:
compiler/unused_imports.m:
compiler/granularity.m:
compiler/granularity.m:
Conform to the changes above. Mostly this means handling the new
kind of goal.
compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/build_mode_constraints.m:
compiler/closure_analysis.m:
compiler/dead_proc_elim.m:
compiler/deforest.m:
compiler/follow_vars.m:
compiler/higher_order.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/loop_inv.m:
compiler/module_qual.m:
compiler/prog_util.m:
compiler/purity.m:
compiler/quantification.m:
compiler/store_alloc.m:
compiler/stratify.m:
compiler/tabling_analysis.m:
compiler/term_constr_build.m:
compiler/term_pass1.m:
compiler/term_traversal.m:
compiler/trailing_analysis.m:
Conform to the changes above. Mostly this means handling the new
kind of goal.
Switch syntax from clauses to disj.
runtime/mercury_stm.[ch]:
Implement the primitives needed by the STM transformation.
Add more debugging support to the existing primitives.
library/term.m:
Generalize get_term_context to work on terms of all kinds.
Estimated hours taken: 24
Branches: main
A first step towards rationalizing the parse tree representation of the
program. This step moves the information specific to each kind of item
into a structure specific to that kind of item.
In the short term, this allows us to express some old invisible invariants
as types. For example, we used to store general items in method definitions;
we now store clause-specific data there. This allows us to simplify some code
and eliminate some old "can't fail" tests.
In the longer term, this change will allow us to replace the old list of items
representation of the parse tree with a more structured representation,
which aggregates each kind of item differently. For example, we could
keep clause items in a list, but map module imports to the contexts
of their :- import_module items, which would allow us to detect duplicate
imports. We could also change the current three pass structure of the
parse tree to HLDS conversion step, where each pass processes *all* items,
to a much more flexible structure where each pass processes only what it
needs to process, new passes could be added much more simply, and in fact
the whole notion of a "pass" could be eliminated.
In a bunch of places, factor out some common code.
compiler/prog_item.m:
Make the change to the item type as above.
Rename the old item_pred_or_func as item_pred_decl (it already had
a field to indicate predicate or function) and item_pred_or_func_mode
as item_mode_decl. These names are much more consistent with the
other item names.
Eliminate the item_and_context type by moving the context into
the items themselves. In code that cares about contexts, this
makes it easier to match up each item with its context. In code
that doesn't care about contexts, this avoids the extra code
that would be required to discard the item_and_context wrapper.
compiler/prog_data.m:
Store item_clause_infos instead of items in method definitions.
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_pragma.m:
compiler/prog_io_typeclass.m:
Construct the new item structure when creating the parse tree.
Instead of constructing items and later attaching the context to them,
pass the context down, since we now need to include them in items.
Some old code was assuming that term.variables had no contexts;
update such code.
In prog_io_pragma.m, replace a single predicate that parsed all kinds
of pragmas, which spanned more than one thousand lines and whose
clauses had been interspersed with the clauses of other predicates,
with a predicate whose only job is to select which of a bunch of
pragma-type-specific parse predicates to invoke. Each of these
pragma-type-specific parse predicates corresponds to one of the
clauses of the old predicate. In that form, the predicates can be
declared det, even though the predicate as a whole is semidet
(since not all pragma names are valid). This actually exposed
an old bug; the case MaybeAttributes = error1(_) was not handled
in foreign_export_enum pragmas.
To make the diff easier to check, I left the predicates in the
original order of the clauses, even though that order does not
make sense (it does not group related pragmas together). I did
leave an XXX comment about this. The matter will be addressed
in a later diff. (A similar problem occurs in some of the other
modules in which I broke up very large predicates.)
compiler/prog_io_util.m:
Remove some stuff that the new item structure makes unnecessary.
compiler/make_hlds_passes.m:
compiler/add_class.m:
compiler/add_mode.m:
compiler/add_pragma.m:
compiler/add_solver.m:
Conform to the new item structure when converting it to HLDS.
Break up excessively large predicates.
compiler/prog_foreign.m:
Provide a function to return all supported foreign languages,
instead of requiring callers to call solutions to compute this list.
compiler/mercury_to_mercury.m:
Print out the new item structure.
Break up excessively large predicates.
Rename some predicates to avoid name collisions.
compiler/equiv_type.m:
compiler/hlds_module.m:
compiler/intermod.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/prog_mutable.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/state_var.m:
compiler/trans_opt.m:
Operate on the new item structure. Factor out code (usually tests)
where the new item structure makes this possible and desirable.
Turn if-then-elses into switches where this is desirable.
Build up large terms from named pieces instead of all at once.
Break up excessively large predicates.
In equiv_type.m, rename a predicate to clarify its function,
and add an XXX about a possible improvement in abstraction.
In modules.m, simplify the interface between some predicates
and their callers, turn some predicates into functions, and
make some code return error specifications instead of doing
raw printing of error messages. Note that this module still
has plenty of scope for improvement (I marked some with XXXs),
but that is for a later date.
In some cases, mark potential bugs with XXXs.
compiler/equiv_type_hlds.m:
Conform to the change in equiv_type.m.
library/term.m:
compiler/recompilation.check.m:
Move the function for getting the context out of a term from
recompilation.check.m to term.m, so it can be used from other modules.
(Also, adding such a function to the standard library is long overdue.)
NEWS:
Note the change to term.m.
Estimated hours taken: 1
Branch: main
library/term.m:
library/type_desc.m:
library/construct.m:
Move same_type/2 and find_functor/5 from module term into the interfaces of
type_desc and construct, respectively. Both are useful in custom pickling
and unpickling predicates.
NEWS:
Announce the change.
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.
Estimated hours taken: 20
Branches: main
Add support for deconstructing by functor number rather than name,
for use by write_binary.
library/deconstruct.m:
runtime/mercury_deconstruct.h:
runtime/mercury_deconstruct.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_ml_deconstruct_body.h:
Add predicates deconstruct.functor_number and
deconstruct.deconstruct.du, which returns a functor number
suitable for use by construct.construct rather than a functor
name.
library/construct.m:
library/term.m:
browser/term_rep.m:
extras/quickcheck/qcheck.m:
tests/valid/agc_unbound_typevars.m:
tests/valid/agc_unbound_typevars2.m:
Add a function get_functor_lex, which returns the lexicographic
functor number given an ordinal functor number.
Add equivalence types to make it clearer which ordering is
being used by which functor numbers.
Remove a C-ism: num_functors now fails rather than returning -1
for types without functors.
NEWS:
Document the new predicates and functions.
runtime/mercury_type_info.h:
runtime/mercury_builtin_types.c:
runtime/mercury_mcpp.h:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/type_ctor_info.m:
compiler/rtti_to_mlds.m:
compiler/opt_debug.m:
Add a field to MR_TypeCtorInfo which contains a mapping from
an ordinal functor number to a lexicographic functor number
which can be passed to construct.construct.
Bump MR_RTTI_VERSION.
tests/hard_coded/expand.m:
tests/hard_coded/expand.exp:
tests/hard_coded/expand.exp2:
tests/hard_coded/construct_test.m:
tests/hard_coded/construct_test.exp:
tests/hard_coded/construct_test_exist.m:
tests/hard_coded/construct_test_exist.exp:
Test cases.
Estimated hours taken: 24
Branches: main
Generate an XML representation of the du types in the current module.
The XML representation contains all the information about the type,
as well as associating with each type, data constructor and data field
any comments located near the comment.
The current strategy associates the comment starting on the same line
as the type declaration, and if there is none then the comment directly
above. At a later date, this strategy needs to be made more flexible.
This required two main changes to the compiler.
Change one was to associate with a term.variable the context
of that variable.
Then the constructor and constructor_arg types had to have their
context recorded.
compiler/xml_documentation.m:
Add a pass that generates an XML documentation
for the du types in the current module.
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/options.m:
Call the xml_documentation phase and stop afterwards.
compiler/error_utils.m:
Add a utitily predicate for reporting errors where
a file is unable to be opened.
library/term.m:
Add the term.context to term.variables.
Remove the backwards mode of var_list_to_term_list as it
no longer works.
Make the predicate version of term_list_to_var_list
semidet as we can no longer use the backwards version
var_list_to_term_list.
NEWS:
Mention the changes to the term module.
library/parser.m:
Fill in the term.context of term.variables while parsing.
compiler/prog_data.m:
Add the context to the constructor and constructor_arg types.
compiler/prog_io.m:
Fill in the context fields in the constructor and constructor_arg
types.
compiler/add_clause.m:
compiler/prog_io.m:
compiler/prog_io_typeclass.m:
compiler/typecheck.m:
Call the correct version of term_list_to_var_list,
to deal with the fact that we removed the reverse
mode of var_list_to_term_list.
compiler/notes/compiler_design.html:
doc/user_guide.texi:
Document the new module.
compiler/add_clause.m:
compiler/det_util.m:
compiler/fact_table.m:
compiler/hlds_out.m:
compiler/inst_graph.m:
compiler/intermod.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/prog_ctgc.m:
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
compiler/prog_io_util.m:
compiler/prog_util.m:
compiler/state_var.m:
compiler/superhomogeneous.m:
compiler/switch_detection.m:
compiler/typecheck_errors.m:
library/term_io.m:
library/varset.m:
Handle the context in the term.variable structure.
compiler/add_type.m:
compiler/check_typeclass.m:
compiler/equiv_type.m:
compiler/hhf.m:
compiler/hlds_out.m:
compiler/inst_check.m:
compiler/make_tags.m:
compiler/mercury_to_mercury.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mode_util.m:
compiler/module_qual.m:
compiler/post_typecheck.m:
compiler/prog_io.m:
compiler/prog_mode.m:
compiler/prog_type.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/special_pred.m:
compiler/term_constr_build.m:
compiler/term_norm.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_proc.m:
compiler/untupling.m:
compiler/unused_imports.m:
Handle the context field in the constructor and constructor_arg
types.
compiler/check_hlds.m:
Add the xml_documentation module.
Estimated hours taken: 1
Branches: main
Various minor cleanups and syntax updates for the standard library.
There are no changes to any algorithms.
library/injection.m:
library/set.m:
library/sparse_bitset.m:
Use promise_equivalent_clauses where appropriate.
library/set_ordlist.m:
library/set_unordlist.m:
Convert these module to 4-space indentation:
Convert these module to 4-space indentation
library/*.m:
Convert some if-then-elses into switches.
Remove unnecessary module qualification - this is related
mainly to the breakup of std_util and the fact that on
the 0.13 branche we had two versions of the all-solutions
predicates.
Various other style cleanups.
vim/syntax/mercury.vim:
Highlight promise_equivalent_clauses appropriately.