Exemplo n.º 1
0
        /// <summary>
        /// Creates an entity handle from a token value.
        /// </summary>
        /// <exception cref="ArgumentException"><paramref name="token"/> is not a valid metadata entity token.</exception>
        public static EntityHandle EntityHandle(int token)
        {
            if (!TokenTypeIds.IsEntityToken(unchecked ((uint)token)))
            {
                Throw.InvalidToken();
            }

            return(new EntityHandle((uint)token));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a handle from a token value.
        /// </summary>
        /// <exception cref="ArgumentException">
        /// <paramref name="token"/> is not a valid metadata token.
        /// It must encode a metadata table entity or an offset in <see cref="HandleKind.UserString"/> heap.
        /// </exception>
        public static Handle Handle(int token)
        {
            if (!TokenTypeIds.IsEntityOrUserStringToken(unchecked ((uint)token)))
            {
                Throw.InvalidToken();
            }

            return(Metadata.Handle.FromVToken((uint)token));
        }
            private DocumentHandle ReadDocumentHandle()
            {
                int rowId = _reader.ReadCompressedInteger();
                if (rowId == 0 || !TokenTypeIds.IsValidRowId(rowId))
                {
                    Throw.InvalidHandle();
                }

                return DocumentHandle.FromRowId(rowId);
            }
Exemplo n.º 4
0
        /// <summary>
        /// Creates an <see cref="Metadata.EntityHandle"/> from a token value.
        /// </summary>
        /// <exception cref="ArgumentException">
        /// <paramref name="tableIndex"/> is not a valid table index.</exception>
        public static EntityHandle Handle(TableIndex tableIndex, int rowNumber)
        {
            int token = ((int)tableIndex << TokenTypeIds.RowIdBitCount) | rowNumber;

            if (!TokenTypeIds.IsEntityOrUserStringToken(unchecked ((uint)token)))
            {
                Throw.TableIndexOutOfRange();
            }

            return(new EntityHandle((uint)token));
        }
Exemplo n.º 5
0
        // When reference has at most 24 bits.
        internal int PeekReference(int offset, bool smallRefSize)
        {
            if (smallRefSize)
            {
                return(PeekUInt16(offset));
            }

            uint value = PeekUInt32(offset);

            if (!TokenTypeIds.IsValidRowId(value))
            {
                Throw.ReferenceOverflow();
            }

            return((int)value);
        }
Exemplo n.º 6
0
        public void CompareTokens()
        {
            Assert.True(TokenTypeIds.CompareTokens(0x02000001, 0x02000002) < 0);
            Assert.True(TokenTypeIds.CompareTokens(0x02000002, 0x02000001) > 0);
            Assert.True(TokenTypeIds.CompareTokens(0x02000001, 0x02000001) == 0);

            // token type is ignored
            Assert.True(TokenTypeIds.CompareTokens(0x20000001, 0x21000002) < 0);

            // virtual tokens follow non-virtual:
            Assert.True(TokenTypeIds.CompareTokens(0x82000001, 0x02000002) > 0);
            Assert.True(TokenTypeIds.CompareTokens(0x02000002, 0x82000001) < 0);
            Assert.True(TokenTypeIds.CompareTokens(0x82000001, 0x82000001) == 0);

            // make sure we won't overflow for extreme values:
            Assert.True(TokenTypeIds.CompareTokens(0xffffffff, 0) > 0);
            Assert.True(TokenTypeIds.CompareTokens(0, 0xffffffff) < 0);
            Assert.True(TokenTypeIds.CompareTokens(0xfffffffe, 0xffffffff) < 0);
            Assert.True(TokenTypeIds.CompareTokens(0xffffffff, 0xfffffffe) > 0);
            Assert.True(TokenTypeIds.CompareTokens(0xffffffff, 0xffffffff) == 0);
        }
Exemplo n.º 7
0
 private MethodDebugInformationHandle(int rowId)
 {
     Debug.Assert(TokenTypeIds.IsValidRowId(rowId));
     _rowId = rowId;
 }
Exemplo n.º 8
0
 private DocumentHandle(int rowId)
 {
     Debug.Assert(TokenTypeIds.IsValidRowId(rowId));
     _rowId = rowId;
 }
Exemplo n.º 9
0
 public int Compare(Handle x, Handle y)
 {
     return(TokenTypeIds.CompareTokens(x.value, y.value));
 }
Exemplo n.º 10
0
 private ImportScopeHandle(int rowId)
 {
     Debug.Assert(TokenTypeIds.IsValidRowId(rowId));
     _rowId = rowId;
 }
Exemplo n.º 11
0
 private LocalConstantHandle(int rowId)
 {
     Debug.Assert(TokenTypeIds.IsValidRowId(rowId));
     _rowId = rowId;
 }
Exemplo n.º 12
0
 private LocalVariableHandle(int rowId)
 {
     Debug.Assert(TokenTypeIds.IsValidRowId(rowId));
     _rowId = rowId;
 }