зеркало из https://github.com/mono/mono.git
[interp] support ntype.CompareTo ()
This commit is contained in:
Родитель
a576a799b1
Коммит
13e412ee52
|
@ -248,6 +248,28 @@ public class BuiltinTests {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int test_0_nint_compareto ()
|
||||
{
|
||||
if (((nint) 0).CompareTo ((nint) 0) != 0)
|
||||
return 1;
|
||||
if (((nint) 0).CompareTo ((nint) 1) != -1)
|
||||
return 2;
|
||||
if (((nint) 1).CompareTo ((nint) 0) != 1)
|
||||
return 3;
|
||||
|
||||
if (((nint) 0).CompareTo ((object)(nint) 0) != 0)
|
||||
return 4;
|
||||
if (((nint) 0).CompareTo ((object)(nint) 1) != -1)
|
||||
return 5;
|
||||
if (((nint) 1).CompareTo ((object)(nint) 0) != 1)
|
||||
return 6;
|
||||
|
||||
if (((nint) 1).CompareTo (null) != 1)
|
||||
return 7;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// static int test_0_nint_call_boxed_equals ()
|
||||
// {
|
||||
// object x = new nint (10);
|
||||
|
@ -610,6 +632,28 @@ public class BuiltinTests {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int test_0_nuint_compareto ()
|
||||
{
|
||||
if (((nuint) 0).CompareTo ((nuint) 0) != 0)
|
||||
return 1;
|
||||
if (((nuint) 0).CompareTo ((nuint) 1) != -1)
|
||||
return 2;
|
||||
if (((nuint) 1).CompareTo ((nuint) 0) != 1)
|
||||
return 3;
|
||||
|
||||
if (((nuint) 0).CompareTo ((object)(nuint) 0) != 0)
|
||||
return 4;
|
||||
if (((nuint) 0).CompareTo ((object)(nuint) 1) != -1)
|
||||
return 5;
|
||||
if (((nuint) 1).CompareTo ((object)(nuint) 0) != 1)
|
||||
return 6;
|
||||
|
||||
if (((nuint) 1).CompareTo (null) != 1)
|
||||
return 7;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// static int test_0_nuint_call_boxed_equals ()
|
||||
// {
|
||||
// object x = new nuint (10);
|
||||
|
@ -965,6 +1009,28 @@ public class BuiltinTests {
|
|||
return nfloat.IsNaN (x) ? 0 : 1;
|
||||
}
|
||||
|
||||
static int test_0_nfloat_compareto ()
|
||||
{
|
||||
if (((nfloat) 0).CompareTo ((nfloat) 0) != 0)
|
||||
return 1;
|
||||
if (((nfloat) 0).CompareTo ((nfloat) 1) != -1)
|
||||
return 2;
|
||||
if (((nfloat) 1).CompareTo ((nfloat) 0) != 1)
|
||||
return 3;
|
||||
|
||||
if (((nfloat) 0).CompareTo ((object)(nfloat) 0) != 0)
|
||||
return 4;
|
||||
if (((nfloat) 0).CompareTo ((object)(nfloat) 1) != -1)
|
||||
return 5;
|
||||
if (((nfloat) 1).CompareTo ((object)(nfloat) 0) != 1)
|
||||
return 6;
|
||||
|
||||
if (((nfloat) 1).CompareTo (null) != 1)
|
||||
return 7;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// static int test_0_nfloat_call_boxed_equals ()
|
||||
// {
|
||||
// object x = new nfloat (10f);
|
||||
|
|
|
@ -1051,6 +1051,16 @@ interp_handle_intrinsics (TransformData *td, MonoMethod *target_method, MonoMeth
|
|||
SET_TYPE (td->sp - 1, stack_type [mt], magic_class);
|
||||
td->ip += 5;
|
||||
return TRUE;
|
||||
} else if (!strcmp ("CompareTo", tm)) {
|
||||
MonoType *arg = csignature->params [0];
|
||||
|
||||
/* on 'System.n*::CompareTo (System.n*)' variant we need to push managed
|
||||
* pointer instead of value */
|
||||
if (arg->type == MONO_TYPE_VALUETYPE)
|
||||
emit_store_value_as_local (td, arg);
|
||||
|
||||
/* emit call to managed conversion method */
|
||||
return FALSE;
|
||||
} else if (!strcmp (".cctor", tm)) {
|
||||
/* white list */
|
||||
return FALSE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче