예제 #1
0
        public UInt32          Index; // 1 to N, not 0 to N-1.

        public MetadataToken(MDTables.Tables table, UInt32 index)
        {
            System.Diagnostics.Contracts.Contract.Requires((index & 0xFF000000U) == 0);

            Table = table;
            Index = index;
        }
예제 #2
0
        public UInt32 Index;   // 1 to N, not 0 to N-1.

        public MetadataToken(MDTables.Tables table, UInt32 index)
        {
            System.Diagnostics.Contracts.Contract.Requires((index & 0xFF000000U) == 0);

            Table = table;
            Index = index;
        }
예제 #3
0
        private TypeInfo ParseTypeDefRefOrSpec(byte[] sig, ref uint i)
        {
            // The encoded version of this TypeRef token is made follows up:
            // 1. encode the table that this token the indexes least significant 2 bits.
            //    The bit values to use are 0, 1 and 2, specifying the target table is the
            //    TypeDef, TypeRef or TypeSpec table, respectively
            // 2. shift the 3-byte row index (0x000012 in this example) left by 2 bits
            //    and OR into the 2-bit encoding from step 1;
            // 3. compress the resulting value (see Section 22.2)
            uint compressed = DecodeInteger(sig, ref i);
            uint tableCode  = compressed & 0x3;
            uint index      = (uint)((compressed & (~0x3)) / 4);

            MDTables.Tables[] mapToTable = new MDTables.Tables[] { MDTables.Tables.TypeDef, MDTables.Tables.TypeRef, MDTables.Tables.TypeSpec };

            MetadataToken token = new MetadataToken(mapToTable[tableCode], index);

            switch (tableCode)
            {
            case 0:      // TypeDef
                return(new TypeInfo(token, _assembly));

            case 1:                                            // TypeRef
                return(new TypeInfo(token, _assembly, false)); // TypeRef-specific constructor.

            case 2:                                            // TypeSpec
                throw new NotImplementedException();

            default:
                throw new BadImageFormatException(Res.InvalidMetadataToken);
            }
        }