mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 09:23:44 +00:00
Each of the new modules, and intermod.m itself, has better cohesion
than the original intermod.m.
compiler/intermod_decide.m:
New module that contains the code that decides what to put
into .opt files.
compiler/intermod_info.m:
New module that defines the intermod_info type, which records
the results of those decisions.
compiler/intermod_mark_exported.m:
New module that contains the code that updates the statuses of entitties
that we *would* export if the compiler were asked to generate a .opt file,
but its current task is something else.
compiler/intermod_status.m:
New module that contains the code that decides whether an entity's
status allows it to be opt-exported.
compiler/intermod.m:
Delete the code moved to other modules.
compiler/transform_hlds.m:
Include the new modules.
compiler/notes/compiler_design.html:
Document the new modules.
compiler/mercury_compile_front_end.m:
Conform to the changes above.
compiler/intermod_analysis.m:
Fix a comment.
94 lines
3.4 KiB
Mathematica
94 lines
3.4 KiB
Mathematica
|
|
%---------------------------------------------------------------------------%
|
|
% vim: ft=mercury ts=4 sw=4 et
|
|
%---------------------------------------------------------------------------%
|
|
% Copyright (C) 2023 The Mercury team.
|
|
% This file may only be copied under the terms of the GNU General
|
|
% Public License - see the file COPYING in the Mercury distribution.
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% This module contains code that makes decisions about whether an entity's
|
|
% status allows it to be written out to .opt files.
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module transform_hlds.intermod_status.
|
|
:- interface.
|
|
|
|
:- import_module hlds.
|
|
:- import_module hlds.status.
|
|
|
|
:- import_module bool.
|
|
|
|
% Should a declaration with the given status be written to the `.opt' file?
|
|
%
|
|
:- func type_status_to_write(type_status) = bool.
|
|
:- func inst_status_to_write(inst_status) = bool.
|
|
:- func mode_status_to_write(mode_status) = bool.
|
|
:- func typeclass_status_to_write(typeclass_status) = bool.
|
|
:- func instance_status_to_write(instance_status) = bool.
|
|
:- func pred_status_to_write(pred_status) = bool.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
type_status_to_write(type_status(OldStatus)) = ToWrite :-
|
|
ToWrite = old_status_to_write(OldStatus).
|
|
|
|
inst_status_to_write(inst_status(InstModeStatus)) = ToWrite :-
|
|
ToWrite = instmode_status_to_write(InstModeStatus).
|
|
|
|
mode_status_to_write(mode_status(InstModeStatus)) = ToWrite :-
|
|
ToWrite = instmode_status_to_write(InstModeStatus).
|
|
|
|
typeclass_status_to_write(typeclass_status(OldStatus)) = ToWrite :-
|
|
ToWrite = old_status_to_write(OldStatus).
|
|
|
|
instance_status_to_write(instance_status(OldStatus)) = ToWrite :-
|
|
ToWrite = old_status_to_write(OldStatus).
|
|
|
|
pred_status_to_write(pred_status(OldStatus)) = ToWrite :-
|
|
ToWrite = old_status_to_write(OldStatus).
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- func instmode_status_to_write(new_instmode_status) = bool.
|
|
|
|
instmode_status_to_write(InstModeStatus) = ToWrite :-
|
|
(
|
|
InstModeStatus = instmode_defined_in_this_module(InstModeExport),
|
|
(
|
|
InstModeExport = instmode_export_anywhere,
|
|
ToWrite = no
|
|
;
|
|
( InstModeExport = instmode_export_only_submodules
|
|
; InstModeExport = instmode_export_nowhere
|
|
),
|
|
ToWrite = yes
|
|
)
|
|
;
|
|
InstModeStatus = instmode_defined_in_other_module(_),
|
|
ToWrite = no
|
|
).
|
|
|
|
:- func old_status_to_write(old_import_status) = bool.
|
|
|
|
old_status_to_write(status_imported(_)) = no.
|
|
old_status_to_write(status_abstract_imported) = no.
|
|
old_status_to_write(status_pseudo_imported) = no.
|
|
old_status_to_write(status_opt_imported) = no.
|
|
old_status_to_write(status_exported) = no.
|
|
old_status_to_write(status_opt_exported) = yes.
|
|
old_status_to_write(status_abstract_exported) = yes.
|
|
old_status_to_write(status_pseudo_exported) = no.
|
|
old_status_to_write(status_exported_to_submodules) = yes.
|
|
old_status_to_write(status_local) = yes.
|
|
old_status_to_write(status_external(Status)) =
|
|
bool.not(old_status_is_exported(Status)).
|
|
|
|
%---------------------------------------------------------------------------%
|
|
:- end_module transform_hlds.intermod_status.
|
|
%---------------------------------------------------------------------------%
|