Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
MetadataTokens.cs
Go to the documentation of this file.
2
3public static class MetadataTokens
4{
5 public static readonly int TableCount = 64;
6
7 public static readonly int HeapCount = 4;
8
9 public static int GetRowNumber(this MetadataReader reader, EntityHandle handle)
10 {
11 if (handle.IsVirtual)
12 {
13 return MapVirtualHandleRowId(reader, handle);
14 }
15 return handle.RowId;
16 }
17
18 public static int GetHeapOffset(this MetadataReader reader, Handle handle)
19 {
20 if (!handle.IsHeapHandle)
21 {
23 }
24 if (handle.IsVirtual)
25 {
26 return MapVirtualHandleRowId(reader, handle);
27 }
28 return handle.Offset;
29 }
30
31 public static int GetToken(this MetadataReader reader, EntityHandle handle)
32 {
33 if (handle.IsVirtual)
34 {
35 return (int)handle.Type | MapVirtualHandleRowId(reader, handle);
36 }
37 return handle.Token;
38 }
39
40 public static int GetToken(this MetadataReader reader, Handle handle)
41 {
42 if (!handle.IsEntityOrUserStringHandle)
43 {
45 }
46 if (handle.IsVirtual)
47 {
48 return (int)handle.EntityHandleType | MapVirtualHandleRowId(reader, handle);
49 }
50 return handle.Token;
51 }
52
54 {
55 switch (handle.Kind)
56 {
57 case HandleKind.AssemblyReference:
58 return reader.AssemblyRefTable.NumberOfNonVirtualRows + 1 + handle.RowId;
59 case HandleKind.Blob:
60 case HandleKind.String:
62 default:
64 return 0;
65 }
66 }
67
68 public static int GetRowNumber(EntityHandle handle)
69 {
70 if (!handle.IsVirtual)
71 {
72 return handle.RowId;
73 }
74 return -1;
75 }
76
77 public static int GetHeapOffset(Handle handle)
78 {
79 if (!handle.IsHeapHandle)
80 {
82 }
83 if (handle.IsVirtual)
84 {
85 return -1;
86 }
87 return handle.Offset;
88 }
89
90 public static int GetHeapOffset(BlobHandle handle)
91 {
92 if (!handle.IsVirtual)
93 {
94 return handle.GetHeapOffset();
95 }
96 return -1;
97 }
98
99 public static int GetHeapOffset(GuidHandle handle)
100 {
101 return handle.Index;
102 }
103
105 {
106 return handle.GetHeapOffset();
107 }
108
110 {
111 if (!handle.IsVirtual)
112 {
113 return handle.GetHeapOffset();
114 }
115 return -1;
116 }
117
118 public static int GetToken(Handle handle)
119 {
120 if (!handle.IsEntityOrUserStringHandle)
121 {
123 }
124 if (handle.IsVirtual)
125 {
126 return 0;
127 }
128 return handle.Token;
129 }
130
131 public static int GetToken(EntityHandle handle)
132 {
133 if (!handle.IsVirtual)
134 {
135 return handle.Token;
136 }
137 return 0;
138 }
139
141 {
142 if ((int)type < TableCount && ((1L << (int)type) & 0xFF1FC9FFFFFFFFL) != 0L)
143 {
145 return true;
146 }
147 index = TableIndex.Module;
148 return false;
149 }
150
152 {
153 switch (type)
154 {
155 case HandleKind.UserString:
156 index = HeapIndex.UserString;
157 return true;
158 case HandleKind.String:
159 case HandleKind.NamespaceDefinition:
160 index = HeapIndex.String;
161 return true;
162 case HandleKind.Blob:
163 index = HeapIndex.Blob;
164 return true;
165 case HandleKind.Guid:
166 index = HeapIndex.Guid;
167 return true;
168 default:
169 index = HeapIndex.UserString;
170 return false;
171 }
172 }
173
174 public static Handle Handle(int token)
175 {
176 if (!TokenTypeIds.IsEntityOrUserStringToken((uint)token))
177 {
179 }
180 return System.Reflection.Metadata.Handle.FromVToken((uint)token);
181 }
182
183 public static EntityHandle EntityHandle(int token)
184 {
185 if (!TokenTypeIds.IsEntityToken((uint)token))
186 {
188 }
189 return new EntityHandle((uint)token);
190 }
191
192 public static EntityHandle EntityHandle(TableIndex tableIndex, int rowNumber)
193 {
194 return Handle(tableIndex, rowNumber);
195 }
196
197 public static EntityHandle Handle(TableIndex tableIndex, int rowNumber)
198 {
199 int vToken = (int)((uint)tableIndex << 24) | rowNumber;
200 if (!TokenTypeIds.IsEntityOrUserStringToken((uint)vToken))
201 {
203 }
204 return new EntityHandle((uint)vToken);
205 }
206
207 private static int ToRowId(int rowNumber)
208 {
209 return rowNumber & 0xFFFFFF;
210 }
211
213 {
215 }
216
221
226
227 public static TypeDefinitionHandle TypeDefinitionHandle(int rowNumber)
228 {
230 }
231
232 public static ExportedTypeHandle ExportedTypeHandle(int rowNumber)
233 {
235 }
236
237 public static TypeReferenceHandle TypeReferenceHandle(int rowNumber)
238 {
240 }
241
246
251
252 public static MemberReferenceHandle MemberReferenceHandle(int rowNumber)
253 {
255 }
256
257 public static FieldDefinitionHandle FieldDefinitionHandle(int rowNumber)
258 {
260 }
261
262 public static EventDefinitionHandle EventDefinitionHandle(int rowNumber)
263 {
265 }
266
271
276
277 public static ParameterHandle ParameterHandle(int rowNumber)
278 {
280 }
281
283 {
285 }
286
291
292 public static ModuleReferenceHandle ModuleReferenceHandle(int rowNumber)
293 {
295 }
296
301
302 public static CustomAttributeHandle CustomAttributeHandle(int rowNumber)
303 {
305 }
306
311
312 public static ConstantHandle ConstantHandle(int rowNumber)
313 {
315 }
316
318 {
320 }
321
322 public static AssemblyFileHandle AssemblyFileHandle(int rowNumber)
323 {
325 }
326
327 public static DocumentHandle DocumentHandle(int rowNumber)
328 {
330 }
331
336
337 public static LocalScopeHandle LocalScopeHandle(int rowNumber)
338 {
340 }
341
342 public static LocalVariableHandle LocalVariableHandle(int rowNumber)
343 {
345 }
346
347 public static LocalConstantHandle LocalConstantHandle(int rowNumber)
348 {
350 }
351
352 public static ImportScopeHandle ImportScopeHandle(int rowNumber)
353 {
355 }
356
361
366
371
372 public static BlobHandle BlobHandle(int offset)
373 {
375 }
376
377 public static GuidHandle GuidHandle(int offset)
378 {
380 }
381
386}
static TypeReferenceHandle TypeReferenceHandle(int rowNumber)
static TypeDefinitionHandle TypeDefinitionHandle(int rowNumber)
static int GetHeapOffset(this MetadataReader reader, Handle handle)
static MethodDebugInformationHandle MethodDebugInformationHandle(int rowNumber)
static int GetRowNumber(EntityHandle handle)
static GenericParameterHandle GenericParameterHandle(int rowNumber)
static DeclarativeSecurityAttributeHandle DeclarativeSecurityAttributeHandle(int rowNumber)
static LocalScopeHandle LocalScopeHandle(int rowNumber)
static MethodSpecificationHandle MethodSpecificationHandle(int rowNumber)
static FieldDefinitionHandle FieldDefinitionHandle(int rowNumber)
static ManifestResourceHandle ManifestResourceHandle(int rowNumber)
static CustomDebugInformationHandle CustomDebugInformationHandle(int rowNumber)
static EventDefinitionHandle EventDefinitionHandle(int rowNumber)
static InterfaceImplementationHandle InterfaceImplementationHandle(int rowNumber)
static int GetToken(this MetadataReader reader, EntityHandle handle)
static bool TryGetHeapIndex(HandleKind type, out HeapIndex index)
static AssemblyFileHandle AssemblyFileHandle(int rowNumber)
static CustomAttributeHandle CustomAttributeHandle(int rowNumber)
static int GetHeapOffset(UserStringHandle handle)
static StandaloneSignatureHandle StandaloneSignatureHandle(int rowNumber)
static ExportedTypeHandle ExportedTypeHandle(int rowNumber)
static MethodDefinitionHandle MethodDefinitionHandle(int rowNumber)
static ParameterHandle ParameterHandle(int rowNumber)
static ModuleReferenceHandle ModuleReferenceHandle(int rowNumber)
static EntityHandle Handle(TableIndex tableIndex, int rowNumber)
static int GetToken(this MetadataReader reader, Handle handle)
static DocumentNameBlobHandle DocumentNameBlobHandle(int offset)
static int GetRowNumber(this MetadataReader reader, EntityHandle handle)
static bool TryGetTableIndex(HandleKind type, out TableIndex index)
static int MapVirtualHandleRowId(MetadataReader reader, Handle handle)
static LocalConstantHandle LocalConstantHandle(int rowNumber)
static GenericParameterConstraintHandle GenericParameterConstraintHandle(int rowNumber)
static DocumentHandle DocumentHandle(int rowNumber)
static int GetHeapOffset(StringHandle handle)
static LocalVariableHandle LocalVariableHandle(int rowNumber)
static UserStringHandle UserStringHandle(int offset)
static ConstantHandle ConstantHandle(int rowNumber)
static ImportScopeHandle ImportScopeHandle(int rowNumber)
static TypeSpecificationHandle TypeSpecificationHandle(int rowNumber)
static EntityHandle EntityHandle(TableIndex tableIndex, int rowNumber)
static AssemblyReferenceHandle AssemblyReferenceHandle(int rowNumber)
static MemberReferenceHandle MemberReferenceHandle(int rowNumber)
static PropertyDefinitionHandle PropertyDefinitionHandle(int rowNumber)
static MethodImplementationHandle MethodImplementationHandle(int rowNumber)
static bool IsEntityOrUserStringToken(uint vToken)
static void TableIndexOutOfRange()
Definition Throw.cs:173
static Exception InvalidArgument_UnexpectedHandleKind(HandleKind kind)
Definition Throw.cs:33
static void InvalidToken()
Definition Throw.cs:103
static void EntityOrUserStringHandleRequired()
Definition Throw.cs:96
static void HeapHandleRequired()
Definition Throw.cs:89
static string CantGetOffsetForVirtualHeapHandle
Definition SR.cs:102
Definition SR.cs:7
static AssemblyFileHandle FromRowId(int rowId)
static AssemblyReferenceHandle FromRowId(int rowId)
static BlobHandle FromOffset(int heapOffset)
Definition BlobHandle.cs:34
static ConstantHandle FromRowId(int rowId)
static CustomAttributeHandle FromRowId(int rowId)
static CustomDebugInformationHandle FromRowId(int rowId)
static DocumentHandle FromRowId(int rowId)
static DocumentNameBlobHandle FromOffset(int heapOffset)
static EventDefinitionHandle FromRowId(int rowId)
static ExportedTypeHandle FromRowId(int rowId)
static FieldDefinitionHandle FromRowId(int rowId)
static GenericParameterHandle FromRowId(int rowId)
static GuidHandle FromIndex(int heapIndex)
Definition GuidHandle.cs:18
static Handle FromVToken(uint vToken)
Definition Handle.cs:52
static ImportScopeHandle FromRowId(int rowId)
static InterfaceImplementationHandle FromRowId(int rowId)
static LocalConstantHandle FromRowId(int rowId)
static LocalScopeHandle FromRowId(int rowId)
static LocalVariableHandle FromRowId(int rowId)
static ManifestResourceHandle FromRowId(int rowId)
static MemberReferenceHandle FromRowId(int rowId)
static MethodDebugInformationHandle FromRowId(int rowId)
static MethodDefinitionHandle FromRowId(int rowId)
static MethodImplementationHandle FromRowId(int rowId)
static MethodSpecificationHandle FromRowId(int rowId)
static ModuleReferenceHandle FromRowId(int rowId)
static ParameterHandle FromRowId(int rowId)
static PropertyDefinitionHandle FromRowId(int rowId)
static StandaloneSignatureHandle FromRowId(int rowId)
static StringHandle FromOffset(int heapOffset)
static TypeDefinitionHandle FromRowId(int rowId)
static TypeReferenceHandle FromRowId(int rowId)
static TypeSpecificationHandle FromRowId(int rowId)
static UserStringHandle FromOffset(int heapOffset)