mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 05:44:58 +00:00
77a1261d3bd0900b09d06f6d2061da9f72bf22f9
197 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6221d014b7 |
Change the function symbols in type module_errors to avoid clashes with
Estimated hours taken: 0.3 Branches: main Change the function symbols in type module_errors to avoid clashes with the function symbols of type bool. compiler/prog_io.m: Change the function symbols in type module_errors to avoid clashes with the function symbols of type bool. The new function symbols are more meaningful. compiler/intermod.m: compiler/mercury_compile.m: compiler/modules.m: compiler/recompilation_check.m: compiler/trans_opt.m: Conform to the change to module_errors. compiler/typecheck.m: Delete a now unnecessary type disambiguation. |
||
|
|
9dd11b2fc6 |
Smart recompilation. Record version numbers for each item
Estimated hours taken: 400
Smart recompilation. Record version numbers for each item
in interface files. Record which items are used in each compilation.
Only recompile a module if the output file does not exist or
nothing has changed.
There is still some work to do on this:
- it doesn't work with inter-module optimization.
- it doesn't work when the module name doesn't match the file name.
(this problem will go away when mmake functionality is moved into
the compiler.
I'll hold off documenting this change in the NEWS file and
on the web page for a month or so, until I've had a bit more
experience using it.
compiler/options.m:
compiler/handle_options.m:
doc/user_guide.texi:
Add an option `--smart-recompilation', currently off by default.
Add an internal option `--generate-version-numbers' to control
whether version numbers are written to the interface files. If
`--smart-recompilation' is disabled because the module
is being compiled with `--intermodule-optimization' (e.g. in the
standard library), we still want to write the version numbers
to the interface files.
Add an option `--verbose-recompilation' (default off)
to write messages describing why recompilation is needed.
Add an option `--warn-smart-recompilation' (default on)
to control warnings relating to the smart recompilation
system. Warn if smart recompilation will not work with
the output and inter-module optimization options given.
compiler/recompilation.m:
Type declarations for smart recompilation.
Predicates to record program items used by compilation.
compiler/recompilation_version.m:
Compute version numbers for program items in interface files.
compiler/recompilation_usage.m:
Find all items used by a compilation.
compiler/recompilation_check.m:
Check whether recompilation is necessary.
compiler/timestamp.m:
Timestamp ADT for smart recompilation.
compiler/mercury_compile.m:
Invoke the smart recompilation passes.
compiler/modules.m:
compiler/prog_io.m:
Return timestamps for modules read.
When reading a module make sure the current input stream
is reset to its old value, not stdin.
Handle version number items in interface files.
compiler/module_qual.m:
compiler/unify_proc.m:
compiler/make_hlds.m:
Record all items used by local items.
compiler/make_hlds.m:
Process `:- pragma type_spec' declarations in
add_item_list_clauses. The qual_info is needed
when processing `:- pragma type_spec' declarations
so that any equivalence types used by the declaration
can be recorded as used by the predicate or function to
which the `:- pragma type_spec' applies.
compiler/equiv_type.m:
For each imported item, record which equivalence types
are used by that item.
compiler/hlds_module.m:
Add a field to the module_info to store information about
items used during compilation of a module.
compiler/check_typeclass.m:
Make sure any items used in clauses for typeclass method
implementations are recorded in the `.used' file.
compiler/prog_data.m:
compiler/*.m:
Factor out some duplicated code by combining the
pred and func, and pred_mode and func_mode items.
Make it easier to extract the name of a type, inst or mode
from its declaration.
Add an item type to hold the version numbers for an interface file.
Allow warnings to be reported for `nothing' items (used for
reporting when version numbers are written using an
obsolete format).
compiler/prog_io.m:
compiler/prog_io_util.m:
compiler/typecheck.m:
compiler/type_util.m:
compiler/*.m:
Strip contexts from all types, not just those in class constraints.
This makes it possible to use ordinary unification to check
whether items have changed (with the exception of clauses).
Remove code to create types with contexts in typechecking.
Remove code scattered through the compiler to remove contexts
from types in class constraints.
compiler/hlds_pred.m:
compiler/prog_util.m:
Move hlds_pred__adjust_func_arity to prog_util, so that it
can be used by the pre-hlds passes.
compiler/typecheck.m:
compiler/hlds_module.m:
Move typecheck__visible_modules to hlds_module.m, so it can
be used by recompilation_usage.m.
compiler/typecheck.m:
Add a comment telling where updates may be required if the
code to typecheck a var-functor unification changes.
compiler/error_util.m:
Allow writing messages without contexts (used for the verbose
recompilation messages).
Add functions to format sym_name and sym_name_and_arity,
and to add punctuation to the end of an error message
without unwanted line breaks before the punctuation.
scripts/Mmake.rules:
compiler/modules.m:
Don't remove the output file before running the compiler. We need
to leave the old output file intact if smart recompilation detects
that recompilation is not needed.
compiler/notes/compiler_design.html:
Document the new modules.
library/io.m:
NEWS:
Add predicates to find the modification time of files
and input_streams.
library/set.m:
NEWS:
Add a predicate version of set__fold
Don't sort the output of set__filter, it's already sorted.
library/std_util.m:
NEWS:
Add a predicate `std_util__map_maybe/3' and a function
`std_util__map_maybe/2' to apply a predicate or a function to
a value stored in a term of type `std_util__maybe'.
configure.in:
runtime/mercury_conf.h.in:
runtime/RESERVED_MACRO_NAMES:
When checking whether the compiler is recent enough, check for
the --warn-smart-recompilation option.
Check for stat().
library/Mmakefile:
Disable warnings about smart recompilation not working with
`--intermodule-optimization'.
browser/Mmakefile:
Disable warnings about smart recompilation not working when
the module name doesn't match the file name.
runtime/mercury_string.h:
Add a macro MR_make_string_const() which automates computation
of the length of string argument to MR_string_const().
tests/recompilation/Mmakefile:
tests/recompilation/runtests:
tests/recompilation/test_functions:
tests/recompilation/TESTS:
tests/recompilation/README:
A framework for testing smart recompilation.
The option currently only works for the recompilation directory.
tests/recompilation/TEST.m.{1,2}:
tests/recompilation/TEST_2.m.{1,2}:
tests/recompilation/TEST.exp.{1,2}:
tests/recompilation/TEST.err_exp.2:
Test cases, where TEST is one of add_constructor_r, add_instance_r,
add_instance_2_r, add_type_nr, change_class_r, change_instance_r,
change_mode_r, field_r, func_overloading_nr, func_overloading_r,
lambda_mode_r, nested_module_r, no_version_numbers_r,
pragma_type_spec_r, pred_ctor_ambiguity_r, pred_overloading_r,
add_type_re, remove_type_re, type_qual_re.
tests/handle_options:
Add an option `-e' to generate any missing expected output files.
|
||
|
|
cddde72b73 |
Remove the `--convert-to-goedel' option. It doesn't really work
Estimated hours taken: 0.5 Remove the `--convert-to-goedel' option. It doesn't really work and it's a hassle to maintain. Remove the `--generate-prolog' and `--prolog-dialect' options. They aren't implemented, and now that we have a proper debugger they probably never will be. compiler/mercury_to_goedel.m: Removed. compiler/notes/compiler_design.html: Remove mercury_to_goedel.m. compiler/globals.m: compiler/handle_options.m: Remove code dealing with Prolog dialects. compiler/options.m: doc/user_guide.texi: Remove the options. compiler/prog_io.m: Delete a comment referring to Mercury-to-Goedel converters. compiler/mercury_compile.m: Don't call convert_to_goedel. NEWS: Document the removal of the `--convert-to-goedel' option. WORK_IN_PROGRESS: Remove a reference to the `--generate-prolog' option. |
||
|
|
e6769ef622 |
Record the module that each instance declaration came from.
Estimated hours taken: 8 Record the module that each instance declaration came from. This is needed for the IL back-end, which includes that module name in the symbol name that it generates for each instance declaration. compiler/prog_data.m: Add a module_name field to the `instance' item. compiler/prog_io_typeclass.m: When parsing `instance' declarations, store the module name that they came from in the module_name field of the `instance' item. compiler/hlds_data.m: Add a module_name field to the `hlds_instance_defn' structure. compiler/make_hlds.m: Copy the module_name field from the `instance' item to the `hlds_instance_defn' structure. compiler/polymorphism.m: Fix an old XXX: when constructing `base_typeclass_info_const's, use the module name from the `hlds_instance_defn', rather than hard-coding the invalid value "some bogus module name". compiler/rtti.m: Add a module_name field to the `base_typeclass_info' rtti_name and rtti_data. compiler/base_typeclass_info.m: Copy the module_name field in the `hlds_instance_defn' to the module_name field in the `base_typeclass_info' rtti_data and rtti_name. compiler/rtti_to_mlds.m: When constructing mlds `data_addr's, use the module_name from the `base_typeclass_info' rtti_name, rather than assuming that such references always refer to instance declarations in the current module. (That assumption would be a safe one currently, but doing it this way is probably a bit more robust against future changes.) compiler/*.m: Trivial changes to reflect the above data structure changes. |
||
|
|
82378c381b |
Allow polymorphic ground insts. This change assumes that all inst
Estimated hours taken: 80 Allow polymorphic ground insts. This change assumes that all inst parameters in the mode declaration for a predicate or function are constrained to be ground-shared. This is a temporary measure until we work out a nice syntax to allow the programmer to tell the compiler that certain inst parameters may be treated as ground insts. Since we don't currently support unconstrained inst parameters anyway, this shouldn't cause a problem. TODO: - Add syntax, something like `:- mode p(in(I)) <= ground(I).', to specify that an inst parameter represents a ground inst. - Allow abstract ground insts that are treated in a similar way to what we've done here with ground inst parameters. - Make mode checking more efficient (i.e. rewrite the mode system). compiler/inst.m: Add a new alternative for ground insts: `constrained_inst_var(inst_var)'. Define the type `inst_var_sub'. compiler/inst_match.m: Change inst_matches_initial so that it: - handles constrained_inst_vars correctly; - returns the inst_var substitutions necessary for the call; - handles inst_matches_initial(ground(...), bound(...), ...) properly (this requires knowing the type of the variable). The last change has also been made for inst_matches_final and inst_matches_binding. However, the check is disabled for now because, without alias tracking, the mode checker becomes too conservative. compiler/hlds_pred.m: compiler/mode_info.m: compiler/simplify.m: compiler/det_util.m: Include the inst_varset in the proc_info, mode_info and simplify_info. Add a vartypes field to the det_info. Remove the vartypes field from the simplify_info since it is now in the det_info. Use record syntax for these data structures and their access predicates to make future changes easier. compiler/prog_io.m: When processing pred and func mode declarations, convert all inst_var(V) insts to ground(shared, constrained_inst_var(V)). compiler/prog_data.m: compiler/hlds_data.m: compiler/make_hlds.m: compiler/mode_util.m: Use inst_vars instead of inst_params. compiler/modes.m: compiler/modecheck_call.m: compiler/unique_modes.m: compiler/mode_util.m: When checking or recomputing initial insts of a call, build up an inst_var substitution (using the modified inst_matches_initial) and apply this to the final insts of the called procedure before checking/recomputing them. compiler/mode_util.m: Make sure that recompute_instmap_delta recomputes the instmap_deltas for lambda_goals even when RecomputeAtomic = no. compiler/type_util.m: Add a new predicate, type_util__cons_id_arg_types which nondeterministically returns the cons_ids and argument types for a given type. Add a new predicate type_util__get_consid_non_existential_arg_types which is the same as type_util__get_existential_arg_types except that it fails rather than aborting for existenially typed arguments. compiler/accumulator.m: compiler/check_typeclass.m: compiler/clause_to_proc.m: compiler/common.m: compiler/continuation_info.m: compiler/deforest.m: compiler/det_analysis.m: compiler/det_report.m: compiler/det_util.m: compiler/dnf.m: compiler/follow_code.m: compiler/goal_store.m: compiler/goal_util.m: compiler/higher_order.m: compiler/inst_util.m: compiler/instmap.m: compiler/lambda.m: compiler/magic.m: compiler/magic_util.m: compiler/mercury_to_mercury.m: compiler/modecheck_unify.m: compiler/module_qual.m: compiler/pd_info.m: compiler/pd_util.m: compiler/polymorphism.m: compiler/post_typecheck.m: compiler/prog_io_util.m: compiler/prog_rep.m: compiler/saved_vars.m: compiler/stack_layout.m: compiler/table_gen.m: compiler/unify_proc.m: compiler/unneeded_code.m: compiler/unused_args.m: Pass inst_varsets and types where needed. Changes to reflect change in definition of the inst data type. compiler/inlining.m: Recompute the instmap deltas for a procedure after inlining. This bug showed up compiling tests/hard_coded/lp.m with inlining and deforestation turned on: deforestation was getting incorrect instmap deltas from inlining, causing the transformation to break mode-correctness. It has only just shown up because of the added call to `inst_matches_initial' from within `recompute_instmap_delta'. tests/invalid/Mmakefile: tests/invalid/unbound_inst_var.m: tests/invalid/unbound_inst_var.err_exp: tests/valid/Mmakefile: tests/valid/unbound_inst_var.m: Move the `unbound_inst_var' test case from `invalid' to `valid' and extend its coverage a bit. |
||
|
|
3b09d46824 |
Check for various cases of type variables that occur only in type class
Estimated hours taken: 6 Check for various cases of type variables that occur only in type class constraints. These cases are all errors, since the type variable can never be bound, but previously the compiler was not checking for these errors. compiler/prog_io.m: Fix a bug that was due to an accidental name clash between two different variables both named `Args' (one was the type constructor arguments, the other was the class constraint arguments, but both had type `term'). This bug was preventing it from reporting errors for type variables in existentially quantified data types which do not occur in the argument types. Also improve one of the other error messages slightly. compiler/prog_io_typeclass.m: Check that type vars in superclass constraints are parameters of the type class. This enforces the following requirement from the "type class constraints on type classes" section of the Mercury language reference manual: | The variables that appear as arguments to the type classes in the | [superclass] constraints must also be arguments to the type class | in question. Likewise check type variables in instance declarations, to enforce the following requirement from the "type class constraints on instance declarations" section of the Mercury language reference manual: | The variables that appear as arguments to the type classes in the | constraints must all be type variables that appear in the types in | the instance declarations. compiler/make_hlds.m: Check that type vars in constraints on pred and func declarations (including type class methods) occur in the procedure's argument types. This enforces the following requirement from the "type class constraints on predicates and functions" section of the Mercury language reference manual: | where ... TYPEVARIABLE is a type variable that appears in the | predicate's or function's type signature. Note that this can't be done in prog_io.m, since for type class methods we don't know what the type variables in the type class are when we're parsing the type class methods. Hence I did it in make_hlds.m instead. tests/invalid/type_vars.m: tests/invalid/type_vars.err_exp: Add another test to this test case, to test the fix to prog_io.m, and add some comments to the existing tests. Adjust the expected output to reflect the slightly improved error message and the new test. tests/invalid/Mmakefile: tests/invalid/unbound_type_vars.m: tests/invalid/unbound_type_vars.err_exp: A new test case containing regression tests to test the fixes to prog_io_typeclass.m and make_hlds.m. |
||
|
|
401298c013 |
Make the syntax for defining modes and insts similar to type equivalence.
Estimated hours taken: 2 Make the syntax for defining modes and insts similar to type equivalence. Old syntax: :- inst foo = someinstdefn. :- mode foo :: someinst -> someotherinst. New syntax: :- inst foo == someinstdefn. :- mode foo == someinst >> someotherinst. The old syntax is still supported. For `::' and `->' it may eventually be phased out (but it doesn't cause many problems apart from possible confusion of users, so it's a low priority). In the case of `:- inst' we could already use `==' or `=', however we now make `==' the standard syntax. Again, we support both and probably will for quite some time. NEWS: Mention these changes. compiler/prog_io.m: Make `==' the standard operator for `:- inst <InstDefn>.' declarations. Make `==' and `>>' the standard operators for `:- mode foo == someinst >> someotherinst'. `::' and `->' are still supported. compiler/prog_io_util.m: Make `>>' the standard operator for inline mode declarations. `->' is still supported. doc/reference_manual.texi: Update the syntax in the reference manual. Mention that `::' and `->' is deprecated. tests/valid/Mmakefile: tests/valid/mode_syntax.m: Add a new test of the new syntax. compiler/fact_table.m: Fix a typo (missing quote) in the verbose messages for fact tables. |
||
|
|
226e3607ae |
Fix a bug: the code to test for type variables having overlapping
Estimated hours taken: 1.5 compiler/prog_io.m: Fix a bug: the code to test for type variables having overlapping scopes (being both a parameter and also explicitly quantified) in type definitions was wrong. This bug seems to have been caused by a cut-and-paste error: the condition used was the same as in the immediately following if-then-else. Also improve the error message for an existentially quantified variable that doesn't occur in the constructor arguments -- previously we complained "var occurs only in existential quantifiers", but if the variable occurs in the constraints, then that error message was wrong. I changed it to say "does not occur in arguments of constructor", and to describe the entity as a "type variable" rather than just a "var". tests/invalid/Mmakefile: tests/invalid/type_vars.m: tests/invalid/type_vars.err_exp: Add a test case to test this code. |
||
|
|
79d75acdb0 |
Add impure functions to Mercury, clean up the purity module somewhat,
Estimated hours taken: 30 Add impure functions to Mercury, clean up the purity module somewhat, fix some bugs in purity, update and expand the purity documentation, and re-organize the purity checks. Impure functions can be declared just like impure preds. However, they can only be called in an explicit unification preceeded by a purity level: impure X = some_impure_func(Y, Z) The bug fixed was the fact that closures of impure predicates were only being detected when using lambda syntax. Purity information was discarded and impure closures could be created like this: Pred = some_impure_pred You could then use this predicate anywhere you like without any purity declarations. compiler/hlds_module.m: Add get_pred_id pred which will return the pred_id of a predicate matching a given type. This is like get_pred_and_proc_id, but only gets the information we are interested in, and is semidet. We need a semidet version to handle cases where type inference cannot infer a type before the limit is reached, but we try to purity check this code. (The bug mentioned above was stopping us from purity checking the test case for this before). compiler/make_hlds.m: Check for "impure" unifications with expressions that are not function calls and issue appropriate error messages. When unravelling impure function call unifications, put the input parameter unifications (if any) before the actual call. Only mark the goal_info for the function call as impure. compiler/mercury_to_goedel.m: compiler/mercury_to_mercury.m: compiler/module_qual.m: compiler/prog_data.m: compiler/prog_io.m: compiler/prog_io_dcg.m: compiler/prog_io_goal.m: compiler/prog_util.m: Add purity information to unify goals. Don't assume unify goals are pure. compiler/purity.m: Allow impure functions. Check unification goals for purity (not just lambda unification). Check unifications that are transformed into calls to make sure the call is purity correct. Put purity checking logic into separate predicates. Use an enum to return different errors and warnings. (The last two changes make it much easier to see the similarities between checking goals and checking predicates for purity correctness). Give different error messages for impure functions (highlight that you need to use them in an explicit unification). Handle unknown predicate lookups (can occur when unifying with a higher order term whose type could not be inferred). Add a few comments delineating where changes might need to be made to make foreign code impure by default in future. compiler/notes/authors.html: Add Peter Schachte to the authors list. doc/reference_manual.texi: Document impure functions. Expand more on what impure predicates/functions can do. Explain the concept of worst purity, and use it to explain the "inferred purity"/"declared purity" concepts. Make it more explicit that only impure goals obey strict-sequential like semantics. tests/invalid/type_inf_loop.err_exp2: Fix this test case to reflect the new error message new that we check the purity of this code correctly (or rather, we correctly fail to be able to purity check this code). tests/hard_coded/Mmakefile: tests/hard_coded/purity.exp: tests/hard_coded/purity.m: tests/hard_coded/purity/Mmakefile: tests/hard_coded/purity/impure_func_t1.m: tests/hard_coded/purity/purity.m: tests/hard_coded/purity/runtests: Remove purity tests from the hard_coded directory, give it a sub-directory of its own. tests/invalid/Mmakefile: tests/invalid/purity.err_exp: tests/invalid/purity.m: tests/invalid/purity_nonsense.err_exp: tests/invalid/purity_nonsense.m: tests/invalid/purity/Mmakefile: tests/invalid/purity/impure_func_t2.err_exp: tests/invalid/purity/impure_func_t2.m: tests/invalid/purity/impure_func_t3.err_exp: tests/invalid/purity/impure_func_t3.m: tests/invalid/purity/impure_func_t4.err_exp: tests/invalid/purity/impure_func_t4.m: tests/invalid/purity/impure_func_t5.err_exp: tests/invalid/purity/impure_func_t5.m: tests/invalid/purity/impure_pred_t1.err_exp: tests/invalid/purity/impure_pred_t1.m: tests/invalid/purity/impure_pred_t2.err_exp: tests/invalid/purity/impure_pred_t2.m: tests/invalid/purity/purity.err_exp: tests/invalid/purity/purity.m: tests/invalid/purity/purity_nonsense.err_exp: tests/invalid/purity/purity_nonsense.m: tests/invalid/purity/runtests: Remove purity tests from the invalid directory, give it a sub-directory of its own. |
||
|
|
e46e2d5eb1 |
Remove calls to !.
Estimated hours taken: 0.5 library/*.m: compiler/*.m: Remove calls to !. |
||
|
|
f9b942b30e |
Allow functions to be declared by supplying the determinism but not the
Estimated hours taken: 12 Allow functions to be declared by supplying the determinism but not the modes (we assume the default modes). compiler/make_hlds.m: Assume default modes if determinism is declared without modes in the :- func declaration. compiler/prog_io.m: Don't give an error message for determinism without modes for function. compiler/prog_io_goal.m: Update documentation to reflect default mode syntax. Assume default modes if determinism is declared without modes in lambda expressions. compiler/prog_util.m: Mention that declaring modes for some but not all of the arguments of a function will be noticed in prog_io, so shouldn't be a concern in this code. doc/reference_manual.texi: Document the new syntax. tests/valid/Mmakefile: tests/valid/func_default_modes.m: A test case for the new syntax. |
||
|
|
5940825cdb |
Implement syntax for getting and setting fields of constructors.
Estimated hours taken: 70 Implement syntax for getting and setting fields of constructors. compiler/make_hlds.m: Add information about field definitions to the module_info. Check that user-defined field access functions for exported fields are also exported, otherwise predicates in other modules could use a different method to access a field than predicates in module defining the field. Add a `predicate preds_add_implicit_report_error' to allow that check to be performed for functions which are added to the module_info by some means other than a `:- func' declaration. Parse field access goals and expressions. Add predicates `insert_arg_unifications_with_supplied_contexts', and `append_arg_unification', which allow more control over the contexts given to the added unifications. These are useful because the field value for an update is really an argument of the inner-most update function call, while the input term is an argument of the outer-most function call. compiler/prog_io_dcg.m: Allow DCG goals of the form `:=(DCGArg)', which unifies `DCGArg' with the output DCG argument, ignoring the input DCG argument. The rationale for this change is that if we have convenient syntax for updating parts of a DCG argument, we should also have convenient syntax for updating the whole DCG argument. compiler/typecheck.m: Add a default clause for field access functions for which the user has supplied type and mode declarations but no clauses. Typecheck field access function calls. Use `io__write_list' to remove some duplication of code to write out comma separated lists of error descriptions. compiler/post_typecheck.m: Expand field accessor goals into the equivalent unifications. They are expanded inline rather than generating new get and set predicates for field name to avoid having to work out how to mode the generated predicates. Remove an unnecessary goal traversal to qualify function calls and constructors. That code is now called from purity.m. compiler/prog_data.m: compiler/prog_io.m: compiler/mercury_to_goedel.m: compiler/mercury_to_mercury.m: Store field names as `sym_name's rather than strings. Use a `maybe' type rather than an empty string to designate an unlabelled field. compiler/hlds_data.m: Define data structures to hold information about the field names visible in a module. compiler/hlds_module.m: Add a field to type module_info to hold information about the fields visible in a module. compiler/hlds_pred.m: Add predicates to identify field access function names, and to handle the arguments of field access functions. compiler/make_hlds.m: compiler/hlds_goal.m: compiler/modecheck_call.m: compiler/higher_order.m: compiler/purity.m: compiler/polymorphism.m: compiler/dnf.m: compiler/cse_detection.m: compiler/lambda.m: Move `create_atomic_unification' from make_hlds.m to hlds_goal.m because it is used by several other modules. compiler/hlds_goal.m: Add a version of goal_info_init which takes the context of the goal, for use by make_hlds.m. compiler/type_util.m: Add a predicate `type_util__get_type_and_cons_defn' to get the hlds_type_defn and hlds_cons_defn for a user-defined constructor. compiler/prog_util.m: Add predicates to add and remove prefixes or suffixes from the unqualified part of a sym_name. compiler/prog_out.m: Add a predicate to convert a `sym_name/arity' to a string. compiler/hlds_out.m: Add `hlds_out__simple_call_id_to_string' to convert a `pred_or_func - sym_name/arity' to a string for use in error messages. compiler/purity.m: Thread through the pred_info so that the expansion of field accessor goals can add new variables. compiler/mercury_to_mercury.m: library/ops.m: Reduce precedence of `^/2' for use as a field name separator. Add operator `^'/1 to designate which side of the `:=' is the field name in a DCG field access goal. Add operator `:=/2' for field update expressions. doc/reference_manual.texi: Document the new syntax. doc/transition_guide.texi: Document the new operators. tests/hard_coded/Mmakefile: tests/hard_coded/record_syntax.m: tests/hard_coded/record_syntax.exp: tests/invalid/Mmakefile: tests/invalid/record_syntax_errors.m: tests/invalid/record_syntax_errors.err_exp: Test cases. |
||
|
|
cbe2de18fb |
Completely remove support for `:- assertion' declarations.
Estimated hours taken: 1
Completely remove support for `:- assertion' declarations.
This change can be bootstrapped with the tag
bootstrap_19991116_promise_decls in the compiler and library
directories.
configure.in:
The up-to-date check must now ensure that `:- promise' declarations
can be parsed, and the declarations don't have to have every
variable explicitly quantified.
compiler/mercury_to_mercury.m:
compiler/prog_io.m:
library/ops.m:
Remove the support for parsing `:- assertion' declarations.
doc/reference_manual.texi:
library/int.m:
s/assertion/promise/
|
||
|
|
ed9bb38494 |
Change from :- assertion' to :- promise'.
Estimated hours taken: 2
Change from `:- assertion' to `:- promise'.
compiler/assertion.m:
compiler/error_util.m:
compiler/hlds_data.m:
compiler/hlds_out.m:
compiler/make_hlds.m:
compiler/mercury_to_goedel.m:
compiler/mercury_to_mercury.m:
compiler/prog_io.m:
compiler/notes/glossary.html:
doc/transition_guide.texi:
library/ops.m:
Change all externally visible references to promise from assertion.
|
||
|
|
64b3c37f45 |
More changes to reduce the complexity of the intermodule dependencies.
Estimated hours taken: 2 More changes to reduce the complexity of the intermodule dependencies. compiler/module_qual.m: Some minor changes to avoid the need to import hlds*.m. This module acts on the parse tree, not the HLDS, so we shouldn't import hlds*.m here. compiler/modules.m: compiler/prog_io.m: compiler/det_analysis.m: Delete some unnecessary imports. compiler/equiv_type.m: compiler/dependency_graph.m: Add some XXX comments about unwanted intermodule dependencies. |
||
|
|
a5f5c63a3a |
Add the infrastructure for assertions into the compiler.
Estimated hours taken: 50
Add the infrastructure for assertions into the compiler.
compiler/error_util.m:
Output the correct pred name for assertions.
compiler/hlds_data.m:
Add the assertion_table structure.
compiler/hlds_module.m:
Get/set the assertion_table from the module_info.
compiler/hlds_out.m:
Modify hlds_out__write_pred_id to identify assertions.
compiler/hlds_pred.m:
Add the goal_type assertion.
compiler/make_hlds.m:
Transform the assertion to a HLDS data structure that can be
typechecked.
compiler/mercury_to_goedel.m:
compiler/module_qual.m:
Handle the assertion structure.
compiler/mercury_to_mercury.m:
Output assertions.
compiler/post_typecheck.m:
Add a predicate which must be called after typechecking of
assertions has been finished. Also document some possible problems
with typechecking assertions.
compiler/prog_data.m:
Add assertion to the type item.
compiler/prog_io.m:
Add the ability to parse assertions.
compiler/purity.m:
After finished typechecking assertions call
post_typecheck__finish_assertion.
compiler/typecheck.m:
Don't output inference messages for assertions.
compiler/notes/compiler_design.html:
Update documentation about exactly where quantification is done.
compiler/notes/glossary.html:
Define what an assertion is.
|
||
|
|
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. |