[m-rev.] diff: remove MC++ function implementations from the library
Tyson Dowd
trd at miscrit.be
Tue Aug 14 01:48:17 AEST 2001
Hi,
This fixes a few bugs in the library and avoids creating more bugs.
===================================================================
Estimated hours taken: 10
Branches: main
The MC++ interface for functions is buggy.
This change generates errors in most cases where a function is
implemented in MC++, and removes all the occurances of such functions
from the library. We replace them with C# implementations, as functions
work fine in C#.
compiler/mlds_to_il.m:
Abort if a function is implemented in MC++. We don't catch the
case of functions that return int, as it is difficult to be sure
this isn't just a semidet predicate (which works and is used).
However this catches a lot of cases where we were silently
generating bad code so it is better than nothing.
library/Mmakefile:
Add flags to control debugging (commented out for the moment).
Move the .NET flags together.
library/builtin.m:
library/float.m:
library/io.m:
library/math.m:
library/sparse_bitset.m:
library/std_util.m:
library/string.m:
Implement functions in C#, as functions don't work when a
foreign_proc is MC++.
This fixes several latent bugs in the library.
runtime/Mmakefile:
Add support for debugging (commented out for the moment).
runtime/mercury_mcpp.cpp:
Add code to manipulate low level data structures (so we can do
this from C# as well as MC++).
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.71
diff -u -r1.71 mlds_to_il.m
--- compiler/mlds_to_il.m 2001/08/13 04:01:27 1.71
+++ compiler/mlds_to_il.m 2001/08/13 14:11:48
@@ -1579,8 +1579,10 @@
% return a useful value.
{ RetType = void ->
StoreReturnInstr = empty
- ;
+ ; RetType = simple_type(int32) ->
StoreReturnInstr = instr_node(stloc(name("succeeded")))
+ ;
+ sorry(this_file, "functions in MC++")
},
MethodName =^ method_name,
{ assoc_list__keys(Params, TypeParams) },
Index: library/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.77
diff -u -r1.77 Mmakefile
--- library/Mmakefile 2001/08/12 13:29:16 1.77
+++ library/Mmakefile 2001/08/13 14:11:51
@@ -91,10 +91,6 @@
$(INTERMODULE_OPTS) $(CHECK_TERM_OPTS)
MGNUC = $(M_ENV) $(SCRIPTS_DIR)/mgnuc
MGNUCFLAGS = $(DLL_CFLAGS)
- # -AI sets the assembly search path (just like -I for assemblies)
-MS_CLFLAGS = -AI$(RUNTIME_DIR) -I$(RUNTIME_DIR)
-MS_CL_NOASM=:noAssembly
-MS_CSCFLAGS=/t:module
LDFLAGS = -L$(BOEHM_GC_DIR) -L$(RUNTIME_DIR)
ALL_LDFLAGS = $(LDFLAGS) $(EXTRA_LDFLAGS)
LDLIBS = -l$(RT_LIB_NAME) \
@@ -218,7 +214,16 @@
RUNTIME_DLLS=../runtime/mercury_mcpp.dll ../runtime/mercury_il.dll
# Turn this on if you wish to enable .NET debugging.
-#MS_ILASMFLAGS = /debug
+DEBUG_MS_ILASMFLAGS=
+#DEBUG_MS_ILASMFLAGS=/debug
+#DEBUG_MS_CLFLAGS=/Zi
+#DEBUG_MS_CSCFLAGS=/debug
+
+ # -AI sets the assembly search path (just like -I for assemblies)
+MS_CLFLAGS = -AI`cygpath -w $(RUNTIME_DIR)` -I`cygpath -w $(RUNTIME_DIR)` $(DEBUG_MS_CLFLAGS)
+MS_CL_NOASM=:noAssembly
+MS_CSCFLAGS=/t:module $(DEBUG_MS_CSCFLAGS)
+MS_ILASMFLAGS=$(DEBUG_MS_ILASMFLAGS)
# If you do generate a new strong name, you had better update
# compiler/mlds_to_il.m to generate references to it. It is also hard-coded
Index: library/builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/builtin.m,v
retrieving revision 1.59
diff -u -r1.59 builtin.m
--- library/builtin.m 2001/07/31 10:07:58 1.59
+++ library/builtin.m 2001/08/13 14:11:51
@@ -237,11 +237,11 @@
(Y :: out(pred(out) is semidet)),
[will_not_call_mercury, thread_safe],
"Y = X;").
-:- pragma foreign_proc("MC++", cc_cast(X :: (pred(out) is cc_multi)) =
+:- pragma foreign_proc("C#", cc_cast(X :: (pred(out) is cc_multi)) =
(Y :: out(pred(out) is det)),
[will_not_call_mercury, thread_safe],
"Y = X;").
-:- pragma foreign_proc("MC++", cc_cast(X :: (pred(out) is cc_nondet)) =
+:- pragma foreign_proc("C#", cc_cast(X :: (pred(out) is cc_nondet)) =
(Y :: out(pred(out) is semidet)),
[will_not_call_mercury, thread_safe],
"Y = X;").
@@ -258,7 +258,7 @@
(Y :: out(pred(out, di, uo) is det)),
[will_not_call_mercury, thread_safe],
"Y = X;").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
cc_cast_io(X :: (pred(out, di, uo) is cc_multi)) =
(Y :: out(pred(out, di, uo) is det)),
[will_not_call_mercury, thread_safe],
Index: library/float.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/float.m,v
retrieving revision 1.35
diff -u -r1.35 float.m
--- library/float.m 2001/05/02 14:44:25 1.35
+++ library/float.m 2001/08/13 14:11:52
@@ -381,10 +381,10 @@
"
Ceil = (MR_Integer) ceil(X);
").
-:- pragma foreign_proc("MC++", float__ceiling_to_int(X :: in) = (Ceil :: out),
+:- pragma foreign_proc("C#", float__ceiling_to_int(X :: in) = (Ceil :: out),
[will_not_call_mercury, thread_safe],
"
- Ceil = (MR_Integer) System::Math::Ceiling(X);
+ Ceil = System.Convert.ToInt32(System.Math.Ceiling(X));
").
float__ceiling_to_int(X, float__ceiling_to_int(X)).
@@ -396,10 +396,10 @@
"
Floor = (MR_Integer) floor(X);
").
-:- pragma foreign_proc("MC++", float__floor_to_int(X :: in) = (Floor :: out),
+:- pragma foreign_proc("C#", float__floor_to_int(X :: in) = (Floor :: out),
[will_not_call_mercury, thread_safe],
"
- Floor = (MR_Integer) System::Math::Floor(X);
+ Floor = System.Convert.ToInt32(System.Math.Floor(X));
").
float__floor_to_int(X, float__floor_to_int(X)).
@@ -411,10 +411,10 @@
"
Round = (MR_Integer) floor(X + 0.5);
").
-:- pragma foreign_proc("MC++", float__round_to_int(X :: in) = (Round :: out),
+:- pragma foreign_proc("C#", float__round_to_int(X :: in) = (Round :: out),
[will_not_call_mercury, thread_safe],
"
- Round = (MR_Integer) System::Math::Floor(X + 0.5);
+ Round = System.Convert.ToInt32(System.Math.Floor(X + 0.5));
").
float__round_to_int(X, float__round_to_int(X)).
@@ -426,10 +426,10 @@
"
Trunc = (MR_Integer) X;
").
-:- pragma foreign_proc("MC++", float__truncate_to_int(X :: in) = (Trunc :: out),
+:- pragma foreign_proc("C#", float__truncate_to_int(X :: in) = (Trunc :: out),
[will_not_call_mercury, thread_safe],
"
- Trunc = (MR_Integer) X;
+ Trunc = System.Convert.ToInt32(X);
").
float__truncate_to_int(X, float__truncate_to_int(X)).
@@ -494,7 +494,7 @@
"
H = MR_hash_float(F);
").
-:- pragma foreign_proc("MC++", float__hash(F::in) = (H::out),
+:- pragma foreign_proc("C#", float__hash(F::in) = (H::out),
[will_not_call_mercury, thread_safe],
"
H = F.GetHashCode();
@@ -535,9 +535,9 @@
:- pragma foreign_proc("C", float__max = (Max::out),
[will_not_call_mercury, thread_safe],
"Max = ML_FLOAT_MAX;").
-:- pragma foreign_proc("MC++", float__max = (Max::out),
+:- pragma foreign_proc("C#", float__max = (Max::out),
[will_not_call_mercury, thread_safe],
- "Max = MR_BoxedFloat::MaxValue;").
+ "Max = System.Double.MaxValue;").
float__max(float__max).
@@ -546,9 +546,9 @@
:- pragma foreign_proc("C", float__min = (Min::out),
[will_not_call_mercury, thread_safe],
"Min = ML_FLOAT_MIN;").
-:- pragma foreign_proc("MC++", float__min = (Min::out),
+:- pragma foreign_proc("C#", float__min = (Min::out),
[will_not_call_mercury, thread_safe],
- "Min = MR_BoxedFloat::MinValue;").
+ "Min = System.Double.MinValue;").
float__min(float__min).
@@ -556,9 +556,9 @@
:- pragma foreign_proc("C", float__epsilon = (Eps::out),
[will_not_call_mercury, thread_safe],
"Eps = ML_FLOAT_EPSILON;").
-:- pragma foreign_proc("MC++", float__epsilon = (Eps::out),
+:- pragma foreign_proc("C#", float__epsilon = (Eps::out),
[will_not_call_mercury, thread_safe],
- "Eps = MR_BoxedFloat::Epsilon;").
+ "Eps = System.Double.Epsilon;").
float__epsilon(float__epsilon).
@@ -566,9 +566,10 @@
:- pragma foreign_proc("C", float__radix = (Radix::out),
[will_not_call_mercury, thread_safe],
"Radix = ML_FLOAT_RADIX;").
-:- pragma foreign_proc("MC++", float__radix = (_Radix::out),
+:- pragma foreign_proc("C#", float__radix = (_Radix::out),
[will_not_call_mercury, thread_safe], "
- mercury::runtime::Errors::SORRY(""foreign code for this function"");
+ mercury.runtime.Errors.SORRY(""foreign code for this function"");
+ _Radix = 0;
").
float__radix(float__radix).
@@ -577,9 +578,10 @@
:- pragma foreign_proc("C", float__mantissa_digits = (MantDig::out),
[will_not_call_mercury, thread_safe],
"MantDig = ML_FLOAT_MANT_DIG;").
-:- pragma foreign_proc("MC++", float__mantissa_digits = (_MantDig::out),
+:- pragma foreign_proc("C#", float__mantissa_digits = (_MantDig::out),
[will_not_call_mercury, thread_safe], "
- mercury::runtime::Errors::SORRY(""foreign code for this function"");
+ mercury.runtime.Errors.SORRY(""foreign code for this function"");
+ _MantDig = 0;
").
float__mantissa_digits(float__mantissa_digits).
@@ -590,9 +592,10 @@
:- pragma foreign_proc("C", float__min_exponent = (MinExp::out),
[will_not_call_mercury, thread_safe],
"MinExp = ML_FLOAT_MIN_EXP;").
-:- pragma foreign_proc("MC++", float__min_exponent = (_MinExp::out),
+:- pragma foreign_proc("C#", float__min_exponent = (_MinExp::out),
[will_not_call_mercury, thread_safe], "
- mercury::runtime::Errors::SORRY(""foreign code for this function"");
+ mercury.runtime.Errors.SORRY(""foreign code for this function"");
+ _MinExp = 0;
").
float__min_exponent(float__min_exponent).
@@ -604,9 +607,10 @@
[will_not_call_mercury, thread_safe],
"MaxExp = ML_FLOAT_MAX_EXP;").
-:- pragma foreign_proc("MC++", float__max_exponent = (_MaxExp::out),
+:- pragma foreign_proc("C#", float__max_exponent = (_MaxExp::out),
[will_not_call_mercury, thread_safe], "
- mercury::runtime::Errors::SORRY(""foreign code for this function"");
+ mercury.runtime.Errors.SORRY(""foreign code for this function"");
+ _MaxExp = 0;
").
Index: library/io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.229
diff -u -r1.229 io.m
--- library/io.m 2001/07/31 01:22:33 1.229
+++ library/io.m 2001/08/13 14:11:53
@@ -2408,7 +2408,7 @@
"
VarOut = VarIn;
").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
unsafe_cast(VarIn::in) = (VarOut::out),
[will_not_call_mercury, thread_safe],
"
Index: library/math.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/math.m,v
retrieving revision 1.29
diff -u -r1.29 math.m
--- library/math.m 2001/05/02 16:13:26 1.29
+++ library/math.m 2001/08/13 14:11:53
@@ -227,12 +227,12 @@
"). % end pragma foreign_decl
-:- pragma foreign_decl("MC++", "
+:- pragma foreign_code("C#", "
// This is not defined in the .NET Frameworks.
- // For pi and e we use the constants defined in System::Math.
+ // For pi and e we use the constants defined in System.Math.
- #define ML_FLOAT_LN2 0.69314718055994530941
+ public static double ML_FLOAT_LN2 = 0.69314718055994530941;
").
:- pragma foreign_code("C", "
@@ -259,15 +259,15 @@
"). % end pragma foreign_code
-:- pragma foreign_code("MC++", "
+:- pragma foreign_code("C#", "
/*
** Handle domain errors.
*/
static void
-ML_math_domain_error(MR_String where)
+ML_math_domain_error(string where)
{
- throw new mercury::runtime::Exception(where);
+ throw new mercury.runtime.Exception(where);
}
"). % end pragma foreign_code
@@ -280,9 +280,9 @@
math__pi = (Pi::out), [will_not_call_mercury, thread_safe],"
Pi = ML_FLOAT_PI;
").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
math__pi = (Pi::out), [will_not_call_mercury, thread_safe],"
- Pi = System::Math::PI;
+ Pi = System.Math.PI;
").
% Base of natural logarithms
@@ -290,9 +290,9 @@
math__e = (E::out), [will_not_call_mercury, thread_safe],"
E = ML_FLOAT_E;
").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
math__e = (E::out), [will_not_call_mercury, thread_safe],"
- E = System::Math::E;
+ E = System.Math.E;
").
%
@@ -304,10 +304,10 @@
[will_not_call_mercury, thread_safe],"
Ceil = ceil(Num);
").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
math__ceiling(Num::in) = (Ceil::out),
[will_not_call_mercury, thread_safe],"
- Ceil = System::Math::Ceiling(Num);
+ Ceil = System.Math.Ceiling(Num);
").
%
@@ -319,10 +319,10 @@
[will_not_call_mercury, thread_safe],"
Floor = floor(Num);
").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
math__floor(Num::in) = (Floor::out),
[will_not_call_mercury, thread_safe],"
- Floor = System::Math::Floor(Num);
+ Floor = System.Math.Floor(Num);
").
%
@@ -335,12 +335,12 @@
[will_not_call_mercury, thread_safe],"
Rounded = floor(Num+0.5);
").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
math__round(Num::in) = (Rounded::out),
[will_not_call_mercury, thread_safe],"
- // XXX the semantics of System::Math::Round() are not the same as ours.
+ // XXX the semantics of System.Math.Round() are not the same as ours.
// Unfortunately they are better (round to nearest even number).
- Rounded = System::Math::Floor(Num+0.5);
+ Rounded = System.Math.Floor(Num+0.5);
").
%
@@ -365,14 +365,15 @@
#endif
SquareRoot = sqrt(X);
").
-:- pragma foreign_proc("MC++", math__sqrt(X::in) = (SquareRoot::out),
+:- pragma foreign_proc("C#", math__sqrt(X::in) = (SquareRoot::out),
[will_not_call_mercury, thread_safe], "
-#ifndef ML_OMIT_MATH_DOMAIN_CHECKS
+#if ML_OMIT_MATH_DOMAIN_CHECKS
+#else
if (X < 0.0) {
ML_math_domain_error(""math__sqrt"");
}
#endif
- SquareRoot = System::Math::Sqrt(X);
+ SquareRoot = System.Math.Sqrt(X);
").
@@ -446,9 +447,11 @@
#endif
").
-:- pragma foreign_proc("MC++", math__pow(X::in, Y::in) = (Res::out),
+:- pragma foreign_proc("C#", math__pow(X::in, Y::in) = (Res::out),
[will_not_call_mercury, thread_safe], "
-#ifndef ML_OMIT_MATH_DOMAIN_CHECKS
+#if ML_OMIT_MATH_DOMAIN_CHECKS
+ Res = System.Math.Pow(X, Y);
+#else
if (X < 0.0) {
ML_math_domain_error(""math__pow"");
}
@@ -458,10 +461,8 @@
}
Res = 0.0;
} else {
- Res = System::Math::Pow(X, Y);
+ Res = System.Math.Pow(X, Y);
}
-#else
- Res = System::Math::Pow(X, Y);
#endif
").
@@ -474,9 +475,9 @@
[will_not_call_mercury, thread_safe],"
Exp = exp(X);
").
-:- pragma foreign_proc("MC++", math__exp(X::in) = (Exp::out),
+:- pragma foreign_proc("C#", math__exp(X::in) = (Exp::out),
[will_not_call_mercury, thread_safe],"
- Exp = System::Math::Exp(X);
+ Exp = System.Math.Exp(X);
").
%
@@ -495,14 +496,15 @@
#endif
Log = log(X);
").
-:- pragma foreign_proc("MC++", math__ln(X::in) = (Log::out),
+:- pragma foreign_proc("C#", math__ln(X::in) = (Log::out),
[will_not_call_mercury, thread_safe], "
-#ifndef ML_OMIT_MATH_DOMAIN_CHECKS
+#if ML_OMIT_MATH_DOMAIN_CHECKS
+#else
if (X <= 0.0) {
ML_math_domain_error(""math__ln"");
}
#endif
- Log = System::Math::Log(X);
+ Log = System.Math.Log(X);
").
%
@@ -521,14 +523,15 @@
#endif
Log10 = log10(X);
").
-:- pragma foreign_proc("MC++", math__log10(X::in) = (Log10::out),
+:- pragma foreign_proc("C#", math__log10(X::in) = (Log10::out),
[will_not_call_mercury, thread_safe], "
-#ifndef ML_OMIT_MATH_DOMAIN_CHECKS
+#if ML_OMIT_MATH_DOMAIN_CHECKS
+#else
if (X <= 0.0) {
ML_math_domain_error(""math__log10"");
}
#endif
- Log10 = System::Math::Log10(X);
+ Log10 = System.Math.Log10(X);
").
%
@@ -547,14 +550,15 @@
#endif
Log2 = log(X) / ML_FLOAT_LN2;
").
-:- pragma foreign_proc("MC++", math__log2(X::in) = (Log2::out),
+:- pragma foreign_proc("C#", math__log2(X::in) = (Log2::out),
[will_not_call_mercury, thread_safe], "
-#ifndef ML_OMIT_MATH_DOMAIN_CHECKS
+#if ML_OMIT_MATH_DOMAIN_CHECKS
+#else
if (X <= 0.0) {
ML_math_domain_error(""math__log2"");
}
#endif
- Log2 = System::Math::Log(X) / ML_FLOAT_LN2;
+ Log2 = System.Math.Log(X) / ML_FLOAT_LN2;
").
%
@@ -578,9 +582,10 @@
#endif
Log = log(X)/log(B);
").
-:- pragma foreign_proc("MC++", math__log(B::in, X::in) = (Log::out),
+:- pragma foreign_proc("C#", math__log(B::in, X::in) = (Log::out),
[will_not_call_mercury, thread_safe], "
-#ifndef ML_OMIT_MATH_DOMAIN_CHECKS
+#if ML_OMIT_MATH_DOMAIN_CHECKS
+#else
if (X <= 0.0 || B <= 0.0) {
ML_math_domain_error(""math__log"");
}
@@ -588,7 +593,7 @@
ML_math_domain_error(""math__log"");
}
#endif
- Log = System::Math::Log(X,B);
+ Log = System.Math.Log(X,B);
").
@@ -599,9 +604,9 @@
[will_not_call_mercury, thread_safe],"
Sin = sin(X);
").
-:- pragma foreign_proc("MC++", math__sin(X::in) = (Sin::out),
+:- pragma foreign_proc("C#", math__sin(X::in) = (Sin::out),
[will_not_call_mercury, thread_safe],"
- Sin = System::Math::Sin(X);
+ Sin = System.Math.Sin(X);
").
@@ -612,9 +617,9 @@
[will_not_call_mercury, thread_safe],"
Cos = cos(X);
").
-:- pragma foreign_proc("MC++", math__cos(X::in) = (Cos::out),
+:- pragma foreign_proc("C#", math__cos(X::in) = (Cos::out),
[will_not_call_mercury, thread_safe],"
- Cos = System::Math::Cos(X);
+ Cos = System.Math.Cos(X);
").
%
@@ -624,9 +629,9 @@
[will_not_call_mercury, thread_safe],"
Tan = tan(X);
").
-:- pragma foreign_proc("MC++", math__tan(X::in) = (Tan::out),
+:- pragma foreign_proc("C#", math__tan(X::in) = (Tan::out),
[will_not_call_mercury, thread_safe],"
- Tan = System::Math::Tan(X);
+ Tan = System.Math.Tan(X);
").
%
@@ -645,14 +650,15 @@
#endif
ASin = asin(X);
").
-:- pragma foreign_proc("MC++", math__asin(X::in) = (ASin::out),
+:- pragma foreign_proc("C#", math__asin(X::in) = (ASin::out),
[will_not_call_mercury, thread_safe], "
-#ifndef ML_OMIT_MATH_DOMAIN_CHECKS
+#if ML_OMIT_MATH_DOMAIN_CHECKS
+#else
if (X < -1.0 || X > 1.0) {
ML_math_domain_error(""math__asin"");
}
#endif
- ASin = System::Math::Asin(X);
+ ASin = System.Math.Asin(X);
").
%
@@ -671,14 +677,15 @@
#endif
ACos = acos(X);
").
-:- pragma foreign_proc("MC++", math__acos(X::in) = (ACos::out),
+:- pragma foreign_proc("C#", math__acos(X::in) = (ACos::out),
[will_not_call_mercury, thread_safe], "
-#ifndef ML_OMIT_MATH_DOMAIN_CHECKS
+#if ML_OMIT_MATH_DOMAIN_CHECKS
+#else
if (X < -1.0 || X > 1.0) {
ML_math_domain_error(""math__acos"");
}
#endif
- ACos = System::Math::Acos(X);
+ ACos = System.Math.Acos(X);
").
@@ -690,9 +697,9 @@
[will_not_call_mercury, thread_safe],"
ATan = atan(X);
").
-:- pragma foreign_proc("MC++", math__atan(X::in) = (ATan::out),
+:- pragma foreign_proc("C#", math__atan(X::in) = (ATan::out),
[will_not_call_mercury, thread_safe],"
- ATan = System::Math::Atan(X);
+ ATan = System.Math.Atan(X);
").
%
@@ -703,9 +710,9 @@
[will_not_call_mercury, thread_safe], "
ATan2 = atan2(Y, X);
").
-:- pragma foreign_proc("MC++", math__atan2(Y::in, X::in) = (ATan2::out),
+:- pragma foreign_proc("C#", math__atan2(Y::in, X::in) = (ATan2::out),
[will_not_call_mercury, thread_safe], "
- ATan2 = System::Math::Atan2(Y, X);
+ ATan2 = System.Math.Atan2(Y, X);
").
%
@@ -716,9 +723,9 @@
[will_not_call_mercury, thread_safe],"
Sinh = sinh(X);
").
-:- pragma foreign_proc("MC++", math__sinh(X::in) = (Sinh::out),
+:- pragma foreign_proc("C#", math__sinh(X::in) = (Sinh::out),
[will_not_call_mercury, thread_safe],"
- Sinh = System::Math::Sinh(X);
+ Sinh = System.Math.Sinh(X);
").
%
@@ -729,9 +736,9 @@
[will_not_call_mercury, thread_safe],"
Cosh = cosh(X);
").
-:- pragma foreign_proc("MC++", math__cosh(X::in) = (Cosh::out),
+:- pragma foreign_proc("C#", math__cosh(X::in) = (Cosh::out),
[will_not_call_mercury, thread_safe],"
- Cosh = System::Math::Cosh(X);
+ Cosh = System.Math.Cosh(X);
").
%
@@ -742,9 +749,9 @@
[will_not_call_mercury, thread_safe],"
Tanh = tanh(X);
").
-:- pragma foreign_proc("MC++", math__tanh(X::in) = (Tanh::out),
+:- pragma foreign_proc("C#", math__tanh(X::in) = (Tanh::out),
[will_not_call_mercury, thread_safe],"
- Tanh = System::Math::Tanh(X);
+ Tanh = System.Math.Tanh(X);
").
%---------------------------------------------------------------------------%
Index: library/sparse_bitset.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/sparse_bitset.m,v
retrieving revision 1.9
diff -u -r1.9 sparse_bitset.m
--- library/sparse_bitset.m 2001/07/31 10:07:59 1.9
+++ library/sparse_bitset.m 2001/08/13 14:11:54
@@ -781,15 +781,15 @@
}").
% XXX this needs to take reserve-tag into account too
-:- pragma foreign_proc("MC++", make_bitset_elem(A::in, B::in) = (Pair::out),
+:- pragma foreign_proc("C#", make_bitset_elem(A::in, B::in) = (Pair::out),
[will_not_call_mercury, thread_safe],
"{
-#ifdef MR_RESERVE_TAG
- #error ""sparse_bitset not implemented for MC++ in .rt grades""
+#if MR_RESERVE_TAG
+ #error ""sparse_bitset not implemented for .NET in .rt grades""
#endif
- MR_newobj((Pair), 0, 2);
- MR_objset((Pair), 1, __box(A));
- MR_objset((Pair), 2, __box(B));
+ Pair = mercury.runtime.LowLevelData.make_MR_Word(0, 2);
+ mercury.runtime.LowLevelData.set_MR_Word_field(Pair, 1, A);
+ mercury.runtime.LowLevelData.set_MR_Word_field(Pair, 2, B);
}").
%-----------------------------------------------------------------------------%
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.236
diff -u -r1.236 std_util.m
--- library/std_util.m 2001/07/16 09:49:41 1.236
+++ library/std_util.m 2001/08/13 14:11:56
@@ -1635,7 +1635,7 @@
}
").
-:- pragma foreign_proc("MC++", type_of(_Value::unused) = (TypeInfo::out),
+:- pragma foreign_proc("C#", type_of(_Value::unused) = (TypeInfo::out),
will_not_call_mercury, "
{
TypeInfo = TypeInfo_for_T;
@@ -1648,7 +1648,7 @@
TypeInfo_for_T = TypeInfo;
").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
has_type(_Arg::unused, TypeInfo::in), will_not_call_mercury, "
TypeInfo_for_T = TypeInfo;
").
@@ -1760,10 +1760,11 @@
}
").
-:- pragma foreign_proc("MC++", type_ctor(_TypeInfo::in) = (_TypeCtor::out),
+:- pragma foreign_proc("C#", type_ctor(_TypeInfo::in) = (_TypeCtor::out),
will_not_call_mercury, "
{
- mercury::runtime::Errors::SORRY(""compare for type_desc"");
+ mercury.runtime.Errors.SORRY(""foreign code for type_ctor"");
+ _TypeCtor = null;
}
").
@@ -2265,11 +2266,14 @@
}
").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
make_type(_TypeCtorDesc::out, _ArgTypes::out) = (_TypeDesc::in),
will_not_call_mercury, "
{
- mercury::runtime::Errors::SORRY(""compare for type_desc"");
+ mercury.runtime.Errors.SORRY(""foreign code for this function"");
+ // XXX this is required to keep the C# compiler quiet, but we should
+ // really fix the interface to semidet C#
+ succeeded = 1;
}
").
@@ -2278,14 +2282,14 @@
_TypeCtorArity::out),
will_not_call_mercury, "
{
- mercury::runtime::Errors::SORRY(""compare for type_desc"");
+ mercury::runtime::Errors::SORRY(""foreign code for this function"");
}
").
:- pragma foreign_proc("MC++", num_functors(_TypeInfo::in) = (_Functors::out),
will_not_call_mercury, "
{
- mercury::runtime::Errors::SORRY(""compare for type_desc"");
+ mercury::runtime::Errors::SORRY(""foreign code for this function"");
}
").
@@ -2293,7 +2297,7 @@
_FunctorName::out, _Arity::out, _TypeInfoList::out),
will_not_call_mercury, "
{
- mercury::runtime::Errors::SORRY(""compare for type_desc"");
+ mercury::runtime::Errors::SORRY(""foreign code for this function"");
}
").
@@ -2301,15 +2305,19 @@
get_functor_ordinal(_TypeDesc::in, _FunctorNumber::in,
_Ordinal::out), will_not_call_mercury, "
{
- mercury::runtime::Errors::SORRY(""compare for type_desc"");
+ mercury::runtime::Errors::SORRY(""foreign code for this function"");
}
").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
construct(_TypeDesc::in, _FunctorNumber::in,
_ArgList::in) = (_Term::out), will_not_call_mercury, "
{
- mercury::runtime::Errors::SORRY(""compare for type_desc"");
+ mercury.runtime.Errors.SORRY(""foreign code for this function"");
+ _Term = null;
+ // XXX this is required to keep the C# compiler quiet, but we should
+ // really fix the interface to semidet C#
+ succeeded = 1;
}
").
@@ -2361,11 +2369,12 @@
}
").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
construct_tuple_2(_Args::in, _ArgTypes::in, _Arity::in) = (_Term::out),
will_not_call_mercury, "
{
- mercury::runtime::Errors::SORRY(""compare for type_desc"");
+ mercury.runtime.Errors.SORRY(""compare for type_desc"");
+ _Term = null;
}
").
@@ -3279,18 +3288,24 @@
** changes to store__arg_ref in store.m.
*/
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
arg(_Term::in, _ArgumentIndex::in) = (_Argument::out),
will_not_call_mercury, "
{
- mercury::runtime::Errors::SORRY(""foreign code for this function"");
+ mercury.runtime.Errors.SORRY(""foreign code for this function"");
+ // XXX this is required to keep the C# compiler quiet, but we should
+ // really fix the interface to semidet C#
+ succeeded = 1;
}").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
argument(_Term::in, _ArgumentIndex::in) = (_ArgumentUniv::out),
will_not_call_mercury, "
{
- mercury::runtime::Errors::SORRY(""foreign code for this function"");
+ mercury.runtime.Errors.SORRY(""foreign code for this function"");
+ // XXX this is required to keep the C# compiler quiet, but we should
+ // really fix the interface to semidet C#
+ succeeded = 1;
}").
det_arg(Type, ArgumentIndex) = Argument :-
Index: library/string.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/string.m,v
retrieving revision 1.153
diff -u -r1.153 string.m
--- library/string.m 2001/08/13 01:18:04 1.153
+++ library/string.m 2001/08/13 14:11:57
@@ -1019,16 +1019,18 @@
Str[len] = '\\0';
}").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
string__append_list(_Strs::in) = (_Str::uo),
[will_not_call_mercury, thread_safe], "{
- mercury::runtime::Errors::SORRY(""c code for this function"");
+ mercury.runtime.Errors.SORRY(""foreign code for this function"");
+ _Str = null;
}").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
string__join_list(_Sep::in, _Strs::in) = (_Str::uo),
[will_not_call_mercury, thread_safe], "{
- mercury::runtime::Errors::SORRY(""c code for this function"");
+ mercury.runtime.Errors.SORRY(""foreign code for this function"");
+ _Str = null;
}").
%-----------------------------------------------------------------------------%
@@ -1456,10 +1458,11 @@
(MR_String) (MR_Word) MR_INTEGER_LENGTH_MODIFIER);
}").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
int_length_modifer = (_LengthModifier::out),
[will_not_call_mercury, thread_safe], "{
- mercury::runtime::Errors::SORRY(""c code for this function"");
+ mercury.runtime.Errors.SORRY(""foreign code for this function"");
+ _LengthModifier = null;
}").
@@ -1474,10 +1477,11 @@
Str = MR_make_string(MR_PROC_LABEL, FormatStr, (double) Val);
MR_restore_transient_hp();
}").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
format_float(_FormatStr::in, _Val::in) = (_Str::out),
[will_not_call_mercury, thread_safe], "{
- mercury::runtime::Errors::SORRY(""c code for this function"");
+ mercury.runtime.Errors.SORRY(""foreign code for this function"");
+ _Str = null;
}").
% Create a string from a int using the format string.
@@ -1491,10 +1495,11 @@
Str = MR_make_string(MR_PROC_LABEL, FormatStr, Val);
MR_restore_transient_hp();
}").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
format_int(_FormatStr::in, _Val::in) = (_Str::out),
[will_not_call_mercury, thread_safe], "{
- mercury::runtime::Errors::SORRY(""c code for this function"");
+ mercury.runtime.Errors.SORRY(""foreign code for this function"");
+ _Str = null;
}").
% Create a string from a string using the format string.
@@ -1506,10 +1511,11 @@
[will_not_call_mercury, thread_safe], "{
Str = MR_make_string(MR_PROC_LABEL, FormatStr, Val);
}").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
format_string(_FormatStr::in, _Val::in) = (_Str::out),
[will_not_call_mercury, thread_safe], "{
- mercury::runtime::Errors::SORRY(""c code for this function"");
+ mercury.runtime.Errors.SORRY(""foreign code for this function"");
+ _Str = null;
}").
% Create a string from a char using the format string.
@@ -1523,10 +1529,11 @@
Str = MR_make_string(MR_PROC_LABEL, FormatStr, Val);
MR_restore_transient_hp();
}").
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
format_char(_FormatStr::in, _Val::in) = (_Str::out),
[will_not_call_mercury, thread_safe], "{
- mercury::runtime::Errors::SORRY(""c code for this function"");
+ mercury.runtime.Errors.SORRY(""foreign code for this function"");
+ _Str = null;
}").
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.76
diff -u -r1.76 Mmakefile
--- runtime/Mmakefile 2001/07/31 10:08:01 1.76
+++ runtime/Mmakefile 2001/08/13 14:11:57
@@ -336,6 +336,8 @@
install_lib: $(DOTNET_DLLS) install_headers install_dirs
cp `vpath_find $(DOTNET_DLLS)` $(INSTALL_MERC_LIB_DIR)
+#MS_ILASMFLAGS=/debug
+
else
.PHONY: install_headers
Index: runtime/mercury_mcpp.cpp
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_mcpp.cpp,v
retrieving revision 1.6
diff -u -r1.6 mercury_mcpp.cpp
--- runtime/mercury_mcpp.cpp 2001/07/31 10:08:02 1.6
+++ runtime/mercury_mcpp.cpp 2001/08/13 14:11:57
@@ -36,6 +36,38 @@
}
};
+__gc public class LowLevelData
+{
+
+public:
+ // Make a Mercury enumeration with the given integer value.
+static MR_Word make_enum(int enum_value) {
+
+ MR_Word e;
+ MR_newenum(e, enum_value);
+ return e;
+
+}
+
+ // Make an MR_Word with the given tag and arity.
+static MR_Word make_MR_Word(int tag, int arity) {
+ MR_Word e;
+ MR_newobj(e, tag, arity);
+ return e;
+
+}
+ // Set a field of an MR_Word with a given value.
+ // The first field is at index 1.
+static void set_MR_Word_field(MR_Word w, int index, System::Object *value) {
+ MR_objset(w, index, value);
+}
+ // Get the value from an MR_Word.
+ // The first field is at index 1.
+static System::Object * get_MR_Word_field(MR_Word w, int index) {
+ return w[index];
+}
+
+};
__gc public class Errors {
public:
--------------------------------------------------------------------------
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