[m-rev.] diff: .NET MC++ string literals
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Mar 3 13:57:40 AEDT 2003
Estimated hours taken: 2
Branches: main
library/builtin.m:
library/io.m:
library/library.m:
library/private_builtin.m:
library/string.m:
library/std_util.m:
library/table_builtin.m:
library/type_desc.m:
runtime/mercury_mcpp.cpp:
Use .NET string literals rather than using C string literals and
having them be then implicitly converted to .NET strings.
Workspace: /home/fjh/ws/hermes
Index: library/builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/builtin.m,v
retrieving revision 1.86
diff -u -d -r1.86 builtin.m
--- library/builtin.m 12 Feb 2003 22:58:16 -0000 1.86
+++ library/builtin.m 3 Mar 2003 02:35:25 -0000
@@ -608,7 +608,7 @@
__Unify____void_0_0(MR_Word x, MR_Word y)
{
mercury::runtime::Errors::fatal_error(
- ""called unify for type `void'"");
+ S""called unify for type `void'"");
return 0;
}
@@ -616,7 +616,7 @@
__Unify____c_pointer_0_0(MR_Word x, MR_Word y)
{
mercury::runtime::Errors::fatal_error(
- ""called unify for type `c_pointer'"");
+ S""called unify for type `c_pointer'"");
return 0;
}
@@ -624,7 +624,7 @@
__Unify____func_0_0(MR_Word x, MR_Word y)
{
mercury::runtime::Errors::fatal_error(
- ""called unify for `func' type"");
+ S""called unify for `func' type"");
return 0;
}
@@ -632,7 +632,7 @@
__Unify____pred_0_0(MR_Word x, MR_Word y)
{
mercury::runtime::Errors::fatal_error(
- ""called unify for `pred' type"");
+ S""called unify for `pred' type"");
return 0;
}
@@ -640,7 +640,7 @@
__Unify____tuple_0_0(MR_Word x, MR_Word y)
{
mercury::runtime::Errors::fatal_error(
- ""called unify for `tuple' type"");
+ S""called unify for `tuple' type"");
return 0;
}
@@ -663,7 +663,7 @@
x == y ? MR_COMPARE_EQUAL :
x < y ? MR_COMPARE_LESS :
(mercury::runtime::Errors::fatal_error(
- ""incomparable floats in compare/3""),
+ S""incomparable floats in compare/3""),
MR_COMPARE_EQUAL));
MR_newenum(*result, r);
}
@@ -695,7 +695,7 @@
MR_Word x, MR_Word y)
{
mercury::runtime::Errors::fatal_error(
- ""called compare/3 for type `void'"");
+ S""called compare/3 for type `void'"");
}
static void
@@ -703,7 +703,7 @@
MR_Word_Ref result, MR_Word x, MR_Word y)
{
mercury::runtime::Errors::fatal_error(
- ""called compare/3 for type `c_pointer'"");
+ S""called compare/3 for type `c_pointer'"");
}
static void
@@ -711,7 +711,7 @@
MR_Word x, MR_Word y)
{
mercury::runtime::Errors::fatal_error(
- ""called compare/3 for `func' type"");
+ S""called compare/3 for `func' type"");
}
static void
@@ -719,7 +719,7 @@
MR_Word x, MR_Word y)
{
mercury::runtime::Errors::fatal_error(
- ""called compare/3 for `pred' type"");
+ S""called compare/3 for `pred' type"");
}
static void
@@ -727,7 +727,7 @@
MR_Word x, MR_Word y)
{
mercury::runtime::Errors::fatal_error(
- ""called compare/3 for `pred' type"");
+ S""called compare/3 for `pred' type"");
}
/*
@@ -771,7 +771,7 @@
do_unify__void_0_0(MR_Box x, MR_Box y)
{
mercury::runtime::Errors::fatal_error(
- ""called unify for type `void'"");
+ S""called unify for type `void'"");
return 0;
}
@@ -787,7 +787,7 @@
do_unify__func_0_0(MR_Box x, MR_Box y)
{
mercury::runtime::Errors::fatal_error(
- ""called unify for `func' type"");
+ S""called unify for `func' type"");
return 0;
}
@@ -795,7 +795,7 @@
do_unify__pred_0_0(MR_Box x, MR_Box y)
{
mercury::runtime::Errors::fatal_error(
- ""called unify for `pred' type"");
+ S""called unify for `pred' type"");
return 0;
}
@@ -803,7 +803,7 @@
do_unify__tuple_0_0(MR_Box x, MR_Box y)
{
mercury::runtime::Errors::fatal_error(
- ""called unify for `tuple' type"");
+ S""called unify for `tuple' type"");
return 0;
}
@@ -850,7 +850,7 @@
do_compare__void_0_0(MR_Word_Ref result, MR_Box x, MR_Box y)
{
mercury::runtime::Errors::fatal_error(
- ""called compare/3 for type `void'"");
+ S""called compare/3 for type `void'"");
}
static void
@@ -867,21 +867,21 @@
do_compare__func_0_0(MR_Word_Ref result, MR_Box x, MR_Box y)
{
mercury::runtime::Errors::fatal_error(
- ""called compare/3 for func type"");
+ S""called compare/3 for func type"");
}
static void
do_compare__pred_0_0(MR_Word_Ref result, MR_Box x, MR_Box y)
{
mercury::runtime::Errors::fatal_error(
- ""called compare/3 for pred type"");
+ S""called compare/3 for pred type"");
}
static void
do_compare__tuple_0_0(MR_Word_Ref result, MR_Box x, MR_Box y)
{
mercury::runtime::Errors::fatal_error(
- ""called compare/3 for tuple type"");
+ S""called compare/3 for tuple type"");
}
").
Index: library/io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.291
diff -u -d -r1.291 io.m
--- library/io.m 15 Feb 2003 22:38:43 -0000 1.291
+++ library/io.m 3 Mar 2003 02:35:25 -0000
@@ -3779,24 +3779,24 @@
System::IO::Stream *stream = 0;
try {
- if (System::String::op_Equality(openmode, ""r"")) {
+ if (System::String::op_Equality(openmode, S""r"")) {
// Like '<' in Bourne shell.
// Read a file. The file must exist already.
mode = System::IO::FileMode::Open;
access = System::IO::FileAccess::Read;
- } else if (System::String::op_Equality(openmode, ""w"")) {
+ } else if (System::String::op_Equality(openmode, S""w"")) {
// Like '>' in Bourne shell.
// Overwrite an existing file, or create a new file.
mode = System::IO::FileMode::Create;
access = System::IO::FileAccess::Write;
- } else if (System::String::op_Equality(openmode, ""a"")) {
+ } else if (System::String::op_Equality(openmode, S""a"")) {
// Like '>>' in Bourne shell.
// Append to an existing file, or create a new file.
mode = System::IO::FileMode::Append;
access = System::IO::FileAccess::Write;
} else {
mercury::runtime::Errors::SORRY(System::String::Concat(
- ""foreign code for this function, open mode:"",
+ S""foreign code for this function, open mode:"",
openmode));
}
@@ -3940,7 +3940,7 @@
for (int i = 0; i < s->Length; i++) {
if (s->Chars[i] == '\\n') {
mf->line_number++;
- mf->writer->WriteLine("""");
+ mf->writer->WriteLine(S"""");
} else {
mf->writer->Write(s->Chars[i]);
}
@@ -3985,8 +3985,7 @@
// sanity check
if (mf->file_encoding != ML_raw_binary) {
mercury::runtime::Errors::fatal_error(
- ""mercury_print_binary_string: ""
- ""file encoding is not raw binary"");
+ S""mercury_print_binary_string: file encoding is not raw binary"");
}
//
@@ -4028,7 +4027,7 @@
byte_array[i] = s->get_Chars(i);
if (byte_array[i] != s->get_Chars(i)) {
mercury::runtime::Errors::SORRY(
- ""write_bytes: Unicode char does not fit in a byte"");
+ S""write_bytes: Unicode char does not fit in a byte"");
}
}
#endif
@@ -4113,9 +4112,7 @@
break;
default:
mercury::runtime::Errors::SORRY(
- ""mercury_getc: ""
- ""Environment::NewLine::Length ""
- ""is neither 1 nor 2"");
+ S""mercury_getc: Environment::NewLine::Length is neither 1 nor 2"");
}
}
break;
@@ -4128,7 +4125,7 @@
{
if (mf->putback != -1) {
mercury::runtime::Errors::SORRY(
- ""mercury_ungetc: max one character of putback"");
+ S""mercury_ungetc: max one character of putback"");
}
mf->putback = code;
if (code == '\\n') {
@@ -4429,7 +4426,7 @@
MR_word_to_c_pointer(File));
if (mf->putback != -1) {
mercury::runtime::Errors::SORRY(
- ""io__putback_byte: max one character of putback"");
+ S""io__putback_byte: max one character of putback"");
}
mf->putback = Byte;
MR_update_io(IO0, IO);
@@ -4568,7 +4565,7 @@
w->Write(Character);
break;
case ML_OS_text_encoding:
- w->WriteLine("""");
+ w->WriteLine(S"""");
break;
}
mercury_current_text_output->line_number++;
@@ -4839,7 +4836,7 @@
w->Write(Character);
break;
case ML_OS_text_encoding:
- w->WriteLine("""");
+ w->WriteLine(S"""");
break;
}
stream->line_number++;
@@ -6025,9 +6022,9 @@
StringToHGlobalAnsi(Prefix).ToPointer());;
char tmpFileName[MAX_PATH];
System::String *msg[] = {
- ""Unable to create temporary file in "",
+ S""Unable to create temporary file in "",
Dir,
- "" with prefix "",
+ S"" with prefix "",
Prefix
};
@@ -6036,23 +6033,23 @@
if (result == 0) {
Error = -1;
- FileName = """";
- ErrorMessage = System::String::Join("""", msg);
+ FileName = S"""";
+ ErrorMessage = System::String::Join(S"""", msg);
} else {
Error = 0;
FileName = tmpFileName;
- ErrorMessage = """";
+ ErrorMessage = S"""";
}
*/
try {
FileName = System::IO::Path::GetTempFileName();
Error = 0;
- ErrorMessage = """";
+ ErrorMessage = S"""";
}
catch (System::Exception *e)
{
- FileName = """";
+ FileName = S"""";
Error = -1;
ErrorMessage = e->Message;
}
Index: library/library.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/library.m,v
retrieving revision 1.65
diff -u -d -r1.65 library.m
--- library/library.m 23 Jan 2003 04:25:46 -0000 1.65
+++ library/library.m 3 Mar 2003 02:35:25 -0000
@@ -71,9 +71,11 @@
:- pragma foreign_proc("MC++",
library__version(Version::out), [will_not_call_mercury, promise_pure],
"
- // XXX we should use string literals with an S at the start
- // so this code uses just managed types.
- Version = MR_VERSION "", configured for "" MR_FULLARCH;
+ // MR_VERSION and MR_FULLARCH are C string literals.
+ // We need to paste 'S' to the front of them to make them into .NET
+ // string literals.
+ Version = MR_PASTE2(S, MR_VERSION) S"", configured for ""
+ MR_PASTE2(S, MR_FULLARCH);
").
library__version(_) :-
Index: library/private_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/private_builtin.m,v
retrieving revision 1.112
diff -u -d -r1.112 private_builtin.m
--- library/private_builtin.m 14 Feb 2003 10:03:27 -0000 1.112
+++ library/private_builtin.m 3 Mar 2003 02:35:25 -0000
@@ -464,7 +464,7 @@
__Unify____type_info_1_0(
MR_Word type_info, MR_Word x, MR_Word y)
{
- mercury::runtime::Errors::SORRY(""unify for type_info"");
+ mercury::runtime::Errors::SORRY(S""unify for type_info"");
return 0;
}
@@ -472,7 +472,7 @@
__Unify____typeclass_info_1_0(
MR_Word type_info, MR_Word x, MR_Word y)
{
- mercury::runtime::Errors::SORRY(""unify for typeclass_info"");
+ mercury::runtime::Errors::SORRY(S""unify for typeclass_info"");
return 0;
}
@@ -480,7 +480,7 @@
__Unify____base_typeclass_info_1_0(
MR_Word type_info, MR_Word x, MR_Word y)
{
- mercury::runtime::Errors::SORRY(""unify for base_typeclass_info"");
+ mercury::runtime::Errors::SORRY(S""unify for base_typeclass_info"");
return 0;
}
@@ -488,7 +488,7 @@
__Unify____type_ctor_info_1_0(
MR_Word type_info, MR_Word x, MR_Word y)
{
- mercury::runtime::Errors::SORRY(""unify for type_ctor_info"");
+ mercury::runtime::Errors::SORRY(S""unify for type_ctor_info"");
return 0;
}
@@ -496,28 +496,28 @@
__Compare____type_ctor_info_1_0(
MR_Word type_info, MR_Word_Ref result, MR_Word x, MR_Word y)
{
- mercury::runtime::Errors::SORRY(""compare for type_ctor_info"");
+ mercury::runtime::Errors::SORRY(S""compare for type_ctor_info"");
}
static void
__Compare____type_info_1_0(
MR_Word type_info, MR_Word_Ref result, MR_Word x, MR_Word y)
{
- mercury::runtime::Errors::SORRY(""compare for type_info"");
+ mercury::runtime::Errors::SORRY(S""compare for type_info"");
}
static void
__Compare____typeclass_info_1_0(
MR_Word type_info, MR_Word_Ref result, MR_Word x, MR_Word y)
{
- mercury::runtime::Errors::SORRY(""compare for typeclass_info"");
+ mercury::runtime::Errors::SORRY(S""compare for typeclass_info"");
}
static void
__Compare____base_typeclass_info_1_0(
MR_Word type_info, MR_Word_Ref result, MR_Word x, MR_Word y)
{
- mercury::runtime::Errors::SORRY(""compare for base_typeclass_info"");
+ mercury::runtime::Errors::SORRY(S""compare for base_typeclass_info"");
}
static int
@@ -836,7 +836,7 @@
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
- mercury::runtime::Errors::SORRY(""foreign code for this function"");
+ mercury::runtime::Errors::SORRY(S""foreign code for this function"");
// MR_store_ticket(Ticket);
#else
Ticket = 0;
@@ -847,7 +847,7 @@
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
- mercury::runtime::Errors::SORRY(""foreign code for this function"");
+ mercury::runtime::Errors::SORRY(S""foreign code for this function"");
// MR_reset_ticket(Ticket, MR_undo);
#endif
").
@@ -856,7 +856,7 @@
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
- mercury::runtime::Errors::SORRY(""foreign code for this function"");
+ mercury::runtime::Errors::SORRY(S""foreign code for this function"");
// MR_reset_ticket(Ticket, MR_commit);
#endif
").
@@ -865,7 +865,7 @@
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
- mercury::runtime::Errors::SORRY(""foreign code for this function"");
+ mercury::runtime::Errors::SORRY(S""foreign code for this function"");
// MR_reset_ticket(Ticket, MR_solve);
#endif
").
@@ -874,7 +874,7 @@
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
- mercury::runtime::Errors::SORRY(""foreign code for this function"");
+ mercury::runtime::Errors::SORRY(S""foreign code for this function"");
// MR_discard_ticket();
#endif
").
@@ -883,7 +883,7 @@
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
- mercury::runtime::Errors::SORRY(""foreign code for this function"");
+ mercury::runtime::Errors::SORRY(S""foreign code for this function"");
// MR_prune_ticket();
#endif
").
@@ -892,7 +892,7 @@
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
- mercury::runtime::Errors::SORRY(""foreign code for this function"");
+ mercury::runtime::Errors::SORRY(S""foreign code for this function"");
// MR_mark_ticket_stack(TicketCounter);
#else
TicketCounter = 0;
@@ -903,7 +903,7 @@
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
- mercury::runtime::Errors::SORRY(""foreign code for this function"");
+ mercury::runtime::Errors::SORRY(S""foreign code for this function"");
// MR_prune_tickets_to(TicketCounter);
#endif
").
@@ -1092,7 +1092,7 @@
__Unify__private_builtin__heap_pointer_0_0(MR_Word x, MR_Word y)
{
mercury::runtime::Errors::fatal_error(
- ""called unify for type `private_builtin:heap_pointer'"");
+ S""called unify for type `private_builtin:heap_pointer'"");
return 0;
}
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.280
diff -u -d -r1.280 std_util.m
--- library/std_util.m 10 Feb 2003 17:03:50 -0000 1.280
+++ library/std_util.m 3 Mar 2003 02:35:25 -0000
@@ -1045,7 +1045,7 @@
#ifdef MR_USE_TRAIL
/* XXX trailing not yet implemented for the MLDS back-end */
- mercury::runtime::Errors::SORRY(""foreign code for get_registers"");
+ mercury::runtime::Errors::SORRY(S""foreign code for get_registers"");
#else
TrailPtr = 0;
#endif
@@ -1073,7 +1073,8 @@
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
- mercury::runtime::Errors::SORRY(""foreign code for check_for_floundering"");
+ mercury::runtime::Errors::SORRY(
+ S""foreign code for check_for_floundering"");
#endif
").
@@ -1101,7 +1102,8 @@
[will_not_call_mercury, thread_safe],
"
#ifdef MR_USE_TRAIL
- mercury::runtime::Errors::SORRY(""foreign code for discard_trail_ticket"");
+ mercury::runtime::Errors::SORRY(
+ S""foreign code for discard_trail_ticket"");
#endif
").
Index: library/string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.193
diff -u -d -r1.193 string.m
--- library/string.m 13 Feb 2003 17:24:31 -0000 1.193
+++ library/string.m 3 Mar 2003 02:35:25 -0000
@@ -3522,7 +3522,7 @@
MR_Integer len;
MR_Word tmp;
if (Count <= 0) {
- Left = """";
+ Left = S"""";
Right = Str;
} else {
len = Str->get_Length();
Index: library/table_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/table_builtin.m,v
retrieving revision 1.26
diff -u -d -r1.26 table_builtin.m
--- library/table_builtin.m 28 Jan 2003 17:16:25 -0000 1.26
+++ library/table_builtin.m 3 Mar 2003 02:35:25 -0000
@@ -782,13 +782,13 @@
retry_code(""),
common_code("
mercury::runtime::Errors::SORRY(
- ""foreign code for this function"");
+ S""foreign code for this function"");
")
).
:- pragma foreign_proc("MC++",
table_nondet_resume(_A::in), [will_not_call_mercury, promise_pure], "
- mercury::runtime::Errors::SORRY(""foreign code for this function"");
+ mercury::runtime::Errors::SORRY(S""foreign code for this function"");
").
*/
Index: library/type_desc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/type_desc.m,v
retrieving revision 1.16
diff -u -d -r1.16 type_desc.m
--- library/type_desc.m 17 Jan 2003 05:56:50 -0000 1.16
+++ library/type_desc.m 3 Mar 2003 02:35:25 -0000
@@ -193,13 +193,15 @@
__Compare____type_ctor_desc_0_0(
MR_ComparisonResult *result, MR_TypeInfo_0 x, MR_TypeInfo_0 y)
{
- mercury::runtime::Errors::SORRY(""foreign code for comparing type_ctor_descs"");
+ mercury::runtime::Errors::SORRY(
+ S""foreign code for comparing type_ctor_descs"");
}
static MR_bool
__Unify____type_ctor_desc_0_0(MR_TypeInfo_0 x, MR_TypeInfo_0 y)
{
- mercury::runtime::Errors::SORRY(""foreign code for unifying type_ctor_descs"");
+ mercury::runtime::Errors::SORRY(
+ S""foreign code for unifying type_ctor_descs"");
return 0;
}
@@ -207,13 +209,15 @@
special___Compare___type_ctor_desc_0_0(
MR_ComparisonResult *result, MR_TypeInfo_0 x, MR_TypeInfo_0 y)
{
- mercury::runtime::Errors::SORRY(""foreign code for comparing type_ctor_descs"");
+ mercury::runtime::Errors::SORRY(
+ S""foreign code for comparing type_ctor_descs"");
}
static MR_bool
special___Unify___type_ctor_desc_0_0(MR_TypeInfo_0 x, MR_TypeInfo_0 y)
{
- mercury::runtime::Errors::SORRY(""foreign code for unifying type_ctor_descs"");
+ mercury::runtime::Errors::SORRY(
+ S""foreign code for unifying type_ctor_descs"");
return 0;
}
Index: runtime/mercury_mcpp.cpp
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_mcpp.cpp,v
retrieving revision 1.16
diff -u -d -r1.16 mercury_mcpp.cpp
--- runtime/mercury_mcpp.cpp 10 Feb 2003 18:03:16 -0000 1.16
+++ runtime/mercury_mcpp.cpp 3 Mar 2003 02:35:25 -0000
@@ -86,14 +86,14 @@
static void SORRY(MR_String s)
{
MR_String msg;
- msg = System::String::Concat("Sorry, unimplemented: ", s);
+ msg = System::String::Concat(S"Sorry, unimplemented: ", s);
throw new mercury::runtime::SystemException(msg);
}
static void fatal_error(MR_String s)
{
MR_String msg;
- msg = System::String::Concat("Fatal error: ", s);
+ msg = System::String::Concat(S"Fatal error: ", s);
throw new mercury::runtime::SystemException(msg);
}
};
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list