compiler/file_names.m:
Document the meaning of the maybe_create_dirs and maybe_search types.
Delete long-obsolete references to .il files.
compiler/make.util.m:
Rename make_remove_target_file to remove_make_target_file, since this
predicate removes target files in Makefiles, and does not "make" anything.
Rename several other predicates in a similar manner, for the same reason.
Add an extra argument to get_file_name and some related predicates
that will allow future conditionally-enabled trace goals in the compiler
to track where the requests for file name translations come from.
compiler/write_deps_file.m:
Factor out some code.
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changes above.
tools/file_name_translation_stats:
Allow for large numbers of file name translations.
compiler/parse_tree_out_cons_id.m:
Move the predicates and functions in prog_out.m that deal with cons_ids
to this module.
compiler/parse_tree_out_sym_name.m:
Move the predicates and functions in prog_out.m that deal with sym_names
and similar entities to this module.
compiler/parse_tree_out_type.m:
Move the predicates and functions in prog_out.m that deal with types
to this module.
compiler/parse_tree_out_misc.m:
Move the predicates and functions in prog_out.m that deal with simple
types to this module.
Delete mercury_output_det and mercury_format_det, replacing all their
uses with calls to mercury_det_to_string.
compiler/prog_out.m:
Delete this module.
compiler/parse_tree.m:
Delete prog_out from the parse_tree package.
compiler/Mercury.options:
compiler/notes/compiler_design.html:
Delete references to prog_out.m.
compiler/*.m:
Update imports and any explicit module qualifications to account
for the moved code.
tools/filter_sort_imports:
Automatically filter out any repeated imports. This can help with
changes like this that redistribute the contents of one module to other
modules. In this case, after a global replacement of prog_out's import
with the import of parse_tree_out_misc, this updated script could
remove this changed import from modules that already imported
parse_tree_out_misc.
Building programs with --intermodule-optimization fails when using a library
containing submodules that was *not* installed with --intermodule-optimization
enabled. This is because the compiler is trying to find the .int0 files for the
library, but these are only installed when the library is built with
--intermodule-optimization enabled. The fix is to always install any .int0
files for a library.
compiler/make.program_target.m:
compiler/write_deps_file.m:
Always install the .int0 files for libraries.
When writing out dependency files, the compiler would call
module_name_to_file_name often for the same pairs of module name and
file extension. Caching the results of those calls saves on
constructing temporary strings.
This change reduces the time to make dependencies in the compiler
directory from 2.40 seconds to 2.15 seconds on my machine.
compiler/write_deps_file.m:
Add a predicate make_module_file_name that caches calls to
module_name_to_file_name.
Thread the cache map through the predicates in this module.
Replace calls to module_name_to_file_name with calls to
make_module_file_name when appropriate.
This reduces the time to make dependencies in the compiler directory
from 5.85 seconds to 3.60 seconds on my machine.
compiler/write_deps_file.m:
Use set.list_to_set instead of calling set.insert in a loop.
Evaluating the .classes variable in a Mmakefile can be quite slow.
We can speed up mmake invocations by assigning the variable to an
empty value unless we are targeting Java.
On my machine, a call to mmake in an up-to-date compiler directory
now takes about 0.4 seconds, down from 1.2 seconds.
compiler/write_deps_file.m:
As above.
This option lets the user provide a file containing information to
remove some edges from the trans-opt dependency graph, i.e. the graph
used to determine which .trans_opt files to read when making a module's
own .trans_opt file.
The reason to remove edges from the graph is to break dependency cycles.
.trans_opt files for modules within an SCC have to be made one after
another, instead of in parallel. For example, the standard library
contains one large SCC due to circular imports, so making .trans_opt
files turns out to be a bottleneck when building the standard library
(on a machine with sufficient parallelism available).
Furthermore, the user had no control over which modules in an SCC
could read the .trans_opt files of other modules in the same SCC.
If a and b happened to import each other, the compiler would always
break the cycle by allowing a to read b.trans_opt, but not allow b to
read a.trans_opt, simply based on module names. The new option lets the
user break the cycle in a way that may improve analysis results.
compiler/options.m:
Add the --trans-opt-deps-spec option.
compiler/generate_dep_d_files.m:
If the option --trans-opt-deps-spec FILE is used, use the
information given in the file to remove some edges from the
trans-opt dependency graph.
If --generate-module-order is passed, also output the module order
computed from the trans-opt dependency graph to a file.
Users may find this a useful starting point when writing their own
spec file.
compiler/write_deps_file.m:
Add a field to intermod_deps to hold the (user-adjusted)
trans-opt dependencies.
Add a type, maybe_include_trans_opt_rule, to indicate whether or not
to include a trans_opt_deps rule in a mmake dependency file.
Separate the case when a trans_opt_deps rule is to be written,
indicating where the dependencies come from.
When automatically rewriting a .d file after producing target code,
etc., write the trans_opt_deps rule with the same list of dependencies
as the old .d file.
compiler/mercury_compile_make_hlds.m:
Conform to maybe_include_trans_opt_rule change.
Rename some variables for clarity.
library/term.m:
library/term_context.m:
As above.
Rename the term.context type as term_context.term_context, with
term.context now being defined as an equivalence type.
Replace the context_init function and predicate and the dummy_context_init
function with just one function: dummy_context. This name includes
the important part (the fact that it return a *dummy* context) and deletes
the nonimportant part (dummy contexts are just about never updated,
so the function does not really "initialize" them).
Reduce function/predicate pairs that do the same thing to just a function.
library/MODULES_DOC:
library/library.m:
Add the new module to the list of standard library modules.
NEWS:
Mention the new module, and the obsoleting of the moved predicates
and functions in term.m.
compiler/*.m:
library/*.m:
Conform to the changes above.
... and bundle sets of error kinds and their associated lists of error_specs
into a single structure.
compiler/parse_error.m:
Use separate types to represent fatal errors and nonfatal errors,
because those two kinds of errors are often treated differently.
Change the read_module_errors type, which used to be just a set of errors,
to being a set of fatal errors, a set of nonfatal errors, the error
message for each, and error messages for warnings. This preserves
distinctions that we should be able to use in the future to improve
error handling.
Provide utility routines for operating on this now-structured type.
compiler/parse_types.m:
Change the definition of the item_or_marker type slighly to preserve
distinctions that the read_module_errors type now cares about.
compiler/parse_module.m:
Thread the new read_module_errors structure through the predicates
that parse source, interface and optimization files.
Treat the failure of reading the contents of a file as a fatal error.
Previously, we treated it as a nonfatal error.
Delete some fields from types when those field were always set to the
same value, and therefore contained no useful information.
compiler/module_baggage.m:
Switch to using the new read_module_errors structure in module baggage.
compiler/grab_modules.m:
Conform to the changes above.
Use a bespoke type to represent the absence/presence of errors
when reading in optimization files.
compiler/mercury_compile_make_hlds.m:
Conform to the changes above.
Delete a call to pre_hlds_write_out_errors that duplicates
another call a few lines above.
compiler/deps_map.m:
compiler/generate_dep_d_files.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile_main.m:
compiler/parse_item.m:
compiler/parse_pragma.m:
compiler/parse_type_defn.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
Since this is the first converted module that dumps out goals when
debugging trace flags are enabled, this required generalizing the code
that does that, to take either varsets or var_tables as a means of
specifying the names of variables. We do this via a new type,
var_name_source, which contains either a varset or a var_table.
Almost all of this diff is there to implement this generalization.
A large part of it affects code in the parse_tree package that we use
to write out the parts of HLDS goals that are defined by types defined
in that package. Since we want to avoid making any part of the parse_tree
package dependent on the hlds package, this required defining the
var_name_source type in the parse_tree package, which in turn requires
var_table.m to be in that same package.
compiler/lco.m:
Convert this module to use var_tables instead of varsets and vartypes.
compiler/var_table.m:
Move this module from the hlds package to the parse_tree package.
To make this, possible, move the parts that required access to the HLDS
to hlds_pred.m, from where it was usually invoked.
Export some utility predicates to allow the moved code to work
in hlds_pred.m without access to the actual definition of the
var_table type.
Define the var_name_source type.
Add some utility functions for use by code writing out variable names.
compiler/hlds_pred.m:
Add the code moved from var_table.m.
compiler/vartypes.m:
Move this module from the hlds package to the parse_tree package,
for symmetry with var_table.m. It did not depend on being in hlds
in any way.
compiler/hlds.m:
compiler/parse_tree.m:
Move vartypes.m and var_table.m from the hlds package
to the parse_tree package.
compiler/hlds_out_goal.m:
Change all the predicates in this module to take a var_name_source
instead of a prog_varset.
Fix some comments.
compiler/hlds_out_util.m:
Change some of the predicates in this module (those called from
hlds_out_goal.m) to take a var_name_source instead of a prog_varset.
compiler/parse_tree_out_term.m:
Provide variants of some existing predicates and functions that take
var_name_sources instead of varsets. The code of the copies
duplicates the logic of the originals, though I hope that this
duplication can be done away with at the end of the transition.
(The best solution would be to use a typeclass with methods
that convert vars to their names, but we would want to ensure
that the compiler can specialize all the affected predicates
and functions to the two instances of this typeclass, which is
something that we cannot do yet. In the meantime, the lack of
any generalization in the old versions preserves their performance.)
tools/sort_imports:
tools/filter_sort_imports:
A new tool that automatically sorts any occurrences of consecutive
":- import_module" declarations in the named files. The sorting is done
in filter_sort_imports; sort_imports loops over the named files.
After automatically replacing all occurrences of hlds.{vartypes,var_table}
in import_module declarations with their parse_tree versions, the updated
import_module declarations were usually out of order with respect to
their neighbours. I used this script to fix that, and some earlier
out-of-order imports.
compiler/accumulator.m:
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_heap_ops.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_trail_ops.m:
compiler/analysis.m:
compiler/arg_info.m:
compiler/build_mode_constraints.m:
compiler/bytecode_gen.m:
compiler/call_gen.m:
compiler/check_promise.m:
compiler/closure_analysis.m:
compiler/closure_gen.m:
compiler/code_info.m:
compiler/code_loc_dep.m:
compiler/common.m:
compiler/compile_target_code.m:
compiler/complexity.m:
compiler/const_prop.m:
compiler/constraint.m:
compiler/continuation_info.m:
compiler/convert_parse_tree.m:
compiler/coverage_profiling.m:
compiler/cse_detection.m:
compiler/ctgc.datastruct.m:
compiler/ctgc.util.m:
compiler/dead_proc_elim.m:
compiler/deep_profiling.m:
compiler/deforest.m:
compiler/delay_construct.m:
compiler/delay_partial_inst.m:
compiler/dep_par_conj.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/det_util.m:
compiler/direct_arg_in_out.m:
compiler/disj_gen.m:
compiler/distance_granularity.m:
compiler/equiv_type_hlds.m:
compiler/exception_analysis.m:
compiler/file_names.m:
compiler/float_regs.m:
compiler/follow_vars.m:
compiler/format_call.m:
compiler/generate_dep_d_files.m:
compiler/get_dependencies.m:
compiler/goal_expr_to_goal.m:
compiler/goal_mode.m:
compiler/goal_path.m:
compiler/goal_store.m:
compiler/goal_util.m:
compiler/granularity.m:
compiler/hhf.m:
compiler/higher_order.m:
compiler/hlds_clauses.m:
compiler/hlds_code_util.m:
compiler/hlds_error_util.m:
compiler/hlds_goal.m:
compiler/hlds_llds.m:
compiler/hlds_out_pred.m:
compiler/hlds_rtti.m:
compiler/hlds_statistics.m:
compiler/inlining.m:
compiler/inst_check.m:
compiler/inst_test.m:
compiler/inst_user.m:
compiler/instance_method_clauses.m:
compiler/instmap.m:
compiler/intermod.m:
compiler/intermod_analysis.m:
compiler/interval.m:
compiler/introduce_exists_casts.m:
compiler/introduce_parallelism.m:
compiler/item_util.m:
compiler/lambda.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/llds.m:
compiler/llds_out_data.m:
compiler/llds_out_file.m:
compiler/llds_out_util.m:
compiler/lookup_switch.m:
compiler/loop_inv.m:
compiler/make.module_target.m:
compiler/make.util.m:
compiler/make_goal.m:
compiler/make_hlds_separate_items.m:
compiler/make_hlds_types.m:
compiler/mark_tail_calls.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/middle_rec.m:
compiler/ml_accurate_gc.m:
compiler/ml_args_util.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_commit_gen.m:
compiler/ml_disj_gen.m:
compiler/ml_foreign_proc_gen.m:
compiler/ml_gen_info.m:
compiler/ml_lookup_switch.m:
compiler/ml_proc_gen.m:
compiler/ml_simplify_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tag_switch.m:
compiler/ml_unify_gen.m:
compiler/ml_unify_gen_construct.m:
compiler/ml_unify_gen_deconstruct.m:
compiler/ml_unify_gen_test.m:
compiler/ml_unify_gen_util.m:
compiler/mlds_to_c_data.m:
compiler/mlds_to_c_func.m:
compiler/mlds_to_c_global.m:
compiler/mlds_to_cs_class.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_data.m:
compiler/mlds_to_java_file.m:
compiler/mlds_to_java_stmt.m:
compiler/mlds_to_java_type.m:
compiler/mmc_analysis.m:
compiler/mode_comparison.m:
compiler/mode_constraints.m:
compiler/mode_debug.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/mode_ordering.m:
compiler/modecheck_call.m:
compiler/modecheck_coerce.m:
compiler/modecheck_goal.m:
compiler/modecheck_unify.m:
compiler/modecheck_util.m:
compiler/modes.m:
compiler/module_cmds.m:
compiler/old_type_constraints.m:
compiler/opt_debug.m:
compiler/optimize.m:
compiler/options_file.m:
compiler/ordering_mode_constraints.m:
compiler/par_loop_control.m:
compiler/parse_item.m:
compiler/parse_string_format.m:
compiler/parse_tree_out_inst.m:
compiler/parse_tree_to_term.m:
compiler/parse_util.m:
compiler/pd_debug.m:
compiler/pd_info.m:
compiler/pd_util.m:
compiler/peephole.m:
compiler/polymorphism.m:
compiler/polymorphism_info.m:
compiler/polymorphism_lambda.m:
compiler/polymorphism_type_class_info.m:
compiler/polymorphism_type_info.m:
compiler/post_typecheck.m:
compiler/pragma_c_gen.m:
compiler/pred_name.m:
compiler/pred_table.m:
compiler/prog_item.m:
compiler/prog_rep.m:
compiler/prop_mode_constraints.m:
compiler/purity.m:
compiler/push_goals_together.m:
compiler/qual_info.m:
compiler/quantification.m:
compiler/rbmm.execution_path.m:
compiler/rbmm.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.points_to_graph.m:
compiler/rbmm.points_to_info.m:
compiler/rbmm.region_resurrection_renaming.m:
compiler/rbmm.region_transformation.m:
compiler/recompilation.used_file.m:
compiler/recompilation.version.m:
compiler/recompute_instmap_deltas.m:
compiler/resolve_unify_functor.m:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/saved_vars.m:
compiler/set_of_var.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_conj.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/simplify_goal_scope.m:
compiler/simplify_goal_switch.m:
compiler/simplify_goal_unify.m:
compiler/simplify_info.m:
compiler/simplify_proc.m:
compiler/size_prof.m:
compiler/smm_common.m:
compiler/ssdebug.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/stack_opt.m:
compiler/stm_expand.m:
compiler/store_alloc.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.domain.m:
compiler/structure_reuse.indirect.m:
compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
compiler/superhomogeneous.m:
compiler/switch_detection.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/tabling_analysis.m:
compiler/term_constr_build.m:
compiler/term_constr_data.m:
compiler/term_constr_initial.m:
compiler/term_constr_main.m:
compiler/term_constr_main_types.m:
compiler/term_constr_util.m:
compiler/term_pass1.m:
compiler/term_traversal.m:
compiler/term_util.m:
compiler/trace_gen.m:
compiler/trailing_analysis.m:
compiler/transform_llds.m:
compiler/try_expand.m:
compiler/tupling.m:
compiler/type_assign.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/typecheck_debug.m:
compiler/typecheck_errors.m:
compiler/typecheck_info.m:
compiler/unify_gen_construct.m:
compiler/unify_gen_deconstruct.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
compiler/unneeded_code.m:
compiler/untupling.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/var_locn.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
compiler/module_baggage.m:
This reflects the changes to this module over the last year.
compiler/parse_tree.m:
Change the module name in the include_module declaration.
compiler/deps_map.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/mercury_compile_main.m:
compiler/module_dep_info.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/recompilation.used_file.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Change the module name in import_module declarations.
compiler/notes/compiler_design.html:
Change the module name in the module description.
library/io.file.m:
library/io.m:
Move two sections of io.m, the "file handling predicates" section
and the "handling temporary files" section to the new submodule io.file.m.
Leave behind in io.m "forwarding predicates", predicates that do nothing
except call the moved predicates in io.file.m, to provide backward
compatibility. But do mark the forwarding predicates as obsolete,
to tell people to update their (at their leisure, since the obsoleteness
warning can be turned off).
Also leave behind in io.m the definitions of the two types used
by some parameters of some of the moved predicates. Document the reason
why this is done.
library/MODULES_DOC:
List the new module among the documented modules.
NEWS:
Announce the changes.
browser/browse.m:
browser/interactive_query.m:
browser/listing.m:
compiler/analysis.file.m:
compiler/compile_target_code.m:
compiler/export.m:
compiler/fact_table.m:
compiler/file_util.m:
compiler/handle_options.m:
compiler/make.build.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/mercury_compile_main.m:
compiler/module_cmds.m:
compiler/parse_module.m:
compiler/passes_aux.m:
compiler/prog_event.m:
compiler/recompilation.check.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
deep_profiler/conf.m:
deep_profiler/mdprof_cgi.m:
library/dir.m:
mdbcomp/program_representation.m:
ssdb/ssdb.m:
Call the file operation predicates directly in io.file.m, not indirectly
through io.m.
In two modules, add a #include of fcntl.h in C code. These modules contain
C code that needs this #include, but until now, they got it via a copy
in an automatically generated C header file of a foreign_decl pragma
in io.m that contained that #include. This diff moves that foreign_decl
to io.file.m, removing that crutch.
tests/debugger/browser_test.m:
tests/hard_coded/bit_buffer_test.m:
tests/hard_coded/bitmap_test.m:
tests/hard_coded/construct_bug.m:
tests/hard_coded/dir_fold.m:
tests/hard_coded/dir_test.m:
tests/hard_coded/read_binary_int16.m:
tests/hard_coded/read_binary_int32.m:
tests/hard_coded/read_binary_int64.m:
tests/hard_coded/read_binary_uint16.m:
tests/hard_coded/read_binary_uint32.m:
tests/hard_coded/read_binary_uint64.m:
tests/hard_coded/read_bitmap_size.m:
tests/hard_coded/remove_file.m:
tests/hard_coded/write_binary.m:
tests/hard_coded/write_binary_int8.m:
tests/hard_coded/write_binary_multibyte_int.m:
tests/hard_coded/write_binary_uint8.m:
Call the file operation predicates directly in io.file.m, not indirectly
through io.m.
compiler/module_imports.m:
Introduce the type burdened_module, as a version of burdened_aug_comp_unit
that contains only the parse_tree_module_src part of an augmented
compilation unit (i.e. the part *before* any augmentation).
Make some predicates operate on parse_tree_module_srcs instead of
aug_comp_units.
compiler/deps_map.m:
compiler/module_dep_info.m:
Replace burdened_aug_comp_units with burdened_modules in dependency maps
and module_dep_infos respectively. This works because in both cases,
we only ever use the parse_tree_module_src part of the aug_comp_units,
and the presence of the rest of the aug_comp_unit is just a maintenance
burden. (The use of burdened_aug_comp_units was a holdover from
ancient code that used module_and_imports structures, while they existed.)
The burdened_aug_comp_units we used to put into those data structures
always consisted of a parse_tree_module_src *without* any augmentation.
In deps_map.m, simplify some code.
compiler/write_deps_file.m:
This module gets dependency information from two sources: full,
actually-filled-out aug_comp_units from mercury_compile_main.m,
and from deps_maps. In the latter case, turn the burdened_modules
into burdened_aug_comp_units just before entering code that also handles
actually-filled-out aug_comp_units.
Update some old documentation.
compiler/make.module_dep_file.m:
Delete code that used to actively strip away any preexisting augmentation
from burdened_aug_comp_units, since burdened_modules have nothing to strip.
Conform to the changes above.
compiler/mercury_compile_main.m:
Pass a burdened_module, instead of a burdened_aug_comp_unit,
to the predicate in make.module_dep_file.m that used to strip away
all the augmentation from the burdened_aug_comp_unit.
compiler/generate_dep_d_files.m:
Conform to the changes above.
compiler/make.top_level.m:
compiler/make.track_flags.m:
compiler/make.make_info.m:
Carve these three modules out of make.m.
make.top_level.m contains the top level of the mmc --make algorithm.
make.track_flags.m contains code for keeping track of which options
were used to compile which modules.
make.make_info.m defines the make_info structure used by all the
submodules of make.m, as well as a few other utility types.
compiler/notes/compiler_design.html:
Document the new modules.
compiler/make.m:
Delete the code that has been moved to the new modules, leaving
make.m as purely a package.
Include make.build.m in the interface, so we can delete the forwarding
predicate we used to have here for use by mercury_compile_main.m.
compiler/Mercury.options:
Make make.top_level.m and make.track_flags inherit make.m's old
-no-warn-implicit-stream-calls option.
compiler/file_names.m:
Move a utility function about extensions here from make.m.
This also allows the removal of an undesirable module import of make.m
in write_deps_file.m.
compiler/make.build.m:
Move a type here from make.m, since it is needed to allow
mercury_compile_main.m call this module directly (i.e. not through
a forwarding predicate in make.m).
compiler/make.dependencies.m:
compiler/make.deps_set.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/mercury_compile_main.m:
compiler/options_file.m:
compiler/write_deps_file.m:
Conform to the changes above. This mostly means having each module make.X
actually import the modules it uses, instead of relying on make.m
importing them, and getting those imports via make.int0.
In a few cases, it means having each module make.X NOT import the modules
it does NOT use, since after the "package-ification" of make.m,
we now get warnings about these imports being unused.
compiler/prog_item.m:
Split aug_compilation_unit into two types. One, aug_make_int_unit,
is a new type, and it is a version of the old aug_compilation_unit
that contains only what is needed when making .int{,0,2} files.
The other, the new aug_compilation_unit, contains what is needed
when generating target language code. Both encode in their argument types
stronger invariants that the old aug_compilation_unit type did.
compiler/comp_unit_interface.m:
compiler/decide_type_repn.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/grab_modules.m:
compiler/make_hlds_separate_items.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.m:
compiler/parse_tree_out.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Conform to the change above.
In some cases, this means passing around aug_make_int_units instead of
aug_compilation_units.
In a few cases, it means creating two copies of a predicate,
one for aug_compilation_units and one for aug_make_int_units.
In such cases, factor out any commonalities between the copies.
In many cases, it means updates to account for the specialized types
of the fields of aug_compilation_unit or aug_make_int_unit.
In some cases, it means deleting code that was always unreachable,
but the not-tight-enough types did not make this fact visible.
(Due to this effect, this diff removes more lines than it adds.)
compiler/module_imports.m:
Delete the module_and_imports type, and replace its uses with
aug_compilation_units.
The structure of module_and_imports used to be private, but the
structure of aug_compilation_units is public. Delete the getter/setter
predicates on module_and_imports structures that can now be done
using field names on aug_compilation_units. Delete, along with this,
the infrastructure for keeping track of which module_and_imports fields
are ever accessed. It has served its purpose, but it won't be needed
anymore.
Change types that used to include module_and_imports to include
aug_compilation_units instead.
Rename any types, predicates and functions that used to contain
the "module_and_imports" string in their name.
compiler/prog_item.m:
Move the version number map to be the last field of aug_compilation_units,
as it used to be in module_and_imports structures, since this fits better.
compiler/get_dependencies.m:
Make the name of a predicate more reflective of the type it returns.
compiler/comp_unit_interface.m:
compiler/deps_map.m:
compiler/equiv_type.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/make.m:
compiler/make.module_dep_file.m:
compiler/make_hlds_separate_items.m:
compiler/mercury_compile_main.m:
compiler/module_qual.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
compiler/module_imports.m:
Keep in the module_and_imports structure only the fields that used to
construct aug_compilation_units, to prepare for the replacement
of module_and_imports by aug_compilation_unit. Move the remaining fields
into a new structure, the module_baggage, and introduce a new type,
module_imports_and_baggage, that contains module_and_imports (for now)
and module_baggage.
The point of this is to allow the splitting of aug_compilation_unit
into types:
- one (aug_compilation_unit itself) for use when generating
target language code, and
- one (maybe named aug_make_int_unit) for use when generating
.int/.int2 files.
These two use cases fill some of the fields, such as direct and indirect
imports, with different kinds of parse trees. Until now, we handled this
using types such as direct_int_spec, which could contain either kind
of parse tree, but having separate aug_compilation_unit/aug_make_int_unit
types would allow the compiler to enforce the different invariants
of the two use cases.
This split requires factoring out the common parts of module_and_imports
structure. The module_baggage type contains these common parts.
Simplify some operations as permitted by the above change.
Rename others to reflect the new names of the types they operate on.
Don't return an output argument that is contained in another output
argument.
Delete operations on deleted fields.
Delete a predicate that has become identical to another.
compiler/grab_modules.m:
Add operations on module_baggage (that previously were operations on
module_and_imports) that are needed only in this module.
Conform to the changes above.
compiler/deps_map.m:
compiler/generate_dep_d_files.m:
compiler/make.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile_main.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
compiler/module_imports.m:
As above.
compiler/grab_modules.m:
Add indirectly imported module names only to indirect_int_specs field,
and not redundantly to the now-deleted field.
compiler/write_deps_file.m:
Get the same info from the indirect_int_specs field.
compiler/module_imports.m:
Delete module_and_imports' {int,imp}_deps fields, as their contents
are computable from the field containing the parse_tree_module_src.
Add a utility predicate that returns the int and imp dependencies
separately. Clients for whom the int/imp distinction is not relevant
can get the union of those sets more simply by just taking the
key set of the parse_tree_module_src's import_and_or_use_map.
Delete now unneeded arguments.
Make some minor rearrangements to minimize the remaining differences
between the two methods of initializing module_and_imports structures,
init_module_and_imports and make_module_and_imports.
compiler/grab_modules.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile_main.m:
compiler/write_deps_file.m:
Conform to the change above.
compiler/module_imports.m:
As above. The new approach has a much simpler correctness argument,
especially since some of the methods for initializing module_and_imports
structures didn't actually fill in one of the fields with meaningful
information.
Don't ask callers for arguments that are not used.
compiler/get_dependencies.m:
Add utility predicates for computing the information that those fields
used to contain on demand.
Simplify the interface to some similar recently-added utility predicates.
compiler/make.module_dep_file.m:
Call those utility predicates when needed.
compiler/item_util.m:
Delete the utility predicates that module_imports.m *used* to use
to fill in those fields, which is no longer needed.
compiler/grab_modules.m:
compiler/write_deps_file.m:
Conform to the changes above.
compiler/write_deps_file.m:
The generate_dependencies_write_d_file predicate used to pass information
about interface, implementation, and indirect dependencies that it derived
from the intermodule dependencies graph to write_dependency_file
by storing it in the module_and_imports structure. This violated the
obvious semantics of the relevant fields of that structure (or replaced
the obvious semantics with an unnecessarily more complicated semantics,
depending on your view). Fix this by passing such override information
in a separate structure. As a bonus, this allows us to pass that
information in its desired form (as sets of module names), without
having to associate a dummy context that is destined to be ignored
with each module name.
Pass along in the same data structure similar information about foreign
import module dependencies. The deletion of the code that added this
info to the module_and_imports structure in a commit yesterday was a bug
that caused a test case to fail in valid and two in valid_seq. This
diff fixes those failures.
compiler/mercury_compile_main.m:
Conform to the change in write_deps_file.m.
compiler/module_imports.m:
Delete the field containing foreign_import_module (fim) info from
the module_and_imports structure, for two reasons. First, because
it is redundant; the same info is implicit in the other fields
of the module_and_imports structure. Second, because its semantics
were unclear: on different code paths and at different points in time,
it could contain fims from only the parse_tree_module_src, on other
code paths it could contain fims from the imported interface and/or
optimization files as well, and yet on other paths and times
it could be just set to empty regardless of the presence of fims
in the module being compiled.
Replace this with a predicate that calls get_dependencies.m to get fims
on demand from the parse_tree_module_src.
Don't give write_deps_file.m info it does not need.
compiler/get_dependencies.m:
Provide the utility predicate that does that.
compiler/item_util.m:
Provide helper predicates for the new predicate in get_dependencies.m.
(Eventually, these could be moved to get_dependencies.m, but while
the predicate whose logic they follow is in item_util.m, that is
where they should be.)
compiler/write_deps_file.m:
Eliminate the special cases in the code that generates the mmake rules
for dependencies on foreign imported modules. The codes handling the
two special cases never had any documented or easily discoverable
correctness arguments, and the fact that we can now never forcibly
initialize the fims field of the module_and_imports structure to
the empty list has tickled a bug in at least one of the special cases:
the fact that it did not restrict the set of fims to be recorded
to the fims for the relevant target language. Deleting the special
cases seems a better bet that a bandaid fix on questionable code.
Also, replace the two rules we used to generate, which were
modulename.o: <list of .mh files>
modulename.pic_o: <list of .mh files>
where the .mh file lists were always the same with a single mmake rule
of the form
modulename.o modulename.pic_o: <list of .mh files>
In one predicate, do not both updating several fields of a local copy
of a module_and_imports structure, because the fields that used
to be update are never read before the variable goes out of scope.
compiler/deps_map.m:
compiler/make.module_dep_file.m:
Conform to the changes above.
compiler/module_imports.m:
Delete the field containing foreign_include_file_infos from
the module_and_imports structure, because it is redundant;
the same info is implicit in the parse_tree_module_src field.
compiler/grab_modules.m:
Don't pass the set of foreign_file_include_infos to module_imports.m,
since it does not need it anymore.
compiler/get_dependencies.m:
Provide a predicate to get the set of foreign_file_include_infos
on demand. Provide this info in the form of a set, not a cord,
since duplicates don't count.
compiler/make.module_dep_file.m:
compiler/write_deps_file.m:
Get the set of foreign_file_include_infos when needed.
compiler/prog_data_foreign.m:
Delete a type synonym that is not needed anymore.
compiler/module_imports.m:
Delete the redundant fact table field from module_and_imports.
Get that info when needed from the parse_tree_module_src stored
in the module_and_imports structure.
compiler/get_dependencies.m:
Add a predicate to get this info on demand.
compiler/grab_modules.m:
Don't precompute the set of fact tables. (Actually, for now we do
precompute it but ignore it, but the precomputation should be gone soon.)
compiler/make.module_dep_file.m:
Conform to the changes above, and give a predicate a better name.
compiler/write_deps_file.m:
Conform to the changes above.
compiler/prog_item.m:
Delete the module name and module name context fields from
aug_compilation_units, since the same info is available from
the parse_tree_module_src field.
compiler/comp_unit_interface.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/grab_modules.m:
compiler/item_util.m:
compiler/make_hlds_passes.m:
compiler/make_hlds_separate_items.m:
compiler/mercury_compile_main.m:
compiler/module_imports.m:
compiler/module_qual.m:
compiler/prog_item_stats.m:
compiler/write_deps_file.m:
Conform to the change above.
compiler/module_imports.m:
As above; delete the ancestors field, since users can compute its value
by calling get_ancestors_set on the module name.
On some initialization paths, the ancestors field used to be filled
with a dummy empty set, so this change should improve robustness.
compiler/deps_map.m:
compiler/grab_modules.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile_main.m:
compiler/module_deps_graph.m:
compiler/write_deps_file.m:
Conform to the changes in module_imports.m.
... not from separate fields in the module_and_imports_structure.
compiler/module_imports.m:
As above. This is a step towards using the parse_tree_module_src
as the single source of truth about the properties of the module
being compiled.
compiler/deps_map.m:
compiler/grab_modules.m:
compiler/write_deps_file.m:
Conform to the changes in module_imports.m.
compiler/module_imports.m:
The module_and_imports structure used to have a field, mf_nested_children,
which stored a set of module names, but which had confusing semantics:
it had two different meanings in two different circumstances.
Replace that field with a value of a new type, maybe_top_module, which
has two separate function symbols for those two circumstances:
when a module is the top module in its source file, and when it is not.
compiler/mercury_compile_main.m:
Conform to the change above.
Put related arguments next to each other.
compiler/grab_modules.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/recompilation.check.m:
compiler/write_deps_file.m:
Conform to the change above.
tests/recompilation/test_functions:
Impose a limit of 10 minutes of CPU time on each process. This should
help catch infinite loops, such as happened during the development
of this diff.
Fix indentation, and clarify some comments.
tests/recompilation/README:
Fix stray blank line.
compiler/du_type_layout.m:
Add a first draft of the code that will eventually get type representation
information from .int files. Invoke the new code only if undocumented,
developer-only experiment flags are set, and when invoked, compare
its output with the output of the old algorithm it is intended to
eventually replace.
The new code is not yet complete, and thus has not yet been tested.
compiler/prog_item.m:
Add a new field to the augmented compilation unit data type
that is intended to hold the .int file of the main module, the module
that the augmented compilation unit is for. For every module imported
by the main module, we read its .int or .int2 file and get the
representation information for the types they define from those files,
but we need this info for the main module's own types as well.
Add "need type representation information" as reason for reading
a .int file.
Break some types down into smaller types, to allow their components
to be manipulated individually by du_type_layout.m.
Start using uint8, not uint, in situations where we want to store
values that select bits in words, which fit into 6 bits.
Add XXXs where we could, and maybe should switch to uint8s.
Add extra documentation.
compiler/grab_modules.m:
Read in the main module's own .int file.
Replace a bool with a bespoke type.
compiler/module_imports.m:
Provide a slot for the main module's own interface file,
which will be used to set the new slot in augmented compilation units.
compiler/comp_unit_interface.m:
Put the exact same type_ctor_repn_map into .int2 files as .int files.
This should prevent the scenario where a compilation reads
e.g. mod_x.int2, gains access to the definitions of the exported types
of module mod_x, but then needs to read mod_x.int as well to find out
how those types are represented. Since neither type checking nor any
other semantic analysis pass pays any attention to type_repn items,
the additional type_repn items in mod_x.int2 cannot turn an otherwise
illegal program into a legal one.
compiler/hlds_data.m:
Clarify a comment.
compiler/maybe_error.m:
Provide a utility predicate.
compiler/prog_data.m:
Add XXXs about possible future improvements.
compiler/decide_type_repn.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/make_hlds_passes.m:
compiler/make_hlds_separate_items.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.m:
compiler/parse_tree_out.m:
compiler/parse_tree_out_type_repn.m:
compiler/parse_type_repn.m:
compiler/prog_item_stats.m:
compiler/write_deps_file.m:
Conform to the changes above.
Besides this main purpose, this diff also replaces code that calls
io.write_string several times in a row with code that prints the
thing to be printed in one go with io.format. In a couple of places,
this has caught (and fixed) bugs where we wanted to put `' quotes
around a filename, but printed only one of the two quotes.
compiler/file_util.m:
Provide alternatives to the existing maybe_report_stats,
maybe_write_string and maybe_flush_output predicates that explicitly
specify the output stream.
Rename report_error_to_stream as report_error, to allow
--warn-implicit-stream-calls to report calls to the existing report_error
predicate, which does not take an explicit output stream.
Add a module_name argument to the output_to_file_stream predicate,
to allow its code to figure out where to print both progress and
error messages.
compiler/module_cmds.m:
Add a module_name argument to the predicates that update interface,
to allow their code to figure out where to print both progress and
error messages.
For now, leave the predicates that issue commands that are not
clearly linked to a single module using implicit streams.
compiler/pd_debug.m:
compiler/analysis.file.m:
Specify output streams in some places.
In other places, doing so would require redoing the whole debug
infrastructure, since the current one is based on higher order predicates
that always write to the non-explicitly-specified *current* output stream.
compiler/passes_aux.m:
Provide predicates that get progress, debug and error streams
given a module_info, by extracting the globals and the module name
from the module_info, and then calling the predicates in globals.m
to get those streams. Doing this sequence of actions here factors out
what would otherwise be repeated code in many other parts of the compiler.
Delete two predicates that were not used anywhere in the compiler.
compiler/deforest.m:
compiler/export.m:
compiler/intermod.m:
compiler/llds_out_file.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/recompilation.usage.m:
compiler/simplify_goal_conj.m:
compiler/type_assign.m:
compiler/typecheck.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Use explicit streams everywhere where --warn-implicit-stream-calls
says this is possible.
compiler/Mercury.options:
Specify --warn-implicit-stream-calls for the modules above
with the listed exceptions, and with the exception of the modules
for which it was already specified.
compiler/compile_target_code.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_middle_passes.m:
Conform to the changes above.
Right now, most parts of the compiler write to the "current output stream".
This was a pragmatic choice at the time, but has not aged well. The problem
is that the answer to the question "where is the current output stream going?"
is not obvious in *all* places in the compiler (although it is obvious in
most). When using such implicit streams, finding where the output is going
to in a given predicate requires inspecting not just the ancestors of that
predicate, but also all their older siblings (since any of them could have
changed the current stream), *including* their entire call trees. This is
usually an infeasible task. By constrast, if we explicitly pass streams
to all output operations, we need only follow the places where the variable
representing that stream is bound, which the mode system makes easy.
This diff switches large parts of the compiler over to doing output only
to explicitly passed streams, never to the implicit "current output stream".
The parts it switches over are the parts that rely to a significant degree
on the innermost change, which is to the "output" typeclass in
parse_tree_out_info.m. This is the part that has to be switched over to
explicit streams first, because (a) many modules such as mercury_to_mercury.m
rely on the output typeclass, and (b) most other modules that do output
call predicates in these modules. Starting anywhere else would be like
building a skyscraper starting at the top.
This typeclass, output(U), has two instances: output(io), and output(string),
so you could output either to the current output stream, or to a string.
To allow the specification of the destination stream in the first case,
this diff changes the typeclass to output(S, U) with a functional dependency
from U to S, with the two instances being output(io.text_output_stream, io)
and output(unit, string). (The unit arg is ignored in the second case.)
There is a complication with the output typeclass method, add_list, that
outputs a list of items. The complication is that each item is output
by a predicate supplied by the caller, but the separator between the items
(usually a comma) is output by add_list itself. We don't want to give
callers of this method the opportunity to screw up by specifying (possibly
implicitly) two different output streams for these two purposes, so we want
(a) the caller to tell add_list where to put the separators, and then
(b) for add_list, not its caller, tell the user-supplied predicate what
stream to write to. This works only if the stream argument is just before
the di,uo pair of I/O state arguments, which differs from our usual practice
of passing the stream at or near the left edge of the argument list,
not near the right. The result of this complication is that two categories
of predicates that are and are not used to print items in a list differ
in where they put the stream in their argument lists. This makes it easy
to pass the stream in the wrong argument position if you call a predicate
without looking up its signature, and may require *changing* the argument
order when a predicate is used to print an item in a list for the first time.
A complete switch over to always passing the stream just before !IO
would fix this inconsistency, but is far to big a change to make all at once.
compiler/parse_tree_out_info.m:
Make the changes described above.
Add write_out_list, which is a variant of io.write_list specifically
designed to address the "complication" described above. It also has
the arguments in an order that is better suited for higher-order use.
Make the same change to argument order in the class method add_list
as well.
Almost all of the following changes consist of passing an extra stream
argument to output predicates. In some places, where I thought this would
aid readability, I replaced sequences of calls to output predicates
with a single io.format.
compiler/prog_out.m:
This module had many predicates that wrote things to the current output
stream. This diff adds versions of these predicates that take an
explicit stream argument.
If the originals are still needed after the changes to the other modules,
keep them, but add "_to_cur_stream" to the end of their names.
Otherwise, delete them. (Many of the changes below replace
write_xyz(..., !IO) with io.write_string(Stream, xyz_to_string(...), !IO),
especially when write_xyz did nothing except call xyz_to_string
and wrote out the result.)
compiler/c_util.m:
Add either an explicit stream argument to the argument list, or a
"_current_stream" suffix to the name, of every predicate defined
in this module that does output.
Add a new predicate to print out the block comment containing
input for mkinit. This factors out common code in the LLDS and MLDS
backends.
compiler/name_mangle.m:
Delete all predicates that used to write to the current output stream,
after replacing them if necessary with functions that return a string,
which the caller can print to wherever it wants. (The "if necessary"
part is there because some of the "replacement" functions already
existed.)
When converting a proc_label to a string, *always* require the caller
to say whether the label prefix should be added to the string,
instead of silently assuming "yes, add it", as calls to one of the old,
now deleted predicates had it.
compiler/file_util.m:
Add output_to_file_stream, a version of output_to_file which
simply passes the output file stream it opens to the predicate
that is intended to define the contents of the newly created or
updated file. The existing output_to_file, which instead sets
and resets the current output stream around the equivalent
predicate call, is still needed e.g. by the MLDS backend,
but hopefully for not too long.
compiler/mercury_to_mercury.m:
compiler/parse_tree_out.m:
compiler/parse_tree_out_clause.m:
compiler/parse_tree_out_inst.m:
compiler/parse_tree_out_pragma.m:
compiler/parse_tree_out_pred_decl.m:
compiler/parse_tree_out_term.m:
compiler/parse_tree_out_type_repn.m:
Change the code writing out parse trees to explicitly pass a stream
to every predicate that does output.
In some places, this allows us to avoid changing the identity
of the current output stream.
compiler/hlds_out.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_mode.m:
compiler/hlds_out_module.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/intermod.m:
Change the code writing out HLDS code to explicitly pass a stream
to every predicate that does output. (The changes to these modules
belong in this diff because these modules call many of the output
predicates in the parse tree package.)
In hlds_out_util.m, delete some write_to_xyz(...) predicates that wrote
the result of xyz_to_string(...) to the current output stream.
Replace calls to the deleted predicates with calls to io.write_string
with the string being written being computed by xyz_to_string.
Add a predicate to hlds_out_util.m that outputs a comment containing
the current context, if it is valid. This factors out code that used
to be common to several of the other modules.
In a few places in hlds_out_module.m, the new code generates a
slighly different set of blank lines, but this should not be a problem.
compiler/layout_out.m:
compiler/llds_out_code_addr.m:
compiler/llds_out_data.m:
compiler/llds_out_file.m:
compiler/llds_out_global.m:
compiler/llds_out_instr.m:
compiler/llds_out_util.m:
compiler/opt_debug.m:
compiler/rtti_out.m:
Change the code writing out the LLDS to explicitly pass a stream
to every predicate that does output. (The changes to these modules
belong in this diff because layout_out.m and rtti_out.m call
many of the output predicates in the parse tree package,
and through them, the rest of the LLDS backend is affected as well.)
compiler/make.module_dep_file.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
Replace code that sets and resets the current output stream
with code that simply passes an explicit output stream to a
predicate that now *takes* an explicit stream as an argument.
compiler/accumulator.m:
compiler/add_clause.m:
compiler/code_gen.m:
compiler/code_loc_dep.m:
compiler/cse_detection.m:
compiler/delay_partial_inst.m:
compiler/dep_par_conj.m:
compiler/det_analysis.m:
compiler/error_msg_inst.m:
compiler/export.m:
compiler/format_call.m:
compiler/goal_expr_to_goal.m:
compiler/ite_gen.m:
compiler/lco.m:
compiler/liveness.m:
compiler/lp_rational.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_c_global.m:
compiler/mode_debug.m:
compiler/mode_errors.m:
compiler/modes.m:
compiler/optimize.m:
compiler/passes_aux.m:
compiler/pd_debug.m:
compiler/pragma_c_gen.m:
compiler/proc_gen.m:
compiler/prog_ctgc.m:
compiler/push_goals_together.m:
compiler/rat.m:
compiler/recompilation.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
compiler/rtti.m:
compiler/saved_vars.m:
compiler/simplify_goal_conj.m:
compiler/stack_opt.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.domain.m:
compiler/structure_reuse.indirect.m:
compiler/structure_sharing.analysis.m:
compiler/superhomogeneous.m:
compiler/term_constr_build.m:
compiler/term_constr_data.m:
compiler/term_constr_fixpoint.m:
compiler/term_constr_pass2.m:
compiler/term_constr_util.m:
compiler/tupling.m:
compiler/type_assign.m:
compiler/unneeded_code.m:
compiler/write_deps_file.m:
Conform to the changes above, mostly by passing streams explicitly.
compiler/hlds_dependency_graph.m:
Conform to the changes above, mostly by passing streams explicitly.
Move a predicate's definition next it only use.
compiler/Mercury.options:
Specify --warn-implicit-stream-calls for all the modules in which
this diff has replaced all implicit streams with explicit streams.
(Unfortunately, debugging this diff has shown that --warn-implicit-
stream-calls detects only *some*, and not *all*, uses of implicit
streams.)
library/term_io.m:
Fix documentation.
compiler/Mercury.options:
Delete a workaround we needed only for Erlang.
compiler/add_mutable_aux_preds.m:
Delete the implementation of mutables for Erlang.
compiler/builtin_ops.m:
Document the fact that the Erlang backend was the only user of
two operations.
compiler/compile_target_code.m:
compiler/module_cmds.m:
Delete the predicates that handled the compilation of Erlang code.
compiler/file_names.m:
Delete code dealing with file names used only by the Erlang backend.
compiler/options.m:
Delete the old internal-only order_constructors_for_erlang option.
Add an XXX about another option intended for Erlang being unused.
Leave the other erlang-related options alive for now, to avoid breaking
Mmakefiles, Mercury.options files etc that may still refer to them.
Delete references to Erlang in help and/or error messages.
compiler/handle_options.m:
Don't both updating options that were used only by the Erlang backend,
and which are now unused.
Delete references to Erlang in help and/or error messages.
compiler/unify_proc.m:
Delete the code handling the Erlang-specific option deleted from options.m.
compiler/check_libgrades.m:
compiler/delay_partial_inst.m:
compiler/llds_out_data.m:
compiler/make_hlds_passes.m:
compiler/mlds_to_c_data.m:
compiler/prog_item.m:
compiler/simplify_goal_call.m:
compiler/write_deps_file.m:
Either delete comments referring to Erlang or the Erlang backend,
or, where their existence was the motivation for some design decisions,
shift the comments to the past tense.
tests/mmc_make/Mmakefile:
Delete a reference to a recently deleted .hrl file.
compiler/elds.m:
compiler/elds_to_erlang.m:
compiler/erl_backend.m:
compiler/erl_call_gen.m:
compiler/erl_code_gen.m:
compiler/erl_code_util.m:
compiler/erl_rtti.m:
compiler/erl_unify_gen.m:
compiler/erlang_rtti.m:
compiler/mercury_compile_erl_back_end.m:
Delete these modules, which together constitute the Erlang backend.
compiler/notes/compiler_design.html:
Delete references to the deleted modules.
compiler/parse_tree_out_type_repn.m:
Update the format we use to represent the sets of foreign_type and
foreign_enum declarations for a type as part of its item_type_repn_info,
now that Erlang is no longer a target language.
compiler/parse_type_repn.m:
Accept both the updated version of the item_type_repn_info and the
immediately previous version, since the installed compiler will
initially generate that previous version. However, stop accepting
an even older version that we stopped generating several months ago.
compiler/parse_pragma_foreign.m:
When the compiler finds a reference to Erlang as a foreign language,
add a message about support for Erlang being discontinued to the error
message.
Make the code parsing foreign_decls handle the term containing
the foreign language the same way as the codes parsing foreign
codes, procs, types and enums.
Add a mechanism to help parse_mutable.m to do the same.
compiler/parse_mutable.m:
When the compiler finds a reference to Erlang as a foreign language,
print an error message about support for Erlang being discontinued.
compiler/compute_grade.m:
When the compiler finds a reference to Erlang as a grade component,
print an informational message about support for Erlang being discontinued.
compiler/pickle.m:
compiler/make.build.m:
Delete Erlang foreign procs and types.
compiler/add_foreign_enum.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pred.m:
compiler/add_solver.m:
compiler/add_type.m:
compiler/check_libgrades.m:
compiler/check_parse_tree_type_defns.m:
compiler/code_gen.m:
compiler/compile_target_code.m:
compiler/compute_grade.m:
compiler/const_struct.m:
compiler/convert_parse_tree.m:
compiler/dead_proc_elim.m:
compiler/decide_type_repn.m:
compiler/deps_map.m:
compiler/du_type_layout.m:
compiler/export.m:
compiler/foreign.m:
compiler/globals.m:
compiler/granularity.m:
compiler/handle_options.m:
compiler/hlds_code_util.m:
compiler/hlds_data.m:
compiler/hlds_module.m:
compiler/inlining.m:
compiler/int_emu.m:
compiler/intermod.m:
compiler/item_util.m:
compiler/lambda.m:
compiler/lco.m:
compiler/llds_out_file.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_separate_items.m:
compiler/make_hlds_warn.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/ml_code_util.m:
compiler/ml_foreign_proc_gen.m:
compiler/ml_target_util.m:
compiler/ml_top_gen.m:
compiler/mlds.m:
compiler/mlds_dump.m:
compiler/mlds_to_c_export.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_data.m:
compiler/mlds_to_cs_export.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_cs_type.m:
compiler/mlds_to_java_export.m:
compiler/mlds_to_java_file.m:
compiler/mlds_to_java_type.m:
compiler/module_imports.m:
compiler/parse_pragma_foreign.m:
compiler/parse_tree_out.m:
compiler/polymorphism.m:
compiler/pragma_c_gen.m:
compiler/prog_data.m:
compiler/prog_data_foreign.m:
compiler/prog_foreign.m:
compiler/prog_item.m:
compiler/simplify_goal_scope.m:
compiler/special_pred.m:
compiler/string_encoding.m:
compiler/top_level.m:
compiler/uint_emu.m:
compiler/write_deps_file.m:
Remove references to Erlang as a backend or as a target language.
tests/invalid/bad_foreign_code.{m,err_exp}:
tests/invalid/bad_foreign_decl.{m,err_exp}:
tests/invalid/bad_foreign_enum.{m,err_exp}:
tests/invalid/bad_foreign_export.{m,err_exp}:
tests/invalid/bad_foreign_export_enum.{m,err_exp}:
tests/invalid/bad_foreign_import_module.{m,err_exp}:
tests/invalid/bad_foreign_proc.{m,err_exp}:
tests/invalid/bad_foreign_type.{m,err_exp}:
Add a test for Erlang as an invalid foreign language. Expect both the
new error message for this new error, and the updated list of now-valid
foreign languages on all errors.
compiler/write_deps_file.m:
As above.
Simplify some logic.
Make the code constructing error messages more readable.
compiler/mmakefiles.m:
Rename end_mmakefile as write_mmakefile, since that is what
the predicate does.
Export a function to write_deps_file.m.
compiler/write_deps_file.m:
Move two blocks of code that construct mmake rules to two new predicates.
compiler/module_imports.m:
Delete a redundant output argument.
compiler/file_names.m:
Delete extra_link_obj_file_name, because (a) its definition was
exactly the same as the definition of fact_table_file_name, and
(b) it was used *only* on fact tables, so the definition
couldn't be different anyway.
compiler/write_deps_file.m:
Conform to the change above.
This is a first step towards a much finer grained partition.
compiler/file_names.m:
Split the ext type into ext_src and ext_other, as mentioned above.
Add the first predicate for checking whether a string falls into
a given category of extensions.
Add an XXX proposing a better solution for an old problem that does not
actually arise in practice.
compiler/compile_target_code.m:
Split the two-moded predicate maybe_pic_object_file_extension into
two separate one-mode predicates, one for each old mode. The
implementations of the two modes were already separate, because
the two modes already did different jobs: while one went from PIC
to an "extension", the other went from an "extension string" to PIC.
Until now, "extension" and "extension string" were equivalent;
after this diff, they aren't anymore.
Delete an unused argument.
compiler/make.util.m:
Split the two-moded predicate target_extension into
two separate one-mode predicates, one for each old mode,
for the same reason as maybe_pic_object_file_extension above:
the fact that "extension" and "extension string" are now distinct.
compiler/options_file.m:
Move debug infrastructure here from mercury_compile_main.m, to help
debug possible problems with options files. (I had such a problem
while writing this diff.)
Improve how progress messages are printed.
compiler/options.m:
Make an error message more useful.
compiler/mercury_compile_main.m:
Add infrastructure for debugging possible problems with command lines.
(I had such a problem while writing this diff.)
compiler/analysis.m:
Conform to the changes above. Put the arguments of some methods
into the same order as similar predicates in file_names.m.
compiler/find_module.m:
Conform to the changes above. Delete an unused argument,
compiler/analysis.file.m:
compiler/du_type_layout.m:
compiler/elds_to_erlang.m:
compiler/export.m:
compiler/fact_table.m:
compiler/file_kind.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.deps_set.m:
compiler/make.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/prog_foreign.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/source_file_map.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
... to allow later changes to its definition.
compiler/file_names.m:
We used to represent filename extensions simply as strings. This meant
all calls to the predicates in file_names.m that convert module names
to file names with various suffixes had to go through a complicated
sequence of tests that effectively partition the extensions into
several classes, with all extensions in a class being treated the same
but different classes being treated differently. And since this general
translation process is quite convoluted (which is not helped by it
being spread across several predicates), it is very hard to construct
a correctness argument for it.
It would be better to represent the different classes of extensions
explicitly, in a du type, with each function symbol of that type
representing all the extensions in the corresponding class (in the sense
of the paragraph above). However, getting there in one diff would make
that diff far too hard to test and to review. So this first diff
starts by simply making extension a notag type.
The above is the first step in implementing one old XXX. This diff
fully implements another old XXX, which is to make the argument order
of several predicates friendly to higher order code.
Add infrastructure for profiling how often this code makes directories.
Delete an unused type.
Add comments outlining proposed future improvements.
compiler/analysis.file.m:
compiler/analysis.m:
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/elds_to_erlang.m:
compiler/export.m:
compiler/fact_table.m:
compiler/file_kind.m:
compiler/find_module.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/llds_out_file.m:
compiler/make.build.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/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/module_imports.m:
compiler/parse_tree_out.m:
compiler/prog_foreign.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the change to file_names.m.
Consistently use "Ext" for the abstract representation of extensions
and "ExtStr" for their string representation.
In a few places, add "XXX EXT" where the code manipulates extensions
as strings in a way that potentially inferferes with the partition
of extensions into classes.
In a few places, rename predicates to avoid ambiguities. factor out
common code, delete unneeded arguments, replace bools with bespoke types,
and make similar minor improvements.
In a few places, remove rafe-isms, such as the use ^elem.