diff --git a/library/array.m b/library/array.m index afa9186b9..b3ec45460 100644 --- a/library/array.m +++ b/library/array.m @@ -456,14 +456,14 @@ array__compare_elements(N, Size, Array1, Array2, Result) :- #endif "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", bounds_checks, [will_not_call_mercury, promise_pure, thread_safe], " #if ML_OMIT_ARRAY_BOUNDS_CHECKS - SUCCESS_INDICATOR = MR_FALSE; + SUCCESS_INDICATOR = false; #else - SUCCESS_INDICATOR = MR_TRUE; + SUCCESS_INDICATOR = true; #endif "). diff --git a/library/char.m b/library/char.m index 44958f039..415f8fd50 100644 --- a/library/char.m +++ b/library/char.m @@ -455,25 +455,25 @@ char__lower_upper('z', 'Z'). SUCCESS_INDICATOR = ((MR_UnsignedChar) Character == Int); "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", char__to_int(Character::in, Int::out), [will_not_call_mercury, promise_pure, thread_safe], " Int = Character; "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", char__to_int(Character::in, Int::in), [will_not_call_mercury, promise_pure, thread_safe], " SUCCESS_INDICATOR = (Character == Int); "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", char__to_int(Character::out, Int::in), [will_not_call_mercury, promise_pure, thread_safe], " - Character = Int; + Character = (char) Int; SUCCESS_INDICATOR = (Character == Int); "). diff --git a/library/exception.m b/library/exception.m index 7003aedba..63422a165 100644 --- a/library/exception.m +++ b/library/exception.m @@ -549,13 +549,13 @@ very_unsafe_perform_io(Goal, Result) :- :- impure pred make_io_state(io__state::uo) is det. :- pragma foreign_proc("C", make_io_state(_IO::uo), [will_not_call_mercury, thread_safe], ""). -:- pragma foreign_proc("MC++", make_io_state(_IO::uo), +:- pragma foreign_proc("C#", make_io_state(_IO::uo), [will_not_call_mercury, thread_safe], ""). :- impure pred consume_io_state(io__state::di) is det. :- pragma foreign_proc("C", consume_io_state(_IO::di), [will_not_call_mercury, thread_safe], ""). -:- pragma foreign_proc("MC++", consume_io_state(_IO::di), +:- pragma foreign_proc("C#", consume_io_state(_IO::di), [will_not_call_mercury, thread_safe], ""). :- pred wrap_exception(univ::in, exception_result(T)::out) is det. @@ -1186,17 +1186,16 @@ mercury__exception__builtin_catch_model_non(MR_Mercury_Type_Info type_info, % For the .NET backend we override throw_impl as it is easier to % implement these things using foreign_proc. -:- pragma foreign_decl("MC++", " +:- pragma foreign_decl("C#", " namespace mercury { namespace runtime { - __gc public class Exception : public System::Exception + public class Exception : System.Exception { - public: - Exception(MR_Univ data) + public Exception(object[] data) { mercury_exception = data; } - MR_Univ mercury_exception; + public object[] mercury_exception; }; } } diff --git a/library/float.m b/library/float.m index b912d0a42..10ba54203 100644 --- a/library/float.m +++ b/library/float.m @@ -257,14 +257,14 @@ X / Y = Z :- #endif "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", domain_checks, [thread_safe, promise_pure], " #if ML_OMIT_MATH_DOMAIN_CHECKS - SUCCESS_INDICATOR = MR_FALSE; + SUCCESS_INDICATOR = false; #else - SUCCESS_INDICATOR = MR_TRUE; + SUCCESS_INDICATOR = true; #endif "). diff --git a/library/int.m b/library/int.m index e512bbab0..57a3093bb 100644 --- a/library/int.m +++ b/library/int.m @@ -343,12 +343,12 @@ X rem Y = Rem :- #endif "). -:- pragma foreign_proc("MC++", domain_checks, +:- pragma foreign_proc("C#", domain_checks, [thread_safe, promise_pure], " #if ML_OMIT_MATH_DOMAIN_CHECKS - SUCCESS_INDICATOR = MR_FALSE; + SUCCESS_INDICATOR = false; #else - SUCCESS_INDICATOR = MR_TRUE; + SUCCESS_INDICATOR = true; #endif "). @@ -509,11 +509,11 @@ is(X, X). " FloatVal = IntVal; "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", int__to_float(IntVal::in, FloatVal::out), [will_not_call_mercury, promise_pure], " - FloatVal = (MR_Float) IntVal; + FloatVal = (double) IntVal; "). %-----------------------------------------------------------------------------% @@ -524,16 +524,6 @@ is(X, X). #define ML_BITS_PER_INT (sizeof(MR_Integer) * CHAR_BIT) "). -:- pragma foreign_decl("MC++", " - #include - - // XXX this should work, but it would be nice to have a more robust - // technique that used the fact we map to System.Int32 in the compiler. - - #define ML_BITS_PER_INT (sizeof(MR_Integer) * CHAR_BIT) - -"). - :- pragma foreign_proc("C", int__max_int(Max::out), [will_not_call_mercury, promise_pure, thread_safe], @@ -586,25 +576,26 @@ is(X, X). Rem = Int % ML_BITS_PER_INT; "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", int__max_int(Max::out), [will_not_call_mercury, promise_pure, thread_safe], " - Max = System::Int32::MaxValue; + Max = System.Int32.MaxValue; "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", int__min_int(Min::out), [will_not_call_mercury, promise_pure, thread_safe], " - Min = System::Int32::MinValue; + Min = System.Int32.MinValue; "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", int__bits_per_int(Bits::out), [will_not_call_mercury, promise_pure, thread_safe], " - Bits = ML_BITS_PER_INT; + // XXX we are using int32 in the compiler. + Bits = 32; "). int__quot_bits_per_int(Int::in) = (Result::out) :- diff --git a/library/math.m b/library/math.m index 90a27ad49..b307118b1 100644 --- a/library/math.m +++ b/library/math.m @@ -255,12 +255,12 @@ #endif "). -:- pragma foreign_proc("MC++", domain_checks, +:- pragma foreign_proc("C#", domain_checks, [thread_safe, promise_pure], " #if ML_OMIT_MATH_DOMAIN_CHECKS - SUCCESS_INDICATOR = MR_FALSE; + SUCCESS_INDICATOR = false; #else - SUCCESS_INDICATOR = MR_TRUE; + SUCCESS_INDICATOR = true; #endif "). diff --git a/library/private_builtin.m b/library/private_builtin.m index ce4a1c60f..23e5fe1f5 100644 --- a/library/private_builtin.m +++ b/library/private_builtin.m @@ -164,10 +164,10 @@ builtin_compare_string(R, S1, S2) :- [will_not_call_mercury, promise_pure, thread_safe], "Res = strcmp(S1, S2);"). -:- pragma foreign_proc("MC++", builtin_strcmp(Res::out, S1::in, S2::in), +:- pragma foreign_proc("C#", builtin_strcmp(Res::out, S1::in, S2::in), [will_not_call_mercury, promise_pure, thread_safe], " - Res = System::String::Compare(S1, S2); + Res = System.String.Compare(S1, S2); "). :- pragma foreign_proc("Java", builtin_strcmp(Res::out, S1::in, S2::in), [will_not_call_mercury, promise_pure, thread_safe], diff --git a/library/rtti_implementation.m b/library/rtti_implementation.m index 722350280..64134c24c 100644 --- a/library/rtti_implementation.m +++ b/library/rtti_implementation.m @@ -720,50 +720,50 @@ result_call_9(_::in, (=)::out, _::in, _::in, _::in, _::in, _::in, % We override the above definitions in the .NET backend. -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", semidet_call_3(Pred::in, X::in, Y::in), [will_not_call_mercury, promise_pure, thread_safe], " SUCCESS_INDICATOR = - mercury::runtime::GenericCall::semidet_call_3(Pred, X, Y); + mercury.runtime.GenericCall.semidet_call_3(Pred, X, Y); "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", semidet_call_4(Pred::in, A::in, X::in, Y::in), [will_not_call_mercury, promise_pure, thread_safe], " SUCCESS_INDICATOR = - mercury::runtime::GenericCall::semidet_call_4(Pred, A, X, Y); + mercury.runtime.GenericCall.semidet_call_4(Pred, A, X, Y); "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", semidet_call_5(Pred::in, A::in, B::in, X::in, Y::in), [will_not_call_mercury, promise_pure, thread_safe], " SUCCESS_INDICATOR = - mercury::runtime::GenericCall::semidet_call_5(Pred, A, B, X, Y); + mercury.runtime.GenericCall.semidet_call_5(Pred, A, B, X, Y); "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", semidet_call_6(Pred::in, A::in, B::in, C::in, X::in, Y::in), [will_not_call_mercury, promise_pure, thread_safe], " SUCCESS_INDICATOR = - mercury::runtime::GenericCall::semidet_call_6(Pred, A, B, C, + mercury.runtime.GenericCall.semidet_call_6(Pred, A, B, C, X, Y); "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", semidet_call_7(Pred::in, A::in, B::in, C::in, D::in, X::in, Y::in), [will_not_call_mercury, promise_pure, thread_safe], " SUCCESS_INDICATOR = - mercury::runtime::GenericCall::semidet_call_7(Pred, A, B, C, D, + mercury.runtime.GenericCall.semidet_call_7(Pred, A, B, C, D, X, Y); "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", semidet_call_8(Pred::in, A::in, B::in, C::in, D::in, E::in, X::in, Y::in), [will_not_call_mercury, promise_pure, thread_safe], " SUCCESS_INDICATOR = - mercury::runtime::GenericCall::semidet_call_8(Pred, A, B, C, D, + mercury.runtime.GenericCall.semidet_call_8(Pred, A, B, C, D, E, X, Y); "). @@ -1348,14 +1348,14 @@ get_arg(Term, Index, SecTagLocn, FunctorDesc, TypeInfo) = (Arg) :- :- pred high_level_data is semidet. :- pragma promise_pure(high_level_data/0). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", high_level_data, [will_not_call_mercury, thread_safe], " -#ifdef MR_HIGHLEVEL_DATA - SUCCESS_INDICATOR = MR_TRUE; +#if MR_HIGHLEVEL_DATA + SUCCESS_INDICATOR = true; #else - SUCCESS_INDICATOR = MR_FALSE; + SUCCESS_INDICATOR = false; #endif "). high_level_data :- @@ -1672,7 +1672,7 @@ get_type_ctor_info(_) = _ :- same_pointer_value(X, Y) :- same_pointer_value_untyped(X, Y). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", same_pointer_value_untyped(T1::in, T2::in), [will_not_call_mercury, promise_pure, thread_safe], " @@ -2245,11 +2245,11 @@ unsafe_make_enum(_) = _ :- " SUCCESS_INDICATOR = ((void *)S == NULL); "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", null(S::in), [will_not_call_mercury, thread_safe, promise_pure], " - SUCCESS_INDICATOR = (S == 0); + SUCCESS_INDICATOR = (S == null); "). null(_) :- % This version is only used for back-ends for which there is no @@ -2265,7 +2265,7 @@ null(_) :- " T = (MR_Word) NULL; "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", null = (T::out), [will_not_call_mercury, thread_safe, promise_pure], " diff --git a/library/std_util.m b/library/std_util.m index 97c107c00..e2b085d02 100644 --- a/library/std_util.m +++ b/library/std_util.m @@ -1115,15 +1115,15 @@ non_cc_call(P::pred(in, out, di, uo) is cc_multi, X::in, More::out, #endif }"). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", swap_heap_and_solutions_heap, [will_not_call_mercury, thread_safe], " - /* - ** For the .NET back-end, we use the system heap, rather - ** than defining our own heaps. So we don't need to - ** worry about swapping them. Hence do nothing here. - */ + // + // For the .NET back-end, we use the system heap, rather + // than defining our own heaps. So we don't need to + // worry about swapping them. Hence do nothing here. + // "). % @@ -1184,24 +1184,24 @@ non_cc_call(P::pred(in, out, di, uo) is cc_multi, X::in, More::out, MR_PARTIAL_DEEP_COPY(SolutionsHeapPtr, OldVal, NewVal, TypeInfo_for_T); "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", partial_deep_copy(_SolutionsHeapPtr::in, OldVal::in, NewVal::out), [will_not_call_mercury, thread_safe, promise_pure], " - /* - ** For the IL back-end, we don't do heap reclamation on failure, - ** so we don't need to worry about making deep copies here. - ** Shallow copies will suffice. - */ + // + // For the IL back-end, we don't do heap reclamation on failure, + // so we don't need to worry about making deep copies here. + // Shallow copies will suffice. + // NewVal = OldVal; "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", partial_deep_copy(_SolutionsHeapPtr::in, OldVal::mdi, NewVal::muo), [will_not_call_mercury, thread_safe, promise_pure], " NewVal = OldVal; "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", partial_deep_copy(_SolutionsHeapPtr::in, OldVal::di, NewVal::uo), [will_not_call_mercury, thread_safe, promise_pure], " @@ -1225,14 +1225,14 @@ non_cc_call(P::pred(in, out, di, uo) is cc_multi, X::in, More::out, #endif "). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", reset_solutions_heap(_SolutionsHeapPtr::in), [will_not_call_mercury, thread_safe], " - /* - ** For the IL back-end, we don't have a separate `solutions heap'. - ** Hence this operation is a NOP. - */ + // + // For the IL back-end, we don't have a separate `solutions heap'. + // Hence this operation is a NOP. + // "). %-----------------------------------------------------------------------------% @@ -1407,19 +1407,19 @@ unsorted_aggregate(Generator, Accumulator, Acc0, Acc) :- [will_not_call_mercury, thread_safe, promise_pure], "Y = X;"). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", semidet_succeed, [will_not_call_mercury, thread_safe, promise_pure], - "SUCCESS_INDICATOR = MR_TRUE;"). -:- pragma foreign_proc("MC++", + "SUCCESS_INDICATOR = true;"). +:- pragma foreign_proc("C#", semidet_fail, [will_not_call_mercury, thread_safe, promise_pure], - "SUCCESS_INDICATOR = MR_FALSE;"). -:- pragma foreign_proc("MC++", + "SUCCESS_INDICATOR = false;"). +:- pragma foreign_proc("C#", cc_multi_equal(X::in, Y::out), [will_not_call_mercury, thread_safe, promise_pure], "Y = X;"). -:- pragma foreign_proc("MC++", +:- pragma foreign_proc("C#", cc_multi_equal(X::di, Y::uo), [will_not_call_mercury, thread_safe, promise_pure], "Y = X;"). diff --git a/library/table_builtin.m b/library/table_builtin.m index 8d3f91a0b..243f2fefd 100644 --- a/library/table_builtin.m +++ b/library/table_builtin.m @@ -769,28 +769,6 @@ table_nondet_setup(_, _) :- :- external(table_nondet_suspend/2). :- external(table_nondet_resume/1). -/* - -XXX :- external stops us from using these two definitions - -:- pragma foreign_proc("MC++", - table_nondet_suspend(_A::in, _B::out), [will_not_call_mercury, promise_pure], - local_vars(""), - first_code(""), - retry_code(""), - common_code(" - mercury::runtime::Errors::SORRY( - 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(S""foreign code for this function""); -"). - -*/ - :- pragma foreign_proc("C", table_nondet_is_complete(Subgoal::in), [will_not_call_mercury],