Files
mercury/tests/valid/lambda_recompute.m
Julien Fischer 459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00

106 lines
2.3 KiB
Mathematica

% Regression test.
% Date: Feb 27: 1998.
% Symptom: Software error: variable XX not found.
% Cause: mode_util:recompute_instmap_delta was not recomputing the instmap
% delta of the inner lambda goal after some duplicate call elimination was
% performed.
:- module lambda_recompute.
:- interface.
:- import_module io.
:- pred compile_display_list(display_list, io__state, io__state).
:- mode compile_display_list(out, di, uo) is det.
%------------------------------------------------------------------------------%
:- implementation.
:- import_module bool, char, float, int, list, map, require, std_util, pair, string.
%------------------------------------------------------------------------------%
compile_display_list([mon(PPos, 1)|DList]) -->
{ PPos = 1 - 1 },
{ map__init(MapIKnow) },
{ for(0, 1, (pred(X::in, in, out) is det -->
for(0, 1, (pred(Y::in, in, out) is det -->
( { search(MapIKnow, pos(X, Y), Place) } ->
{ Place = place(Kind, _Flags, Obj) },
( (
{ Kind \= 1 }
;
{ PPos = pos(X, Y) }
)
->
element(place(pos(X, Y), Kind)),
( { Obj = [_N - T|_] } ->
element(thing(pos(X, Y), T))
;
[]
)
;
[]
)
;
[]
)
))
), [], DList) }.
:- pred element(element, display_list, display_list).
:- mode element(in, in, out) is det.
element(E, DL, [E|DL]).
:- type map == map(pos, place).
:- type pos == pair(int).
:- type place
---> place(int, int, list(pair(int))).
:- func pos(int, int) = pos.
:- external(pos/2).
:- type map_i_know
---> map(
list(map),
map,
list(map)
).
:- type element
---> place(pos, int)
; thing(pos, int)
; mon(pos, int)
.
:- type display_list == list(element).
%------------------------------------------------------------------------------%
:- pred get_monst(int, int, io__state, io__state).
:- mode get_monst(in, out, di, uo) is det.
:- external(get_monst/4).
:- pred for(int, int, pred(int, T, T), T, T).
:- mode for(in, in, pred(in, in, out) is det, in, out) is det.
:- mode for(in, in, pred(in, in, out) is semidet, in, out) is semidet.
:- mode for(in, in, pred(in, di, uo) is det, di, uo) is det.
for(Min, Max, Pred, Acc0, Acc) :-
( Min =< Max ->
call(Pred, Min, Acc0, Acc1),
for(Min+1, Max, Pred, Acc1, Acc)
;
Acc = Acc0
).