blob: 4452e8d6ee7953c07cb712478579014e303032d5 (
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
|
// 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.Diagnostics;
namespace Internal.TypeSystem
{
// Api extensions for fields that allow keeping track of field layout
public partial class FieldDesc
{
private LayoutInt _offset = FieldAndOffset.InvalidOffset;
public LayoutInt Offset
{
get
{
if (_offset == FieldAndOffset.InvalidOffset)
{
if (IsStatic)
OwningType.ComputeStaticFieldLayout(StaticLayoutKind.StaticRegionSizesAndFields);
else
OwningType.ComputeInstanceLayout(InstanceLayoutKind.TypeAndFields);
// If the offset still wasn't computed, this must be a field that doesn't participate in layout
// (either literal or RVA mapped). We shouldn't be asking for the offset.
Debug.Assert(_offset != FieldAndOffset.InvalidOffset);
}
return _offset;
}
}
/// <summary>
/// For static fields, represents whether or not the field is held in the GC or non GC statics region.
/// </summary>
public bool HasGCStaticBase
{
get
{
Debug.Assert(IsStatic);
return Context.ComputeHasGCStaticBase(this);
}
}
internal void InitializeOffset(LayoutInt offset)
{
Debug.Assert(_offset == FieldAndOffset.InvalidOffset || _offset == offset);
_offset = offset;
}
}
}
|