-------------------------------------------------------
Implement unique modes. We do not handle local aliasing yet, so this
is still not very useful, except for io__state. Destructive update is
not yet implemented. Also note that this really only implements
"mostly unique" variables that may be non-unique on backtracking - we
don't check that you don't backtrack over I/O, for example.
prog_io.m, mode_util.m, modes.m, inst_match.m:
Major changes to Handle unique modes.
mercury_to_mercury.m, polymorphism.m, prog_out.m, undef_modes.m:
Use `ground(Uniqueness)' rather than just `ground'.
compiler/*.m:
Fix compile errors now that unique modes are enforced: add a
few calls to copy/2, and comment out lots of unique mode
declarations that caused problems.
typecheck.m, mode_info.m:
Hack around the use of unique modes, which doesn't work
because we don't allow local aliasing yet: make the insts
`uniq_type_info' and `uniq_mode_info' not unique at all,
and add a call to copy/2 when extracting the io_state from
type_info or mode_info.
-------------------------------------------------------
Plus a couple of unrelated changes:
hlds.m:
Change the modes for the special predicates from `ground -> ground'
to `in', so that any error messages that show those modes
come out looking nicer.
Add a new shared_inst_table for shared versions of user-defined
insts.
mercury_to_goedel.m:
Use string__is_alnum_or_underscore.
context of the unification from which call was made. We we use this to generate
significantly better error messages. (There should be no more messages of the
form "call to __Unify__(blah blah blah) can fail".) Most of the files are
changed just to reflect this.
An unrelated change in det_analysis is that we now ensure the absence of
cycles by modifying the new inferred determinism in the light of the old
one, ensuring that any changes are monotonic.
In hlds_out, inhibit the printing of pseudo-imported predicates (unifications)
since nobody cares about them except sometimes Fergus.
unifications. See the comments at the top of unify_proc.m for
details of how it's done.
hlds.m:
Add new export statuses `pseudo_imported' and `pseudo_exported'
to handle unification predicates, which can now have complicated
modes.
code_gen.pp, code_info.m, common.m, constraint.m, cse_detection.m,
follow_code.m, follow_vars.m, hlds_out.m, inlining.m, live_vars,
make_hlds.m, mercury_compile.pp, modes.m, store_alloc.m,
switch_detection.m:
Handle pseudo_imported predicates.
modes.m, constraint.m:
Change modecheck to return an updated module_info, since
modechecking may insert new entries into the unify_requests
queue in the module_info. Make sure that modechecking
never inserts requests into the unify_requests queue
for code that has mode errors (or needs rescheduling).
call_gen.m, polymorphism.m:
Move duplicated code into unify_proc.m.
clause_to_proc.m:
Add new predicate clauses_to_proc for use by unify_proc.m.
unify_proc.m:
Implement complicated unifications with complicated modes.
hlds.m and lots of other files:
Change the type of the first two arguments of unify/5 in
hlds__goal_expr from `term, term' to `var, unify_rhs'
where unify_rhs is given by
:- type unify_rhs
---> var(var)
; functor(const, list(var))
; lambda_goal(list(var), hlds__goal).
This change was for two reasons: firstly, it simplifies the
code in a lot of places, and secondly, it is a step towards
implementing lambda closures and higher-order predicates
properly.
switch_detection:
Detect partial switches, i.e. disjunctions in which not all
disjuncts form part of the switch. We give preference to full
switches, and failing that, to partial switches with the most arms.
peephole, opt_util:
Fixed the code for the introduction of succeed_discard.
code_gen:
Fixed spelling error in error message.
code_info:
Made error message somewhat more informative.
cse_detection:
Removed debugging code; we now always repeat cse detection after
finding some cses.
det_analysis:
Added some comments.
value_number, vn_debug, vn_flush:
Changes to make debugging easier.
prog_io, hlds: Added the functor "multidet" to the type determinism.
Added types and predicates to relate determinism to its
two components, can_fail and soln_count.
Removed the functor "unspecified" from the type determinism,
substituting maybe(determinism) for determinism in proc_info.
Replaced the type category with the type code_model,
and added predicates to compute it from determinism.
det_analysis: Redone the analyses to work with determinism, not category
(or code_model). This should enable programmers to write
their own erroneous (and failure) predicates.
other files: Use the new and renamed types and access predicates.
compiler/*:
Add copyright messages.
Change all occurences of *.nl in comments to *.m.
compiler/mercury_compile.pp:
Change the output to the .dep files to use *.m rather than *.nl.
(NOTE: this means that `mmake' will not work any more if you
call your files *.nl!!!)
*.nl:
Replace all occurrences of `not(Vars, Goal)' with just
plain `not(Goal)'.
type_util.nl, switch_gen.nl:
Higher-order pred types are not user-defined types.
Add a `predtype' type category for them.
call_gen.nl:
Change call_closure/2 to call_closure/3 (with liveinfo).
Plus a little bit of random hacking.
det_analysis.nl:
Fix an old "XXX": implement `no_output_vars' properly.
This required threading InstMaps through everything.
modes.nl, inst_match.nl:
Move some predicates from modes.nl into a new module, inst_match.nl,
so that they can be used by det_analysis.nl.
hlds.nl, mode_util.nl:
Do some more work for propagating type info into modes.
hlds_out.nl:
Some minor cosmetic changes.
hlds.nl, prog_io.nl:
Add a couple of comments.
switch_detection.nl:
Search through nested conjunctions, which can be created as
a result of mode analysis.
typecheck.nl, unify_proc.nl:
Fix some determinism errors.
prog_io.nl:
Remove some stuff put in by squirrell:
don't recognize `=>', `<=', or `<=>' in DCG goals.
They don't make sense in DCG goals.
term.nl:
In term__create_var, use bit reversals rather than random numbers
to ensure that the binary trees remain balanced.
call_gen.nl:
For polymorphic unifications, generate a call to fatal_error().
code_gen.nl, hlds.nl, make_hlds.nl, modes.nl, unify_proc.nl:
Move the unify_request data structure from code_info to the HLDS,
and move the unify_request handling from code_gen.nl to modes.nl.
This is because we now generate HLDS code rather than LLDS code
for complicated unifications.
code_util.nl, hlds_out.nl:
Do some special name mangling for =/2.
float.nl, typecheck.nl, undef_types.nl, term.nl, hlds.nl:
Until we implement `float' properly, define it as an abstract type
in float.nl.
hlds.nl, make_hlds.nl:
Rename `local_pred, imported_pred, exported_pred' to just
`local, imported, exported' since they also apply to types, etc.,
not just to preds.
mercury_compile.pp, mercury_to_goedel.nl, prog_util.nl:
Replace to goedel__ prefixes in prog_util.nl with prog_util__.
std_util.nl:
Change the code for semidet_succeed to avoid determinism warning.
switch_detection.nl:
Improve switch detection by handling chained unifications.
We now detect switches in cases like the following:
( X = X1, X1 = a, ... ; X = X2, X2 = b, ... )
backtracked over contains a construction unification or a
non-builtin call. Add code to save/restore the heap pointer
in one or two places where this was missing, e.g. semidet disjunctions.
Change switch/2 into switch/3 so that we can store the `local
determinism' of the switch there, rather than in the goal_info.
Fix code generation for semidet/nondet switches, so that
we omit the test for the last case if the switch is locally
det.
switch_detection.nl:
Do (local) determinism analysis to work out whether
each switch is deterministic or semidetermistic, based
on whether it covers all the possible cases or not.
list.nl:
Fix a bug in the type declaration for same_length/2.
Should be same_length(T1, T2), not same_length(T, T)!
goal_info, by adding a new predicate `recompute_instmap_delta' in
mode_util.nl to recompute this info. A couple of minor fixes to
code_gen.nl. Renamed `detect_liveness_is_atomic' as `goal_is_atomic'
and moved it to hlds.nl.
switch_detection.nl:
Fix up the determinism annotation on deconstruction unifications
which are made deterministic when the test is moved into the
switch. This means that the tests in a switch no longer cause
duplicate code to get generated.
switch_detection.nl:
Minor efficiency improvement.
call_gen.nl, hlds.nl, make_hlds.nl, modes.nl, det_analysis, followvars,
code_gen.nl:
Add an extra field to record the determinism for
deconstruct(...) and complicated_unify(...) unifications.
modes.nl, mode_util.nl:
Handle free-free unifications as assignments, not as
complicated_unifies.
Add mode_is_unused to mode_util.nl so we can detect them.
call_info.nl:
Fix bug in call_info__cons_id_to_tag.
bintree.nl, map.nl, varset.nl:
Remove map__search_insert; it's not needed and it's not
really useful.
bintree.nl:
Fix determinism problem in bintree__from_list_2.
options.nl, det_analysis.nl, make_hlds.nl:
Add options to suppress determinism warnings.
det_analysis.nl, hlds.nl, modes.nl:
Allow the delta-instmap to be `unreachable'.
hlds_out.nl:
Output the delta-instmap.
Output conjunctions differently in verbose mode.
llds.nl:
Fix determinism problem.
Change GOTO(LABEL(...)) into GOTO_LABEL(...) which can be
more efficient.
map.nl:
Add map__overlay/3.
typecheck.nl, modes.nl, mode_errors.nl, options.nl, hlds_out.nl.
Split the old `debug' option into debug-types and debug-modes.
Change the default for the `modecheck' option to `yes'.
Add a new verbose-dump-hlds option, and use that instead
of the very-verbose option in hlds_out.nl.
mode_util.nl:
Export mode_get_insts/4.
Add instmap_lookup_var (moved from modes.nl).
Add apply_instmap_delta.
modes.nl, term.nl, prog_util.nl:
Add determinism annotations.
term.nl, prog_io.nl:
Fix bugs in when declarations.
std_util.nl, prog_io.nl:
Add a maybe(T) type to std_util.nl.
Rename the maybe(T) type in prog_io.nl as maybe1(T).
mercury_builtin.nl:
Use det_pred(...), semidet_pred(...), nondet_pred(...)
rather than call_pred(...) for the higher-order predicate modes.
prog_io.nl, io.nl, varset.nl, etc.
Add determinism annotations.
hlds.nl, make_hlds.nl, LOTS of other files:
Reorganize the way the predicate table works.
Make hlds.nl a bit more modular.
Change call/4 to call/5.
Remove all/2 from the hlds.
Changed pred_id to an integer.
Added pred_call_id which is similar to the old pred_id.
Makefile:
Add a rule for creating *.hlds_dump.
array.nl:
Fix determinism error.
det_analysis.nl:
Fix a bug in printing determinism warnings.
fix_errors.sed:
Modify this so it allows all the `inferred nondet' determinism
errors but none of the `inferred semidet' ones.
llds.nl:
Rename llds__pred_mode_id as llds__proc_id.
mode_errors.nl:
Finally got around to implementing Zoltan's suggestions
about the error messages from the mode analysis.
If an error occurs in a conjunction, only one error message
is printed out - the first error which doesn't relate to
a head unification.
modes.nl:
Handle X = f(X) properly. NB: determinism analysis and code
generation still get it wrong!
undef_modes, undef_insts:
I've broken the error message code, since it's not easy
to print pred_ids. I just changed it so that it didn't
print the pred_ids out. Should fix this properly at some stage...
followvars.nl:
Do some work on this. It still doesn't compile, let
alone work.
mode_info.nl:
Fix bug in last change.
hlds_out.nl:
A couple of very minor fixes.
switch_detection.nl:
Fix a bug so that 2nd-argument indexing works.
hlds.nl:
Add proc_info_get_initial_instmap.
Add some determinism declarations.
switch_detection.nl:
Bug fix: call proc_info_get_initial_instmap to initialize the instmap,
rather than initializing it to be empty (all vars free).
Also look for switches for every input variable, not just when
the input variable's final inst is bound(...) since the mode
analysis may produce ground rather than bound(...) even for
a switch. (Or was that just the result of the two unfixed
bugs in the mode analysis???? Should this change be reversed?)
Also don't process imported predicates.
Also added some determinism declarations.
hlds_out.nl, mercury_to_mercury.nl:
Fix bugs in the output.
make_hlds.nl:
Bug fix - some goals in a conjunction were in the wrong order.
(Didn't cause a mode error because Mercury would have automatically
reordered it to be correct!)
modes.nl:
The code for inst_matches_initial(ground, bound(...)) was wrong.
Mark it with an XXX and some comments.
fix_errors.sed:
Supress warnings about missing determinism declarations.
builtins.nl, hlds.nl, det_analysis.nl, hlds_out.nl:
Change case/3 to case/2.
char.nl, mode_info.nl:
Add some determinism declarations.
hlds.nl:
Change the `liveness' field to a `delta_liveness' field.
Add goal_to_conj_list/2 and goal_to_disj_list/2.
hlds_out.nl:
Export hlds_out__write_goal.
make_hlds.nl:
Warn about missing determinism annotations.
mercury_to_mercury.nl, hlds_out.nl:
Fix the problem where determinism annotations were
not being output correctly for zero-arity predicates
in interface files.
mercury_to_mercury.nl, mode_errors.nl:
Remove mercury_output_hlds_goal (it's been replaced by
hlds_out__write_goal).
parser.nl:
Minor change.
switch_detection.nl:
Fix this. It now works!
toplevel.nl:
Call switch_detection.nl.
Makefile, doit.nl:
Add switch_detection.nl.
modes.nl, mode_errors.nl, delay_info.nl, mode_info.nl, undef_modes.nl:
Break modes.nl up into separate modules.
toplevel.nl (plus LOTS of other files):
Change the way module imports are handled. Fix the resulting missing
import problems found in most of the modules.
mode_util.nl:
Add predicate inst_is_bound_to_functors/3.
switch_detection.nl:
New file. Still very incomplete.
meta.nl:
Remove. This file was old junk.