File: Compiler\CompilerTypeSystemContext.Sorting.cs
Web Access
Project: src\src\runtime\src\coreclr\tools\aot\ILCompiler.Compiler\ILCompiler.Compiler.csproj (ILCompiler.Compiler)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Internal.TypeSystem;

namespace ILCompiler
{
    // Functionality related to deterministic ordering of types and members
    public partial class CompilerTypeSystemContext
    {
        private partial class BoxedValueType
        {
            protected override int ClassCode => 1062019524;

            protected override int CompareToImpl(TypeDesc other, TypeSystemComparer comparer)
            {
                return comparer.Compare(ValueTypeRepresented, ((BoxedValueType)other).ValueTypeRepresented);
            }
        }

        private partial class GenericUnboxingThunk
        {
            protected override int ClassCode => -247515475;

            protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer)
            {
                var otherMethod = (GenericUnboxingThunk)other;
                return comparer.Compare(_targetMethod, otherMethod._targetMethod);
            }
        }

        private partial class UnboxingThunk
        {
            protected override int ClassCode => 446545583;

            protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer)
            {
                var otherMethod = (UnboxingThunk)other;
                return comparer.Compare(_targetMethod, otherMethod._targetMethod);
            }
        }

        private partial class DefaultInterfaceMethodImplementationInstantiationThunk
        {
            protected override int ClassCode => -789598;

            protected override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer)
            {
                var otherMethod = (DefaultInterfaceMethodImplementationInstantiationThunk)other;

                int result = System.Collections.Generic.Comparer<int>.Default.Compare(_interfaceIndex, otherMethod._interfaceIndex);
                if (result != 0)
                    return result;

                return comparer.Compare(_targetMethod, otherMethod._targetMethod);
            }
        }
    }
}