| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | namespace System.Reflection.Metadata.Ecma335 |
| | | 5 | | { |
| | | 6 | | public static class CodedIndex |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Calculates a HasCustomAttribute coded index for the specified handle. |
| | | 10 | | /// </summary> |
| | | 11 | | /// <param name="handle"> |
| | | 12 | | /// <see cref="MethodDefinitionHandle"/>, |
| | | 13 | | /// <see cref="FieldDefinitionHandle"/>, |
| | | 14 | | /// <see cref="TypeReferenceHandle"/>, |
| | | 15 | | /// <see cref="TypeDefinitionHandle"/>, |
| | | 16 | | /// <see cref="ParameterHandle"/>, |
| | | 17 | | /// <see cref="InterfaceImplementationHandle"/>, |
| | | 18 | | /// <see cref="MemberReferenceHandle"/>, |
| | | 19 | | /// <see cref="ModuleDefinitionHandle"/>, |
| | | 20 | | /// <see cref="DeclarativeSecurityAttributeHandle"/>, |
| | | 21 | | /// <see cref="PropertyDefinitionHandle"/>, |
| | | 22 | | /// <see cref="EventDefinitionHandle"/>, |
| | | 23 | | /// <see cref="StandaloneSignatureHandle"/>, |
| | | 24 | | /// <see cref="ModuleReferenceHandle"/>, |
| | | 25 | | /// <see cref="TypeSpecificationHandle"/>, |
| | | 26 | | /// <see cref="AssemblyDefinitionHandle"/>, |
| | | 27 | | /// <see cref="AssemblyReferenceHandle"/>, |
| | | 28 | | /// <see cref="AssemblyFileHandle"/>, |
| | | 29 | | /// <see cref="ExportedTypeHandle"/>, |
| | | 30 | | /// <see cref="ManifestResourceHandle"/>, |
| | | 31 | | /// <see cref="GenericParameterHandle"/>, |
| | | 32 | | /// <see cref="GenericParameterConstraintHandle"/> or |
| | | 33 | | /// <see cref="MethodSpecificationHandle"/>. |
| | | 34 | | /// </param> |
| | | 35 | | /// <exception cref="ArgumentException">Unexpected handle kind.</exception> |
| | 0 | 36 | | public static int HasCustomAttribute(EntityHandle handle) => (handle.RowId << (int)HasCustomAttributeTag.BitCoun |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Calculates a HasConstant coded index for the specified handle. |
| | | 40 | | /// </summary> |
| | | 41 | | /// <param name="handle"><see cref="ParameterHandle"/>, <see cref="FieldDefinitionHandle"/>, or <see cref="Prope |
| | | 42 | | /// <exception cref="ArgumentException">Unexpected handle kind.</exception> |
| | 0 | 43 | | public static int HasConstant(EntityHandle handle) => (handle.RowId << (int)HasConstantTag.BitCount) | (int)ToHa |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Calculates a CustomAttributeType coded index for the specified handle. |
| | | 47 | | /// </summary> |
| | | 48 | | /// <param name="handle"><see cref="MethodDefinitionHandle"/> or <see cref="MemberReferenceHandle"/></param> |
| | | 49 | | /// <exception cref="ArgumentException">Unexpected handle kind.</exception> |
| | 0 | 50 | | public static int CustomAttributeType(EntityHandle handle) => (handle.RowId << (int)CustomAttributeTypeTag.BitCo |
| | | 51 | | |
| | | 52 | | /// <summary> |
| | | 53 | | /// Calculates a HasDeclSecurity coded index for the specified handle. |
| | | 54 | | /// </summary> |
| | | 55 | | /// <param name="handle"><see cref="TypeDefinitionHandle"/>, <see cref="MethodDefinitionHandle"/>, or <see cref= |
| | | 56 | | /// <exception cref="ArgumentException">Unexpected handle kind.</exception> |
| | 0 | 57 | | public static int HasDeclSecurity(EntityHandle handle) => (handle.RowId << (int)HasDeclSecurityTag.BitCount) | ( |
| | | 58 | | |
| | | 59 | | /// <summary> |
| | | 60 | | /// Calculates a HasFieldMarshal coded index for the specified handle. |
| | | 61 | | /// </summary> |
| | | 62 | | /// <param name="handle"><see cref = "ParameterHandle" /> or <see cref="FieldDefinitionHandle"/></param> |
| | | 63 | | /// <exception cref="ArgumentException">Unexpected handle kind.</exception> |
| | 0 | 64 | | public static int HasFieldMarshal(EntityHandle handle) => (handle.RowId << (int)HasFieldMarshalTag.BitCount) | ( |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// Calculates a HasSemantics coded index for the specified handle. |
| | | 68 | | /// </summary> |
| | | 69 | | /// <param name="handle"><see cref="EventDefinitionHandle"/> or <see cref="PropertyDefinitionHandle"/></param> |
| | | 70 | | /// <exception cref="ArgumentException">Unexpected handle kind.</exception> |
| | 0 | 71 | | public static int HasSemantics(EntityHandle handle) => (handle.RowId << (int)HasSemanticsTag.BitCount) | (int)To |
| | | 72 | | |
| | | 73 | | /// <summary> |
| | | 74 | | /// Calculates a Implementation coded index for the specified handle. |
| | | 75 | | /// </summary> |
| | | 76 | | /// <param name="handle"><see cref="AssemblyFileHandle"/>, <see cref="ExportedTypeHandle"/> or <see cref="Assemb |
| | | 77 | | /// <exception cref="ArgumentException">Unexpected handle kind.</exception> |
| | 0 | 78 | | public static int Implementation(EntityHandle handle) => (handle.RowId << (int)ImplementationTag.BitCount) | (in |
| | | 79 | | |
| | | 80 | | /// <summary> |
| | | 81 | | /// Calculates a MemberForwarded coded index for the specified handle. |
| | | 82 | | /// </summary> |
| | | 83 | | /// <param name="handle"><see cref="FieldDefinition"/>, <see cref="MethodDefinition"/></param> |
| | | 84 | | /// <exception cref="ArgumentException">Unexpected handle kind.</exception> |
| | 0 | 85 | | public static int MemberForwarded(EntityHandle handle) => (handle.RowId << (int)MemberForwardedTag.BitCount) | ( |
| | | 86 | | |
| | | 87 | | /// <summary> |
| | | 88 | | /// Calculates a MemberRefParent coded index for the specified handle. |
| | | 89 | | /// </summary> |
| | | 90 | | /// <param name="handle"> |
| | | 91 | | /// <see cref="TypeDefinitionHandle"/>, |
| | | 92 | | /// <see cref="TypeReferenceHandle"/>, |
| | | 93 | | /// <see cref="ModuleReferenceHandle"/>, |
| | | 94 | | /// <see cref="MethodDefinitionHandle"/>, or |
| | | 95 | | /// <see cref="TypeSpecificationHandle"/>. |
| | | 96 | | /// </param> |
| | | 97 | | /// <exception cref="ArgumentException">Unexpected handle kind.</exception> |
| | 0 | 98 | | public static int MemberRefParent(EntityHandle handle) => (handle.RowId << (int)MemberRefParentTag.BitCount) | ( |
| | | 99 | | |
| | | 100 | | /// <summary> |
| | | 101 | | /// Calculates a MethodDefOrRef coded index for the specified handle. |
| | | 102 | | /// </summary> |
| | | 103 | | /// <param name="handle"><see cref="MethodDefinitionHandle"/> or <see cref="MemberReferenceHandle"/></param> |
| | | 104 | | /// <exception cref="ArgumentException">Unexpected handle kind.</exception> |
| | 0 | 105 | | public static int MethodDefOrRef(EntityHandle handle) => (handle.RowId << (int)MethodDefOrRefTag.BitCount) | (in |
| | | 106 | | |
| | | 107 | | /// <summary> |
| | | 108 | | /// Calculates a ResolutionScope coded index for the specified handle. |
| | | 109 | | /// </summary> |
| | | 110 | | /// <param name="handle"><see cref="ModuleDefinitionHandle"/>, <see cref="ModuleReferenceHandle"/>, <see cref="A |
| | | 111 | | /// <exception cref="ArgumentException">Unexpected handle kind.</exception> |
| | 0 | 112 | | public static int ResolutionScope(EntityHandle handle) => (handle.RowId << (int)ResolutionScopeTag.BitCount) | ( |
| | | 113 | | |
| | | 114 | | /// <summary> |
| | | 115 | | /// Calculates a TypeDefOrRef coded index for the specified handle. |
| | | 116 | | /// </summary> |
| | | 117 | | /// <param name="handle"><see cref="TypeDefinitionHandle"/> or <see cref="TypeReferenceHandle"/></param> |
| | | 118 | | /// <exception cref="ArgumentException">Unexpected handle kind.</exception> |
| | 0 | 119 | | public static int TypeDefOrRef(EntityHandle handle) => (handle.RowId << (int)TypeDefOrRefTag.BitCount) | (int)To |
| | | 120 | | |
| | | 121 | | /// <summary> |
| | | 122 | | /// Calculates a TypeDefOrRefOrSpec coded index for the specified handle. |
| | | 123 | | /// </summary> |
| | | 124 | | /// <param name="handle"><see cref="TypeDefinitionHandle"/>, <see cref="TypeReferenceHandle"/> or <see cref="Typ |
| | | 125 | | /// <exception cref="ArgumentException">Unexpected handle kind.</exception> |
| | 0 | 126 | | public static int TypeDefOrRefOrSpec(EntityHandle handle) => (handle.RowId << (int)TypeDefOrRefOrSpecTag.BitCoun |
| | | 127 | | |
| | | 128 | | /// <summary> |
| | | 129 | | /// Calculates a TypeOrMethodDef coded index for the specified handle. |
| | | 130 | | /// </summary> |
| | | 131 | | /// <param name="handle"><see cref="TypeDefinitionHandle"/> or <see cref="MethodDefinitionHandle"/></param> |
| | | 132 | | /// <exception cref="ArgumentException">Unexpected handle kind.</exception> |
| | 0 | 133 | | public static int TypeOrMethodDef(EntityHandle handle) => (handle.RowId << (int)TypeOrMethodDefTag.BitCount) | ( |
| | | 134 | | |
| | | 135 | | /// <summary> |
| | | 136 | | /// Calculates a HasCustomDebugInformation coded index for the specified handle. |
| | | 137 | | /// </summary> |
| | | 138 | | /// <param name="handle"> |
| | | 139 | | /// <see cref="MethodDefinitionHandle"/>, |
| | | 140 | | /// <see cref="FieldDefinitionHandle"/>, |
| | | 141 | | /// <see cref="TypeReferenceHandle"/>, |
| | | 142 | | /// <see cref="TypeDefinitionHandle"/>, |
| | | 143 | | /// <see cref="ParameterHandle"/>, |
| | | 144 | | /// <see cref="InterfaceImplementationHandle"/>, |
| | | 145 | | /// <see cref="MemberReferenceHandle"/>, |
| | | 146 | | /// <see cref="ModuleDefinitionHandle"/>, |
| | | 147 | | /// <see cref="DeclarativeSecurityAttributeHandle"/>, |
| | | 148 | | /// <see cref="PropertyDefinitionHandle"/>, |
| | | 149 | | /// <see cref="EventDefinitionHandle"/>, |
| | | 150 | | /// <see cref="StandaloneSignatureHandle"/>, |
| | | 151 | | /// <see cref="ModuleReferenceHandle"/>, |
| | | 152 | | /// <see cref="TypeSpecificationHandle"/>, |
| | | 153 | | /// <see cref="AssemblyDefinitionHandle"/>, |
| | | 154 | | /// <see cref="AssemblyReferenceHandle"/>, |
| | | 155 | | /// <see cref="AssemblyFileHandle"/>, |
| | | 156 | | /// <see cref="ExportedTypeHandle"/>, |
| | | 157 | | /// <see cref="ManifestResourceHandle"/>, |
| | | 158 | | /// <see cref="GenericParameterHandle"/>, |
| | | 159 | | /// <see cref="GenericParameterConstraintHandle"/>, |
| | | 160 | | /// <see cref="MethodSpecificationHandle"/>, |
| | | 161 | | /// <see cref="DocumentHandle"/>, |
| | | 162 | | /// <see cref="LocalScopeHandle"/>, |
| | | 163 | | /// <see cref="LocalVariableHandle"/>, |
| | | 164 | | /// <see cref="LocalConstantHandle"/> or |
| | | 165 | | /// <see cref="ImportScopeHandle"/>. |
| | | 166 | | /// </param> |
| | | 167 | | /// <exception cref="ArgumentException">Unexpected handle kind.</exception> |
| | 0 | 168 | | public static int HasCustomDebugInformation(EntityHandle handle) => (handle.RowId << (int)HasCustomDebugInformat |
| | | 169 | | |
| | | 170 | | private enum HasCustomAttributeTag |
| | | 171 | | { |
| | | 172 | | MethodDef = 0, |
| | | 173 | | Field = 1, |
| | | 174 | | TypeRef = 2, |
| | | 175 | | TypeDef = 3, |
| | | 176 | | Param = 4, |
| | | 177 | | InterfaceImpl = 5, |
| | | 178 | | MemberRef = 6, |
| | | 179 | | Module = 7, |
| | | 180 | | DeclSecurity = 8, |
| | | 181 | | Property = 9, |
| | | 182 | | Event = 10, |
| | | 183 | | StandAloneSig = 11, |
| | | 184 | | ModuleRef = 12, |
| | | 185 | | TypeSpec = 13, |
| | | 186 | | Assembly = 14, |
| | | 187 | | AssemblyRef = 15, |
| | | 188 | | File = 16, |
| | | 189 | | ExportedType = 17, |
| | | 190 | | ManifestResource = 18, |
| | | 191 | | GenericParam = 19, |
| | | 192 | | GenericParamConstraint = 20, |
| | | 193 | | MethodSpec = 21, |
| | | 194 | | |
| | | 195 | | BitCount = 5 |
| | | 196 | | } |
| | | 197 | | |
| | | 198 | | private static HasCustomAttributeTag ToHasCustomAttributeTag(HandleKind kind) |
| | 0 | 199 | | { |
| | 0 | 200 | | switch (kind) |
| | | 201 | | { |
| | 0 | 202 | | case HandleKind.MethodDefinition: return HasCustomAttributeTag.MethodDef; |
| | 0 | 203 | | case HandleKind.FieldDefinition: return HasCustomAttributeTag.Field; |
| | 0 | 204 | | case HandleKind.TypeReference: return HasCustomAttributeTag.TypeRef; |
| | 0 | 205 | | case HandleKind.TypeDefinition: return HasCustomAttributeTag.TypeDef; |
| | 0 | 206 | | case HandleKind.Parameter: return HasCustomAttributeTag.Param; |
| | 0 | 207 | | case HandleKind.InterfaceImplementation: return HasCustomAttributeTag.InterfaceImpl; |
| | 0 | 208 | | case HandleKind.MemberReference: return HasCustomAttributeTag.MemberRef; |
| | 0 | 209 | | case HandleKind.ModuleDefinition: return HasCustomAttributeTag.Module; |
| | 0 | 210 | | case HandleKind.DeclarativeSecurityAttribute: return HasCustomAttributeTag.DeclSecurity; |
| | 0 | 211 | | case HandleKind.PropertyDefinition: return HasCustomAttributeTag.Property; |
| | 0 | 212 | | case HandleKind.EventDefinition: return HasCustomAttributeTag.Event; |
| | 0 | 213 | | case HandleKind.StandaloneSignature: return HasCustomAttributeTag.StandAloneSig; |
| | 0 | 214 | | case HandleKind.ModuleReference: return HasCustomAttributeTag.ModuleRef; |
| | 0 | 215 | | case HandleKind.TypeSpecification: return HasCustomAttributeTag.TypeSpec; |
| | 0 | 216 | | case HandleKind.AssemblyDefinition: return HasCustomAttributeTag.Assembly; |
| | 0 | 217 | | case HandleKind.AssemblyReference: return HasCustomAttributeTag.AssemblyRef; |
| | 0 | 218 | | case HandleKind.AssemblyFile: return HasCustomAttributeTag.File; |
| | 0 | 219 | | case HandleKind.ExportedType: return HasCustomAttributeTag.ExportedType; |
| | 0 | 220 | | case HandleKind.ManifestResource: return HasCustomAttributeTag.ManifestResource; |
| | 0 | 221 | | case HandleKind.GenericParameter: return HasCustomAttributeTag.GenericParam; |
| | 0 | 222 | | case HandleKind.GenericParameterConstraint: return HasCustomAttributeTag.GenericParamConstraint; |
| | 0 | 223 | | case HandleKind.MethodSpecification: return HasCustomAttributeTag.MethodSpec; |
| | | 224 | | |
| | | 225 | | default: |
| | 0 | 226 | | Throw.InvalidArgument_UnexpectedHandleKind(kind); |
| | | 227 | | return 0; |
| | | 228 | | } |
| | 0 | 229 | | } |
| | | 230 | | |
| | | 231 | | private enum HasConstantTag |
| | | 232 | | { |
| | | 233 | | Field = 0, |
| | | 234 | | Param = 1, |
| | | 235 | | Property = 2, |
| | | 236 | | |
| | | 237 | | BitCount = 2 |
| | | 238 | | } |
| | | 239 | | |
| | | 240 | | private static HasConstantTag ToHasConstantTag(HandleKind kind) |
| | 0 | 241 | | { |
| | 0 | 242 | | switch (kind) |
| | | 243 | | { |
| | 0 | 244 | | case HandleKind.FieldDefinition: return HasConstantTag.Field; |
| | 0 | 245 | | case HandleKind.Parameter: return HasConstantTag.Param; |
| | 0 | 246 | | case HandleKind.PropertyDefinition: return HasConstantTag.Property; |
| | | 247 | | |
| | | 248 | | default: |
| | 0 | 249 | | Throw.InvalidArgument_UnexpectedHandleKind(kind); |
| | | 250 | | return 0; |
| | | 251 | | } |
| | 0 | 252 | | } |
| | | 253 | | |
| | | 254 | | private enum CustomAttributeTypeTag |
| | | 255 | | { |
| | | 256 | | MethodDef = 2, |
| | | 257 | | MemberRef = 3, |
| | | 258 | | |
| | | 259 | | BitCount = 3 |
| | | 260 | | } |
| | | 261 | | |
| | | 262 | | private static CustomAttributeTypeTag ToCustomAttributeTypeTag(HandleKind kind) |
| | 0 | 263 | | { |
| | 0 | 264 | | switch (kind) |
| | | 265 | | { |
| | 0 | 266 | | case HandleKind.MethodDefinition: return CustomAttributeTypeTag.MethodDef; |
| | 0 | 267 | | case HandleKind.MemberReference: return CustomAttributeTypeTag.MemberRef; |
| | | 268 | | |
| | | 269 | | default: |
| | 0 | 270 | | Throw.InvalidArgument_UnexpectedHandleKind(kind); |
| | | 271 | | return 0; |
| | | 272 | | } |
| | 0 | 273 | | } |
| | | 274 | | |
| | | 275 | | private enum HasDeclSecurityTag |
| | | 276 | | { |
| | | 277 | | TypeDef = 0, |
| | | 278 | | MethodDef = 1, |
| | | 279 | | Assembly = 2, |
| | | 280 | | |
| | | 281 | | BitCount = 2 |
| | | 282 | | } |
| | | 283 | | |
| | | 284 | | private static HasDeclSecurityTag ToHasDeclSecurityTag(HandleKind kind) |
| | 0 | 285 | | { |
| | 0 | 286 | | switch (kind) |
| | | 287 | | { |
| | 0 | 288 | | case HandleKind.TypeDefinition: return HasDeclSecurityTag.TypeDef; |
| | 0 | 289 | | case HandleKind.MethodDefinition: return HasDeclSecurityTag.MethodDef; |
| | 0 | 290 | | case HandleKind.AssemblyDefinition: return HasDeclSecurityTag.Assembly; |
| | | 291 | | |
| | | 292 | | default: |
| | 0 | 293 | | Throw.InvalidArgument_UnexpectedHandleKind(kind); |
| | | 294 | | return 0; |
| | | 295 | | } |
| | 0 | 296 | | } |
| | | 297 | | |
| | | 298 | | private enum HasFieldMarshalTag |
| | | 299 | | { |
| | | 300 | | Field = 0, |
| | | 301 | | Param = 1, |
| | | 302 | | |
| | | 303 | | BitCount = 1 |
| | | 304 | | } |
| | | 305 | | |
| | | 306 | | private static HasFieldMarshalTag ToHasFieldMarshalTag(HandleKind kind) |
| | 0 | 307 | | { |
| | 0 | 308 | | switch (kind) |
| | | 309 | | { |
| | 0 | 310 | | case HandleKind.FieldDefinition: return HasFieldMarshalTag.Field; |
| | 0 | 311 | | case HandleKind.Parameter: return HasFieldMarshalTag.Param; |
| | | 312 | | |
| | | 313 | | default: |
| | 0 | 314 | | Throw.InvalidArgument_UnexpectedHandleKind(kind); |
| | | 315 | | return 0; |
| | | 316 | | } |
| | 0 | 317 | | } |
| | | 318 | | |
| | | 319 | | private enum HasSemanticsTag |
| | | 320 | | { |
| | | 321 | | Event = 0, |
| | | 322 | | Property = 1, |
| | | 323 | | |
| | | 324 | | BitCount = 1 |
| | | 325 | | } |
| | | 326 | | |
| | | 327 | | private static HasSemanticsTag ToHasSemanticsTag(HandleKind kind) |
| | 0 | 328 | | { |
| | 0 | 329 | | switch (kind) |
| | | 330 | | { |
| | 0 | 331 | | case HandleKind.EventDefinition: return HasSemanticsTag.Event; |
| | 0 | 332 | | case HandleKind.PropertyDefinition: return HasSemanticsTag.Property; |
| | | 333 | | |
| | | 334 | | default: |
| | 0 | 335 | | Throw.InvalidArgument_UnexpectedHandleKind(kind); |
| | | 336 | | return 0; |
| | | 337 | | } |
| | 0 | 338 | | } |
| | | 339 | | |
| | | 340 | | private enum ImplementationTag |
| | | 341 | | { |
| | | 342 | | File = 0, |
| | | 343 | | AssemblyRef = 1, |
| | | 344 | | ExportedType = 2, |
| | | 345 | | |
| | | 346 | | BitCount = 2 |
| | | 347 | | } |
| | | 348 | | |
| | | 349 | | private static ImplementationTag ToImplementationTag(HandleKind kind) |
| | 0 | 350 | | { |
| | 0 | 351 | | switch (kind) |
| | | 352 | | { |
| | 0 | 353 | | case HandleKind.AssemblyFile: return ImplementationTag.File; |
| | 0 | 354 | | case HandleKind.AssemblyReference: return ImplementationTag.AssemblyRef; |
| | 0 | 355 | | case HandleKind.ExportedType: return ImplementationTag.ExportedType; |
| | | 356 | | |
| | | 357 | | default: |
| | 0 | 358 | | Throw.InvalidArgument_UnexpectedHandleKind(kind); |
| | | 359 | | return 0; |
| | | 360 | | } |
| | 0 | 361 | | } |
| | | 362 | | |
| | | 363 | | private enum MemberForwardedTag |
| | | 364 | | { |
| | | 365 | | Field = 0, |
| | | 366 | | MethodDef = 1, |
| | | 367 | | |
| | | 368 | | BitCount = 1 |
| | | 369 | | } |
| | | 370 | | |
| | | 371 | | private static MemberForwardedTag ToMemberForwardedTag(HandleKind kind) |
| | 0 | 372 | | { |
| | 0 | 373 | | switch (kind) |
| | | 374 | | { |
| | 0 | 375 | | case HandleKind.FieldDefinition: return MemberForwardedTag.Field; |
| | 0 | 376 | | case HandleKind.MethodDefinition: return MemberForwardedTag.MethodDef; |
| | | 377 | | |
| | | 378 | | default: |
| | 0 | 379 | | Throw.InvalidArgument_UnexpectedHandleKind(kind); |
| | | 380 | | return 0; |
| | | 381 | | } |
| | 0 | 382 | | } |
| | | 383 | | |
| | | 384 | | private enum MemberRefParentTag |
| | | 385 | | { |
| | | 386 | | TypeDef = 0, |
| | | 387 | | TypeRef = 1, |
| | | 388 | | ModuleRef = 2, |
| | | 389 | | MethodDef = 3, |
| | | 390 | | TypeSpec = 4, |
| | | 391 | | |
| | | 392 | | BitCount = 3 |
| | | 393 | | } |
| | | 394 | | |
| | | 395 | | private static MemberRefParentTag ToMemberRefParentTag(HandleKind kind) |
| | 0 | 396 | | { |
| | 0 | 397 | | switch (kind) |
| | | 398 | | { |
| | 0 | 399 | | case HandleKind.TypeDefinition: return MemberRefParentTag.TypeDef; |
| | 0 | 400 | | case HandleKind.TypeReference: return MemberRefParentTag.TypeRef; |
| | 0 | 401 | | case HandleKind.ModuleReference: return MemberRefParentTag.ModuleRef; |
| | 0 | 402 | | case HandleKind.MethodDefinition: return MemberRefParentTag.MethodDef; |
| | 0 | 403 | | case HandleKind.TypeSpecification: return MemberRefParentTag.TypeSpec; |
| | | 404 | | |
| | | 405 | | default: |
| | 0 | 406 | | Throw.InvalidArgument_UnexpectedHandleKind(kind); |
| | | 407 | | return 0; |
| | | 408 | | } |
| | 0 | 409 | | } |
| | | 410 | | |
| | | 411 | | private enum MethodDefOrRefTag |
| | | 412 | | { |
| | | 413 | | MethodDef = 0, |
| | | 414 | | MemberRef = 1, |
| | | 415 | | |
| | | 416 | | BitCount = 1 |
| | | 417 | | } |
| | | 418 | | |
| | | 419 | | private static MethodDefOrRefTag ToMethodDefOrRefTag(HandleKind kind) |
| | 0 | 420 | | { |
| | 0 | 421 | | switch (kind) |
| | | 422 | | { |
| | 0 | 423 | | case HandleKind.MethodDefinition: return MethodDefOrRefTag.MethodDef; |
| | 0 | 424 | | case HandleKind.MemberReference: return MethodDefOrRefTag.MemberRef; |
| | | 425 | | |
| | | 426 | | default: |
| | 0 | 427 | | Throw.InvalidArgument_UnexpectedHandleKind(kind); |
| | | 428 | | return 0; |
| | | 429 | | } |
| | 0 | 430 | | } |
| | | 431 | | |
| | | 432 | | private enum ResolutionScopeTag |
| | | 433 | | { |
| | | 434 | | Module = 0, |
| | | 435 | | ModuleRef = 1, |
| | | 436 | | AssemblyRef = 2, |
| | | 437 | | TypeRef = 3, |
| | | 438 | | |
| | | 439 | | BitCount = 2 |
| | | 440 | | } |
| | | 441 | | |
| | | 442 | | private static ResolutionScopeTag ToResolutionScopeTag(HandleKind kind) |
| | 0 | 443 | | { |
| | 0 | 444 | | switch (kind) |
| | | 445 | | { |
| | 0 | 446 | | case HandleKind.ModuleDefinition: return ResolutionScopeTag.Module; |
| | 0 | 447 | | case HandleKind.ModuleReference: return ResolutionScopeTag.ModuleRef; |
| | 0 | 448 | | case HandleKind.AssemblyReference: return ResolutionScopeTag.AssemblyRef; |
| | 0 | 449 | | case HandleKind.TypeReference: return ResolutionScopeTag.TypeRef; |
| | | 450 | | |
| | | 451 | | default: |
| | 0 | 452 | | Throw.InvalidArgument_UnexpectedHandleKind(kind); |
| | | 453 | | return 0; |
| | | 454 | | } |
| | 0 | 455 | | } |
| | | 456 | | |
| | | 457 | | private enum TypeDefOrRefOrSpecTag |
| | | 458 | | { |
| | | 459 | | TypeDef = 0, |
| | | 460 | | TypeRef = 1, |
| | | 461 | | TypeSpec = 2, |
| | | 462 | | |
| | | 463 | | BitCount = 2 |
| | | 464 | | } |
| | | 465 | | |
| | | 466 | | private static TypeDefOrRefOrSpecTag ToTypeDefOrRefOrSpecTag(HandleKind kind) |
| | 0 | 467 | | { |
| | 0 | 468 | | switch (kind) |
| | | 469 | | { |
| | 0 | 470 | | case HandleKind.TypeDefinition: return TypeDefOrRefOrSpecTag.TypeDef; |
| | 0 | 471 | | case HandleKind.TypeReference: return TypeDefOrRefOrSpecTag.TypeRef; |
| | 0 | 472 | | case HandleKind.TypeSpecification: return TypeDefOrRefOrSpecTag.TypeSpec; |
| | | 473 | | |
| | | 474 | | default: |
| | 0 | 475 | | Throw.InvalidArgument_UnexpectedHandleKind(kind); |
| | | 476 | | return 0; |
| | | 477 | | } |
| | 0 | 478 | | } |
| | | 479 | | |
| | | 480 | | private enum TypeDefOrRefTag |
| | | 481 | | { |
| | | 482 | | TypeDef = 0, |
| | | 483 | | TypeRef = 1, |
| | | 484 | | |
| | | 485 | | BitCount = 2 |
| | | 486 | | } |
| | | 487 | | |
| | | 488 | | private static TypeDefOrRefTag ToTypeDefOrRefTag(HandleKind kind) |
| | 0 | 489 | | { |
| | 0 | 490 | | switch (kind) |
| | | 491 | | { |
| | 0 | 492 | | case HandleKind.TypeDefinition: return TypeDefOrRefTag.TypeDef; |
| | 0 | 493 | | case HandleKind.TypeReference: return TypeDefOrRefTag.TypeRef; |
| | | 494 | | |
| | | 495 | | default: |
| | 0 | 496 | | Throw.InvalidArgument_UnexpectedHandleKind(kind); |
| | | 497 | | return 0; |
| | | 498 | | } |
| | 0 | 499 | | } |
| | | 500 | | |
| | | 501 | | private enum TypeOrMethodDefTag |
| | | 502 | | { |
| | | 503 | | TypeDef = 0, |
| | | 504 | | MethodDef = 1, |
| | | 505 | | |
| | | 506 | | BitCount = 1 |
| | | 507 | | } |
| | | 508 | | |
| | | 509 | | private static TypeOrMethodDefTag ToTypeOrMethodDefTag(HandleKind kind) |
| | 0 | 510 | | { |
| | 0 | 511 | | switch (kind) |
| | | 512 | | { |
| | 0 | 513 | | case HandleKind.TypeDefinition: return TypeOrMethodDefTag.TypeDef; |
| | 0 | 514 | | case HandleKind.MethodDefinition: return TypeOrMethodDefTag.MethodDef; |
| | | 515 | | |
| | | 516 | | default: |
| | 0 | 517 | | Throw.InvalidArgument_UnexpectedHandleKind(kind); |
| | | 518 | | return 0; |
| | | 519 | | } |
| | 0 | 520 | | } |
| | | 521 | | |
| | | 522 | | private enum HasCustomDebugInformationTag |
| | | 523 | | { |
| | | 524 | | MethodDef = 0, |
| | | 525 | | Field = 1, |
| | | 526 | | TypeRef = 2, |
| | | 527 | | TypeDef = 3, |
| | | 528 | | Param = 4, |
| | | 529 | | InterfaceImpl = 5, |
| | | 530 | | MemberRef = 6, |
| | | 531 | | Module = 7, |
| | | 532 | | DeclSecurity = 8, |
| | | 533 | | Property = 9, |
| | | 534 | | Event = 10, |
| | | 535 | | StandAloneSig = 11, |
| | | 536 | | ModuleRef = 12, |
| | | 537 | | TypeSpec = 13, |
| | | 538 | | Assembly = 14, |
| | | 539 | | AssemblyRef = 15, |
| | | 540 | | File = 16, |
| | | 541 | | ExportedType = 17, |
| | | 542 | | ManifestResource = 18, |
| | | 543 | | GenericParam = 19, |
| | | 544 | | GenericParamConstraint = 20, |
| | | 545 | | MethodSpec = 21, |
| | | 546 | | Document = 22, |
| | | 547 | | LocalScope = 23, |
| | | 548 | | LocalVariable = 24, |
| | | 549 | | LocalConstant = 25, |
| | | 550 | | ImportScope = 26, |
| | | 551 | | |
| | | 552 | | BitCount = 5 |
| | | 553 | | } |
| | | 554 | | |
| | | 555 | | private static HasCustomDebugInformationTag ToHasCustomDebugInformationTag(HandleKind kind) |
| | 0 | 556 | | { |
| | 0 | 557 | | switch (kind) |
| | | 558 | | { |
| | 0 | 559 | | case HandleKind.MethodDefinition: return HasCustomDebugInformationTag.MethodDef; |
| | 0 | 560 | | case HandleKind.FieldDefinition: return HasCustomDebugInformationTag.Field; |
| | 0 | 561 | | case HandleKind.TypeReference: return HasCustomDebugInformationTag.TypeRef; |
| | 0 | 562 | | case HandleKind.TypeDefinition: return HasCustomDebugInformationTag.TypeDef; |
| | 0 | 563 | | case HandleKind.Parameter: return HasCustomDebugInformationTag.Param; |
| | 0 | 564 | | case HandleKind.InterfaceImplementation: return HasCustomDebugInformationTag.InterfaceImpl; |
| | 0 | 565 | | case HandleKind.MemberReference: return HasCustomDebugInformationTag.MemberRef; |
| | 0 | 566 | | case HandleKind.ModuleDefinition: return HasCustomDebugInformationTag.Module; |
| | 0 | 567 | | case HandleKind.DeclarativeSecurityAttribute: return HasCustomDebugInformationTag.DeclSecurity; |
| | 0 | 568 | | case HandleKind.PropertyDefinition: return HasCustomDebugInformationTag.Property; |
| | 0 | 569 | | case HandleKind.EventDefinition: return HasCustomDebugInformationTag.Event; |
| | 0 | 570 | | case HandleKind.StandaloneSignature: return HasCustomDebugInformationTag.StandAloneSig; |
| | 0 | 571 | | case HandleKind.ModuleReference: return HasCustomDebugInformationTag.ModuleRef; |
| | 0 | 572 | | case HandleKind.TypeSpecification: return HasCustomDebugInformationTag.TypeSpec; |
| | 0 | 573 | | case HandleKind.AssemblyDefinition: return HasCustomDebugInformationTag.Assembly; |
| | 0 | 574 | | case HandleKind.AssemblyReference: return HasCustomDebugInformationTag.AssemblyRef; |
| | 0 | 575 | | case HandleKind.AssemblyFile: return HasCustomDebugInformationTag.File; |
| | 0 | 576 | | case HandleKind.ExportedType: return HasCustomDebugInformationTag.ExportedType; |
| | 0 | 577 | | case HandleKind.ManifestResource: return HasCustomDebugInformationTag.ManifestResource; |
| | 0 | 578 | | case HandleKind.GenericParameter: return HasCustomDebugInformationTag.GenericParam; |
| | 0 | 579 | | case HandleKind.GenericParameterConstraint: return HasCustomDebugInformationTag.GenericParamConstraint; |
| | 0 | 580 | | case HandleKind.MethodSpecification: return HasCustomDebugInformationTag.MethodSpec; |
| | 0 | 581 | | case HandleKind.Document: return HasCustomDebugInformationTag.Document; |
| | 0 | 582 | | case HandleKind.LocalScope: return HasCustomDebugInformationTag.LocalScope; |
| | 0 | 583 | | case HandleKind.LocalVariable: return HasCustomDebugInformationTag.LocalVariable; |
| | 0 | 584 | | case HandleKind.LocalConstant: return HasCustomDebugInformationTag.LocalConstant; |
| | 0 | 585 | | case HandleKind.ImportScope: return HasCustomDebugInformationTag.ImportScope; |
| | | 586 | | |
| | | 587 | | default: |
| | 0 | 588 | | Throw.InvalidArgument_UnexpectedHandleKind(kind); |
| | | 589 | | return 0; |
| | | 590 | | } |
| | 0 | 591 | | } |
| | | 592 | | } |
| | | 593 | | } |
| | | 594 | | |