mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 05:12:33 +00:00
Change representation of mutvar(T) for Java back-end in std_util library.
Estimated hours taken: 0.3
Branches: main
Change representation of mutvar(T) for Java back-end in std_util library.
library/std_util.m:
Defined the type mutvar(T) as mercury.std_util.Mutvar, a trivial class
with a single member field to hold the variable.
Modified the implementation of the following procedures in Java:
new_mutvar/2
get_mutvar/2
set_mutvar/2
This commit is contained in:
@@ -1408,35 +1408,43 @@ XXX `ui' modes don't work yet
|
|||||||
Ref[0] = X;
|
Ref[0] = X;
|
||||||
").
|
").
|
||||||
|
|
||||||
:- pragma foreign_type(java, mutvar(T), "java.lang.Object[]").
|
:- pragma foreign_code("Java",
|
||||||
|
"
|
||||||
|
public static class Mutvar {
|
||||||
|
public Object object;
|
||||||
|
|
||||||
|
public Mutvar(Object init) {
|
||||||
|
object = init;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
").
|
||||||
|
:- pragma foreign_type(java, mutvar(T), "mercury.std_util.Mutvar").
|
||||||
|
|
||||||
:- pragma foreign_proc("Java",
|
:- pragma foreign_proc("Java",
|
||||||
new_mutvar(X::in, Ref::out),
|
new_mutvar(X::in, Ref::out),
|
||||||
[will_not_call_mercury, thread_safe],
|
[will_not_call_mercury, thread_safe],
|
||||||
"
|
"
|
||||||
Ref = new java.lang.Object[1];
|
Ref = new mercury.std_util.Mutvar(X);
|
||||||
Ref[0] = X;
|
|
||||||
").
|
").
|
||||||
:- pragma foreign_proc("Java",
|
:- pragma foreign_proc("Java",
|
||||||
new_mutvar(X::di, Ref::uo),
|
new_mutvar(X::di, Ref::uo),
|
||||||
[will_not_call_mercury, thread_safe],
|
[will_not_call_mercury, thread_safe],
|
||||||
"
|
"
|
||||||
Ref = new java.lang.Object[1];
|
Ref = new mercury.std_util.Mutvar(X);
|
||||||
Ref[0] = X;
|
|
||||||
").
|
").
|
||||||
|
|
||||||
:- pragma foreign_proc("Java",
|
:- pragma foreign_proc("Java",
|
||||||
get_mutvar(Ref::in, X::uo),
|
get_mutvar(Ref::in, X::uo),
|
||||||
[will_not_call_mercury, thread_safe],
|
[will_not_call_mercury, thread_safe],
|
||||||
"
|
"
|
||||||
X = Ref[0];
|
X = Ref.object;
|
||||||
").
|
").
|
||||||
|
|
||||||
:- pragma foreign_proc("Java",
|
:- pragma foreign_proc("Java",
|
||||||
set_mutvar(Ref::in, X::in),
|
set_mutvar(Ref::in, X::in),
|
||||||
[will_not_call_mercury, thread_safe],
|
[will_not_call_mercury, thread_safe],
|
||||||
"
|
"
|
||||||
Ref[0] = X;
|
Ref.object = X;
|
||||||
").
|
").
|
||||||
|
|
||||||
%%% end_module mutvar.
|
%%% end_module mutvar.
|
||||||
|
|||||||
Reference in New Issue
Block a user