Beispiel #1
0
        public MethodDesc GetMethod(Internal.Metadata.NativeFormat.Handle token)
        {
            MethodDesc method             = _metadataUnit.GetMethod(token, null);
            MethodDesc instantiatedMethod = method.InstantiateSignature(TypeInstantiation, MethodInstantiation);

            return(instantiatedMethod);
        }
Beispiel #2
0
        public FieldDesc GetField(Internal.Metadata.NativeFormat.Handle token)
        {
            FieldDesc field             = _metadataUnit.GetField(token, null);
            FieldDesc instantiatedField = field.InstantiateSignature(TypeInstantiation, MethodInstantiation);

            return(instantiatedField);
        }
Beispiel #3
0
        public TypeDesc GetType(Internal.Metadata.NativeFormat.Handle token)
        {
            TypeDesc type             = _metadataUnit.GetType(token);
            TypeDesc instantiatedType = type.InstantiateSignature(TypeInstantiation, MethodInstantiation);

            return(instantiatedType);
        }
Beispiel #4
0
        public RuntimeSignature GetSignature(Internal.Metadata.NativeFormat.Handle token)
        {
            switch (token.HandleType)
            {
            // These are the only valid token types for creating a method signature
            case Internal.Metadata.NativeFormat.HandleType.Method:
            case Internal.Metadata.NativeFormat.HandleType.MemberReference:
            case Internal.Metadata.NativeFormat.HandleType.QualifiedMethod:
            case Internal.Metadata.NativeFormat.HandleType.MethodInstantiation:
            case Internal.Metadata.NativeFormat.HandleType.MethodSignature:
                break;

            default:
                Environment.FailFast("Unknown and invalid handle type");
                break;
            }
            return(RuntimeSignature.CreateFromMethodHandle(_metadataUnit.RuntimeModule, token.ToInt()));
        }
        /// <summary>
        /// Build an array of GenericDictionaryCell from a NativeParser stream that has the appropriate metadata
        /// Return null if there are no cells to describe
        /// </summary>
        internal unsafe static GenericDictionaryCell[] BuildDictionaryFromMetadataTokensAndContext(TypeBuilder typeBuilder, NativeParser parser, NativeFormatMetadataUnit nativeMetadataUnit, FixupCellMetadataResolver resolver)
        {
            uint parserStartOffset = parser.Offset;

            uint count = parser.GetSequenceCount();

            // An empty dictionary isn't interesting
            if (count == 0)
                return null;

            Debug.Assert(count > 0);
            TypeLoaderLogger.WriteLine("Parsing dictionary layout @ " + parserStartOffset.LowLevelToString() + " (" + count.LowLevelToString() + " entries)");

            GenericDictionaryCell[] dictionary = new GenericDictionaryCell[count];

            for (uint i = 0; i < count; i++)
            {
                MetadataFixupKind fixupKind = (MetadataFixupKind)parser.GetUInt8();
                Internal.Metadata.NativeFormat.Handle token = parser.GetUnsigned().AsHandle();
                Internal.Metadata.NativeFormat.Handle token2 = new Internal.Metadata.NativeFormat.Handle();

                switch (fixupKind)
                {
                    case MetadataFixupKind.GenericConstrainedMethod:
                    case MetadataFixupKind.NonGenericConstrainedMethod:
                    case MetadataFixupKind.NonGenericDirectConstrainedMethod:
                        token2 = parser.GetUnsigned().AsHandle();
                        break;
                }
                GenericDictionaryCell cell = CreateCellFromFixupKindAndToken(fixupKind, resolver, token, token2);
                cell.Prepare(typeBuilder);
                dictionary[i] = cell;
            }

            return dictionary;
        }