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:
James Goddard
2004-01-20 23:05:43 +00:00
parent db6899f14d
commit d2abd7fff6

View File

@@ -1408,35 +1408,43 @@ XXX `ui' modes don't work yet
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",
new_mutvar(X::in, Ref::out),
[will_not_call_mercury, thread_safe],
"
Ref = new java.lang.Object[1];
Ref[0] = X;
Ref = new mercury.std_util.Mutvar(X);
").
:- pragma foreign_proc("Java",
new_mutvar(X::di, Ref::uo),
[will_not_call_mercury, thread_safe],
"
Ref = new java.lang.Object[1];
Ref[0] = X;
Ref = new mercury.std_util.Mutvar(X);
").
:- pragma foreign_proc("Java",
get_mutvar(Ref::in, X::uo),
[will_not_call_mercury, thread_safe],
"
X = Ref[0];
X = Ref.object;
").
:- pragma foreign_proc("Java",
set_mutvar(Ref::in, X::in),
[will_not_call_mercury, thread_safe],
"
Ref[0] = X;
Ref.object = X;
").
%%% end_module mutvar.