Estimated hours taken: 4
Branches: main
Various cleanups for the modules in the compiler directory. The are
no changes to algorithms except the replacement of some if-then-elses
that would naturally be switches with switches and the replacement of
most of the calls to error/1.
compiler/*.m:
Convert calls to error/1 to calls to unexpected/2 or sorry/2 as
appropriate throughout most or the compiler.
Fix inaccurate assertion failure messages, e.g. identifying the
assertion failure as taking place in the wrong module.
Add :- end_module declarations.
Fix formatting problems and bring the positioning of comments
into line with our current coding standards.
Fix some overlong lines.
Convert some more modules to 4-space indentation. Fix some spots
where previous conversions to 4-space indentation have stuffed
the formatting of the code up.
Fix a bunch of typos in comments.
Use state variables in more places; use library predicates
from the sv* modules where appropriate.
Delete unnecessary and duplicate module imports.
Misc. other small cleanups.
Estimated hours taken: 3
Branches: main
compiler/*.m:
Import only one module per line in the modules of the compiler
where my previous diff did not already do so.
Misc other cleanups.
Where relevant, use the new mechanism in tree.m.
compiler/tree.m:
Fix a performance problem I noticed while update :- import_module
items. Instead of supplying a function to convert lists of trees
to a tree, make the tree data structure able to hold a list of
subtrees directly. This reduces the number of times where we have to
convert list of trees to trees that are sticks just to stay within
the old definition of what a tree is.
Estimated hours taken: 4
Branches: main
Reduce the dependence of earlier parts of the compiler on the later ones.
Unnecessary import_module declarations in top level modules such as hlds.m
cause unnecessary recompilations when adding new types in later modules,
such as submodules of ll_backend.m. This change reduces the number of such
unnecessary imports.
There are no changes in algorithms, only functionality being moved around.
compiler/code_model.m:
Change this module from being a submodule of backend_libs.m to being a
submodule of hlds.m, since nothing in it is dependent on any backend.
compiler/arg_info.m:
compiler/code_util.m:
Change arg_info.m from being a submodule of ll_backend.m to being a
submodule of hlds.m, since most of it is applicable to all current
and foreseeable backends. Move the one exported predicate that is
ll_backend dependent, and its support predicates, to code_util.m.
compiler/backend_libs.m:
compiler/ll_backend.m:
compiler/hlds.m:
Update include_module declarations in accordance with the above.
compiler/prog_data.m:
compiler/term_util.m:
Instead of defining two separate types for holding argument size and
termination information, one including HLDS-specific information (in
term_util.m) and one not (in prog_data.m), use a polymorphic type
defined in prog_data.m and two monomorphic instances.
compiler/termination.m:
compiler/mercury_to_mercury.m:
Change the predicates for writing out argument size and termination
information to handle the polymorphic type (we don't need special
handling of the monomorphic versions), and move them from termination.m
to mercury_to_mercury.m, since this allows us to avoid some
undesirable dependencies.
compiler/base_typeclass_info.m:
compiler/hlds_code_util.m:
Move the predicate make_instance_string from base_typeclass_info.m
to hlds_code_util.m, again because it allows us to remove some
undesirable dependencies.
compiler/top_level.m:
compiler/backend_libs.m:
compiler/check_hlds.m:
compiler/hlds.m:
compiler/ll_backend.m:
compiler/parse_tree.m:
compiler/transform_hlds.m:
Delete some import_module declarations of other top level modules
in these top level modules. Some imports were totally unnecessary.
Some imports were useful in only a small minority of submodules;
those submodules now import the necessary top level modules directly.
Move remaining import_module declarations to the implementation section
where this is feasible.
Where we still need to import modules we ideally shouldn't, note why.
compiler/*.m:
Update imports of code_util and arg_info.
In some cases, import top level modules no longer imported by the
parent module.
In some cases, delete unnecessary imports.
Estimated hours taken: 2
Branches: main
compiler/*.m:
Import only one compiler module per line. Sort the blocks of imports.
This makes it easier to merge in changes.
In a couple of places, remove unnecessary imports.
The main aim of this change is to make the overall, high-level structure
of the compiler clearer, and to encourage better encapsulation of the
major components.
compiler/libs.m:
compiler/backend_libs.m:
compiler/parse_tree.m:
compiler/hlds.m:
compiler/check_hlds.m:
compiler/transform_hlds.m:
compiler/bytecode_backend.m:
compiler/aditi_backend.m:
compiler/ml_backend.m:
compiler/ll_backend.m:
compiler/top_level.m:
New files. One module for each of the major components of the
Mercury compiler. These modules contain (as separate sub-modules)
all the other modules in the Mercury compiler, except gcc.m and
mlds_to_gcc.m.
Mmakefile:
compiler/Mmakefile:
Handle the fact that the top-level module is now `top_level',
not `mercury_compile' (since `mercury_compile' is a sub-module
of `top_level').
compiler/Mmakefile:
Update settings of *FLAGS-<modulename> to use the appropriate
nested module names.
compiler/recompilation_check.m:
compiler/recompilation_version.m:
compiler/recompilation_usage.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/recompilation.version.m:
Convert the `recompilation_*' modules into sub-modules of the
`recompilation' module.
compiler/*.m:
compiler/*.pp:
Module-qualify the module names in `:- module', `:- import_module',
and `:- use_module' declarations.
compiler/base_type_info.m:
compiler/base_type_layout.m:
Deleted these unused empty modules.
compiler/prog_data.m:
compiler/globals.m:
Move the `foreign_language' type from prog_data to globals.
compiler/mlds.m:
compiler/ml_util.m:
compiler/mlds_to_il.m:
Import `globals', for `foreign_language'.
Mmake.common.in:
trace/Mmakefile:
runtime/Mmakefile:
Rename the %.check.c targets as %.check_hdr.c,
to avoid conflicts with compiler/recompilation.check.c.
Estimated hours taken: 2
Branches: main
mlds_to_il.m:
Wrap an exception handler around main. This avoids those annoying
pop up windows, and hence allows people to use windows machines via
ssh.
tree.m:
Add the higher order function map.
Estimated hours taken: 0.3
compiler/tree.m:
Add a functional version of tree__flatten.
Add tree__list, which creates trees from lists of trees.
(using list syntax is much more readable than creating lots of
branching trees).
Estimated hours taken: 0.5
Most of the uses of the type `tree:tree/1' are lists of instructions.
`tree__is_empty' is used to ask "was any code generated", but
`tree__is_empty' fails for `node([])'. This has not been a problem
in the past because the code generator builds up a trees of lists that
are known to be non-empty. Parts of the RL generation code can create
empty lists of instructions, and it can't hurt to test for this
case elsewhere.
compiler/tree.m:
Added `tree__tree_of_lists_is_empty', which is similar to
`tree__is_empty' except that `node([])' is also considered empty.
compiler/lookup_switch.m:
compiler/rl_gen.m:
Use `tree__tree_of_lists_is_empty' instead of `tree__is_empty'.
Estimated hours taken: 0.75
library/*.m:
compiler/*.m:
Undo Zoltan's bogus update of all the copyright dates.
The dates in the copyright header should reflect the years
in which the file was modified (and no, changes to the
copyright header itself don't count as modifications).
Estimated hours taken: 5
Remove support for term_to_type and type_to_term implemented as special
preds. Remove support for one-cell and one-or-two-cell type_infos (now
shared-one-or-two-cell type_infos). Move definitions that were in
mercury_builtin.m back to where they belong.
This code has been removed because it is no longer used, and was no
longer being maintained but was still quite complex.
compiler/globals.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/options.m:
Remove one_cell and one_or_two_cell from type_info methods.
compiler/polymorphism.m:
Remove term_to_type and type_to_term support.
Remove one_cell and one_or_two_cell from type_info methods.
Fix documentation to reflect the new situation.
compiler/special_pred.m:
compiler/unify_proc.m:
Remove term_to_type and type_to_term support.
library/list.m:
Put the definition of `list' back into list.m
library/mercury_builtin.m:
Take the definitions of `list', `term', `var', `var__supply',
etc, out of this module.
Remove type_to_term, term_to_type, det_term_to_type,
term__init_var_supply, term__create_var, term__var_to_int
and term__context_init.
Remove references to USE_TYPE_TO_TERM and #ifdefs around
SHARED_ONE_OR_TWO_CELL_TYPE_INFO.
library/std_util.m:
Remove references ONE_OR_TWO_CELL_TYPE_INFO, and code that
handles one-cell typeinfo comparisons.
library/term.m:
Add type_to_term, term_to_type, det_term_to_type,
term__init_var_supply, term__create_var, term__var_to_int
and term__context_init back to term.m.
Add new implementation of type_to_term/2.
library/uniq_array.m:
Fix a typo in a comment - term_to_type/3 instead of term_to_type/2.
runtime/call.mod:
Remove special case code for unify, compare, index for
one-cell typeinfos.
Remove code for type_to_term/2.
runtime/type_info.h:
Remove references to ONE_CELL_TYPE_INFO or ONE_OR_TWO_CELL_TYPE_INFO.
Make sure only SHARED_ONE_OR_TWO_CELL_TYPE_INFO.
Remove references to USE_TYPE_TO_TERM.
compiler/base_type_layout.m:
compiler/bytecode_gen.m:
compiler/code_util.m:
compiler/delay_slot.m:
compiler/det_util.m:
compiler/fact_table.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/mode_debug.m:
compiler/tree.m:
library/bag.m:
library/queue.m:
Import module `list' or `term' (or both).
Estimated hours taken: 0.25
disj_gen:
Remove redundant code.
liveness:
Trap some unreachable code.
lookup_switch, tree:
Move the code for testing code trees for emptyness to tree.m.
compiler/*:
Add copyright messages.
Change all occurences of *.nl in comments to *.m.
compiler/mercury_compile.pp:
Change the output to the .dep files to use *.m rather than *.nl.
(NOTE: this means that `mmake' will not work any more if you
call your files *.nl!!!)
Lots of bug fixes for make_hlds.nl.
A couple of bug fixes for hlds.nl.
Did some optimization of memory usage: added io__gc_call to io.nl
and used it in prog_io.nl and module.nl. Rewrote the main loop
of prog_io to take maximum advantage of manual garbage collection.
Started working on typecheck.nl.