mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-18 19:03:45 +00:00
tests/hard_coded/foreign_name_mutable.m:
Both C# and Java foreign_procs here do not match the actual code
we generate for the mutable here. Change them so they do so.
(Officially, the 'foreign_name' attribute is only supported in C
grades anyway.)
53 lines
1.1 KiB
Mathematica
53 lines
1.1 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
:- module foreign_name_mutable.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- mutable(foo, int, 42, ground, [
|
|
untrailed,
|
|
foreign_name("C", "FOO"),
|
|
foreign_name("C#", "FOO"),
|
|
foreign_name("Java", "FOO")
|
|
]).
|
|
|
|
main(!IO) :-
|
|
increment_global(!IO),
|
|
promise_pure (
|
|
semipure get_foo(X)
|
|
),
|
|
io.write_string("X = ", !IO),
|
|
io.write_int(X, !IO),
|
|
io.nl(!IO).
|
|
|
|
:- pred increment_global(io::di, io::uo) is det.
|
|
|
|
:- pragma foreign_proc("C",
|
|
increment_global(_IO0::di, _IO::uo),
|
|
[will_not_call_mercury, promise_pure],
|
|
"
|
|
FOO++;
|
|
").
|
|
|
|
:- pragma foreign_proc("C#",
|
|
increment_global(_IO0::di, _IO::uo),
|
|
[will_not_call_mercury, promise_pure],
|
|
"
|
|
FOO++;
|
|
").
|
|
|
|
:- pragma foreign_proc("Java",
|
|
increment_global(_IO0::di, _IO::uo),
|
|
[will_not_call_mercury, promise_pure],
|
|
"
|
|
FOO++;
|
|
").
|