mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 01:43:35 +00:00
tests/general/float_test.exp3:
tests/general/float_test.m:
tests/general/read_dir_regression.exp4:
tests/general/read_dir_regression.m:
tests/hard_coded/remove_file.exp2:
tests/hard_coded/remove_file.m:
Delete Erlang backend specific expected outputs.
tests/hard_coded/Mmakefile:
tests/hard_coded/erlang_deconstruct.exp:
tests/hard_coded/erlang_deconstruct.m:
tests/hard_coded/existential_list.exp:
tests/hard_coded/existential_list.m:
tests/valid/Mmakefile:
tests/valid/erl_ite_vars.m:
tests/valid/zf_erlang_bug.m:
Delete erlang target specific tests.
tests/*:
Delete Erlang foreign procs and foreign types.
73 lines
1.8 KiB
Mathematica
73 lines
1.8 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module impure_prune.
|
|
:- interface.
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
:- import_module int.
|
|
:- import_module require.
|
|
|
|
:- pragma promise_pure(main/2).
|
|
|
|
main(!IO) :-
|
|
( if impure do_impure_stuff, fail then
|
|
error("not reached")
|
|
else
|
|
semipure get_counter(X),
|
|
print("X = ", !IO), print(X, !IO), nl(!IO)
|
|
).
|
|
|
|
:- impure pred do_impure_stuff is multi.
|
|
do_impure_stuff :-
|
|
impure bump_counter.
|
|
do_impure_stuff :-
|
|
impure bump_counter.
|
|
do_impure_stuff :-
|
|
impure bump_counter.
|
|
|
|
:- impure pred bump_counter is det.
|
|
bump_counter :-
|
|
semipure get_counter(X),
|
|
impure set_counter(X + 1).
|
|
|
|
:- semipure pred get_counter(int::out) is det.
|
|
:- impure pred set_counter(int::in) is det.
|
|
|
|
:- pragma foreign_decl("C", "extern MR_Integer counter;").
|
|
:- pragma foreign_code("C", "MR_Integer counter = 0;").
|
|
:- pragma foreign_proc("C",
|
|
get_counter(X::out),
|
|
[will_not_call_mercury, promise_semipure],
|
|
"
|
|
X = counter;
|
|
").
|
|
:- pragma foreign_proc("C",
|
|
set_counter(X::in),
|
|
[will_not_call_mercury],
|
|
"
|
|
counter = X;
|
|
").
|
|
|
|
:- pragma foreign_code("C#", "static int counter = 0;").
|
|
:- pragma foreign_proc("C#",
|
|
get_counter(X::out),
|
|
[will_not_call_mercury, promise_semipure],
|
|
"
|
|
X = counter;
|
|
").
|
|
:- pragma foreign_proc("C#", set_counter(X::in), [], "counter = X;").
|
|
|
|
:- pragma foreign_code("Java", "static int counter = 0;").
|
|
:- pragma foreign_proc("Java",
|
|
get_counter(X::out),
|
|
[will_not_call_mercury, promise_semipure],
|
|
"
|
|
X = counter;
|
|
").
|
|
:- pragma foreign_proc("Java", set_counter(X::in), [], "counter = X;").
|