Welcome to mirror list, hosted at ThFree Co, Russian Federation.

DynamicInvokeMethodThunk.Sorting.cs « Stubs « IL « TypeSystem « src « Common « src - github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d9c937f058558e2d6d691a55b26cb234084d97cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using Internal.TypeSystem;

using Debug = System.Diagnostics.Debug;

namespace Internal.IL.Stubs
{
    // Functionality related to determinstic ordering of types
    partial class DynamicInvokeMethodThunk
    {
        protected internal override int ClassCode => -1980933220;

        protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer)
        {
            return CompareTo((DynamicInvokeMethodThunk)other);
        }

        private int CompareTo(DynamicInvokeMethodThunk otherMethod)
        {
            int result = _targetSignature.Length - otherMethod._targetSignature.Length;
            if (result != 0)
                return result;

            DynamicInvokeMethodParameterKind thisReturnType = _targetSignature.ReturnType;
            result = (int)thisReturnType - (int)otherMethod._targetSignature.ReturnType;
            if (result != 0)
                return result;

            result = _targetSignature.GetNumerOfReturnTypePointerIndirections() - otherMethod._targetSignature.GetNumerOfReturnTypePointerIndirections();
            if (result != 0)
                return result;

            for (int i = 0; i < _targetSignature.Length; i++)
            {
                DynamicInvokeMethodParameterKind thisParamType = _targetSignature[i];
                result = (int)thisParamType - (int)otherMethod._targetSignature[i];
                if (result != 0)
                    return result;

                result = _targetSignature.GetNumberOfParameterPointerIndirections(i) - otherMethod._targetSignature.GetNumberOfParameterPointerIndirections(i);
                if (result != 0)
                    return result;
            }

            Debug.Assert(this == otherMethod);
            return 0;
        }

        partial class DynamicInvokeThunkGenericParameter
        {
            protected internal override int ClassCode => -234393261;

            protected internal override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer)
            {
                var otherType = (DynamicInvokeThunkGenericParameter)other;
                int result = Index - otherType.Index;
                if (result != 0)
                    return result;

                return _owningMethod.CompareTo(otherType._owningMethod);
            }
        }
    }
}