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

FunctionPointerType.Canon.cs « Canon « TypeSystem « Common « tools « coreclr « src - github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ce0f96f7990bda022a9ce571d70f9fe63bc29fa4 (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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Internal.TypeSystem
{
    // Holds code for canonicalizing a function pointer type
    public partial class FunctionPointerType
    {
        public override bool IsCanonicalSubtype(CanonicalFormKind policy)
        {
            if (_signature.ReturnType.IsCanonicalSubtype(policy))
                return true;

            for (int i = 0; i < _signature.Length; i++)
                if (_signature[i].IsCanonicalSubtype(policy))
                    return true;

            return false;
        }

        protected override TypeDesc ConvertToCanonFormImpl(CanonicalFormKind kind)
        {
            MethodSignatureBuilder sigBuilder = new MethodSignatureBuilder(_signature);
            sigBuilder.ReturnType = Context.ConvertToCanon(_signature.ReturnType, kind);
            for (int i = 0; i < _signature.Length; i++)
                sigBuilder[i] = Context.ConvertToCanon(_signature[i], kind);

            MethodSignature canonSignature = sigBuilder.ToSignature();
            if (canonSignature != _signature)
                return Context.GetFunctionPointerType(canonSignature);

            return this;
        }
    }
}