mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-16 06:14:59 +00:00
ec86c88404a46a2bbfb8dad31852f430d5ce7eb0
181 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
14728289fa |
Remove support for NU-Prolog and SICStus Prolog.
Estimated hours taken: 5
Remove support for NU-Prolog and SICStus Prolog.
The reasons for this are:
(a) We now have a proper working debugger, so we don't need to use
NU-Prolog or SICStus Prolog for debugging.
(b) The Prolog support was only ever a hack, not a proper solution;
Mercury language features like functions or mode reordering
were never supported.
(c) It was a maintenance problem.
compiler/make_hlds.m:
Warn that NU-Prolog `when' declarations are deprecated.
compiler/prog_io.m:
Update a comment to say that NU-Prolog `when' declarations
are now deprecated.
library/*.m:
Delete `when' declarations.
configure.in:
bindist/bindist.configure.in:
Delete the autoconf tests for NU-Prolog and SICStus Prolog.
Delete the stuff for generating the NU-Prolog and SICStus Prolog
scripts.
tools/bootcheck:
Delete the options for testing using SICStus Prolog.
library/Mmakefile:
Delete the rules for building NU-Prolog and SICStus Prolog stuff.
library/library.nu.nl.in:
library/swi_*.m:
library/*.nu.nl:
library/array.nu.nl:
library/assoc_list.nu.nl:
library/char.nu.nl:
library/float.nu.nl:
library/int.nu.nl:
library/io.nu.nl:
library/library.nu.nl.in:
library/map.nu.nl:
library/mercury_builtin.nu.nl:
library/nc_builtin.nl:
library/require.nu.nl:
library/sp_builtin.nl:
library/sp_lib.nl:
library/std_util.nu.nl:
library/store.nu.nl:
library/string.nu.nl:
library/swi_builtin.m:
library/swi_lib.m:
library/term_io.nu.nl:
Delete these files.
scripts/mnc.in:
scripts/mnp.in:
scripts/mnl.in:
scripts/msc.in:
scripts/msl.in:
scripts/msp.in:
Delete these files.
doc/user_guide.texi:
Delete the documentation about the Prolog support.
NEWS:
w3/news/newsdb.inc:
Mention that we've removed the Prolog support.
|
||
|
|
474a223d6d |
Fix typo in comment: s/fals/fails/
Estimated hours taken: 0.01 compiler/prog_io.m: Fix typo in comment: s/fals/fails/ |
||
|
|
fbfb6de3ae |
Fix a bug reported by Warwick Harvey <wharvey@cs.monash.edu.au>.
Estimated hours taken: 0.75 Fix a bug reported by Warwick Harvey <wharvey@cs.monash.edu.au>. compiler/prog_io.m: Don't complain if the module name in the final `end_module' declaration doesn't match the expected name for the top-level module, because it could be for a nested module. compiler/make_hlds.m: Report errors for unexpected `module' and `end_module' declarations. This will catch the cases that used to be caught by prog_io.m, among others. |
||
|
|
5c955626f2 |
These changes make var' and term' polymorphic.
Estimated hours taken: 20 These changes make `var' and `term' polymorphic. This allows us to make variables and terms representing types of a different type to those representing program terms and those representing insts. These changes do not *fix* any existing problems (for instance there was a messy conflation of program variables and inst variables, and where necessary I've just called varset__init(InstVarSet) with an XXX comment). NEWS: Mention the changes to the standard library. library/term.m: Make term, var and var_supply polymorphic. Add new predicates: term__generic_term/1 term__coerce/2 term__coerce_var/2 term__coerce_var_supply/2 library/varset.m: Make varset polymorphic. Add the new predicate: varset__coerce/2 compiler/prog_data.m: Introduce type equivalences for the different kinds of vars, terms, and varsets that we use (tvar and tvarset were already there but have been changed to use the polymorphic var and term). Also change the various kinds of items to use the appropriate kinds of var/varset. compiler/*.m: Thousands of boring changes to make the compiler type correct with the different types for type, program and inst vars and varsets. |
||
|
|
270c12e80e |
Report an error if the first argument of a `some' goal
Estimated hours taken: 0.75 Report an error if the first argument of a `some' goal is not a list of variables. compiler/prog_io.m: compiler/prog_io_util.m: Move `parse_list_of_vars' from prog_io.m to prog_io_util.m. compiler/prog_io_goal.m: Check to make sure that the first argument to a some goal is a list of variables. (If not, we don't report an error here -- the error will be reported by typecheck.m.) compiler/typecheck.m: Report an proper error message if there is a call to an undefined predicate `some/2'. Also add `some/2' and `all/2' to the list of language builtins for which we report a special error message if they occur as undefined function symbols. tests/invalid/Mmakefile: tests/invalid/some.m: tests/invalid/some.err_exp: Regression test for the above change. |
||
|
|
a593e51f63 |
Change the syntax for existential type class constraints to use
Estimated hours taken: 1 Change the syntax for existential type class constraints to use `=>' instead of `&'. We eventually decided that `=>' was better, even though semantically speaking it's more like conjunction than implication, because of the symmetry with `<=' for universal type class constraints, and because the precedence of `=>' matches what we want. [However, the associativity might not.] compiler/prog_io.m: Update the code that parses existential type class constraints. compiler/mercury_to_mercury.m: Update the code that prints existential type class constraints. tests/hard_coded/typeclasses/existential_type_classes.m: tests/debugger/existential_type_classes.m: Update the test case that tests existential type class constraints. Also add a test of passing typeclass_infos to C code. |
||
|
|
f1f6c52439 |
For existential quantifiers in data declarations,
Estimated hours taken: 0.25 compiler/prog_io.m: For existential quantifiers in data declarations, check that the first argument of the quantifier has the correct syntax (a list of variables). |
||
|
|
6455e041cb |
Merge in the changes from the existential types branch,
Estimated hours taken: 6
(plus another 80 or so already recorded for
my commits on the existential_types branch)
Merge in the changes from the existential types branch,
and make some modifications to address dgj's code review comments.
These changes add support for existentially quantified type variables
and type class constraints on functions and predicates.
(Existential data types, however, are not supported -- see below.)
Existentially quantified type variables are introduced with
an explicit `some [T]', e.g. `:- some [T] pred foo(T)'.
Existentially quantified type class constraints are introduced
with `&' instead of `<=', e.g. `:- some [T] (pred foo(T) & ord(T))'.
There's still several limitations:
0. XXX It's not yet documented in the language reference manual.
1. XXX It doesn't do any mode checking or mode reordering.
If you write code that uses existentially typed procedures in the
wrong order, then you'll get an internal error in polymorphism.m
or in the code generator. (Cases where a type_info has no
producer at all are caught by the check for unbound type
variables in post_typecheck.m.)
To support this, we need to change things so that polymorphism.m
gets invoked before mode checking.
2. Using `in' modes on arguments of existential type won't work.
If you try, you will get a compile error.
It would be nice to extend things to allow this kind of
"implied mode" for type_infos, where an existential type
becomes a universal type if some value of that type is
input. Supporting this would require first fixing
limitation 1 (described above) and then
3. There's no support for `pragma c_code' for procedures
with existential type class constraints.
(In fact, there's not really any support for `pragma c_code'
for procedures with universal type class constraints either --
the C code has no way of getting access to the type class info.)
4. XXX Taking the address of something which is existentially typed
should be illegal, but we don't check this.
In addition, these changes in this batch make a start towards allowing
existentially typed data types. The compiler now accepts existential
quantifiers and type class constraints on type definitions, and type
checks them accordingly (assuming all functor occurrences are
deconstructors, not constructors -- see limitation 2 above). But
there's no special handling for them in polymorphism.m, so if you try
to use them, it will abort with an internal error.
The changes also includes fixes for a couple of bugs in typechecking
and polymorphism that I discovered while making the above changes,
and an improvement to the error reporting from typecheck.m in one case.
Those changes are listed separately below.
compiler/prog_data.m:
Add a new type `class_constraints', which holds two different
lists of constraints, namely the existentially quantified constraints
and the universally quantified ones.
Add a new field to the parse tree representation of pred and
func declarations to hold a list of the existentially quantified
type variables, and change the `list(class_constraint)' into
`class_constraints' so that we can store existential constraints too.
Add new fields to the `constructor' data type (formerly just a pair)
to hold the existentially quantified type variables and
type class constraints.
compiler/hlds_pred.m:
Add several new fields to the pred_info:
- a list of the existentially quantified type variables;
- a list of the "HeadTypeParams": type variables which
cannot be bound by this predicate (i.e. those whose type_infos
come from this pred's caller or are returned from
other preds called by this one);
- and a list of unsatisfied type class constraints.
Add a predicate pred_info_get_univ_quant_tvars to compute the
universally quantified type variables.
Change the pred constraints field from `list(class_constraint)'
to `class_constraints' so that it can hold existential constraints too.
compiler/hlds_data.m:
Add new fields to hlds_cons_defn to hold the existentially
quantified type variables and type class constraints.
compiler/*.m:
Minor changes to reflect the above-mentioned data structure
changes in prog_data.m, hlds_pred.m, and hlds_data.m.
compiler/prog_io.m:
Add code to parse the new constructs.
Also rewrite the code for parsing purity specifiers,
type quantifiers and type class constraints, using basically
the method suggested by Peter Schachte: treat these as
"declaration attributes", and have parse_decl strip off
all the declaration attributes into a seperate list and
then pass that list to process_decl, which for each different
kind of declaration processes the attributes which are
appropriate for that declaration and then calls check_no_attributes
to ensure that there were no inappropriate attributes.
The purpose of this rewrite was to allow it to handle the new
constructs properly, and to avoid unnecessary code duplication.
compiler/mercury_to_mercury.m:
Add code to pretty-print the new constructs.
compiler/make_hlds.m:
Copy the new fields in the parse tree into the
corresponding new fields in the pred_info.
Add code to check for various misuses of quantifiers.
compiler/hlds_out.m:
Print out the new fields in the pred_info (except the
unsatisfied type class constraints -- if these are non-empty,
post_typecheck.m will print them out in the error message).
When printing out types, pass the AppendVarNums parameter down,
so that HLDS dumps will distinguish between different type
variables that have the same name.
Delete hlds_out__write_constructor, since it was doing exactly
the same thing as mercury__output_ctor.
compiler/typecheck.m:
Lots of changes to handle existential types and existential
type class constraints.
compiler/post_typecheck.m:
When checking for unbound type variables,
use the value of HeadTypeParams from the pred_info.
compiler/type_util.m:
Delete `type_and_constraint_list_matches_exactly', since it was not
used. Add various `apply_variable_renaming_to_*' predicates for
renaming constraints.
compiler/polymorphism.m:
Lots of changes to handle existential types and existential
type class constraints.
Also some changes to make the code more maintainable:
compiler/prog_data.m:
compiler/hlds_goal.m:
compiler/mercury_to_mercury.m:
Put curly braces around the definitions of 'some'/2 and '&'/2 functors
in `:- type' definitions, to avoid them being misinterpreted as
existential type constraints.
compiler/goal_util.m:
compiler/polymorphism.m:
compiler/hlds_pred.m:
compiler/lambda.m:
Include type_infos for existentially quantified type variables
and type_class_infos for existential constraints
in the set of extra variables computed by
goal_util__extra_type_info_vars.
compiler/inlining.m:
Change inlining__do_goal to handle inlining of calls to
existentially typed predicates -- for them, instead of not
binding any type variables at all in the caller, it allows the
call to bind any type variables in the caller except for those
that are universally quantified.
compiler/inlining.m:
compiler/deforest.m:
Call pred_info_get_univ_quant_tvars and pass the
result to inlining__do_inline_goal.
tests/hard_coded/Mmakefile:
tests/hard_coded/existential_types_test.{m,exp}:
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/existential_type_classes.{m,exp}:
Test cases for the use of existential types and
existential type class constraints.
----------
Improve an error message.
compiler/typecheck.m:
Improve error reporting by checking type class constraints for
satisfiability as we go and thus reporting unsatisfiable constraints
as soon as possible, rather than only at the end of the clause.
Previously we already did that for the case of ground constraints,
but they are not the only unsatsfiable constraints: constraints
on head type params (type variables which cannot be bound) are
also unsatisfiable if they can't be eliminated straight away
by context reduction.
tests/invalid/Mmakefile:
tests/invalid/typeclass_test_7.{m,err_exp}:
Regression test for the above change.
----------
Avoid problems where type inference was reporting some
spurious errors for predicates using type classes,
because the check for unsatisfied type class constraints
was being done before the final pass of type inference
had finished.
compiler/hlds_pred.m:
Add new field to the pred_info containing the unproven
type class constraints.
compiler/typecheck.m:
When inferring type class constraints, make sure that before
we save the results back in the pred_info, we restrict the
constraints to the head type variables. Constraints
on other type variables should be treated as
unsatisfied constraints.
Don't check for unsatisfied type class constraints at the
end of each pass; instead, just save the unproven type class
constraints in the pred_info.
compiler/post_typecheck.m:
Check for unsatisfied type class constraints, using
the new field in the pred_info.
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/inference_test_2.{m,exp}:
tests/invalid/Mmakefile:
tests/invalid/typeclass_test_8.{m,err_exp}:
Add regression tests for this change.
----------
Fix a bug with the computation of the non-locals for
predicates with more than one constraint on the same type variable --
it was only including one of the type-class-infos, rather than all of them.
compiler/goal_util.m:
Change `goal_util__extra_nonlocal_typeinfos' so that it gets
passed the TypeClassInfoVarMap and uses this to include all
the appropriate typeclass infos in the extra nonlocals.
compiler/hlds_pred.m:
compiler/lambda.m:
compiler/polymorphism.m:
Pass the TypeClassInfoVarMap to `goal_util__extra_nonlocal_typeinfos'.
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/lambda_multi_constraint_same_tvar.{m,exp}:
Regression test for the above-mentioned bug.
|
||
|
|
19ed0e5a32 |
Avoid spurious warning messages about source file
Estimated hours taken: 0.1 compiler/prog_io.m: Avoid spurious warning messages about source file `bar.m' containing module `foo:bar' -- this case is supported, and should not trigger a warning. |
||
|
|
e880e3ac59 |
Allow modules to be put in source files whose names do not directly match
Estimated hours taken: 12 Allow modules to be put in source files whose names do not directly match their the module names. When looking for the source for a module such as `foo:bar:baz', search for it first in `foo.bar.baz.m', then in `bar.baz.m', and finally in `baz.m'. compiler/prog_io.m: Change prog_io__read_module so that it returns the name of the module read, as determined by the `:- module' declaration. Add predicate `check_module_has_expected_name', for checking that this name matches what was expected. compiler/modules.m: Add read_mod_from_file, for reading a module given the file name, and generated_file_dependencies, for generating the dependencies of a module given the file name. (As opposed to the module name.) Change read_mod and read_mod_ignore_errors so that they search for `.m' files as described above, and return the name of the source file read. Also improve the efficiency of read_dependencies slightly: when reading in `.int' files, there's no need to call split_into_submodules, because we generate a seperate `.int' file for each submodule anyway. compiler/mercury_compile.m: Change the handling of command-line arguments. Arguments ending with `.m' are assumed to be file names, and other arguments are assumed to be module names. For file names, call read_mod_from_file instead of read_mod. compiler/handle_options.m: Change help message to reflect the above change to the semantics of command-line arguments. compiler/intermod.m: compiler/trans_opt.m: Fix a bug: call prog_io__read_opt_file instead of prog_io__read_module. doc/user_guide.texi: Document the above change to the semantics of command-line arguments. Update the "libraries" chapter to reflect our support for nested modules. tests/*/*.m: tests/*/*.exp: Fix a few incorrect module names in `:- module' declarations. |
||
|
|
9e02faf9c4 |
Implement compiler support for nested sub-modules.
Estimated hours taken: 5 Implement compiler support for nested sub-modules. (Mmake support is still missing, so you have to compile by hand. Also you must use `ml' to link rather `mmc', because `mmc' doesn't link all the object files that it generates.) compiler/prog_io.m: Fix a couple of bugs in the parsing of `module' and `end_module' declarations. compiler/mercury_to_mercury.m: Handle output of `:- module' and `:- end_module' declarations. compiler/modules.m: Add predicate split_into_submodules, which takes the item_list for a module and splits it into a list of item_lists for each submodule. compiler/mercury_compile.m: Change the code for creating interface files and generating LLDS fragments so that it calls split_into_submodules and then iterates over each submodule. That means that we now generate a seperate HLDS for each submodule, and compile that to a seperate LLDS and a seperate C file. It would be more efficient to combine the LLDS fragments for each submodule after code generation, generate a single C file, and thus only invoke the C compiler once. In view of this goal, I have done some cleaning up of the HLDS/LLDS distinction, so that we don't need to pass the HLDS to the various LLDS output routines. (However, I haven't actually gotten as far as combining the LLDS code fragments.) compiler/llds.m: Add type `c_interface_info' which contains information from the HLDS that is used during the LLDS output pass. compiler/mercury_compile.m: Add a predicate `get_c_interface_info' which gets the relevant info from the HLDS that is needed for LLDS output. compiler/export.m: Add `export__get_c_export_decls', and rename `export__get_pragma_exported_procs' as `export__get_c_export_defns'. Change export__produce_header_file so that it takes a `c_export_decls' (part of the `c_interface_info') instead of an HLDS. |
||
|
|
11d8161692 |
Add support for nested modules.
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.
|
||
|
|
72ff8fffe3 |
A few minor changes, including fixing the syntax of a typeclass declaration.
Estimated hours taken: 1/2
A few minor changes, including fixing the syntax of a typeclass declaration.
The methods inside a typeclass declaration no longer have a ":-" at the start.
compiler/make_hlds.m:
Give an error message is a typeclass is multiply defined.
compiler/prog_io.m:
Export parse_decl, and make the output a maybe_item_and_context so
that it is more useful to prog_io_typeclass.
compiler/prog_io_typeclass.m:
Use parse_decl rather than parse_item to parse the class methods. This
way the ":-" is left off.
compiler/notes/compiler_design.html:
Document why check_typeclass is the final semantic analysis pass.
|
||
|
|
82744e5b95 |
Add new options for disabling some warnings, so that they
Estimated hours taken: 1 Add new options for disabling some warnings, so that they can be disabled by `--inhibit-warnings'. compiler/options.m: Add new options `warn-missing-module-name' and `warn-wrong-module-name' (enabled by default), and ensure that `--inhibit-warnings' disables these options. compiler/prog_io.m: Add code to conditionalize the printing of warnings based on the settings of the new options. doc/user_guide.texi: Document the new options. tests/valid/Mmakefile: tests/valid/inhibit_warn_test.m: A regression test. |
||
|
|
7406335105 |
This change implements typeclasses. Included are the necessary changes to
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. |
||
|
|
bf824facde |
Make Mercury cope with impure code
The purpose of this diff is to allow Mercury programs to contain
impure Mercury code without the compiler changing its behavior
inappropriately, while still allowing the compiler to aggressively
optimize pure code. To do this, we require impure predicates to be so
declared, and calls to impure predicates to be flagged as such. We
also allow predicates implemented in terms of impure predicates to be
promised to be pure; lacking such a promise, any predicate that calls
an impure predicate is assumed to be impure.
At the moment, we don't allow impure functions (only predicates),
though some of the work necessary to support them has been done.
Note that to make the operators work properly, the precedence of the
`pred' and `func' operators has been changed from 1199 to 800.
Estimated hours taken: 150
compiler/purity.m:
New compiler pass for purity checking.
compiler/hlds_goal.m:
Add `impure' and `semipure' to the goal_feature enum.
compiler/hlds_out.m:
compiler/typecheck.m:
compiler/special_pred.m:
Fixed code that prints predicate name to write something more
helpful for special (compiler-generated) predicates. Added
code to print new markers. Added purity argument to
mercury_output_pred_type. New public predicate
special_pred_description/2 provides an english description for
each compiler-generated predicate.
compiler/hlds_pred.m:
Add `impure' and `semipure' to marker enum. Added new
public predicates to get predicate purity and whether or not
it's promised to be pure.
compiler/prog_data.m:
compiler/mercury_to_mercury.m:
compiler/prog_io.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_dcg.m:
compiler/prog_util.m:
compiler/equiv_type.m:
compiler/intermod.m:
compiler/mercury_to_c.m:
compiler/module_qual.m:
Add purity argument to pred and func items. Add new `impure'
and `semipure' operators. Add promise_pure pragma. Add
purity/2 wrapper to goal_expr type.
compiler/make_hlds.m:
compiler/mercury_to_goedel.m:
Added purity argument to module_add_{pred,func},
clauses_info_add_pragma_c_code, and to pred and func items.
Handle promise_pure pragma. Handle purity/2 wrapper used to
handle user-written impurity annotations on goals.
compiler/mercury_compile.m:
Add purity checking pass between type and mode checking.
compiler/mode_errors.m:
Distinguish mode errors caused by impure goals preventing
goals being delayed.
compiler/modes.m:
Don't delay impure goals, and ensure before scheduling an
impure goal that no goals are delayed. Actually, we go ahead
and try to schedule goals even if impurity causes a problem,
and then if it still doesn't mode check, then we report an
ordinary mode error. Only if the clause would be mode correct
except for an impure goal do we report it as an impurity problem.
compiler/simplify.m:
Don't optimize away non-pure duplicate calls. We could do
better and still optimize duplicate semipure goals without an
intervening impure goal, but it's probably not worth the
trouble. Also don't eliminate impure goals on a failing branch.
compiler/notes/compiler_design.html:
Documented purity checking pass.
doc/reference_manual.texi:
Document purity system.
doc/transition_guide.texi:
library/nc_builtin.nl:
library/ops.m:
library/sp_builtin.nl:
New operators and new precdence for `pred' and `func'
operators.
tests/hard_coded/purity.m
tests/hard_coded/purity.exp
tests/hard_coded/Mmakefile:
tests/invalid/purity.m
tests/invalid/purity_nonsense.m
tests/invalid/purity.err_exp
tests/invalid/purity_nonsense.err_exp
tests/invalid/Mmakefile:
Test cases for purity.
|
||
|
|
fa8a94feaf |
Improve the error messages for certain kinds of syntax errors,
Estimated hours taken: 1 Improve the error messages for certain kinds of syntax errors, where variables occur in places that they shouldn't. compiler/prog_io_goal.m: Change parse_qualified_term to take an extra argument, the "containing" term, in case the term being parsed is a term__variable, which will not have a term__context. Use the new argument to give better error messages. compiler/make_hlds.m: compiler/prog_io.m: compiler/prog_io_dcg.m: compiler/prog_io_pragma.m: compiler/prog_io_util.m: Changed calls to parse_qualified_term to pass the new argument. tests/invalid/Mmakefile: tests/invalid/vars_in_wrong_places.m: tests/invalid/vars_in_wrong_places.err_exp: Test cases for the above change. |
||
|
|
f9ad85698a |
Add termination analysis to the compiler. The termination analysis
Estimated hours taken: 500 Add termination analysis to the compiler. The termination analysis annotates each procinfo structure with termination information stating whether each procedure is guaranteed to terminate. Add transitive intermodule optimization to the compiler. Transitive intermodule optimization uses .trans_opt files to store optimization information. The difference between .trans_opt files and .opt files is that .trans_opt files may depend on other .trans_opt files, whereas .opt files may only depend on a .m file. compiler/termination.m: New file. The main module which controls the termination analysis. compiler/term_pass1.m: New file. This file implements the first pass of the termination analysis which attempts to derive relationships between the relative sizes of variables. This information is used by term_pass2.m compiler/term_pass2.m: New file. The second pass of the termination analysis attempts to prove that each predicate or function in the program is guaranteed to terminate. compiler/term_util.m: New file. Contains utilities which are used in various stages of the termination analysis. compiler/term_errors.m: New file. Contains predicates for printing out error messages produced by termination analysis. compiler/trans_opt.m: New file. This module contains predicates for both reading in and writing .trans_opt files. compiler/globals.m: compiler/handle_options.m: compiler/options.m: Various modifications to handle the new options. Some of the new options imply other options, and the `--termination-norm' option is a string option which needs processing. compiler/hlds_goal.m: Added a comment that the list(uni_mode) subfield of construct, and the unify_mode subfield of unify are not necessarily valid when the unification applies to higher order terms. compiler/hlds_out.m: Added code to output termination information, as well as code to print out the new markers. compiler/hlds_pred.m: Added the termination subfield to the proc_info structure and added code to support it. Also added support for the new markers. compiler/make_hlds.m: compiler/mercury_to_mercury.m: compiler/module_qual.m: compiler/modules.m: compiler/prog_io_pragma.m: Added support for the new pragmas, `termination_info', `teminates', `check_termination' and `does_not_terminate'. compiler/prog_data.m: Added the new pragmas to the pragma_type. Also reformatted the type declarations to conform with the coding specifications. compiler/prog_io.m: Reformatted some code and comments. compiler/mercury_compiler.m: Added code to call the termination analyser and to call the predicate which creates .trans_opt files. doc/reference_manual.texi: Documented the termination analysis and the new pragmas. doc/user_guide.texi: Documented the new options. |
||
|
|
b461464647 |
Delete an obsolete comment.
Estimated hours taken: 0.1. prog_io.m: Delete an obsolete comment. |
||
|
|
3d920e328f |
Fix of some documentation rot: We _do_ know how to do a
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. |
||
|
|
99184d3578 |
Implement support for types with user-defined equality predicates.
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. |
||
|
|
04b720630b |
Update the copyright messages so that (a) they contain the correct years
and (b) they say "Copyright (C) ... _The_ University of Melbourne". |
||
|
|
9b7f11c6dd |
Reorganisation of modules to do with the inst data type.
Estimated hours taken: 20 Reorganisation of modules to do with the inst data type. This is actually the first installment of the alias tracking mode checker in disguise. A very good disguise. The rationale for this reorganisation is to reduce coupling in the part of the mode checker which is _not_ in this change (ie most of it). Alias tracking requires a new kind of inst, alias(inst_key), where an inst_key is a handle on some other sub-inst. With it goes a data structure in which to store dereferenced insts and all the operations which go with it. This code will go in the new module inst.m so that it doesn't have to go in prog_data.m. (I briefly considered putting it in instmap.m however this introduces some bad coupling since instmap.m imports hlds_module.m. Putting it in prog_data.m would cause hlds_*.m to depend on prog_data.m, but we have designed things so that the dependencies go in the other direction.) The remainder of the reorganisation is a general cleanup: the inst testing predicates (inst_is_*) have been moved out of mode_util because they are not actually operations on modes at all, and have been moved into inst_match. inst_match has then been split because otherwise it would be 2000 lines long and will get significantly bigger when aliasing is added. Roughly speaking, any operations which create new insts from old ones have been moved into a new module, inst_util while any operations which test the values of insts remain in inst_match. Also included are the removal of some NU-Prologisms since the NU-Prolog version of the compiler is no longer supported. Two changes here: - Removal of some when declarations. - A gross hack in inst_is_*_2, where two copies of the same inst were passed into the predicate so that one could be switched on. Thank NU-Prolog's lack of common subexpression elimination. compiler/inst.m: New module which contains the data types inst, uniqueness, pred_inst_info, bound_inst. compiler/inst_util.m: New module which contains predicates which perform mode checking-like operations on insts. Moved in: abstractly_unify_inst, abstractly_unify_inst_functor, inst_merge, make_mostly_uniq_inst (from inst_match.m) compiler/inst_match.m: Moved out: inst_merge, make_mostly_uniq_inst, abstractly_unify_inst, abstractly_unify_inst_functor (to inst_util.m) Moved in: inst_is_*, inst_list_is_*, bound_inst_list_is_* (from mode_util.m) Now exported: unique_matches_initial/2, unique_matches_final/2 inst_contains_instname/3, pred_inst_matches/3 (They are required by inst_util.m, and they are useful in their own right.) compiler/instmap.m: instmap_delta_lookup_var/3 reincarnated as instmap_delta_search_var/3. The reason for this change is that previously, instmap_delta_lookup_var simply returned `free' if the searched-for var did not occur in the instmap_delta. This is somewhat non-obvious behaviour. instmap_delta_search_var/3 fails in such a situation. compiler/mode_util.m: Moved out: inst_is_*, inst_list_is_*, bound_inst_list_is_* (to inst_match.m) (These are not really operations on modes.) compiler/modecheck_call.m: Moved in modecheck_higher_order_func_call/5, from modecheck_unify.m compiler/modecheck_unify.m: Moved out modecheck_higher_order_func_call/5, to modecheck_call.m where it should have been all along. compiler/prog_data.m: Moved out the types inst, uniqueness, pred_inst_info, bound_inst (to inst.m). compiler/common.m: compiler/cse_detection.m: compiler/fact_table.m: compiler/higher_order.m: compiler/hlds_data.m: compiler/hlds_goal.m: compiler/hlds_out.m: compiler/intermod.m: compiler/liveness.m: compiler/llds.m: compiler/make_hlds.m: compiler/mercury_to_mercury.m: compiler/mode_debug.m: compiler/mode_errors.m: compiler/mode_info.m: compiler/modes.m: compiler/module_qual.m: compiler/polymorphism.m: compiler/prog_io.m: compiler/prog_io_util.m: compiler/prog_util.m: compiler/simplify.m: compiler/switch_detection.m: compiler/unify_proc.m: compiler/unique_modes.m: Miscellaneous minor changes to cope with the above changes. compiler/notes/compiler_design.html: Document the new modules. |
||
|
|
9b5428d0f5 |
Fix some bugs where the compiler was silently ignoring certain errors.
Estimated hours taken: 1.5 Fix some bugs where the compiler was silently ignoring certain errors. compiler/prog_io.m: Check for some possible errors in function declarations that were previously being silently ignored. Specifically, we now catch cases where a function type declaration includes modes for some but not all of its arguments or return value, or where it includes a determinism but no modes. tests/invalid/Mmake: tests/invalid/func_errors.m: tests/invalid/func_errors.err_exp: Test case for the above change. |
||
|
|
3abef80dc1 |
Trivial aesthetic change: when calling parse_qualified_term,
Estimated hours taken: 0.25 compiler/prog_io.m: compiler/prog_io_util.m: Trivial aesthetic change: when calling parse_qualified_term, pass a reasonable human-readable string for the context, even in cases where the context won't be used. |
||
|
|
27d156bbb5 |
Implemented a :- use_module directive. This is the same as
Estimated hours taken: 14 Implemented a :- use_module directive. This is the same as :- import_module, except all uses of the imported items must be explicitly module qualified. :- use_module is implemented by ensuring that unqualified versions of items only get added to the HLDS symbol tables if they were imported using import_module. Indirectly imported items (from `.int2' files) and items declared in `.opt' files are treated as if they were imported with use_module, since all uses of them should be module qualified. compiler/module_qual.m Keep two sets of type, mode and inst ids, those which can be used without qualifiers and those which can't. Renamed some predicates which no longer have unique names since '__' became a synonym for ':'. Made mq_info_set_module_used check whether the current item is in the interface, rather than relying on its caller to do the check. Removed init_mq_info_module, since make_hlds.m now uses the mq_info built during the module qualification pass. compiler/prog_data.m Added a pseudo-declaration `used', same as `imported' except uses of the following items must be module qualified. Added a type need_qualifier to describe whether uses of an item need to be module qualified. compiler/make_hlds.m Keep with the import_status whether current item was imported using a :- use_module directive. Use the mq_info structure passed in instead of building a new one. Ensure unqualified versions of constructors only get added to the cons_table if they can be used without qualification. compiler/hlds_module.m Added an extra argument to predicate_table_insert of type need_qualifier. Only add predicates to the name and name-arity indices if they can be used without qualifiers. Changed the structure of the module-name-arity index, so that lookups can be made without an arity, such as when type-checking module qualified higher-order predicate constants. This does not change the interface to the module_name_arity index. Factored out some common code in predicate_table_insert which applies to both predicates and functions. compiler/hlds_pred.m Removed the opt_decl import_status. It isn't needed any more since all uses of items declared in .opt files must now be module qualified. Added some documentation about when the clauses_info is valid. compiler/intermod.m Ensure that predicate and function calls in the `.opt' file are module qualified. Use use_module instead of import_module in `.opt' files. compiler/modules.m Handle use_module directives. Report a warning if both use_module and import_module declarations exist for the same module. compiler/mercury_compile.m Collect inter-module optimization information before module qualification, since it can't cause conflicts any more. This means that the mq_info structure built in module_qual.m can be reused in make_hlds.m, instead of building a new one. compiler/prog_out.m Add a predicate prog_out__write_module_list, which was moved here from module_qual.m. compiler/typecheck.m Removed code to check that predicates declared in `.opt' files were being used appropriately, since this is now handled by use_module. compiler/*.m Added missing imports, mostly for prog_data and term. NEWS compiler/notes/todo.html doc/reference_manual.texi Document `:- use_module'. tests/valid/intermod_lambda_test.m tests/valid/intermod_lambda_test2.m tests/invalid/errors.m tests/invalid/errors2.m Test cases. |
||
|
|
cbcb23d17b |
Enable --warn-interface-imports by default.
Estimated hours taken: 3
Enable --warn-interface-imports by default. This was turned off while
list and term were defined in mercury_builtin.m, since it caused many
warnings.
Fix all the unused interface imports that have been added since then.
compiler/options.m:
Enable --warn-interface-imports by default.
compiler/module_qual.m:
Fix formatting inconsistencies with module names in warning
messages. (".m" was not appended to module names if there was
only one module).
compiler/*.m:
library/*.m:
tests/invalid/type_loop.m:
tests/warnings/*.m:
Remove usused interface imports, or move them into
implementation (mostly bool, list and std_util).
|
||
|
|
3ec8a17ffc |
Enable the code to treat `__' as an alternative syntax for module
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. |
||
|
|
f12d206b57 |
Add code to treat `__' as an alternative syntax for 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. |
||
|
|
1839ebb663 |
Module qualification of constructors.
Estimated hours taken: 15
Module qualification of constructors.
compiler/modes.m
compiler/unique_modes.m
compiler/modecheck_unify.m
compiler/modecheck_call.m
Enable propagate_type_info_into_modes.
Use type information to module qualify cons_ids.
compiler/mode_util.m
Use propagate_type_information_into_modes to module qualify cons_ids
in bound insts.
typed_ground/2 and free/1 insts are not yet generated, since they
are not yet used anywhere.
Avoid expanding insts when propagating type information, since
that is not yet useful.
I still need to fix the handling of
inst_matches_{initial, final, binding}(
ground(_, _), bound(_, [all_functors_in_the_type]))
compiler/typecheck.m
Don't assume a module qualified cons_id is a function call
or higher-order pred constant.
compiler/modes.m
compiler/unique_modes.m
compiler/modecheck_unify.m
compiler/instmap.m
compiler/inst_match.m
Remove some unnecessary conversion between cons_ids and consts.
compiler/typecheck.m
compiler/mode_errors.m
Strip builtin qualifiers from cons_ids.
compiler/mercury_to_mercury.m
Output module qualified cons_ids.
compiler/prog_io.m
compiler/prog_io_util.m
Module qualify constructors in type definitions.
Parse qualified cons_ids in bound insts.
compiler/hlds_data.m
Remove cons_id_to_const/3, since it doesn't make much sense any more.
Add cons_id_arity/2 and cons_id_and_args_to_term/3.
compiler/make_hlds.m
Add both qualified and unqualified versions of each cons_id to
the cons_table.
compiler/det_util.m
Handle module qualified cons_ids in det_util__interpret_unify.
compiler/code_util.m
Remove some dead code in code_util__cons_id_to_tag to do with
tags for higher-order terms. Don't assume module qualified
cons_ids are higher-order pred constants.
compiler/polymorphism.m
Module qualify type_info cons_ids.
|
||
|
|
91c4330db7 |
The first half of a change to introduce nondet pragma C goals.
Estimated hours taken: 12 The first half of a change to introduce nondet pragma C goals. This half makes the necessary modifications to the HLDS; the next half will modify the LLDS and emit it. prog_data: Add a new pragma type for nondet pragma c_codes; these specify the names of a a bunch of variables to save across backtracking, and a list of label names to which backtracking may take place. Rename is_recursive to may_call_mercury, since this is a more direct expression of the meaning. prog_io: Move much of the functionality to new files. prog_io_dcg, prog_io_goal, prog_io_pragma, prog_io_util: New files, made up of pieces of prog_io. hlds_goal: Add an extra argument to the pragma_c_goals to store the extra information present in the new type of pragma c_codes. det_analysis: Take into account that the new type of pragma_c goal may have more than one solution. goal_util: Rename variables in the new field of pragma_cs. live_vars: Allocate stack slots to the saved variables in the new type of pragma_c goals. make_hlds: Handle the new type of pragma_c goals. mercury_output, hlds_out: Output the new type of pragma_c goals. garbage_out: Rename type "det" to "frame_type". others: Ignore one more arg of pragma_c goals or import prog_io_util. |
||
|
|
bb2b816787 |
* Inter-module unused argument removal.
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. |
||
|
|
d0e054223a |
Allow `pragma export' for semidet predicates and for det/semidet functions.
Estimated hours taken: 4 Allow `pragma export' for semidet predicates and for det/semidet functions. (Previously it only worked for det predicates.) prog_data.m: Add a pred_or_func field to the pragma_export struct. prog_io.m: Add code to parse `pragma export' declarations for functions, e.g. `pragma export(foo(in) = out, "foo")'. mercury_to_mercury.m: Add code to print out `pragma export' declarations for functions. module_qual.m: Change export/3 to export/4. export.m: Handle semidet procedures -- the C function returns TRUE/FALSE depending on whether the Mercury procedure succeeded or failed. Handle functions -- for det functions whose return value has mode `out', the Mercury function return value is returned as the C function return value. Don't call save_registers() after returning from call_engine(), since call_engine() now saves them itself. When generating header files, don't make up argument names for the function prototypes, instead just leave the arguments unnamed. Also, make sure the `#ifndef HEADER_NAME_H' comes at the very start of the file, before #include "imp.h". |
||
|
|
37c5340f1c |
Added code to various sections of the compiler to parse
Estimated hours taken: 80 Added code to various sections of the compiler to parse `pragma fact_table' declarations and add them to the HLDS. Added output of fact_table dependencies to .d and .dep files. Added a new module fact_table.m for parsing the actual fact tables and generating code. This is not finished yet. Added ability to have `pragma c_code' declarations for Mercury functions. Modified Files: compiler/hlds_module.m Added predicate `module_info_set_pred_info' to add a `pred_info' entry to `module_info' given a `pred_id'. compiler/make_hlds.m Added code to handle new `pragma fact_table' declarations. New predicate `module_add_pragma_fact_table' which calls the fact compiler in fact_table.m to compile the fact table and generate C code to access it. Then add the C code to the HLDS as a `pragma c_code'. Mercury functions can now have `pragma c_code' declarations. compiler/intermod.m Included PredOrFunc argument in call to mercury_output_pragma_c_code. compiler/mercury_compile.m Added parameters to some predicates to allow fact table dependency information to be passed around. compiler/mercury_to_mercury.m Handle output of `pragma fact_table' declarations. Handle output of `pragma c_code' declarations for functions. compiler/module_qual.m Handle module qualification of `pragma fact_table' declarations. compiler/modules.m New predicate `get_fact_table_dependencies' to work out which fact tables a module depends on. Changes to `write_dependency_file' to write out fact table dependencies. Changes to some other predicates to allow fact table dependencies to be passed around the module. compiler/prog_data.m Added new functor `fact_table(sym_name, arity, string)' to the `pragma_type' type. Added a `pred_or_func' field to the `c_code' functor of the `pragma_type' type. compiler/prog_io.m Added code to `parse_pragma_type' to parse `:- pragma fact_table'. Here is a sample declaration. The facts are in a file called "factfile": :- pred facts(string, int, float). :- mode facts(out, out, out) is multidet. :- pragma fact_table(facts/3, "factfile"). Mercury functions can now have `pragma c_code' declarations. Here is a sample declaration: :- func c_add(int, int) = int. :- pragma c_code(non_recursive, c_add(A::in, B::in) = (C::out), " C = A + B; "). Added Files: compiler/fact_table.m Module not yet finished, but it compiles correctly and doesn't interfere with the rest of the compiler. Main purposes of the module are to parse the fact table file, perform type, mode and determinism checks and generate C code for the fact table. Completed so far: parsing, type and mode checking, determinism inference. A C array is output to represent the table, but no functions are produced yet to access it. |
||
|
|
4c3bbe13e2 |
Add some comments.
Estimated hours taken: 0.5 compiler/prog_io.m: compiler/prog_data.m: Add some comments. |
||
|
|
fd6f3e028f |
Report an error for attempts to redefine builtin insts.
Estimated hours taken: 1 compiler/prog_io.m: Report an error for attempts to redefine builtin insts. This change is in response to a bug report by Steve Spagnolo. It will do for now. In the long term, however, the ideal solution would be for builtin insts to be treated as being defined in module `mercury_builtin'; attempting to redefine a builtin inst should elicit at worst a warning, since if you refer to it in module qualified form things should work OK. |
||
|
|
5d64b759db |
The main changes are
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.
|
||
|
|
d0f5aada77 |
Fix bugs in the parsing of variables as goals, e.g.
Estimated hours taken: 1 compiler/prog_io.m: Fix bugs in the parsing of variables as goals, e.g. p(X) :- X. % same as p(X) :- call(X). q(X) --> X. % same as p(X, A0, A) :- call(X, A0, A). It seems that Dylan managed to break the parsing of goals such as that during his changes to introduce module qualification. |
||
|
|
9205a7e445 |
Module qualification of function calls and higher-order predicate constants.
Estimated hours taken: 6 Module qualification of function calls and higher-order predicate constants. compiler/hlds_data.m Changed the cons(string, arity) constructor of cons_id to cons(sym_name, arity). A module qualified cons_id is assumed to be a function or higher-order pred constant, since we don't yet support module qualification of constructors (Explicit type qualification is much more useful anyway, but that doesn't work yet either). compiler/hlds_goal.m Changed the functor(const, list(var)) constructor of unify_rhs to functor(cons_id, list(var)) to allow the storing of a module qualifier. compiler/make_hlds.m Parse qualified function calls and higher-order pred constants. compiler/modes.m compiler/intermod.m Take module qualifiers into account when resolving function overloading. compiler/*.m Updated unify_rhs's and cons_id's everywhere. |
||
|
|
5d3fc10571 |
- Inter-module optimization.
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. |
||
|
|
a15c032df7 |
Flesh out the code already here for traversing module_infos,
Estimated hours taken: 4 passes_aux: Flesh out the code already here for traversing module_infos, making it suitable to handle all the passes of the back end. mercury_compile: Use the traversal code in passes_aux to invoke the back end passes over each procvedure in turn. Print a one-line message for each predicate if -v is given (this fixes a long-standing bug). excess.m, follow_code.m, follow_vars.m, live_vars.m, lveness.m, store_alloc.m: Remove the code to traverse module_infos, since it is now unnecessary. export.m: Remove an unused argument from export__produce_header_file_2. others: Move imports from interfaces to implementations, or in some cases remove them altogether. |
||
|
|
cf2e95c28b |
Fix the capitalization of some more error messages.
Estimated hours taken: 0.1 compiler/prog_io.m: Fix the capitalization of some more error messages. |
||
|
|
6ebe46c20a |
Implement a new `:- pragma source_file("<source file name>").' declaration,
Estimated hours taken: 3
Implement a new `:- pragma source_file("<source file name>").' declaration,
and a `#<line number>' directive, to make it more convenient to use
preprocessors or to use Mercury as a target language.
prog_data.m:
Add `source_file' pragma.
make_hlds.m, module_qual.m:
Ignore `pragma source_file' declarations.
mercury_to_mercury.m:
Print `pragma source_file' declarations.
Simplify a couple of unnecessarily complicated bits of code.
prog_io.m:
Parse `source_file' pragmas. When parsing items, check for them;
handle `pragma source_file' declarations by keeping track of the
source file name, and passing it to parser__parse_term/4.
Also, change the "Error: module should start with a `:- module'
declaration" message from an error to a warning.
Also, fix the capitalization in a bunch of error messages:
change from "Error: Blah" to "Error: blah".
|
||
|
|
03d1f75c7e |
These changes comprise
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). |
||
|
|
5d9e4158f7 |
Module qualification of types, insts and modes.
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.
|
||
|
|
0e1e0b0b91 |
Implement recursive' and non_recursive' pragma c_code declarations.
Estimated hours taken: 4 Implement `recursive' and `non_recursive' pragma c_code declarations. This allows the compiler to optimize cases when the C code is known to not call Mercury code. It's also necessary to allow C code which modifies the hp register to work (such code must be declared `non_recursive', otherwise the registers will be saved and restored over it). To make things bootstrap OK, the old pragma c_code declarations default to `non_recursive'. prog_data.m, hlds_goal.m: Add new field c_is_recursive to pragma c_code goals. prog_io.m: Parse the new `recursive' and `non_recursive' pragma c_code declarations. make_hlds.m: Pass the c_is_recursive field from the parse tree to the HLDS. live_vars.m: For non-recursive C code, don't save variables on the stack. code_gen.pp: For non-recursive C code, don't save variables on the stack, don't mark the succip as needing to be saved, and don't call save_registers() and restore_registers(). *.m: Change c_code/5 to c_code/6. |
||
|
|
cb41c485ef |
Update a comment.
Estimated hours taken: 2 code_util: Update a comment. dead_proc_elim: Fix a progress message. hlds_out: Put a comment sign before each switch arm's "X has functor f" output, since this is not proper Prolog or Mercury syntax. make_hlds: Temporarily allow the definition of builtins, to permit bootchecking while unary builtins are added. prog_io: Improve the handling of DCG variables in if-then-elses the same way I recently improved disjunctions. Also factor out a bit of common code. |
||
|
|
c588526f03 |
Add a predicate to rename variables in the kinds of goals we have in
Estimated hours taken: 1 prog_util: Add a predicate to rename variables in the kinds of goals we have in items. (We already have similar predicates for terms and for hlds_goals). prog_io: We used to expand ( p ; q ) in DCG clauses to become ( p(DCG1, DCG2) ; q(DCG1, DCG3), DCG2 = DCG3 ). These extra unifications can pile up rather badly; in the new version of lexer.m, two 128-way switches each ended up with 90 unifications in the last arm. This is very bad for performance. Instead of adding unifications to make sure that both arms of a disjunction put the final stream value in the same variable, we now use renaming when possible. |
||
|
|
b4cf70fccc |
Rename the pragma' type as pragma_type', to avoid bootstrapping
Estimated hours taken: 0.25 prog_data.m, prog_io.m: Rename the `pragma' type as `pragma_type', to avoid bootstrapping problems caused by my change to make `pragma' an operator. |
||
|
|
a8acf00f9d |
Add a new pragma `:- pragma obsolete(Name/Arity).';
Estimated hours taken: 3 Add a new pragma `:- pragma obsolete(Name/Arity).'; the effect of this pragma is that we issue a warning for any call to the specified predicate(s) or function(s). prog_data.m: Add new pragma type `obsolete'. prog_io.m: Parse pragma `obsolete'. hlds_pred.m, hlds_out.m: Add new pred_marker `obsolete' make_hlds.m: When we encounter a pragma `obsolete', insert `request(obsolete)' in the pred_marker list for the specified predicate(s) and function(s). simplify.m: For each predicate call, check if the called predicate has been marked as obsolete. If so, return a `warn_obsolete' warning. det_report.m: Add a new warning type `warn_obsolete', and add code to print the warning for this warning type. det_analysis.m: Add a comment. |