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

FieldDesc.cs « Common « TypeSystem « src « Common « src - github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e7478d7e7393398efe18a19e165816daef57ea4a (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// 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 System.Runtime.CompilerServices;

using Debug = System.Diagnostics.Debug;

namespace Internal.TypeSystem
{
    public abstract partial class FieldDesc
    {
        public readonly static FieldDesc[] EmptyFields = new FieldDesc[0];

        public override int GetHashCode()
        {
            // Inherited types are expected to override
            return RuntimeHelpers.GetHashCode(this);
        }

        public override bool Equals(Object o)
        {
            // Its only valid to compare two FieldDescs in the same context
            Debug.Assert(Object.ReferenceEquals(o, null) || !(o is FieldDesc) || Object.ReferenceEquals(((FieldDesc)o).Context, this.Context));
            return Object.ReferenceEquals(this, o);
        }

        public virtual string Name
        {
            get
            {
                return null;
            }
        }

        public abstract TypeSystemContext Context
        {
            get;
        }

        public abstract DefType OwningType
        {
            get;
        }

        public abstract TypeDesc FieldType
        {
            get;
        }

        public abstract bool IsStatic
        {
            get;
        }

        public abstract bool IsInitOnly
        {
            get;
        }

        public abstract bool IsThreadStatic
        {
            get;
        }

        public abstract bool HasRva
        {
            get;
        }

        public abstract bool IsLiteral
        {
            get;
        }

        public abstract bool HasCustomAttribute(string attributeNamespace, string attributeName);

        public virtual FieldDesc GetTypicalFieldDefinition()
        {
            return this;
        }

        public virtual FieldDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation)
        {
            FieldDesc field = this;

            TypeDesc owningType = field.OwningType;
            TypeDesc instantiatedOwningType = owningType.InstantiateSignature(typeInstantiation, methodInstantiation);
            if (owningType != instantiatedOwningType)
                field = instantiatedOwningType.Context.GetFieldForInstantiatedType(field.GetTypicalFieldDefinition(), (InstantiatedType)instantiatedOwningType);

            return field;
        }
    }
}