mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-16 06:14:59 +00:00
1c3bc03415740d648e99d0a34389767d76f8808a
303 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
8a28e40c9b |
Add the predicates sorry, unexpected and expect to library/error.m.
Estimated hours taken: 2 Branches: main Add the predicates sorry, unexpected and expect to library/error.m. compiler/compiler_util.m: library/error.m: Move the predicates sorry, unexpected and expect from compiler_util to error. Put the predicates in error.m into the same order as their declarations. compiler/*.m: Change imports as needed. compiler/lp.m: compiler/lp_rational.m: Change imports as needed, and some minor cleanups. deep_profiler/*.m: Switch to using the new library predicates, instead of calling error directly. Some other minor cleanups. NEWS: Mention the new predicates in the standard library. |
||
|
|
8e8281ce7b |
Represent ":- module" and ":- end_module" items using purpose-specific kinds of
Estimated hours taken: 8 Branches: main Represent ":- module" and ":- end_module" items using purpose-specific kinds of items, instead of as part of the generic "module_defn" item kind. This is in preparation for a diff that would return submodules as separate entities in their own right, instead of as an embedded sequence of items that happen to start with a :- module item and end with an optional :- end_module item. Also as preparation, make missing a ":- module" declaration at the start of a source file an error instead of a warning. compiler/prog_item.m: Change the type representing items. compiler/prog_io.m: Conform to the change above, make missing module declarations into an error, and simplify some code. compiler/equiv_type.m: compiler/make_hlds_passes.m: compiler/mercury_to_mercury.m: compiler/module_qual.m: compiler/modules.m: compiler/recompilation.check.m: compiler/recompilation.version.m: Conform to the change above. Where relevant, turn chains of if-then-elses on item types into switches. compiler/inst.m: Make the module name in the module declaration match the module name. tests/invalid/big_test.err_exp: tests/invalid/errors.err_exp: tests/invalid/typeclass_test_1.err_exp: Update the expected error messages. tests/valid/inhibit_warn_test.m: To keep this test case valid, don't omit the ":- module" declaration. |
||
|
|
4ebe3d0d7e |
Stop storing globals in the I/O state, and divide mercury_compile.m
Estimated hours taken: 60 Branches: main Stop storing globals in the I/O state, and divide mercury_compile.m into smaller, more cohesive modules. (This diff started out as doing only the latter, but it became clear that this was effectively impossible without the former, and the former ended up accounting for the bulk of the changes.) Taking the globals out of the I/O state required figuring out how globals data flowed between pieces of code that were often widely separated. Such flows were invisible when globals could be hidden in the I/O state, but now they are visible, because the affected code now passes around globals structures explicitly. In some cases, the old flow looked buggy, as when one job invoked by mmc --make could affect the globals value of its parent or the globals value passed to the next job. I tried to fix such problems when I saw them. I am not 100% sure I succeeded in every case (I may have replaced old bugs with new ones), but at least now the flow is out in the open, and any bugs should be much easier to track down and fix. In most cases, changes the globals after the initial setup are intended to be in effect only during the invocation of a few calls. This used to be done by remembering the initial values of the to-be-changed options, changing their values in the globals in the I/O state, making the calls, and restoring the old values of the options. We now simply create a new version of the globals structure, pass it to the calls to be affected, and then discard it. In two cases, when discovering reasons why (1) smart recompilation should not be done or (2) item version numbers should not be generated, the record of the discovery needs to survive this discarding. This is why in those cases, we record the discovery by setting a mutable attached to the I/O state. We use pure code (with I/O states) both to read and to write the mutables, so this is no worse semantically than storing the information in the globals structure inside the I/O state. (Also, we were already using such a mutable for recording whether -E could add more information.) In many modules, the globals information had to be threaded through several predicates in the module. In some places, this was made more difficult by predicates being defined by many clauses. In those cases, this diff converts those predicates to using explicit disjunctions. compiler/globals.m: Stop storing the globals structure in the I/O state, and remove the predicates that accessed it there. Move a mutable and its access predicate here from handle_options.m, since here is when the mutables treated the same way are. In a couple of cases, the value of an option is available in a mutable for speed of access from inside performance-critical code. Set the values of those mutables from the option when the processing of option values is finished, not when it is starting, since otherwise the copies of each option could end up inconsistent. Validate the reuse strategy option here, since doing it during ctgc analysis (a) is too late, and (b) would require an update to the globals to be done at an otherwise inconvenient place in the code. Put the reuse strategy into the globals structure. Two fields in the globals structure were unused. One (have_printed_usage) was made redundant when the one predicate that used it itself became unused; the other (source_file_map) was effectively replaced by a mutable some time ago. Delete these fields from the globals. Give the fields of the globals structure a distinguishing prefix. Put the type declarations, predicate declarations and predicate definitions in a consistent order. compiler/source_file_map.m: Record this module's results only in the mutable (it serves as a cache), not in globals structure. Use explicitly passed globals structure for other purposes. compiler/handle_options.m: Rename handle_options as handle_given_options, since it does not process THE options to the program, but the options it is given, and even during the processing of a single module, it can be invoked up the three times in a row, each time being given different options. (It was up to four times in a row before this diff.) Make handle_given_options explicitly return the globals structure it creates. Since it does not take an old global structure as input and globals are not stored in the I/O state, it is now clear that the globals structure it returns is affected only by the default values of the options and the options it processes. Before this diff, in the presence of errors in the options, handle_options *could* return (implicitly, in the I/O state) the globals structure that happened to be in the I/O state when it was invoked. Provide a separate predicate for generating a dummy globals based only on the default values of options. This allows by mercury_compile.m to stop abusing a more general-purpose predicate from handle_options.m, which we no longer export. Remove the mutable and access predicate moved to globals.m. compiler/options.m: Document the fact that two options, smart_recompilation and generate_item_version_numbers, should not be used without seeing whether the functionalities they call for have been disabled. compiler/mercury_compile_front_end.m: compiler/mercury_compile_middle_passes.m: compiler/mercury_compile_llds_back_end.m: compiler/mercury_compile_mlds_back_end.m: compiler/mercury_compile_erl_back_end.m: New modules carved out of the old mercury_compile.m. They each cover exactly the areas suggested by their names. Each of the modules is more cohesive than the old mercury_compile.m. Their code is also arranged in a more logical order, with predicates representing compiler passes being defined in the order of their invocation. Some of these modules export predicates for use by their siblings, showing the dependencies between the groups of passes. compiler/top_level.m: compiler/notes/compiler_design.html: Add the new modules. compiler/mark_static_terms.m: Move this module from the ml_backend package to the hlds package, since (a) it does not depend on the MLDS in any way, and (b) it is also needed by a compiler pass (loop invariants) in the middle passes. compiler/hlds.m: compiler/ml_backend.m: compiler/notes/compiler_design.html: Reflect mark_static_terms.m's change of package. compiler/passes_aux.m: Move the predicates for dumping out the hLDS here from mercury_compile.m, since the new modules also need them. Look up globals in the HLDS, not the I/O state. compiler/hlds_module.m: Store the prefix (common part) of HLDS dump file names in the HLDS itself, so that the code moved to passes_aux.m can figure out the file name for a HLDS dump without doing system calls. Give the field names of some structures prefixes to avoid ambiguity. compiler/mercury_compile.m: Remove the code moved to the other modules. This module now looks after only option handling (such as deciding whether to generate .int3 files, .int files, .opt files etc), and the compilation passes up to and including the creation of the first version of the HLDS. Everything after that is subcontracted to the new modules. Simplify and make explicit the flow of globals information. When invoking predicates that could disable smart recompilation, check whether they have done so, and if yes, update the globals accordingly. When compiling via gcc, we need to link into the executable the object files of any separate C files we generate for C code foreign_procs, which we cannot translate into gcc's internal structures without becoming a C compiler as well as a Mercury compiler. Instead of adding such files to the accumulating option for extra object files in the globals structure, we return their names using the already existing mechanism we have always used to link the object files of fact tables into the executable. Give several predicates more descriptive names. Put predicates in a more logical order. compiler/make.m: compiler/make.dependencies.m: compiler/make.module_target.m: compiler/make.module_dep_file.m: compiler/make.program_target.m: compiler/make.util.m: Require callers to supply globals structures explicitly, not via the I/O state. Afterward pass them around explicitly, passing modified versions to mercury_compile.m when invoking it with module- and/or task-specific options. Due the extensive use of partial application for higher order code in these modules, passing around the globals structures explicitly is quite tricky here. There may be cases where a predicate uses an old globals structure it got from a closure instead of the updated module- and/or task-specific globals it should be using, or vice versa. However, it is just as likely that, this diff fixes old problems by preventing the implicit flow of updated-only-for-one-invocation globals structures back to the original invoking context. Although I have tried to be careful about this, it is also possible that in some places, the code is using an updated-for-an-invocation globals structure in some but not all of the places where it SHOULD be used. compiler/c_util.m: compiler/compile_target_code.m: compiler/compiler_util.m: compiler/error_util.m: compiler/file_names.m: compiler/file_util.m: compiler/ilasm.m: compiler/ml_optimize.m: compiler/mlds_to_managed.m: compiler/module_cmds.m: compiler/modules.m: compiler/options_file.m: compiler/pd_debug.m: compiler/prog_io.m: compiler/transform_llds.m: compiler/write_deps_file.m: Require callers to supply globals structures explicitly, not via the I/O state. In some cases, the explicit globals structure argument allows a predicate to dispense with the I/O states previously passed to it. In some modules, rename some predicates, types and/or function symbols to avoid ambiguity. compiler/read_modules.m: Require callers to supply globals structures explicitly, not via the I/O state. Record when smart recompilation and the generation of item version numbers should be disabled. compiler/opt_debug.m: compiler/process_util.m: Require callers to supply the needed options explicitly, not via the globals in the I/O state. compiler/analysis.m: compiler/analysis.file.m: compiler/mmc_analysis.m: Make the analysis framework's methods take their global structures as explicit arguments, not as implicit data stored in the I/O state. Stop using `with_type` and `with_inst` declarations unnecessarily. Rename some predicates to avoid ambiguity. compiler/hlds_out.m: compiler/llds_out.m: compiler/mercury_to_mercury.m: compiler/mlds_to_c.m: compiler/mlds_to_java.m: compiler/optimize.m: Make these modules stop accessing the globals from the I/O state. Do this by requiring the callers of their top predicates to explicitly supply a globals structure. To compensate for the cost of having to pass around a representation of the options, look up the values of the options of interest just once, to make further access much faster. (In the case of mlds_to_c.m, the code already did much of this, but it still had a few accesses to globals in the I/O state that this diff eliminates.) If the module exports a predicate that needs these pre-looked-up options, then export the type of this data structure and its initialization function. compiler/frameopt.m: Since this module needs only one option from the globals, pass that option instead of the globals. compiler/accumulator.m: compiler/add_clause.m: compiler/closure_analysis.m: compiler/complexity.m: compiler/deforest.m: compiler/delay_construct.m: compiler/elds_to_erlang.m: compiler/exception_analysis.m: compiler/fact_table.m: compiler/intermod.m: compiler/mode_constraints.m: compiler/mode_errors.m: compiler/pd_util.m: compiler/post_term_analysis.m: compiler/recompilation.usage.m: compiler/size_prof.usage.m: compiler/structure_reuse.analysis.m: compiler/structure_reuse.direct.choose_reuse.m: compiler/structure_reuse.direct.m: compiler/structure_sharing.analysis.m: compiler/tabling_analysis.m: compiler/term_constr_errors.m: compiler/term_constr_fixpoint.m: compiler/term_constr_initial.m: compiler/term_constr_main.m: compiler/term_constr_util.m: compiler/trailing_analysis.m: compiler/trans_opt.m: compiler/typecheck_info.m: Look up globals information from the HLDS, not the I/O state. Conform to the changes above. compiler/gcc.m: compiler/maybe_mlds_to_gcc.pp: compiler/mlds_to_gcc.m: Look up globals information from the HLDS, not the I/O state. Conform to the changes above. Convert these modules to our current programming style. compiler/termination.m: Look up globals information from the HLDS, not the I/O state. Conform to the changes above. Report some warnings with error_specs, instead of immediately printing them out. compiler/export.m: compiler/il_peephole.m: compiler/layout_out.m: compiler/rtti_out.m: compiler/liveness.m: compiler/make_hlds.m: compiler/make_hlds_passes.m: compiler/mlds_to_il.m: compiler/mlds_to_ilasm.m: compiler/recompilation.check.m: compiler/stack_opt.m: compiler/superhomogeneous.m: compiler/tupling..m: compiler/unneeded_code.m: compiler/unused_args.m: compiler/unused_import.m: compiler/xml_documentation.m: Conform to the changes above. compiler/equiv_type_hlds.m: Give the field names of a structure prefixes to avoid ambiguity. Stop using `with_type` and `with_inst` declarations unnecessarily. compiler/loop_inv.m: compiler/pd_info.m: compiler/stack_layout.m: Give the field names of some structures prefixes to avoid ambiguity. compiler/add_pragma.m: Add notes. compiler/string.m: NEWS: Add a det version of remove_suffix, for use by new code above. |
||
|
|
77a6a6c10c |
Implement several more changes that together speed up compilation time
Estimated hours taken: 16 Branches: main Implement several more changes that together speed up compilation time on training_cars_full by 12%, and also improve tools/speedtest -h by 7.2% and tools/speedtest by 1.6%. The first change is designed to eliminate the time that the compiler spends constructing error messages that are then ignored. The working predicates of prog_io_sym_name used to always return a single result, which either gave a description of the thing being looked, or an error message. However, in many places, the caller did not consider not finding the thing being looked for to be an error, and thus threw away the error message, keeping only the "not found" indication. For each predicate with such callers, this diff provides a parallel predicate that indicates "not found" simply by failing. This allows us to eliminate the construction of the error message, the preparation for the construction of the error message (usually by describing the context), and the construction of the "ok" wrapper. The second change is to specialize the handling of from_ground_term_construct scopes in the termination analyzer. To make this easier, I also cleaned up of the infrastructure of the termination analyzer. The third change is to avoid traversing from_ground_term_construct scopes in quantification.m when finding the variables in a goal, since termination analysis no longer needs the information it gathers. The fourth change is to avoid traversing second and later conjuncts in conjunctions twice. The first step in handling conjunctions is to call implicitly_quantify_conj, which builds up a data structure that pairs each conjunct with the variables that occur free in all the conjuncts following it. However, after this was done and each conjunct was annotated with its nonlocals, we used to compute the variables that occur free in the conjunction as a whole from scratch. This diff changes the code so that we now compute that set based on the information we gathered earlier, avoiding a redundant traversal. The fifth change is to create specialized, lower-arity versions of many of the predicates in quantification.m. These versions are intended for traversals that take place after the compiler has replaced lambda expressions with references to separate procedures. These traversals do not need to pass around arguments representing the variables occurring free in the (now non-existent) lambda expressions. compiler/prog_io_sym_name.m: Make the first change described above. Change some predicate names to adopt a consistent naming scheme in which predicates that do the same job and differ only in how they handle errors have names that differ only in a "try_" prefix. Add some predicate versions that do common tests on the output of the base versions. For example, try_parse_sym_name_and_no_args is a version of try_parse_sym_name_and_args that insists on finding an empty argument list. Remove the unused "error term" argument that we used to need a while ago. Move some predicate definitions to make their order match the order of their declarations. Turn a predicate into a function for its caller's convenience. compiler/term_constr_build.m: Make the second change described above by modeling each from_ground_term_construct scope as a single unification, assigning the total size of the ground term to the variable being built. compiler/term_constr_util.m: Put the arguments of some predicates into a more standard order. compiler/lp_rational.m: Change the names of some function symbols to avoid both the use of graphic characters that require quoting and clashes with other types. Change the names of some predicates to make their purpose clear, and to avoid ambiguity. compiler/quantification.m: Make the third, fourth and fifth changes described above. compiler/*.m: Conform to the changes above. |
||
|
|
cc1711071e |
Make all the pre-HLDS and front-end passes of the compiler gather up
Estimated hours taken: 50 Branches: main Make all the pre-HLDS and front-end passes of the compiler gather up all their error messages and print them all at once, in sorted order, unless the user asked for progress messages, in which case we print all the errors accumulated so far just before each printing each progress message. This should make error message output significantly easier to interpret. compiler/module_imports.m: Add a new field to the module_imports structure (the main pre-HLDS representation of the parse tree) to hold the list of error messages generated so far. Rename the module_imports structure as the module_and_imports structure, since it holds the module's items as well as information about its imports. Update the access predicates to encourage getting the items, the error messages and the error indication all at once. Add mechanisms for updating the error indication and the error messages. Add a distinguishing prefix to the field names of the structure. compiler/error_util.m: compiler/hlds_error_util.m: Add facilities for printing error messages in batches. In error_util.m, delete an unused argument from several predicates. compiler/mercury_compile.m: compiler/intermod.m: Gather up error messages to print in batches. In the parts of the code affected by the above, explicitly pass around a globals structure, instead of having all the predicates get it of the I/O state. Since some code (e.g. the start recompilation system) still uses the copy in the I/O state, we ensure that this copy is kept in sync with the explicitly passed around copy. Rename some predicates to avoid ambiguities. compiler/modules.m: Return errors in the module_and_imports structure, not separately. Gather up error messages to print in batches. Explicitly pass around globals structures. compiler/read_modules.m: Rename the read_modules type to have_read_module_map, since this is more explicit. For each module we have already read, remember not just the items we read from it, but also the error messages we generated during the reading. This is so these error messages can be printed together with other errors from other sources. Explicitly pass around globals structures. compiler/prog_io.m: compiler/purity.m: compiler/stratify.m: Rename several predicates to avoid ambiguities. compiler/modes.m: Change the interface of the main predicate to avoid the need for a lambda expression in mercury_compile.m. compiler/recompilation.check.m: Add a distinguishing prefix to the field names of a structure. Fix a wrong definition of this_file. Conform to the changes above. compiler/compiler_target_code.m: compiler/deps_map.m: compiler/make.m: compiler/make.dependencies.m: compiler/make.module_dep_file.m: compiler/make.module_target.m: compiler/make.program_target.m: compiler/make.util.m: compiler/make_hlds.m: compiler/make_hlds_passes.m: compiler/trans_opt.m: compiler/write_deps_file.m: Conform to the changes above. compiler/add_clause.m: compiler/add_pragma.m: compiler/state_var.m: Add an import of io, since their parent make_hlds.m does not import io anymore. In add_pragma, update an error message that did not mention trseg as well as tr as indicating a trailing grade. tests/hard_coded/Mmakefile: Move two tests that cannot pass in debug grades due to the lack of tail recursion to the list containing the other tests with this property. tests/invalid/test_feature_set.err_exp: Update the expected output of this test to expect the updated error message from add_pragma. tests/invalid/test_feature_set.err_exp2: Add this file as the expected output for trailing grades. tests/invalid/*.err_exp: tests/warnings/*.err_exp: Update the expected output for many tests to expect the error messages in sorted order. |
||
|
|
fc95b27671 |
Add search_for_file_mod_time which returns the last modification time
Branches: main
compiler/file_util.m:
Add search_for_file_mod_time which returns the last modification time
of the found file.
Add parameters to search_for_file and search_for_file_returning_dir
that chooses whether the found file should be left open as the input
stream on success.
Avoid dir.make_path_name where possible as it is slow.
compiler/make.util.m:
Use search_for_file_mod_time instead of something complicated.
compiler/file_names.m:
Make file_is_arch_or_grade_dependent not consider further clauses after
stripping the ".tmp" suffix off a filename.
compiler/compile_target_code.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
compiler/mercury_compile.m:
compiler/mmc_analysis.m:
compiler/module_cmds.m:
compiler/options_file.m:
compiler/prog_io.m:
compiler/read_modules.m:
compiler/write_deps_file.m:
Conform to changes.
|
||
|
|
4292e6fd94 |
Fix an old bug: don't insist that two parts of the same field access
Estimated hours taken: 0.5 Branches: main compiler/prog_io.m: Fix an old bug: don't insist that two parts of the same field access goal have the same context. Always get the context for field access goals from the ^ character. tests/hard_coded/field_access.m: Modify this old test case by giving different parts of a field access different contexts. The old version of the compiler mistakenly rejects it, but the fixed version accepts it. |
||
|
|
056fd7d26c |
Hopefully finish the breakup of the monster module prog_io.m.
Estimated hours taken: 2 Branches: main Hopefully finish the breakup of the monster module prog_io.m. It is now way out of the list of the ten biggest modules. More important, it now has much more coherence: it consists mainly of - the top level loop for reading in items, and - the code for parsing predicate, function and mode declarations. There are still some other misc things that don't fit here (e.g. checking insts for consistency), but they don't fit that well in other modules either. compiler/prog_io.m: compiler/prog_io_mode_defn.m: compiler/prog_io_type_defn.m: Move the code in prog_io.m for dealing with definitions of insts, modes and types into two new modules. Delete some obsolete comments at the top of prog_io.m.. compiler/prog_io_util.m: Move some generic stuff for dealing with declaration attributes and (nonsupported) conditions here from prog_io.m, since the module prog_io_type_defn.m also needs them. compiler/parse_tree.m: compiler/notes/compiler_design.html: Add the new modules. compiler/*.m: Import the new modules where needed. |
||
|
|
1abc2f39a0 |
Continue the breakup of the monster module prog_io.m.
Estimated hours taken: 3 Branches: main Continue the breakup of the monster module prog_io.m. compiler/prog_io.m: compiler/prog_io_mutable.m: compiler/prog_io_sym_name.m: Move the code in prog_io.m for dealing with declarations for mutables and for parsing symbol names and specifiers into two new modules. compiler/parse_tree.m: compiler/notes/compiler_design.html: Add the new modules. compiler/*.m: Import prog_io_sym_name instead of (or, in a couple of cases, as well as) prog_io. |
||
|
|
b445b51205 |
Add a sequence number to the information we collect for each kind of item.
Estimated hours taken: 4 Branches: main Add a sequence number to the information we collect for each kind of item. The purpose of this is to prepare for a later change that will switch from representing the stuff we read in from a file as a list of items to representing it is a data structure that groups all items of a given kind together. This will lose the original order of the items. The sequence number will allow us to recreate it if necessary, e.g. for pretty-printing. compiler/prog_item.m: Add the sequence number field to the information we have about each kind of item. compiler/prog_io.m: compiler/prog_io_dcg.m: compiler/prog_io_pragma.m: compiler/prog_io_typeclass.m: Add code to generate the item sequence numbers. In prog_io.m, change some predicates that used to return an intermediate type such as processed_type_body to make them return an item, since this simplifies adding sequence numbers; it also simplifies the code in general and reduces memory allocation. Rename some uninformatively-named variables that I missed in my last diff. compiler/*.m: Minor changes to conform to the above. Mostly this involves either ignoring the seqnum field, or copying it when an item is updated. |
||
|
|
ec7e2f28ef |
More cleanups. Replace Term0, Term1 etc with meaningful variable
Estimated hours taken: 5
Branches: main
compiler/prog_io.m:
More cleanups. Replace Term0, Term1 etc with meaningful variable
names, and use better variable names in general. Rename some
predicates as well when the old names didn't tell you what the
predicate did, and where the name was ambiguous. Convert several
predicates to disjunctions where this allows factoring out common
code or giving consistent names to arguments.
Inline some more auxiliary predicates whose purpose of indexing
on Prolog systems has long expired. In one case, the simplification
that this made possible showed an opportunity to generate more
comprehensive error messages.
Reorder the predicates in this module to form blocks of code each
dealing with one kind of Mercury construct, e.g. type definitions,
mode definitions, predicate and function declarations, etc.
compiler/prog_io_util.m:
A few changes of the same sort as in prog_io.m.
compiler/prog_io_goal.m:
Conform to the new name of a predicate in prog_io.m.
tests/invalid/func_errors.err_exp:
Expect the more comprehensive error messages.
|
||
|
|
a00596c283 |
The file modules.m contains lots of different kinds of functionality.
Estimated hours taken: 16 Branches: main The file modules.m contains lots of different kinds of functionality. While much of it belongs together, much of it does not. This diff moves most of the functionality that does not belong with the rest to several new modules: libs.file_util parse_tree.deps_map parse_tree.file_names parse_tree.module_cmds parse_tree.module_imports parse_tree.read_module parse_tree.write_deps_file To make them coherent, move some predicates from hlds.passes_aux, parse_tree.prog_io and parse_tree.prog_out to the new modules, making them more accessible, reducing the required access from the hlds package to parse_tree, or from the parse_tree package to libs. In the same spirit, this diff also moves some simple predicates and functions dealing with sym_names from prog_util.m to mdbcomp/prim_data.m. This allows several modules to avoid depending on parse_tree.prog_util. Rename some of the moved predicates and function symbols where this avoids ambiguity. (There were several that differed from other predicates or function symbols only in arity.) Replace several uses of bools with purpose-specific types. This makes some of the code significantly easier to read. This diff moves modules.m from being by far the largest module, to being only the seventh largest, from 8900+ lines to just 4200+. It also reduces the number of modules that import parse_tree.modules considerably; most modules that imported it now import only one or two of the new modules instead. Despite the size of the diff, there should be no algorithmic changes. compiler/modules.m: compiler/passes_aux.m: compiler/prog_io.m: compiler/prog_out.m: Delete the moved functionality. compiler/file_util.m: New module in the libs package. Its predicates search for files and do simple error or progress reporting. compiler/file_names.m: New module in the parse_tree package. It contains predicates for converting module names to file names. compiler/module_cmds.m: New module in the parse_tree package. Its predicates handle the commands for manipulating interface files of various kinds. compiler/module_import.m: New module in the parse_tree package. It contains the module_imports type and its access predicates, and the predicates that compute various sorts of direct dependencies (those caused by imports) between modules. compiler/deps_map.m: New module in the parse_tree package. It contains the data structure for recording indirect dependencies between modules, and the predicates for creating it. compiler/read_module.m: New module in the parse_tree package. Its job is reading in modules, both human-written and machine-written (such as interface and optimization files). compiler/write_deps_file.m: New module in the parse_tree package. Its job is writing out makefile fragments. compiler/libs.m: compiler/parse_tree.m: Include the new modules. compiler/notes/compiler_design.m: Document the new modules. mdbcomp/prim_data.m: compiler/prog_util.m: Move the predicates that operate on nothing but sym_names from prog_util to prim_data. Move get_ancestors from modules to prim_data. compiler/prog_item.m: Move stuff that looks for foreign code in a list of items here from modules.m. compiler/source_file_map.m: Note why this module needs to be in the parse_tree package. compiler/add_pred.m: compiler/add_special_pred.m: compiler/analysis.file.m: compiler/analysis.m: compiler/assertion.m: compiler/check_typeclass.m: compiler/compile_target_code.m: compiler/cse_detection.m: compiler/det_analysis.m: compiler/elds_to_erlang.m: compiler/exception_analysis.m: compiler/export.m: compiler/fact_table.m: compiler/higher_order.m: compiler/hlds_module.m: compiler/hlds_pred.m: compiler/intermod.m: compiler/llds_out.m: compiler/make.dependencies.m: compiler/make.m: compiler/make.module_dep_file.m: compiler/make.module_target.m: compiler/make.program_target.m: compiler/make.util.m: compiler/make_hlds_passes.m: compiler/maybe_mlds_to_gcc.pp: compiler/mercury_compile.m: compiler/mlds.m: compiler/mlds_to_c.m: compiler/mlds_to_gcc.m: compiler/mlds_to_ilasm.m: compiler/mlds_to_java.m: compiler/mmc_analysis.m: compiler/mode_constraints.m: compiler/mode_debug.m: compiler/modes.m: compiler/module_qual.m: compiler/optimize.m: compiler/passes_aux.m: compiler/proc_gen.m: compiler/prog_foreign.m: compiler/prog_io.m: compiler/prog_io_util.m: compiler/prog_mutable.m: compiler/prog_out.m: compiler/pseudo_type_info.m: compiler/purity.m: compiler/recompilation.check.m: compiler/recompilation.usage.m: compiler/simplify.m: compiler/structure_reuse.analysis.m: compiler/structure_reuse.direct.detect_garbage.m: compiler/structure_reuse.direct.m: compiler/structure_sharing.analysis.m: compiler/tabling_analysis.m: compiler/term_constr_main.m: compiler/termination.m: compiler/trailing_analysis.m: compiler/trans_opt.m: compiler/type_util.m: compiler/typecheck.m: compiler/typecheck_info.m: compiler/unify_proc.m: compiler/unused_args.m: compiler/unused_imports.m: compiler/xml_documentation.m: Minor changes to conform to the changes above. |
||
|
|
cc42c8fac5 |
Switch to using error_util to generate error message during the process of
Estimated hours taken: 40 Branches: main Switch to using error_util to generate error message during the process of converting terms to prog_items. In many predicates, we used to return error messages as a string/term pair, with the string being the error message and a term, which both provided the context and was printed after the message. We now return error indications as lists of error_specs. These include a printout of the relevant term only if this helps users understand the nature or the location of the error. To make the printouts easier to understand we print variable names in them using the applicable varsets. (The old version of the compiler used to print each error term long after it lost track of the right varset, and thus used a dummy varset that yielded error messages referring to _1, _2 etc instead of the variable names used by the programmer.) Sometimes the callers of some parse predicates prepended other strings indicating the context of the error in front of the error string. This diff changes things so that now the caller instead passes a list of format components describing the context to the predicates that construct the error_specs. In some places, simplify the code, e.g. by factoring out common code, and by inlining some auxiliary predicates (we used to need these auxiliary predicates for indexing when we executed the compiler using Prolog, but those days are long past). Mark with XXXs places where I think the error messages or their contexts could be improved, and places where the structure of the code could be improved. compiler/prog_io_util.m: Change the representation of the maybeN types to use error_spec lists. 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: Change the way we generate error messages along the lines described at the top. In several cases, this required adding extra arguments (varsets, context descriptions) to predicates for use in error messages. Some of these predicates were also used in contexts where the caller was interested only in success, and would ignore any error messages. In these cases, add a version of the predicate that does not require the extra arguments, and which is semidet (to allow the caller to avoid a test for ok). compiler/error_util.m: Add a mechanism for changing the case of the next format_component, to allow an error message to be appended to a list of format_components providing the context that generates good-looking output whether or not that context is empty. Replace some bools with purpose-specific types. Make sort_error_specs internal to the module, since outside modules should never need to use it. Use cords instead of reversed lists to simplify some parts of the internal implementation. compiler/mercury_to_mercury.m: Provide a mechanism to print out terms only if they aren't too big, for use in our error messages. compiler/prog_item.m: Delete the message_list type, and note a future improvement. compiler/prog_out.m: Delete the predicates for printing message_lists. compiler/intermod.m: compiler/modules.m: Change the way we print out error messages along the lines described at the top. compiler/add_clause.m: compiler/field_access.m: compiler/recompilation.check.m: compiler/recompilation.version.m: compiler/superhomogeneous.m: Conform to the changes above by modifying how we generate error messages. compiler/add_class.m: compiler/add_pragma.m: compiler/check_typeclass.m: compiler/common.m: compiler/make.module_dep_file.m: compiler/make_hlds_error.m: compiler/make_hlds_passes.m: compiler/mercury_compile.m: compiler/mode_errors.m: compiler/modes.m: compiler/options_file.m: compiler/prog_ctgc.m: compiler/prog_event.m: compiler/purity.m: compiler/trans_opt.m: compiler/typecheck.m: Trivial updates to conform to the changes above. compiler/prog_data.m: Add some field names and access functions for use in the modules above. library/list.m: Add list.contains, which is list.member with the arguments reversed to make it possibly to partially apply it. tests/invalid/bad_finalise_decl.err_exp: tests/invalid/bad_initialise_decl.err_exp: tests/invalid/bad_mutable.err_exp: tests/invalid/bigtest.err_exp: tests/invalid/conflicting_fs.err_exp: tests/invalid/constrained_poly_insts.err_exp: tests/invalid/errors.err_exp: tests/invalid/func_errors.err_exp: tests/invalid/fundeps_unbound_in_ctor.err_exp: tests/invalid/fundeps_vars.err_exp: tests/invalid/impl_def_literal_syntax.err_exp: tests/invalid/inst_list_dup.err_exp: tests/invalid/invalid_typeclass.err_exp: tests/invalid/kind.err_exp: tests/invalid/null_char.err_exp: tests/invalid/pragma_source_file.err_exp: tests/invalid/predmode.err_exp: tests/invalid/reserve_tag.err_exp: tests/invalid/some.err_exp: tests/invalid/specified.err_exp: tests/invalid/trace_goal_env.err_exp: tests/invalid/type_vars.err_exp: tests/invalid/typeclass_test_1.err_exp: tests/invalid/typeclass_test_11.err_exp: tests/invalid/typeclass_test_2.err_exp: tests/invalid/unbound_type_vars.err_exp: tests/invalid/unicode1.err_exp: tests/invalid/unicode2.err_exp: tests/invalid/uu_type.err_exp: tests/invalid/vars_in_wrong_places.err_exp: tests/invalid/with_type.err_exp: tests/invalid/purity/purity_nonsense2.err_exp: Update the expected error messages. |
||
|
|
9854006d68 |
Make some long-overdue simplifications.
Estimated hours taken: 1 Branches: main Make some long-overdue simplifications. compiler/prog_item.m: Delete the varset from item_module_defn_infos, since it wasn't being used anywhere. compiler/prog_data.m: compiler/prog_item.m: Remove all the stuff related to importing predicates, functions, ADTs, operators, etc, which have never been implemented. (If we ever wanted to implement them, we would need different code anyway.) Keep only the stuff relating to importing modules. compiler/*.m: Conform to the changes above. tests/invalid/bigtest.err_exp: Update error messages for the never-implemented language features. |
||
|
|
801125616f |
A first step towards rationalizing the parse tree representation of the
Estimated hours taken: 24 Branches: main A first step towards rationalizing the parse tree representation of the program. This step moves the information specific to each kind of item into a structure specific to that kind of item. In the short term, this allows us to express some old invisible invariants as types. For example, we used to store general items in method definitions; we now store clause-specific data there. This allows us to simplify some code and eliminate some old "can't fail" tests. In the longer term, this change will allow us to replace the old list of items representation of the parse tree with a more structured representation, which aggregates each kind of item differently. For example, we could keep clause items in a list, but map module imports to the contexts of their :- import_module items, which would allow us to detect duplicate imports. We could also change the current three pass structure of the parse tree to HLDS conversion step, where each pass processes *all* items, to a much more flexible structure where each pass processes only what it needs to process, new passes could be added much more simply, and in fact the whole notion of a "pass" could be eliminated. In a bunch of places, factor out some common code. compiler/prog_item.m: Make the change to the item type as above. Rename the old item_pred_or_func as item_pred_decl (it already had a field to indicate predicate or function) and item_pred_or_func_mode as item_mode_decl. These names are much more consistent with the other item names. Eliminate the item_and_context type by moving the context into the items themselves. In code that cares about contexts, this makes it easier to match up each item with its context. In code that doesn't care about contexts, this avoids the extra code that would be required to discard the item_and_context wrapper. compiler/prog_data.m: Store item_clause_infos instead of items in method definitions. compiler/prog_io.m: compiler/prog_io_dcg.m: compiler/prog_io_pragma.m: compiler/prog_io_typeclass.m: Construct the new item structure when creating the parse tree. Instead of constructing items and later attaching the context to them, pass the context down, since we now need to include them in items. Some old code was assuming that term.variables had no contexts; update such code. In prog_io_pragma.m, replace a single predicate that parsed all kinds of pragmas, which spanned more than one thousand lines and whose clauses had been interspersed with the clauses of other predicates, with a predicate whose only job is to select which of a bunch of pragma-type-specific parse predicates to invoke. Each of these pragma-type-specific parse predicates corresponds to one of the clauses of the old predicate. In that form, the predicates can be declared det, even though the predicate as a whole is semidet (since not all pragma names are valid). This actually exposed an old bug; the case MaybeAttributes = error1(_) was not handled in foreign_export_enum pragmas. To make the diff easier to check, I left the predicates in the original order of the clauses, even though that order does not make sense (it does not group related pragmas together). I did leave an XXX comment about this. The matter will be addressed in a later diff. (A similar problem occurs in some of the other modules in which I broke up very large predicates.) compiler/prog_io_util.m: Remove some stuff that the new item structure makes unnecessary. compiler/make_hlds_passes.m: compiler/add_class.m: compiler/add_mode.m: compiler/add_pragma.m: compiler/add_solver.m: Conform to the new item structure when converting it to HLDS. Break up excessively large predicates. compiler/prog_foreign.m: Provide a function to return all supported foreign languages, instead of requiring callers to call solutions to compute this list. compiler/mercury_to_mercury.m: Print out the new item structure. Break up excessively large predicates. Rename some predicates to avoid name collisions. compiler/equiv_type.m: compiler/hlds_module.m: compiler/intermod.m: compiler/make.module_dep_file.m: compiler/mercury_compile.m: compiler/module_qual.m: compiler/modules.m: compiler/prog_mutable.m: compiler/recompilation.check.m: compiler/recompilation.version.m: compiler/state_var.m: compiler/trans_opt.m: Operate on the new item structure. Factor out code (usually tests) where the new item structure makes this possible and desirable. Turn if-then-elses into switches where this is desirable. Build up large terms from named pieces instead of all at once. Break up excessively large predicates. In equiv_type.m, rename a predicate to clarify its function, and add an XXX about a possible improvement in abstraction. In modules.m, simplify the interface between some predicates and their callers, turn some predicates into functions, and make some code return error specifications instead of doing raw printing of error messages. Note that this module still has plenty of scope for improvement (I marked some with XXXs), but that is for a later date. In some cases, mark potential bugs with XXXs. compiler/equiv_type_hlds.m: Conform to the change in equiv_type.m. library/term.m: compiler/recompilation.check.m: Move the function for getting the context out of a term from recompilation.check.m to term.m, so it can be used from other modules. (Also, adding such a function to the standard library is long overdue.) NEWS: Note the change to term.m. |
||
|
|
7460aadbf8 |
Implement higher-order any' insts. Pred or func expressions with an any'
Estimated hours taken: 100 Branches: main Implement higher-order `any' insts. Pred or func expressions with an `any' inst may bind non-local solver variables, but themselves must not be called in a negated context. (The existing ground pred and func expressions may not bind non-local solver variables, but may be called in a negated context.) Higher-order `any' insts are specified by using `any_pred' and `any_func' in place of `pred' and `func', respectively. We implement these insts by adding a new field to the any/1 constructor of mer_inst, which is identical to the ground_inst_info field of the ground/2 constructor. Both are given the new type `ho_inst_info'. We then relax the locking of non-local variables in these pred and func expressions, and extend call/N and apply/N to also accept the new insts (provided the variables are not locked). We also store the groundness (ho_ground or ho_any) of each lambda expression in a unification, in a new field in the rhs_lambda_goal constructor. NEWS: Mention the new feature. compiler/prog_data.m: Rename the ground_inst_info type ho_inst_info, and update its documentation. Add the ho_inst_info field to the any constructor in mer_inst. compiler/hlds_goal.m: Add the rhs_groundness field to rhs_lambda_goal in unify_rhs. compiler/inst_match.m: Propagate inst matching into the pred_inst_infos of any insts, if they exist. compiler/inst_util.m: Propagate abstract unification and inst merging into the pred_inst_infos of any insts, if they exist. May use of this information when building ground, any, shared and mostly_unique versions of insts. compiler/modecheck_call.m: Allow an `any' inst as the pred (func) argument to call/N (apply/N), but check that the variable is not locked. If the variable is locked, report a mode error which suggests using the ground inst. (We could also suggest that the goal be made impure, but it is best to point users towards the pure approach.) compiler/modecheck_unify.m: Relax the locking of non-locals when processing non-ground lambda goals. Update documentation. compiler/mode_util.m: Propagate type information into the pred_inst_infos of any insts. compiler/mode_errors.m: Change the purity error "lambda should be impure" to "lambda should be any", since this is better advice. Also provide an example of correct syntax if the verbose errors option is given. compiler/prog_io_goal.m: Parse the new kinds of expressions, returning the groundness along with the existing information about lambda expressions. compiler/superhomogeneous.m: Use the above groundness when building the lambda unification. compiler/prog_io_util.m: Parse the new kind of insts, filling in the new ho_inst_info field where appropriate. compiler/polymorphism.m: Handle the new fields. Assume that the shorthand form of lambda expressions always defines a ground inst -- if users want non-ground higher-order expressions they will need to use an explicit any_pred or any_func expression. compiler/equiv_type_hlds.m: Replace equivalent types in the pred_inst_infos of `any' insts. compiler/module_qual.m: Module qualify the pred_inst_infos of `any' insts. compiler/recompilation.usage.m: compiler/unused_imports.m: Look for items or imports used by insts in the pred_inst_infos of `any' insts. compiler/hlds_out.m: compiler/mercury_to_mercury.m: Output the new lambda expressions and insts in the correct format. compiler/type_util.m: Treat all pred and func types as solver types. (Effectively they are, since all such types can now have non-ground values, with call/N and apply/N acting as constraints.) compiler/lambda.m: Pass the groundness value when building procedures for lambda expressions. This is not currently required for anything. doc/reference_manual.texi: Document the new feature, and update existing documentation on solver types and negated contexts. tests/valid/Mmakefile: tests/valid/ho_any_inst.m: New test case for some valid code using higher-order any insts. tests/invalid/Mmakefile: tests/invalid/ho_any_inst.err_exp: tests/invalid/ho_any_inst.m: New test case for some illegal code. tests/invalid/anys_in_negated_contexts.err_exp: Update expected error message for this test case. We now report that the expression should be `any', rather than impure. compiler/*.m: Handle the new fields. |
||
|
|
5c4ef16fdc |
Improve the style of some predicates.
Estimated hours taken: 0.2
Branches: main
compiler/prog_io.m:
Improve the style of some predicates.
|
||
|
|
0bb49f40d2 |
Fix one of the problems that causes the compiler to run out of stack
Estimated hours taken: 2 Branches: main Fix one of the problems that causes the compiler to run out of stack space when compiling a discriminated unions that has a large numbers of constructors. This speeds up compilation of a type with 200000 constructors by about 1% -- it doesn't have a measurable impact on discriminated unions of a more usual size. compiler/prog_io.m: When checking that the constructors of a discriminated union are well-formed, iterate through the list of constructors once instead of four times. |
||
|
|
bcec8a99e7 |
Remove support for the `initialisation is ...' attribute from solver types.
Estimated hours taken: 2 Branches: main Remove support for the `initialisation is ...' attribute from solver types. This attribute is now a syntax error, unless the developer-only option `--solver-type-auto-init' is enabled -- in which case things will work as before. Update the test suite to conform to the above change. compiler/globals.m: Add a mutable that stores whether or not we support automatic solver type initialisation. The value of this mutable is used in the parser to decide if `initialisation is ...' attributes in solver type definitions are legal syntax or not. compiler/prog_io.m: Only accept `initialisation is ...' attributes in solver type definitions as legal syntax if the value of the above mutable indicates that `--solver-type-auto-init' is enabled. NEWS: Announce the removal of support for automatic initialisation. tests/debugger/Mercury.options: Run the solver_test test with `--solver-type-auto-init' enabled. tests/hard_coded/Mercury.options: Run tests that check if automatic initialisation is working with `--solver-type-auto-init' enabled. Delete a reference to a test case was deleted some time ago. tests/warnings/Mercury.options: tests/invalid/Mercury.options: Enable `--solver-type-auto-init' for some tests. tests/invalid/any_mode.m: tests/invalid/any_passed_as_ground.m: tests/invalid/any_should_not_match_bound.m: tests/invalid/any_ground_in_ite_cond.m: tests/valid/solv.m: tests/hard_coded/any_call_hoist_bug.m: tests/hard_coded/any_free_unify.m: tests/hard_coded/sub-modules/ts.m: Remove `initialisation is ...' attributes from the solver type definitions in these tests. |
||
|
|
f5667464c7 |
Remove support for automatic initialisation of solver types from the language.
Estimated hours taken: 10 Branches: main Remove support for automatic initialisation of solver types from the language. This is being done because: * the current implementation of automatic initialisation means we cannot support polymorphic solver types, e.g. you cannot have the type foo(bar) where: :- solver type foo(T). :- solver type bar. * the current initialisation strategy is fairly ad-hoc anyway; in particular it has a tendency to unnecessarily change the determinism of procedures. * mode error messages are often quite poor because of the interaction between automatic initialisation and impure code. * automatic initialisation is not used in practice. All of the G12 solver libraries that use solver types recommend explicitly initialising solver variables. This change removes support for automatic solver initialisation from the language. The code for supporting it remains in the implementation, but it is now dependent upon the developer-only `--solver-type-auto-init' option. As a transitional measure the compiler will still accept `initialisation is ...' attributes in solver type definitions even when `--no-solver-type-auto-init' is enabled. After this change has bootstrapped, and the relevant updates have been made to the G12 solver libraries, this will be changed so that `initialisation is ...' attributes are considered a syntax error unless `--solver-type-auto-init' is enabled. doc/reference_manual.texi: Document that solver type definitions no longer allow initialisation predicates to be supplied. (The section documenting initialisation predicates has been commented out rather than deleted since the implementation of automatic initialisation still exists.) Remove the section documenting the restrictions on polymorphic solver types. These restrictions no longer apply in the absence of automatic initialisation. compiler/options.m: Add a new developer-only option, `--solver-type-auto-init', that controls whether automatic initialisation of solver variables is allowed (for those solver types that have initialisation predicates specified.) compiler/prog_data.m: Add a type that represents whether a solver type allows automatic initialisation or not. Extend the solver_type_details structure to allow initialisation predicates to be optional. compiler/prog_io.m: Allow initialisation predicates to be optional in solver type definitions. compiler/modes.m: compiler/modecheck_call.m: compiler/modecheck_unify.m: Only insert calls to solver type initialisation predicates if the solver type has an initialisation predicate and the developer-only option `--solver-type-auto-init' is enabled. compiler/unify_proc.m: Handle the situation where a solver type does not have an initialise predicate. compiler/add_special_pred.m: Only add initialisation special predicates for those solver types whose definition provides an initialisation predicate. compiler/mode_info.m: Add a utility predicate that tests whether the support for automatic solver type initialisation is enabled. compiler/type_util.m: Add a predicate that tests whether a type is a solver type that supports automatic initialisation. Add an XXX comment about such types and abstract equivalence types. compiler/mercury_to_mercury.m: Conform to the above changes. compiler/special_pred.m: Fix some typos. samples/solver_types/eqneq.m: Delete the `initialisation is ...' from the definition of the solver type eqneq/1. tests/hard_coded/Mercury.options: Enable `--solver-type-auto-init' for the solver_construction_init_test test. tests/hard_coded/solver_build_call.m: tests/invalid/any_pass_as_ground.m: Don't use automatic solver variable initialisation in these test cases. tests/invalid/partial_implied_mode.err_exp: Conform to the above changes in the mode analyser. tests/valid/Mercury.options: Compile some tests cases with `--solver-type-auto-init' enabled. |
||
|
|
1d61e9a681 |
Fix a bug where a ":- pragma source_file" declaration was effectively
Estimated hours taken: 4
Branches: main
Fix a bug where a ":- pragma source_file" declaration was effectively
ignored if it appeared before the ":- module" declaration. The problem was
that prog_io.read_first_term was not passing the source file name to the
predicates that read the subsequent terms.
compiler/options_file.m:
Fix a typo in a comment.
compiler/prog_io.m:
Change read_first_item to return the source file name, in case this
has been changed by a ":- pragma source_file" declaration.
tests/invalid/Mmakefile:
tests/invalid/pragma_source_file.err_exp:
tests/invalid/pragma_source_file.m:
Add a regression test.
|
||
|
|
057246b934 |
Fix a bug which caused the presence of a file named write.m
Estimated hours taken: 2 Branches: main compiler/modules.m: compiler/prog_io.m: Fix a bug which caused the presence of a file named write.m in the current directory to stop the compiler finding a module bit_buffer.write in a library. The test case for this is tests/hard_coded/bit_buffer_test.m. `mmc --make' already handled this correctly. |
||
|
|
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. |
||
|
|
81b8e55825 |
Add support for thread-local mutables. These can take on a different value for
Estimated hours taken: 15 Branches: main Add support for thread-local mutables. These can take on a different value for each Mercury thread. Child threads automatically inherit the thread-local values of the parent thread that spawned it. compiler/make_hlds_passes.m: compiler/prog_io.m: compiler/prog_item.m: compiler/prog_mutable.m: Accept a `thread_local' attribute for mutables and update the source-to-source transformation. doc/reference_manual.texi: Document the `thread_local' attribute as a Melbourne Mercury compiler extension. runtime/mercury_context.c: runtime/mercury_context.h: Add a `thread_local_mutables' field to MR_Context, which points to an array which holds all the values of thread-local mutables in the program. Each thread-local mutable has an associated index into the array, which is allocated during initialisation. A child thread inherits the parent's thread-locals simply by copying the array. Add a `thread_local_mutables' field to MR_Spark and update the parallel conjunction implementation to take into account thread-locals. runtime/mercury_thread.c: runtime/mercury_thread.h: Add the functions and macros which are used by the code generated for thread-local mutables. runtime/mercury_wrapper.c: Allocate a thread-local mutable array for the initial context at startup. extras/concurrency/spawn.m: Update the spawn/3 implementation to make child threads inherit the thread-local values of the parent. Make different threads in high-level C grades use different MR_Contexts. This makes it possible to use the same implementation of thread-local mutables as in the low-level C grades. tests/hard_coded/mutable_decl.exp: tests/hard_coded/mutable_decl.m: tests/hard_coded/pure_mutable.exp: tests/hard_coded/pure_mutable.m: tests/invalid/bad_mutable.err_exp: tests/invalid/bad_mutable.m: Add some thread-local mutables to these test cases. NEWS: Announce the addition. |
||
|
|
ba93a52fe7 |
This diff changes a few types from being defined as equivalent to a pair
Estimated hours taken: 10 Branches: main This diff changes a few types from being defined as equivalent to a pair to being discriminated union types with their own function symbol. This was motivated by an error message (one of many, but the one that broke the camel's back) about "-" being used in an ambiguous manner. It will reduce the number of such messages in the future, and will make compiler data structures easier to inspect in the debugger. The most important type changed by far is hlds_goal, whose function symbol is now "hlds_goal". Second and third in importance are llds.instruction (function symbol "llds_instr") and prog_item.m's item_and_context (function symbol "item_and_context"). There are some others as well. In several places, I rearranged predicates to factor the deconstruction of goals into hlds_goal_expr and hlds_goal_into out of each clause into a single point. In many places, I changed variable names that used "Goal" to refer to just hlds_goal_exprs to use "GoalExpr" instead. I also changed variable names that used "Item" to refer to item_and_contexts to use "ItemAndContext" instead. This should make reading such code less confusing. I renamed some function symbols and predicates to avoid ambiguities. I only made one algorithmic change (at least intentionally). In assertion.m, comparing two goals for equality now ignores goal_infos for all kinds of goals, whereas previously it ignored them for most kinds of goals, but for shorthand goals it was insisting on them being equal. This seemed to me to be a bug. Pete, can you confirm this? |
||
|
|
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. |
||
|
|
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. |
||
|
|
f9cac21e3e |
Get rid of a bunch more ambiguities by renaming predicates, mostly
Estimated hours taken: 8
Branches: main
Get rid of a bunch more ambiguities by renaming predicates, mostly
in polymorphism.m, {abstract,build,ordering}_mode_constraints.m, prog_type.m,
and opt_debug.m in the compiler directory and term_io.m, term.m, parser.m,
and string.m in the library.
In some cases, when the library and the compiler defined the same predicate
with the same code, delete the compiler's copy and give it access to the
library's definition by exporting the relevant predicate (in the undocumented
part of the library module's interface).
NEWS:
Mention that the names of some library functions have changed.
library/*.m:
compiler/*.m:
mdbcomp/*.m:
browser/*.m:
Make the changes mentioned above, and conform to them.
test/general/string_test.m:
test/hard_coded/string_strip.m:
test/hard_coded/string_strip.exp:
Conform to the above changes.
|
||
|
|
586cbb16ac |
Change the implementation of map.merge/3 so that it throws an exception if the
Estimated hours taken: 1.5
Branches: main, release
Change the implementation of map.merge/3 so that it throws an exception if the
sets of keys of the input maps are not disjoint. This is more in keeping with
the documentation for that predicate which says they should be disjoint.
The existing implementation handled duplicate keys by inserting the key and
the smallest of the corresponding values into the output map. Some of the
code in the compiler seems to rely on this behaviour - this is (probably) a
bug but in at least in one instance, to do with merging RTTI varmaps
during higher-order specialisation, it's going to be a bit tricky to fix.
Rather than modify the compiler at the moment the old version of map.merge/3
is available as map.old_merge/3 and the compiler still uses this. (This
predicate is not included in the library reference manual.)
library/map.m:
Make map.merge/3 throw an exception if the sets of keys of the
input maps are not disjoint.
Add the implementor-only predicate map.old_merge/3 for use by the
compiler.
compiler/hlds_rtti.m:
compiler/interval.m:
compiler/prog_io.m:
compiler/tupling.m:
Conform to the above changes.
tests/hard_coded/map_merge_test.{m,exp}:
Test for the new behaviour.
tests/hard_coded/Makefile:
Don't run the above test in deep profiling grades since it
catches exceptions which the deep profiler cannot currently handle.
|
||
|
|
f070e2a1b7 |
Convert the make_hlds stage of the compiler from printing out error messages
Estimated hours taken: 14 Branches: main Convert the make_hlds stage of the compiler from printing out error messages one at a time to gathering them all up and printing them all at once after sorting and deleting duplicates. This approach makes it much easier to be consistent about updating the exit status in the I/O state and the error count in the module info, and indeed this diff fixes some bugs in this area. This approach also means that instead of threading a pair of I/O states through these modules, we now mostly thread through a list of error specifications. In a couple of places, we create the I/O states we need for printing progress messages using trace goals. configure.in: Check that the installed compiler supports trace goals (perhaps with warnings), since the compiler now uses them. compiler/Mercury.options: Temporarily compensate for a bug in the handling of trace goals. compiler/add_class.m: compiler/add_clause.m: compiler/add_mode.m: compiler/add_pragma.m: compiler/add_pred.m: compiler/add_solver.m: compiler/add_type.m: compiler/field_access.m: compiler/foreign.m: compiler/make_hlds_error.m: compiler/make_hlds_passes.m: compiler/make_hlds_warn.m: compiler/module_qual.m: compiler/modules.m: compiler/qual_info.m: compiler/state_var.m: compiler/superhomogeneous.m: Make the change described at the top. In many cases, this required changing code to error util instead of io.write_strings to create the error messages. In some cases, move a predicate used in one module but defined in another module to the first module. Delete some predicates whose job used to be to test options to see whether a message should be generated, since we can now embed the option value that a message depends on in the error message itself. In module_qual.m, remove unnecessary module qualifications. In modules.m, give explicit names to a bunch of lambda expressions. Reformat comments to exploit the available columns. compiler/check_typeclass.m: Conform to the changes above. Mark with XXX the places where we are ignoring the proper update of the error count in module_infos. compiler/modes.m: compiler/post_typecheck.m: compiler/stratify.m: compiler/table_gen.m: compiler/unused_args.m: Use error_specs instead of plain pieces to print error messages. compiler/options.m: Rename an option that conflicts with a language keyword. compiler/handle_options.m: Conform to the change to options.m. compiler/prog_data.m: Rename some function symbols that conflict with language keywords. compiler/prog_out.m: compiler/prog_io_util.m: Conform the change above, and delete some predicates that have now become unused. compiler/mercury_compile.m: Rename a predicate to avoid an ambiguity. Conform to the changes above. compiler/hlds_out.m: compiler/make.module_dep_file.m: compiler/make_hlds.m: compiler/mercury_to_mercury.m: compiler/mode_errors.m: compiler/prog_io.m: Conform to the changes above. In some cases, delete predicates that aren't needed anymore. tests/invalid/errors.err_exp: tests/invalid/errors1.err_exp: tests/invalid/state_vars_test3.err_exp: tests/invalid/undef_inst.err_exp: Update this expected output to reflect the fact that we now sort the error messages. tests/invalid/missing_interface_import2.err_exp: tests/warnings/double_underscore.exp: Update this expected output to reflect the fact that we no longer print the same error message twice. tests/invalid/missing_det_decls.err_exp: Update this expected output to reflect the fact that we now indent an error messages correctly. tests/invalid/multimode_syntax.err_exp: Update this expected output to reflect the fact that we now use error_util instead of plain io.writes to create an error message. tests/invalid/typeclass_test.err_exp: tests/invalid/unsatisfiable_constraint.err_exp: Update this expected output to reflect minor improvements in the formatting of an error message. |
||
|
|
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. |
||
|
|
e35f5832d2 |
Make the get and set operations for non-constant mutables thread safe.
Estimated hours taken: 12
Branches: main
Make the get and set operations for non-constant mutables thread safe. (The
get operation for constant mutables is thread safe by definition.) The
source-to-source transformation for (non-constant) mutables is modified as
follows: we introduce four primitive operations: unsafe_get, unsafe_set, lock
and unlock. These operations are private implementation details. The first
two read and write the value of the mutable. In .par grades lock and unlock
are used to respectively acquire and release the mutex associated with the
mutable. In non .par grades they are no-ops.
The user-level mutable operations are now defined in terms of these
primitives. In particular get and set must acquire the mutable's mutex before
they can read or modify its value. (We will shortly add support for atomic
updates to mutables - defined in terms of the above primitives - as well.)
Fix intermodule inlining so that the clauses for the mutable access predicates
are written to .opt files even though they contain calls to impure predicates.
This is usually not allowed because of problems caused by reordering what were
headvar unifications in the original source file. It's okay to do this for
the mutable access predicates since we can guarantee that they won't need to
be reordered by construction.
compiler/make_hlds_passes.m:
Add declarations and implementation for: unsafe_{get,set}, lock
and unlock.
Redefine get/1, set/1, get/3 and set/3 in terms of the above
operations. In .par grades acquire the mutable's mutex before reading
or writing to it and release it afterwards.
Fill in the item_origin field for predicate declarations introduced by
the source-to-source transformation for mutables.
compiler/prog_mutable.m:
Add auxiliary predicates required by the above.
Update the description of the mutable source-to-source transformation.
compiler/prog_util.m:
Add a function: goal_list_to_conj/2. This is needed by the mutable
transformation.
compiler/add_clauses.m:
Delete the function goal_list_to_goal/2 which is identical
to goal_list_to_conj/2 but for the name.
compiler/prog_item.m:
Add an origin field to the pred_or_func item.
compiler/hlds_pred.m:
Add a new pred_marker for identifying predicates that were introduced
by the mutable source-to-source transformation.
compiler/add_pragma.m:
Fill in the item_origin field for the predicate declarations introduced
by tabling pragmas.
compiler/intermod.m:
Mutable access predicates should always be written to the .opt files
if they are referred to by an opt_exported predicate.
Remove the restriction that clauses that call impure predicates should
not be opt_exported in the case where the clause in question was
introduced by the mutable transformation. For those clauses we can
guarantee that there won't be any problems associated with reordering
(the reason given for the restriction) by construction.
Rename some variables.
compiler/prog_io.m:
Fill in the origin field for pred_or_func items.
compiler/add_pred.m:
compiler/equiv_type.m:
compiler/hlds_out.m:
compiler/inlining:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/prog_io_goal.m:
compiler/prog_io_typeclass.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/table_gen.m:
Conform to the above changes.
TODO: update reference manual to mention the new behaviour of mutables in
grades that support concurrency.
|
||
|
|
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.) |
||
|
|
2b2f3d3cbe |
This diff contains no algorithmic changes.
Estimated hours taken: 8 Branches: main This diff contains no algorithmic changes. It merely renames apart a bunch of function symbols to reduce ambiguity. Basically I went through prog_data.m, prog_item.m, hlds_data.m, hlds_goal.m and hlds_pred.m looking for type definitions containing function symbol names that were either language "keywords" (e.g. "terminates", which is an annotation on foreign_procs), used with slightly different meanings in several types (e.g. "sym"), or both (e.g. "call"). When I found such type definitions, I changed the names of the function symbols, usually by adding a prefix or suffix indicating the type to all function symbols of the type. For example, the old function symbol "foreign_proc" in type "pragma_type" is now named "pragma_foreign_proc", and the names of all other function symbols in that type also start with "pragma_". All of this should yield simpler compiler error messages when we make mistakes, and will make it more likely that looking up a function symbol using a tags file will take you to the actual definition of the relevant instance of that function symbol. However, the most important benefit is the increase in the readability of unfamiliar code; the reader won't have to emulate the compiler's type ambiguity resolution algorithm (which in many cases used to require distinguishing between f/14 and f/15 by counting the arguments, e.g. for "pred_or_func"). compiler/prog_data.m: compiler/prog_item.m: compiler/hlds_data.m: compiler/hlds_goal.m: compiler/hlds_pred.m: Rename function symbols as explained above. compiler/*.m: Conform to the function symbol renames. In some cases, rename other function symbols as well. Minor style fixes, e.g. replace if-then-elses with switches, or simple det predicates with functions. |
||
|
|
16184103d7 |
Add new documentation for the implementation of mutables.
Estimated hours taken: 1 Branches: main Add new documentation for the implementation of mutables. compiler/prog_mutable.m: Provide an up-to-date description of the source-to-source transformation used to implement mutables. compiler/prog_io.m: Delete the old description of the transformation. (This hadn't been maintained and was quite out-of-date.) Minor documentation update caused by the removal of the mutable `thread_safe' attribute. compiler/make_hlds_passes.m: Add a pointer to the new documentation in prog_mutable.m. |
||
|
|
fe65fe427e |
Get rid of the `thread_safe' mutable attribute, since this doesn't actually
Estimated hours taken: 1
Branches: main, release
Get rid of the `thread_safe' mutable attribute, since this doesn't actually
make access to a mutable thread safe (in fact it makes them less thread
safe than the `not_thread_safe' version).
By extension this also removes support for the `not_thread_safe' mutable
attribute.
compiler/prog_io.m:
compiler/prog_item.m:
compiler/prog_mutable.m:
Remove support for the `thread_safe' mutable attribute.
compiler/make_hlds_passes.m:
Remove support for the `thread_safe' mutable attribute.
Mark the foreign clauses for `get' predicates for constant
mutables as thread safe.
doc/reference_manual.texi:
Delete the documentation for the `thread_safe' mutable attribute.
tests/hard_coded/mutable_decl.m:
tests/hard_coded/pure_mutable.m:
tests/hard_coded/trace_goal_env_1.m:
tests/hard_coded/trace_goal_env_2.m:
tests/hard_coded/unusual_name_mutable.m:
tests/hard_coded/sub-modules/mutable_child.m:
tests/hard_coded/sub-modules/mutable_grandchild.m:
tests/hard_coded/sub-modules/mutable_parent.m:
tests/invalid/bad_mutable.{err_exp,m}:
tests/invalid/not_in_interface.m:
Conform to the above change.
|
||
|
|
9d23d8e2e7 |
Implement the trace goal construct we discussed, for now for the LLDS backends
Estimated hours taken: 70
Branches: main
Implement the trace goal construct we discussed, for now for the LLDS backends
only.
Since the syntax of trace goals is non-trivial, useful feedback on syntax
errors inside trace goal attributes is essential. With the previous setup, this
wasn't possible, since the code that turned terms into parse tree goals turned
*all* terms into goals; it couldn't recognize any errors, sweeping them under
the rug as calls. This diff changes that. Now, if this code recognizes a
keyword that indicates a particular construct, it insists on the rest of the
code following the syntax required for that construct, and returns error
messages if it doesn't.
We handle the trace goal attributes that specify state variables to be threaded
through the trace goal (either the I/O state or a mutable variable) in
add_clause.m, at the point at which we transform the list of items to the HLDS.
We handle the compile-time condition on trace goals in the invocation of
simplify at the end of semantics analysis, by eliminating the goal if the
compile-time condition isn't met. We handle run-time conditions on trace goals
partially in the same invocation of simplify: we transform trace goals with
runtime conditions into an if-then-else with the trace goal as the then part
and `true' as the else part, the condition being a foreign_proc that is handled
specially by the code generator, that special handling being to replace
the actual code of the foreign_proc (which is a dummy) with the evaluation of
the runtime condition.
Since these changes require significant changes to some of our key data
structures, I took the liberty of doing some renaming of function symbols
at the same time to avoid using ambiguities with respect to language keywords.
library/ops.m:
Add "trace" as an operator.
compiler/prog_data.m:
Define data types to represent the various attributes of trace goals.
Rename some function symbols to avoid ambiguities.
compiler/prog_item.m:
Extend the parse tree representation of goals with a trace goal.
compiler/mercury_to_mercury.m:
Output the new kind of goal and its components.
compiler/hlds_goal.m:
Extend the HLDS representation of scopes with a scope_reason
representing trace goals.
Add a mechanism (an extra argument in foreign_procs) to allow
the representation of goals that evaluate runtime trace conditions.
Since this requires modifying all code that traverses the HLDS,
do some renames that were long overdue: rename not as negation,
rename call as plain_call, and rename foreign_proc as
call_foreign_proc. These renames all avoid using language keywords
as function symbols.
Change the way we record goals' purities. Instead of optional features
to indicate impure or semipure, which is error-prone, use a plain
field in the goal_info, accessed in the usual way.
Add a way to represent that a goal contains a trace goal, and should
therefore be treated as if it were impure when considering whether to
optimize it away.
Reformat some comments describing function symbols.
compiler/hlds_out.m:
Output the new construct in the HLDS.
compiler/prog_io_util.m:
Generalize the maybe[123] types to allow the representation of more
than one error message. Add functions to extract the error messages.
Add a maybe4 type. Rename the function symbols of these types to
avoid massive ambiguity.
Change the order of some predicates to bring related predicates
next to each other.
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
Rework these modules almost completely to find and accumulate syntax
errors as terms are being parsed. In some cases, this allowed us to
replace "XXX this is a hack" markers with meaningful error-reporting
code.
In prog_io_goal.m, add code for parsing trace goals.
In a bunch of places, update obsolete coding practices, such as using
nested chains of closures instead of simple sequential code, and
using A0 and A to refer to values of different types (terms and goals
respectively). Use more meaningful variable names.
Break up some too-large predicates.
compiler/superhomogeneous.m:
Find and accumulate syntax errors as terms are being parsed.
compiler/add_clause.m:
Add code to transform trace goals from the parse tree to the HLDS.
This is where the IO state and mutable variable attributes of trace
goals are handled.
Eliminate the practice of using the naming scheme Body0 and Body
to refer to values of different types (prog_item.goal and hlds_goal
respectively).
Use error_util for some error messages.
library/private_builtin.m:
Add the predicates referred to by the transformation in add_clause.m.
compiler/goal_util.m:
Rename a predicate to avoid ambiguity.
compiler/typecheck.m:
Do not print error messages about missing clauses if some errors have
been detected previously.
compiler/purity.m:
Instead of just computing purity, compute (and record) also whether
a goal contains a trace goal. However, treat trace goals as pure.
compiler/mode_info.m:
Add trace goals as a reason for locking variables.
Rename some function symbols to avoid ambiguity.
compiler/modes.m:
When analyzing trace goal scopes, lock the scope's nonlocal variables
to prevent them from being further instantiated.
compiler/det_analysis.m:
Insist on the code in trace goal scopes being det or cc_multi.
compiler/det_report.m:
Generate the error message if the code in a trace goal scope isn't det
or cc_multi.
compiler/simplify.m:
At the end of the front end, eliminate trace goal scopes if their
compile-time condition is false. Transform trace goals with runtime
conditions as described at the top.
Treat goals that contain trace goals as if they were impure when
considering whether to optimize them away.
compiler/mercury_compile.m:
Tell simplify when it is being invoked at the end of the front end.
Rename a predicate to avoid ambiguity.
compiler/trace_params.m:
Provide the predicates simplify.m need to be able to evaluate the trace
goal conditions regarding trace levels.
compiler/trace.m:
compiler/trace_gen.m:
Rename the trace module as trace_gen, since "trace" is now an operator.
Rename some predicates exported by the module, now that it is no longer
possible to preface calls with "trace." as a module qualifier.
compiler/notes/compiler_design.html:
Document this name change.
compiler/options.m:
Rename the trace option as trace_level internally, since "trace"
is now an operator. The user-visible name remains the same.
Add the new --trace-flag option.
Delete an obsolete option.
compiler/handle_options.m:
Rename the function symbols of the grade_component type,
since "trace" is now an operator.
compiler/llds.m:
Extend the LLDS with a mechanism to refer to C global variables.
For now, these are used to refer to C globals that will be created
by mkinit to represent the initial values of the environment variables
referred to by trace goals.
compiler/commit_gen.m:
Check that no trace goal with a runtime condition survives to code
generation; they should have been transformed by simplify.m.
compiler/code_gen.m:
Tell commit_gen.m what kind of scope it is generating code for.
compiler/pragma_c_gen.m:
Generate code for runtime conditions when handling the foreign_procs
created by simplify.m.
compiler/code_info.m:
Allow pragma_c_gen.m to record what environment variables it has
generated references to.
compiler/proc_gen.m:
Record the set of environment variables a procedure refers to
in the LLDS procedure header, for efficient access by llds_out.m.
compiler/llds_out.m:
Handle the new LLDS construct, and tell mkinit which environment
variables need C globals created for them.
compiler/pd_util.m:
Rename some predicates to avoid ambiguity.
compiler/*.m:
Conform to the changes above, mainly the renames of function symbols
and predicates, the changed signatures of some predicates, and the new
handling of purity.
util/mkinit.c:
Generate the definitions and the initializations of any C globals
representing the initial status (set or not set) of environment
variables needed by trace goals.
library/assoc_list.m:
Add some predicates that are useful in prog_io*.m.
library/term_io.m:
Minor cleanup.
tests/hard_coded/trace_goal_{1,2}.{m,exp}:
New test cases to test the new construct, identical except for whether
the trace goal is enabled at compile time.
tests/hard_coded/trace_goal_env_{1,2}.{m,exp}:
New test cases to test the new construct, identical except for whether
the trace goal is enabled at run time.
tests/hard_coded/Mercury.options:
tests/hard_coded/Mmakefile:
Enable the new test cases.
tests/invalid/*.err_exp:
Update the expected output for the new versions of the error messages
now being generated.
|
||
|
|
c3b1c2003e |
Support constant "mutables". Though this sounds like a contradiction in terms,
Estimated hours taken: 3
Branches: main
Support constant "mutables". Though this sounds like a contradiction in terms,
they can be useful, because in some cases they are the best alternative.
- For some types, e.g. arrays, there is no way to write manifest constants.
- For some other types, one can write manifest constants, but the compiler
may be too slow in compiling clauses containing them if the constant is
very large (even after my recent improvements).
- Using a tabled zero-arity function incurs overhead on every access to check
whether the result was recorded previously or not. This is a bad idea e.g.
in the inner loop of a scanner (which may want to use an array for the
representation of the DFA).
compiler/prog_item.m:
Add a new attribute to say whether the mutable is constant or not.
compiler/prog_io.m:
Recognize the "constant" mutable attribute.
compiler/prog_mutable.m:
Provide predicates to construct the signatures of the get and set
predicates of constant mutables. Rename some existing predicates
to better reflect their purpose.
compiler/make_hlds_passes.m:
compiler/modules.m:
Modify the code for creating mutables' get, set and init predicates
to do the right thing for constant mutables.
doc/reference_manual.texi:
Document the new attribute.
tests/hard_coded/pure_mutable.{m,exp}:
Test the new attribute.
|
||
|
|
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. |
||
|
|
19159de6b7 |
Add a new goal form, as discussed on our mailing lists:
Estimated hours taken: 12
Branches: main
Add a new goal form, as discussed on our mailing lists:
promise_equivalent_solution_sets [Vars] (
arbitrary [Vars1] Goal1,
arbitrary [Vars2] Goal2,
...
)
NEWS:
Mention the new goal form.
doc/reference_manual.texi:
Document the new goal form.
library/ops.m:
Add "promise_equivalent_solution_sets" and "arbitrary" as new
operators.
compiler/prog_item.m:
Add a parse_tree representation of new constructs.
Change the representation of goal forms in the parse tree to avoid
using punctuation marks as function symbols, to avoid function symbols
that need quoting, and to avoid ambiguity with hlds_goal_expr.
Delete the obsolete if_then (no else) goal form.
compiler/hlds_goal.m:
Provide a HLDS representation of the new constructs.
compiler/det_analysis.m:
Implement the rules for processing the new constructs.
compiler/det_report.m:
Implement the messages for the errors that can occur with the
new constructs.
Add quotes around `promise_equivalent_solutions' in an existing error
message, for consistency.
compiler/prog_io_goal.m:
Parse the new goal constructs.
compiler/add_clause.m:
compiler/hlds_out.m:
compiler/make_hlds_passes.m:
compiler/make_hlds_warn.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/pd_util.m:
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_util.m:
compiler/saved_vars.m:
compiler/simplify.m:
Conform to the changes to prog_item.m and hlds_goal.m.
tests/hard_coded/one_member.{m,exp}:
New test case to test the proper functioning of the new construct.
tests/invalid/one_member.{m,err_exp}:
New test case to test the kinds of errors that can occur when using
the new construct.
tests/hard_coded/Mmakefile:
tests/invalid/Mmakefile:
Enable the new test cases.
tests/invalid/promise_equivalent_solutions_test.err_exp:
Expect quotes around an old construct name, after the change to
det_report.m.
|
||
|
|
007ca75f87 |
Fix a bug with solver types and mutables that was causing the compiler to
Estimated hours taken: 6 Branches: main Fix a bug with solver types and mutables that was causing the compiler to abort in deep profiling grades (The HLDS was incorrect in all grades, it just didn't show in most of them). The bug occurred when a mutable was initialised with a non-ground value, as in the following example derived from Ralph's sat solver: :- mutable(global, sat_literal, _, any, [untrailed]). (sat_literal is some solver type). The problem was that when adding the clauses for the mutable initialisation predicates to the HLDS we did not consider that the initial value might be a variable, as in this case, and attached an empty varset to the clause instead of one containing the variable. For the intialisation predicate for the above mutable, we have the following at stage 197: msat.initialise_mutable_global :- msat.'__Initialise__'(V_1), impure msat.set_global(V_1). The prog_varset is (incorrectly) empty at this point - it should contain V_1. Deep profiling, stage 205, now comes along and starts allocating fresh variables. The results pretty much speak for themselves ;-) msat.initialise_mutable_global :- ProcStaticLayout = deep_profiling_proc_layout(...), impure det_call_port_code_sr(ProcStaticLayout, TopCSD, MiddleCSD, ActivationPtr), SiteNum = 0, impure prepare_for_normal_call(SiteNum), msat.'__Initialise__'(TopCSD), % *** should be V_1 SiteNum = 1, impure prepare_for_normal_call(SiteNum), impure msat.set_global(TopCSD), % *** should be V_1 impure det_exit_port_code_sr(TopCSD, MiddleCSD, ActivationPtr). The fix is to attach the varset we use at parse time to the mutable items and when adding the clauses for the mutable initialisation predicate to the HLDS, to use that varset instead of an empty one. compiler/prog_item.m: compiler/prog_io.m: Attach the varset to the mutable item, in case the initial value term has a non-ground value. compiler/make_hlds_passes.m: Use the above varset when constructing the clauses for the mutable initialisation predicates in order to avoid the bug outlined above. compiler/equiv_type.m: compiler/mercury_to_mercury.m: compiler/module_qual.m: compiler/modules.m: compiler/recompilation.check.m: compiler/recompilation.version.m: Conform to the above changes to the mutable item. tests/valid/Mmakefile: tests/valid/solver_type_mutable_bug.m: Test case for the above derived from msat.m by Ralph. |
||
|
|
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. |
||
|
|
45fdb6c451 |
Use expect/3 in place of require/2 throughout most of the
Estimated hours taken: 4 Branches: main compiler/*.m: Use expect/3 in place of require/2 throughout most of the compiler. Use unexpected/2 (or sorry/2) in place of error/1 in more places. Fix more dodgy assertion error messages. s/map(prog_var, mer_type)/vartypes/ where the latter is meant. |
||
|
|
a8d3e06db7 |
Add support for `constraint_store is mutable(...)' or
Estimated hours taken: 3 Branches: main Add support for `constraint_store is mutable(...)' or `constraint_store is [mutable(...), ...]' attributes on solver type definitions. compiler/equiv_type.m: compiler/equiv_type_hlds.m: compiler/module_qual.m: compiler/prog_data.m: The solver_type_details structure now contains the list of mutable declatations given in the constraint_store attribute (empty if this attribute was not provided). compiler/make_hlds_passes.m: Process the constraint_store mutable items for solver types. compiler/mercury_to_mercury.m: Output the constraint_store attribute value for solver types if present. compiler/prog_io.m: Parse the new attribute. doc/reference_manual.texi: Document the addition of constraint_store solver type attributes. |
||
|
|
2a477fb7e7 |
Split the parse tree (currently defined in prog_data.m) into two
Estimated hours taken: 3.5 Branches: main Split the parse tree (currently defined in prog_data.m) into two separate modules. The reason for doing this is that while over 80% of the modules in the compiler import prog_data, very few of them actually require access to the types that define the parse tree (principally the item type). At the moment even small changes to these types can result in recompiles that rebuild almost all of the compiler. This change shifts the item type (and related types) into a new module, prog_item, that is only imported where these types are required (mostly at the frontend of the compiler). This should reduce the size of recompiles required when the parse tree is modified. This diff does not change any algorithms; it just shifts things around. compiler/prog_data.m: Move the item type and any related types that are not needed after the HLDS has been built to the new prog_item module. Fix bitrot in comments. Fix formatting and layout of comments. Use unexpected/2 in place of error/1 in a spot. compiler/prog_item.m: New file. This module contains any parts of the parse tree that are not needed by the rest of the compiler after the HLDS has been built. compiler/check_typeclass.m: s/list(instance_method)/instance_methods/ compiler/equiv_type.m: compiler/hlds_module.m: compiler/intermod.m: compiler/make.module_dep_file.m: compiler/make_hlds.m: compiler/mercury_compile.m: compiler/mercury_to_mercury.m: compiler/module_qual.m: compiler/modules.m: compiler/parse_tree.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_out.m: compiler/prog_util.m: compiler/recompilation.check.m: compiler/recompilation.usage.m: compiler/recompilation.version.m: compiler/trans_opt.m: Conform to the above changes. compiler/notes/compiler_design.html: Mention the new module. |
||
|
|
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.
|
||
|
|
b2012c0c0e |
Rename the types 'type', 'inst' and 'mode' to 'mer_type', 'mer_inst'
Estimated hours taken: 8 Branches: main compiler/*.m: Rename the types 'type', 'inst' and 'mode' to 'mer_type', 'mer_inst' and 'mer_mode'. This is to avoid the need to parenthesize these type names in some contexts, and to prepare for the possibility of a parser that considers those words to be reserved words. Rename some other uses of those names (e.g. as item types in recompilation.m). Delete some redundant synonyms (prog_type, mercury_type) for mer_type. Change some type names (e.g. mlds__type) and predicate names (e.g. deforest__goal) to make them unique even without module qualification. Rename the function symbols (e.g. pure, &) that need to be renamed to avoid the need to parenthesize them. Make their replacement names more expressive. Convert some more modules to four space indentation. Avoid excessively long lines, such as those resulting from the automatic substitution of 'mer_type' for 'type'. |
||
|
|
d7554de953 |
Convert a bunch more modules to four-space indentation.
Estimated hours taken: 5 Branches: main browser/*.m: compiler/*.m: mdbcomp/*.m: Convert a bunch more modules to four-space indentation. |
||
|
|
192a58021b |
Add optional support for generating a pure interface to mutables.
Estimated hours taken: 8 Branches: main Add optional support for generating a pure interface to mutables. This is done by adding a new mutable attribute, `attach_to_io_state'. If this attribute is specified in the mutable declaration then in addition to the usual non-pure access predicates, the compiler will also add a pair of access predicates that take the IO state. compiler/prog_data.m: Add the `attach_to_io_state' mutable attribute. Add the necessary access predicates for the mutable_var_attributes structure. compiler/prog_io.m: Parse the `attach_to_io_state' attribute. compiler/prog_mutable.m: Shift some of the code for constructing items related to mutables to this module from make_hlds_passes. This reduces unnecessary clutter in the latter. Remove the XXX comment about needing to mangle the names of the globals - we now do that. compiler/make_hlds_passes.m: If a mutable has the `attach_to_io_state' attribute specified then create pure access predicates that take the IO state in addition to the non-pure ones. compiler/modules.m: If we are generating the pure access predicates then output the declarations for these predicates in private interfaces. compiler/type_util.m: Replace the use of ':' as a module qualifier in some comments. doc/reference_manual.texi: Document the `attach_to_io_state' mutable attribute. vim/syntax/mercury.vim: Highlight various mutable attributes appropriately. tests/hard_coded/Mmakefile: tests/hard_coded/pure_mutable.m: tests/hard_coded/pure_mutable.exp: Test mutables with pure access predicates. tests/hard_coded/ppc_bug.m: Unrelated change: update the comments in this test case so they describe what the cause of the bug and the fix were. |