forked from anydream/il2cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFieldX.cs
More file actions
81 lines (66 loc) · 1.63 KB
/
FieldX.cs
File metadata and controls
81 lines (66 loc) · 1.63 KB
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
using System.Diagnostics;
using System.Text;
using dnlib.DotNet;
namespace il2cpp
{
internal class FieldX
{
// 所属类型
public readonly TypeX DeclType;
// 字段定义
public readonly FieldDef Def;
// 唯一名称
private string NameKey;
// 定义顺序
private int DefOrder = -1;
// 字段类型
public TypeSig FieldType;
// 生成的字段名称
public string GeneratedFieldName;
// 是否需要生成元数据
public bool NeedGenMetadata;
public bool GenMetadata => NeedGenMetadata || DeclType.NeedGenMetadata;
public bool IsStatic => Def.IsStatic;
public bool IsInstance => Helper.IsInstanceField(Def);
public FieldX(TypeX declType, FieldDef fldDef)
{
Debug.Assert(declType != null);
Debug.Assert(fldDef.DeclaringType == declType.Def);
DeclType = declType;
Def = fldDef;
}
public override string ToString()
{
return DeclType + " -> " + NameKey;
}
public string GetNameKey()
{
if (NameKey == null)
{
// Name|FieldType
StringBuilder sb = new StringBuilder();
Helper.FieldNameKey(sb, Def.Name, Def.FieldType);
NameKey = sb.ToString();
}
return NameKey;
}
public string GetReplacedNameKey()
{
Debug.Assert(FieldType != null);
StringBuilder sb = new StringBuilder();
Helper.FieldNameKey(sb, Def.Name, FieldType);
return sb.ToString();
}
public int GetDefOrder()
{
Debug.Assert(IsInstance);
if (DefOrder == -1)
DeclType.CalcFieldsOrder();
return DefOrder;
}
internal void SetDefOrder(int order)
{
DefOrder = order;
}
}
}