for review: cleanup of access predicates in hlds_module
Zoltan Somogyi
zs at cs.mu.oz.au
Fri Dec 12 18:10:29 AEDT 1997
DJ, please review this.
hlds_module.m:
Remove unused fields from dependency_info, and clean up the way
dependency_infos are accessed.
Add a new field that will be needed for nondet pragma C codes.
Clean up the access predicates of module_info. Get rid of some
ad-hoc substructures of module_info. Instead, consolidate all
infrequently updated fields into a module_sub_info (updated only
9 times while compiling make_hlds).
This change reduces memory consumption by 0.5%.
Zoltan.
cvs diff: Diffing .
Index: dependency_graph.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dependency_graph.m,v
retrieving revision 1.30
diff -u -u -r1.30 dependency_graph.m
--- dependency_graph.m 1997/09/01 14:00:59 1.30
+++ dependency_graph.m 1997/12/09 03:18:34
@@ -50,7 +50,8 @@
% it if necessary.
module_info_ensure_dependency_info(ModuleInfo0, ModuleInfo) :-
- ( module_info_dependency_info_built(ModuleInfo0) ->
+ module_info_get_maybe_dependency_info(ModuleInfo0, MaybeDepInfo),
+ ( MaybeDepInfo = yes(_) ->
ModuleInfo = ModuleInfo0
;
dependency_graph__build_dependency_graph(ModuleInfo0, ModuleInfo)
Index: hlds_module.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_module.m,v
retrieving revision 1.25
diff -u -u -r1.25 hlds_module.m
--- hlds_module.m 1997/09/01 04:17:55 1.25
+++ hlds_module.m 1997/12/12 06:57:01
@@ -77,27 +77,84 @@
hlds_type_defn % defn of type
).
- % This structure contains information needed to create
- % base_type_* structures.
-
-:- type base_gen_data ---> base_gen_data(
- list(base_gen_info),
- list(base_gen_layout)
- ).
-
% Various predicates for manipulating the module_info data structure
% map from proc to a list of unused argument numbers.
:- type unused_arg_info == map(pred_proc_id, list(int)).
+%-----------------------------------------------------------------------------%
+
% Create an empty module_info for a given module name (and the
% global options).
:- pred module_info_init(string, globals, module_info).
:- mode module_info_init(in, in, out) is det.
+:- pred module_info_get_predicate_table(module_info, predicate_table).
+:- mode module_info_get_predicate_table(in, out) is det.
+
+:- pred module_info_set_predicate_table(module_info, predicate_table,
+ module_info).
+:- mode module_info_set_predicate_table(in, in, out) is det.
+
+ % For an explanation of the unify_requests structure,
+ % see unify_info.m.
+:- pred module_info_get_unify_requests(module_info, unify_requests).
+:- mode module_info_get_unify_requests(in, out) is det.
+
+:- pred module_info_get_special_pred_map(module_info, special_pred_map).
+:- mode module_info_get_special_pred_map(in, out) is det.
+
+:- pred module_info_set_special_pred_map(module_info, special_pred_map,
+ module_info).
+:- mode module_info_set_special_pred_map(in, in, out) is det.
+
+:- pred module_info_get_continuation_info(module_info, continuation_info).
+:- mode module_info_get_continuation_info(in, out) is det.
+
+:- pred module_info_set_continuation_info(module_info, continuation_info,
+ module_info).
+:- mode module_info_set_continuation_info(in, in, out) is det.
+
+:- pred module_info_types(module_info, type_table).
+:- mode module_info_types(in, out) is det.
+
+:- pred module_info_set_types(module_info, type_table, module_info).
+:- mode module_info_set_types(in, in, out) is det.
+
+:- pred module_info_insts(module_info, inst_table).
+:- mode module_info_insts(in, out) is det.
+
+:- pred module_info_set_insts(module_info, inst_table, module_info).
+:- mode module_info_set_insts(in, in, out) is det.
+
+:- pred module_info_modes(module_info, mode_table).
+:- mode module_info_modes(in, out) is det.
+
+:- pred module_info_set_modes(module_info, mode_table, module_info).
+:- mode module_info_set_modes(in, in, out) is det.
+
+:- pred module_info_ctors(module_info, cons_table).
+:- mode module_info_ctors(in, out) is det.
+
+:- pred module_info_set_ctors(module_info, cons_table, module_info).
+:- mode module_info_set_ctors(in, in, out) is det.
+
+ % The cell count is used as a unique label number for
+ % constants in the generated C code.
+:- pred module_info_get_cell_count(module_info, int).
+:- mode module_info_get_cell_count(in, out) is det.
+
+:- pred module_info_set_cell_count(module_info, int, module_info).
+:- mode module_info_set_cell_count(in, in, out) is det.
+
+%-----------------------------------------------------------------------------%
+
:- pred module_info_name(module_info, string).
:- mode module_info_name(in, out) is det.
+:- pred module_info_globals(module_info, globals).
+:- mode module_info_globals(in, out) is det.
+
:- pred module_info_get_c_header(module_info, c_header_info).
:- mode module_info_get_c_header(in, out) is det.
@@ -110,8 +167,57 @@
:- pred module_info_set_c_body_code(module_info, c_body_info, module_info).
:- mode module_info_set_c_body_code(in, in, out) is det.
-:- pred module_info_get_predicate_table(module_info, predicate_table).
-:- mode module_info_get_predicate_table(in, out) is det.
+:- pred module_info_get_maybe_dependency_info(module_info,
+ maybe(dependency_info)).
+:- mode module_info_get_maybe_dependency_info(in, out) is det.
+
+:- pred module_info_num_errors(module_info, int).
+:- mode module_info_num_errors(in, out) is det.
+
+:- pred module_info_unused_arg_info(module_info, unused_arg_info).
+:- mode module_info_unused_arg_info(in, out) is det.
+
+:- pred module_info_set_unify_requests(module_info, unify_requests,
+ module_info).
+:- mode module_info_set_unify_requests(in, in, out) is det.
+
+:- pred module_info_set_unused_arg_info(module_info,
+ unused_arg_info, module_info).
+:- mode module_info_set_unused_arg_info(in, in, out) is det.
+
+:- pred module_info_set_num_errors(module_info, int, module_info).
+:- mode module_info_set_num_errors(in, in, out) is det.
+
+:- pred module_info_get_pragma_exported_procs(module_info,
+ list(pragma_exported_proc)).
+:- mode module_info_get_pragma_exported_procs(in, out) is det.
+
+:- pred module_info_set_pragma_exported_procs(module_info,
+ list(pragma_exported_proc), module_info).
+:- mode module_info_set_pragma_exported_procs(in, in, out) is det.
+
+:- pred module_info_base_gen_infos(module_info, list(base_gen_info)).
+:- mode module_info_base_gen_infos(in, out) is det.
+
+:- pred module_info_set_base_gen_infos(module_info, list(base_gen_info),
+ module_info).
+:- mode module_info_set_base_gen_infos(in, in, out) is det.
+
+:- pred module_info_base_gen_layouts(module_info, list(base_gen_layout)).
+:- mode module_info_base_gen_layouts(in, out) is det.
+
+:- pred module_info_set_base_gen_layouts(module_info, list(base_gen_layout),
+ module_info).
+:- mode module_info_set_base_gen_layouts(in, in, out) is det.
+
+:- pred module_info_stratified_preds(module_info, set(pred_id)).
+:- mode module_info_stratified_preds(in, out) is det.
+
+:- pred module_info_set_stratified_preds(module_info, set(pred_id),
+ module_info).
+:- mode module_info_set_stratified_preds(in, in, out) is det.
+
+%-----------------------------------------------------------------------------%
:- pred module_info_preds(module_info, pred_table).
:- mode module_info_preds(in, out) is det.
@@ -122,7 +228,6 @@
% Given a pred_id and a proc_id, get the
% pred_info that predicate and the proc_info for that
% mode of that predicate.
-
:- pred module_info_pred_proc_info(module_info, pred_id, proc_id,
pred_info, proc_info).
:- mode module_info_pred_proc_info(in, in, in, out, out) is det.
@@ -142,200 +247,178 @@
:- pred module_info_reverse_predids(module_info, module_info).
:- mode module_info_reverse_predids(in, out) is det.
- % For an explanation of the unify_requests structure,
- % see unify_info.m.
-:- pred module_info_get_unify_requests(module_info, unify_requests).
-:- mode module_info_get_unify_requests(in, out) is det.
-
-:- pred module_info_get_special_pred_map(module_info, special_pred_map).
-:- mode module_info_get_special_pred_map(in, out) is det.
+ % Remove a predicate from the list of pred_ids, to prevent
+ % further processing of this predicate after an error is encountered.
+:- pred module_info_remove_predid(module_info, pred_id, module_info).
+:- mode module_info_remove_predid(in, in, out) is det.
-:- pred module_info_get_continuation_info(module_info, continuation_info).
-:- mode module_info_get_continuation_info(in, out) is det.
+ % Completely remove a predicate from a module.
+:- pred module_info_remove_predicate(pred_id, module_info, module_info).
+:- mode module_info_remove_predicate(in, in, out) is det.
- % the cell count is used as a unique label number for
- % constants in the generated C code
-:- pred module_info_get_cell_count(module_info, int).
-:- mode module_info_get_cell_count(in, out) is det.
+:- pred module_info_set_preds(module_info, pred_table, module_info).
+:- mode module_info_set_preds(in, in, out) is det.
-:- pred module_info_types(module_info, type_table).
-:- mode module_info_types(in, out) is det.
+:- pred module_info_set_pred_info(module_info, pred_id, pred_info, module_info).
+:- mode module_info_set_pred_info(in, in, in, out) is det.
:- pred module_info_typeids(module_info, list(type_id)).
:- mode module_info_typeids(in, out) is det.
-:- pred module_info_insts(module_info, inst_table).
-:- mode module_info_insts(in, out) is det.
-
:- pred module_info_instids(module_info, list(inst_id)).
:- mode module_info_instids(in, out) is det.
-:- pred module_info_modes(module_info, mode_table).
-:- mode module_info_modes(in, out) is det.
-
:- pred module_info_modeids(module_info, list(mode_id)).
:- mode module_info_modeids(in, out) is det.
-:- pred module_info_ctors(module_info, cons_table).
-:- mode module_info_ctors(in, out) is det.
-
-:- pred module_info_num_errors(module_info, int).
-:- mode module_info_num_errors(in, out) is det.
-
-% not used
-% :- pred module_info_num_warnings(module_info, int).
-% :- mode module_info_num_warnings(in, out) is det.
-
:- pred module_info_consids(module_info, list(cons_id)).
:- mode module_info_consids(in, out) is det.
- % The dependency information must have been build before
- % calling this predicate.
-
:- pred module_info_dependency_info(module_info, dependency_info).
:- mode module_info_dependency_info(in, out) is det.
- % Succeeds iff the dependency information has already been built
-
-:- pred module_info_dependency_info_built(module_info).
-:- mode module_info_dependency_info_built(in) is semidet.
+:- pred module_info_set_dependency_info(module_info, dependency_info,
+ module_info).
+:- mode module_info_set_dependency_info(in, in, out) is det.
-:- pred module_info_unused_arg_info(module_info, unused_arg_info).
-:- mode module_info_unused_arg_info(in, out) is det.
+:- pred module_info_clobber_dependency_info(module_info, module_info).
+:- mode module_info_clobber_dependency_info(in, out) is det.
-:- pred module_info_set_name(module_info, string, module_info).
-:- mode module_info_set_name(in, in, out) is det.
+:- pred module_info_incr_errors(module_info, module_info).
+:- mode module_info_incr_errors(in, out) is det.
-:- pred module_info_set_predicate_table(module_info, predicate_table,
- module_info).
-:- mode module_info_set_predicate_table(in, in, out) is det.
+ % The module_info stores a counter which is used to number
+ % introduced lambda predicates as __LambdaGoal__1, __LambdaGoal__2,
+ % etc.; this predicate returns the next number and increments
+ % the counter.
+:- pred module_info_next_lambda_count(module_info, int, module_info).
+:- mode module_info_next_lambda_count(in, out, out) is det.
-:- pred module_info_set_preds(module_info, pred_table, module_info).
-:- mode module_info_set_preds(in, in, out) is det.
+:- pred module_info_next_model_non_pragma_count(module_info, int, module_info).
+:- mode module_info_next_model_non_pragma_count(in, out, out) is det.
-:- pred module_info_set_pred_info(module_info, pred_id, pred_info, module_info).
-:- mode module_info_set_pred_info(in, in, in, out) is det.
+ % Once the module_info has been built, we call module_info_optimize
+ % to attempt to optimize the data structures for lots of accesses
+ % and relatively few insertion/deletions. (This was useful when
+ % we were using unbalanced binary trees, but now that we are using
+ % 234-trees, it is a no-op, except for the mode and inst tables,
+ % where the cached lists of mode_ids and inst_ids are sorted for
+ % efficient conversion to sets in module_qual.m.)
+:- pred module_info_optimize(module_info, module_info).
+:- mode module_info_optimize(in, out) is det.
-:- pred module_info_set_unify_requests(module_info, unify_requests,
- module_info).
-:- mode module_info_set_unify_requests(in, in, out) is det.
+%-----------------------------------------------------------------------------%
-:- pred module_info_set_special_pred_map(module_info, special_pred_map,
- module_info).
-:- mode module_info_set_special_pred_map(in, in, out) is det.
+:- implementation.
-:- pred module_info_set_continuation_info(module_info, continuation_info,
- module_info).
-:- mode module_info_set_continuation_info(in, in, out) is det.
+:- pred module_info_get_sub_info(module_info, module_sub_info).
+:- mode module_info_get_sub_info(in, out) is det.
-:- pred module_info_set_cell_count(module_info, int, module_info).
-:- mode module_info_set_cell_count(in, in, out) is det.
+:- pred module_info_set_sub_info(module_info, module_sub_info, module_info).
+:- mode module_info_set_sub_info(in, in, out) is det.
-:- pred module_info_set_types(module_info, type_table, module_info).
-:- mode module_info_set_types(in, in, out) is det.
+:- pred module_info_get_lambda_count(module_info, int).
+:- mode module_info_get_lambda_count(in, out) is det.
-:- pred module_info_set_insts(module_info, inst_table, module_info).
-:- mode module_info_set_insts(in, in, out) is det.
+:- pred module_info_set_lambda_count(module_info, int, module_info).
+:- mode module_info_set_lambda_count(in, in, out) is det.
-:- pred module_info_set_modes(module_info, mode_table, module_info).
-:- mode module_info_set_modes(in, in, out) is det.
+:- pred module_info_get_model_non_pragma_count(module_info, int).
+:- mode module_info_get_model_non_pragma_count(in, out) is det.
-:- pred module_info_set_ctors(module_info, cons_table, module_info).
-:- mode module_info_set_ctors(in, in, out) is det.
+:- pred module_info_set_model_non_pragma_count(module_info, int, module_info).
+:- mode module_info_set_model_non_pragma_count(in, in, out) is det.
-:- pred module_info_set_dependency_info(module_info, dependency_info,
- module_info).
-:- mode module_info_set_dependency_info(in, in, out) is det.
+:- pred module_info_set_maybe_dependency_info(module_info,
+ maybe(dependency_info), module_info).
+:- mode module_info_set_maybe_dependency_info(in, in, out) is det.
-:- pred module_info_clobber_dependency_info(module_info, module_info).
-:- mode module_info_clobber_dependency_info(in, out) is det.
+:- pred module_sub_get_name(module_sub_info, string).
+:- mode module_sub_get_name(in, out) is det.
-:- pred module_info_set_unused_arg_info(module_info,
- unused_arg_info, module_info).
-:- mode module_info_set_unused_arg_info(in, in, out) is det.
+:- pred module_sub_get_globals(module_sub_info, globals).
+:- mode module_sub_get_globals(in, out) is det.
-:- pred module_info_set_num_errors(module_info, int, module_info).
-:- mode module_info_set_num_errors(in, in, out) is det.
+:- pred module_sub_get_c_header_info(module_sub_info, c_header_info).
+:- mode module_sub_get_c_header_info(in, out) is det.
-:- pred module_info_incr_errors(module_info, module_info).
-:- mode module_info_incr_errors(in, out) is det.
+:- pred module_sub_get_c_body_info(module_sub_info, c_body_info).
+:- mode module_sub_get_c_body_info(in, out) is det.
-/* not used
-:- pred module_info_incr_warnings(module_info, module_info).
-:- mode module_info_incr_warnings(in, out) is det.
-*/
+:- pred module_sub_get_maybe_dependency_info(module_sub_info,
+ maybe(dependency_info)).
+:- mode module_sub_get_maybe_dependency_info(in, out) is det.
- % The module_info stores a counter which is used to number
- % introduced lambda predicates as __LambdaGoal__1, __LambdaGoal__2,
- % etc.; this predicate returns the next number and increments
- % the counter.
+:- pred module_sub_get_num_errors(module_sub_info, int).
+:- mode module_sub_get_num_errors(in, out) is det.
-:- pred module_info_next_lambda_count(module_info, int, module_info).
-:- mode module_info_next_lambda_count(in, out, out) is det.
+:- pred module_sub_get_lambda_count(module_sub_info, int).
+:- mode module_sub_get_lambda_count(in, out) is det.
-:- pred module_info_get_pragma_exported_procs(module_info,
+:- pred module_sub_get_pragma_exported_procs(module_sub_info,
list(pragma_exported_proc)).
-:- mode module_info_get_pragma_exported_procs(in, out) is det.
+:- mode module_sub_get_pragma_exported_procs(in, out) is det.
-:- pred module_info_set_pragma_exported_procs(module_info,
- list(pragma_exported_proc), module_info).
-:- mode module_info_set_pragma_exported_procs(in, in, out) is det.
+:- pred module_sub_get_base_gen_infos(module_sub_info, list(base_gen_info)).
+:- mode module_sub_get_base_gen_infos(in, out) is det.
- % Remove a predicate from the list of pred_ids, to prevent
- % further processing of this predicate after an error is
- % encountered.
+:- pred module_sub_get_base_gen_layouts(module_sub_info, list(base_gen_layout)).
+:- mode module_sub_get_base_gen_layouts(in, out) is det.
-:- pred module_info_remove_predid(module_info, pred_id, module_info).
-:- mode module_info_remove_predid(in, in, out) is det.
+:- pred module_sub_get_stratified_preds(module_sub_info, set(pred_id)).
+:- mode module_sub_get_stratified_preds(in, out) is det.
- % Completely remove a predicate from a module.
+:- pred module_sub_get_unused_arg_info(module_sub_info, unused_arg_info).
+:- mode module_sub_get_unused_arg_info(in, out) is det.
-:- pred module_info_remove_predicate(pred_id, module_info, module_info).
-:- mode module_info_remove_predicate(in, in, out) is det.
+:- pred module_sub_get_model_non_pragma_count(module_sub_info, int).
+:- mode module_sub_get_model_non_pragma_count(in, out) is det.
- % Once the module_info has been built, we call module_info_optimize
- % to attempt to optimize the data structures for lots of accesses
- % and relatively few insertion/deletions. (This was useful when
- % we were using unbalanced binary trees, but now that we are using
- % 234-trees, it is a no-op, except for the mode and inst tables,
- % where the cached lists of mode_ids and inst_ids are sorted for
- % efficient conversion to sets in module_qual.m.)
+:- pred module_sub_set_c_header_info(module_sub_info, c_header_info,
+ module_sub_info).
+:- mode module_sub_set_c_header_info(in, in, out) is det.
-:- pred module_info_optimize(module_info, module_info).
-:- mode module_info_optimize(in, out) is det.
+:- pred module_sub_set_c_body_info(module_sub_info, c_body_info,
+ module_sub_info).
+:- mode module_sub_set_c_body_info(in, in, out) is det.
-:- pred module_info_base_gen_infos(module_info, list(base_gen_info)).
-:- mode module_info_base_gen_infos(in, out) is det.
+:- pred module_sub_set_maybe_dependency_info(module_sub_info,
+ maybe(dependency_info), module_sub_info).
+:- mode module_sub_set_maybe_dependency_info(in, in, out) is det.
-:- pred module_info_set_base_gen_infos(module_info, list(base_gen_info),
- module_info).
-:- mode module_info_set_base_gen_infos(in, in, out) is det.
+:- pred module_sub_set_num_errors(module_sub_info, int, module_sub_info).
+:- mode module_sub_set_num_errors(in, in, out) is det.
-:- pred module_info_base_gen_layouts(module_info, list(base_gen_layout)).
-:- mode module_info_base_gen_layouts(in, out) is det.
+:- pred module_sub_set_lambda_count(module_sub_info, int, module_sub_info).
+:- mode module_sub_set_lambda_count(in, in, out) is det.
-:- pred module_info_set_base_gen_layouts(module_info, list(base_gen_layout),
- module_info).
-:- mode module_info_set_base_gen_layouts(in, in, out) is det.
+:- pred module_sub_set_pragma_exported_procs(module_sub_info,
+ list(pragma_exported_proc), module_sub_info).
+:- mode module_sub_set_pragma_exported_procs(in, in, out) is det.
-:- pred module_info_globals(module_info, globals).
-:- mode module_info_globals(in, out) is det.
+:- pred module_sub_set_base_gen_infos(module_sub_info, list(base_gen_info),
+ module_sub_info).
+:- mode module_sub_set_base_gen_infos(in, in, out) is det.
-:- pred module_info_stratified_preds(module_info, set(pred_id)).
-:- mode module_info_stratified_preds(in, out) is det.
+:- pred module_sub_set_base_gen_layouts(module_sub_info, list(base_gen_layout),
+ module_sub_info).
+:- mode module_sub_set_base_gen_layouts(in, in, out) is det.
-:- pred module_info_set_stratified_preds(module_info, set(pred_id),
- module_info).
-:- mode module_info_set_stratified_preds(in, in, out) is det.
+:- pred module_sub_set_stratified_preds(module_sub_info, set(pred_id),
+ module_sub_info).
+:- mode module_sub_set_stratified_preds(in, in, out) is det.
-%-----------------------------------------------------------------------------%
+:- pred module_sub_set_unused_arg_info(module_sub_info, unused_arg_info,
+ module_sub_info).
+:- mode module_sub_set_unused_arg_info(in, in, out) is det.
-:- implementation.
+:- pred module_sub_set_model_non_pragma_count(module_sub_info, int,
+ module_sub_info).
+:- mode module_sub_set_model_non_pragma_count(in, in, out) is det.
:- type module_info
---> module(
- string, % module name
- c_code_info,
+ module_sub_info,
predicate_table,
unify_requests,
special_pred_map,
@@ -344,37 +427,42 @@
inst_table,
mode_table,
cons_table,
+ int % cell count, passed into code_info
+ % and used to generate unique label
+ % numbers for constant terms in the
+ % generated C code
+ ).
+
+:- type module_sub_info
+ ---> module_sub(
+ string, % module name
+ globals, % global options
+ c_header_info,
+ c_body_info,
maybe(dependency_info),
int, % number of errors
- %%% num_warnings not used:
- %%% int, % number of warnings
- int, % lambda predicate counter
+ int, % lambda predicate counter
list(pragma_exported_proc),
- % list of the procs for which
- % there is a pragma(export, ...)
- % declaration
- base_gen_data,
- % info about the the types
- % defined here
- globals, % global options
+ % list of the procs for which
+ % there is a pragma(export, ...)
+ % declaration
+ list(base_gen_info),
+ list(base_gen_layout),
+ % info about the types defined here
set(pred_id),
- % list of preds which
- % must be stratified
+ % preds which must be stratified
unused_arg_info,
- % unused argument info about
- % predicates in the current
- % module which has been exported
- % in .opt files.
- int % cell count, passed into code_info
- % and used to generate unique label
- % numbers for constant terms in the
- % generated C code
+ % unused argument info about
+ % predicates in the current
+ % module which has been exported
+ % in .opt files.
+ int % number of the structure types defined
+ % so far for model_non pragma C codes
).
% A predicate which creates an empty module
-module_info_init(Name, Globals, Module_Info) :-
- C_Code_Info = c_code_info([], []),
+module_info_init(Name, Globals, ModuleInfo) :-
predicate_table_init(PredicateTable),
unify_proc__init_requests(Requests),
map__init(UnifyPredMap),
@@ -383,59 +471,358 @@
mode_table_init(Modes),
continuation_info__init(ContinuationInfo),
map__init(Ctors),
- DepInfo = no,
- PragmaExports = [],
- BaseTypeData = base_gen_data([], []),
set__init(StratPreds),
map__init(UnusedArgInfo),
- Module_Info = module(Name, C_Code_Info, PredicateTable, Requests,
- UnifyPredMap, ContinuationInfo, Types, Insts, Modes,
- Ctors, DepInfo, 0, 0, PragmaExports, BaseTypeData, Globals,
- StratPreds, UnusedArgInfo, 0).
-
- % Various access predicates which extract different pieces
- % of info from the module_info data structure.
-
-module_info_name(ModuleInfo, Name) :-
- ModuleInfo = module(Name, _, _, _, _, _, _, _, _, _, _, _, _,
- _, _, _, _, _, _).
-
-module_info_get_c_header(ModuleInfo, C_Header) :-
- ModuleInfo = module(_, C_Code_Info, _, _, _, _, _, _, _, _, _, _,
- _, _, _, _, _, _, _),
- C_Code_Info = c_code_info(C_Header, _).
-
-module_info_set_c_header(ModuleInfo1, C_Header, ModuleInfo2) :-
- ModuleInfo1 = module(A, C_Code_Info0,
- C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S),
- C_Code_Info0 = c_code_info(_C_Header0, C_Body),
- C_Code_Info = c_code_info(C_Header, C_Body),
- ModuleInfo2 = module(A, C_Code_Info,
- C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S).
-
-module_info_get_c_body_code(ModuleInfo, C_Body) :-
- ModuleInfo = module(_, C_Code_Info, _, _, _, _, _, _, _, _, _, _,
- _, _, _, _, _, _, _),
- C_Code_Info = c_code_info(_, C_Body).
-
-module_info_set_c_body_code(ModuleInfo1, C_Body, ModuleInfo2) :-
- ModuleInfo1 = module(A, C_Code_Info0,
- C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S),
- C_Code_Info0 = c_code_info(C_Header, _C_Body0),
- C_Code_Info = c_code_info(C_Header, C_Body),
- ModuleInfo2 = module(A, C_Code_Info,
- C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S).
-
-module_info_get_predicate_table(ModuleInfo, PredicateTable) :-
- ModuleInfo = module(_, _, PredicateTable,
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _).
-
-module_info_preds(ModuleInfo, Preds) :-
- module_info_get_predicate_table(ModuleInfo, PredicateTable),
- predicate_table_get_preds(PredicateTable, Preds).
+ ModuleSubInfo = module_sub(Name, Globals, [], [], no, 0, 0, [],
+ [], [], StratPreds, UnusedArgInfo, 0),
+ ModuleInfo = module(ModuleSubInfo, PredicateTable, Requests,
+ UnifyPredMap, ContinuationInfo, Types, Insts, Modes, Ctors, 0).
+
+%-----------------------------------------------------------------------------%
+
+% :- type module_sub_info
+% ---> module_sub(
+% A string, % module name
+% B globals, % global options
+% C c_header_info,
+% D c_body_info,
+% E maybe(dependency_info),
+% F int, % number of errors
+% G int, % lambda predicate counter
+% H list(pragma_exported_proc),
+% % list of the procs for which
+% % there is a pragma(export, ...)
+% % declaration
+% I list(base_gen_info),
+% J list(base_gen_layout)
+% % info about the types defined here
+% K set(pred_id),
+% % preds which must be stratified
+% L unused_arg_info,
+% % unused argument info about
+% % predicates in the current
+% % module which has been exported
+% % in .opt files.
+% M int % number of the structure types defined
+% % so far for model_non pragma C codes
+% ).
+
+%-----------------------------------------------------------------------------%
+
+ % Various predicates which access the module_sub_info data structure.
+
+module_sub_get_name(MI0, A) :-
+ MI0 = module_sub(A, _, _, _, _, _, _, _, _, _, _, _, _).
+
+module_sub_get_globals(MI0, B) :-
+ MI0 = module_sub(_, B, _, _, _, _, _, _, _, _, _, _, _).
+
+module_sub_get_c_header_info(MI0, C) :-
+ MI0 = module_sub(_, _, C, _, _, _, _, _, _, _, _, _, _).
+
+module_sub_get_c_body_info(MI0, D) :-
+ MI0 = module_sub(_, _, _, D, _, _, _, _, _, _, _, _, _).
+
+module_sub_get_maybe_dependency_info(MI0, E) :-
+ MI0 = module_sub(_, _, _, _, E, _, _, _, _, _, _, _, _).
+
+module_sub_get_num_errors(MI0, F) :-
+ MI0 = module_sub(_, _, _, _, _, F, _, _, _, _, _, _, _).
+
+module_sub_get_lambda_count(MI0, G) :-
+ MI0 = module_sub(_, _, _, _, _, _, G, _, _, _, _, _, _).
+
+module_sub_get_pragma_exported_procs(MI0, H) :-
+ MI0 = module_sub(_, _, _, _, _, _, _, H, _, _, _, _, _).
+
+module_sub_get_base_gen_infos(MI0, I) :-
+ MI0 = module_sub(_, _, _, _, _, _, _, _, I, _, _, _, _).
+
+module_sub_get_base_gen_layouts(MI0, J) :-
+ MI0 = module_sub(_, _, _, _, _, _, _, _, _, J, _, _, _).
+
+module_sub_get_stratified_preds(MI0, K) :-
+ MI0 = module_sub(_, _, _, _, _, _, _, _, _, _, K, _, _).
+
+module_sub_get_unused_arg_info(MI0, L) :-
+ MI0 = module_sub(_, _, _, _, _, _, _, _, _, _, _, L, _).
-module_info_pred_info(ModuleInfo, PredId, PredInfo) :-
- module_info_preds(ModuleInfo, Preds),
+module_sub_get_model_non_pragma_count(MI0, M) :-
+ MI0 = module_sub(_, _, _, _, _, _, _, _, _, _, _, _, M).
+
+%-----------------------------------------------------------------------------%
+
+ % Various predicates which modify the module_sub_info data structure.
+
+module_sub_set_c_header_info(MI0, C, MI) :-
+ MI0 = module_sub(A, B, _, D, E, F, G, H, I, J, K, L, M),
+ MI = module_sub(A, B, C, D, E, F, G, H, I, J, K, L, M).
+
+module_sub_set_c_body_info(MI0, D, MI) :-
+ MI0 = module_sub(A, B, C, _, E, F, G, H, I, J, K, L, M),
+ MI = module_sub(A, B, C, D, E, F, G, H, I, J, K, L, M).
+
+module_sub_set_maybe_dependency_info(MI0, E, MI) :-
+ MI0 = module_sub(A, B, C, D, _, F, G, H, I, J, K, L, M),
+ MI = module_sub(A, B, C, D, E, F, G, H, I, J, K, L, M).
+
+module_sub_set_num_errors(MI0, F, MI) :-
+ MI0 = module_sub(A, B, C, D, E, _, G, H, I, J, K, L, M),
+ MI = module_sub(A, B, C, D, E, F, G, H, I, J, K, L, M).
+
+module_sub_set_lambda_count(MI0, G, MI) :-
+ MI0 = module_sub(A, B, C, D, E, F, _, H, I, J, K, L, M),
+ MI = module_sub(A, B, C, D, E, F, G, H, I, J, K, L, M).
+
+module_sub_set_pragma_exported_procs(MI0, H, MI) :-
+ MI0 = module_sub(A, B, C, D, E, F, G, _, I, J, K, L, M),
+ MI = module_sub(A, B, C, D, E, F, G, H, I, J, K, L, M).
+
+module_sub_set_base_gen_infos(MI0, I, MI) :-
+ MI0 = module_sub(A, B, C, D, E, F, G, H, _, J, K, L, M),
+ MI = module_sub(A, B, C, D, E, F, G, H, I, J, K, L, M).
+
+module_sub_set_base_gen_layouts(MI0, J, MI) :-
+ MI0 = module_sub(A, B, C, D, E, F, G, H, I, _, K, L, M),
+ MI = module_sub(A, B, C, D, E, F, G, H, I, J, K, L, M).
+
+module_sub_set_stratified_preds(MI0, K, MI) :-
+ MI0 = module_sub(A, B, C, D, E, F, G, H, I, J, _, L, M),
+ MI = module_sub(A, B, C, D, E, F, G, H, I, J, K, L, M).
+
+module_sub_set_unused_arg_info(MI0, L, MI) :-
+ MI0 = module_sub(A, B, C, D, E, F, G, H, I, J, K, _, M),
+ MI = module_sub(A, B, C, D, E, F, G, H, I, J, K, L, M).
+
+module_sub_set_model_non_pragma_count(MI0, M, MI) :-
+ MI0 = module_sub(A, B, C, D, E, F, G, H, I, J, K, L, _),
+ MI = module_sub(A, B, C, D, E, F, G, H, I, J, K, L, M).
+
+%-----------------------------------------------------------------------------%
+
+% :- type module_info
+% ---> module(
+% A module_sub_info,
+% B predicate_table,
+% C unify_requests,
+% D special_pred_map,
+% E continuation_info,
+% F type_table,
+% G inst_table,
+% H mode_table,
+% I cons_table,
+% J int % cell count, passed into code_info
+% % and used to generate unique label
+% % numbers for constant terms in the
+% % generated C code
+% ).
+
+%-----------------------------------------------------------------------------%
+
+ % Various predicates which access the module_info data structure.
+
+module_info_get_sub_info(MI0, A) :-
+ MI0 = module(A, _, _, _, _, _, _, _, _, _).
+
+module_info_get_predicate_table(MI0, B) :-
+ MI0 = module(_, B, _, _, _, _, _, _, _, _).
+
+module_info_get_unify_requests(MI0, C) :-
+ MI0 = module(_, _, C, _, _, _, _, _, _, _).
+
+module_info_get_special_pred_map(MI0, D) :-
+ MI0 = module(_, _, _, D, _, _, _, _, _, _).
+
+module_info_get_continuation_info(MI0, E) :-
+ MI0 = module(_, _, _, _, E, _, _, _, _, _).
+
+module_info_types(MI0, F) :-
+ MI0 = module(_, _, _, _, _, F, _, _, _, _).
+
+module_info_insts(MI0, G) :-
+ MI0 = module(_, _, _, _, _, _, G, _, _, _).
+
+module_info_modes(MI0, H) :-
+ MI0 = module(_, _, _, _, _, _, _, H, _, _).
+
+module_info_ctors(MI0, I) :-
+ MI0 = module(_, _, _, _, _, _, _, _, I, _).
+
+module_info_get_cell_count(MI0, J) :-
+ MI0 = module(_, _, _, _, _, _, _, _, _, J).
+
+%-----------------------------------------------------------------------------%
+
+ % Various predicates which modify the module_info data structure.
+
+module_info_set_sub_info(MI0, A, MI) :-
+ MI0 = module(_, B, C, D, E, F, G, H, I, J),
+ MI = module(A, B, C, D, E, F, G, H, I, J).
+
+module_info_set_predicate_table(MI0, B, MI) :-
+ MI0 = module(A, _, C, D, E, F, G, H, I, J),
+ MI = module(A, B, C, D, E, F, G, H, I, J).
+
+module_info_set_unify_requests(MI0, C, MI) :-
+ MI0 = module(A, B, _, D, E, F, G, H, I, J),
+ MI = module(A, B, C, D, E, F, G, H, I, J).
+
+module_info_set_special_pred_map(MI0, D, MI) :-
+ MI0 = module(A, B, C, _, E, F, G, H, I, J),
+ MI = module(A, B, C, D, E, F, G, H, I, J).
+
+module_info_set_continuation_info(MI0, E, MI) :-
+ MI0 = module(A, B, C, D, _, F, G, H, I, J),
+ MI = module(A, B, C, D, E, F, G, H, I, J).
+
+module_info_set_types(MI0, F, MI) :-
+ MI0 = module(A, B, C, D, E, _, G, H, I, J),
+ MI = module(A, B, C, D, E, F, G, H, I, J).
+
+module_info_set_insts(MI0, G, MI) :-
+ MI0 = module(A, B, C, D, E, F, _, H, I, J),
+ MI = module(A, B, C, D, E, F, G, H, I, J).
+
+module_info_set_modes(MI0, H, MI) :-
+ MI0 = module(A, B, C, D, E, F, G, _, I, J),
+ MI = module(A, B, C, D, E, F, G, H, I, J).
+
+module_info_set_ctors(MI0, I, MI) :-
+ MI0 = module(A, B, C, D, E, F, G, H, _, J),
+ MI = module(A, B, C, D, E, F, G, H, I, J).
+
+module_info_set_cell_count(MI0, J, MI) :-
+ MI0 = module(A, B, C, D, E, F, G, H, I, _),
+ MI = module(A, B, C, D, E, F, G, H, I, J).
+
+%-----------------------------------------------------------------------------%
+
+ % Various predicates which access the module_sub_info data structure
+ % via the module_info structure.
+
+module_info_name(MI0, A) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_get_name(MS0, A).
+
+module_info_globals(MI0, B) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_get_globals(MS0, B).
+
+module_info_get_c_header(MI0, C) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_get_c_header_info(MS0, C).
+
+module_info_get_c_body_code(MI0, D) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_get_c_body_info(MS0, D).
+
+module_info_get_maybe_dependency_info(MI0, E) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_get_maybe_dependency_info(MS0, E).
+
+module_info_num_errors(MI0, F) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_get_num_errors(MS0, F).
+
+module_info_get_lambda_count(MI0, G) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_get_lambda_count(MS0, G).
+
+module_info_get_pragma_exported_procs(MI0, H) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_get_pragma_exported_procs(MS0, H).
+
+module_info_base_gen_infos(MI0, I) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_get_base_gen_infos(MS0, I).
+
+module_info_base_gen_layouts(MI0, J) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_get_base_gen_layouts(MS0, J).
+
+module_info_stratified_preds(MI0, K) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_get_stratified_preds(MS0, K).
+
+module_info_unused_arg_info(MI0, L) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_get_unused_arg_info(MS0, L).
+
+module_info_get_model_non_pragma_count(MI0, M) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_get_model_non_pragma_count(MS0, M).
+
+%-----------------------------------------------------------------------------%
+
+ % Various predicates which modify the module_sub_info data structure
+ % via the module_info structure.
+
+module_info_set_c_header(MI0, C, MI) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_set_c_header_info(MS0, C, MS),
+ module_info_set_sub_info(MI0, MS, MI).
+
+module_info_set_c_body_code(MI0, D, MI) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_set_c_body_info(MS0, D, MS),
+ module_info_set_sub_info(MI0, MS, MI).
+
+module_info_set_maybe_dependency_info(MI0, E, MI) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_set_maybe_dependency_info(MS0, E, MS),
+ module_info_set_sub_info(MI0, MS, MI).
+
+module_info_set_num_errors(MI0, F, MI) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_set_num_errors(MS0, F, MS),
+ module_info_set_sub_info(MI0, MS, MI).
+
+module_info_set_lambda_count(MI0, G, MI) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_set_lambda_count(MS0, G, MS),
+ module_info_set_sub_info(MI0, MS, MI).
+
+module_info_set_pragma_exported_procs(MI0, H, MI) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_set_pragma_exported_procs(MS0, H, MS),
+ module_info_set_sub_info(MI0, MS, MI).
+
+module_info_set_base_gen_infos(MI0, I, MI) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_set_base_gen_infos(MS0, I, MS),
+ module_info_set_sub_info(MI0, MS, MI).
+
+module_info_set_base_gen_layouts(MI0, J, MI) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_set_base_gen_layouts(MS0, J, MS),
+ module_info_set_sub_info(MI0, MS, MI).
+
+module_info_set_stratified_preds(MI0, K, MI) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_set_stratified_preds(MS0, K, MS),
+ module_info_set_sub_info(MI0, MS, MI).
+
+module_info_set_unused_arg_info(MI0, L, MI) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_set_unused_arg_info(MS0, L, MS),
+ module_info_set_sub_info(MI0, MS, MI).
+
+module_info_set_model_non_pragma_count(MI0, M, MI) :-
+ module_info_get_sub_info(MI0, MS0),
+ module_sub_set_model_non_pragma_count(MS0, M, MS),
+ module_info_set_sub_info(MI0, MS, MI).
+
+%-----------------------------------------------------------------------------%
+
+ % Various predicates which do simple things that are nevertheless
+ % beyond the capability of an access predicate.
+
+module_info_preds(MI, Preds) :-
+ module_info_get_predicate_table(MI, PredTable),
+ predicate_table_get_preds(PredTable, Preds).
+
+module_info_pred_info(MI, PredId, PredInfo) :-
+ module_info_preds(MI, Preds),
( map__search(Preds, PredId, PredInfoPrime) ->
PredInfo = PredInfoPrime
;
@@ -445,272 +832,85 @@
error(Msg)
).
-module_info_pred_proc_info(ModuleInfo, PredId, ProcId, PredInfo, ProcInfo) :-
- module_info_pred_info(ModuleInfo, PredId, PredInfo),
+module_info_pred_proc_info(MI, PredId, ProcId, PredInfo, ProcInfo) :-
+ module_info_pred_info(MI, PredId, PredInfo),
pred_info_procedures(PredInfo, Procs),
map__lookup(Procs, ProcId, ProcInfo).
-module_info_predids(ModuleInfo, PredIds) :-
- module_info_get_predicate_table(ModuleInfo, PredicateTable),
- predicate_table_get_predids(PredicateTable, PredIds).
-
-module_info_reverse_predids(ModuleInfo0, ModuleInfo) :-
- module_info_get_predicate_table(ModuleInfo0, PredicateTable0),
- predicate_table_reverse_predids(PredicateTable0, PredicateTable),
- module_info_set_predicate_table(ModuleInfo0, PredicateTable,
- ModuleInfo).
-
-module_info_get_unify_requests(ModuleInfo, Requests) :-
- ModuleInfo = module(_, _, _, Requests, _, _, _, _, _, _, _, _,
- _, _, _, _, _, _, _).
-
-module_info_get_special_pred_map(ModuleInfo, SpecialPredMap) :-
- ModuleInfo = module(_, _, _, _, SpecialPredMap,
- _, _, _, _, _, _, _, _, _, _, _, _, _, _).
-
-module_info_types(ModuleInfo, Types) :-
- ModuleInfo = module(_, _, _, _, _, _, Types, _, _, _, _, _, _,
- _, _, _, _, _, _).
-
-module_info_typeids(ModuleInfo, TypeIDs) :-
- ModuleInfo = module(_, _, _, _, _, _, Types, _, _, _, _, _, _,
- _, _, _, _, _, _),
- map__keys(Types, TypeIDs).
-
-module_info_insts(ModuleInfo, Insts) :-
- ModuleInfo = module(_, _, _, _, _, _, _, Insts, _, _, _, _, _,
- _, _, _, _, _, _).
+module_info_predids(MI, PredIds) :-
+ module_info_get_predicate_table(MI, PredTable),
+ predicate_table_get_predids(PredTable, PredIds).
+
+module_info_reverse_predids(MI0, MI) :-
+ module_info_get_predicate_table(MI0, PredTable0),
+ predicate_table_reverse_predids(PredTable0, PredTable),
+ module_info_set_predicate_table(MI0, PredTable, MI).
+
+module_info_remove_predid(MI0, PredId, MI) :-
+ module_info_get_predicate_table(MI0, PredTable0),
+ predicate_table_remove_predid(PredTable0, PredId, PredTable),
+ module_info_set_predicate_table(MI0, PredTable, MI).
+
+module_info_remove_predicate(PredId, MI0, MI) :-
+ module_info_get_predicate_table(MI0, PredTable0),
+ predicate_table_remove_predicate(PredTable0, PredId, PredTable),
+ module_info_set_predicate_table(MI0, PredTable, MI).
+
+module_info_set_preds(MI0, Preds, MI) :-
+ module_info_get_predicate_table(MI0, PredTable0),
+ predicate_table_set_preds(PredTable0, Preds, PredTable),
+ module_info_set_predicate_table(MI0, PredTable, MI).
+
+module_info_set_pred_info(MI0, PredId, PredInfo, MI) :-
+ module_info_preds(MI0, Preds0),
+ map__set(Preds0, PredId, PredInfo, Preds),
+ module_info_set_preds(MI0, Preds, MI).
+
+module_info_typeids(MI, TypeIds) :-
+ module_info_types(MI, Types),
+ map__keys(Types, TypeIds).
-module_info_instids(ModuleInfo, InstIDs) :-
- module_info_insts(ModuleInfo, InstTable),
+module_info_instids(MI, InstIds) :-
+ module_info_insts(MI, InstTable),
inst_table_get_user_insts(InstTable, UserInstTable),
- user_inst_table_get_inst_ids(UserInstTable, InstIDs).
+ user_inst_table_get_inst_ids(UserInstTable, InstIds).
-module_info_modes(ModuleInfo, Modes) :-
- ModuleInfo = module(_, _, _, _, _, _, _, _, Modes, _, _, _, _,
- _, _, _, _, _, _).
-
-module_info_modeids(ModuleInfo, ModeIDs) :-
- ModuleInfo = module(_, _, _, _, _, _, _, _, Modes, _, _, _, _,
- _, _, _, _, _, _),
- mode_table_get_mode_ids(Modes, ModeIDs).
-
-module_info_ctors(ModuleInfo, Ctors) :-
- ModuleInfo = module(_, _, _, _, _, _, _, _, _, Ctors, _, _, _,
- _, _, _, _, _, _).
-
-module_info_consids(ModuleInfo, ConsIDs) :-
- ModuleInfo = module(_, _, _, _, _, _, _, _, _, Ctors, _, _, _,
- _, _, _, _, _, _),
- map__keys(Ctors, ConsIDs).
-
-module_info_dependency_info(ModuleInfo, DepInfo) :-
- ModuleInfo = module(_, _, _, _, _, _, _, _, _, _, DepInfo0, _, _,
- _, _, _, _, _, _),
- ( DepInfo0 = yes(DepInfo1) ->
- DepInfo = DepInfo1
+module_info_modeids(MI, ModeIds) :-
+ module_info_modes(MI, Modes),
+ mode_table_get_mode_ids(Modes, ModeIds).
+
+module_info_consids(MI, ConsIds) :-
+ module_info_ctors(MI, Ctors),
+ map__keys(Ctors, ConsIds).
+
+module_info_dependency_info(MI, DepInfo) :-
+ module_info_get_maybe_dependency_info(MI, MaybeDepInfo),
+ ( MaybeDepInfo = yes(DepInfoPrime) ->
+ DepInfo = DepInfoPrime
;
- error("Attempted to access uninitialised dependency_info")
+ error("Attempted to access invalid dependency_info")
).
-module_info_unused_arg_info(ModuleInfo, UnusedArgInfo) :-
- ModuleInfo = module(_, _, _, _, _, _, _, _, _, _, _, _, _,
- _, _, _, _, UnusedArgInfo, _).
-
-module_info_dependency_info_built(ModuleInfo) :-
- ModuleInfo = module(_, _, _, _, _, _, _, _, _, _, yes(_), _, _,
- _, _, _, _, _, _).
-
-module_info_num_errors(ModuleInfo, NumErrors) :-
- ModuleInfo = module(_, _, _, _, _, _, _, _, _, _, _, NumErrors,
- _, _, _, _, _, _, _).
-
-module_info_base_gen_infos(ModuleInfo, BaseGenInfos) :-
- ModuleInfo = module(_, _, _, _, _, _, _, _, _, _, _, _, _, _,
- base_gen_data(BaseGenInfos, _), _, _, _, _).
-
-module_info_base_gen_layouts(ModuleInfo, BaseGenLayouts) :-
- ModuleInfo = module(_, _, _, _, _, _, _, _, _, _, _, _, _, _,
- base_gen_data(_, BaseGenLayouts), _, _, _, _).
-
-module_info_globals(ModuleInfo, Globals) :-
- ModuleInfo = module(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
- Globals, _, _, _).
-
-module_info_stratified_preds(ModuleInfo, StratPreds) :-
- ModuleInfo = module(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
- _, StratPreds, _, _).
-
-module_info_get_cell_count(ModuleInfo, CellCount) :-
- ModuleInfo = module(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
- _, _, _, CellCount).
-
-% not used:
-% module_info_num_warnings(ModuleInfo, NumWarnings) :-
-% ModuleInfo = module(_, _, _, _, _, _, _, _, _, _, _, _, NumWarnings).
+module_info_set_dependency_info(MI0, DependencyInfo, MI) :-
+ module_info_set_maybe_dependency_info(MI0, yes(DependencyInfo), MI).
- % Various predicates which modify the module_info data structure.
+module_info_clobber_dependency_info(MI0, MI) :-
+ module_info_set_maybe_dependency_info(MI0, no, MI).
-module_info_set_name(ModuleInfo0, Name, ModuleInfo) :-
- ModuleInfo0 = module(_, B, C, D, E, F, G, H, I, J, K, L, M, N,
- O, P, Q, R, S),
- ModuleInfo = module(Name, B, C, D, E, F, G, H, I, J, K, L, M, N,
- O, P, Q, R, S).
-
-module_info_set_predicate_table(ModuleInfo0, PredicateTable, ModuleInfo) :-
- ModuleInfo0 = module(A, B, _, D, E, F, G, H, I, J, K, L, M, N,
- O, P, Q, R, S),
- ModuleInfo = module(A, B, PredicateTable,
- D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S).
-
-module_info_set_preds(ModuleInfo0, Preds, ModuleInfo) :-
- module_info_get_predicate_table(ModuleInfo0, PredicateTable0),
- predicate_table_set_preds(PredicateTable0, Preds, PredicateTable),
- module_info_set_predicate_table(ModuleInfo0, PredicateTable,
- ModuleInfo).
-
-module_info_set_pred_info(ModuleInfo0, PredID, PredInfo, ModuleInfo) :-
- module_info_preds(ModuleInfo0, Preds0),
- map__set(Preds0, PredID, PredInfo, Preds),
- module_info_set_preds(ModuleInfo0, Preds, ModuleInfo).
-
-module_info_set_unify_requests(ModuleInfo0, Requests, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, _, E, F, G, H, I, J, K, L, M, N,
- O, P, Q, R, S),
- ModuleInfo = module(A, B, C, Requests, E, F, G, H, I, J, K, L,
- M, N, O, P, Q, R, S).
-
-module_info_set_special_pred_map(ModuleInfo0, SpecialPredMap, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, _, F, G, H, I, J, K, L, M,
- N, O, P, Q, R, S),
- ModuleInfo = module(A, B, C, D, SpecialPredMap,
- F, G, H, I, J, K, L, M, N, O, P, Q, R, S).
-
-module_info_set_continuation_info(ModuleInfo0, ContinuationInfo, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, _, G, H, I, J, K, L, M, N,
- O, P, Q, R, S),
- ModuleInfo = module(A, B, C, D, E, ContinuationInfo, G, H, I, J, K, L,
- M, N, O, P, Q, R, S).
-
-module_info_set_types(ModuleInfo0, Types, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, _, H, I, J, K, L, M, N,
- O, P, Q, R, S),
- ModuleInfo = module(A, B, C, D, E, F, Types, H, I, J, K, L, M,
- N, O, P, Q, R, S).
-
-module_info_set_insts(ModuleInfo0, Insts, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, G, _, I, J, K, L, M, N,
- O, P, Q, R, S),
- ModuleInfo = module(A, B, C, D, E, F, G, Insts, I, J, K, L, M,
- N, O, P, Q, R, S).
-
-module_info_set_modes(ModuleInfo0, Modes, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, G, H, _, J, K, L, M, N,
- O, P, Q, R, S),
- ModuleInfo = module(A, B, C, D, E, F, G, H, Modes, J, K, L, M,
- N, O, P, Q, R, S).
-
-module_info_set_ctors(ModuleInfo0, Ctors, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, G, H, I, _, K, L, M, N,
- O, P, Q, R, S),
- ModuleInfo = module(A, B, C, D, E, F, G, H, I, Ctors, K, L, M,
- N, O, P, Q, R, S).
-
-module_info_set_dependency_info(ModuleInfo0, DepInfo, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, G, H, I, J, _, L, M, N,
- O, P, Q, R, S),
- ModuleInfo = module(A, B, C, D, E, F, G, H, I, J, yes(DepInfo),
- L, M, N, O, P, Q, R, S).
-
-module_info_clobber_dependency_info(ModuleInfo0, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, G, H, I, J, _,
- L, M, N, O, P, Q, R, S),
- ModuleInfo = module(A, B, C, D, E, F, G, H, I, J, no,
- L, M, N, O, P, Q, R, S).
-
-module_info_set_num_errors(ModuleInfo0, Errs, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, G, H, I, J, K, _, M, N,
- O, P, Q, R, S),
- ModuleInfo = module(A, B, C, D, E, F, G, H, I, J, K, Errs, M, N,
- O, P, Q, R, S).
-
-module_info_incr_errors(ModuleInfo0, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, G, H, I, J, K, Errs0, M,
- N, O, P, Q, R, S),
+module_info_incr_errors(MI0, MI) :-
+ module_info_num_errors(MI0, Errs0),
Errs is Errs0 + 1,
- ModuleInfo = module(A, B, C, D, E, F, G, H, I, J, K, Errs, M, N,
- O, P, Q, R, S).
+ module_info_set_num_errors(MI0, Errs, MI).
-/* not used
-module_info_incr_warnings(ModuleInfo0, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, G, H, I, J, K, L, Warns0),
- Warns is Warns0 + 1,
- ModuleInfo = module(A, B, C, D, E, F, G, H, I, J, K, L, Warns).
-*/
-module_info_next_lambda_count(ModuleInfo0, Count, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, G, H, I, J, K, L, Count0, N, O,
- P, Q, R, S),
+module_info_next_lambda_count(MI0, Count, MI) :-
+ module_info_get_lambda_count(MI0, Count0),
Count is Count0 + 1,
- ModuleInfo = module(A, B, C, D, E, F, G, H, I, J, K, L, Count,
- N, O, P, Q, R, S).
+ module_info_set_lambda_count(MI0, Count, MI).
-module_info_get_continuation_info(ModuleInfo, ContinuationInfo) :-
- ModuleInfo = module(_, _, _, _, _, ContinuationInfo, _, _, _, _, _, _,
- _, _, _, _, _, _, _).
-
-module_info_get_pragma_exported_procs(ModuleInfo, Procs) :-
- ModuleInfo = module(_, _, _, _, _, _, _, _, _, _, _, _, _,
- Procs, _, _, _, _, _).
-
-module_info_set_pragma_exported_procs(ModuleInfo0, Procs, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, G, H, I, J, K, L, M, _,
- O, P, Q, R, S),
- ModuleInfo = module(A, B, C, D, E, F, G, H, I, J, K, L, M, Procs,
- O, P, Q, R, S).
-
-module_info_set_base_gen_infos(ModuleInfo0, BaseGenInfos, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N,
- base_gen_data(_, BaseGenLayouts), P, Q, R, S),
- ModuleInfo = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N,
- base_gen_data(BaseGenInfos, BaseGenLayouts), P, Q, R, S).
-
-module_info_set_base_gen_layouts(ModuleInfo0, BaseGenLayouts, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N,
- base_gen_data(BaseGenInfos, _), P, Q, R, S),
- ModuleInfo = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N,
- base_gen_data(BaseGenInfos, BaseGenLayouts), P, Q, R, S).
-
-module_info_set_stratified_preds(ModuleInfo0, StratPreds, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O,
- P, _, R, S),
- ModuleInfo = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N,
- O, P, StratPreds, R, S).
-
-module_info_set_unused_arg_info(ModuleInfo0, UnusedArgInfo, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, G, H, I, J, K,
- L, M, N, O, P, Q, _, S),
- ModuleInfo = module(A, B, C, D, E, F, G, H, I, J, K,
- L, M, N, O, P, Q, UnusedArgInfo, S).
-
-module_info_set_cell_count(ModuleInfo0, CellCount, ModuleInfo) :-
- ModuleInfo0 = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O,
- P, Q, R, _),
- ModuleInfo = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N,
- O, P, Q, R, CellCount).
-
-module_info_remove_predid(ModuleInfo0, PredId, ModuleInfo) :-
- module_info_get_predicate_table(ModuleInfo0, PredicateTable0),
- predicate_table_remove_predid(PredicateTable0, PredId,
- PredicateTable),
- module_info_set_predicate_table(ModuleInfo0, PredicateTable,
- ModuleInfo).
-
-module_info_remove_predicate(PredId, ModuleInfo0, ModuleInfo) :-
- module_info_get_predicate_table(ModuleInfo0, PredicateTable0),
- predicate_table_remove_predicate(PredicateTable0, PredId,
- PredicateTable),
- module_info_set_predicate_table(ModuleInfo0, PredicateTable,
- ModuleInfo).
+module_info_next_model_non_pragma_count(MI0, Count, MI) :-
+ module_info_get_model_non_pragma_count(MI0, Count0),
+ Count is Count0 + 1,
+ module_info_set_model_non_pragma_count(MI0, Count, MI).
% After we have finished constructing the symbol tables,
% we balance all the binary trees, to improve performance
@@ -777,32 +977,27 @@
:- type dependency_info --->
dependency_info(
dependency_graph, % Dependency graph
- dependency_ordering, % Dependency ordering
- set(pred_proc_id), % Unused procs
- unit, % Junk slots
- unit,
- unit
+ dependency_ordering % Dependency ordering
).
hlds_dependency_info_init(DepInfo) :-
- DepInfo = dependency_info(DepRel, DepOrd, Unused, unit, unit, unit),
relation__init(DepRel),
DepOrd = [],
- set__init(Unused).
+ DepInfo = dependency_info(DepRel, DepOrd).
-hlds_dependency_info_get_dependency_graph(DepInfo, DepRel) :-
- DepInfo = dependency_info(DepRel, _, _, _, _, _).
+hlds_dependency_info_get_dependency_graph(DepInfo, A) :-
+ DepInfo = dependency_info(A, _).
-hlds_dependency_info_get_dependency_ordering(DepInfo, DepOrd) :-
- DepInfo = dependency_info(_, DepOrd, _, _, _, _).
+hlds_dependency_info_get_dependency_ordering(DepInfo, B) :-
+ DepInfo = dependency_info(_, B).
-hlds_dependency_info_set_dependency_graph(DepInfo0, DepRel, DepInfo) :-
- DepInfo0 = dependency_info(_, B, C, D, E, F),
- DepInfo = dependency_info(DepRel, B, C, D, E, F).
+hlds_dependency_info_set_dependency_graph(DepInfo0, A, DepInfo) :-
+ DepInfo0 = dependency_info(_, B),
+ DepInfo = dependency_info(A, B).
-hlds_dependency_info_set_dependency_ordering(DepInfo0, DepRel, DepInfo) :-
- DepInfo0 = dependency_info(A, _, C, D, E, F),
- DepInfo = dependency_info(A, DepRel, C, D, E, F).
+hlds_dependency_info_set_dependency_ordering(DepInfo0, B, DepInfo) :-
+ DepInfo0 = dependency_info(A, _),
+ DepInfo = dependency_info(A, B).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
cvs diff: Diffing notes
More information about the developers
mailing list