Files
mercury/compiler/transform.m
Fergus Henderson 7597790760 Use sub-modules to structure the modules in the Mercury compiler directory.
The main aim of this change is to make the overall, high-level structure
of the compiler clearer, and to encourage better encapsulation of the
major components.

compiler/libs.m:
compiler/backend_libs.m:
compiler/parse_tree.m:
compiler/hlds.m:
compiler/check_hlds.m:
compiler/transform_hlds.m:
compiler/bytecode_backend.m:
compiler/aditi_backend.m:
compiler/ml_backend.m:
compiler/ll_backend.m:
compiler/top_level.m:
	New files.  One module for each of the major components of the
	Mercury compiler.  These modules contain (as separate sub-modules)
	all the other modules in the Mercury compiler, except gcc.m and
	mlds_to_gcc.m.

Mmakefile:
compiler/Mmakefile:
	Handle the fact that the top-level module is now `top_level',
	not `mercury_compile' (since `mercury_compile' is a sub-module
	of `top_level').

compiler/Mmakefile:
	Update settings of *FLAGS-<modulename> to use the appropriate
	nested module names.

compiler/recompilation_check.m:
compiler/recompilation_version.m:
compiler/recompilation_usage.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/recompilation.version.m:
	Convert the `recompilation_*' modules into sub-modules of the
	`recompilation' module.

compiler/*.m:
compiler/*.pp:
	Module-qualify the module names in `:- module', `:- import_module',
	and `:- use_module' declarations.

compiler/base_type_info.m:
compiler/base_type_layout.m:
	Deleted these unused empty modules.

compiler/prog_data.m:
compiler/globals.m:
	Move the `foreign_language' type from prog_data to globals.

compiler/mlds.m:
compiler/ml_util.m:
compiler/mlds_to_il.m:
	Import `globals', for `foreign_language'.

Mmake.common.in:
trace/Mmakefile:
runtime/Mmakefile:
	Rename the %.check.c targets as %.check_hdr.c,
	to avoid conflicts with compiler/recompilation.check.c.
2002-03-20 12:37:56 +00:00

81 lines
3.0 KiB
Mathematica

%-----------------------------------------------------------------------------%
% 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_hlds__transform.
:- interface.
:- import_module hlds__hlds_goal, check_hlds__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 check_hlds__mode_util, check_hlds__delay_info, term, require.
:- import_module varset, ll_backend__code_aux, parse_tree__prog_data.
:- import_module hlds__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] }
).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%