mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-20 16:31:04 +00:00
Estimated hours taken: 10
hlds, hlds_module, hlds_pred, hlds_goal, hlds_data:
Divided the old hlds.m into four files:
hlds_module.m defines the data structures that deal with issues
that are wider than a single predicate. These data structures are
the module_info structure, dependency_info, the predicate table
and the shape table.
hlds_pred.m defined pred_info and proc_info, pred_id and proc_id.
hlds_goal.m defines hlds__goal, hlds__goal_{expr,info}, and the
other parts of goal structures.
hlsd_data.m defines the HLDS types that deal with issues related
to data and its representation: function symbols, types, insts, modes.
It also defines the types related to determinism.
hlds.m is now an empty module. I have not removed it from CVS
because we may need the name hlds.m again, and CVS does not like
the reuse of a name once removed.
other modules:
Import the necessary part of hlds.
det_analysis:
Define a type that was up to now improperly defined in hlds.m.
prog_io:
Move the definition of type determinism to hlds_data. This decision
may need to be revisited when prog_io is broken up.
dnf, lambda:
Simplify the task of defining predicates.
llds:
Fix some comments.
mercury_compile:
If the option -d all is given, dump all HLDS stages.
shape, unused_args:
Fix formatting.
79 lines
2.8 KiB
Mathematica
79 lines
2.8 KiB
Mathematica
%-----------------------------------------------------------------------------%
|
|
% Copyright (C) 1995 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: transform.m
|
|
% Main author: bromage.
|
|
%
|
|
% This module defines the primitive operations that may be performed
|
|
% on a logic program. These include:
|
|
%
|
|
% - unfold (NYI)
|
|
% Replaces a goal with its possible expansions.
|
|
%
|
|
% - fold (NYI)
|
|
% Opposite of unfold (not surprisingly).
|
|
%
|
|
% - definition (NYI)
|
|
% Define a new predicate with a given goal.
|
|
%
|
|
% - identity (NYI)
|
|
% Apply an identity (such as the associative law for
|
|
% addition) to a goal.
|
|
%
|
|
% These operations form the basis of most high-level transformations.
|
|
%
|
|
% Also included is a conjunction rescheduler. Useful just in case
|
|
% your transformer upset the ordering in a conjunction.
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- module transform.
|
|
:- interface.
|
|
:- import_module hlds_goal, llds, mode_info.
|
|
|
|
%:- pred unfold__in_proc(pred_id, proc_id, hlds__goal_expr,
|
|
% mode_info, mode_info).
|
|
%:- mode unfold__in_proc(in, in, out, mode_info_di, module_info_uo) is det.
|
|
|
|
:- pred transform__reschedule_conj(list(hlds__goal), list(hlds__goal),
|
|
mode_info, mode_info).
|
|
:- mode transform__reschedule_conj(in, out, mode_info_di, mode_info_uo) is det.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
:- import_module list, map, set, std_util.
|
|
:- import_module mode_util, delay_info, term, require.
|
|
:- import_module varset, code_aux, prog_io.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
% unfold__in_proc(
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
transform__reschedule_conj([], []) --> [].
|
|
transform__reschedule_conj([Goal0 | Goals0], Goals) -->
|
|
=(ModeInfo0),
|
|
{ mode_info_get_instmap(ModeInfo0, InstMap0) },
|
|
{ mode_info_get_delay_info(ModeInfo0, DelayInfo0) },
|
|
|
|
{ delay_info__wakeup_goals(DelayInfo0, WokenGoals, DelayInfo1) },
|
|
mode_info_set_delay_info(DelayInfo1),
|
|
( { WokenGoals \= [] } ->
|
|
{ list__append(WokenGoals, [Goal0 | Goals0], Goals1) },
|
|
transform__reschedule_conj(Goals1, Goals)
|
|
;
|
|
{ Goal0 = _Goal0Goal - Goal0Info },
|
|
{ goal_info_get_instmap_delta(Goal0Info, InstMapDelta) },
|
|
{ apply_instmap_delta(InstMap0, InstMapDelta, InstMap1) },
|
|
mode_info_set_instmap(InstMap1),
|
|
transform__reschedule_conj(Goals0, Goals1),
|
|
{ Goals = [Goal0 | Goals1] }
|
|
).
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
%-----------------------------------------------------------------------------%
|