Estimated hours taken: 6
Fix various invasions of the user's namespace by `mercury_builtin.m',
by splitting mercury_builtin.m into two modules, called builtin.m and
private_builtin.m, and ensuring that the latter is imported as if
by `:- use_module' rather than `:- import_module'.
library/builtin.m:
library/private_builtin.m:
Split mercury_builtin.m into two modules, builtin.m,
which contains stuff intended to be public,
and private_builtin.m, which contains implementation
details that are not supposed to be public.
library/mercury_builtin.m:
Add a comment saying that this module is no longer used, and
should eventually be removed. I have not removed it yet, since
that would prevent bootstrapping with the current compiler. It
will be removed as a seperate change later, once all the
changes have propagated.
compiler/prog_util.m:
Change the definition of mercury_private_builtin_module/1 and
mercury_public_builtin_module so that instead of automatically
importing mercury_builtin.m as if by `import_module', the
copiler will now automatically import builtin.m as if by
`import_module' and private_builtin.m as if by `use_module'.
compiler/polymorphism.m:
Change a call to mercury_private_builtin_module/1 for
unsafe_promise_unique to instead call mercury_public_builtin_module/1.
compiler/unify_proc.m:
Avoid hard-coding "mercury_builtin" by instead
calling one of mercury_{private,public}_builtin_module/1.
runtime/mercury_type_info.[ch]:
library/term.m:
library/std_util.m:
compiler/code_util.m:
Change a few hard-coded instances of "mercury_builtin"
to "builtin" or "private_builtin" as appropriate.
runtime/mercury_trace_util.c:
runtime/mercury_trace_internal.c:
library/prolog.m:
compiler/*.m:
Update comments that refer to "mercury_builtin" to instead
refer to either "builtin" or "private_builtin".
doc/Mmakefile:
Don't include the interface to private_builtin.m in the
library reference manual.
tools/bootcheck:
Add `-p'/`--copy-profiler' option. This is needed to get
the above changes to bootstrap.
tools/test_mercury:
Pass `-p' to tools/bootcheck.
tests/term/*.trans_opt_exp:
s/mercury_builtin/builtin/g
Estimated hours taken: 25
A re-work of check_typeclass.m. Now, rather than the ad-hoc approach of
checking each method of each instance declaration for *exact* type and mode
correctness, we generate a new predicate that gets inserted into the HLDS.
This predicate is checked for type, mode, uniqueness and determinism
correctness in the appropriate compiler pass.
As a consequence, the check_typeclass pass now has to come before typecheck.m.
Previously, it was the final semantic analysis pass because it had to use
type, mode, uniqueness and determinism information. The new approach does not
need that information to be available.
This has the following user-visible improvements:
- constraints on class methods are now checked properly. An
instance's implementation of a method may be less constrained.
(Previously, these constraints weren't even checked at all. Oops).
- a method implementation may be more polymorphic than expected
- implied modes will be used for methods if necessary
This is a much more robust approach (and it co-incides with the typeclass
paper ;-) ).
compiler/check_typeclass.m:
Introduce the auxiliary predicate for the instance method. As an
optimisation, do not introduce the predicate if the implementation
given is an *exact* match (in terms of types, modes and determinism).
compiler/mercury_compile.m:
Put the check_typeclass pass before typechecking.
compiler/type_util.m:
Change type_list_matches_exactly to
type_and_constraint_list_matches_exactly since check_typeclass is
also responsible for checking constraints on method implementations.
(This is only used in the optimisation mentioned above).
Estimated hours taken: 12
Fix some bugs in the handling of "non-simple" type class constraints
(ones for which the types being constrained are not just type variables).
compiler/prog_io_typeclass.m:
Ensure that constraints on type class declarations must be "simple".
This is needed the ensure termination of type checking.
(We already did this for instance declarations, but not for
superclass constraints on type class declarations.)
compiler/prog_data.m:
Document the invariant that the types in a type class constraint
must not contain any information in their term__context fields.
compiler/type_util.m:
compiler/equiv_type.m:
compiler/polymorphism.m:
compiler/prog_io_typeclass.m:
Enforce the above-mentioned invariant.
compiler/typecheck.m:
Allow the declared constraints to be a superset of the
inferred constraints.
When performing context reduction, eliminate declared
constraints at each step rather than only at the end.
Remove declared constraints and apply superclass rules
before applying instance rules.
When applying instance rules, make sure that it is a type
error if there is no matching instance rule for a ground
constraint.
If context reduction results in an error, restore the
original type assign set, to avoid repeating the same
error message at every subsequent call to perform_context_reduction.
compiler/check_typeclass.m:
Change the way we superclass conformance for instance declarations
to take advantage of the new "DeclaredConstraints" argument to
typecheck__reduce_context_by_rule_application.
Estimated hours taken: 50
Add support for nested modules.
- module names may themselves be module-qualified
- modules may contain `:- include_module' declarations
which name sub-modules
- a sub-module has access to all the declarations in the
parent module (including its implementation section).
This support is not yet complete; see the BUGS and LIMITATIONS below.
LIMITATIONS
- source file names must match module names
(just as they did previously)
- mmc doesn't allow path names on the command line any more
(e.g. `mmc --make-int ../library/foo.m').
- import_module declarations must use the fully-qualified module name
- module qualifiers must use the fully-qualified module name
- no support for root-qualified module names
(e.g. `:parent:child' instead of `parent:child').
- modules may not be physically nested (only logical nesting, via
`include_module').
BUGS
- doesn't check that the parent module is imported/used before allowing
import/use of its sub-modules.
- doesn't check that there is an include_module declaration in the
parent for each module claiming to be a child of that parent
- privacy of private modules is not enforced
-------------------
NEWS:
Mention that we support nested modules.
library/ops.m:
library/nc_builtin.nl:
library/sp_builtin.nl:
compiler/mercury_to_mercury.m:
Add `include_module' as a new prefix operator.
Change the associativity of `:' from xfy to yfx
(since this made parsing module qualifiers slightly easier).
compiler/prog_data.m:
Add new `include_module' declaration.
Change the `module_name' and `module_specifier' types
from strings to sym_names, so that module names can
themselves be module qualified.
compiler/modules.m:
Add predicates module_name_to_file_name/2 and
file_name_to_module_name/2.
Lots of changes to handle parent module dependencies,
to create parent interface (`.int0') files, to read them in,
to output correct dependencies information for them to the
`.d' and `.dep' files, etc.
Rewrite a lot of the code to improve the readability
(add comments, use subroutines, better variable names).
Also fix a couple of bugs:
- generate_dependencies was using the transitive implementation
dependencies rather than the transitive interface dependencies
to compute the `.int3' dependencies when writing `.d' files
(this bug was introduced during crs's changes to support
`.trans_opt' files)
- when creating the `.int' file, it was reading in the
interfaces for modules imported in the implementation section,
not just those in the interface section.
This meant that the compiler missed a lot of errors.
library/graph.m:
library/lexer.m:
library/term.m:
library/term_io.m:
library/varset.m:
compiler/*.m:
Add `:- import_module' declarations to the interface needed
by declarations in the interface. (The previous version
of the compiler did not detect these missing interface imports,
due to the above-mentioned bug in modules.m.)
compiler/mercury_compile.m:
compiler/intermod.m:
Change mercury_compile__maybe_grab_optfiles and
intermod__grab_optfiles so that they grab the opt files for
parent modules as well as the ones for imported modules.
compiler/mercury_compile.m:
Minor changes to handle parent module dependencies.
(Also improve the wording of the warning about trans-opt
dependencies.)
compiler/make_hlds.m:
compiler/module_qual.m:
Ignore `:- include_module' declarations.
compiler/module_qual.m:
A couple of small changes to handle nested module names.
compiler/prog_out.m:
compiler/prog_util.m:
Add new predicates string_to_sym_name/3 (prog_util.m) and
sym_name_to_string/{2,3} (prog_out.m).
compiler/*.m:
Replace many occurrences of `string' with `module_name'.
Change code that prints out module names or converts
them to strings or filenames to handle the fact that
module names are now sym_names intead of strings.
Also change a few places (e.g. in intermod.m, hlds_module.m)
where the code assumed that any qualified symbol was
fully-qualified.
compiler/prog_io.m:
compiler/prog_io_goal.m:
Move sym_name_and_args/3, parse_qualified_term/4 and
parse_qualified_term/5 preds from prog_io_goal.m to prog_io.m,
since they are very similar to the parse_symbol_name/2 predicate
already in prog_io.m. Rewrite these predicates, both
to improve maintainability, and to handle the newly
allowed syntax (module-qualified module names).
Rename parse_qualified_term/5 as `parse_implicit_qualified_term'.
compiler/prog_io.m:
Rewrite the handling of `:- module' and `:- end_module'
declarations, so that it can handle nested modules.
Add code to parse `include_module' declarations.
compiler/prog_util.m:
compiler/*.m:
Add new predicates mercury_public_builtin_module/1 and
mercury_private_builtin_module/1 in prog_util.m.
Change most of the hard-coded occurrences of "mercury_builtin"
to call mercury_private_builtin_module/1 or
mercury_public_builtin_module/1 or both.
compiler/llds_out.m:
Add llds_out__sym_name_mangle/2, for mangling module names.
compiler/special_pred.m:
compiler/mode_util.m:
compiler/clause_to_proc.m:
compiler/prog_io_goal.m:
compiler/lambda.m:
compiler/polymorphism.m:
Move the predicates in_mode/1, out_mode/1, and uo_mode/1
from special_pred.m to mode_util.m, and change various
hard-coded definitions to instead call these predicates.
compiler/polymorphism.m:
Ensure that the type names `type_info' and `typeclass_info' are
module-qualified in the generated code. This avoids a problem
where the code generated by polymorphism.m was not considered
type-correct, due to the type `type_info' not matching
`mercury_builtin:type_info'.
compiler/check_typeclass.m:
Simplify the code for check_instance_pred and
get_matching_instance_pred_ids.
compiler/mercury_compile.m:
compiler/modules.m:
Disallow directory names in command-line arguments.
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/modules.m:
Add a `--make-private-interface' option.
The private interface file `<module>.int0' contains
all the declarations in the module; it is used for
compiling sub-modules.
scripts/Mmake.rules:
scripts/Mmake.vars.in:
Add support for creating `.int0' and `.date0' files
by invoking mmc with `--make-private-interface'.
doc/user_guide.texi:
Document `--make-private-interface' and the `.int0'
and `.date0' file extensions.
doc/reference_manual.texi:
Document nested modules.
util/mdemangle.c:
profiler/demangle.m:
Demangle names with multiple module qualifiers.
tests/general/Mmakefile:
tests/general/string_format_test.m:
tests/general/string_format_test.exp:
tests/general/string__format_test.m:
tests/general/string__format_test.exp:
tests/general/.cvsignore:
Change the `:- module string__format_test' declaration in
`string__format_test.m' to `:- module string_format_test',
because with the original declaration the `__' was taken
as a module qualifier, which lead to an error message.
Hence rename the file accordingly, to avoid the warning
about file name not matching module name.
tests/invalid/Mmakefile:
tests/invalid/missing_interface_import.m:
tests/invalid/missing_interface_import.err_exp:
Regression test to check that the compiler reports
errors for missing `import_module' in the interface section.
tests/invalid/*.err_exp:
tests/warnings/unused_args_test.exp:
tests/warnings/unused_import.exp:
Update the expected diagnostics output for the test cases to
reflect a few minor changes to the warning messages.
tests/hard_coded/Mmakefile:
tests/hard_coded/parent.m:
tests/hard_coded/parent.child.m:
tests/hard_coded/parent.exp:
tests/hard_coded/parent2.m:
tests/hard_coded/parent2.child.m:
tests/hard_coded/parent2.exp:
Two simple tests case for the use of nested modules with
separate compilation.
Estimated hours taken: 0.75
library/*.m:
compiler/*.m:
Undo Zoltan's bogus update of all the copyright dates.
The dates in the copyright header should reflect the years
in which the file was modified (and no, changes to the
copyright header itself don't count as modifications).
Estimated hours taken: 500 or so
This change implements typeclasses. Included are the necessary changes to
the compiler, runtime and library.
compiler/typecheck.m:
Typecheck the constraints on a pred by adding constraints for each
call to a pred/func with constraints, and eliminating constraints
by applying context reduction.
While reducing the constraints, keep track of the proofs so that
polymorphism can produce the tyepclass_infos for eliminated
constraints.
compiler/polymorphism.m:
Perform the source-to-source transformation which turns code with
typeclass constraints into code without constraints, but with extra
"typeclass_info", or "dictionary" parameters.
Also, rather than always having a type_info directly for each type
variable, sometimes the type_info is hidden inside a typeclass_info.
compiler/bytecode*.m:
Insert some code to abort if bytecode generation is used when
typeclasses are used.
compiler/call_gen.m:
Generate code for a class_method_call, which forms the body of a class
method (by selecting the appropriate proc from the typeclass_info).
compiler/dead_proc_elim.m:
Don't eliminate class methods if they are potentially used outside
the module
compiler/hlds_data.m:
Define data types to store:
- the typeclass definitions
- the instances of a class
- "constraint_proof". ie. the proofs of redundancy of a
constraint. This info is used by polymorphism to construct the
typeclass_infos for a constraint.
- the "base_tyepclass_info_constant", which is analagous the
the base_type_info_constant
compiler/hlds_data.m:
Define the class_method_call goal. This goal is inserted into the
body of class method procs, and is responsible for selecting the
appropriate part of the typeclass_info to call.
compiler/hlds_data.m:
Add the class table and instance table to the module_info.
compiler/hlds_out.m:
Output info about base_typeclass_infos and class_method_calls
compiler/hlds_pred.m:
Change the representation of the locations of type_infos from "var"
to type_info_locn, which is either a var, or part of a typeclass_info,
since now the typeclass_infos contain the type_infos for the type that
they constrain.
Add constraints to the pred_info.
Add constraint_proofs to the pred_info (so that typeclass.m can
annotate the pred_info with the reasons that constraints were
eliminated, so that polymorphism.m can in turn generate the
typeclass_infos for the constraints).
Add the "class_method" marker.
compiler/lambda.m:
A feable attempt at adding class ontexts to lambda expressions,
untested and almost certainly not working.
compiler/llds_out.m:
Output the code addresses for do_*det_class_method, and output
appropriately mangled symbol names for base_typeclass_infos.
compiler/make_hlds.m:
Add constraints to the types on pred and func decls, and add
class and instance declarations to the class_table and instance_table
respectively.
compiler/mercury_compile.m:
Add the check_typeclass pass.
compiler/mercury_to_mercury.m:
Output constraints of pred and funcs, and output typeclass and instance
declarations.
compiler/module_qual.m:
Module qualify typeclass names in pred class contexts, and qualify the
typeclass and instance decls themselves.
compiler/modules.m:
Output typeclass declarations in the short interface too.
compiler/prog_data.m:
Add the "typeclass" and "instance" items. Define the types to store
information about the declarations, including class contexts on pred
and func decls.
compiler/prog_io.m:
Parse constraints on pred and func declarations.
compiler/prod_out.m:
Output class contexts on pred and func decls.
compiler/type_util.m:
Add preds to apply a substitution to a class_constraint, and to
a list of class constraints. Add type_list_matches_exactly/2. Also
add typeclass_info and base_typeclass_info as types which should not
be optimised as no_tag types (seeing that we cheat a bit about their
representation).
compiler/notes/compiler_design.html:
Add notes on module qualification of class contexts. Needs expansion
to include more stuff on typeclasses.
compiler/*.m:
Various minor changes.
New Files:
compiler/base_typeclass_info.m:
Produce one base_typeclass_info for each instance declaration.
compiler/prog_io_typeclass.m:
Parse typeclass and instance declarations.
compiler/check_typeclass.m:
Check the conformance of an instance declaration to the typeclass
declaration, including building up a proof of how superclass
constraints are satisfied so that polymorphism.m is able to construct
the typeclass_info, including the superclass typeclass_infos.
library/mercury_builtin.m:
Implement that base_typeclass_info and typeclass_info types, as
well as the predicates type_info_from_typeclass_info/3 to extract
a type_info from a typeclass_info, and superclass_from_typeclass_info/3
for extracting superclasses.
library/ops.m:
Add "typeclass" and "instance" as operators.
library/string.m:
Add a (in, uo) mode for string__length/3.
runtime/mercury_ho_call.c:
Implement do_call_*det_class_method, which are the pieces of code
responsible for extracting the correct code address from the
typeclass_info, setting up the arguments correctly, then executing
the code.
runtime/mercury_type_info.h:
Macros for accessing the typeclass_info structure.
Estimated hours: 0.5
Minor efficiency improvment.
compiler/type_util.m:
compiler/polymorphism.m:
compiler/switch_gen.m:
Change the type category `user_type(Type)' to just `user_type';
pass the type as well as the type category, if needed.
Estimated hours taken: 5 mins
modes.m:
Fix of some documentation rot: We _do_ know how to do a
deep copy. We just don't know how to do a partially
instatiated deep copy.
hlds_module.m:
make_hlds.m:
mercury_to_mercury.m:
prog_io.m:
type_util.m:
typecheck.m:
Remove some when declarations, since the NU-Prolog version
of the compiler isn't supported any more.
Estimated hours taken: 30
Implement support for types with user-defined equality predicates.
Types with user-defined equality predicates are called "non-canonical types";
they may have more than one representation for the same abstract value.
That means that any attempt to deconstruct a value of a non-canonical
type, i.e. any attempt to peek at the representation, must be cc_multi.
This also implies that conceptually speaking, non-canonical types are not
members of the type classes `comparable' (compare/3) or `deconstructible'
(index/2, argument/3, functor/3, deconstruct/5). Since we don't support
type classes yet, that just means that the type-class checking is done
at runtime, i.e. any call to one of those functions for a non-canonical
type will call error/1 or fatal_error().
To make non-canonical types useful, we really need type classes,
so that the user can provide instance definitions for `comparable'
and `deconstructible' for such types. It might also be a good idea
to have a type-class `canonicalizable' which provides a function
to convert its argument to some canonical type (that would
require existential types to do nicely, but alternatively we could
just use `univ').
Note that currently the only mechanism for promising that things are
unique is via the C interface.
compiler/det_analysis.m:
Add code to check unifications that examine the
representation of a type with a user-defined equality predicate.
Any such unification must occur in a single-solution context and
must not be able to fail. Such unifications determinism have
determinism cc_multi.
compiler/det_report.m:
Add code to report errors for misuse of types with user-defined
equality predicates. (Also some other stylistic improvements:
split up a complicated predicate into subroutines, and
avoid some unnecessary code duplication.)
compiler/prog_data.m:
compiler/hlds_data.m:
Add a new `maybe(sym_name)' field to the du_type/3 constructor
to hold the name of the user-defined equality pred for the
type, if any.
compiler/prog_io.m:
Add code to parse the new `... where equality is <name>.' syntax.
Delete the old support for `... where <condition>'.
compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
compiler/mercury_to_goedel.m:
Print out the new field.
compiler/base_type_layout.m:
compiler/code_util.m:
compiler/dense_switch.m:
compiler/equiv_type.m:
compiler/intermod.m:
compiler/make_hlds.m:
compiler/mode_util.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/switch_detection.m:
compiler/tag_switch.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_gen.m:
Trivial changes to ignore (or leave unchanged)
the new field in `du_type'.
compiler/modecheck_unify.m:
Pass the term__context to unify_proc__request_unify.
compiler/typecheck.m:
Typecheck the compiler-generated unify predicates for types
with user-defined equality preds.
compiler/unify_proc.m:
For d.u. types, if the type has a user-defined equality predicate
then generate code for the compiler-generated unify predicate
that just calls the specified predicate, and generate
code for the compiler-generated compare and index predicates
that just calls some procedures in mercury_builtin.m that
report appropriate error messages.
Ensure that the automatically-generated predicates
have appropriate term__contexts everywhere, so that if
the user-defined equality predicate name is ambiguous,
non-existent, or has the wrong type, mode, or determinism,
then the error messages from type checking, mode checking,
or determinism checking refer to the type declaration.
library/mercury_builtin.m:
Add predicates builtin_index_non_canonical_type/2
and builtin_compare_non_canonical_type/2, used by
the code generated by compiler/unify_proc.m.
doc/reference_manual.texi:
Document the support for user-defined equality predicates.
library/std_util.m:
Change ML_expand() to return an indication of whether or not
the type is a non-canonical type (one with a user-defined
equality predicate). Change argument/2, functor/2, and
deconstruct/4 to abort if called for a non-canonical type.
Estimated hours taken: 5
Fix another bug triggered by compilation for accurate gc.
The compiler was not correctly handling the unbound type variables when
doing inlining.
compiler/inlining.m:
Update TypeVarSet and TypeInfoVarMap when inlining - unbound
type variables can occur in the callee which need to be migrated
to the caller when inlined. Introduce new inline_info type, which
stores information threaded through inling. This should make future
changes to inlining much easier.
compiler/type_util.m:
Add `apply_substitutions_to_var_map' which will update a
map(tvar, var) given a type substitution and a variable
substitution.
tests/valid/Mmake:
tests/valid/agc_unbound_typevars2.m:
Test case for this bug.
Estimated hours: 8
Bug fixes for module qualified cons_ids.
Improve the compilation time of modules with lots of user_defined insts.
(Compilation of tree234.m with the unique tree skeleton modes enabled is
still way too slow).
compiler/mode_util.m
In propagate_type_info_into_modes and the predicates it calls, avoid
finding the constructors for a type and substituting the argument
types.
compiler/hlds_pred.m
Add a new field to the proc_info, maybe_declared_argmodes which
holds the declared arg_modes for use in .opt files and error messages.
compiler/typecheck.m
Call propagate_type_info_into_modes from here to avoid calling it
many times throughout mode analysis. This does not cause a
substantial performance improvement, but reduces confusion
over where everything should be module qualified.
This also fixes a bug with the no_tag optimisation reported by
Mark Brown. A runtime abort occurred because a constructor in a bound
inst was not being module qualified which confused mode_to_arg_mode
into giving the argument an arg_mode of top_unused.
compiler/modecheck_unify.m
Call propagate_type_info_mode_list for modes of lambda predicates.
compiler/modes.m
compiler/modecheck_call.m
compiler/unique_modes.m
Don't call propagate_type_info_mode_list since that has
already been done in typecheck.m.
compiler/intermod.m
Write out the declared arg_modes, since these don't contain
constructs such $typed_inst which the parser doesn't handle.
compiler/clause_to_proc.m
compiler/unify_proc.m
Fill in the declared_argmodes field in proc_infos.
compiler/type_util.m
Avoid creating the substitution multiple times in type_constructors.
compiler/mercury_compile.m
Added some documentation.
tests/hard_coded/Mmake
tests/hard_coded/imported_no_tag.m
tests/hard_coded/test_imported_no_tag.m
tests/hard_coded/test_imported_no_tag.exp
Add Mark Brown's test case.
Estimated hours taken: 3
Replace calls to map__set with calls to either map__det_insert or
map__det_update. In some cases this required a small amount of code
reorganization.
Estimated hours taken: 8
Enable the code to treat `__' as an alternative syntax for module
qualification, after fixing various places in the compiler where
we use `__' in ways that are incompatible with this.
compiler/prog_io.m:
compiler/prog_io_goal.m:
Uncomment the code to handle `__' as module qualification.
compiler/intermod.m:
compiler/hlds_module.m:
compiler/modecheck_unify.m:
Fix bugs in the handling of module qualified higher-order terms.
compiler/*.m:
s/hlds__/hlds_/g
compiler/passes_aux.m:
s/process__/process_/g
compiler/pragma_c_gen.m:
compiler/code_gen.m:
s/code_gen__/pragma_c_gen__/ for the predicates defined in
pragma_c_gen.m (this ought to have been done when the code
was first moved from code_gen.m to pragma_c_gen.m).
compiler/llds.m:
s/llds__proc_id/llds_proc_id/g
The reason for this was to avoid ambiguity between proc_id
in hlds_pred.m and llds__proc_id in llds.m.
compiler/quantification.m:
compiler/make_hlds.m:
compiler/mercury_to_c.m:
s/goal_vars/quantification__goal_vars/g
The reason for this was to avoid ambiguity between goal_vars
in quantification.m and goal_util__goal_vars in goal_util.m.
compiler/dupelim.m:
compiler/optimize.m:
s/dupelim__main/dupelim_main/g
The reason for this change is that a program can only
have one main/2 predicate.
compiler/prog_io_dcg.m:
Remove the old "temporary hack" to strip off and ignore
io__gc_call/1, since the new handling of `__' broke it.
It was only useful for optimizing NU-Prolog performance,
which we don't care about anymore.
compiler/mercury_compile.m:
compiler/modules.m:
compiler/intermod.m:
compiler/prog_io.m:
Remove occurrences of io__gc_call.
compiler/llds_out.m:
compiler/base_type_info.m:
Ensure that we properly handle the special hacks in mercury_builtin
where predicates from other modules (e.g. term__context_init)
are defined in mercury_builtin because they are needed for
type_to_term and term_to_type. llds_out.m: don't put
`mercury_builtin' in the mangled names for those symbols.
base_type_info.m: handle types whose status is "imported"
in their own module.
Estimated hours taken: 4
Add code to treat `__' as an alternative syntax for module
qualification. The code is currently commented out, because at the
time this change was made, we don't yet support module qualification of
data constructors. Now that we do, it should be re-enabled as soon as
it has been tested.
Also avoid some code duplication.
compiler/prog_io.m:
compiler/prog_io_goal.m:
Add (commented out) code to handle `__'.
compiler/prog_io_dcg.m:
compiler/type_util.m:
Avoid code duplication: use sym_name_and_args from prog_io_goal.m
for parsing possibly qualified terms.
Estimated hours taken: 100
* Inter-module unused argument removal.
* Allow the user to specify which directories should be searched
for .opt files.
* Enhancements to simplify.m and common.m which will be useful for
partial deduction.
compiler/options.m
Added and documented options:
--intermod-unused-args to enable inter-module unused argument removal.
--intermod-directory <dir>, same as --search-directory except used
to locate .opt files.
--use-search-directories-for-intermod - use the search directories
for .opt files as well.
--warn-simple-code - a flag to control the warnings produced by
simplify.m so that they respect --inhibit-warnings.
compiler/unused_args.m
Use the unused argument info from the .opt file.
Clobber the dependency_info if any new preds were added.
compiler/hlds_module.m
Added a field to the module_info to store unused argument
information from .opt files.
compiler/prog_data.m
Add :- pragma unused_args to hold unused argument information.
This should only be used in .opt files.
compiler/make_hlds.m
Build the unused_arg_info field in the module_info.
Check that pragma unused_args only appears in .opt files.
Fill in the non-locals field in the goal_info for the builtin
stubs so that mode analysis computes the correct instmap delta.
compiler/intermod.m
Read in the unused argument information for the current module when
compiling to C. This is used to ensure that clauses are produced with
the correct number of removed arguments (it may be possible to remove
more arguments with the information from other modules).
Fix a bug in the handling of module qualified function calls and
higher-order predicate constants.
compiler/handle_options.m
Handle --intermod-unused-args and
--use-search-directories-for-intermod.
compiler/mercury_compile.m
Run the entire front end and polymorphism (not just up to
typechecking) when building the .opt file with
--intermod-unused-args.
Use the new interface to simplify.m, remove calls to excess.m
and common.m.
compiler/code_util.m
compiler/llds_out.m
When generating local code for a specialized version of a predicate
from another module, put this module's name on the label to avoid
link errors.
compiler/higher_order.m
Don't add the originating module name to the name of the specialized
version, since that is now done in code_util.m.
Clobber the dependency graph so that inlining will work on the
specialized versions in profiling grades (this will cause slightly
slower compilation in profiling grades, something I need to fix).
compiler/simplify.m
Merge a branching goal and an adjacent switch where the branches
of the first goal contain extra information about the switched
on variable of the second goal.
Merge the excess assignments and common subexpression elimination
passes into simplify.m.
compiler/excess.m
The functionality of this module is now in simplify.m, but I'll
leave it here for now.
compiler/instmap.m
Added predicates instmap__bind_var_to_functor and
instmap_delta_bind_var_functor to which take a var, cons_id
and an instmap and adjust the inst of the var. This is used to
update the instmap at the beginning of each case in a switch.
Fix a bug in merge_instmap_delta where variables whose inst had
information added in one branch of a switch, disj, or ite had that
changed inst included in the instmap_delta for the entire
branched goal.
compiler/mode_util.m
Use instmap_delta_bind_var_to_functor in recompute_instmap_delta.
Added predicate bind_inst_to_functor which takes a ground or bound
inst and a cons_id and adjusts the top level of the inst to be bound
to that cons_id. Other types of inst are left unchanged.
Change recompute_instmap_delta so that the switched on variable of
a switch is bound to the functor in each case even if the binding
unification has been removed. Added a boolean argument to request
recomputation of instmap_deltas for atomic goals.
compiler/modes.m
compiler/unique_modes.m
Make sure that the instmap_delta for each branch of a switch
includes the extra information added by the functor test.
compiler/common.m
Removed the goal traversal. Leave preds to be called by simplify.m
to optimise common unifications and calls.
Warn about and eliminate multiple calls to a predicate with the same
input arguments.
Replace deconstructions of known terms with assignments to the output
variables where this would not make more variables live at stack
flushes.
compiler/follow_code.m
Exported move_follow_code_select.
Don't move follow code into erroneous branches.
library/string.nu.nl
Added string__contains_char/2.
compiler/base_type_layout.m
compiler/special_pred.m
compiler/vn_order.m
library/mercury_builtin.m
Removed duplicate calls.
doc/user_guide.texi
Documented options.
tests/warnings/duplicate_call.m
tests/warnings/duplicate_call.exp
Test duplicate call warning.
Estimated hours taken: 2
Fix for bug I introduced yesterday. type_to_type_id would generate
type_ids for functions of =/1 =/2 =/3 =/4 etc, with the arity of the
function. construct_types, given the same type_id and arguments back,
would not always generate the same type.
compiler/type_util.m:
Use the arity of = (2), not the arity of the function,
when computing higher order types.
Estimated hours taken: 3
Fix bug that caused higher-order functions to be ignored, thus creating
mercury_data___base_type_info_func_X references to non-existant
structures.
compiler/type_util.m:
Fix a comment.
Add type_id_is_higher_order/2.
Change type_to_type_id/3 so that it correctly returns higher
order arguments (particularly functions).
Change construct_type/3 and construct_type/4 so they correctly
create higher-order types (particularly functions).
compiler/equiv_type.m:
Use construct_type instead of construct_qualified_term, so
that we handle higher order arguments correctly.
Estimated hours taken: 50
Create base_type_layout structures, which store information about how
Mercury data is represented in memory.
compiler/base_type_layout.m:
Generate base_gen_layouts from HLDS.
Pass over base_gen_layouts after code generation, create layout
tables, and pseudo-typeinfos as needed.
compiler/base_type_info.m, compiler/dead_proc_elim.m:
Allow base_type_infos to be `neutered' rather than eliminated
by dead_proc_elim. This just removes references to compiler
generated preds, and replaces them with references to an
'unused' pred in mercury_builtin, which prints an error
message if ever used. (The base_type_infos are always needed,
even if the generated preds aren't, because the layout tables
refer to them).
compiler/hlds_module.m:
Add marker for procs eliminated in base_type_infos.
Add base_gen_layout structure, and access predicates to HLDS.
compiler/llds.m, compiler/llds_out.m, compiler/opt_debug.m:
Add a base_type_layout data_name, for storing references to
base_type_layouts. Add output code.
compiler/llds_common.m:
Get llds_common to process c_data structures given to it.
(We'll give it the base_type_layouts).
compiler/mercury_compile.m:
Add a pass to generate and process the base_type_gens.
Fix a newline in a ... done message.
Let llds_common work on the base_type_layouts.
compiler/type_util.m:
Add type_util__var, which returns the type variable of a type
(if it is a variable at the top level).
Estimated hours taken: 16
Fix some bugs with the handling of partially instantiated
variables which have `no_tag' types.
N.B. This fix does not handle the case of passing a partially
instantiated variable of a no_tag type to polymorphic predicate.
However, polymorphic predicates with partially instantiated
modes are a bit of a dodgy case anyway.
mode_util.m:
Change mode_to_arg_mode to handle `no_tag' types properly.
unify_gen.m:
Change the code to handle `no_tag' types properly.
arg_info.m, bytecode_gen.m:
Pass the type of the variable, not just its mode,
to mode_to_arg_mode, since whether a variable
is `top_in' or not may depend on the type.
live_vars.m, liveness.m, store_alloc.m, unify_gen.m:
Use `mode_to_arg_mode(..., top_in)' rather than
`mode_is_input(...)', since here we're concerned
with the low-level concept of top_in/top_out
rather than the higher-level notion of input/output.
modecheck_unify.m:
In split_complicated_subunifies, `mode_to_arg_mode(..., top_in)'
rather than `mode_is_input(...)', for same reason as above.
(In other parts of mode analysis we're concerned with the higher-level
notion, but split_complicated_subunifies is basically just there
for the code generator.)
type_util.m, make_tags.m, shapes.m:
Put the test for a `no_tag' type into a utility predicate
type_is_not_tag_type in type_util.m.
make_hlds.m:
Change the code for add_builtin so that it puts the correct
type annotations in the pred_info. (The previous code was
wrong, but the problem didn't show up until the new code in the
other parts of this change tried to use the var_types field of
the pred_info.)
Estimated hours taken: 12
The main changes are
1 associating a name with the arguments of constructors
2 removing the follow_vars field from calls, higher-order calls
and complicated unifications, since they are not used
3 merging the follow_vars and store_alloc passes, since they logically
belong together
4 add a new module, lco, for detecting opportunities for last
call optimization modulo constructor application; it won't
actually apply the optimization until the mode system becomes
expressive enough to handle it (this module detects 529 opportunities
in the compiler and library)
5 make "-O3 --optimize-value-number" do the right thing; previously,
it used not to apply value numbering because the vnrepeat option
defaulted to zero
6 don't refer to .err2 files anymore; use .err instead.
prog_data:
The list associated with each value of type "constructor" now
contains not only the types of the arguments but their names as well.
equiv_type, hlds_data, hlds_out, make_hlds, mercury_to_{goedel,mercury},
mode_util, module_qual, shapes, type_util, unify_proc:
Modify the traversal of type definitions to account for the names
in the lists inside values of type "constructor".
prog_io:
Parse argument names. An unrelated change is that we now
check whether :- pred declarations give modes to some of their
arguments but not to all, in which case we return an error.
hlds_goal:
Remove the follow_vars field from calls, higher-order calls
and complicated unifications.
*.m:
Handle the new arities of calls, higher order calls and complicated
unifications.
mercury_compile:
Don't call follow_vars directly anymore, but do call lco if its option
is set. Also flush the main output before a call to maybe_report_stats
to prevent ugly output.
store_alloc:
Call follow_vars directly.
follow_vars:
Expose the initialization and traversal predicates for store_alloc.
lco:
Find opportunities for last call optimization modulo constructor
application.
passes_aux:
Add a HLDS traversal type for lco.
optimize:
Consider the vnrepeat count to be zero unless value numbering is on.
options:
Set the default value of vnrepeat to 1.
modules:
Don't refer to .err2 files.
Estimated hours taken: 50
- Inter-module optimization.
Allows inlining and higher-order specialization across module boundaries.
Gives ~10% speed-up on the compiler compiling to C.
- The code to handle explicit type qualification.
The test to recognise a type qualification is semidet_fail'ed
until we work out which operator to use.
- Improved data structures in module_qual.m.
Also, module qualification of the modes of lambda expressions is now
done in make_hlds.m, since it is more convenient now that type
qualifications are module qualified there also.
* Type qualification and module qualifiers on higher-order predicate
constants and function calls still need to be implemented before this
will work on all programs.
* To create a version of a program using this optimization method,
add --intermodule-optimization to MCFLAGS, mmake change_clean,
mmake depend, then make as normal.
* mmake change_clean removes the executable, the .dep file and all
.cs and .os.
compiler/intermod.m
Handle input and output of .opt files.
compiler/modules.m
Added some new dependencies in the .d files for
the .c and .opt files if inter-module optimization
is being used.
Also added .opt and .optdate to the list of things for
mmake realclean to remove.
Added a target, change_clean, which removes only those files
necessary to force a rebuild using --intermodule-optimization.
These are <module>, <module>.dep and all the .c, .o and .s files.
compiler/options.m
Added options:
--make-optimization-interface - make the .opt file.
--intermodule-optimization - puts extra dependencies
into .d files and turns on input of .opt files.
compiler/make_hlds.m
Changes to give items from .opt files the correct import_status.
Also, when matching pragma_c_code clauses to the declared modes
of the predicates, expand and match on the initial and final insts
of the argument modes, not the modes themselves, since items in
.opt files have the modes expanded.
Module qualify the modes of lambda expressions in unravel_unification
rather than during mode analysis.
Parse explicit type qualifications, and add these to the vartypes.
At the moment this is disabled.
compiler/typecheck.m
Get the head type params from the tvarset, not from the arg types,
so that tvars in type qualifications are included.
Added checks to prevent matching of predicates, functions and
constructors which should not be visible to a clause.
compiler/module_qual.m
Module qualify explicit type qualifications.
More efficient data structures.
compiler/mercury_to_mercury.m
Export some predicates. Make sure C code strings are properly
quoted in the .opt files.
compiler/hlds_out.m
Output function calls correctly. Alter hlds_out__write_goal to write
out type qualifications on all functors if writing a .opt file.
compiler/hlds_pred.m
Added a new import_status opt_imported for clauses and declarations
read from a .opt file. Pred and func declarations read from a .opt
file get an `opt_decl' import_status so that the compiler doesn't
expect clauses for them and local preds can't use them.
Also added import_status abstract_imported and abstract_exported
to describe types which have only an abstract definition imported
or exported.
Added a field to clauses_info to store the map(var, type) from
explicit type qualifications.
Renamed pred_info_set_status/3 to pred_info_set_import_status/3 to
be consistent with pred_info_import_status/2.
compiler/hlds_data.m
Added an import_status field to the hlds__mode_defn and
hlds__inst_defn so that intermod.m knows what has already
been exported.
compiler/equiv_type.m
Pass out the equiv_map and export a predicate used to
expand type qualifications.
compiler/dead_proc_elim.m
Remove non-optimized versions of opt_imported preds. All
optimizations must give the optimized version an import_status
of local.
compiler/code_util.m
Changed code_util__make_local_entry_label so that `localcall's
are used for recursive calls in exported predicates.
compiler/code_aux.m
Changed code_aux__contains_only_builtins_2 so that it doesn't
check for complicated unifies, since any time this is called,
complicated unifies have either not been created (when called
when writing the .opt files) or have been converted to calls
(when called during inlining).
compiler/higher_order.m
Make sure that the specialized versions get unique names.
compiler/mercury_compile.pp
Add calls to intermod.m predicates.
compiler/bytecode_gen.m
Bracketed some '->'/2 insts so that they can be parsed by SICStus.
compiler/peephole.m
Replace computed_gotos where all the targets are the same with
an unconditional goto.
compiler/notes/COMPILER_DESIGN
Documented intermod.m.
library/list.m
Added list__all_same/1, which is true if all elements of a list are
identical. Also added list__last/2, which returns the final element
of a list, failing on the empty list.
library/io.m
Change the format specifier for io__write_float so that the decimal
point is always output. Without this, the result may not be a valid
Mercury floating point constant.
library/varset.m
Add predicate varset__create_name_var_map/2 to create a mapping
from variable name to variable id given a varset. This is used
in processing type qualifications.
scripts/Mmake.rules
scripts/Mmake.vars.in
Add suffixes, rules and options for .opt and .optdate.
scripts/mercury_update_interface.in
Work-around for a problem with parallel gmake. mc --make-interface
was being run twice in a row on the same module. The first call
mercury_update_interface moves module.int.tmp to module.int,
then the second can't find module.int.tmp. The work-around is to
ignore the exit status of the mv.
Some cleaning up:
compiler/*.m
Fixed some out of date comments about the handling of
complicated_unify. Also commented some dead code to do
with generation of code for complicated_unify.
compiler/modes.m
compiler/mode_info.m
Moved code to module qualify modes of lambda expressions into
make_hlds.
Moved predicates resolve_pred_overloading and find_matching_pred_id
into typecheck, renaming with a typecheck__ prefix, so that these
can be called from intermod.m.
compiler/undef_modes.m
compiler/undef_types.m
Removed - their functionality is now in module_qual.m, except
for checking for looping equivalence types.
compiler/no_builtin.m
compiler/nit_builtin.m
Removed - they were made useless (if they weren't already) by
the removal of the --builtin-module option.
compiler/notes/AUTHORS
Updated student email addresses.
Estimated hours taken: 2
Prepare for the new type_info representation.
options:
Add a --type-info option to specify which type_info representation
should be used.
globals:
Add a field to the global tuple giving the type_info method.
handle_options:
Convert the type_info option value to the global value.
hlds_data:
Associate an import_status with type definitions. This will be needed
to figure out whether the base_type_info associated with the type
needs to be exported or not.
hlds_out:
Print out the status field of type definitions.
make_hlds:
Compute the right value for the status fields of type definitions.
type_util:
Fix spelling.
Estimated hours taken: 15
hlds_data:
Rename address_const to code_addr_const, and add base_type_info_const
as a new alternative in cons_id, and make corresponding changes
to cons_tag.
Make hlds_type__defn an abstract type.
llds:
Rename address_const to code_addr_const, and add data_addr_const
as a new alternative in rval_const.
Change type "label" to have four alternatives, not three:
local/2 (for internal labels), c_local (local to a C module),
local/1 (local a Mercury module but not necessarily to a C module,
and exported.
llds_out:
Keep track of the things declared previously, and don't declare them
again unnecessarily. Associate indentation with the following item
rather than the previous item (the influence of 244); this results
in braces being put in different places than previously, but should be
easier to maintain. Handle the new forms of addresses and labels.
Refer to c_local labels as STATIC when not using --split-c-files.
code_info:
Use a presently junk field to store a cell counter, which is used
to allocate distinguishing numbers to create'd cells. Previously
we used the label counter, which meant that label numbers changed
when we optimized away some creates. Handle the new forms of
addresses and labels.
exprn_aux:
Handle the new forms of addresses and labels. We are now more
precise in figuring out what label address forms will be considered
constants by the C compilers.
others:
Changes to handle the new forms of addresses and labels, and/or to
access hlds_type__defn as an abstract type.
Estimated hours taken: 40
(including testing)
These changes comprise
* some configuration changes for accurate GC (setting -DNATIVE_GC,
working out dependencies for accurate GC, new .agc grade)
* liveness changes for supporting polymorphism in accurate GC
* some support of polymorphism for GC (mostly consisting of keeping
the typevar -> typinfo_var mappings (eg T in list(T) is
stored in TypeInfo_For_T) and corresponing mappings into
lvals at continuation labels.
* changes required to data structures so that above changes could
work.
* cut down on the number of abstract exports handled by checking
types to see whether they are imported (duh...)
* don't use '-I' directories when searching for '.m' files.
(since this will wrecks dependency generation in some situations).
* don't lookup and create shape information when not doing accurate
GC. (instead we just give back dummy values).
Estimated hours taken: 45
Module qualification of types, insts and modes.
Added a new interface file - <module>.int3. This contains the
short interface qualified as much as possible given the information
in the current module.
When producing the .int and .int2 files for a module, the compiler uses
the information in the .int3 files of modules imported in the interface
to fully module qualify all items. The .int2 file is just a fully
qualified version of the .int3 file. The .int3 file cannot be overwritten
by the fully qualified version in the .int2 file because then mmake would
not be able to tell when the interface files that depend on that .int3
file really need updating.
The --warn-interface-imports option can be used to check whether
a module imported in the interface really needs to be imported in
the interface.
compiler/module_qual.m
Module qualify all types, insts and modes. Also checks for modules
imported in the interface of a module that do not need to be.
compiler/modules.m
The .int file for a module now depends on the .int3 files of imported
modules. Added code to generate the make rule for the .int file in the
.d file. There is now a file .date2 which records the last time the
.int2 file was updated.
The .int3 files are made using the --make-short-interface option
introduced a few weeks ago.
compiler/options.m
Added option --warn-interface-imports to enable warning about interface
imports which need not be in the interface. This is off by default
because a lot of modules in the library import list.m when they only
need the type list, which is defined in mercury_builtin.m.
Removed option --builtin-module, since the mercury_builtin name is wired
into the compiler in a large number of places.
compiler/prog_util.m
Added a predicates construct_qualified_term/3 and construct_qualfied_term/4
which take a sym_name, a list of argument term and a context for the /4
version and give a :/2 term.
compiler/type_util.m
Modified type_to_type_id to handle qualified types. Also added predicates
construct_type/3 and construct_type/4 which take a sym_name and a list of
types and return a type by calling prog_util:construct_qualified_term.
compiler/modes.m
On the first iteration of mode analysis, module qualify the modes of
lambda expressions.
compiler/mode_info.m
Added field to mode_info used to decide whether or not to module qualify
lambda expressions.
compiler/mode_errors.m
Added dummy mode error for when module qualification fails so that mode
analysis will stop.
Added code to strip mercury_builtin qualifiers from error messages to
improve readability.
compiler/typecheck.m
Strip builtin qualifiers from error messages.
compiler/llds.m
compiler/llds_out.m
compiler/opt_util.m
compiler/opt_debug.m
Change the format of labels produced for the predicates to use the
qualified version of the type name.
compiler/mercury_compile.pp
Call module_qual__module_qualify_items and make_short_interface.
Remove references to undef_modes.m and undef_types.m
compiler/undef_modes.m
compiler/undef_types.m
Removed, since their functionality is now in module_qual.m.
compiler/prog_io.m
Changed to qualify the subjects of type, mode and inst declarations.
compiler/*.m
Changes to stop various parts of the compiler from throwing away
module qualifiers.
Qualified various mercury_builtin builtins, e.g. in, out, term etc.
where they are wired in to the compiler.
compiler/hlds_data.m
The mode_table and user_inst_table are now abstract types each
storing the {mode | inst}_id to hlds__{mode | inst}_defn maps
and a list of mode_ids or inst_ids. This was done to improve the
efficiency of module qualifying the modes of lambda expressions
during mode analysis.
module_info_optimize/2 now sorts the lists of ids.
The hlds_module interface to the mode and inst tables has not changed.
compiler/hlds_module.m
Added yet another predicate to search the predicate table.
predicate_table_search_pf_sym_arity searches for predicates or
functions matching the given sym_name, arity and pred_or_func.
compiler/higher_order.m
Changed calls to solutions/2 to list__filter/3. Eliminated unnecessary
requantification of goals.
compiler/unused_args.m
Improved abstraction slightly.
Estimated hours taken: 8
Bug fixes for higher_order.m and unused_args.m
NEWS
Removed the message about bugs in unused_args.m and higher_order.m
compiler/options.m
Re-enabled higher_order and unused_args.
compiler/unused_args.m
Fixed so that this now handles partially instantiated
deconstructions correctly.
compiler/higher_order.m
Two bug fixes:
Specialization of types for specialized versions of predicates.
Fixed handling of curried arguments.
compiler/inlining.m, compiler/type_util.m:
Moved inlining:apply_substitution_to_type_map and
inlining:apply_rec_substitution_to_type_map to type_util.m
for use in the higher_order.m bug fix.
library/varset.m
Added predicate varset__new_vars which returns a list of new
variables.
library/term.m
Added predicates term__apply_variable_renaming(_to_list)
to apply a variable renaming (map(var, var)) to a term
or list of terms.
library/map.m
Added map__det_insert_from_corresponding_lists to insert
multiple key-value pairs into a map.
tests/valid/{Mmake, higher_order2.m, higher_order3.m, unused_args_test2.m}
Tests for the bug fixes.
Estimated hours taken: 8
options.m:
Rename branch_delay_slot to have_delay_slot.
Set optimize_delay_slot in -O2 only if have_delay_slot was set earlier.
This is possible now because the default optimization level is now
set in mc.
mercury_compile:
Change verbose output a bit to be more consistent.
dead_proc_elim:
Export the predicates that will eventually be needed by inlining.m.
inlining.m:
Use the information about the number of times each procedure is called
to inline local nonrecursive procedures that are called exactly once.
EXCEPT that this is turned off at the moment, since the inlining of
parse_dcg_goal_2 in prog_io, which this change enables, causes the
compiler to emit incorrect code.
prog_io:
Moved the data type definitions to prog_data. (Even though prog_io.m
is ten times the size of prog_data.m, the sizes of the .c files are
not too dissimilar.)
Estimated hours taken: 0.1
Fix a bug in inlining of polymorphic predicates, which showed up
for the `pseudoknot' benchmark when excess_assign was turned on again.
compiler/inlining.m:
Make sure we substitute in the new values of any type
parameters which are bound by an inlined call.
This fixed a bug which led to the the code generator
aborting because the code output from inlining.m was
not type-correct.
Also, tidy up the source code a bit and a some comments.
type_util.m:
Add predicate type_list_subsumes/3, for use by inlining.m and
modes.m.
modes.m:
Use type_list_subsumes/3.
Estimated hours taken: 3
A bunch of cleanups: improve error messages, tidy up the code.
Also, do some work towards supporting higher-order functions.
type_util.m:
Add new predicate type_is_higher_order/3 for checking
whether a type is a higher-order type. This recognizes
both higher-order predicate types and also higher-order
function types.
code_info.m, modes.m, polymorphism.m, shapes.m:
Use type_is_higher_order/3.
make_hlds.m:
Fix another error message to do the right thing when
reporting errors for functions.
mercury_to_mercury:
List `func' in the table of operators, so that it gets
parenthesized correctly.
modes.m, mode_errors.m:
Improve the error message for attempted higher-order unifications:
spit out some context, and if verbose_errors is enabled, spit
out a long description.
Estimated hours taken: 10
hlds, hlds_module, hlds_pred, hlds_goal, hlds_data:
Divided the old hlds.m into four files:
hlds_module.m defines the data structures that deal with issues
that are wider than a single predicate. These data structures are
the module_info structure, dependency_info, the predicate table
and the shape table.
hlds_pred.m defined pred_info and proc_info, pred_id and proc_id.
hlds_goal.m defines hlds__goal, hlds__goal_{expr,info}, and the
other parts of goal structures.
hlsd_data.m defines the HLDS types that deal with issues related
to data and its representation: function symbols, types, insts, modes.
It also defines the types related to determinism.
hlds.m is now an empty module. I have not removed it from CVS
because we may need the name hlds.m again, and CVS does not like
the reuse of a name once removed.
other modules:
Import the necessary part of hlds.
det_analysis:
Define a type that was up to now improperly defined in hlds.m.
prog_io:
Move the definition of type determinism to hlds_data. This decision
may need to be revisited when prog_io is broken up.
dnf, lambda:
Simplify the task of defining predicates.
llds:
Fix some comments.
mercury_compile:
If the option -d all is given, dump all HLDS stages.
shape, unused_args:
Fix formatting.
Estimated hours taken: 1.5
Undo dylan's changes in the names of some library entities,
by applying the following sed script
s/term_atom/term__atom/g
s/term_string/term__string/g
s/term_integer/term__integer/g
s/term_float/term__float/g
s/term_context/term__context/g
s/term_functor/term__functor/g
s/term_variable/term__variable/g
s/_term__/_term_/g
s/std_util__bool_/bool__/g
to all the `.m' and `.pp' files in the compiler and library directories.
The reason for undoing these changes was to minimize incompatibilities
with 0.4 (and besides, the changes were not a really good idea in the first
place).
I also moved `bool' to a separate module.
The main reason for that change is to ensure that the `__' prefix is
only used when it genuinely represents a module qualifier.
(That's what dylan's changes were trying to acheive, but `term__'
does genuinely represent a module qualifier.)
compiler/*.m:
Apply sed script above;
where appropriate, add `bool' to the list of imported modules.
Estimated hours taken: _2___
Change names with badly placed double underscores (ie where the part of
a name before a double underscore is not the same as the module name.)
Reflect changes in the library interface.
compiler/*:
Use the newer, more correct form of the term and bool names.
Predicates "bool__" are now "std_util__bool" and labels of
the term ADT are now "term_" instead of "term__".
compiler/vn*.m:
change all names "vn__*" to a correct module prefix. All the
names remain qualified.
compiler/hlds.m:
s/\<is_builtin__/hlds__is_builtin_/g
s/\<dependency_info__/hlds__dependency_info_/g
compiler/unify_proc.m:
s/\<unify_proc_info__/unify_proc__info_/g
compiler/transform.m:
s/\<reschedule__conj/transform__reschedule_conj/g
frameopt:
Look inside blocks introduced by value numbering when looking
restorations of succip.
value_number, opt_util:
If we are using conservative garbage collection, disable value
numbering for blocks that allocate more than one cell on the heap.
This allows value numbering of most blocks to work in the absence
of -DALL_INTERIOR_POINTERS.
all other source files:
Clean up "blank" lines that nevertheless contain space or tab
characters.
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!!!)
code_util.nl, float.nl, llds.nl, mercury_builtin.nl, opt_debug.nl,
parser.nl, polymorphism.nl, sp_lib.nl, string.nl, string.nu.nl,
type_util.nl, typecheck.nl, unify_gen.nl:
Implement floating point.
Makefile.common:
Remove `-include test.dep' line. Use Mmake.
int.nl:
Update a few of the comments.
io.nu.nl:
For Sicstus Prolog, if main/2 is not defined then enter the
debugger.
Makefile.common:
Add some targets for compiling the compiler and the library.
type_util.nl, dense_switch.nl, switch_gen.nl, polymorphism.nl:
Rename inttype, chartype, etc. as int_type, char_type, etc.
Add polymorphic_type.
modes.nl, mode_errors.nl:
Report an error for direct attempts to unify higher-order pred types.
(Of course, we don't catch indirect attempts via polymorphic types -
that would require global analysis. For them, we report the error
at runtime.)
modes.nl:
Remove unreachable code from conjuctions.
(XXX also should do this for if-then-else.)
options.nl:
Turn -p off by default. I'll turn it on again when it works ;-)
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").
*.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.
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.
lots of files:
Make a start at implementing code generation for complicated
unifications. In the HLDS, change complicated_unify/4 to
complicated_unify/2 since we didn't need the extra two args
after all.
peephole.nl:
A couple of minor efficiency improvements.
queue.nl:
Add queue__queue_to_list/2.
hlds_out.nl:
Minor improvements to the output.
code_info.nl, type_util.nl:
Change make_type_id to fail rather than call error/1
if the type is not valid.
undef_types.nl:
Report invalid types.
mode_util.nl:
Add a new pred `type_constructors'.
modes.nl:
Detect determinism of deconstruction unifications properly,
using the type information.
code_info.nl:
Tidy up the code for code_info__cons_id_to_tag.
prog_io.nl, mode_util.nl, mercury_to_mercury.nl:
Add new inst `free(Type)' and new inst_names `typed_ground(Type)'
and `typed_inst(Type, Inst)' so that we can propagate type
information through the mode system.
Do some of the work necessary to propagate type info to modes.
type_util.nl:
Add an extra output argument to type_to_type_id so that it can
return the type's arguments; also fix a determinism error in
type_to_type_id.
hlds.nl:
Add a comment.
list.nl:
Fix the determinism annotation for same_length.
map.nl:
Add map__apply_to_list.
mode_info.nl:
Add mode_info__get_types_of_vars.
Makefile.mercury:
Fix the definition of MERCC.
hlds.nl:
For each discriminated union type, store the tags for the
constructors for that type, and store whether
or not the type is an enumeration type.
make_hlds.nl, make_tags.nl:
Added a new file `make_tags.nl' which is caled from make_hlds.nl
to computes the above info.
type_util.nl:
In type_is_enumeration, use the flag stored in the HLDS rather
than recomputing it on demand.
undef_types.nl:
Minor change to match the changes in hlds.nl.
mercury_compile.nl:
Ensure that foo.err depends on foo.nl.
Dump the hlds before liveness analysis as well as after
compilation (this is probably just a temporary hack).