for review: add nested modules [1/5]
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Feb 26 16:31:26 AEDT 1998
Hi,
This change is a bit incomplete, so ordinarily I would
prefer to wait until it was a bit more complete before
committing. However, due to the size of the change
(12000 lines of diff, although much of that is trivial
changes) and the likelihood of cvs conflicts,
I think it is better to commit this sooner rather than later.
The current implementation has a few limitations and
doesn't enforce some of the rules, but nevertheless
it should be usable as is.
Simon, you did the support for `use_module', so you're
the natural candidate for reviewer. Could you please
review this one?
-----------------------------------------------------------------------------
Estimated hours taken: 50
Add support for nested modules.
- module names may themselves be module-qualified
- modules may contain `:- include_module' declarations
which name sub-modules
- a sub-module has access to all the declarations in the
parent module (including its implementation section).
This support is not yet complete; see the BUGS and LIMITATIONS below.
LIMITATIONS
- source file names must match module names
(just as they did previously)
- mmc doesn't allow path names on the command line any more
(e.g. `mmc --make-int ../library/foo.m').
- import_module declarations must use the fully-qualified module name
- module qualifiers must use the fully-qualified module name
- no support for root-qualified module names
(e.g. `:parent:child' instead of `parent:child').
- modules may not be physically nested (only logical nesting, via
`include_module').
BUGS
- doesn't check that the parent module is imported/used before allowing
import/use of its sub-modules.
- doesn't check that there is an include_module declaration in the
parent for each module claiming to be a child of that parent
- privacy of private modules is not enforced
library/ops.m:
library/nc_builtin.nl:
library/sp_builtin.nl:
compiler/mercury_to_mercury.m:
Add `include_module' as a new prefix operator.
Change the associativity of `:' from xfy to yfx
(since this made parsing module qualifiers slightly easier).
compiler/prog_data.m:
Add new `include_module' declaration.
Change the `module_name' and `module_specifier' types
from strings to sym_names, so that module names can
themselves be module qualified.
compiler/modules.m:
Add predicates module_name_to_file_name/2 and
file_name_to_module_name/2.
Lots of changes to handle parent module dependencies,
to create parent interface (`.int0') files, to read them in,
to output correct dependencies information for them to the
`.d' and `.dep' files, etc.
Rewrite a lot of the code to improve the readability
(add comments, use subroutines, better variable names).
Also fix a couple of bugs:
- generate_dependencies was using the transitive implementation
dependencies rather than the transitive interface dependencies
to compute the `.int3' dependencies when writing `.d' files
(this bug was introduced during crs's changes to support
`.trans_opt' files)
- when creating the `.int' file, it was reading in the
interfaces for modules imported in the implementation section,
not just those in the interface section.
This meant that the compiler missed a lot of errors.
library/graph.m:
library/lexer.m:
library/term.m:
library/term_io.m:
library/varset.m:
compiler/*.m:
Add `:- import_module' declarations to the interface needed
by declarations in the interface. (The previous version
of the compiler did not detect these missing interface imports,
due to the above-mentioned bug in modules.m.)
compiler/mercury_compile.m:
compiler/intermod.m:
Change mercury_compile__maybe_grab_optfiles and
intermod__grab_optfiles so that they grab the opt files for
parent modules as well as the ones for imported modules.
compiler/mercury_compile.m:
Minor changes to handle parent module dependencies.
(Also improve the wording of the warning about trans-opt
dependencies.)
compiler/make_hlds.m:
compiler/module_qual.m:
Ignore `:- include_module' declarations.
compiler/module_qual.m:
A couple of small changes to handle nested module names.
compiler/prog_out.m:
compiler/prog_util.m:
Add new predicates string_to_sym_name/3 (prog_util.m) and
sym_name_to_string/{2,3} (prog_out.m).
compiler/*.m:
Replace many occurrences of `string' with `module_name'.
Change code that prints out module names or converts
them to strings or filenames to handle the fact that
module names are now sym_names intead of strings.
Also change a few places (e.g. in intermod.m, hlds_module.m)
where the code assumed that any qualified symbol was
fully-qualified.
compiler/prog_io.m:
compiler/prog_io_goal.m:
Move sym_name_and_args/3, parse_qualified_term/4 and
parse_qualified_term/5 preds from prog_io_goal.m to prog_io.m,
since they are very similar to the parse_symbol_name/2 predicate
already in prog_io.m. Rewrite these predicates, both
to improve maintainability, and to handle the newly
allowed syntax (module-qualified module names).
Rename parse_qualified_term/5 as `parse_implicit_qualified_term'.
compiler/prog_io.m:
Rewrite the handling of `:- module' and `:- end_module'
declarations, so that it can handle nested modules.
Add code to parse `include_module' declarations.
compiler/prog_util.m:
compiler/*.m:
Add new predicates mercury_public_builtin_module/1 and
mercury_private_builtin_module/1 in prog_util.m.
Change most of the hard-coded occurrences of "mercury_builtin"
to call mercury_private_builtin_module/1 or
mercury_public_builtin_module/1 or both.
compiler/llds_out.m:
Add llds_out__sym_name_mangle/2, for mangling module names.
compiler/special_pred.m:
compiler/mode_util.m:
compiler/clause_to_proc.m:
compiler/prog_io_goal.m:
compiler/lambda.m:
compiler/polymorphism.m:
Move the predicates in_mode/1, out_mode/1, and uo_mode/1
from special_pred.m to mode_util.m, and change various
hard-coded definitions to instead call these predicates.
compiler/polymorphism.m:
Ensure that the type names `type_info' and `typeclass_info' are
module-qualified in the generated code. This avoids a problem
where the code generated by polymorphism.m was not considered
type-correct, due to the type `type_info' not matching
`mercury_builtin:type_info'.
compiler/check_typeclass.m:
Simplify the code for check_instance_pred and
get_matching_instance_pred_ids.
compiler/mercury_compile.m:
compiler/modules.m:
Disallow directory names in command-line arguments.
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/modules.m:
Add a `--make-private-interface' option.
The private interface file `<module>.int0' contains
all the declarations in the module; it is used for
compiling sub-modules.
scripts/Mmake.rules:
scripts/Mmake.vars.in:
Add support for creating `.int0' and `.date0' files
by invoking mmc with `--make-private-interface'.
doc/user_guide.texi:
Document `--make-private-interface' and the `.int0'
and `.date0' file extensions.
doc/reference_manual.texi:
Document nested modules.
util/demangle.c:
profiler/mdemangle.m:
Demangle names with multiple module qualifiers.
tests/general/Mmakefile:
tests/general/string_format_test.m:
tests/general/string_format_test.exp:
tests/general/string__format_test.m:
tests/general/string__format_test.exp:
tests/general/.cvsignore:
Change the `:- module string__format_test' declaration in
`string__format_test.m' to `:- module string_format_test',
because with the original declaration the `__' was taken
as a module qualifier, which lead to an error message.
Hence rename the file accordingly, to avoid the warning
about file name not matching module name.
tests/invalid/*.err_exp:
tests/warnings/*.exp:
Update the expected diagnostics output for the test cases to
reflect a few minor changes to the warning messages.
tests/hard_coded/Mmakefile:
tests/hard_coded/parent.m:
tests/hard_coded/parent.child.m:
tests/hard_coded/parent.exp:
A very simple test case for the use of nested modules with
separate compilation.
cvs diff: Diffing .
Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.94
diff -u -u -r1.94 NEWS
--- NEWS 1998/02/24 23:59:35 1.94
+++ NEWS 1998/02/26 03:55:19
@@ -238,6 +238,23 @@
* Mode inference can now infer "mostly-unique" modes as well as
"unique" modes.
+* The module system now includes support for logically nested sub-modules
+ with separate compilation.
+
+ The aim of this extension is to provide better support for structuring
+ large software packages.
+
+ Modules may now contain `:- include_module' declarations.
+ If a module `foo' contains an `include_module bar' declaration,
+ this specifies that module `foo' contains the sub-module `foo:bar'.
+ Since a sub-module is logically part of the containing module,
+ it has access to all the entities declared in or imported into
+ the containing module, including those declared in the implementation
+ section.
+
+ See the "Modules" chapter of the Mercury language reference manual for
+ details.
+
* We've made more improvements to the C interface.
The C interface now includes support for defining procedures
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing bytecode
cvs diff: Diffing bytecode/test
cvs diff: Diffing compiler
Index: compiler/arg_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/arg_info.m,v
retrieving revision 1.26
diff -u -u -r1.26 arg_info.m
--- arg_info.m 1998/02/12 01:16:54 1.26
+++ arg_info.m 1998/02/25 02:43:20
@@ -22,8 +22,8 @@
:- module arg_info.
:- interface.
-:- import_module hlds_module, llds, globals, prog_data.
-:- import_module bool.
+:- import_module hlds_module, hlds_pred, llds, globals, prog_data.
+:- import_module bool, list.
:- pred generate_arg_info(module_info, module_info).
:- mode generate_arg_info(in, out) is det.
@@ -50,8 +50,7 @@
:- implementation.
-:- import_module hlds_pred.
-:- import_module map, int, mode_util, list, require.
+:- import_module map, int, mode_util, require.
%-----------------------------------------------------------------------------%
Index: compiler/base_type_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/base_type_info.m,v
retrieving revision 1.15
diff -u -u -r1.15 base_type_info.m
--- base_type_info.m 1998/01/23 12:56:13 1.15
+++ base_type_info.m 1998/02/25 04:09:17
@@ -25,7 +25,8 @@
:- interface.
-:- import_module hlds_module.
+:- import_module hlds_module, llds.
+:- import_module list.
:- pred base_type_info__generate_hlds(module_info, module_info).
:- mode base_type_info__generate_hlds(in, out) is det.
@@ -35,9 +36,12 @@
:- implementation.
-:- import_module prog_data, hlds_data, hlds_pred, hlds_out, base_typeclass_info.
-:- import_module llds, code_util, globals, special_pred, options.
-:- import_module bool, string, list, map, std_util, require.
+:- import_module base_typeclass_info.
+:- import_module prog_data, prog_util, prog_out.
+:- import_module hlds_data, hlds_pred, hlds_out.
+:- import_module code_util, special_pred, globals, options.
+
+:- import_module bool, string, map, std_util, require.
%---------------------------------------------------------------------------%
@@ -54,8 +58,8 @@
% find the types defined in this module, and return a base_gen_info
% for each.
-:- pred base_type_info__gen_base_gen_infos(list(type_id), type_table, string,
- module_info, list(base_gen_info)).
+:- pred base_type_info__gen_base_gen_infos(list(type_id), type_table,
+ module_name, module_info, list(base_gen_info)).
:- mode base_type_info__gen_base_gen_infos(in, in, in, in, out) is det.
base_type_info__gen_base_gen_infos([], _, _, _, []).
@@ -159,8 +163,9 @@
TypeArity, LayoutArg),
base_type_info__construct_functors(ModuleInfo, TypeName,
TypeArity, FunctorsArg),
+ prog_out__sym_name_to_string(ModuleName, ModuleNameString),
NameArg = yes(const(string_const(TypeName))),
- ModuleArg = yes(const(string_const(ModuleName))),
+ ModuleArg = yes(const(string_const(ModuleNameString))),
list__append(PredAddrArgs, [LayoutArg, FunctorsArg, ModuleArg,
NameArg], FinalArgs)
;
@@ -207,9 +212,10 @@
globals__have_static_code_addresses(Globals, yes)
->
hlds_pred__initial_proc_id(ProcId),
+ mercury_private_builtin_module(MercuryBuiltin),
PredAddrArg = yes(const(code_addr_const(
- imported(proc("mercury_builtin", predicate,
- "mercury_builtin", "unused", 0,
+ imported(proc(MercuryBuiltin, predicate,
+ MercuryBuiltin, "unused", 0,
ProcId)))))
;
PredAddrArg = yes(const(int_const(0)))
Index: compiler/base_type_layout.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/base_type_layout.m,v
retrieving revision 1.27
diff -u -u -r1.27 base_type_layout.m
--- base_type_layout.m 1998/01/23 12:56:14 1.27
+++ base_type_layout.m 1998/02/25 02:26:14
@@ -217,7 +217,7 @@
:- interface.
-:- import_module hlds_module.
+:- import_module hlds_module, list, llds, prog_data.
:- pred base_type_layout__generate_hlds(module_info, module_info).
:- mode base_type_layout__generate_hlds(in, out) is det.
@@ -234,14 +234,14 @@
:- implementation.
-:- import_module prog_data, hlds_data, hlds_pred, hlds_out, type_util.
-:- import_module llds, code_util, globals, options, special_pred, prog_util.
-:- import_module assoc_list, bool, string, int, list, map, std_util, require.
+:- import_module hlds_data, hlds_pred, hlds_out, type_util.
+:- import_module code_util, globals, options, special_pred, prog_util.
+:- import_module assoc_list, bool, string, int, map, std_util, require.
:- import_module term.
:- type layout_info --->
layout_info(
- string, % module name
+ module_name, % module name
cons_table, % ctor table
int, % number of tags available
int, % next available label
@@ -274,7 +274,7 @@
% base_gen_layout for each.
:- pred base_type_layout__gen_base_gen_layouts(list(type_id), type_table,
- string, module_info, list(base_gen_layout)).
+ module_name, module_info, list(base_gen_layout)).
:- mode base_type_layout__gen_base_gen_layouts(in, in, in, in, out) is det.
base_type_layout__gen_base_gen_layouts([], _, _, _, []).
@@ -1089,7 +1089,7 @@
type_is_higher_order(Type, _PredFunc, _TypeArgs)
->
- TypeModule = "",
+ TypeModule = unqualified(""),
TypeName = "pred",
Arity = 0,
TypeId = _QualTypeName - RealArity,
@@ -1097,7 +1097,8 @@
;
TypeId = QualTypeName - Arity,
unqualify_name(QualTypeName, TypeName),
- sym_name_get_module_name(QualTypeName, "", TypeModule),
+ sym_name_get_module_name(QualTypeName, unqualified(""),
+ TypeModule),
RealArityArg = []
),
Pseudo0 = yes(const(data_addr_const(data_addr(TypeModule,
@@ -1229,7 +1230,7 @@
% access to the base_type_layout data structure.
-:- pred base_type_layout__get_module_name(layout_info, string).
+:- pred base_type_layout__get_module_name(layout_info, module_name).
:- mode base_type_layout__get_module_name(in, out) is det.
base_type_layout__get_module_name(LayoutInfo, ModuleName) :-
LayoutInfo = layout_info(ModuleName, _, _, _, _, _).
Index: compiler/base_typeclass_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/base_typeclass_info.m,v
retrieving revision 1.3
diff -u -u -r1.3 base_typeclass_info.m
--- base_typeclass_info.m 1998/01/23 12:56:15 1.3
+++ base_typeclass_info.m 1998/02/25 02:26:55
@@ -20,7 +20,7 @@
:- interface.
-:- import_module hlds_module.
+:- import_module hlds_module, list, llds, prog_data.
:- pred base_typeclass_info__generate_llds(module_info, list(c_module)).
:- mode base_typeclass_info__generate_llds(in, out) is det.
@@ -33,9 +33,9 @@
:- implementation.
-:- import_module prog_data, hlds_data, hlds_pred, hlds_out.
-:- import_module llds, code_util, globals, options.
-:- import_module bool, string, list, map, std_util, require, assoc_list, term.
+:- import_module hlds_data, hlds_pred, hlds_out.
+:- import_module code_util, globals, options.
+:- import_module bool, string, map, std_util, require, assoc_list, term.
%---------------------------------------------------------------------------%
@@ -47,7 +47,7 @@
ModuleInfo, CModules).
:- pred base_typeclass_info__gen_infos_for_classes(assoc_list(class_id,
- list(hlds_instance_defn)), string, module_info, list(c_module)).
+ list(hlds_instance_defn)), module_name, module_info, list(c_module)).
:- mode base_typeclass_info__gen_infos_for_classes(in, in, in, out) is det.
base_typeclass_info__gen_infos_for_classes([], _ModuleName, _ModuleInfo, []).
@@ -62,7 +62,7 @@
% XXX make it use an accumulator
:- pred base_typeclass_info__gen_infos_for_instance_list(
- pair(class_id, list(hlds_instance_defn)), string, module_info,
+ pair(class_id, list(hlds_instance_defn)), module_name, module_info,
list(c_module)).
:- mode base_typeclass_info__gen_infos_for_instance_list(in, in, in, out)
is det.
@@ -178,7 +178,8 @@
InstanceString),
% it doesn't matter which module the instance
% decl comes from
- DataAddr = data_addr("<unknown>", DataName),
+ Module = unqualified("<unknown>"),
+ DataAddr = data_addr(Module, DataName),
Rval = yes(const(data_addr_const(DataAddr)))
)),
list__map(GetRval, SuperClassConstraints, SuperClassRvals).
Index: compiler/bytecode.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/bytecode.m,v
retrieving revision 1.34
diff -u -u -r1.34 bytecode.m
--- bytecode.m 1998/01/25 06:05:20 1.34
+++ bytecode.m 1998/02/25 02:24:48
@@ -15,7 +15,7 @@
:- interface.
:- import_module hlds_data, prog_data, llds, tree.
-:- import_module list, std_util, io.
+:- import_module char, list, std_util, io.
:- type byte_tree == tree(list(byte_code)).
@@ -106,7 +106,7 @@
; to_none
.
-:- type byte_module_id == string.
+:- type byte_module_id == module_name.
:- type byte_pred_id == string.
:- type byte_proc_id == int.
:- type byte_label_id == int.
@@ -124,8 +124,8 @@
:- implementation.
-:- import_module hlds_pred, llds_out.
-:- import_module char, library, int, string, require.
+:- import_module hlds_pred, prog_out, llds_out.
+:- import_module library, int, string, require.
:- pred bytecode__version(int::out) is det.
@@ -635,13 +635,14 @@
:- mode output_module_id(in, di, uo) is det.
output_module_id(ModuleId) -->
- output_string(ModuleId).
+ { prog_out__sym_name_to_string(ModuleId, ModuleIdString) },
+ output_string(ModuleIdString).
:- pred debug_module_id(byte_module_id, io__state, io__state).
:- mode debug_module_id(in, di, uo) is det.
debug_module_id(ModuleId) -->
- debug_string(ModuleId).
+ debug_sym_name(ModuleId).
%---------------------------------------------------------------------------%
@@ -692,7 +693,7 @@
output_cons_id(cons(ModuleId, Functor, Arity, Tag)) -->
output_byte(0),
- output_string(ModuleId),
+ output_module_id(ModuleId),
output_string(Functor),
output_short(Arity),
output_tag(Tag).
@@ -737,7 +738,7 @@
debug_cons_id(cons(ModuleId, Functor, Arity, Tag)) -->
debug_string("functor"),
- debug_string(ModuleId),
+ debug_sym_name(ModuleId),
debug_string(Functor),
debug_int(Arity),
debug_tag(Tag).
@@ -1289,7 +1290,7 @@
io__write_string(Val),
io__write_char(' ').
debug_sym_name(qualified(Module, Val)) -->
- io__write_string(Module),
+ debug_sym_name(Module),
io__write_char(':'),
io__write_string(Val),
io__write_char(' ').
Index: compiler/call_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/call_gen.m,v
retrieving revision 1.120
diff -u -u -r1.120 call_gen.m
--- call_gen.m 1998/02/12 01:16:58 1.120
+++ call_gen.m 1998/02/25 04:05:49
@@ -18,8 +18,8 @@
:- interface.
-:- import_module hlds_pred, llds, code_info.
-:- import_module term.
+:- import_module prog_data, hlds_pred, hlds_data, hlds_goal, llds, code_info.
+:- import_module term, list, set, assoc_list, std_util.
:- pred call_gen__generate_higher_order_call(code_model, var, list(var),
list(type), list(mode), determinism, hlds_goal_info,
@@ -77,11 +77,11 @@
:- implementation.
-:- import_module hlds_module, hlds_goal, hlds_data, prog_data, code_util.
+:- import_module hlds_module, code_util.
:- import_module arg_info, type_util, mode_util, unify_proc, instmap.
:- import_module trace, globals, options.
-:- import_module bool, int, list, assoc_list, tree, set, map.
-:- import_module varset, std_util, require.
+:- import_module bool, int, tree, map.
+:- import_module varset, require.
%---------------------------------------------------------------------------%
Index: compiler/check_typeclass.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/check_typeclass.m,v
retrieving revision 1.3
diff -u -u -r1.3 check_typeclass.m
--- check_typeclass.m 1998/01/22 05:59:47 1.3
+++ check_typeclass.m 1998/02/19 00:54:53
@@ -134,15 +134,8 @@
pred_info_name(PredInfo, PredName0),
pred_info_module(PredInfo, PredModule),
PredName = qualified(PredModule, PredName0),
- pred_info_arity(PredInfo, PredArity0),
+ pred_info_arity(PredInfo, PredArity),
pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
- (
- PredOrFunc = predicate,
- PredArity = PredArity0
- ;
- PredOrFunc = function,
- PredArity is PredArity0 - 1
- ),
pred_info_procedures(PredInfo, ProcTable),
list__map(
lambda([TheProcId::in, ModesAndDetism::out] is det,
@@ -244,12 +237,13 @@
InstanceNames)
;
PredOrFunc = function,
+ FuncArity is PredArity - 1,
solutions(
lambda([SymName::out] is nondet,
(
list__member(Method, InstanceInterface),
Method = func_instance(PredName,
- SymName, PredArity)
+ SymName, FuncArity)
)),
InstanceNames)
).
@@ -258,39 +252,18 @@
arity, list(pred_id)).
:- mode get_matching_instance_pred_ids(in, in, in, in, out) is semidet.
-get_matching_instance_pred_ids(ModuleInfo, InstancePredName, PredOrFunc,
+get_matching_instance_pred_ids(ModuleInfo, InstancePredName0, PredOrFunc,
PredArity, InstancePredIds) :-
- module_info_get_predicate_table(ModuleInfo, PredicateTable),
- (
- (
- InstancePredName = unqualified(InstancePred)
- ;
- InstancePredName = qualified("", InstancePred)
- )
- ->
- (
- PredOrFunc = predicate,
- predicate_table_search_pred_name_arity( PredicateTable,
- InstancePred, PredArity, InstancePredIds)
- ;
- PredOrFunc = function,
- predicate_table_search_func_name_arity( PredicateTable,
- InstancePred, PredArity, InstancePredIds)
- )
+ % strip off any empty module qualifiers
+ % XXX how do these bogus empty qualifiers get here in the first place?
+ ( InstancePredName0 = qualified(unqualified(""), Name) ->
+ InstancePredName = unqualified(Name)
;
- InstancePredName = qualified(InstanceModule, InstancePred),
- (
- PredOrFunc = predicate,
- predicate_table_search_pred_m_n_a( PredicateTable,
- InstanceModule, InstancePred, PredArity,
- InstancePredIds)
- ;
- PredOrFunc = function,
- predicate_table_search_func_m_n_a( PredicateTable,
- InstanceModule, InstancePred, PredArity,
- InstancePredIds)
- )
- ).
+ InstancePredName = InstancePredName0
+ ),
+ module_info_get_predicate_table(ModuleInfo, PredicateTable),
+ predicate_table_search_pf_sym_arity(PredicateTable,
+ PredOrFunc, InstancePredName, PredArity, InstancePredIds).
:- pred handle_instance_method_overloading(module_info, list(var), list(type),
list(type), list(pair(list(mode), determinism)), list(pred_id),
@@ -347,7 +320,8 @@
invalid_pred_id(InstancePredId),
InstanceProcIds = [],
% XXX improve error message
- NewError = "instance method not found",
+ NewError =
+ "no type/mode-correct match for overloaded instance method name",
Errors = [NewError|Errors0]
;
% There is a single matching
@@ -361,7 +335,7 @@
invalid_pred_id(InstancePredId),
InstanceProcIds = [],
% XXX improve error message
- NewError = "unresolved overloading in instance method",
+ NewError = "ambiguous overloading in instance method",
Errors = [NewError|Errors0]
)
).
Index: compiler/clause_to_proc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/clause_to_proc.m,v
retrieving revision 1.20
diff -u -u -r1.20 clause_to_proc.m
--- clause_to_proc.m 1998/02/12 01:16:59 1.20
+++ clause_to_proc.m 1998/02/19 07:54:21
@@ -9,6 +9,7 @@
:- interface.
:- import_module hlds_pred, hlds_module.
+:- import_module list, std_util.
% In the hlds, we initially record the clauses for a predicate
% in the clauses_info data structure which is part of the
@@ -49,8 +50,9 @@
:- implementation.
-:- import_module hlds_goal, hlds_data, prog_data, make_hlds, globals.
-:- import_module int, list, set, map, std_util.
+:- import_module hlds_goal, hlds_data, prog_data, mode_util, make_hlds.
+:- import_module globals.
+:- import_module int, set, map.
maybe_add_default_modes(_, [], Preds, Preds).
maybe_add_default_modes(ModuleInfo, [PredId | PredIds], Preds0, Preds) :-
@@ -79,10 +81,8 @@
%
pred_info_arity(PredInfo0, PredArity),
FuncArity is PredArity - 1,
- InMode = user_defined_mode(
- qualified("mercury_builtin", "in"), []),
- OutMode = user_defined_mode(
- qualified("mercury_builtin", "out"), []),
+ in_mode(InMode),
+ out_mode(OutMode),
list__duplicate(FuncArity, InMode, FuncArgModes),
FuncRetMode = OutMode,
list__append(FuncArgModes, [FuncRetMode], PredArgModes),
Index: compiler/code_aux.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_aux.m,v
retrieving revision 1.52
diff -u -u -r1.52 code_aux.m
--- code_aux.m 1998/01/13 10:11:07 1.52
+++ code_aux.m 1998/02/19 07:55:02
@@ -15,8 +15,8 @@
:- interface.
-:- import_module code_info, hlds_goal.
-:- import_module varset.
+:- import_module code_info, hlds_module, hlds_goal.
+:- import_module bool, varset.
% code_aux__contains_only_builtins(G) is true if G is a leaf procedure,
% i.e. control does not leave G to call another procedure, even if
@@ -52,8 +52,8 @@
:- implementation.
-:- import_module hlds_module, llds, llds_out, type_util.
-:- import_module bool, string, set, term, std_util, assoc_list, require.
+:- import_module llds, llds_out, type_util.
+:- import_module string, set, term, std_util, assoc_list, require.
:- import_module list, map.
code_aux__contains_only_builtins(Goal - _GoalInfo) :-
Index: compiler/code_exprn.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_exprn.m,v
retrieving revision 1.56
diff -u -u -r1.56 code_exprn.m
--- code_exprn.m 1998/01/23 12:56:20 1.56
+++ code_exprn.m 1998/02/19 07:57:51
@@ -36,7 +36,8 @@
:- interface.
-:- import_module hlds_goal, llds, list, varset, assoc_list, options.
+:- import_module hlds_goal, llds, options.
+:- import_module map, set, list, term, varset, assoc_list.
:- type exprn_info.
@@ -244,7 +245,7 @@
:- implementation.
:- import_module exprn_aux, tree.
-:- import_module bool, map, bag, set, require, int, term, string, std_util.
+:- import_module bool, bag, require, int, term, string, std_util.
:- type var_stat ---> evaled(set(rval))
; cached(rval).
Index: compiler/code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.47
diff -u -u -r1.47 code_gen.m
--- code_gen.m 1998/02/10 02:04:48 1.47
+++ code_gen.m 1998/02/25 03:50:45
@@ -30,8 +30,8 @@
:- interface.
:- import_module hlds_module, hlds_pred, hlds_goal, llds, code_info.
-:- import_module continuation_info.
-:- import_module list, assoc_list, io.
+:- import_module continuation_info, globals.
+:- import_module set, list, assoc_list, term, io.
% Translate a HLDS structure into an LLDS
@@ -58,12 +58,12 @@
:- implementation.
:- import_module call_gen, unify_gen, ite_gen, switch_gen, disj_gen.
-:- import_module pragma_c_gen, trace, globals, options, hlds_out.
+:- import_module pragma_c_gen, trace, options, hlds_out.
:- import_module code_aux, middle_rec, passes_aux, llds_out.
:- import_module code_util, type_util, mode_util.
-:- import_module prog_data, instmap.
-:- import_module bool, char, int, string, list, term.
-:- import_module map, tree, std_util, require, set, varset.
+:- import_module prog_data, prog_out, instmap.
+:- import_module bool, char, int, string.
+:- import_module map, tree, std_util, require, varset.
%---------------------------------------------------------------------------%
@@ -436,8 +436,9 @@
{ predicate_module(ModuleInfo, PredId, ModuleName) },
{ predicate_name(ModuleInfo, PredId, PredName) },
{ predicate_arity(ModuleInfo, PredId, Arity) },
+ { prog_out__sym_name_to_string(ModuleName, ModuleNameString) },
{ string__int_to_string(Arity, ArityStr) },
- { string__append_list([ModuleName, ":", PredName, "/", ArityStr],
+ { string__append_list([ModuleNameString, ":", PredName, "/", ArityStr],
PushMsg) },
(
{ CodeModel = model_non }
Index: compiler/code_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.217
diff -u -u -r1.217 code_info.m
--- code_info.m 1998/02/03 08:18:16 1.217
+++ code_info.m 1998/02/25 03:53:59
@@ -33,16 +33,18 @@
:- interface.
-:- import_module hlds_pred, hlds_goal, llds, instmap, trace.
-:- import_module globals.
-:- import_module bool, set, std_util, assoc_list.
+:- import_module hlds_module, hlds_pred, hlds_goal, llds, instmap, trace.
+:- import_module continuation_info, prog_data, hlds_data, globals.
+
+:- import_module bool, set, varset, list, map, term, std_util, assoc_list.
:- implementation.
-:- import_module hlds_module, hlds_data, code_util.
-:- import_module code_exprn, set, varset, term, stack, prog_data.
-:- import_module continuation_info, type_util, mode_util, options.
-:- import_module string, require, char, list, map, bimap, tree, int.
+:- import_module code_util, code_exprn, prog_out.
+:- import_module type_util, mode_util, options.
+
+:- import_module set, varset, stack.
+:- import_module string, require, char, bimap, tree, int.
%---------------------------------------------------------------------------%
@@ -2016,8 +2018,9 @@
code_info__get_pred_id(PredId),
{ predicate_module(ModuleInfo, PredId, ModuleName) },
{ predicate_name(ModuleInfo, PredId, PredName) },
- { string__append_list(["commit in ", ModuleName, ":", PredName],
- Message) },
+ { prog_out__sym_name_to_string(ModuleName, ModuleNameString) },
+ { string__append_list(["commit in ",
+ ModuleNameString, ":", PredName], Message) },
{ PushCode = node([
incr_sp(NumSlots, Message) - SaveMessage
]) },
Index: compiler/code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_util.m,v
retrieving revision 1.94
diff -u -u -r1.94 code_util.m
--- code_util.m 1998/02/25 00:11:17 1.94
+++ code_util.m 1998/02/26 03:55:53
@@ -1,24 +1,24 @@
-%---------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
% Copyright (C) 1994-1998 The University of Melbourne.
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
-%---------------------------------------------------------------------------%
-%---------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
%
% file: code_util.m.
%
% various utilities routines for code generation and recognition
% of builtins.
%
-%---------------------------------------------------------------------------%
-%---------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- module code_util.
:- interface.
-:- import_module hlds_module, hlds_pred, hlds_goal, hlds_data, llds.
-:- import_module list.
+:- import_module hlds_module, hlds_pred, hlds_goal, hlds_data, prog_data, llds.
+:- import_module list, std_util, term.
% Create a code address which holds the address of the specified
% procedure.
@@ -110,7 +110,7 @@
% Each to be assigned rval is guaranteed to be either in a form
% acceptable for a test rval, or in the form of a variable.
-:- pred code_util__translate_builtin(string, string, proc_id, list(var),
+:- pred code_util__translate_builtin(module_name, string, proc_id, list(var),
maybe(rval), maybe(pair(var, rval))).
:- mode code_util__translate_builtin(in, in, in, in, out, out) is semidet.
@@ -333,18 +333,25 @@
BuiltinState = not_builtin
).
-:- pred code_util__inline_builtin(string, string, int, int).
+:- pred code_util__inline_builtin(module_name, string, int, int).
:- mode code_util__inline_builtin(in, in, in, in) is semidet.
-code_util__inline_builtin(ModuleName, PredName, ProcId, Arity) :-
+code_util__inline_builtin(FullyQualifiedModule, PredName, ProcId, Arity) :-
Arity =< 3,
varset__init(VarSet),
varset__new_vars(VarSet, Arity, Args, _),
+ % --- not yet:
+ % FullyQualifiedModule = qualified(unqualified("std"), ModuleName),
+ FullyQualifiedModule = unqualified(ModuleName),
code_util__translate_builtin_2(ModuleName, PredName, ProcId, Args, _, _).
-code_util__translate_builtin(Module, PredName, ProcId, Args, BinOp, AsgOp) :-
+code_util__translate_builtin(FullyQualifiedModule, PredName, ProcId, Args,
+ BinOp, AsgOp) :-
proc_id_to_int(ProcId, ProcInt),
- code_util__translate_builtin_2(Module, PredName, ProcInt, Args,
+ % -- not yet:
+ % FullyQualifiedModule = qualified(unqualified("std"), ModuleName),
+ FullyQualifiedModule = unqualified(ModuleName),
+ code_util__translate_builtin_2(ModuleName, PredName, ProcInt, Args,
BinOp, AsgOp).
:- pred code_util__translate_builtin_2(string, string, int, list(var),
Index: compiler/common.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/common.m,v
retrieving revision 1.48
diff -u -u -r1.48 common.m
--- common.m 1998/02/25 00:11:18 1.48
+++ common.m 1998/02/26 04:20:21
@@ -29,7 +29,8 @@
:- module common.
:- interface.
-:- import_module hlds_pred, simplify.
+:- import_module hlds_pred, hlds_goal, hlds_data, prog_data, simplify.
+:- import_module term, list.
% If we find a deconstruction or a construction we cannot optimize,
% record the details of the memory cell in CommonInfo.
@@ -78,10 +79,10 @@
:- implementation.
-:- import_module hlds_goal, hlds_data, quantification, mode_util, type_util.
+:- import_module quantification, mode_util, type_util, prog_util.
:- import_module det_util, det_report, globals, options, inst_match, instmap.
-:- import_module prog_data, hlds_module, (inst).
-:- import_module bool, term, map, set, list, eqvclass, require, std_util.
+:- import_module hlds_module, (inst).
+:- import_module bool, map, set, eqvclass, require, std_util.
:- type structure ---> structure(var, type, cons_id, list(var)).
@@ -602,7 +603,8 @@
% the input and output.
simplify_info_get_module_info(Info0, ModuleInfo),
module_info_get_predicate_table(ModuleInfo, PredTable),
- TypeCast = qualified("mercury_builtin", "unsafe_type_cast"),
+ mercury_private_builtin_module(MercuryBuiltin),
+ TypeCast = qualified(MercuryBuiltin, "unsafe_type_cast"),
(
predicate_table_search_pred_sym_arity(
PredTable, TypeCast, 2, [PredId])
Index: compiler/const_prop.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/const_prop.m,v
retrieving revision 1.4
diff -u -u -r1.4 const_prop.m
--- const_prop.m 1998/01/24 05:44:14 1.4
+++ const_prop.m 1998/02/25 02:23:41
@@ -16,7 +16,7 @@
:- interface.
-:- import_module hlds_goal, hlds_pred, instmap.
+:- import_module hlds_module, hlds_goal, hlds_pred, instmap.
:- import_module list, term.
:- pred evaluate_builtin(pred_id, proc_id, list(var), hlds_goal_info,
@@ -29,7 +29,7 @@
:- implementation.
:- import_module code_aux, det_analysis, follow_code, goal_util.
-:- import_module hlds_module, hlds_goal, hlds_data, instmap, inst_match.
+:- import_module hlds_goal, hlds_data, instmap, inst_match.
:- import_module globals, options, passes_aux, prog_data, mode_util, type_util.
:- import_module code_util, quantification, modes.
:- import_module bool, list, int, float, map, require.
@@ -57,8 +57,11 @@
% Module_info is not actually used at the moment.
-evaluate_builtin_2(Mod, Pred, ModeNum, Args, GoalInfo0, Goal, GoalInfo,
+evaluate_builtin_2(Module, Pred, ModeNum, Args, GoalInfo0, Goal, GoalInfo,
ModuleInfo, ModuleInfo) :-
+ % -- not yet:
+ % Module = qualified(unqualified("std"), Mod),
+ Module = unqualified(Mod),
(
Args = [X, Y],
evaluate_builtin_bi(Mod, Pred, ModeNum, X, Y, W, Cons)
Index: compiler/continuation_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/continuation_info.m,v
retrieving revision 1.9
diff -u -u -r1.9 continuation_info.m
--- continuation_info.m 1998/02/03 08:18:18 1.9
+++ continuation_info.m 1998/02/25 03:55:22
@@ -44,8 +44,8 @@
:- interface.
-:- import_module llds, hlds_pred, hlds_data.
-:- import_module list.
+:- import_module llds, hlds_pred, prog_data, hlds_data.
+:- import_module set, map, list, assoc_list, term, std_util.
%
% Information used by the continuation_info module.
@@ -182,8 +182,7 @@
:- implementation.
-:- import_module llds, prog_data.
-:- import_module map, list, assoc_list, std_util, term, set, require.
+:- import_module require.
% The continuation_info data structure
Index: compiler/dead_proc_elim.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dead_proc_elim.m,v
retrieving revision 1.37
diff -u -u -r1.37 dead_proc_elim.m
--- dead_proc_elim.m 1998/02/12 01:17:03 1.37
+++ dead_proc_elim.m 1998/02/25 03:55:43
@@ -18,7 +18,8 @@
:- interface.
-:- import_module hlds_module, io.
+:- import_module prog_data, hlds_module, hlds_pred.
+:- import_module map, std_util, io.
:- pred dead_proc_elim(module_info, module_info, io__state, io__state).
:- mode dead_proc_elim(in, out, di, uo) is det.
@@ -39,7 +40,7 @@
:- mode dead_pred_elim(in, out) is det.
:- type entity ---> proc(pred_id, proc_id)
- ; base_gen_info(string, string, int).
+ ; base_gen_info(module_name, string, int).
:- type needed_map == map(entity, maybe(int)).
@@ -47,9 +48,11 @@
%-----------------------------------------------------------------------------%
:- implementation.
-:- import_module hlds_pred, hlds_goal, hlds_data, prog_data, llds.
+
+:- import_module hlds_goal, hlds_data, prog_util, llds.
:- import_module passes_aux, globals, options, code_util.
-:- import_module int, string, list, set, queue, map, bool, std_util, require.
+
+:- import_module int, string, list, set, queue, bool, require.
%-----------------------------------------------------------------------------%
@@ -293,8 +296,8 @@
%-----------------------------------------------------------------------------%
-:- pred dead_proc_elim__examine_base_gen_info(string, string, int, module_info,
- entity_queue, entity_queue, needed_map, needed_map).
+:- pred dead_proc_elim__examine_base_gen_info(module_name, string, arity,
+ module_info, entity_queue, entity_queue, needed_map, needed_map).
:- mode dead_proc_elim__examine_base_gen_info(in, in, in, in, in, out, in, out)
is det.
@@ -312,7 +315,7 @@
Needed = Needed0
).
-:- pred dead_proc_elim__find_base_gen_info(string, string, int,
+:- pred dead_proc_elim__find_base_gen_info(module_name, string, arity,
list(base_gen_info), list(pred_proc_id)).
:- mode dead_proc_elim__find_base_gen_info(in, in, in, in, out) is semidet.
@@ -690,7 +693,9 @@
;
% Don't eliminate preds from mercury_builtin.m since
% polymorphism.m needs unify/2 and friends.
- PredModule = "mercury_builtin"
+ mercury_public_builtin_module(PredModule)
+ ;
+ mercury_private_builtin_module(PredModule)
;
% Don't attempt to eliminate local preds here, since we
% want to do semantic checking on those even if they
Index: compiler/delay_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/delay_info.m,v
retrieving revision 1.15
diff -u -u -r1.15 delay_info.m
--- delay_info.m 1998/01/23 12:56:24 1.15
+++ delay_info.m 1998/02/19 08:02:02
@@ -21,7 +21,7 @@
:- interface.
:- import_module hlds_goal, mode_errors.
-:- import_module term.
+:- import_module list, term.
%-----------------------------------------------------------------------------%
@@ -89,7 +89,7 @@
%-----------------------------------------------------------------------------%
:- implementation.
-:- import_module int, list, stack, set, map, require, std_util.
+:- import_module int, stack, set, map, require, std_util.
:- import_module mode_errors. % for the mode_error_info and delay_info
% types.
Index: compiler/dense_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dense_switch.m,v
retrieving revision 1.31
diff -u -u -r1.31 dense_switch.m
--- dense_switch.m 1998/01/23 12:56:26 1.31
+++ dense_switch.m 1998/02/19 08:10:30
@@ -17,6 +17,7 @@
:- interface.
:- import_module llds, prog_data, switch_gen, code_info, type_util.
+:- import_module hlds_data, hlds_goal.
:- import_module term.
% Should this switch be implemented as a dense jump table?
Index: compiler/det_analysis.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_analysis.m,v
retrieving revision 1.129
diff -u -u -r1.129 det_analysis.m
--- det_analysis.m 1998/02/12 01:17:05 1.129
+++ det_analysis.m 1998/02/25 03:55:57
@@ -52,7 +52,8 @@
:- interface.
-:- import_module hlds_module, hlds_pred, hlds_data, det_report, io.
+:- import_module hlds_module, hlds_pred, hlds_data, det_report, globals.
+:- import_module list, std_util, io.
% Perform determinism inference for local predicates with no
% determinism declarations, and determinism checking for all other
@@ -102,9 +103,9 @@
:- implementation.
:- import_module hlds_goal, prog_data, det_report, det_util.
-:- import_module type_util, mode_util, globals, options, passes_aux.
+:- import_module type_util, mode_util, options, passes_aux.
:- import_module hlds_out, mercury_to_mercury, instmap.
-:- import_module bool, list, map, set, std_util, require, term.
+:- import_module bool, map, set, require, term.
%-----------------------------------------------------------------------------%
Index: compiler/det_report.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_report.m,v
retrieving revision 1.48
diff -u -u -r1.48 det_report.m
--- det_report.m 1998/01/13 10:11:36 1.48
+++ det_report.m 1998/02/25 03:56:27
@@ -14,8 +14,9 @@
:- interface.
-:- import_module hlds_module, hlds_pred, hlds_goal, det_util, prog_data.
-:- import_module io.
+:- import_module hlds_module, hlds_pred, hlds_goal, hlds_data.
+:- import_module det_util, prog_data.
+:- import_module io, list, term, varset.
:- type det_msg --->
% warnings
@@ -107,7 +108,7 @@
:- import_module globals, options, prog_out, hlds_out, mercury_to_mercury.
:- import_module passes_aux.
-:- import_module bool, int, list, map, set, varset, std_util, term, require.
+:- import_module bool, int, map, set, std_util, require.
%-----------------------------------------------------------------------------%
Index: compiler/det_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_util.m,v
retrieving revision 1.15
diff -u -u -r1.15 det_util.m
--- det_util.m 1998/02/12 01:17:07 1.15
+++ det_util.m 1998/02/19 08:12:35
@@ -18,7 +18,7 @@
:- import_module hlds_module, hlds_pred, hlds_goal, hlds_data, globals.
:- import_module instmap.
-:- import_module bool, set, list.
+:- import_module bool, set, list, term.
:- type maybe_changed ---> changed ; unchanged.
@@ -89,7 +89,7 @@
:- implementation.
:- import_module inst_match, mode_util, type_util, options.
-:- import_module map, term, require, std_util.
+:- import_module map, require, std_util.
update_instmap(_Goal0 - GoalInfo0, InstMap0, InstMap) :-
goal_info_get_instmap_delta(GoalInfo0, DeltaInstMap),
Index: compiler/disj_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/disj_gen.m,v
retrieving revision 1.61
diff -u -u -r1.61 disj_gen.m
--- disj_gen.m 1998/01/23 12:56:27 1.61
+++ disj_gen.m 1998/02/19 08:13:19
@@ -21,6 +21,7 @@
:- interface.
:- import_module hlds_goal, llds, code_info.
+:- import_module list.
:- pred disj_gen__generate_det_disj(list(hlds_goal), store_map,
code_tree, code_info, code_info).
@@ -39,7 +40,7 @@
:- implementation.
:- import_module hlds_data, code_gen, code_util, trace, options, globals.
-:- import_module bool, set, tree, list, map, std_util, require.
+:- import_module bool, set, tree, map, std_util, require.
%---------------------------------------------------------------------------%
Index: compiler/dnf.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dnf.m,v
retrieving revision 1.28
diff -u -u -r1.28 dnf.m
--- dnf.m 1998/01/13 10:11:41 1.28
+++ dnf.m 1998/02/25 02:15:43
@@ -43,7 +43,8 @@
:- interface.
-:- import_module hlds_module, hlds_pred, set.
+:- import_module hlds_module, hlds_pred.
+:- import_module set, list, bool, std_util.
:- pred dnf__transform_module(module_info::in, bool::in,
maybe(set(pred_proc_id))::in, module_info::out) is det.
@@ -59,7 +60,7 @@
:- import_module hlds_goal, hlds_data, prog_data, instmap.
:- import_module excess, make_hlds, mode_util.
-:- import_module require, map, list, string, int, bool, std_util, term, varset.
+:- import_module require, map, string, int, term, varset.
% Traverse the module structure.
Index: compiler/equiv_type.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/equiv_type.m,v
retrieving revision 1.13
diff -u -u -r1.13 equiv_type.m
--- equiv_type.m 1998/01/14 05:31:53 1.13
+++ equiv_type.m 1998/02/19 08:16:54
@@ -11,7 +11,7 @@
:- module equiv_type.
:- interface.
-:- import_module prog_data, list, io.
+:- import_module bool, prog_data, list, io.
%-----------------------------------------------------------------------------%
Index: compiler/export.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/export.m,v
retrieving revision 1.18
diff -u -u -r1.18 export.m
--- export.m 1998/01/09 11:43:47 1.18
+++ export.m 1998/02/16 06:48:12
@@ -28,7 +28,8 @@
% Produce a header file containing prototypes for the exported C
% functions
-:- pred export__produce_header_file(module_info, string, io__state, io__state).
+:- pred export__produce_header_file(module_info, module_name,
+ io__state, io__state).
:- mode export__produce_header_file(in, in, di, uo) is det.
% Convert the term, which represents a type, to a string corresponding
@@ -58,7 +59,8 @@
:- implementation.
-:- import_module code_gen, code_util, hlds_pred, llds, llds_out.
+:- import_module code_gen, code_util, hlds_pred, llds, llds_out, modules.
+
:- import_module library, map, int, string, std_util, assoc_list, require.
:- import_module bool.
@@ -447,7 +449,8 @@
->
{ module_info_get_predicate_table(Module, PredicateTable) },
{ predicate_table_get_preds(PredicateTable, Preds) },
- { string__append(ModuleName, ".h", FileName) },
+ { module_name_to_file_name(ModuleName, BaseFileName) },
+ { string__append(BaseFileName, ".h", FileName) },
io__tell(FileName, Result),
(
{ Result = ok }
@@ -455,15 +458,19 @@
{ library__version(Version) },
io__write_strings(
["/*\n** Automatically generated from `",
- ModuleName,
+ BaseFileName,
".m' by the\n** Mercury compiler, version ",
Version,
". Do not edit.\n*/\n"]),
- { string__to_upper(ModuleName, UpperModuleName) },
- { string__append(UpperModuleName, "_H", UpperFileName) },
+ { llds_out__sym_name_mangle(ModuleName,
+ MangledModuleName) },
+ { string__to_upper(MangledModuleName,
+ UppercaseModuleName) },
+ { string__append(UppercaseModuleName, "_H",
+ GuardMacroName) },
io__write_strings([
- "#ifndef ", UpperFileName, "\n",
- "#define ", UpperFileName, "\n",
+ "#ifndef ", GuardMacroName, "\n",
+ "#define ", GuardMacroName, "\n",
"\n",
"#ifdef __cplusplus\n",
"extern ""C"" {\n",
@@ -478,7 +485,7 @@
"}\n",
"#endif\n",
"\n",
- "#endif /* ", UpperFileName, " */\n"]),
+ "#endif /* ", GuardMacroName, " */\n"]),
io__told
;
io__progname_base("export.m", ProgName),
Index: compiler/fact_table.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/fact_table.m,v
retrieving revision 1.16
diff -u -u -r1.16 fact_table.m
--- fact_table.m 1998/02/12 01:17:10 1.16
+++ fact_table.m 1998/02/16 06:48:12
@@ -88,7 +88,9 @@
:- import_module int, map, std_util, assoc_list, char, require, library, bool.
:- import_module float, math, getopt, term, string.
-:- import_module parser, prog_out, term_io, llds_out, hlds_out, hlds_data.
+:- import_module parser, term_io.
+
+:- import_module prog_util, prog_out, llds_out, hlds_out, hlds_data.
:- import_module globals, options, passes_aux, arg_info, llds, mode_util.
:- import_module code_util, export, inst_match.
@@ -348,11 +350,7 @@
term__functor(Const, Terms0, Context), FactArgInfos, ProcStreams,
MaybeOutput, FactNum, Result) -->
{ pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
- (
- { PredName = unqualified(PredString) }
- ;
- { PredName = qualified(_, PredString) }
- ),
+ { unqualify_name(PredName, PredString) },
(
{ Const = term__atom(TopLevel) }
->
@@ -2414,14 +2412,9 @@
%---------------------------------------------------------------------------%
:- pred make_fact_table_identifier(sym_name::in, string::out) is det.
-make_fact_table_identifier(qualified(ModuleName, PredName), Identifier) :-
- llds_out__name_mangle(ModuleName, MangledModuleName),
- llds_out__name_mangle(PredName, MangledPredName),
- llds_out__qualify_name(MangledModuleName, MangledPredName,
- Identifier).
+make_fact_table_identifier(SymName, Identifier) :-
+ llds_out__sym_name_mangle(SymName, Identifier).
-make_fact_table_identifier(unqualified(PredName), Identifier) :-
- llds_out__name_mangle(PredName, Identifier).
%---------------------------------------------------------------------------%
% Delete a file. Report an error message if something goes wrong.
Index: compiler/follow_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/follow_code.m,v
retrieving revision 1.47
diff -u -u -r1.47 follow_code.m
--- follow_code.m 1998/01/13 10:11:56 1.47
+++ follow_code.m 1998/02/25 02:24:20
@@ -13,7 +13,8 @@
:- interface.
-:- import_module hlds_module, hlds_pred.
+:- import_module hlds_module, hlds_pred, hlds_goal.
+:- import_module list.
:- pred move_follow_code_in_proc(proc_info, proc_info,
module_info, module_info).
@@ -30,10 +31,9 @@
:- implementation.
-:- import_module hlds_goal, hlds_data, goal_util, mode_util.
+:- import_module hlds_data, goal_util, mode_util.
:- import_module globals, options, det_analysis, quantification.
-:- import_module bool, list, map, set.
-:- import_module term, std_util, require.
+:- import_module bool, map, set, term, std_util, require.
%-----------------------------------------------------------------------------%
Index: compiler/follow_vars.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/follow_vars.m,v
retrieving revision 1.47
diff -u -u -r1.47 follow_vars.m
--- follow_vars.m 1998/02/12 01:17:12 1.47
+++ follow_vars.m 1998/02/25 02:14:04
@@ -29,7 +29,7 @@
:- interface.
-:- import_module hlds_module, hlds_pred.
+:- import_module hlds_module, hlds_pred, hlds_goal.
:- pred find_final_follow_vars(proc_info, follow_vars).
:- mode find_final_follow_vars(in, out) is det.
@@ -43,7 +43,7 @@
:- implementation.
-:- import_module hlds_goal, hlds_data, llds, mode_util.
+:- import_module hlds_data, llds, mode_util.
:- import_module code_util, quantification, arg_info, globals.
:- import_module bool, list, map, set, std_util, term, require.
Index: compiler/goal_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/goal_util.m,v
retrieving revision 1.42
diff -u -u -r1.42 goal_util.m
--- goal_util.m 1998/02/12 01:17:13 1.42
+++ goal_util.m 1998/02/25 04:06:26
@@ -26,8 +26,8 @@
:- interface.
-:- import_module hlds_goal, hlds_pred.
-:- import_module bool, list, map.
+:- import_module hlds_goal, hlds_pred, prog_data.
+:- import_module bool, list, set, map, varset, term.
% goal_util__rename_vars_in_goals(GoalList, MustRename, Substitution,
% NewGoalList).
@@ -78,8 +78,8 @@
:- implementation.
-:- import_module hlds_data, mode_util, code_aux, prog_data, instmap.
-:- import_module int, set, std_util, assoc_list, term, require, varset.
+:- import_module hlds_data, mode_util, code_aux, instmap.
+:- import_module int, std_util, assoc_list, require.
%-----------------------------------------------------------------------------%
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.44
diff -u -u -r1.44 handle_options.m
--- handle_options.m 1998/02/09 10:23:41 1.44
+++ handle_options.m 1998/02/18 15:36:06
@@ -67,6 +67,8 @@
globals__io_lookup_bool_option(generate_dependencies,
GenerateDependencies),
globals__io_lookup_bool_option(make_interface, MakeInterface),
+ globals__io_lookup_bool_option(make_private_interface,
+ MakePrivateInterface),
globals__io_lookup_bool_option(make_short_interface,
MakeShortInterface),
globals__io_lookup_bool_option(make_optimization_interface,
@@ -81,8 +83,9 @@
globals__io_lookup_bool_option(errorcheck_only, ErrorcheckOnly),
globals__io_lookup_bool_option(compile_to_c, CompileToC),
globals__io_lookup_bool_option(compile_only, CompileOnly),
- { bool__or_list([GenerateDependencies, MakeTransOptInt,
- MakeInterface, MakeShortInterface, MakeOptimizationInt,
+ { bool__or_list([GenerateDependencies, MakeInterface,
+ MakePrivateInterface, MakeShortInterface,
+ MakeOptimizationInt, MakeTransOptInt,
ConvertToMercury, ConvertToGoedel, TypecheckOnly,
ErrorcheckOnly, CompileToC, CompileOnly], NotLink) },
{ bool__not(NotLink, Link) }
Index: compiler/higher_order.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/higher_order.m,v
retrieving revision 1.41
diff -u -u -r1.41 higher_order.m
--- higher_order.m 1998/02/12 01:17:15 1.41
+++ higher_order.m 1998/02/16 06:48:12
@@ -32,7 +32,7 @@
:- import_module hlds_pred, hlds_goal, hlds_data, instmap, (inst).
:- import_module code_util, globals, make_hlds, mode_util, goal_util.
-:- import_module type_util, options, prog_data, quantification.
+:- import_module type_util, options, prog_data, prog_out, quantification.
:- import_module mercury_to_mercury.
:- import_module assoc_list, bool, char, int, list, map, require, set.
@@ -805,8 +805,10 @@
(
VeryVerbose = yes
->
- io__write_strings(["% Specializing calls to `", PredModule, ":",
- Name0, "'/", ArStr, " with higher-order arguments:\n"],
+ prog_out__sym_name_to_string(PredModule, PredModuleString),
+ io__write_strings(["% Specializing calls to `",
+ PredModuleString, ":", Name0, "'/", ArStr,
+ " with higher-order arguments:\n"],
IOState1, IOState2),
list__length(Types0, ActualArity),
NumToDrop is ActualArity - Arity,
Index: compiler/hlds_data.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_data.m,v
retrieving revision 1.21
diff -u -u -r1.21 hlds_data.m
--- hlds_data.m 1998/01/23 12:56:33 1.21
+++ hlds_data.m 1998/02/25 04:07:11
@@ -14,7 +14,7 @@
:- interface.
:- import_module hlds_pred, llds, prog_data, (inst).
-:- import_module bool, list, map, varset.
+:- import_module bool, list, map, varset, term, std_util.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -34,9 +34,9 @@
% Used for constructing type_infos.
% Note that a pred_const is for a closure
% whereas a code_addr_const is just an address.
- ; base_type_info_const(string, string, int)
+ ; base_type_info_const(module_name, string, int)
% module name, type name, type arity
- ; base_typeclass_info_const(string, class_id,
+ ; base_typeclass_info_const(module_name, class_id,
string)
% name of module containing instance
% declaration, class name and arity, a string
@@ -95,7 +95,7 @@
:- implementation.
:- import_module prog_util.
-:- import_module require, std_util, term.
+:- import_module require.
cons_id_and_args_to_term(int_const(Int), [], Term) :-
term__context_init(Context),
@@ -128,7 +128,14 @@
make_functor_cons_id(term__float(Float), _, float_const(Float)).
make_cons_id(SymName0, Args, TypeId, cons(SymName, Arity)) :-
+ % Use the module qualifier on the SymName, if there is one,
+ % otherwise use the module qualifier on the Type, if there is one,
+ % otherwise leave it unqualified.
+ % XXX is that the right thing to do?
(
+ SymName0 = qualified(_, _),
+ SymName = SymName0
+ ;
SymName0 = unqualified(ConsName),
(
TypeId = unqualified(_) - _,
@@ -137,9 +144,6 @@
TypeId = qualified(TypeModule, _) - _,
SymName = qualified(TypeModule, ConsName)
)
- ;
- SymName0 = qualified(_, _),
- SymName = SymName0
),
list__length(Args, Arity).
@@ -244,13 +248,12 @@
% (used for constructing type_infos).
% The word just contains the address of the
% specified procedure.
- ; base_type_info_constant(string, string, int)
+ ; base_type_info_constant(module_name, string, arity)
% This is how we refer to base_type_info structures
- % represented as global data. The two strings are
- % the name of the module the type is defined in
- % and the name of the type, while the integer is
- % the arity.
- ; base_typeclass_info_constant(string, class_id, string)
+ % represented as global data. The args are
+ % the name of the module the type is defined in,
+ % and the name of the type, and its arity.
+ ; base_typeclass_info_constant(module_name, class_id, string)
% This is how we refer to base_typeclass_info structures
% represented as global data. The first argument is the
% name of the module containing the instance declration,
Index: compiler/hlds_goal.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.48
diff -u -u -r1.48 hlds_goal.m
--- hlds_goal.m 1998/02/12 01:17:16 1.48
+++ hlds_goal.m 1998/02/25 02:34:35
@@ -13,7 +13,7 @@
:- interface.
:- import_module hlds_data, hlds_pred, llds, prog_data, (inst), instmap.
-:- import_module list, set, map, std_util.
+:- import_module list, set, map, term, std_util.
% Here is how goals are represented
@@ -686,7 +686,7 @@
:- implementation.
-:- import_module require, term.
+:- import_module require.
goal_info_init(GoalInfo) :-
Detism = erroneous,
Index: compiler/hlds_module.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_module.m,v
retrieving revision 1.30
diff -u -u -r1.30 hlds_module.m
--- hlds_module.m 1998/01/05 07:26:14 1.30
+++ hlds_module.m 1998/02/25 07:09:42
@@ -21,14 +21,15 @@
:- interface.
-:- import_module hlds_pred, unify_proc, special_pred.
-:- import_module relation, globals, continuation_info.
+:- import_module hlds_pred, hlds_data, prog_data, unify_proc, special_pred.
+:- import_module globals, llds, continuation_info.
+:- import_module relation, map, std_util, list, set.
:- implementation.
-:- import_module hlds_data, hlds_out, llds, prog_data, prog_util.
+:- import_module hlds_out, prog_out, prog_data, prog_util.
:- import_module typecheck.
-:- import_module bool, require, int, string, list, map, set, std_util.
+:- import_module bool, require, int, string, set.
%-----------------------------------------------------------------------------%
@@ -55,7 +56,7 @@
:- type base_gen_info
---> base_gen_info(
type_id,
- string, % module name
+ module_name, % module name
string, % type name
int, % type arity
import_status, % of the type
@@ -73,7 +74,7 @@
:- type base_gen_layout
---> base_gen_layout(
type_id,
- string, % module name
+ module_name, % module name
string, % type name
int, % type arity
import_status, % of the type
@@ -89,7 +90,7 @@
% Create an empty module_info for a given module name (and the
% global options).
-:- pred module_info_init(string, globals, module_info).
+:- pred module_info_init(module_name, globals, module_info).
:- mode module_info_init(in, in, out) is det.
:- pred module_info_get_predicate_table(module_info, predicate_table).
@@ -164,7 +165,7 @@
%-----------------------------------------------------------------------------%
-:- pred module_info_name(module_info, string).
+:- pred module_info_name(module_info, module_name).
:- mode module_info_name(in, out) is det.
:- pred module_info_globals(module_info, globals).
@@ -348,7 +349,7 @@
maybe(dependency_info), module_info).
:- mode module_info_set_maybe_dependency_info(in, in, out) is det.
-:- pred module_sub_get_name(module_sub_info, string).
+:- pred module_sub_get_name(module_sub_info, module_name).
:- mode module_sub_get_name(in, out) is det.
:- pred module_sub_get_globals(module_sub_info, globals).
@@ -452,7 +453,7 @@
:- type module_sub_info
---> module_sub(
- string, % module name
+ module_name, % module name
globals, % global options
c_header_info,
c_body_info,
@@ -502,7 +503,7 @@
% :- type module_sub_info
% ---> module_sub(
-% A string, % module name
+% A module_name, % module name
% B globals, % global options
% C c_header_info,
% D c_body_info,
@@ -1160,10 +1161,16 @@
% When searching for functions, the arity used
% is the arity of the function, not the arity N+1 predicate
% that it gets converted to.
- % Note that in cases (b) and (c) there should be at most
- % one matching pred_id, since under the current overloading
- % rules each predicate or function can be uniquely identified
+ %
+ % Note that in cases (b) and (c) it was previously the case
+ % that there could only be one matching pred_id, since
+ % each predicate or function could be uniquely identified
% by its module, name, arity, and category (function/predicate).
+ % However this is no longer true, due to nested modules.
+ % (For example, `pred foo:bar/2' might match both
+ % `pred mod1:foo:bar/2' and `pred mod2:foo:bar/2').
+ % I hope it doesn't break anything too badly...
+ %
% (`m_n_a' here is short for "module, name, arity".)
:- pred predicate_table_search_m_n_a(predicate_table, module_name, string,
@@ -1353,7 +1360,7 @@
PredN0, PredNA0, PredMNA0, FuncN, FuncNA, FuncMNA)
).
-:- pred predicate_table_remove_from_index(string, string, int, pred_id,
+:- pred predicate_table_remove_from_index(module_name, string, int, pred_id,
name_index, name_index, name_arity_index, name_arity_index,
module_name_arity_index, module_name_arity_index).
:- mode predicate_table_remove_from_index(in, in, in, in, in, out,
@@ -1382,7 +1389,7 @@
).
:- pred do_remove_from_m_n_a_index(module_name_arity_index,
- string, string, int, pred_id, module_name_arity_index).
+ module_name, string, int, pred_id, module_name_arity_index).
:- mode do_remove_from_m_n_a_index(in, in, in, in, in, out) is det.
do_remove_from_m_n_a_index(MNA0, Module, Name, Arity, PredId, MNA) :-
@@ -1769,20 +1776,11 @@
module_info_get_predicate_table(ModuleInfo, PredicateTable),
list__length(ArgTypes, Arity),
(
- (
- % In this case there is no overloading to resolve,
- % so just look up the pred_id.
- SymName = qualified(Module, Name),
- predicate_table_search_pf_m_n_a(PredicateTable,
- PredOrFunc, Module, Name, Arity, [PredId0])
- ;
- % Resolve overloading using the arguments types.
- SymName = unqualified(Name),
- predicate_table_search_pf_name_arity(PredicateTable,
- PredOrFunc, Name, Arity, PredIds),
- typecheck__find_matching_pred_id(PredIds, ModuleInfo,
- TVarSet, ArgTypes, PredId0, _PredName)
- )
+ predicate_table_search_pf_sym_arity(PredicateTable,
+ PredOrFunc, SymName, Arity, PredIds),
+ % Resolve overloading using the argument types.
+ typecheck__find_matching_pred_id(PredIds, ModuleInfo,
+ TVarSet, ArgTypes, PredId0, _PredName)
->
PredId = PredId0,
get_proc_id(PredicateTable, PredId, ProcId)
@@ -1790,7 +1788,7 @@
% Undefined/invalid pred or func.
% the type-checker should ensure that this never happens
hlds_out__pred_or_func_to_str(PredOrFunc, PredOrFuncStr),
- unqualify_name(SymName, Name2),
+ prog_out__sym_name_to_string(SymName, Name2),
string__int_to_string(Arity, ArityString),
string__append_list(
["get_pred_id_and_proc_id: ",
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.189
diff -u -u -r1.189 hlds_out.m
--- hlds_out.m 1998/02/12 01:17:18 1.189
+++ hlds_out.m 1998/02/25 03:57:25
@@ -35,7 +35,7 @@
:- import_module hlds_module, hlds_pred, hlds_goal, hlds_data.
:- import_module prog_data, llds.
-:- import_module io.
+:- import_module io, bool, term, map, list, varset.
%-----------------------------------------------------------------------------%
@@ -177,11 +177,11 @@
:- import_module mercury_to_mercury, globals, options, purity, special_pred.
:- import_module llds_out, prog_out, prog_util, (inst), instmap, trace.
-
-:- import_module bool, int, string, list, set, map, std_util, assoc_list.
-:- import_module term, term_io, varset, require, getopt.
:- import_module termination, term_errors.
+:- import_module int, string, set, std_util, assoc_list.
+:- import_module term_io, require, getopt.
+
hlds_out__write_type_id(Name - Arity) -->
prog_out__write_sym_name(Name),
@@ -189,15 +189,9 @@
io__write_int(Arity).
hlds_out__cons_id_to_string(cons(SymName, Arity), String) :-
+ prog_out__sym_name_to_string(SymName, SymNameString),
string__int_to_string(Arity, ArityString),
- (
- SymName = unqualified(Name),
- string__append_list(["'", Name, "'/", ArityString], String)
- ;
- SymName = qualified(Module, Name),
- string__append_list(["'", Module, ":",
- Name, "'/", ArityString], String)
- ).
+ string__append_list([SymNameString, "/", ArityString], String).
hlds_out__cons_id_to_string(int_const(Int), String) :-
string__int_to_string(Int, String).
hlds_out__cons_id_to_string(string_const(String), S) :-
@@ -210,14 +204,7 @@
"<base_typeclass_info>").
hlds_out__write_cons_id(cons(SymName, Arity)) -->
- (
- { SymName = qualified(Module, Name) },
- io__write_string(Module),
- io__write_string(":")
- ;
- { SymName = unqualified(Name) }
- ),
- io__write_string(Name),
+ prog_out__write_sym_name(SymName),
io__write_string("/"),
io__write_int(Arity).
hlds_out__write_cons_id(int_const(Int)) -->
@@ -260,7 +247,7 @@
;
hlds_out__write_pred_or_func(PredOrFunc),
io__write_string(" `"),
- io__write_string(Module),
+ prog_out__write_sym_name(Module),
io__write_string(":"),
{ PredOrFunc = function ->
OrigArity is Arity - 1
@@ -291,14 +278,7 @@
io__write_string("'").
hlds_out__write_pred_call_id(Name / Arity) -->
- ( { Name = qualified(ModuleName, _) } ->
- io__write_string(ModuleName),
- io__write_char(':')
- ;
- []
- ),
- { unqualify_name(Name, PredName) },
- io__write_string(PredName),
+ prog_out__write_sym_name(Name),
io__write_char('/'),
io__write_int(Arity).
@@ -404,7 +384,7 @@
{ module_info_name(Module, Name) },
hlds_out__write_indent(Indent),
io__write_string(":- module "),
- io__write_string(Name),
+ prog_out__write_sym_name(Name),
io__write_string(".\n").
:- pred hlds_out__write_footer(int, module_info, io__state, io__state).
@@ -414,7 +394,7 @@
{ module_info_name(Module, Name) },
hlds_out__write_indent(Indent),
io__write_string(":- end_module "),
- io__write_string(Name),
+ prog_out__write_sym_name(Name),
io__write_string(".\n").
:- pred hlds_out__write_preds(int, module_info, pred_table,
@@ -1428,13 +1408,13 @@
{ Term = term__functor(Functor, ArgTerms, Context) },
mercury_output_term(Term, VarSet, AppendVarnums).
-:- pred hlds_out__write_qualified_functor(string, const, list(var), varset,
- bool, io__state, io__state).
+:- pred hlds_out__write_qualified_functor(module_name, const, list(var),
+ varset, bool, io__state, io__state).
:- mode hlds_out__write_qualified_functor(in, in, in, in, in, di, uo) is det.
hlds_out__write_qualified_functor(ModuleName, Functor, ArgVars, VarSet,
AppendVarnums) -->
- io__write_string(ModuleName),
+ prog_out__write_sym_name(ModuleName),
io__write_string(":"),
hlds_out__write_functor(Functor, ArgVars, VarSet, AppendVarnums).
@@ -1472,7 +1452,7 @@
;
{ ConsId = base_type_info_const(Module, Name, Arity) },
io__write_string("base_type_info("""),
- io__write_string(Module),
+ prog_out__write_sym_name(Module),
io__write_string(""", """),
io__write_string(Name),
io__write_string(""", "),
@@ -1482,7 +1462,7 @@
{ ConsId = base_typeclass_info_const(Module,
class_id(Name, Arity), Instance) },
io__write_string("base_typeclass_info("""),
- io__write_string(Module),
+ prog_out__write_sym_name(Module),
io__write_string(""", """),
io__write_string("class_id("),
prog_out__write_sym_name(Name),
Index: compiler/hlds_pred.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.45
diff -u -u -r1.45 hlds_pred.m
--- hlds_pred.m 1998/02/12 01:17:20 1.45
+++ hlds_pred.m 1998/02/25 04:07:30
@@ -15,13 +15,13 @@
:- import_module hlds_data, hlds_goal, hlds_module, llds, prog_data, instmap.
:- import_module purity, globals.
-:- import_module bool, list, map, std_util, term, varset.
+:- import_module bool, list, set, map, std_util, term, varset.
:- import_module term_util.
:- implementation.
:- import_module make_hlds, prog_util, mode_util, type_util.
-:- import_module int, string, set, require, assoc_list.
+:- import_module int, string, require, assoc_list.
%-----------------------------------------------------------------------------%
Index: compiler/inlining.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/inlining.m,v
retrieving revision 1.73
diff -u -u -r1.73 inlining.m
--- inlining.m 1998/01/13 10:12:18 1.73
+++ inlining.m 1998/02/19 08:18:58
@@ -81,7 +81,7 @@
%-----------------------------------------------------------------------------%
:- interface.
-:- import_module hlds_module.
+:- import_module hlds_goal, hlds_module.
:- import_module io.
:- pred inlining(module_info, module_info, io__state, io__state).
@@ -95,7 +95,7 @@
:- implementation.
-:- import_module hlds_pred, hlds_goal, globals, options, llds.
+:- import_module hlds_pred, globals, options, llds.
:- import_module dead_proc_elim, type_util, mode_util, goal_util.
:- import_module passes_aux, code_aux, quantification, det_analysis, prog_data.
Index: compiler/inst_match.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/inst_match.m,v
retrieving revision 1.40
diff -u -u -r1.40 inst_match.m
--- inst_match.m 1998/01/16 06:44:36 1.40
+++ inst_match.m 1998/02/19 08:21:04
@@ -39,7 +39,8 @@
:- interface.
-:- import_module hlds_module, (inst).
+:- import_module hlds_module, prog_data, (inst).
+:- import_module list, term.
%-----------------------------------------------------------------------------%
Index: compiler/inst_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/inst_util.m,v
retrieving revision 1.10
diff -u -u -r1.10 inst_util.m
--- inst_util.m 1998/02/13 10:12:16 1.10
+++ inst_util.m 1998/02/25 02:51:48
@@ -41,7 +41,8 @@
:- module inst_util.
:- interface.
-:- import_module hlds_module, prog_data, (inst).
+:- import_module hlds_module, hlds_data, prog_data, (inst).
+:- import_module list.
:- pred abstractly_unify_inst(is_live, inst, inst, unify_is_real, module_info,
inst, determinism, module_info).
Index: compiler/instmap.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/instmap.m,v
retrieving revision 1.19
diff -u -u -r1.19 instmap.m
--- instmap.m 1998/02/13 10:12:17 1.19
+++ instmap.m 1998/02/25 03:58:03
@@ -18,8 +18,11 @@
:- module instmap.
:- interface.
-:- import_module hlds_module, prog_data, mode_info, (inst).
-:- import_module set, term.
+
+:- import_module hlds_module, prog_data, mode_info, (inst), mode_errors.
+:- import_module hlds_data.
+
+:- import_module map, bool, set, term, list, assoc_list.
:- type instmap.
:- type instmap_delta.
@@ -262,9 +265,10 @@
:- implementation.
-:- import_module mode_util, inst_match, prog_data, mode_errors, goal_util.
+:- import_module mode_util, inst_match, prog_data, goal_util.
:- import_module hlds_data, inst_util.
-:- import_module list, std_util, bool, map, set, assoc_list, require.
+
+:- import_module std_util, require.
:- type instmap_delta == instmap.
Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.45
diff -u -u -r1.45 intermod.m
--- intermod.m 1998/02/18 23:41:55 1.45
+++ intermod.m 1998/02/26 03:56:00
@@ -18,7 +18,7 @@
% - pragma declarations for the exported preds.
% - pragma c_header declarations if any pragma_c_code preds are written.
% All these items should be module qualified.
-% Constructors should be explicitly type qualified.
+% Constructors should be explicitly type qualified. (XXX why?)
%
% This module also contains predicates to read in the .opt files and
% to adjust the import status of local predicates which are exported for
@@ -37,7 +37,7 @@
:- interface.
-:- import_module io.
+:- import_module io, bool.
:- import_module hlds_module, modules.
:- pred intermod__write_optfile(module_info, module_info,
@@ -60,7 +60,7 @@
:- implementation.
-:- import_module assoc_list, bool, dir, getopt, int, list, map, require, set.
+:- import_module assoc_list, dir, getopt, int, list, map, require, set.
:- import_module std_util, string, term, varset.
:- import_module code_util, globals, goal_util.
@@ -80,7 +80,8 @@
intermod__write_optfile(ModuleInfo0, ModuleInfo) -->
{ module_info_name(ModuleInfo0, ModuleName) },
- { string__append(ModuleName, ".opt.tmp", TmpName) },
+ { module_name_to_file_name(ModuleName, BaseFileName) },
+ { string__append(BaseFileName, ".opt.tmp", TmpName) },
io__tell(TmpName, Result2),
(
{ Result2 = error(Err2) },
@@ -573,15 +574,12 @@
TVarSet, ArgTypes, ModuleInfo, PredId, _ProcId) },
intermod_info_add_proc(PredId, DoWrite),
%
- % Module-qualify it, if necessary.
+ % Module-qualify it.
%
- { PredName = unqualified(UnqualPredName) ->
- predicate_module(ModuleInfo, PredId, Module),
- QualifiedPredName = qualified(Module, UnqualPredName),
- Functor = cons(QualifiedPredName, Arity)
- ;
- Functor = Functor0
- }
+ { unqualify_name(PredName, UnqualPredName) },
+ { predicate_module(ModuleInfo, PredId, Module) },
+ { QualifiedPredName = qualified(Module, UnqualPredName) },
+ { Functor = cons(QualifiedPredName, Arity) }
;
%
% Is it an unqualified functor symbol?
@@ -594,6 +592,8 @@
{ Functor = cons(qualified(TypeModule, ConsName), ConsArity) },
{ DoWrite = yes }
;
+ % XXX for (perhaps partially) qualified functor symbols,
+ % should we still add the module qualifier from the type?
{ Functor = Functor0 },
{ DoWrite = yes }
).
@@ -722,7 +722,7 @@
{ set__to_sorted_list(Insts0, Insts) },
{ module_info_name(ModuleInfo, ModName) },
io__write_string(":- module "),
- mercury_output_bracketed_constant(term__atom(ModName)),
+ mercury_output_bracketed_sym_name(ModName),
io__write_string(".\n"),
( { Modules \= [] } ->
io__write_string(":- use_module "),
@@ -757,7 +757,7 @@
intermod__write_modules([]) --> [].
intermod__write_modules([Module | Rest]) -->
- mercury_output_bracketed_constant(term__atom(Module)),
+ mercury_output_bracketed_sym_name(Module),
(
{ Rest = [] },
io__write_string(".\n")
@@ -1229,27 +1229,36 @@
% Read in and process the optimization interfaces.
intermod__grab_optfiles(Module0, Module, FoundError) -->
- { Module0 = module_imports(ModuleName, DirectImports0,
- IndirectImports0, Items0, _) },
- { list__sort_and_remove_dups(DirectImports0, DirectImports1) },
- read_optimization_interfaces(DirectImports1, [],
- OptItems, no, OptError),
+ %
+ % Let make_hlds know the opt_imported stuff is coming.
+ %
+ { append_pseudo_decl(Module0, opt_imported, Module1) },
+ { module_imports_get_items(Module1, Items0) },
+
+ %
+ % Read in the .opt files for imported and ancestor modules.
+ %
+ { Module1 = module_imports(ModuleName, Ancestors0, InterfaceDeps0,
+ ImplementationDeps0, _, _, _, _, _) },
+ { list__condense([Ancestors0, InterfaceDeps0, ImplementationDeps0],
+ OptFiles) },
+ read_optimization_interfaces(OptFiles, [], OptItems, no, OptError),
{ get_dependencies(OptItems, NewImportDeps0, NewUseDeps0) },
{ list__append(NewImportDeps0, NewUseDeps0, NewDeps0) },
{ set__list_to_set(NewDeps0, NewDepsSet0) },
- { set__delete_list(NewDepsSet0, [ModuleName | DirectImports1],
- NewDepsSet) },
+ { set__delete_list(NewDepsSet0, [ModuleName | OptFiles], NewDepsSet) },
{ set__to_sorted_list(NewDepsSet, NewDeps) },
- { Module1 = module_imports(ModuleName, DirectImports1,
- IndirectImports0, [], no) },
- process_module_interfaces(NewDeps, [], Module1, Module2),
- { Module2 = module_imports(_, DirectImports, IndirectImports,
- InterfaceItems, IntError) },
- { list__append(OptItems, InterfaceItems, NewItems) },
- { term__context_init("blah", 0, Context) },
- % Let make_hlds know the opt_imported stuff is coming.
- globals__io_lookup_bool_option(intermod_unused_args, UnusedArgs),
- { varset__init(Varset) },
+
+ %
+ % Read in the .int, and .int2 files needed by the .opt files.
+ % (XXX do we also need to read in .int0 files here?)
+ %
+ { module_imports_set_items(Module1, [], Module2) },
+ process_module_long_interfaces(NewDeps, ".int", [], NewIndirectDeps,
+ Module2, Module3),
+ process_module_indirect_imports(NewIndirectDeps, ".int2",
+ Module3, Module4),
+ { module_imports_get_items(Module4, InterfaceItems) },
%
% Get the :- pragma unused_args(...) declarations created
@@ -1258,7 +1267,7 @@
% with intermod_unused_args, but the interface for other
% modules must remain the same.
%
-
+ globals__io_lookup_bool_option(intermod_unused_args, UnusedArgs),
( { UnusedArgs = yes } ->
read_optimization_interfaces([ModuleName], [],
LocalItems, no, UAError),
@@ -1271,16 +1280,23 @@
{ PragmaItems = [] },
{ UAError = no }
),
- { ( IntError \= no ; OptError = yes ; UAError = yes) ->
+
+ %
+ % Figure out whether anything went wrong
+ %
+ { module_imports_get_error(Module4, FoundError0) },
+ { ( FoundError0 \= no ; OptError = yes ; UAError = yes) ->
FoundError = yes
;
FoundError = no
},
- { OptDefn = module_defn(Varset, opt_imported) - Context },
- { list__append([OptDefn | PragmaItems], NewItems, NewItems2) },
- { list__append(Items0, NewItems2, Items) },
- { Module = module_imports(ModuleName, DirectImports,
- IndirectImports, Items, no) }.
+
+ %
+ % Concatenate everything together.
+ %
+ { list__condense([Items0, PragmaItems, OptItems, InterfaceItems],
+ Items) },
+ { module_imports_set_items(Module4, Items, Module) }.
:- pred read_optimization_interfaces(list(module_name)::in, item_list::in,
item_list::out, bool::in, bool::out,
@@ -1293,12 +1309,14 @@
maybe_write_string(VeryVerbose,
"% Reading optimization interface for module"),
maybe_write_string(VeryVerbose, " `"),
- maybe_write_string(VeryVerbose, Import),
+ { prog_out__sym_name_to_string(Import, ImportString) },
+ maybe_write_string(VeryVerbose, ImportString),
maybe_write_string(VeryVerbose, "'... "),
maybe_flush_output(VeryVerbose),
maybe_write_string(VeryVerbose, "% done.\n"),
- { string__append(Import, ".opt", FileName) },
+ { module_name_to_file_name(Import, BaseFileName) },
+ { string__append(BaseFileName, ".opt", FileName) },
prog_io__read_module(FileName, Import, yes,
ModuleError, Messages, Items1),
update_error_status(FileName, ModuleError, Messages, Error0, Error1),
Index: compiler/lambda.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/lambda.m,v
retrieving revision 1.39
diff -u -u -r1.39 lambda.m
--- lambda.m 1998/02/12 01:17:23 1.39
+++ lambda.m 1998/02/25 02:12:45
@@ -40,7 +40,7 @@
:- interface.
-:- import_module hlds_module, hlds_pred, prog_data.
+:- import_module hlds_module, hlds_pred, hlds_goal, hlds_data, prog_data.
:- import_module list, map, term, varset.
:- pred lambda__process_pred(pred_id, module_info, module_info).
@@ -59,7 +59,7 @@
:- implementation.
-:- import_module hlds_goal, hlds_data, make_hlds.
+:- import_module make_hlds.
:- import_module prog_util, mode_util, inst_match, llds, arg_info.
:- import_module bool, set, string, std_util, require.
@@ -349,7 +349,7 @@
% we use the mode in the lambda expression.
list__length(ArgVars, NumArgVars),
- In = user_defined_mode(qualified("mercury_builtin", "in"), []),
+ in_mode(In),
list__duplicate(NumArgVars, In, InModes),
map__from_corresponding_lists(ArgVars, InModes,
ArgModesMap),
@@ -403,7 +403,7 @@
ConsId = pred_const(PredId, ProcId),
Unification = construct(Var, ConsId, ArgVars, UniModes).
-:- pred make_lambda_name(string, pred_or_func, string, int, int, sym_name).
+:- pred make_lambda_name(module_name, pred_or_func, string, int, int, sym_name).
:- mode make_lambda_name(in, in, in, in, in, out) is det.
make_lambda_name(ModuleName, PredOrFunc, PredName, Line, Counter, SymName) :-
Index: compiler/livemap.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/livemap.m,v
retrieving revision 1.32
diff -u -u -r1.32 livemap.m
--- livemap.m 1998/02/18 03:23:31 1.32
+++ livemap.m 1998/02/26 03:56:02
@@ -16,7 +16,7 @@
:- interface.
-:- import_module list, set, map.
+:- import_module list, set, map, std_util.
:- import_module llds.
:- type livemap == map(label, lvalset).
@@ -33,7 +33,7 @@
:- implementation.
:- import_module opt_util.
-:- import_module std_util, require, string, bool.
+:- import_module require, string, bool.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
Index: compiler/liveness.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/liveness.m,v
retrieving revision 1.90
diff -u -u -r1.90 liveness.m
--- liveness.m 1998/02/03 08:18:24 1.90
+++ liveness.m 1998/02/25 04:11:17
@@ -124,6 +124,7 @@
:- interface.
:- import_module hlds_module, hlds_pred.
+:- import_module set, term.
% Add liveness annotations to the goal of the procedure.
% This consists of the {pre,post}{birth,death} sets and
@@ -145,7 +146,8 @@
:- import_module hlds_goal, hlds_data, llds, quantification, (inst), instmap.
:- import_module hlds_out, mode_util, code_util, quantification, options.
:- import_module prog_data, globals, passes_aux.
-:- import_module bool, list, map, set, std_util, term, assoc_list, require.
+
+:- import_module bool, map, std_util, list, assoc_list, require.
:- import_module varset, string.
detect_liveness_proc(ProcInfo0, ModuleInfo, ProcInfo) :-
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.221
diff -u -u -r1.221 llds.m
--- llds.m 1998/02/03 08:18:27 1.221
+++ llds.m 1998/02/16 06:48:13
@@ -28,7 +28,7 @@
:- type c_file
---> c_file(
- string, % filename
+ module_name,
c_header_info,
list(c_module)
).
@@ -42,13 +42,13 @@
:- type c_module
% a bunch of low-level C code
---> c_module(
- string, % module name
+ string, % the name of this C module
list(c_procedure) % code
)
% readonly data, usually containing a typeinfo structure
; c_data(
- string, % The basename of this C file.
+ module_name, % The basename of this C file.
data_name, % A representation of the name
% of the variable; it will be
% qualified with the basename.
@@ -524,7 +524,7 @@
% the address of the label (uses ENTRY macro).
:- type data_addr
- ---> data_addr(string, data_name).
+ ---> data_addr(module_name, data_name).
% module name; which var
:- type data_name
@@ -631,10 +631,12 @@
% from `.opt' files, the defining module's name is added as a
% qualifier to the label.
:- type proc_label
- ---> proc(string, pred_or_func, string, string, int, proc_id)
+ ---> proc(module_name, pred_or_func, module_name, string,
+ int, proc_id)
% defining module, predicate/function,
% declaring module, name, arity, mode #
- ; special_proc(string, string, string, string, int, proc_id).
+ ; special_proc(module_name, string, module_name, string, int,
+ proc_id).
% defining module, pred name, type module,
% type name, type arity, mode #
Index: compiler/llds_common.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_common.m,v
retrieving revision 1.15
diff -u -u -r1.15 llds_common.m
--- llds_common.m 1998/01/13 10:12:39 1.15
+++ llds_common.m 1998/02/25 02:06:43
@@ -21,15 +21,18 @@
:- interface.
:- import_module llds.
+:- import_module prog_data. % for module_name
+:- import_module list.
-:- pred llds_common(list(c_procedure), list(c_module), string,
+:- pred llds_common(list(c_procedure), list(c_module), module_name,
list(c_procedure), list(c_module), list(c_module)).
:- mode llds_common(in, in, in, out, out, out) is det.
:- implementation.
:- import_module llds_out.
-:- import_module bool, int, list, assoc_list, map, std_util, require.
+
+:- import_module bool, int, assoc_list, map, std_util, require.
:- type cell_info
---> cell_info(
@@ -38,7 +41,7 @@
:- type common_info
---> common_info(
- string, % base file name
+ module_name, % base file name
int, % next cell number
map(list(maybe(rval)), cell_info)
% map cell contents to cell declaration
@@ -61,7 +64,7 @@
llds_common__cell_pairs_to_modules(CellPairs, BaseName, DataModules).
:- pred llds_common__cell_pairs_to_modules(
- assoc_list(list(maybe(rval)), cell_info), string, list(c_module)).
+ assoc_list(list(maybe(rval)), cell_info), module_name, list(c_module)).
:- mode llds_common__cell_pairs_to_modules(in, in, out) is det.
llds_common__cell_pairs_to_modules([], _, []).
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.72
diff -u -u -r1.72 llds_out.m
--- llds_out.m 1998/02/03 08:18:29 1.72
+++ llds_out.m 1998/02/19 08:26:57
@@ -17,8 +17,8 @@
:- interface.
-:- import_module llds, hlds_data.
-:- import_module io.
+:- import_module llds, prog_data, hlds_data.
+:- import_module bool, io.
% Given a 'c_file' structure, open the appropriate .c file
% and output the code into that file.
@@ -79,6 +79,12 @@
:- pred llds_out__name_mangle(string, string).
:- mode llds_out__name_mangle(in, out) is det.
+ % Mangle a possibly module-qualified Mercury symbol name
+ % into a C identifier.
+
+:- pred llds_out__sym_name_mangle(sym_name, string).
+:- mode llds_out__sym_name_mangle(in, out) is det.
+
% Produces a string of the form Module__Name.
:- pred llds_out__qualify_name(string, string, string).
@@ -101,10 +107,12 @@
:- implementation.
-:- import_module export.
-:- import_module exprn_aux, prog_data, prog_out, hlds_pred, mercury_to_mercury.
-:- import_module bool, int, list, char, string, set, std_util, term, varset.
-:- import_module assoc_list, require, globals, options.
+:- import_module globals, options.
+:- import_module exprn_aux, prog_util, prog_out, hlds_pred.
+:- import_module export, mercury_to_mercury, modules.
+
+:- import_module int, list, char, string, set, std_util, term, varset.
+:- import_module assoc_list, require.
:- import_module library. % for the version number.
%-----------------------------------------------------------------------------%
@@ -124,11 +132,12 @@
output_c_file(C_File) -->
globals__io_lookup_bool_option(split_c_files, SplitFiles),
( { SplitFiles = yes } ->
- { C_File = c_file(BaseName, C_HeaderInfo, Modules) },
+ { C_File = c_file(ModuleName, C_HeaderInfo, Modules) },
+ { module_name_to_file_name(ModuleName, BaseName) },
{ string__append(BaseName, ".dir", ObjDirName) },
make_directory(ObjDirName),
output_c_file_init(BaseName, Modules),
- output_c_file_list(Modules, 1, BaseName, C_HeaderInfo)
+ output_c_file_list(Modules, 1, ModuleName, C_HeaderInfo)
;
output_single_c_file(C_File, no)
).
@@ -141,16 +150,16 @@
Command) },
io__call_system(Command, _Result).
-:- pred output_c_file_list(list(c_module), int, string, list(c_header_code),
- io__state, io__state).
+:- pred output_c_file_list(list(c_module), int, module_name,
+ list(c_header_code), io__state, io__state).
:- mode output_c_file_list(in, in, in, in, di, uo) is det.
output_c_file_list([], _, _, _) --> [].
-output_c_file_list([Module|Modules], Num, BaseName, C_HeaderLines) -->
- output_single_c_file(c_file(BaseName, C_HeaderLines, [Module]),
+output_c_file_list([Module|Modules], Num, ModuleName, C_HeaderLines) -->
+ output_single_c_file(c_file(ModuleName, C_HeaderLines, [Module]),
yes(Num)),
{ Num1 is Num + 1 },
- output_c_file_list(Modules, Num1, BaseName, C_HeaderLines).
+ output_c_file_list(Modules, Num1, ModuleName, C_HeaderLines).
:- pred output_c_file_init(string, list(c_module), io__state, io__state).
:- mode output_c_file_init(in, in, di, uo) is det.
@@ -191,8 +200,9 @@
:- pred output_single_c_file(c_file, maybe(int), io__state, io__state).
:- mode output_single_c_file(in, in, di, uo) is det.
-output_single_c_file(c_file(BaseName, C_HeaderLines, Modules), SplitFiles)
+output_single_c_file(c_file(ModuleName, C_HeaderLines, Modules), SplitFiles)
-->
+ { module_name_to_file_name(ModuleName, BaseName) },
( { SplitFiles = yes(Num) } ->
{ string__format("%s.dir/%s_%03d.c", [s(BaseName), s(BaseName),
i(Num)], FileName) }
@@ -224,7 +234,7 @@
{ gather_c_file_labels(Modules, Labels) },
{ set__init(DeclSet0) },
output_c_label_decl_list(Labels, DeclSet0, DeclSet),
- output_c_module_list(Modules, DeclSet, BaseName),
+ output_c_module_list(Modules, DeclSet),
( { SplitFiles = yes(_) } ->
[]
;
@@ -318,14 +328,14 @@
globals__io_lookup_bool_option(split_c_files, SplitFiles),
( { SplitFiles = yes } ->
io__write_string("\t{ extern ModuleFunc "),
- output_module_name(ModuleName),
+ io__write_string(ModuleName),
io__write_string(";\n"),
io__write_string("\t "),
- output_module_name(ModuleName),
+ io__write_string(ModuleName),
io__write_string("(); }\n")
;
io__write_string("\t"),
- output_module_name(ModuleName),
+ io__write_string(ModuleName),
io__write_string("();\n")
),
output_c_module_init_list_2(Ms, BaseName,
@@ -368,7 +378,8 @@
io__write_string("\tMR_INIT_BASE_TYPE_INFO(\n\t\t"),
output_data_addr(BaseName, DataName),
io__write_string(",\n\t\t"),
- { string__append(BaseName, "__", UnderscoresModule) },
+ { llds_out__sym_name_mangle(BaseName, BaseNameString) },
+ { string__append(BaseNameString, "__", UnderscoresModule) },
(
{ string__append(UnderscoresModule, _, TypeName) }
->
@@ -405,33 +416,31 @@
io__write_string("_bunch_"),
io__write_int(Number).
-:- pred output_module_name(string, io__state, io__state).
+:- pred output_module_name(module_name, io__state, io__state).
:- mode output_module_name(in, di, uo) is det.
output_module_name(ModuleName0) -->
io__write_string("mercury__"),
- { llds_out__name_mangle(ModuleName0, ModuleName) },
+ { llds_out__sym_name_mangle(ModuleName0, ModuleName) },
io__write_string(ModuleName).
-:- pred output_c_module_list(list(c_module), decl_set, string,
- io__state, io__state).
-:- mode output_c_module_list(in, in, in, di, uo) is det.
+:- pred output_c_module_list(list(c_module), decl_set, io__state, io__state).
+:- mode output_c_module_list(in, in, di, uo) is det.
-output_c_module_list([], _, _) --> [].
-output_c_module_list([M | Ms], DeclSet0, BaseName) -->
- output_c_module(M, DeclSet0, DeclSet, BaseName),
- output_c_module_list(Ms, DeclSet, BaseName).
+output_c_module_list([], _) --> [].
+output_c_module_list([M | Ms], DeclSet0) -->
+ output_c_module(M, DeclSet0, DeclSet),
+ output_c_module_list(Ms, DeclSet).
-:- pred output_c_module(c_module, decl_set, decl_set, string,
- io__state, io__state).
-:- mode output_c_module(in, in, out, in, di, uo) is det.
+:- pred output_c_module(c_module, decl_set, decl_set, io__state, io__state).
+:- mode output_c_module(in, in, out, di, uo) is det.
-output_c_module(c_module(ModuleName, Procedures), DeclSet0, DeclSet, _) -->
+output_c_module(c_module(ModuleName, Procedures), DeclSet0, DeclSet) -->
io__write_string("\n"),
output_c_procedure_list_decls(Procedures, DeclSet0, DeclSet),
io__write_string("\n"),
io__write_string("BEGIN_MODULE("),
- output_module_name(ModuleName),
+ io__write_string(ModuleName),
io__write_string(")\n"),
{ gather_c_module_labels(Procedures, Labels) },
output_c_label_init_list(Labels),
@@ -443,7 +452,7 @@
io__write_string("END_MODULE\n").
output_c_module(c_data(BaseName, VarName, ExportedFromModule, ArgVals, _Refs),
- DeclSet0, DeclSet, _) -->
+ DeclSet0, DeclSet) -->
io__write_string("\n"),
{ DataAddr = data_addr(data_addr(BaseName, VarName)) },
output_cons_arg_decls(ArgVals, "", "", 0, _, DeclSet0, DeclSet1),
@@ -462,7 +471,7 @@
0, _),
{ set__insert(DeclSet1, DataAddr, DeclSet) }.
-output_c_module(c_code(C_Code, Context), DeclSet, DeclSet, _) -->
+output_c_module(c_code(C_Code, Context), DeclSet, DeclSet) -->
globals__io_lookup_bool_option(auto_comments, PrintComments),
( { PrintComments = yes } ->
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list