| | | 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 | | using System.Runtime.CompilerServices; |
| | | 5 | | |
| | | 6 | | namespace System.Reflection.Metadata.Ecma335 |
| | | 7 | | { |
| | | 8 | | internal static class ResolutionScopeTag |
| | | 9 | | { |
| | | 10 | | internal const int NumberOfBits = 2; |
| | | 11 | | internal const int LargeRowSize = 0x00000001 << (16 - NumberOfBits); |
| | | 12 | | internal const uint Module = 0x00000000; |
| | | 13 | | internal const uint ModuleRef = 0x00000001; |
| | | 14 | | internal const uint AssemblyRef = 0x00000002; |
| | | 15 | | internal const uint TypeRef = 0x00000003; |
| | | 16 | | internal const uint TagMask = 0x00000003; |
| | | 17 | | internal const uint TagToTokenTypeByteVector = TokenTypeIds.Module >> 24 | TokenTypeIds.ModuleRef >> 16 | TokenT |
| | | 18 | | internal const TableMask TablesReferenced = |
| | | 19 | | TableMask.Module |
| | | 20 | | | TableMask.ModuleRef |
| | | 21 | | | TableMask.AssemblyRef |
| | | 22 | | | TableMask.TypeRef; |
| | | 23 | | |
| | | 24 | | [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] |
| | | 25 | | internal static EntityHandle ConvertToHandle(uint resolutionScope) |
| | 0 | 26 | | { |
| | 0 | 27 | | uint tokenType = (TagToTokenTypeByteVector >> ((int)(resolutionScope & TagMask) << 3)) << TokenTypeIds.RowId |
| | 0 | 28 | | uint rowId = (resolutionScope >> NumberOfBits); |
| | | 29 | | |
| | 0 | 30 | | if ((rowId & ~TokenTypeIds.RIDMask) != 0) |
| | 0 | 31 | | { |
| | 0 | 32 | | Throw.InvalidCodedIndex(); |
| | | 33 | | } |
| | | 34 | | |
| | 0 | 35 | | return new EntityHandle(tokenType | rowId); |
| | 0 | 36 | | } |
| | | 37 | | } |
| | | 38 | | } |
| | | 39 | | |