[m-rev.] diff: more java things
Peter Wang
novalazy at gmail.com
Fri Apr 24 15:37:57 AEST 2009
Branches: main
java/runtime/TypeInfo_Struct.java:
Modify this class enough so that Java code generated for the standard
library compiles with it.
library/io.m:
A few more Java foreign procs were overriding the wrong procedures.
library/type_desc.m:
Add missing class and methods.
diff --git a/java/runtime/TypeInfo_Struct.java
b/java/runtime/TypeInfo_Struct.java
index 3e19cdf..9b0a873 100644
--- a/java/runtime/TypeInfo_Struct.java
+++ b/java/runtime/TypeInfo_Struct.java
@@ -10,9 +10,14 @@ public class TypeInfo_Struct extends PseudoTypeInfo {
public TypeCtorInfo_Struct type_ctor;
public PseudoTypeInfo args[];
-
+
+ public TypeInfo_Struct(TypeCtorInfo_Struct tc)
+ {
+ type_ctor = tc;
+ }
+
// raw constructor
- public TypeInfo_Struct(TypeCtorInfo_Struct tc, PseudoTypeInfo[] as)
+ public TypeInfo_Struct(TypeCtorInfo_Struct tc, PseudoTypeInfo... as)
{
type_ctor = tc;
args = as;
@@ -28,35 +33,13 @@ public class TypeInfo_Struct extends PseudoTypeInfo {
args = ti.args;
}
- //
- // constructors for fixed-arity type_infos
- //
-
- public TypeInfo_Struct(TypeCtorInfo_Struct tc)
- {
- type_ctor = tc;
- args = null;
- }
-
- public TypeInfo_Struct(TypeCtorInfo_Struct tc, PseudoTypeInfo a1)
+ // XXX "as" should have type PseudoTypeInfo[],
+ // but mlds_to_java.m uses Object[]
+ // because init_array/1 does not store the type.
+ public TypeInfo_Struct(TypeCtorInfo_Struct tc, int arity, Object[] as)
{
- type_ctor = tc;
- args = new PseudoTypeInfo[] { a1 };
- }
-
- public TypeInfo_Struct(TypeCtorInfo_Struct tc, PseudoTypeInfo a1,
- PseudoTypeInfo a2)
- {
- type_ctor = tc;
- args = new PseudoTypeInfo[] { a1, a2 };
- }
+ assert arity == as.length;
- public TypeInfo_Struct(TypeCtorInfo_Struct tc,
- // XXX "as" should have type PseudoTypeInfo[],
- // but mlds_to_java.m uses Object[]
- // because init_array/1 does not store the type.
- Object[] as)
- {
type_ctor = tc;
args = new PseudoTypeInfo[as.length];
for (int i = 0; i < as.length; i++) {
@@ -64,65 +47,39 @@ public class TypeInfo_Struct extends PseudoTypeInfo {
}
}
- //
- // constructors for variable-arity type_infos (tuple, pred, func)
- //
-
- public TypeInfo_Struct(TypeCtorInfo_Struct tc, int arity)
+ // XXX "as" should have type PseudoTypeInfo[],
+ // but mlds_to_java.m uses Object[]
+ // because init_array/1 does not store the type.
+ public TypeInfo_Struct(TypeCtorInfo_Struct tc, Object[] as)
{
- // assert arity == 0;
type_ctor = tc;
- args = new PseudoTypeInfo[] { };
- }
-
- public TypeInfo_Struct(TypeCtorInfo_Struct tc, int arity,
- PseudoTypeInfo a1)
- {
- // assert arity == 1;
- type_ctor = tc;
- args = new PseudoTypeInfo[] { a1 };
+ args = new PseudoTypeInfo[as.length];
+ for (int i = 0; i < as.length; i++) {
+ args[i] = (PseudoTypeInfo) as[i];
+ }
}
- public TypeInfo_Struct(TypeCtorInfo_Struct tc, int arity,
- PseudoTypeInfo a1, PseudoTypeInfo a2)
+ // XXX untested guess
+ public TypeInfo_Struct(TypeInfo_Struct ti, int arity, Object... as)
{
- // assert arity == 2;
- type_ctor = tc;
- args = new PseudoTypeInfo[] { a1, a2 };
+ this(ti.type_ctor, arity, as);
}
- public TypeInfo_Struct(TypeCtorInfo_Struct tc, int arity,
- // XXX "as" should have type PseudoTypeInfo[],
- // but mlds_to_java.m uses Object[]
- // because init_array/1 does not store the type.
- Object[] as)
+ // XXX untested guess
+ public TypeInfo_Struct(TypeInfo_Struct ti, Object... as)
{
- // assert arity == as.length;
- type_ctor = tc;
- args = new PseudoTypeInfo[as.length];
- for (int i = 0; i < as.length; i++) {
- args[i] = (PseudoTypeInfo) as[i];
- }
+ this(ti.type_ctor, as);
}
-
// XXX a temp hack just to get things to run
public TypeInfo_Struct(java.lang.Object obj)
{
- try {
+ if (obj instanceof TypeInfo_Struct) {
TypeInfo_Struct ti = (TypeInfo_Struct) obj;
type_ctor = ti.type_ctor;
args = ti.args;
- } catch (java.lang.Exception e) {
- try {
- TypeCtorInfo_Struct tci =
- (TypeCtorInfo_Struct) obj;
- type_ctor = tci;
- args = null;
- } catch (java.lang.Exception e2) {
- throw new java.lang.Error(
- "TypeInfo_Struct(Object)");
- }
+ } else {
+ throw new java.lang.Error("TypeInfo_Struct(Object)");
}
}
diff --git a/library/io.m b/library/io.m
index 5995425..1ec7b8f 100644
--- a/library/io.m
+++ b/library/io.m
@@ -8757,56 +8757,56 @@
io.set_binary_output_stream(binary_output_stream(NewStream),
").
:- pragma foreign_proc("Java",
- io.stdout_stream(Stream::out, _IO0::di, _IO::uo),
+ io.stdout_stream_2(Stream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
Stream = mercury_stdout;
").
:- pragma foreign_proc("Java",
- io.stderr_stream(Stream::out, _IO0::di, _IO::uo),
+ io.stderr_stream_2(Stream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
Stream = mercury_stderr;
").
:- pragma foreign_proc("Java",
- io.stdin_binary_stream(Stream::out, _IO0::di, _IO::uo),
+ io.stdin_binary_stream_2(Stream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
Stream = mercury_stdin_binary;
").
:- pragma foreign_proc("Java",
- io.stdout_binary_stream(Stream::out, _IO0::di, _IO::uo),
+ io.stdout_binary_stream_2(Stream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
Stream = mercury_stdout_binary;
").
:- pragma foreign_proc("Java",
- io.input_stream(Stream::out, _IO0::di, _IO::uo),
+ io.input_stream_2(Stream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
Stream = mercury_current_text_input;
").
:- pragma foreign_proc("Java",
- io.output_stream(Stream::out, _IO0::di, _IO::uo),
+ io.output_stream_2(Stream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
Stream = mercury_current_text_output;
").
:- pragma foreign_proc("Java",
- io.binary_input_stream(Stream::out, _IO0::di, _IO::uo),
+ io.binary_input_stream_2(Stream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
Stream = mercury_current_binary_input;
").
:- pragma foreign_proc("Java",
- io.binary_output_stream(Stream::out, _IO0::di, _IO::uo),
+ io.binary_output_stream_2(Stream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
Stream = mercury_current_binary_output;
diff --git a/library/type_desc.m b/library/type_desc.m
index b430928..0cec614 100644
--- a/library/type_desc.m
+++ b/library/type_desc.m
@@ -923,6 +923,30 @@ get_type_info_for_type_info = TypeDesc :-
(""compare/3 for type_ctor_desc type implemented"");
}
+ public static class Pseudo_type_desc_0 {
+ // not filled in yet
+ }
+
+ public static boolean
+ __Unify____pseudo_type_desc_0_0(
+ mercury.type_desc.Pseudo_type_desc_0 x,
+ mercury.type_desc.Pseudo_type_desc_0 y)
+ {
+ // stub only
+ throw new java.lang.Error(
+ ""__Unify____type_ctor_desc_0_0 not implemented"");
+ }
+
+ public static mercury.builtin.Comparison_result_0
+ __Compare____pseudo_type_desc_0_0(
+ mercury.type_desc.Pseudo_type_desc_0 x,
+ mercury.type_desc.Pseudo_type_desc_0 y)
+ {
+ // stub only
+ throw new java.lang.Error(
+ ""__Compare____pseudo_type_desc_0_0 not implemented"");
+ }
+
").
:- pragma foreign_code("Erlang", "
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list