[m-rev.] for review: C# backend
Peter Wang
novalazy at gmail.com
Thu Sep 16 10:54:04 AEST 2010
On 2010-09-14, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
>
> Hi Peter,
>
> I've had a look through this diff and it looks ok. (I have some
> reservations regarding the re-use of the java_names module for C# -- see
> below.) Provided you've bootchecked the compiler in at least one of the
> other MLDS grades, feel free to commit.
Committed with a few minor fixes.
diff --git a/compiler/mlds_to_cs.m b/compiler/mlds_to_cs.m
index 15dacb2..3c5e9af 100644
--- a/compiler/mlds_to_cs.m
+++ b/compiler/mlds_to_cs.m
@@ -1154,7 +1154,7 @@ get_type_initializer(Type) = Initializer :-
; Type = mlds_rtti_type(_)
; Type = mlds_tabling_type(_)
),
- Initializer = "/*x2*/ null"
+ Initializer = "null"
;
Type = mlds_foreign_type(ForeignType),
(
diff --git a/library/array.m b/library/array.m
index 5ac3d33..6409ad3 100644
--- a/library/array.m
+++ b/library/array.m
@@ -668,6 +668,97 @@ ML_init_array(MR_ArrayPtr array, MR_Integer size, MR_Word item)
}
").
+:- pragma foreign_code("C#", "
+public static System.Array
+ML_new_array(int Size, object Item, bool fill)
+{
+ System.Array arr;
+ if (Size == 0) {
+ return null;
+ }
+ if (Item is int || Item is double || Item is char || Item is bool) {
+ arr = System.Array.CreateInstance(Item.GetType(), Size);
+ } else {
+ arr = new object[Size];
+ }
+ for (int i = 0; i < Size; i++) {
+ arr.SetValue(Item, i);
+ }
+ return arr;
+}
+
+public static System.Array
+ML_array_resize(System.Array arr0, int Size, object Item)
+{
+ if (Size == 0) {
+ return null;
+ }
+ if (arr0 == null) {
+ return ML_new_array(Size, Item, true);
+ }
+ if (arr0.Length == Size) {
+ return arr0;
+ }
+
+ int OldSize = arr0.Length;
+ System.Array arr;
+ if (Item is int) {
+ int[] tmp = (int[]) arr0;
+ System.Array.Resize(ref tmp, Size);
+ arr = tmp;
+ } else if (Item is double) {
+ double[] tmp = (double[]) arr0;
+ System.Array.Resize(ref tmp, Size);
+ arr = tmp;
+ } else if (Item is char) {
+ char[] tmp = (char[]) arr0;
+ System.Array.Resize(ref tmp, Size);
+ arr = tmp;
+ } else if (Item is bool) {
+ bool[] tmp = (bool[]) arr0;
+ System.Array.Resize(ref tmp, Size);
+ arr = tmp;
+ } else {
+ object[] tmp = (object[]) arr0;
+ System.Array.Resize(ref tmp, Size);
+ arr = tmp;
+ }
+ for (int i = OldSize; i < Size; i++) {
+ arr.SetValue(Item, i);
+ }
+ return arr;
+}
+
+public static System.Array
+ML_shrink_array(System.Array arr, int Size)
+{
+ if (arr == null) {
+ return null;
+ } else if (arr is int[]) {
+ int[] tmp = (int[]) arr;
+ System.Array.Resize(ref tmp, Size);
+ return tmp;
+ } else if (arr is double[]) {
+ double[] tmp = (double[]) arr;
+ System.Array.Resize(ref tmp, Size);
+ return tmp;
+ } else if (arr is char[]) {
+ char[] tmp = (char[]) arr;
+ System.Array.Resize(ref tmp, Size);
+ return tmp;
+ } else if (arr is bool[]) {
+ bool[] tmp = (bool[]) arr;
+ System.Array.Resize(ref tmp, Size);
+ return tmp;
+ } else {
+ object[] tmp = (object[]) arr;
+ System.Array.Resize(ref tmp, Size);
+ return tmp;
+ }
+}
+
+").
+
:- pragma foreign_code("Java", "
public static Object
ML_new_array(int Size, Object Item, boolean fill)
@@ -827,13 +918,7 @@ array.init(Size, Item, Array) :-
array.init_2(Size::in, Item::in, Array::array_uo),
[will_not_call_mercury, promise_pure, thread_safe],
"
- // This does not work because Item.GetType() may return the subtype
- // rather than the type we intended.
- // Array = System.Array.CreateInstance(Item.GetType(), Size);
- Array = new object[Size];
- for (int i = 0; i < Size; i++) {
- Array.SetValue(Item, i);
- }
+ Array = array.ML_new_array(Size, Item, true);
").
:- pragma foreign_proc("C#",
array.make_empty_array(Array::array_uo),
@@ -1197,27 +1282,7 @@ ML_resize_array(MR_ArrayPtr array, MR_ArrayPtr old_array,
array.resize(Array0::array_di, Size::in, Item::in, Array::array_uo),
[will_not_call_mercury, promise_pure, thread_safe],
"
- if (Array0 == null) {
- // Array = System.Array.CreateInstance(Item.GetType(), Size);
- Array = new object[Size];
- for (int i = 0; i < Size; i++) {
- Array.SetValue(Item, i);
- }
- }
- else if (Array0.Length == Size) {
- Array = Array0;
- } else if (Array0.Length > Size) {
- // Array = System.Array.CreateInstance(Item.GetType(), Size);
- Array = new object[Size];
- System.Array.Copy(Array0, Array, Size);
- } else {
- // Array = System.Array.CreateInstance(Item.GetType(), Size);
- Array = new object[Size];
- System.Array.Copy(Array0, Array, Array0.Length);
- for (int i = Array0.Length; i < Size; i++) {
- Array.SetValue(Item, i);
- }
- }
+ Array = array.ML_array_resize(Array0, Size, Item);
").
:- pragma foreign_proc("Erlang",
@@ -1308,10 +1373,7 @@ array.shrink(Array0, Size, Array) :-
array.shrink_2(Array0::array_di, Size::in, Array::array_uo),
[will_not_call_mercury, promise_pure, thread_safe],
"
- // Array = System.Array.CreateInstance(Array0.GetType().GetElementType(),
- // Size);
- Array = new object[Size];
- System.Array.Copy(Array0, Array, Size);
+ Array = array.ML_shrink_array(Array0, Size);
").
:- pragma foreign_proc("Erlang",
@@ -1391,12 +1453,7 @@ ML_copy_array(MR_ArrayPtr array, MR_ConstArrayPtr old_array)
array.copy(Array0::in, Array::array_uo),
[will_not_call_mercury, promise_pure, thread_safe],
"
- // XXX we implement the same as ML_copy_array, which doesn't appear
- // to deep copy the array elements
- // Array = System.Array.CreateInstance(Array0.GetType().GetElementType(),
- // Array0.Length);
- Array = new object[Array0.Length];
- System.Array.Copy(Array0, Array, Array0.Length);
+ Array = (System.Array) Array0.Clone();
").
:- pragma foreign_proc("Erlang",
diff --git a/library/builtin.m b/library/builtin.m
index 52d8743..c6c834a 100644
--- a/library/builtin.m
+++ b/library/builtin.m
@@ -950,14 +950,14 @@ __Compare____tuple_0_0(object x, object y)
copy(X::ui, Y::uo),
[may_call_mercury, thread_safe, promise_pure, terminates],
"
- Y = deep_copy(X);
+ Y = builtin.deep_copy(X);
").
:- pragma foreign_proc("C#",
copy(X::in, Y::uo),
[may_call_mercury, thread_safe, promise_pure, terminates],
"
- Y = deep_copy(X);
+ Y = builtin.deep_copy(X);
").
:- pragma foreign_proc("Java",
diff --git a/library/io.m b/library/io.m
index 979474a..0d09a34 100644
--- a/library/io.m
+++ b/library/io.m
@@ -2606,7 +2606,7 @@ io.make_err_msg(Msg0, Msg, !IO) :-
io.get_system_error(Error::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
- Error = MR_io_exception;
+ Error = io.MR_io_exception;
}").
:- pragma foreign_proc("Java",
@@ -5084,21 +5084,21 @@ io.unlock_stream_db(!IO).
io.get_stream_db_with_locking(StreamDb::out),
[will_not_call_mercury, tabled_for_io],
"
- StreamDb = ML_io_stream_db;
+ StreamDb = io.ML_io_stream_db;
").
:- pragma foreign_proc("C#",
io.get_stream_db(StreamDb::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
- StreamDb = ML_io_stream_db;
+ StreamDb = io.ML_io_stream_db;
").
:- pragma foreign_proc("C#",
io.set_stream_db(StreamDb::in, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
- ML_io_stream_db = StreamDb;
+ io.ML_io_stream_db = StreamDb;
").
:- pragma foreign_proc("Java",
@@ -5312,14 +5312,14 @@ io.unlock_globals :-
io.unsafe_get_globals(Globals::out, _IOState0::di, _IOState::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
- Globals = ML_io_user_globals;
+ Globals = io.ML_io_user_globals;
").
:- pragma foreign_proc("C#",
io.unsafe_set_globals(Globals::in, _IOState0::di, _IOState::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
- ML_io_user_globals = Globals;
+ io.ML_io_user_globals = Globals;
").
:- pragma foreign_proc("Java",
@@ -6376,36 +6376,36 @@ mercury_file_init(System.IO.Stream stream,
// it is a problem in Windows, not in Mercury -- I don't think it is one
// that the Mercury implementation should try to solve.
-static MR_MercuryFileStruct mercury_stdin =
+public static MR_MercuryFileStruct mercury_stdin =
mercury_file_init(System.Console.OpenStandardInput(),
System.Console.In, null, ML_default_text_encoding);
-static MR_MercuryFileStruct mercury_stdout =
+public static MR_MercuryFileStruct mercury_stdout =
mercury_file_init(System.Console.OpenStandardOutput(),
null, System.Console.Out, ML_default_text_encoding);
-static MR_MercuryFileStruct mercury_stderr =
+public static MR_MercuryFileStruct mercury_stderr =
mercury_file_init(System.Console.OpenStandardError(),
null, System.Console.Error, ML_default_text_encoding);
// XXX should we use BufferedStreams here?
-static MR_MercuryFileStruct mercury_stdin_binary =
+public static MR_MercuryFileStruct mercury_stdin_binary =
mercury_file_init(System.Console.OpenStandardInput(),
System.Console.In, null, ML_file_encoding_kind.ML_raw_binary);
-static MR_MercuryFileStruct mercury_stdout_binary =
+public static MR_MercuryFileStruct mercury_stdout_binary =
mercury_file_init(System.Console.OpenStandardOutput(),
null, System.Console.Out, ML_file_encoding_kind.ML_raw_binary);
// Note: these are set again in io.init_state.
-static MR_MercuryFileStruct mercury_current_text_input =
+public static MR_MercuryFileStruct mercury_current_text_input =
mercury_stdin;
-static MR_MercuryFileStruct mercury_current_text_output =
+public static MR_MercuryFileStruct mercury_current_text_output =
mercury_stdout;
-static MR_MercuryFileStruct mercury_current_binary_input =
+public static MR_MercuryFileStruct mercury_current_binary_input =
mercury_stdin_binary;
-static MR_MercuryFileStruct mercury_current_binary_output =
+public static MR_MercuryFileStruct mercury_current_binary_output =
mercury_stdout_binary;
// XXX not thread-safe!
-static System.Exception MR_io_exception;
+public static System.Exception MR_io_exception;
").
@@ -6833,7 +6833,8 @@ mercury_open(const char *filename, const char *openmode)
:- pragma foreign_code("C#", "
-static MR_MercuryFileStruct mercury_open(string filename, string openmode,
+public static
+MR_MercuryFileStruct mercury_open(string filename, string openmode,
ML_file_encoding_kind file_encoding)
{
System.IO.FileMode mode;
@@ -6957,7 +6958,7 @@ mercury_print_string(MercuryFilePtr mf, const char *s)
// Any changes here should also be reflected in the code for
// io.write_char, which (for efficiency) uses its own inline
// code, rather than calling this function.
-static void
+public static void
mercury_print_string(MR_MercuryFileStruct mf, string s)
{
//
@@ -7041,7 +7042,7 @@ mercury_getc(MercuryFilePtr mf)
:- pragma foreign_code("C#", "
-static void
+public static void
mercury_print_binary_string(MR_MercuryFileStruct mf, string s)
{
// sanity check
@@ -7102,7 +7103,7 @@ mercury_print_binary_string(MR_MercuryFileStruct mf, string s)
// converting the bytes from the system's default encoding to Unicode,
// and possibly converting CR-LF to newline. Returns -1 on error or EOF.
-static int
+public static int
mercury_getc(MR_MercuryFileStruct mf)
{
int c;
@@ -7173,7 +7174,7 @@ mercury_getc(MR_MercuryFileStruct mf)
return c;
}
-static void
+public static void
mercury_ungetc(MR_MercuryFileStruct mf, int code)
{
if (mf.putback != -1) {
@@ -7351,7 +7352,7 @@ mercury_close(MercuryFilePtr mf)
:- pragma foreign_code("C#", "
-static void
+public static void
mercury_close(MR_MercuryFileStruct mf)
{
if (mf.reader != null) {
@@ -7459,15 +7460,15 @@ io.putback_byte(binary_input_stream(Stream), Character, !IO) :-
io.read_char_code_2(File::in, CharCode::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure],
"
- MR_MercuryFileStruct mf = File;
- CharCode = mercury_getc(mf);
+ io.MR_MercuryFileStruct mf = File;
+ CharCode = io.mercury_getc(mf);
").
:- pragma foreign_proc("C#",
io.read_byte_val_2(File::in, ByteVal::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure],
"
- MR_MercuryFileStruct mf = File;
+ io.MR_MercuryFileStruct mf = File;
if (mf.putback != -1) {
ByteVal = mf.putback;
mf.putback = -1;
@@ -7480,15 +7481,15 @@ io.putback_byte(binary_input_stream(Stream), Character, !IO) :-
io.putback_char_2(File::in, Character::in, _IO0::di, _IO::uo),
[may_call_mercury, promise_pure, terminates],
"{
- MR_MercuryFileStruct mf = File;
- mercury_ungetc(mf, Character);
+ io.MR_MercuryFileStruct mf = File;
+ io.mercury_ungetc(mf, Character);
}").
:- pragma foreign_proc("C#",
io.putback_byte_2(File::in, Byte::in, _IO0::di, _IO::uo),
[may_call_mercury, promise_pure, terminates],
"{
- MR_MercuryFileStruct mf = File;
+ io.MR_MercuryFileStruct mf = File;
if (mf.putback != -1) {
runtime.Errors.SORRY(
""io.putback_byte: max one character of putback"");
@@ -7671,7 +7672,7 @@ io.write_bitmap(Bitmap, Start, NumBytes, !IO) :-
io.write_string(Message::in, _IO0::di, _IO::uo),
[may_call_mercury, promise_pure, thread_safe, tabled_for_io, terminates],
"
- mercury_print_string(mercury_current_text_output, Message);
+ io.mercury_print_string(io.mercury_current_text_output, Message);
").
:- pragma foreign_proc("C#",
@@ -7679,23 +7680,23 @@ io.write_bitmap(Bitmap, Start, NumBytes, !IO) :-
[may_call_mercury, promise_pure, thread_safe, tabled_for_io, terminates],
"
/* See mercury_output_string() for comments */
- if (mercury_current_text_output.writer == null) {
- mercury_current_text_output.writer =
- new System.IO.StreamWriter(mercury_current_text_output.stream,
+ if (io.mercury_current_text_output.writer == null) {
+ io.mercury_current_text_output.writer =
+ new System.IO.StreamWriter(io.mercury_current_text_output.stream,
System.Text.Encoding.Default);
}
- System.IO.TextWriter w = mercury_current_text_output.writer;
+ System.IO.TextWriter w = io.mercury_current_text_output.writer;
if (Character == '\\n') {
- switch (mercury_current_text_output.file_encoding) {
- case ML_file_encoding_kind.ML_raw_binary:
- case ML_file_encoding_kind.ML_Unix_text_encoding:
+ switch (io.mercury_current_text_output.file_encoding) {
+ case io.ML_file_encoding_kind.ML_raw_binary:
+ case io.ML_file_encoding_kind.ML_Unix_text_encoding:
w.Write(Character);
break;
- case ML_file_encoding_kind.ML_OS_text_encoding:
+ case io.ML_file_encoding_kind.ML_OS_text_encoding:
w.WriteLine("""");
break;
}
- mercury_current_text_output.line_number++;
+ io.mercury_current_text_output.line_number++;
} else {
w.Write(Character);
}
@@ -7705,14 +7706,14 @@ io.write_bitmap(Bitmap, Start, NumBytes, !IO) :-
io.write_int(Val::in, _IO0::di, _IO::uo),
[may_call_mercury, promise_pure, thread_safe, tabled_for_io, terminates],
"
- mercury_print_string(mercury_current_text_output, Val.ToString());
+ io.mercury_print_string(io.mercury_current_text_output, Val.ToString());
").
:- pragma foreign_proc("C#",
io.write_byte(Byte::in, _IO0::di, _IO::uo),
[may_call_mercury, promise_pure, thread_safe, tabled_for_io, terminates],
"
- mercury_current_binary_output.stream.WriteByte(
+ io.mercury_current_binary_output.stream.WriteByte(
System.Convert.ToByte(Byte));
").
@@ -7720,14 +7721,14 @@ io.write_bitmap(Bitmap, Start, NumBytes, !IO) :-
io.flush_output(_IO0::di, _IO::uo),
[may_call_mercury, promise_pure, thread_safe, tabled_for_io, terminates],
"
- mercury_current_text_output.stream.Flush();
+ io.mercury_current_text_output.stream.Flush();
").
:- pragma foreign_proc("C#",
io.flush_binary_output(_IO0::di, _IO::uo),
[may_call_mercury, promise_pure, thread_safe, tabled_for_io, terminates],
"
- mercury_current_binary_output.stream.Flush();
+ io.mercury_current_binary_output.stream.Flush();
").
:- pragma foreign_proc("Java",
@@ -8068,14 +8069,14 @@ io.flush_binary_output(binary_output_stream(Stream), !IO) :-
io.write_string_2(Stream::in, Message::in, _IO0::di, _IO::uo),
[may_call_mercury, promise_pure, thread_safe, tabled_for_io, terminates],
"
- mercury_print_string(Stream, Message);
+ io.mercury_print_string(Stream, Message);
").
:- pragma foreign_proc("C#",
io.write_char_2(Stream::in, Character::in, _IO0::di, _IO::uo),
[may_call_mercury, promise_pure, thread_safe, tabled_for_io, terminates],
"
- MR_MercuryFileStruct stream = Stream;
+ io.MR_MercuryFileStruct stream = Stream;
/* See mercury_output_string() for comments */
if (stream.writer == null) {
stream.writer = new System.IO.StreamWriter(stream.stream,
@@ -8084,11 +8085,11 @@ io.flush_binary_output(binary_output_stream(Stream), !IO) :-
System.IO.TextWriter w = stream.writer;
if (Character == '\\n') {
switch (stream.file_encoding) {
- case ML_file_encoding_kind.ML_raw_binary:
- case ML_file_encoding_kind.ML_Unix_text_encoding:
+ case io.ML_file_encoding_kind.ML_raw_binary:
+ case io.ML_file_encoding_kind.ML_Unix_text_encoding:
w.Write(Character);
break;
- case ML_file_encoding_kind.ML_OS_text_encoding:
+ case io.ML_file_encoding_kind.ML_OS_text_encoding:
w.WriteLine("""");
break;
}
@@ -8102,7 +8103,7 @@ io.flush_binary_output(binary_output_stream(Stream), !IO) :-
io.write_int_2(Stream::in, Val::in, _IO0::di, _IO::uo),
[may_call_mercury, promise_pure, thread_safe, tabled_for_io, terminates],
"{
- mercury_print_string(Stream, Val.ToString());
+ io.mercury_print_string(Stream, Val.ToString());
}").
:- pragma foreign_proc("C#",
@@ -8116,7 +8117,7 @@ io.flush_binary_output(binary_output_stream(Stream), !IO) :-
io.write_bytes_2(Stream::in, Message::in, _IO0::di, _IO::uo),
[may_call_mercury, promise_pure, thread_safe, tabled_for_io, terminates],
"{
- mercury_print_binary_string(Stream, Message);
+ io.mercury_print_binary_string(Stream, Message);
}").
:- pragma foreign_proc("C#",
@@ -8327,7 +8328,7 @@ io.stdin_stream = input_stream(io.stdin_stream_2).
[will_not_call_mercury, promise_pure, thread_safe,
does_not_affect_liveness],
"
- Stream = mercury_stdin;
+ Stream = io.mercury_stdin;
").
:- pragma foreign_proc("Java",
@@ -8369,7 +8370,7 @@ io.stdout_stream = output_stream(io.stdout_stream_2).
[will_not_call_mercury, promise_pure, thread_safe,
does_not_affect_liveness],
"
- Stream = mercury_stdout;
+ Stream = io.mercury_stdout;
").
:- pragma foreign_proc("Java",
@@ -8411,7 +8412,7 @@ io.stderr_stream = output_stream(io.stderr_stream_2).
[will_not_call_mercury, promise_pure, thread_safe,
does_not_affect_liveness],
"
- Stream = mercury_stderr;
+ Stream = io.mercury_stderr;
").
:- pragma foreign_proc("Java",
@@ -8691,70 +8692,70 @@ io.set_binary_output_stream(binary_output_stream(NewStream),
io.stdin_stream_2(Stream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
- Stream = mercury_stdin;
+ Stream = io.mercury_stdin;
").
:- pragma foreign_proc("C#",
io.stdout_stream_2(Stream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
- Stream = mercury_stdout;
+ Stream = io.mercury_stdout;
").
:- pragma foreign_proc("C#",
io.stderr_stream_2(Stream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, thread_safe, tabled_for_io],
"
- Stream = mercury_stderr;
+ Stream = io.mercury_stderr;
").
:- pragma foreign_proc("C#",
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;
+ Stream = io.mercury_stdin_binary;
").
:- pragma foreign_proc("C#",
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;
+ Stream = io.mercury_stdout_binary;
").
:- pragma foreign_proc("C#",
io.input_stream_2(Stream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
- Stream = mercury_current_text_input;
+ Stream = io.mercury_current_text_input;
").
:- pragma foreign_proc("C#",
io.output_stream_2(Stream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
- Stream = mercury_current_text_output;
+ Stream = io.mercury_current_text_output;
").
:- pragma foreign_proc("C#",
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;
+ Stream = io.mercury_current_binary_input;
").
:- pragma foreign_proc("C#",
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;
+ Stream = io.mercury_current_binary_output;
").
:- pragma foreign_proc("C#",
io.get_line_number(LineNum::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
- LineNum = mercury_current_text_input.line_number;
+ LineNum = io.mercury_current_text_input.line_number;
").
:- pragma foreign_proc("C#",
@@ -8768,7 +8769,7 @@ io.set_binary_output_stream(binary_output_stream(NewStream),
io.set_line_number(LineNum::in, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
- mercury_current_text_input.line_number = LineNum;
+ io.mercury_current_text_input.line_number = LineNum;
").
:- pragma foreign_proc("C#",
@@ -8782,7 +8783,7 @@ io.set_binary_output_stream(binary_output_stream(NewStream),
io.get_output_line_number(LineNum::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
- LineNum = mercury_current_text_output.line_number;
+ LineNum = io.mercury_current_text_output.line_number;
").
:- pragma foreign_proc("C#",
@@ -8796,7 +8797,7 @@ io.set_binary_output_stream(binary_output_stream(NewStream),
io.set_output_line_number(LineNum::in, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
- mercury_current_text_output.line_number = LineNum;
+ io.mercury_current_text_output.line_number = LineNum;
").
:- pragma foreign_proc("C#",
@@ -8810,16 +8811,16 @@ io.set_binary_output_stream(binary_output_stream(NewStream),
io.set_input_stream_2(NewStream::in, OutStream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
- OutStream = mercury_current_text_input;
- mercury_current_text_input = NewStream;
+ OutStream = io.mercury_current_text_input;
+ io.mercury_current_text_input = NewStream;
").
:- pragma foreign_proc("C#",
io.set_output_stream_2(NewStream::in, OutStream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
- OutStream = mercury_current_text_output;
- mercury_current_text_output = NewStream;
+ OutStream = io.mercury_current_text_output;
+ io.mercury_current_text_output = NewStream;
").
:- pragma foreign_proc("C#",
@@ -8827,8 +8828,8 @@ io.set_binary_output_stream(binary_output_stream(NewStream),
_IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
- OutStream = mercury_current_binary_input;
- mercury_current_binary_input = NewStream;
+ OutStream = io.mercury_current_binary_input;
+ io.mercury_current_binary_input = NewStream;
").
:- pragma foreign_proc("C#",
@@ -8836,8 +8837,8 @@ io.set_binary_output_stream(binary_output_stream(NewStream),
_IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
- OutStream = mercury_current_binary_output;
- mercury_current_binary_output = NewStream;
+ OutStream = io.mercury_current_binary_output;
+ io.mercury_current_binary_output = NewStream;
").
:- pragma foreign_proc("Java",
@@ -9239,8 +9240,8 @@ io.set_binary_output_stream(binary_output_stream(NewStream),
StreamId::out, Stream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
- MR_MercuryFileStruct mf = mercury_open(FileName, Mode,
- ML_default_text_encoding);
+ io.MR_MercuryFileStruct mf = io.mercury_open(FileName, Mode,
+ io.ML_default_text_encoding);
Stream = mf;
if (mf != null) {
ResultCode = 0;
@@ -9256,8 +9257,8 @@ io.set_binary_output_stream(binary_output_stream(NewStream),
StreamId::out, Stream::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"
- MR_MercuryFileStruct mf = mercury_open(FileName, Mode,
- ML_file_encoding_kind.ML_raw_binary);
+ io.MR_MercuryFileStruct mf = io.mercury_open(FileName, Mode,
+ io.ML_file_encoding_kind.ML_raw_binary);
Stream = mf;
if (mf != null) {
ResultCode = 0;
@@ -9407,7 +9408,7 @@ io.close_binary_output(binary_output_stream(Stream), !IO) :-
io.close_stream(Stream::in, _IO0::di, _IO::uo),
[may_call_mercury, promise_pure, tabled_for_io, thread_safe, terminates],
"
- mercury_close(Stream);
+ io.mercury_close(Stream);
").
:- pragma foreign_proc("Java",
diff --git a/library/private_builtin.m b/library/private_builtin.m
index 3ebf43a..0a1fffa 100644
--- a/library/private_builtin.m
+++ b/library/private_builtin.m
@@ -740,7 +740,8 @@ __Compare____base_typeclass_info_1_0(
TypeInfo::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
- TypeInfo = MR_typeclass_info_param_type_info(TypeClassInfo, Index);
+ TypeInfo = private_builtin.MR_typeclass_info_param_type_info(
+ TypeClassInfo, Index);
").
:- pragma foreign_proc("C#",
@@ -748,7 +749,8 @@ __Compare____base_typeclass_info_1_0(
Index::in, TypeInfo::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
- TypeInfo = MR_typeclass_info_instance_tvar_type_info(TypeClassInfo, Index);
+ TypeInfo = private_builtin.MR_typeclass_info_instance_tvar_type_info(
+ TypeClassInfo, Index);
").
:- pragma foreign_proc("C#",
@@ -756,7 +758,8 @@ __Compare____base_typeclass_info_1_0(
TypeClassInfo::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
- TypeClassInfo = MR_typeclass_info_superclass_info(TypeClassInfo0, Index);
+ TypeClassInfo = private_builtin.MR_typeclass_info_superclass_info(
+ TypeClassInfo0, Index);
").
:- pragma foreign_proc("C#",
@@ -764,8 +767,8 @@ __Compare____base_typeclass_info_1_0(
Index::in, TypeClassInfo::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
- TypeClassInfo =
- MR_typeclass_info_arg_typeclass_info(TypeClassInfo0, Index);
+ TypeClassInfo = private_builtin.MR_typeclass_info_arg_typeclass_info(
+ TypeClassInfo0, Index);
").
:- pragma foreign_proc("Java",
diff --git a/library/string.m b/library/string.m
index d3e619f..91c7b0d 100644
--- a/library/string.m
+++ b/library/string.m
@@ -4488,7 +4488,7 @@ strchars(I, End, Str) = Chars :-
if (Count > len - Start) {
Count = len - Start;
}
- SubString = Str.Substring(Start, Start + Count);
+ SubString = Str.Substring(Start, Count);
}
").
--------------------------------------------------------------------------
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