mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 05:12:33 +00:00
ada4e26dd11e052f8f244cb0af94208f4d329452
63 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ac651b033b |
Only report mode warnings if they occur in all modes.
Estimated hours taken: 5 Branches: main Only report mode warnings if they occur in all modes. simplify.m already had code to remove error_specs that do not occur in all modes, so move this code to error_util.m and reuse it in modes.m. Also only report mode warnings for user defined predicates. Do not report them for compiler generated predicates (after making the change in the previous paragraph, the compiler issued a warning for a generated unification predicate in term_to_xml.m). compiler/cse_detection.m: Conform to new interface of modecheck_proc. compiler/error_util.m: Add an abstract type error_spec_accumulator and predicates for working with this type. The new type is used for accumulating errors over multiple modes of a predicate. The code for accumulating error specs has been moved from simplify.m. There was a bug in this code caused by the arguments of the pair in the error_spec_accumulator type getting mixed up. This bug has now been fixed. Add mode_report_control to the modecheck phase, so we can mark which error specs should only be reported if they occur in all modes. compiler/mode_errors.m: Delete report_mode_errors and report_mode_warnings, since these are no longer used. Export mode_error_info_to_spec and mode_warning_info_to_spec for converting mode errors and warnings to error specs. Conform to changes in error_util.m. compiler/modecheck_unify.m: Do not supress warnings if the mode may use a subtype, since we want such warnings to be displayed if the occur in all modes. Only report mode warnings if the predicate is not a compiler generated predicate. compiler/modes.m: Delete modecheck_pred_mode and modecheck_proc_info, since they are not used anywhere. In modecheck_proc and modecheck_proc_general report a list of error specs, instead of the number of errors. These predicates are now no longer responsible for printing the errors, they just return the error specs. We need to do it this way so we can accumulate the errors over all modes (eliminating any warnings that don't occur in all modes) before printing them. Report errors in modecheck_pred_mode_2, after all modes have been processed. Accumulate the error specs in modecheck_procs, using the new predicates in error_util.m. Move the code for only reporting the first error encountered for a proc from mode_errors.m to here. Also improve the comment for that bit of code. Conform to changes in error_util.m. compiler/pd_util.m: Conform to changes in error_util.m. compiler/simplify.m: Move the code for accumulating error specs to error_util.m compiler/unify_proc.m: compiler/unique_modes.m: Conform to changes elsewhere. tests/invalid/ho_type_mode_bug.err_exp: The order the errors are reported has changed here, because we now call write_error_specs to report mode errors. tests/invalid/qualified_cons_id2.err_exp: tests/warnings/simple_code.exp: tests/warnings/simple_code.m: We now correctly report a warning we didn't report before. |
||
|
|
b23c0dc171 |
Introduce a standard way to read lines and files efficiently but generically
Estimated hours taken: 2 Branches: main Introduce a standard way to read lines and files efficiently but generically using stream.get/4. library/string.m: Add the types string.line and string.text_file. library/io.m: Make io.input_stream instances of stream.reader with units string.line and string.text_file. compiler/error_util.m: Rename error_util.line to error_line to disambiguate it from string.line. extras/net/tcp.m: Remove the tcp.line type and use string.line instead. NEWS: Announce the change. |
||
|
|
b56885be93 |
Fix a bug that caused bootchecks with --optimize-constructor-last-call to fail.
Estimated hours taken: 12 Branches: main Fix a bug that caused bootchecks with --optimize-constructor-last-call to fail. The problem was not in lco.m, but in follow_code.m. In some cases, (specifically, the LCMC version of insert_2 in sparse_bitset.m), follow_code.m moved an impure goal (store_at_ref) into the arms of an if-then-else without marking those arms, or the if-then-else, as impure. The next pass, simplify, then deleted the entire if-then-else, since it had no outputs. (The store_at_ref that originally appeared after the if-then-else was the only consumer of its only output.) The fix is to get follow_code.m to make branched control structures such as if-then-elses, as well as their arms, semipure or impure if a goal being moved into them is semipure or impure, or if they came from an semipure or impure conjunction. Improve the optimization of the LCMC version of sparse_bitset.insert_2, which had a foreign_proc invocation of bits_per_int in it: replace such invocations with a unification of the bits_per_int constant if not cross compiling. Add a new option, --optimize-constructor-last-call-null. When set, LCMC will assign NULLs to the fields not yet filled in, to avoid any junk happens to be there from being followed by the garbage collector's mark phase. This diff also makes several other changes that helped me to track down the bug above. compiler/follow_code.m: Make the fix described above. Delete all the provisions for --prev-code; it won't be implemented. Don't export a predicate that is not now used anywhere else. compiler/simplify.m: Make the optimization described above. compiler/lco.m: Make sure that the LCMC specialized procedure is a predicate, not a function: having a function with the mode LCMC_insert_2(in, in) = in looks wrong. To avoid name collisions when a function and a predicate with the same name and arity have LCMC applied to them, include the predicate vs function status of the original procedure included in the name of the new procedure. Update the sym_name of calls to LCMC variants, not just the pred_id, because without that, the HLDS dump looks misleading. compiler/pred_table.m: Don't have optimizations like LCMC insert new predicates at the front of the list of predicates. Maintain the list of predicates in the module as a two part list, to allow efficient addition of new pred_ids at the (logical) end without using O(N^2) algorithms. Having predicates in chronological order makes it easier to look at HLDS dumps and .c files. compiler/hlds_module.m: Make module_info_predids return a module_info that is physically updated though logically unchanged. compiler/options.m: Add --optimize-constructor-last-call-null. Make the options --dump-hlds-pred-id, --debug-opt-pred-id and --debug-opt-pred-name into accumulating options, to allow the user to specify more than one predicate to be dumped (e.g. insert_2 and its LCMC variant). Delete --prev-code. doc/user_guide.texi: Document the changes in options.m. compiler/code_info.m: Record the value of --optimize-constructor-last-call-null in the code_info, to avoid lookup at every cell construction. compiler/unify_gen.m: compiler/var_locn.m: When deciding whether a cell can be static or not, make sure that we never make static a cell that has some fields initialized with dummy zeros, to be filled in for real later. compiler/hlds_out.m: For goals that are semipure or impure, note this fact. This info was lost when I changed the representation of impurity from markers to a field. mdbcomp/prim_data.m: Rename some ambiguous function symbols. compiler/intermod.m: compiler/trans_opt.m: Rename the main predicates (and some function symbols) of these modules to avoid ambiguity and to make them more expressive. compiler/llds.m: Don't print line numbers for foreign_code fragments if the user has specified --no-line-numbers. compiler/make.dependencies.m: compiler/mercury_to_mercury.m: compiler/recompilation.usage.m: Don't use io.write to write out information to files we may need to parse again, because this is vulnerable to changes to the names of function symbols (e.g. the one to mdbcomp/prim_data.m). The compiler still contains some uses of io.write, but they are for debugging. I added an item to the todo list of the one exception, ilasm.m. compiler/recompilation.m: Rename a misleading function symbol name. compiler/parse_tree.m: Don't import recompilation.m here. It is not needed (all the components of parse_tree that need recompilation.m already import it themselves), and deleting the import avoids recompiling almost everything when recompilation.m changes. compiler/*.m: Conform to the changes above. compiler/*.m: browser/*.m: slice/*.m: Conform to the change to mdbcomp. library/sparse_bitset.m: Use some better variable names. |
||
|
|
c5660cd63c |
Fix some problems with my recent change to simplify to optimize the handling
Estimated hours taken: 6 Branches: main Fix some problems with my recent change to simplify to optimize the handling of calls to the functions in int.m involving the bits_per_int platform-specific constant. One problem was that the transformation in simplify.m worked only if it could find in the HLDS's predicate table the functions it needed (unchecked_quotient, unchecked_remainder and *), but these were deleted earlier as dead predicates. The fix is to prevent dead_proc_elim from deleting these predicates. (Three small predicates aren't a problem for memory consumption.) Another problem was that some of the calls to the library predicates that simplify was trying to optimize were introduced as part of intermodule inlining *after* the first simplify pass, and inlining also replaced the calls with their definitions, which are foreign_procs. The fix is to apply the same transformation to the foreign_proc form of the call as to the plain_call form. compiler/dead_proc_elim.m: Do not eliminate predicates that simplify may introduce calls to. Rename several predicates to avoid ambiguities, and some function symbols and variables to make their purpose clearer. Instead of printing out warning messages on the fly, return them to be printed all at once by mercury_compile.m. compiler/simplify.m: Export a predicate that dead_proc_elim can use to find out which predicates may have calls introduced to them. Implement the fix of the second problem noted above. compiler/mercury_compile.m: compiler/inlinig.m: Conform to the changes in dead_proc_elim. compiler/error_util.m: Add a phase for dead_proc_elim, since that phase can now also generate messages. compiler/pred_table.m: Improve some documentation. |
||
|
|
b4c3bb1387 |
Clean up in unused module imports in the Mercury system detected
Estimated hours taken: 3 Branches: main Clean up in unused module imports in the Mercury system detected by --warn-unused-imports. analysis/*.m: browser/*.m: deep_profiler/*.m: compiler/*.m: library/*.m: mdbcomp/*.m: profiler/*.m: slice/*.m: Remove unused module imports. Fix some minor departures from our coding standards. analysis/Mercury.options: browser/Mercury.options: deep_profiler/Mercury.options: compiler/Mercury.options: library/Mercury.options: mdbcomp/Mercury.options: profiler/Mercury.options: slice/Mercury.options: Set --no-warn-unused-imports for those modules that are used as packages or otherwise break --warn-unused-imports, e.g. because they contain predicates with both foreign and Mercury clauses and some of the imports only depend on the latter. |
||
|
|
f08f22a7de |
Generate an XML representation of the du types in the current module.
Estimated hours taken: 24 Branches: main Generate an XML representation of the du types in the current module. The XML representation contains all the information about the type, as well as associating with each type, data constructor and data field any comments located near the comment. The current strategy associates the comment starting on the same line as the type declaration, and if there is none then the comment directly above. At a later date, this strategy needs to be made more flexible. This required two main changes to the compiler. Change one was to associate with a term.variable the context of that variable. Then the constructor and constructor_arg types had to have their context recorded. compiler/xml_documentation.m: Add a pass that generates an XML documentation for the du types in the current module. compiler/handle_options.m: compiler/mercury_compile.m: compiler/options.m: Call the xml_documentation phase and stop afterwards. compiler/error_utils.m: Add a utitily predicate for reporting errors where a file is unable to be opened. library/term.m: Add the term.context to term.variables. Remove the backwards mode of var_list_to_term_list as it no longer works. Make the predicate version of term_list_to_var_list semidet as we can no longer use the backwards version var_list_to_term_list. NEWS: Mention the changes to the term module. library/parser.m: Fill in the term.context of term.variables while parsing. compiler/prog_data.m: Add the context to the constructor and constructor_arg types. compiler/prog_io.m: Fill in the context fields in the constructor and constructor_arg types. compiler/add_clause.m: compiler/prog_io.m: compiler/prog_io_typeclass.m: compiler/typecheck.m: Call the correct version of term_list_to_var_list, to deal with the fact that we removed the reverse mode of var_list_to_term_list. compiler/notes/compiler_design.html: doc/user_guide.texi: Document the new module. compiler/add_clause.m: compiler/det_util.m: compiler/fact_table.m: compiler/hlds_out.m: compiler/inst_graph.m: compiler/intermod.m: compiler/make_hlds_passes.m: compiler/mercury_to_mercury.m: compiler/prog_ctgc.m: compiler/prog_io.m: compiler/prog_io_dcg.m: compiler/prog_io_goal.m: compiler/prog_io_pragma.m: compiler/prog_io_typeclass.m: compiler/prog_io_util.m: compiler/prog_io_util.m: compiler/prog_util.m: compiler/state_var.m: compiler/superhomogeneous.m: compiler/switch_detection.m: compiler/typecheck_errors.m: library/term_io.m: library/varset.m: Handle the context in the term.variable structure. compiler/add_type.m: compiler/check_typeclass.m: compiler/equiv_type.m: compiler/hhf.m: compiler/hlds_out.m: compiler/inst_check.m: compiler/make_tags.m: compiler/mercury_to_mercury.m: compiler/ml_type_gen.m: compiler/ml_unify_gen.m: compiler/mode_util.m: compiler/module_qual.m: compiler/post_typecheck.m: compiler/prog_io.m: compiler/prog_mode.m: compiler/prog_type.m: compiler/recompilation.check.m: compiler/recompilation.usage.m: compiler/special_pred.m: compiler/term_constr_build.m: compiler/term_norm.m: compiler/type_ctor_info.m: compiler/type_util.m: compiler/typecheck.m: compiler/unify_proc.m: compiler/untupling.m: compiler/unused_imports.m: Handle the context field in the constructor and constructor_arg types. compiler/check_hlds.m: Add the xml_documentation module. |
||
|
|
5826d7820c |
Instead of printing out error messages here, just return them to
Estimated hours taken: 1 Branches: main compiler/equiv_type.m: Instead of printing out error messages here, just return them to mercury_compile.m. compiler/mercury_compile.m: Print the error messages returned by equiv_type.m. compiler/error_util.m: Add type expansion as a phase that can generate errors. |
||
|
|
411b45846a |
Modify check_typeclass.m to gather up all error messages, and print them all
Estimated hours taken: 12 Branches: main Modify check_typeclass.m to gather up all error messages, and print them all at once after sorting. Modify the determinism analysis pass to generate error_specs directly, instead of generating context_det_msgs and converting those to error_specs later. Separate the simplify pass's mechanism for generating error messages from the determinism pass. compiler/check_typeclass.m: Return all error messages instead of printing them when generated. Keep the error messages outside the instance_method_info structure, and give the fields of the structure names. compiler/det_analysis.m: Generate error specs directly. compiler/det_report.m: Delete the context_det_msg data type and the predicates that operated on it, since they are no longer needed. The code that used to convert a context_det_msg into an error_spec is now dispersed to the sites that generate the error report in the first place. These sites are mostly in det_analysis.m and simplify.m, with a few in other modules (e.g. common.m and format_call.m). Export some auxiliary functions that the these sites now need. compiler/simplify.m: Generate error_specs directly, instead of through context_det_msgs, and return them to the caller for printing. compiler/common.m: compiler/format_call.m: Conform to the change to det_report.m. compiler/unused_import.m: Return all error messages instead of printing them when generated. compiler/mercury_compile.m: Print the error message batches returned by the modified passes. Use the version of globals in module_infos in preference to the one in the I/O state, since we would like to phase out the latter. Don't explicitly sort error_specs, since write_error_specs will do it anyway. compiler/error_util.m: Separate the error messages of the simplify pass from those of determinism analysis. Provide a standard way to format type constructor names. Require the calls to provide the globals when printing error_specs. This is to allow callers to provide the globals from a module_info, instead of the one in the I/O state. compiler/passes_aux.m: Provide support for passes that have lists of error_specs threaded through them, as simplify now does. Rename some predicates to avoid some ambiguities. compiler/deforest.m: compiler/pd_util.m: compiler/unify_proc.m: compiler/unused_args.m: Conform to the change to the interface of determinism analysis. compiler/inlining.m: Do not thread the I/O state through this module. compiler/make.module_dep_file.m: compiler/make_hlds_passes.m: compiler/ml_tailcall.m: compiler/mode_errors.m: compiler/modes.m: compiler/modules.m: compiler/stratify.m: compiler/table_gen.m: Conform to the change in error_util. compiler/prog_data.m: Rename some function symbols to avoid some ambiguities. compiler/add_class.m: compiler/base_typeclass_info.m: compiler/hlds_out.m: compiler/intermod.m: compiler/module_qual.m: compiler/prog_io_typeclass.m: compiler/recompilation.check.m: compiler/recompilation.usage.m: compiler/recompilation.version.m: compiler/type_class_info.m: Conform to the change in prog_data.m. tests/invalid/*err_exp: Update the expected output files to conform to the changes above. This mosly involves expecting sorted messages without duplicates. |
||
|
|
863874df85 |
Document my recent change implementing coverage testing.
Estimated hours taken: 6 Branches: main Document my recent change implementing coverage testing. At the same time, eliminate the old hack that allowed a file containing a list of file names to be considered a trace count file. We haven't needed it since the addition of mtc_union, and it can lead to incomprensible error messages. (The presence of the old hack made documenting coverage testing harder.) In the process, fix the tools code for rerunning failed test cases only. doc/user_guide.texi: Document my recent change implementing coverage testing, and the elimination of the old hack. mdbcomp/trace_counts.m: Modify the predicates for reading in trace count files along the lines above. mdbcomp/slice_and_dice.m: Modify the predicates for reading in slices and dices along the lines above. Rename some function symbols to avoid ambiguities. compiler/tupling.m: slice/mcov.m: slice/mtc_diff.m: slice/mtc_union.m: trace/mercury_trace_declarative.c: Conform to the changes above. slice/mcov.m: Fix the usage message, which referred to this program by its old name mct. Allow the output to be restricted to a set of named modules only. This is to make testing easier. slice/mtc_diff.m: Rename the long form of the -o option from --out to --output-file, to make it consistent with the other programs. tests/run_one_test: tools/bootcheck: Modify the algorithm we use to gather trace counts for the Mercury compiler from both passed and failed test cases to run mtc_union periodically instead of gathering all the trace counts file and keeping them to the end (which takes far too much disk space). Fix an old bug: gather trace counts from executions of the Mercury compiler only. tests/debugger/Mmakefile: tests/debugger/dice.passes: Modify the dice test case to compute the union of the trace counts for the passed versions of this test case to use mtc_union to create dice.passes, instead of having dice.passes statically contain the list of the names of the passed trace count files (since that capability is deleted by this diff). tools/bootcheck: tests/Mmake.common: Fix the code for rerunning failed tests only. mdbcomp/prim_data.m: Eliminate some ambiguities in predicate names. compiler/*.m: Conform to the change to prim_data.m. compiler/error_util.m: Add reading files as a phase in error messages. compiler/mercury_compile.m: Use the new facilities in error_util for printing an error message. |
||
|
|
3c5640b572 |
Add an analysis which determines the set of modules which
Branch: main Estimated hours: 24 Add an analysis which determines the set of modules which are imported but are not used. It also has a more precise analysis of those modules not needed in the interface, as it reports more modules than the current analysis. compiler/unused_imports.m: The module which does the analysis. compiler/make_hlds_passes.m: Record the parent used modules. Factor out the code for adding the module specifiers. compiler/hlds_module.m: Add utility predicates for recording those modules used in the parent modules of the current module and those imports which are in the interface. compiler/options.m: Add the option --warn-unused-imports. By default it's turned off because I have yet to run this analysis on the compiler and fix the modules. compiler/check_hlds.m: compiler/mercury_compile.m: Add the analysis to the compiler. doc/user_guide.texi: Document the new option. compiler/notes/compiler_design.html: Document the new pass. |
||
|
|
6de9f4d1e3 |
Modify the type and purity check passes to gather up all error messages,
Estimated hours taken: 8 Branches: main Modify the type and purity check passes to gather up all error messages, and print them all at once after sorting. compiler/typecheck.m: compiler/typeclasses.m: compiler/post_typecheck.m: compiler/purity.m: Gather up all error messages instead of printing them when generated. In some places the gathered list of error specifications allows us to eliminate error counts and error flags. Eliminate the last occurrences of io.write_* in these modules, replacing them with error_specs. Change the error messages generated by purity.m to eliminate the unnecessary module qualification of the name of the predicate or function in which the error occurs. compiler/typecheck_errors.m: Turn the predicates here that used to print error messages into functions that just return the error specification. compiler/mode_errors.m: Make a predicate used by post_typecheck.m return an error spec instead of writing it out. compiler/typecheck_info.m: Record the list of errors instead of simple a count of the errors printed. compiler/mercury_compile.m: Print the error message batches returned by type checking and purity checking. compiler/error_util.m: Modify the way we represent severity to allow passes such as typechecking to count the number of errors *without* printing anything. compiler/add_pred.m: compiler/det_report.m: compiler/make_hlds_warn.m: compiler/module_qual.m: Conform to the change in error_util.m. compiler/Mercury.options: Record the fact that some more compiler modules need the workaround for trace goals. tests/invalid/*err_exp: tests/warnings/*exp: Update the expected output files to conform to the changes above. This mosly involves expecting sorted messages without duplicates. |
||
|
|
5eee81204e |
A big step towards cleaning up the way we handle errors.
Estimated hours taken: 28 Branches: main A big step towards cleaning up the way we handle errors. The main changes are - the provision, in error_util.m, of a mechanism for completely specifying everything to do with a single error in one data structure, - the conversion of typecheck_errors.m from using io.write_string to using this new capability, - the conversion of mode_errors.m and det_report.m from using write_error_pieces to using this new capability, and - consistently using the quoting style `symname'/N instead of `symname/N' in error_util and hlds_error_util (previously, error_util used the former but hlds_error_util used the latter). This diff sets up later diffs which will collect all error specifications in a central place and print them all at once, in order. compiler/error_util.m: The new type error_spec, which completely specifies an error. An error_spec may have multiple components with different contexts and may have parts which are printed only under certain conditions, e.g. a given option being set. Each error_spec has a severity and also records which phase found the error. The new predicate write_error_spec takes care of updates of the exit status for errors and (if --halt-at-warn is set) for warnings. It also takes care of setting the flag that calls for the reminder about -E at the end. This diff also makes it simpler to use the ability to print arbitrary output. It adds the ability to include integers in messages directly, and the ability to create blank lines. It renames some function symbols to avoid ambiguities. Move a predicate that only used by typecheck_errors.m to that file. compiler/hlds_error_util.m: Switch to the `symname'/N quoting style for describing predicates and procedures. compiler/prog_util.m: Switch to the `symname'/N quoting style for describing sym_name_and_arity. compiler/hlds_module.m: Provide a predicate to increment the number of errors not by one, but by the number of errors printed by write_error_spec. Fix some documentation rot. compiler/typecheck_errors.m: Use write_error_spec instead of io.write_strings to print error messages. In several cases, improve the formatting of the messages printed. Mark a number of places where we don't (yet) update the number of errors in the module_info correctly. Rename the checkpoint predicate to avoid potential ambiguity with similar predicates in e.g. mode_info. compiler/typecheck_info.m: Group the code for writing stuff out together in one bunch. For each such predicate, create another that returns a list of format components instead of doing I/O directly. compiler/typecheck.m: Move the code for writing inference messages here from typecheck_errors.m, since these messages aren't errors. compiler/mode_errors.m: compiler/det_report.m: Use write_error_spec instead of write_error_pieces. In the case of mode_errors.m, this means we now get correct the set of circumstances in which we set the flag that calls for the reminder about -E. compiler/add_pragma.m: compiler/add_type.m: Convert some code that used to use write_error_pieces to print error messages to use write_error_spec instead. compiler/assertion.m: compiler/hlds_pred.m: compiler/post_typecheck.m: Assertion.m used to contain some code to check for assertions in the interface that mention predicates that are not exported. Move most of this code to post_typecheck.m (which is where this code used to be called from). One small part, which is a test for a particular property of import_statuses, is moved to hlds_pred.m to be with all the other similar tests of import_statuses. compiler/prog_util.m: Change unqualify_name from a predicate to a function. compiler/pred_table.m: compiler/hlds_out.m: Avoid some ambiguities by adding a suffix to the names of some predicates. compiler/*.m: Conform to the changes above. library/list.m: Add a function that was previously present (with different names) in two compiler modules. tests/hard_coded/allow_stubs.exp: Update the format of the expected exception. tests/invalid/errors2.err_exp2: Remove this file. As far as I can tell, it was never the correct expected output on the main branch. (It originated on the alias branch way back in the mists of time.) tests/invalid/*.err_exp: tests/invalid/purity/*.err_exp: tests/warnings/*.exp: Update the format of the expected error messages. tests/recompilation/*.err_exp.2: Update the format of the expected messages about what was modified. |
||
|
|
00741b0162 |
This diff contains no algorithmic changes.
Estimated hours taken: 6 Branches: main This diff contains no algorithmic changes. It merely renames apart a bunch more function symbols to reduce ambiguity. After this diff, the summary line from the mdb command "ambiguity -f" is Total: 351 names used 975 times, maximum 31, average: 2.78 browser/*.m: compiler/*.m: Rename function symbols to eliminate ambiguities. tests/debugger/declarative/dependency.exp: tests/debugger/declarative/dependency2.exp: Update the expected out where some internal function symbol names appear in the output of the debugger. (This output is meant for implementors only.) |
||
|
|
46a67b0b48 |
When the typechecker finds highly ambiguous overloading, print what symbols
Estimated hours taken: 16
Branches: main
When the typechecker finds highly ambiguous overloading, print what symbols
were overloaded, and where they occurred. Without this information, it is
very hard to fix the error if the predicate body is at all large.
Fix some software engineering problems encountered during this process.
Modify some predicates in error_util in order to simplify their typical usage.
Change the type_ctor type to be not simply a sym_name - int pair but a type
with its own identifying type constructor. Change several other types that
were also sym_name - int pairs (mode_id, inst_id, item_name, module_qual.id
and the related simple_call_id) to have their own function symbols too.
compiler/typecheck_info.m:
Add a field to the typecheck_info structure that records the overloaded
symbols encountered.
compiler/typecheck.m:
When processing ambiguous predicate and function symbols, record this
fact in the typecheck_info.
Add a field to the cons_type_info structure to make this possible.
compiler/typecheck_errors.m:
When printing the message about highly ambiguous overloading,
what the overloaded symbols were and where they occurred.
compiler/error_util.m:
Make error_msg_specs usable with plain in and out modes by separating
out the capability requiring special modes (storing a higher order
value in a function symbol) into its own, rarely used type.
Make component_list_to_line_pieces a bit more flexible.
compiler/prog_data.m:
compiler/module_qual.m:
compiler/recompilation.m:
Change the types listed above from being equivalence types (pairs)
to being proper discriminated union types.
compiler/*.m:
Conform to the changes above.
In some cases, simplify the code's use of error_util.
tests/warnings/ambiguous_overloading.{m,exp}:
Greatly extend this test case to test the new functionality.
tests/recompilation/*.err_exp.2
Reflect the fact that the expected messages now use the standard
error_util way of quoting sym_name/arity pairs.
|
||
|
|
459847a064 |
Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18 Branches: main Move the univ, maybe, pair and unit types from std_util into their own modules. std_util still contains the general purpose higher-order programming constructs. library/std_util.m: Move univ, maybe, pair and unit (plus any other related types and procedures) into their own modules. library/maybe.m: New module. This contains the maybe and maybe_error types and the associated procedures. library/pair.m: New module. This contains the pair type and associated procedures. library/unit.m: New module. This contains the types unit/0 and unit/1. library/univ.m: New module. This contains the univ type and associated procedures. library/library.m: Add the new modules. library/private_builtin.m: Update the declaration of the type_ctor_info struct for univ. runtime/mercury.h: Update the declaration for the type_ctor_info struct for univ. runtime/mercury_mcpp.h: runtime/mercury_hlc_types.h: Update the definition of MR_Univ. runtime/mercury_init.h: Fix a comment: ML_type_name is now exported from type_desc.m. compiler/mlds_to_il.m: Update the the name of the module that defines univs (which are handled specially by the il code generator.) library/*.m: compiler/*.m: browser/*.m: mdbcomp/*.m: profiler/*.m: deep_profiler/*.m: Conform to the above changes. Import the new modules where they are needed; don't import std_util where it isn't needed. Fix formatting in lots of modules. Delete duplicate module imports. tests/*: Update the test suite to confrom to the above changes. |
||
|
|
be5b71861b |
Convert almost all the compiler modules to use . instead of __ as
Estimated hours taken: 6 Branches: main compiler/*.m: Convert almost all the compiler modules to use . instead of __ as the module qualifier. In some cases, change the names of predicates and types to make them meaningful without the module qualifier. In particular, most of the types that used to be referred to with an "mlds__" prefix have been changed to have a "mlds_" prefix instead of changing the prefix to "mlds.". There are no algorithmic changes. |
||
|
|
6b67868a9d |
Address review comments by Peter Moulder.
compiler/error_util.m: Replace a missing full stop. compiler/stratify.m: compiler/termination.m: s/bottom up/bottom-up/ tests/warnings/non_stratification.exp: Conform to the above. |
||
|
|
18c0510231 |
Improve the formatting of some error messages by using error_util
Estimated hours taken: 2
Branches: main
Improve the formatting of some error messages by using error_util
and hlds_error_util to handle the formatting of the error messages.
compiler/error_util.m:
Add a new format component `quote', which is identical to `fixed'
except that it outputs it's argument surrounded by `' quotes.
compiler/add_clause.m:
compiler/add_type.m:
compiler/make_hlds_passes.m:
compiler/options_file.m:
compiler/qual_info.m:
compiler/stratify.m:
Use the error_util to format warning/error messages rather than
doing it manually.
compiler/passes_aux.m:
complier/hlds_out.m:
Update comments.
tests/invalid/errors.err_exp:
tests/invalid/errors1.err_exp:
tests/invalid/multimode_dcg.err_exp:
tests/invalid/multimode_syntax.err_exp:
tests/invalid/sub_c.err_exp:
tests/invalid/types.err_exp:
Update the expected outputs of these test cases to account
for formatting changes introduced by the above.
tests/warnings/Mmakefile:
tests/warnings/Mercury.options:
tests/warnings/non_stratification.{exp,m}:
Add a test case for the `--warn-non-stratification' option.
|
||
|
|
5f589e98fb |
Various cleanups for the modules in the compiler directory.
Estimated hours taken: 4 Branches: main Various cleanups for the modules in the compiler directory. The are no changes to algorithms except the replacement of some if-then-elses that would naturally be switches with switches and the replacement of most of the calls to error/1. compiler/*.m: Convert calls to error/1 to calls to unexpected/2 or sorry/2 as appropriate throughout most or the compiler. Fix inaccurate assertion failure messages, e.g. identifying the assertion failure as taking place in the wrong module. Add :- end_module declarations. Fix formatting problems and bring the positioning of comments into line with our current coding standards. Fix some overlong lines. Convert some more modules to 4-space indentation. Fix some spots where previous conversions to 4-space indentation have stuffed the formatting of the code up. Fix a bunch of typos in comments. Use state variables in more places; use library predicates from the sv* modules where appropriate. Delete unnecessary and duplicate module imports. Misc. other small cleanups. |
||
|
|
f9fe8dcf61 |
Improve the error messages generated for determinism errors involving committed
Estimated hours taken: 8
Branches: main
Improve the error messages generated for determinism errors involving committed
choice contexts. Previously, we printed a message to the effect that e.g.
a cc pred is called in context that requires all solutions, but we didn't say
*why* the context requires all solutions. We now keep track of all the goals
to the right that could fail, since it is these goals that may reject the first
solution of a committed choice goal.
The motivation for this diff was the fact that I found that locating the
failing goal can be very difficult if the conjunction to the right is
a couple of hundred lines long. This would have been a nontrivial problem,
since (a) unifications involving values of user-defined types are committed
choice goals, and (b) we can expect uses of user-defined types to increase.
compiler/det_analysis.m:
Keep track of goals to the right of the current goal that could fail,
and include them in the error representation if required.
compiler/det_report.m:
Include the list of failing goals to the right in the representations
of determinism errors involving committed committed choice goals.
Convert the last part of this module that wasn't using error_util
to use error_util. Make most parts of this module just construct
error message specifications; print those specifications (using
error_util) in only a few places.
compiler/hlds_out.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
compiler/compiler_util.m:
Error_util is still changing reasonably often, and yet it is
included in lots of modules, most of which need only a few simple
non-parse-tree-related predicates from it (e.g. unexpected).
Move those predicates to a new module, compiler_util.m. This also
eliminates some undesirable dependencies from libs to parse_tree.
compiler/libs.m:
Include compiler_util.m.
compiler/notes/compiler_design.html:
Document compiler_util.m, and fix the documentation of some other
modules.
compiler/*.m:
Import compiler_util instead of or in addition to error_util.
To make this easier, consistently use . instead of __ for module
qualifying module names.
tests/invalid/det_errors_cc.{m,err_exp}:
Add this new test case to test the error messages for cc contexts.
tests/invalid/det_errors_deet.{m,err_exp}:
Add this new test case to test the error messages for unifications
inside function symbols.
tests/invalid/Mmakefile:
Add the new test cases.
tests/invalid/det_errors.err_exp:
tests/invalid/magicbox.err_exp:
Change the expected output to conform to the change in det_report.m,
which is now more consistent.
|
||
|
|
6df9a05856 |
This diff cleans up a bunch of modules. It has no algorithmic changes
Estimated hours taken: 10 Branches: main This diff cleans up a bunch of modules. It has no algorithmic changes other than in the formatting of error messages. compiler/error_util.m: Delete the obsolete predicate append_punctuation, since the suffix format component can now do more, and do it more easily. compiler/goal_util.m: compiler/hlds_goal.m: compiler/hlds_llds.m: compiler/instmap.m: compiler/const_prop.m: Change the argument order of some the predicates exported by these modules to make them easier to use with state variable syntax. compiler/*.m: Convert a bunch of these modules to four space indentation, and fix departures from our coding style. Conform to the changed argument order above. Use suffixes instead of append_punctuation. library/string.m: Add string.foldl2. tests/invalid/circ_*.err_exp: tests/warnings/unused_args_*.exp: Expect the updated error messages, which format sym_names consistently the same way as other messages. |
||
|
|
d692bb674f |
Move the rest of mode_errors.m to use error_util.
Estimated hours taken: 8 Branches: main Move the rest of mode_errors.m to use error_util. compiler/mode_errors.m: The parts of this module that generate error messages (as opposed to progress messages) now all return a description of the error to a central place for printing by error_util.m. This should make it significantly easier to add new error messages. compiler/error_util.m: Add the new capability to support mode_errors.m: that of describing in one data structure a sequence of calls to write_error_pieces. compiler/hlds_out.m: Given a bunch of existing predicates that print various things, provide versions that convert those things to strings, for use in mode_errors.m. Write_unify_context had two versions for printing and only one version for conversion to pieces; add the second version for conversion to pieces. Change the order of arguments of the five-argument version of write_unify_context to allow the use of state variables. compiler/mercury_to_mercury.m: compiler/prog_out.m: Given a bunch of existing predicates that print various things, provide versions that convert those things to strings, for use in hlds_out.m and mode_errors.m. compiler/det_report.m: Conform to the changed argument order of write_unify_context. library/term_io.m: Fix an old bug: the code of add_escaped_char wasn't actually doing any escaping. hlds_out.m now relies on it doing so. tests/hard_coded/xmlable_test.m: Due to the bugfix in term_io.m, string__string now protects &s with backslashes; expect this. tests/invalid/*.err_exp: Expect mode error messages in the new, better format. |
||
|
|
e06106dfd6 |
Convert this module to four-space indentation to reduce the number
Estimated hours taken: 4 Branches: main compiler/mode_errors.m: Convert this module to four-space indentation to reduce the number of bad line breaks. Fix some departures from our coding standards. Convert most of this module to use error_util.m to format error messages instead just io__write_strings. (Converting the rest will require some changes in hlds_out.m.) compiler/error_util.m: Provide the ability to add prefixes in front of following format components, and the ability to influence the indentation level when starting a new line. This is needed to support some of the new uses of error_util in mode_errors.m. compiler/state_var.m: Remove a redundant format component that causes a minor test case discrepancy with the new code in error_util.m. compiler/modes.m: Minor style fixes. tests/invalid/*.err_exp: Expect better format in mode error messages. |
||
|
|
a65ad5dcb6 |
Allow simple_call_ids to be formatted by the predicates of error_util.m,
Estimated hours taken: 6 Branches: main Allow simple_call_ids to be formatted by the predicates of error_util.m, and convert the error messages in some submodules of make_hlds.m to use this capability. compiler/hlds_pred.m: compiler/prog_data.m: Move the simple_call_id type from hlds_pred to prog_data, since error_util shouldn't import any HLDS modules. compiler/hlds_out.m: compiler/prog_out.m: Move the predicates for printing simple_call_ids from hlds_out to prog_out. Change prog_out.m to four-space indentation to reduce the number of bad line breaks. In prog_out.m, move the relevant comments to the interface, delete unnecessary module qualifications, and delete some long obsolete commented-out code. compiler/error_util.m: Add simple_call_id to the list of format components. Change to four-space indentation to reduce the number of bad line breaks. Conform to the standard format for comments. compiler/add_pragma.m: compiler/make_hlds_passes.m: compiler/make_hlds_warn.m: Use the new capability to convert some error reporting code to use error_util. compiler/*.m: Conform to the changes above, mostly by deleting now incorrect module qualifications. tests/invalid/*.err_exp: tests/warnings/*.err_exp: Expect the new, better formatted error messages. tests/invalid/Mmakefile: Fix some too-long lines in comments. |
||
|
|
a97bca39d7 |
Format comments according to our current guidelines.
Estimated hours taken: 0.1 Branches: main compiler/error_util.m: Format comments according to our current guidelines. |
||
|
|
d075d35702 |
Implement functional dependencies for the typeclass system.
Estimated hours taken: 240 Branches: main Implement functional dependencies for the typeclass system. The implementation has two major parts. First, some of the basic checks of constraints are relaxed. These used to occur in make_hlds but that functionality has now been moved to check_typeclass. We also add a range of new tests to ensure that the FDs are used correctly. Second, an "improvement" pass to context reduction is added. This looks for constraints which match certain rules, and when it finds them updates the current bindings. The general rule is that type variables become more instantiated, but only in a way which provably does not affect the satisfiability of the constraints. XXX The plan for this change is to put the context reduction into a new module check_hlds.typeclasses.m, but I have left the code in typecheck.m for the moment because the diff will be easier to review that way. Moving to the new module will also remove the problem of one particular function being implemented in both typecheck and hlds_data, which is flagged by an XXX in the code. XXX the check for consistency of instances is not yet complete. We check all visible instances, but not instances that are only present at link time. We could check these in a similar way to the check for overlapping instances (that is, by defining a symbol that will conflict and cause a link error if there are overlapping instances), but in the long run a better solution will be required. Producing this is left for a later change. compiler/check_typeclass.m: Check for ambiguities in typeclass constraints here, rather than make_hlds. We check by calculating the closure of the bound type variables under the induced functional dependencies. This pass is merged in with the already existing pass that checks the quantifiers on constrained type variables. Check instances for range-restrictedness and for consistency. When checking for cycles in the typeclass hierarchy, build up the set of ancestors of a class which have FDs on them. This set is used when searching for opportunities to apply improvement rules during type checking. compiler/hlds_data.m: Define hlds_class_fundeps and add it to to hlds_class_defn. Add a field to hlds_class_defn to store the ancestors which have functional dependencies. Define the type 'instance_id', which is just an integer. This is what is used in proofs to identify instances. In hlds_constraints and in constraint_ids, use the terms 'assumed' and 'unproven' rather than 'existential' and 'universal'. The latter are confusing to use since the treatment of constraints differs depending on whether the constraint is on the head or the body of a clause. Add a field to the hlds_constraints for redundant constraints. These are constraints that have either already been reduced or don't need to be reduced, which may contribute to improvement of types. Define some new predicates for initialising and updating the hlds_constraints. compiler/type_util.m: Accommodate the change to hlds_constraints. compiler/hlds_out.m: Output the functional dependencies. compiler/intermod.m: Reconstruct a functional dependency from the HLDS, for outputting. compiler/make_hlds.m: Convert functional dependencies from parse tree form and add them to the HLDS. Check that functional dependencies are identical in subsequent definitions of the same typeclass. Don't check for ambiguity here. That is now done in check_typeclass. compiler/mercury_to_mercury.m: Output functional dependencies in typeclass declarations. compiler/prog_data.m: Define prog_fundeps and add them to the parse tree. compiler/prog_io_typeclass.m: Parse functional dependencies on typeclass declarations. compiler/typecheck.m: Require the class_table to be passed to reduce_context_by_rule_application, since the functional dependencies are stored here. Also thread the bindings argument through, since the bindings may be improved by context reduction. Save the resulting bindings in the type_assign. Instead of passing a list of assumed constraints and threading the unproven constraints through context reduction, thread through a hlds_constraints structure. This contains more information about redundant constraints than just the two lists. Extend context reduction with two new passes. The first applies the "class" FD rule, which tries to find two constraints which are identical on the domain of some FD, and then unifies the range arguments. The pair of constraints are either both redundant constraints, or one redundant constraint and one assumed constraint. The second applies the "instance" FD rule, which for each constraint tries to find an instance which is more general on the domain arguments. It then binds the instance arguments and unifies the range arguments of the instance with those of the constraint. When calculating the head_type_params for a predicate, include all variables that occur in universal constraints, since these may not necessarily occur in the arguments. Rename some variables: use variable prefixes "Pred" and "Parent" for types that are from the callee or that have been renamed apart respectively. This follows the same naming scheme used in polymorphism. Remove the headtypes/0 type, and use head_type_params/0 throughout. Add a new kind of cons_error for using "new" on a constructor that is not existentially typed. We check for this situation in convert_cons_defn, and report it in report_cons_error. Pass a value to convert_cons_defn indicating whether the constraints should be flipped or not, and whether the context is a constructor that uses 'new'. We flip the constraints here rather than after the fact, since creating the constraints now requires some extra processing to be done, and we don't want to have to redo that processing. Add a constant function that specifies whether variable numbers should be displayed as part of the debugging output. This is currently set to 'yes' but the previous behaviour can be achieved by changing the value to 'no'. doc/reference_manual.texi: Document the new feature. NEWS: Announce the new feature. tests/*: New test cases. compler/*.m: Minor changes related to the above. compiler/error_util.m: Fix comment grammar. compiler/prog_type.m: Fix an incorrect comment. |
||
|
|
624ec2ef16 |
Only allow existential constraints to constrain existentially quantified
Estimated hours taken: 2 Branches: main, release-0.12 Only allow existential constraints to constrain existentially quantified type variables. Likewise only allow universal constraints to constrain universally quantified type variables. We previously didn't check these conditions, and in fact the reference manual allowed otherwise. However, the implementation did not support existential constraints on universally quantified type variables, and will not do so for the foreseeable future. The implementation does support universal constraints on existentially quantified variables, however these are not useful since no caller will ever be able to satisfy the constraints. compiler/check_typeclass.m: Check these conditions as part of typeclass checking. Also return a bool from the recently added check for concrete instances, indicating whether errors were found or not. compiler/error_util.m: compiler/hlds_error_util.m: Add a couple of utility functions for constructing error messages. compiler/mercury_compile.m: Stop compilation after checking typeclasses if errors were encountered. If the above conditions are not met then typechecking may abort. doc/reference_manual.texi: Document the condition on typeclass constraints. tests/invalid/Mmakefile: tests/invalid/quant_constraint_1.err_exp: tests/invalid/quant_constraint_1.m: tests/invalid/quant_constraint_2.err_exp: tests/invalid/quant_constraint_2.m: Test cases for the new error messages. tests/invalid/unbound_type_vars.err_exp: Update this test case. |
||
|
|
a0e5667af5 |
Do not allow non-abstract instance declarations to occur in module
For review by anyone. Estimated hours taken: 10 Branches: main, release Do not allow non-abstract instance declarations to occur in module interfaces. Emit an error message if this occurs. Fix the formatting of some error messages regarding typeclasses and instances. compiler/check_typeclass.m: Use error_util to generate the error messages from this module. This fixes a problem where the printing of sym_names and arities differed in the same error message. compiler/error_util.m: Add a format component for the pred_or_func type. Add the equivalence type format_components. compiler/make_hlds.m: Make the format of some error messages concerning typeclasses more consistent. compiler/modules.m: Check for non-abstract instance declarations in module interfaces and emit an error message if they do. tests/invalid/Mmakefile: tests/invalid/instance_bug.m: tests/invalid/instance_bug.err_exp: Test case for the above. tests/hard_coded/typeclasses/*: tests/invalid/*: tests/recompilation/*: tests/valid/*: Update test cases as necessary. |
||
|
|
c5e315b0fc |
Add the first part of the new termination analyser.
Estimated hours taken: lots Branches: main Add the first part of the new termination analyser. This includes most of the argument size analyser and a simple termination checker - I'll add a more extensive one as part of another diff. The one included here is only a placeholder and is roughly equivalent to the one used by the existing termination analyser. The new analysis abstracts term size relationships over a domain of (rational) convex constraints. The resulting size relationships are, in many cases, more precise than we can obtain with the old analysis. This means that we should be able to prove termination in more cases. The tradeoff for this increased precision is that the new termination analysis is slower than the old one. We should also be able to adapt the new analyser to handle things like higher-order constructs and intermodule mutual recursion more easily than the old one. The code for writing termination2_info pragmas to .opt and .trans_opt files is currently commented out. It will need to stay that way until after this change bootstraps and after the tests/term directory as been reworked (the .trans_opt_exp files need to updated and some new test cases have to added - I'll do this as part of separate diff). It isn't clear what the relationship between the new analyser and the existing one should be, so at the moment they are as independent of each other as possible. compiler/termination2.m: New file. Invokes the the other passes of the new analysis and handles the output of termination2_info pragmas to .opt and .trans_opt files. XXX I've disabled the writing out of termination2_info pragmas to the (transitive-)intermodule optimization files until I've updated the test suite. compiler/term_constr_data.m: New file. Defines the main data structures used by the new analysis. compiler/term_constr_initial.m: New file. Sets up information for builtin and compiler generated procedures and processes information about imported procedures. Also handles termination pragmas. compiler/term_constr_build.m: New file. Converts the HLDS representation of a procedure into the abstract representation that we use during the rest of the analysis. compiler/term_constr_fixpoint.m: New file. Perform a fixpoint calculation in order to derive interargument size relationships for a procedure (in the form of convex constraints). compiler/term_constr_pass2.m: New file. A rudimentary termination checker that is roughly equivalent to what the existing termination analysis does. This is just a placeholder. compiler/term_constr_util.m: New file. Utility predicates that are used by the above modules. compiler/term_constr_errors.m: New file. Equivalent to term_errors.m for the new analyser. compiler/rat.m: Provide rational numbers over fixed precision integers. Originally committed on the termination2 branch. compiler/lp_rational.m: Provides the necessary machinery for manipulating systems of linear constraints. Originally committed on the termination2 branch although most of this version is new. (Some bits of the version on the termination2 branch are now in polyhedron.m). The linear solver is essentially the one that is currently in lp.m converted to use rationals rather than floats. compiler/polyhedron.m: New file. An ADT that provides convex polyhedra over the rationals (or at least over rats). The abstraction barrier was designed so that we could experiment with different representations for the polyhedra. compiler/term_norm: Clean up the documentation of this module. Make set_functor_info into a function. Add a function for finding a lower bound on the weight of a functor. compiler/trans_opt.m: Output termination2_info pragmas in .trans_opt files. compiler/transform_hlds.m: Include the new termination analyser. compiler/goal_form.m: When checking whether a goal can loop or not use information from the new termination analyser as well as the old one. compiler/globals.m: compiler/handle_options: compiler/options.m: Add options to control the new analyser. The documentation is currently commented out because the new analysis is still a work-in-progress. It should be uncommented when the new analysis is more mature. XXX The user guide still needs to be updated. compiler/hlds_out.m: Add hlds_out.write_pred_proc_id/4. compiler/hlds_pred.m: Add a slot in the proc_sub_info structure for the termination2_info structure. compiler/rat.m: Provide rational numbers over fixed precision integers. compiler/lp_rational.m: Provide the constraint machinery required by the analyser. compiler/make_hlds.m: Handle imports of termination2_info pragmas. compiler/mercury_compile.m: Run the new pass. Currently, we do this directly after the old termination analysis pass. compiler/mercury_to_mercury.m: Add code to output termination2_info pragmas. compiler/libs.m: Include the rat, polyhedron and lp_rational modules. compiler/prog_data.m: Define the types necessary for termination2_info pragmas. Change the cannot_loop constructor of the generic_termination_info type so it has a polymorphic argument. The new analyser stores information in it. Fix some spelling errors in some of the comments compiler/prog_io_pragma.m: Parse termination2_info pragmas. compiler/error_util.m: Add function versions of sorry/2 and unexpected/2. compiler/module_qual.m: compiler/modules.m: compiler/recompilation.version.m: compiler/termination.m compiler/term_pass2.m compiler/term_util.m: Minor changes to confrom to the above. |
||
|
|
c08ca7fbc8 |
Import only one module per line in the modules of the compiler
Estimated hours taken: 3 Branches: main compiler/*.m: Import only one module per line in the modules of the compiler where my previous diff did not already do so. Misc other cleanups. Where relevant, use the new mechanism in tree.m. compiler/tree.m: Fix a performance problem I noticed while update :- import_module items. Instead of supplying a function to convert lists of trees to a tree, make the tree data structure able to hold a list of subtrees directly. This reduces the number of times where we have to convert list of trees to trees that are sticks just to stay within the old definition of what a tree is. |
||
|
|
10c8d88223 |
Convert this module to our current coding style.
Estimated hours taken: 6 Branches: main compiler/module_qual.m: Convert this module to our current coding style. Use state variables where appropriate. Reorder arguments as required to allow the use of state variables. Use error_util instead of io__write_string to print error messages. Use predmode declarations where possible. Use . as the module name separator. There are no algorithmic changes except for the use of error_util. compiler/middle_rec.m: Convert this module to our current coding style. Use predmode declarations where possible. compiler/make_hlds.m: compiler/mercury_compile.m: Conform to changed argument orders of predicates in module_qual.m. compiler/error_util.m: Add a new version of the utility predicate that puts commas and "and"s between elements of a list. Fix an old bug: when printing a symname/arity pair, put quotes around only the symname part. tests/invalid/*.err_exp: tests/invalid/purity/*.err_exp: tests/recompilation/*.err_exp.2: tests/warning/*.exp: Update the expected error messages to reflect the better wrapping we get from error_util, and in some cases to reflect the fixed code for quotes around symnames. |
||
|
|
7234e16972 |
Check for cycles in the typeclass hierarchy.
Estimated hours taken: 3 Branches: main Check for cycles in the typeclass hierarchy. This fixes a long-standing bug whereby the compiler could go into an infinite loop in the polymorphism stage if cycles were present. compiler/check_typeclass.m: Add a pass to check through all visible typeclass declarations and report when a cycle is found. The interface to this module has been made more general, to reflect the fact that it checks the superclass relation as well as instance declarations. compiler/mercury_compile.m: Use the new interface to the check_typeclass module. compiler/error_util.m: Add a new format_component for sym_name_and_arity. BUGS: Remove the bug report from this file. tests/invalid/Mmakefile: test/invalid/cyclic_typeclass.err_exp: Enable the cyclic_typeclass test, since we now pass it, and add an expected output file. Also add a couple of new tests. test/invalid/cyclic_typeclass_2.m: test/invalid/cyclic_typeclass_2.err_exp: test/invalid/cyclic_typeclass_3.m: test/invalid/cyclic_typeclass_3.err_exp: New test cases. |
||
|
|
59d2d4a573 |
This adds a module mdbcomp__trace_counts that reads in the
Estimated hours taken: 17 Branches: main This adds a module mdbcomp__trace_counts that reads in the .mercury_trace_counts files produced by the compiler's trace mechanism. The format of said files was slightly changed. As the new module is to be used by the compiler and the debugger, it is placed in the mdbcomp module. This required bringing some types from the compiler into a new module within mdbcomp. browser/trace_counts.m: New module for reading execution trace summaries. browser/prim_data.m: New module holding types and predicates moved in from the compiler. Types: pred_or_func, sym_name, module_name, proc_label, special_pred_id, trace_port Predicates: string_to_sym_name, insert_module_qualifier The mode field of proc_label is now an int instead of a proc_id to avoid pulling proc_id into mdbcomp. browser/mdbcomp.m: Add trace_counts and prim_data to the mdbcomp module. browser/declarative_execution.m: Renamed mdb's definition of module_name to flat_module_name to avoid conflicts with the definition in mdbcomp__prim_data. runtime/mercury_trace_base.c: In the format of .mercury_trace_counts, write module and predicate names now use quoted atom syntax so that names with spaces and non-printable characters can be machine-parsed. browser/: compiler/: Many changes to account for movement of types, and the change to proc_label. |
||
|
|
9187c0d911 |
Bring these modules up to date with our current style guidelines.
Estimated hours taken: 8 Branches: main compiler/hlds_out.m: compiler/llds_out.m: Bring these modules up to date with our current style guidelines. Use state variables in the few places where we weren't doing so already. compiler/purity.m: Bring this module up to date with our current style guidelines. Use the predicates of error_util and hlds_error_util to print error messages. Be more consistent in using quotations. Fix indentation. compiler/error_util.m: Add a long needed facility: the ability to glue some punctuation at the end of a previous word. Add a mechanism for turning a list of components into a string, instead of printing them out. Make the interface of this module more consistent by making list_to_pieces a function just like component_lists_to_pieces. compiler/hlds_error_util.m: Change the way we describe predicates and procedures. Instead of returning their descriptions as single fixed strings that error_util can't break up across lines, return them as separate components that can be split across lines. This makes error output look nicer. Fix a mismatch between what were supposed to be corresponding pieces of code in hlds_error_util and hlds_out. Turn the appropriate predicates into functions. compiler/*.m: Conform to the changed interfaces of some of the above modules. tests/invalid/*.err_exp: tests/invalid/purity/*.err_exp: tests/recompilation/*.err_exp: tests/warnings/*.exp: Update the expected outputs for the better looking error messages we now generate. |
||
|
|
1a6898b0ec |
Emit an error message when a procedure has two or more
Estimated hours taken: 2.5 Branches: main Emit an error message when a procedure has two or more different kinds of tabling pragma applied to it. Presently, the compiler just silently ignores this and applies the last tabling pragma listed. compiler/error_util.m: Make the documentation of write_error_pieces/5 more detailed. compiler/make_hlds.m: Emit an error message if two different tabling pragmas are applied to the same procedure. Fix some lines that are > 80 chars in length. tests/invalid/Mmakefile: tests/invalid/conflicting_tabling_pragmas.m: tests/invalid/conflicting_tabling_pragmas.err_exp: Test case for the above. |
||
|
|
e854a5f9d9 |
Major improvements to tabling, of two types.
Estimated hours taken: 32
Branches: main
Major improvements to tabling, of two types. The first is the implementation
of the loopcheck and memo forms of tabling for model_non procedures, and the
second is a start on the implementation of a new method of implementing
minimal model tabling, one that has the potential for a proper fix of the
problem that we currently merely detect with the pneg stack (the detection
is followed by a runtime abort). Since this new method relies on giving each
own generator its own stack, the grade component denoting it is "mmos"
(minimal model own stack). The true name of the existing method is changed
from "mm" to "mmsc" (minimal model stack copy). The grade component "mm"
is now a shorthand for "mmsc"; when the new method works, "mm" will be changed
to be a shorthand for "mmos".
configure.in:
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/final_grade_options.sh-subr:
compiler/options.m:
Handle the new way of handling minimal model grades.
scripts/mgnuc.in:
compiler/compile_target_code.m:
Conform to the changes in minimal model grade options.
compiler/table_gen.m:
Implement the transformations required by the loopcheck and memo
tabling of model_non procedures, and the minimal model own stack
transformation.
The new implementation transformations use foreign_procs with extra
args, since there is no point in implementing them both that way and
with separate calls to library predicates. This required making the
choice of which method to use at the top level of each transformation.
Fix an oversight that hasn't caused problems yet but may in the future:
mark goals wrapping the original goals as not impure for determinism
computations.
compiler/handle_options.m:
Handle the new arrangement of the options for minimal model tabling.
Detect simultaneous calls for both forms of minimal model tabling,
and generate an error message. Allow for more than one error message
generated at once; report them all once rather than separately.
compiler/globals.m:
Add a mechanism to allow a fix a problem detected by the changes
to handle_options: the fact that we currently may generate a usage
message more than once for invocations with more than one error.
compiler/mercury_compile.m:
compiler/make.program_target.m:
compiler/make.util.m:
Use the new mechanism in handle_options to avoid generating duplicate
usage messages.
compiler/error_util.m:
Add a utility predicate for use by handle_options.
compiler/hlds_pred.m:
Allow memo tabling for model_non predicates, and handle own stack
tabling.
compiler/hlds_out.m:
Print information about the modes of the arguments of foreign_procs,
since this is useful in debugging transformations such as tabling
that generate them.
compiler/prog_data.m:
compiler/layout_out.m:
compiler/prog_out.m:
runtime/mercury_stack_layout.h:
Mention the new evaluation method.
compiler/goal_util.m:
Change the predicates for creating calls and foreign_procs to allow
more than one goal feature to be attached to the new goal. table_gen.m
now uses this capability.
compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/polymorphism.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/typecheck.m:
compiler/unify_proc.m:
Conform to the changes in goal_util.
compiler/code_info.m:
compiler/make_hlds.m:
compiler/modules.m:
compiler/prog_io_pragma.m:
Conform to the new the options controlling minimal model
tabling.
compiler/prog_util.m:
Add a utility predicate for use by table_gen.m.
library/std_util.m:
Conform to the changes in the macros for minimal model tabling grades.
library/table_builtin.m:
Add the types and predicates required by the new transformations.
Delete an obsolete comment.
runtime/mercury_grade.h:
Handle the new minimal model grade component.
runtime/mercury_conf_param.h:
List macros controlling minimal model grades.
runtime/mercury_tabling.[ch]:
Define the types needed by the new transformations,
Implement the performance-critical predicates that need to be
hand-written for memo tabling of model_non predicates.
Add utility predicates for debugging.
runtime/mercury_tabling_preds.h:
Add the implementations of the predicates required by the new
transformations.
runtime/mercury_mm_own_stacks.[ch]:
This new module contains the first draft of the implementation
of the own stack implementation of minimal model tabling.
runtime/mercury_imp.h:
Include the new file if the grade needs it.
runtime/Mmakefile:
Mention the new files, and sort the lists of filenames.
runtime/mercury_tabling_macros.h:
Add a macro for allocating answer blocks without requiring them to be
pointed to directly by trie nodes.
runtime/mercury_minimal_model.[ch]:
The structure type holding answer lists is now in mercury_tabling.h,
since it is now also needed by memo tabling of model_non predicates.
It no longer has a field for an answer num, because while it is ok
to require a separate grade for debugging minimal model tabling,
it is not ok to require a separate grade for debugging memo tabling
of model_non predicates. Instead of printing the answer numbers,
print the answers themselves when we need to identify solutions
for debugging.
Change function names, macro names, error messages etc where this is
useful to distinguish the two kinds of minimal model tabling.
Fix some oversights wrt transient registers.
runtime/mercury_context.[ch]:
runtime/mercury_engine.[ch]:
runtime/mercury_memory.[ch]:
runtime/mercury_wrapper.[ch]:
With own stack tabling, each subgoal has its own context, so record
the identity of the subgoal owning a context in the context itself.
The main computation's context is the exception: it has no owner.
Record not just the main context, but also the contexts of subgoals
in the engine.
Add variables for holding the sizes of the det and nondet stacks
of the contexts of subgoals (which should in general be smaller
than the sizes of the corresponding stacks of the main context),
and initialize them as needed.
Initialize the variables holding the sizes of the gen, cut and pneg
stacks, even in grades where the stacks are not used, for safety.
Fix some out-of-date documentation, and conform to our coding
guidelines.
runtime/mercury_memory_zones.[ch]:
Add a function to test whether a pointer is in a zone, to help
debugging.
runtime/mercury_debug.[ch]:
Add some functions to help debugging in the presence of multiple
contexts, and factor out some common code to help with this.
Delete the obsolete, unused function MR_printdetslot_as_label.
runtime/mercury_context.h:
runtime/mercury_bootstrap.h:
Move a bootstrapping #define from mercury_context.h to
mercury_bootstrap.h.
runtime/mercury_context.h:
runtime/mercury_bootstrap.h:
Move a bootstrapping #define from mercury_context.h to
mercury_bootstrap.h.
runtime/mercury_types.h:
Add some more forward declarations of type names.
runtime/mercury_dlist.[ch]:
Rename a field to avoid assignments that dereference NULL.
runtime/mercury_debug.c:
runtime/mercury_memory.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_trace.c:
runtime/mercury_stacks.[ch]:
trace/mercury_trace_util.c
Update uses of the macros that control minimal model tabling.
runtime/mercury_stack_trace.c:
Provide a mechanism to allow stack traces to be suppressed entirely.
The intention is that by using this mechanism, by the testing system
won't have to provide separate .exp files for hlc grades, nondebug
LLDS grades and debug LLDS grades, as we do currently. The mechanism
is the environment variable MERCURY_SUPPRESS_STACK_TRACE.
tools/bootcheck:
tools/test_mercury:
Specify MERCURY_SUPPRESS_STACK_TRACE.
trace/mercury_trace.c:
When performing retries across tabled calls, handle memo tabled
model_non predicates, for which the call table tip variable holds
a record with a back pointer to a trie node, instead of the trie node
itself.
trace/mercury_trace_internal.c:
When printing tables, handle memo tabled model_non predicates. Delete
the code now moved to runtime/mercury_tabling.c.
Add functions for printing the data structures for own stack minimal
model tabling.
tests/debugger/print_table.{m,inp,exp}:
Update this test case to also test the printing of tables for
memo tabled model_non predicates.
tests/debugger/retry.{m,inp,exp}:
Update this test case to also test retries across memo tabled
model_non predicates.
tests/tabling/loopcheck_nondet.{m,exp}:
tests/tabling/loopcheck_nondet_non_loop.{m,exp}:
New test cases to test loopcheck tabled model_non predicates.
One test case has a loop to detect, one doesn't.
tests/tabling/memo_non.{m,exp}:
tests/tabling/tc_memo.{m,exp}:
tests/tabling/tc_memo2.{m,exp}:
New test cases to test memo tabled model_non predicates.
One test case has a loop to detect, one has a need for minimal model
tabling to detect, and the third doesn't have either.
tests/tabling/Mmakefile:
Add the new test cases, and reenable the existing tc_loop test case.
Rename some make variables and targets to make them better reflect
their meaning.
tests/tabling/test_mercury:
Conform to the change in the name of the make target.
|
||
|
|
ff60134ee9 |
Bring these modules up to our current coding standards.
Estimated hours taken: 8 Branches: main analysis/analysis.m: browser/browse.m: compiler/accumulator.m: compiler/assertion.m: compiler/atsort.m: compiler/c_util.m: compiler/check_typeclass.m: compiler/clause_to_proc.m: compiler/code_gen.m: compiler/code_model.m: compiler/const_prop.m: compiler/constraint.m: compiler/dead_proc_elim.m: compiler/delay_construct.m: compiler/dependency_graph.m: compiler/det_analysis.m: compiler/det_report.m: compiler/export.m: compiler/fact_table.m: compiler/follow_code.m: compiler/graph_colour.m: compiler/hlds_module.m: compiler/inlining.m: compiler/llds.m: compiler/make_hlds.m: compiler/mercury_to_mercury.m: compiler/ml_tailcall.m: compiler/ml_unify_gen.m: compiler/mmc_analysis.m: compiler/mode_errors.m: compiler/passes_aux.m: compiler/post_typecheck.m: compiler/size_prof.m: compiler/switch_util.m: compiler/table_gen.m: compiler/term_errors.m: compiler/transform_llds.m: compiler/type_util.m: compiler/unify_gen.m: compiler/unneeded_code.m: compiler/unused_args.m: Bring these modules up to our current coding standards. Use predmode declarations and state variable syntax where relevant. Reorder arguments where this is needed for the use state variables. Make the orders of predicate definitions correspond to the order of their declarations. Replace some overly large lambda expressions with named predicates. Convert some predicates to functions where this makes their use more convenient. Use field access notation where convenient. Fix any inconsistent indentation. Remove module prefixes on predicate names where this is necessary to allow sane indentation. In several places, use predicates from error_util.m to print error messages. Apart from this, there are no changes in algorithms. In some places, conform to the changes below. compiler/error_util.m: compiler/hlds_error_util.m: Add new variants of existing predicates for use in some of the changed modules above. compiler/hlds_out.m: Add some functions to convert values of some HLDS types as strings, for use in preparing the arguments of the new calls to predicates in error_util.m. Change the implementations of the predicates that print values of those types to call those functions instead of allowing code duplication. compiler/llds.m: Add some field names to allow use of field updates where relevant. tests/invalid/assert_in_interface.err_exp: tests/invalid/multisoln_func.err_exp: tests/invalid/tricky_assert1.err_exp: Update the expected outputs of these test cases to allow for them being generated by error_util.m, and hence being better formatted than before. |
||
|
|
c91313b32f |
Bring these modules up to date with our current coding style.
Estimated hours taken: 8
Branches: main
compiler/modules.m:
compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/bytecode_data.m:
compiler/prog_io_util.m:
Bring these modules up to date with our current coding style. Use
predmode declarations and state variable syntax where appropriate.
Fix inconsistent indentation. Print more error messages using
error_util.m for printing error messages.
compiler/trace_param.m:
Add a new predicate for use by the updated code in handle_options.m.
compiler/error_util.m:
compiler/hlds_error_util.m:
Make error_util.m to be a submodule of parse_tree.m, not hlds.m.
Most of its predicates are not dependent on HLDS data structures.
Move the ones that are into a new module, hlds_error_util, that
is a submodule of hlds.m. Overall, this reduces the dependence
of submodules of parse_tree.m, including modules.m, on submodules
of hlds.m.
compiler/notes/compiler_design.html:
Update the documentation of compiler modes to account for
hlds_error_util.m.
compiler/hlds.m:
compiler/parse_tree.m:
Update the list of included submodules.
compiler/*.m:
Update module imports and module qualifications as needed for the
change above.
tests/invalid/*.{exp,exp2}:
Update the expected outputs of a bunch of test cases to reflect the new
format of some warning messages due to the user error_util; they now
observe line length limits, and print contexts in some cases where they
were previously missing.
|
||
|
|
e64c6cab22 |
Bring this module up to date with our current coding standards.
Estimated hours taken: 2 Branches: main compiler/mercury_compile.m: Bring this module up to date with our current coding standards. Use predmode declarations and state variable syntax where appropriate. Reorder predicate arguments where this is needed for the use of state variable syntax. Replace lambda expressions with explicitly named predicates where appropriate. Break up predicates that are excessively long and/or excessively deeply indented. Fix inconsistent indentation and wrap 80+ column lines. The only algorithmic change is the replacement of some calls to io__write with calls to predicates in error_util. compiler/error_util.m: Add a predicate for printing messages without context, for use by mercury_compile.m to report problems that are not specific to a single predicate, e.g. inconsistent options. Bring this module up to date with our coding standards. Use predmode declarations and state variable syntax where appropriate. compiler/check_typeclass.m: compiler/dnf.m: compiler/optimize.m: Reorder arguments of predicates exported to mercury_compile.m to allow the use of state variable syntax. compiler/globals.m: Wrap an 80+ column line. |
||
|
|
8693e293a2 |
This diff makes hlds_pred.m and many callers of its predicates easier to read
Estimated hours taken: 4 Branches: main This diff makes hlds_pred.m and many callers of its predicates easier to read and to maintain, but contains no changes in algorithms whatsoever. compiler/hlds_pred.m: Bring this module into line with our current coding standards. Use predmode declarations, functions, and state variable syntax when appropriate. Reorder arguments of predicates where necessary for the use of state variable syntax, and where this improves readability. Replace old-style lambdas with new-style lambdas or with partially applied named procedures. Standardize indentation. compiler/*.m: Conform to the changes in hlds_pred.m. This mostly means using the new argument orders of predicates exported by hlds_pred.m. Where this is now conveniently possible, change predicates to use state variable notation. In some modules, using state variable notation required changing the orders of arguments in the module's top predicate. compiler/passes_aux.m: Change the order of arguments in the calls this module makes to allow the callees to use state variable notation. Convert this module to state variable notation too. |
||
|
|
991647a615 |
Fix a bug in the termination analyser that caused it to ignore
Estimated hours take: 5.5 Branches: main Fix a bug in the termination analyser that caused it to ignore pragma terminates/does_not_terminate declarations. BUGS: Delete the description of the bug regarding does_not_terminate pragmas. compiler/error_util: Add a predicate describe_several_pred_names/3. compiler/term_errors: Add an error type indicating that the cause of non-termination was inconsistent termination pragmas. compiler/termination: Fix a bug that caused pragma terminates and pragma does_not_terminate declarations to be ignored. Check that SCCs in the call-graph have not been annotated with termination pragmas that are inconsistent. Remove some old style lambda expressions. doc/reference_manual.texi: Describe how pramga terminates/does_not_terminate interact with mutually recursive procedures. tests/term/Mmakefile: tests/term/pragma_non_term.m: tests/term/pragma_non_term.trans_opt_exp: tests/term/pragma_term.m: tests/term/pragam_term.trans_opt_exp: tests/warnings/Mercury.options: tests/warnings/Mmakefile: tests/warnings/pragma_term_conflict.m: tests/warnings/pragma_term_conflict.exp: Add some test cases for the termination pragmas. |
||
|
|
6554ef7daa |
Replace "is" with "=".
Estimated hours taken: 2 Branches: main Replace "is" with "=". Add field names where relevant. Replace integers with counters where relevant. |
||
|
|
9551640f55 |
Import only one compiler module per line. Sort the blocks of imports.
Estimated hours taken: 2 Branches: main compiler/*.m: Import only one compiler module per line. Sort the blocks of imports. This makes it easier to merge in changes. In a couple of places, remove unnecessary imports. |
||
|
|
a8ffd3680c |
Change the compiler and tools so that .' and not :' is now used as the
Estimated hours taken: 14 Branches: main Change the compiler and tools so that `.' and not `:' is now used as the module separator in all output. Infix `.' now has associativity yfx and priority 10. NEWS: Report the change. configure.in: Amend the test for an up-to-date Mercury compiler to check whether it recognises `.' as a module qualifier. compiler/code_gen.m: compiler/error_util.m: compiler/hlds_out.m: compiler/prog_out.m: compiler/prog_util.m: compiler/rl_exprn.m: compiler/rl_gen.m: compiler/source_file_map.m: compiler/unused_args.m: library/io.m: library/rtti_implementation.m: library/type_desc.m: runtime/mercury_debug.c: runtime/mercury_deconstruct.c: runtime/mercury_stack_trace.c: Change `:' to `.' as module separator for output. compiler/mercury_to_mercury.m: compiler/prog_io_typeclass.m: As above. Fixed a bug where `.' was not being recognised as a module separator. doc/reference_manual.texi: Report the change. library/term_io.m: Ensure that infix `.' is written without surrounding spaces. tests/hard_coded/dot_separator.m: tests/hard_coded/dot_separator.exp: tests/hard_coded/Mmakefile: Test case added. |
||
|
|
0387a6e9c2 |
Improvements for `:- pragma foreign_type'.
Estimated hours taken: 10
Branches: main
Improvements for `:- pragma foreign_type'.
- Allow default Mercury definitions. The Mercury definition must define
a discriminated union type. The constructors of the Mercury type are
only visible in predicates which have implementations for all the
foreign languages the type has implementations for. In all other
predicates the type is treated as an abstract type (the check for
this isn't quite right).
- Allow polymorphic foreign types.
- Don't require the `:- pragma foreign_type' for exported foreign types
to be in the interface. We now only require that all definitions
have the same visibility.
compiler/prog_data.m:
compiler/prog_io_pragma.m:
Allow polymorphic foreign types.
compiler/prog_io.m:
Export code to parse the type name in a type definition for
use by prog_io_pragma.m.
compiler/make_hlds.m:
Handle Mercury definitions for foreign types.
Separate out the code to add constructors and special predicates
to the HLDS into a separate pass. For foreign types, we don't know
what to add until all type definitions have been seen.
Use the C definition for foreign types with `--target asm'.
compiler/modules.m:
Distinguish properly between `exported' and `exported_to_submodules'.
Previously, if a module had sub-modules, all declarations,
including those in the interface, had import_status
`exported_to_submodules'. Now, the declarations in the
interface have status `exported' or `abstract_exported'.
This is needed to check that the visibility of all the
definitions of a type is the same.
compiler/hlds_pred.m:
Add a predicate status_is_exported_to_non_submodules, which
fails if an item is local to the module and its sub-modules.
compiler/hlds_data.m:
compiler/*.m:
Record whether a du type has foreign definitions as well.
Also record whether uses of the type or its constructors
need to be qualified (this is needed now that adding
the constructors to the HLDS is a separate pass).
compiler/typecheck.m:
Check that a predicate or function has foreign clauses before
allowing the use of a constructor of a type which also has
foreign definitions.
compiler/hlds_pred.m:
compiler/make_hlds.m:
Simplify the code to work out the goal_type for a predicate.
compiler/hlds_out.m:
Don't abort on foreign types.
Print the goal type for each predicate.
compiler/error_util.m:
Handle the case where the message being written is a
continuation of an existing message, so the first line
should be indented.
compiler/module_qual.m:
Remove unnecessary processing of foreign types.
doc/reference_manual.tex:
Document the change.
Update the documentation for mixing Mercury and foreign clauses.
The Mercury clauses no longer need to be mode-specific.
tests/hard_coded/Mmakefile:
tests/hard_coded/foreign_type2.{m,exp}:
tests/hard_coded/foreign_type.m:
tests/hard_coded/intermod_foreign_type.{m,exp}:
tests/hard_coded/intermod_foreign_type2.m:
tests/invalid/Mmakefile:
tests/invalid/foreign_type_2.{m,err_exp}:
tests/invalid/foreign_type_visibility.{m,err_exp}:
Test cases.
tests/invalid/record_syntax.err_exp:
Update expected output.
|
||
|
|
7597790760 |
Use sub-modules to structure the modules in the Mercury compiler directory.
The main aim of this change is to make the overall, high-level structure of the compiler clearer, and to encourage better encapsulation of the major components. compiler/libs.m: compiler/backend_libs.m: compiler/parse_tree.m: compiler/hlds.m: compiler/check_hlds.m: compiler/transform_hlds.m: compiler/bytecode_backend.m: compiler/aditi_backend.m: compiler/ml_backend.m: compiler/ll_backend.m: compiler/top_level.m: New files. One module for each of the major components of the Mercury compiler. These modules contain (as separate sub-modules) all the other modules in the Mercury compiler, except gcc.m and mlds_to_gcc.m. Mmakefile: compiler/Mmakefile: Handle the fact that the top-level module is now `top_level', not `mercury_compile' (since `mercury_compile' is a sub-module of `top_level'). compiler/Mmakefile: Update settings of *FLAGS-<modulename> to use the appropriate nested module names. compiler/recompilation_check.m: compiler/recompilation_version.m: compiler/recompilation_usage.m: compiler/recompilation.check.m: compiler/recompilation.version.m: compiler/recompilation.version.m: Convert the `recompilation_*' modules into sub-modules of the `recompilation' module. compiler/*.m: compiler/*.pp: Module-qualify the module names in `:- module', `:- import_module', and `:- use_module' declarations. compiler/base_type_info.m: compiler/base_type_layout.m: Deleted these unused empty modules. compiler/prog_data.m: compiler/globals.m: Move the `foreign_language' type from prog_data to globals. compiler/mlds.m: compiler/ml_util.m: compiler/mlds_to_il.m: Import `globals', for `foreign_language'. Mmake.common.in: trace/Mmakefile: runtime/Mmakefile: Rename the %.check.c targets as %.check_hdr.c, to avoid conflicts with compiler/recompilation.check.c. |
||
|
|
d96f7a9bd5 |
Allow declarations of the form
Estimated hours taken: 40 Branches: main Allow declarations of the form :- pred p `with_type` higher_order_type `with_inst` higher_order_inst. XXX We should allow `with_inst` annotations on higher-order terms. compiler/prog_data.m: Add fields to `pred_or_func' and `pred_or_func_mode' items to hold the `with_type` and `with_inst` annotations. compiler/prog_io.m: compiler/prog_io_typeclass.m: Parse the annotations. compiler/module_qual.m: Module qualify the annotations. compiler/equiv_type.m: Expand away `with_type` and `with_inst`. Report errors. Strip items containing errors from the item list. Record smart recompilation dependencies on the types and modes expanded. Also record a dependency on the arity of predicate and function declarations before expansion. Use error_util for error messages. compiler/mercury_to_mercury.m: Write `with_type` and `with_inst` annotations to interface files. compiler/make_hlds.m: Ignore `with_type` and `with_inst` fields in predicate and function declarations. compiler/recompilation.m: Changes to allow equiv_type.m to record dependencies on arbitrary items, not just types. compiler/recompilation_usage.m: compiler/recompilation_check.m: Allow searches in the sets of used predicates and functions using name, not name and arity, as the key. This is needed because the actual arity of a predicate defined using `with_type` is not known when writing the interface files. compiler/recompilation_version.m: Handle `with_inst` and `with_type`. Pragmas now need to be recorded in the version_numbers even if there is no matching `:- pred' or `:- func' declaration -- the pragma may apply to a predicate or function declared using `with_type`. compiler/mode_util.m: Export inst_subsitute_arg_list for use by equiv_type.m. compiler/error_util.m: Add predicate `pred_or_func_to_string'. library/std_util.m: Add std_util__map_foldl_maybe and std_util__map_foldl2_maybe, which are like list__map_foldl and list__map_foldl2, but apply to the item stored in a value of type std_util__maybe. NEWS: doc/reference_manual.texi: Document the new syntax and library predicates. tests/invalid/Mmakefile: tests/invalid/with_type.m: tests/invalid/with_type.err_exp: tests/invalid/constrained_poly_insts.err_exp: tests/recompilation/TESTS: tests/recompilation/unchanged_with_type_nr*: tests/recompilation/with_type_re*: Test cases. tests/invalid/errors1.err_exp: tests/invalid/type_loop.err_exp: tests/invalid/vars_in_wrong_places.err_exp: Update expected output. |
||
|
|
c0ec782364 |
Added initial error checking of promise ex declarations, and adding
Estimated hours taken: 150 Branches: main Added initial error checking of promise ex declarations, and adding the declarations into the HLDS as dummy predicates to leverage off the error checking done for predicates (similarly to how assertions were done). Following this, `promise_exclusive' and `promise_exclusive_exhaustive' declarations are added into a separate table in the HLDS. assertion.m: Moved the pred declaration for assertion__normalise_goal into the interface. goal_util.m: Added a predicate to get the predids of a goal or list of goals. hlds_data.m: hlds_module.m: Added exclusive_table to HLDS, and operations on it. hlds_out.m: Added printing of promise ex declaration error messages (also improves assertion error messages). hlds_pred.m: Change to type `goal_type' to add constructor for general promise declarations (merged with assertions). dead_proc_elim.m: error_util.m: intermod.m: typecheck.m: Updated to handle promise declarations similarly to how assertions were handled. make_hlds.m: Perform initial typechecking of promise ex declarations, then add them to the HLDS as dummy predicates. purity.m: post_typecheck.m: Post typechecking routine to add exclusivity declarations to the exclusive_table. |
||
|
|
1e89476e38 |
Avoid unnecessary line wrap.
Estimated hours taken: 0.1 Branches: main compiler/error_util.m: Avoid unnecessary line wrap. |
||
|
|
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.
|