Files
mercury/compiler/transform.m
Zoltan Somogyi 20cd51e70a This is a cleanup diff; there are no changes in algorithms.
Estimated hours taken: 8
Branches: main

This is a cleanup diff; there are no changes in algorithms.

compiler/delay_info.m:
compiler/instmap.m:
compiler/inst_match.m:
compiler/inst_util.m:
compiler/make.module_target.m:
compiler/mode_errors.m:
compiler/modes.m:
compiler/mode_util.m:
compiler/process_util.m:
compiler/prog_io_goal.m:
compiler/prog_io.m:
compiler/prog_io_pragma.m:
compiler/prog_io_typeclass.m:
compiler/recompilation.check.m:
compiler/recompilation.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
compiler/unique_modes.m:
	Bring these modules up to date with our current style guidelines.
	Switch to predmode syntax and state variable notation where
	appropriate. Switch argument orders where this makes it possible
	to use state variable notation. Use the svmap and svset modules
	where appropriate. Fix inconsistent indentation; in some places,
	fix inconsistent placement of comments.

compiler/passes_aux.m:
compiler/modecheck_unify.m:
compiler/mercury_compile.m:
compiler/post_typecheck.m:
compiler/prog_io_dcg.m:
compiler/mode_ordering.m:
compiler/inst_graph.m:
compiler/polymorphism.m:
compiler/prog_io_util.m:
compiler/mode_debug.m:
compiler/mode_robdd.check.m:
compiler/transform.m:
	Minor changes to conform to the changed argument orders of some
	predicates in the cleaned up modules. Also, some minor cleanups.
2004-12-23 06:49:21 +00:00

79 lines
2.7 KiB
Mathematica

%-----------------------------------------------------------------------------%
% Copyright (C) 1995-1998, 2003-2004 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_hlds__transform.
:- interface.
:- import_module check_hlds__mode_info.
:- import_module hlds__hlds_goal.
:- import_module list.
:- pred transform__reschedule_conj(list(hlds_goal)::in, list(hlds_goal)::out,
mode_info::in, mode_info::out) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- implementation.
:- import_module check_hlds__delay_info.
:- import_module check_hlds__mode_util.
:- import_module hlds__instmap.
:- import_module parse_tree__prog_data.
:- import_module map, set, std_util.
:- import_module term, require.
:- import_module varset.
%-----------------------------------------------------------------------------%
transform__reschedule_conj([], [], !ModeInfo).
transform__reschedule_conj([Goal0 | Goals0], Goals, !ModeInfo) :-
mode_info_get_instmap(!.ModeInfo, InstMap0),
mode_info_get_delay_info(!.ModeInfo, DelayInfo0),
delay_info__wakeup_goals(WokenGoals, DelayInfo0, DelayInfo1),
mode_info_set_delay_info(DelayInfo1, !ModeInfo),
( WokenGoals \= [] ->
list__append(WokenGoals, [Goal0 | Goals0], Goals1),
transform__reschedule_conj(Goals1, Goals, !ModeInfo)
;
Goal0 = _Goal0Goal - Goal0Info,
goal_info_get_instmap_delta(Goal0Info, InstMapDelta),
instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap1),
mode_info_set_instmap(InstMap1, !ModeInfo),
transform__reschedule_conj(Goals0, Goals1, !ModeInfo),
Goals = [Goal0 | Goals1]
).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%