mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-12 20:34:19 +00:00
compiler/parse_item.m:
Don't accept `:- external' items.
compiler/prog_item.m:
Require the presence of a pred_or_func flag on external pragmas.
They are specified by `:- pragma external_{pred/func}' pragmas,
which are still supported.
compiler/parse_pragma.m:
When parsing external_{pred/func} pragmas, allow the predicate name
to contain a module qualifier; they were allowed on `:- external' items.
We do require the module qualifier to specify the expected (i.e. the
current) module.
compiler/add_pragma.m:
compiler/parse_tree_out_pragma.m:
compiler/recompilation.version.m:
Conform to the changes above.
tests/hard_coded/backend_external.m:
tests/hard_coded/constant_prop_2.m:
tests/invalid/external.err_exp:
tests/invalid/external.m:
tests/invalid/io_in_ite_cond.err_exp:
tests/invalid/io_in_ite_cond.m:
tests/invalid/overloading.m:
tests/invalid/tricky_assert1.m:
tests/invalid/type_spec.err_exp:
tests/invalid/type_spec.m:
tests/invalid/uniq_neg.err_exp:
tests/invalid/uniq_neg.m:
tests/valid/dcg_test.m:
tests/valid/inst_perf_bug_1.m:
tests/valid/lambda_recompute.m:
tests/valid/semidet_disj.m:
tests/valid/solv.m:
tests/valid/solver_type_bug.m:
tests/valid/stack_alloc.m:
tests/valid/tricky_assert2.m:
Replace `:- external' items with external_{pred/func} pragmas.
Modernize the code where needed, replacing DCGs with state variables.
116 lines
3.0 KiB
Mathematica
116 lines
3.0 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% 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.
|
|
|
|
:- type display_list.
|
|
:- pred compile_display_list(display_list::out, io::di, io::uo) is det.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- import_module bool.
|
|
:- import_module char.
|
|
:- import_module float.
|
|
:- import_module int.
|
|
:- import_module list.
|
|
:- import_module map.
|
|
:- import_module pair.
|
|
:- import_module require.
|
|
:- import_module std_util.
|
|
:- import_module 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.
|
|
:- pragma no_inline(pos/2).
|
|
|
|
pos(X, Y) = pos(X, Y).
|
|
|
|
:- 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, io).
|
|
:- mode get_monst(in, out, di, uo) is det.
|
|
|
|
:- pragma external_pred(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, !Acc) :-
|
|
( if Min =< Max then
|
|
call(Pred, Min, !Acc),
|
|
for(Min+1, Max, Pred, !Acc)
|
|
else
|
|
true
|
|
).
|