polymorphism.nl:
Fix some bugs:
- I had forgotten to update the argmodes of the modified
procedures
- I was updating the argtypes and attempting to use there
old value. I fixed this by splitting the algorithm
into two passes.
- to compute the types of the arguments to a call,
apply the type mapping from the _caller_ not the callee.
Also improve efficiency in a couple of places.
hlds.nl:
Add some new access predicates required by polymorphism.nl.
list.nl:
Add a new predicate list__duplicate, which is used by polymorphism.nl.
typecheck.nl, type_util.nl:
Move the type_unify routines from typecheck.nl into type_util.nl,
since they're also needed by polymorphism.nl.
term.nl:
Export term__apply_rec_substitution_to_list, since it's needed
by polymorphism.nl.
- - - - - - - - - - - - - - - - - - - - - - - - -
mode_util.nl, type_util.nl:
Move some routines from mode_util.nl to type_util.nl, where they
really belong.
- - - - - - - - - - - - - - - - - - - - - - - - -
make_hlds.nl, code_util.nl, typecheck.nl:
Mark builtin predicates as "external" in make_hlds.nl,
rather than checking for them as a special case in typecheck.nl.
- - - - - - - - - - - - - - - - - - - - - - - - -
prog_io.nl, hlds.nl, typecheck.nl:
For documentation purposes, define equivalent types `tvar',
`tvarset', `tsubst' for type variables, type varsets, and
type substitutions.
- - - - - - - - - - - - - - - - - - - - - - - - -
mercury_compile.pp, options.nl:
Change the handling of the --dump-hlds option so that you can
now dump the HLDS after any of the 12 HLDS transformation passes.
- - - - - - - - - - - - - - - - - - - - - - - - -
make_hlds.nl:
Report an error if there are clauses for an imported predicate.
- - - - - - - - - - - - - - - - - - - - - - - - -
io.nu.nl:
Add a new predicate r/1 which is like run/1 except that
you pass it a string rather than a list of atoms.
So now you can do
$ mercury_compile.debug
Mercury Interpreter 0.1
NU-Prolog 1.6.4
1?- r("mc -options blah blah blah").
llds.nl, *.nl:
Change field(int, rval, int) to field(int, rval, rval), so
that the field number can be calculated at runtime
(We need this for predicate closures).
Also, remove the incr_hp(int) instruction and replace it
with a heap_alloc(rval) rval.
(We need to determine the space allocated at runtime
for predicate closures, and also we want it to be an rval
not an instruction so we can get conservative garbage collection
to work.)
unify_gen.nl:
More work for higher-order predicate closures.
std_util.nl:
Recode `bool__and' and `bool__or' more elegantly.
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.
frameopt, opt_util, code_uti, middle_recl:
Added comprehensive optimization of detstack frame manipulation
instructions, replacing the earlier limited one. In the process,
moved a function from middle_rec to code_util, since frameopt
could also use it.
switch_gen:
Specialized the handling of switches with two cases to avoid
pipeline breaks.
std_util:
Added boolean and and or predicates.
set:
Added membership enquiry function.
mercury_compile:
Commented out a manual garbage collection point that was causing
trouble.
list.nl:
Remove the backward mode for list__length, so that we can
implement it using pure Mercury code.
We weren't using the backward mode anyway.
mercury_builtin.nl, std_util.nl:
Add some more "external" declarations.
prog_io.nl:
Move join_error/3 to typecheck.nl.
Makefile.common, Makefile.mercury:
Add a couple of things for compiling the compiler to .o files.
prog_io.nl:
Fix bug in DCG expansion of ( { ... } -> { ... } ; ... ).
prog_io.nl, hlds.nl, make_hlds.nl,
nc_builtin.nl, np_builtin.nl, swi_builtin.nl:
Implement a new `:- external(Pred/Arity)' declaration,
for predicates which are defined elsewhere, e.g. in some
other language.
int.nl, io.nl, std_util.nl, string.nl:
Use the new `external' declaration.
llds.nl:
Ouput the module name as mercury__xxx_module rather than
just xxx_module. (This avoids a name clash between code/io.mod
and compiler/io.mod).
typecheck.nl:
Avoid using implied modes.
Makefile.mercury:
Override the MERCURY_LIB_OBJS variable when invoking ml.
This avoids some bootstrapping problems.
Also, add mercury_compile.nu.
Makefile.common:
Bump NU-Prolog's -u option up to 2000 (8M), to avoid some memory
problems.
array.nl, bintree.nl, char.nl, dir.nl, globals.nl, list.nl, map.nl, modes.nl,
prog_util.nl, stack.nl, std_util.nl, string.nl, term.nl:
Avoid the use of implied modes.
code_info.nl, bimap.nl, make_hlds.nl, mercury_compile.nl,
mercury_to_mercury.nl, unify_proc.nl:
Fix determinism errors which had previously not been discovered
because of either implied modes or running out of memory.
(Note that I had to change the interface to bimap__lookup, since
it's not possible to make it bidirectional.)
code_util.nl, llds.nl, opt_debug.nl, value_number.nl:
Rename `operator' as `binary_op'.
hlds.nl, code_info.nl, unify_gen.nl, llds.nl, opt_debug.nl, switch_gen.nl:
*** Handle simple cases of higher-order pred terms. ***
(We don't yet handle taking the address of an overloaded
predicate or a predicate with multiple modes.
We don't handle closures. call/1 and call/N are not yet implemented.
This has not yet been tested.)
make_hlds.nl:
Modify the mode priority ordering so that semidet modes get
selected before det ones.
llds.nl:
Don't include the priority part of the mode number in the mangled
label name. *** Note: this will break some things! ***
mercury_compile.nl:
Move the NU-Prolog hacks into mercury_compile.nu.nl.
switch_gen.nl:
Fix a simple logic bug in handling the grab/slap of the code_info.
prog_io.nl, builtins.nl, int.nl:
Fix bugs and omissions with handling of the new arithmetic operators.
prog_io.nl:
As a quick hack, strip off calls to io__gc_call
(this avoids spurious error messages which are due to
the fact that we don't get mode analysis right in those cases).
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...
Makefile:
added entries for the new files.
codegen.nl:
This is really a new file (well almost). Contains the top level
of the code generator.
doit.nl:
Added the new files (and mode_error which was missing).
hlds.nl:
Changed the type declaration for unifications to use arg_mode
instead of mode.
hlds_out.nl:
Small change for the above alteration.
llds.nl:
Minor changes.
mode_util.nl:
Change the modes to arg_modes for unifications.
modes.nl:
ditto.
std_util.nl:
more assoc_list predicates...
term.nl:
Fixed a small but nasty by in term__vars_list (and don't forget
Fergus that you owe me a chocolate biscuit).
prog_io.nl, hlds.nl:
Add `arity' as an alias for `int'.
map.nl:
Improve the code for map__merge.
Add map__optimize.
Work-around a bug in the determinism analysis.
make_hlds.nl:
Use map__optimize rather than bintree__balance.
codegen.nl, std_util.nl:
Add a call to `semidet_succeed' in codegen.nl, and
implement that pred in std_util.nl, in an
attempt to suppress a determinism warning.
(The attempt failed, due to an as-yet unknown bug in
the determinism analysis.)
hlds.nl, modes.nl, mode_util.nl, mercury_to_mercury.nl, undef_modes.nl.
Replace the inst table with four tables, one for
user-defined insts, and three for compiler-generated
insts. Modify all the routines dealing with insts to
handle this. Change `inst_merge' in modes.nl to return
a compiler-generated recursive inst if necessary.
term_io.nl:
Fix bugs caused by recent changes to io__xxx_op preds.
Makefile, apply_sed_script, fix_errs.sed:
A quick hack to avoid the spurious determinism errors.
term_io.nl, char.nl, string.nl:
Add a few additional utility preds to string.nl.
Add some more preds to handle quoting to term_io.nl.
Remove the stuff which handled quoting in char.nl.
bintree.nl, map.nl, std_util.nl:
Use assoc_list/2 rather than list(pair(...)).
hlds.nl, det_analysis.nl:
Make instmap delta an association list rather than a map;
fix the determinism analysis to use that.
Makefile, doit.nl:
Add det_analysis.nl and builtins.nl.
builins.nl:
Fix bug.
codegen.nl:
Make unimplemented cases abort rather than just fail.
modes.nl, typecheck.nl:
Fix bugs introduced by the performance fixes.
(I wonder if the performance problem will come back now? ;-)
options.nl, toplevel.nl:
Add a new pred `maybe_flush_output' and use it in toplevel.nl.
mercury_to_mercury.nl:
New file: converts the prog_io data structure back into Mercury source
code.
term_io.nl:
Export mercury_quote_string for use by mercury_to_mercury.nl.
Makefile, doit.nl:
Add mercury_to_mercury.
options.nl, toplevel.nl:
Add a new option to save the interface of a module to a `.int' file,
using mercury_to_mercury.
Makefile:
Modify the rule for the `clean' target so that it removes `.int' files.
mercury_builtin.nl:
Fix the module name.
std_util.nl:
Suppress warnings from nit.
modes.nl:
New file. At the moment it just checks for undefined modes and
undefined insts.
Makefile, doit.nl:
Add new files modes.nl and prog_util.nl.
term.nl:
Add term__var_to_int.
toplevel.nl:
Call the mode checker.
prog_io.nl, make_hlds.nl, hlds.nl:
Allow for the possibility of abstract `inst' definitions,
just like abstract type definitions. Currently they
are allowed for in the data structure, but they aren't
parsed correctly, and the utilities in hlds.nl don't handle
them that well.
hlds.nl:
Move `unqualify_name' to prog_util.nl.
make_hlds.nl:
Move `split_types_and_modes' to prog_util.nl.
mercury_to_goedel.nl, toplevel.nl:
Move the equivalence type expansion code to prog_util.nl.
builtin.nl, toplevel.nl:
Add a new module `builtin.nl' which gets automatically imported
into every module. In it, define the standard modes input,
output, etc., and various other stuff.
std_util.nl:
Move the defintion for \= to builtin.nl.
Remove the definition of ~=.
prog_io.nl:
Export parse_goal/2, since it's used by mercury_to_goedel.
mercury_to_goedel.nl:
Fix various type errors.
list.nl, int.nl, io.nl, codegen.nl, det_analysis.nl, llds.nl, hlds_out.nl:
Fix various syntax errors, typos and errors in type and mode
declarations discovered by mercury_compile.
typecheck.nl:
fix bug in error message code
Makefile:
remove pathname from NC definition
make_hlds.nl:
initialize the unify_context field.
std_util.nl, std_util.nu.nl:
move the implementation of solutions/2 from std_util to std_util.nu
(where it should have been in the first place).
typecheck.nl:
added handling of higher-order predicates and the builtin types
pred, pred(T), pred(T1, T2), etc.
hlds.nl:
added new field pred_name_index to the moduleinfo data structure
(needed for higher-order pred handling in typecheck.nl).
make_hlds.nl:
update the pred_name_index
make_hlds.nl:
detect and report as an error any attempts to define multiple
constructors for a single type with the same name and arity.
Makefile:
minor fixes.
hlds_out.nl:
fix type errors introduce when pred_mode_id was renamed as proc_id.
mercury_to_goedel.nl:
fix problems causes by modifications to prog_io.nl.
various places:
change to use the new builtin higher-order pred types.
Optimize for the common case of non-polymorphic types & predicates.
term.nl: Rename term__apply_substitution as term__apply_rec_substitution
and add a new term__apply_substitution for when you want
non-recursive application. Fix logic bug in
term__substitute_corresponding.
varset.nl: Fix logic bug in varset__merge.
io.nu.nl: Fix typo in error message.
term_io.nu.nl: Fix bug in the code used to work-around the NU-Prolog
getToken bug for empty strings.
prog_io.nl: Fix bug: the string "\+" should have been "\\+".
Also fixed LOTS of type errors (discovered by the typechecker,
hurray it now works!).
int.nl, list.nl, std_util.nl: Added pred & mode declarations for some
NU-Prolog predicates that we are using.
Added a couple of new preds to std_util.nl and added std_util.nu.nl.
Fixed some bugs in the typechecker, and improved error reporting
a bit.
Did a bit of work on memory management.
prog_out.nl: remove various bits of crud and clean it up a little.
hlds.nl: add some stuff needed by typecheck.nl
typecheck.nl: did a bit more work on this.
renamed module.nl as toplevel.nl and also rewrote it using stuff
from mercury_to_goedel.nl.