File: transform.m

package info (click to toggle)
mercury 0.9-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 18,488 kB
  • ctags: 9,800
  • sloc: objc: 146,680; ansic: 51,418; sh: 6,436; lisp: 1,567; cpp: 1,040; perl: 854; makefile: 450; asm: 232; awk: 203; exp: 32; fortran: 3; csh: 1
file content (79 lines) | stat: -rw-r--r-- 2,953 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
%-----------------------------------------------------------------------------%
% Copyright (C) 1995-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: 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, mode_info.
:- import_module list.

%:- 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 map, set, std_util.
:- import_module mode_util, delay_info, term, require.
:- import_module varset, code_aux, prog_data, instmap.

%-----------------------------------------------------------------------------%

% 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) },
	    { instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap1) },
	    mode_info_set_instmap(InstMap1),
	    transform__reschedule_conj(Goals0, Goals1),
	    { Goals = [Goal0 | Goals1] }
	).

%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%