コード例 #1
0
        private IExtractedEntity CreateGenericHandle(IGenericContext gc, Handle handle)
        {
            IExtractedEntity entity;

            switch (handle.Kind)
            {
            case HandleKind.MethodDefinition:
                entity = new DefinitionMethod(gc, (MethodDefinitionHandle)handle);
                break;

            case HandleKind.MemberReference:
                entity = Create(gc, (MemberReferenceHandle)handle);
                break;

            case HandleKind.MethodSpecification:
                entity = new MethodSpecificationMethod(gc, (MethodSpecificationHandle)handle);
                break;

            case HandleKind.FieldDefinition:
                entity = new DefinitionField(gc.Context, (FieldDefinitionHandle)handle);
                break;

            case HandleKind.TypeReference:
                var tr = new TypeReferenceType(this, (TypeReferenceHandle)handle);
                if (tr.TryGetPrimitiveType(out var pt))
                {
                    // Map special names like `System.Int32` to `int`
                    return(pt);
                }
                entity = tr;
                break;

            case HandleKind.TypeSpecification:
                return(Entities.Type.DecodeType(gc, (TypeSpecificationHandle)handle));

            case HandleKind.TypeDefinition:
                entity = new TypeDefinitionType(this, (TypeDefinitionHandle)handle);
                break;

            case HandleKind.StandaloneSignature:
                var signature = MdReader.GetStandaloneSignature((StandaloneSignatureHandle)handle);
                var method    = signature.DecodeMethodSignature(gc.Context.TypeSignatureDecoder, gc);
                entity = new FunctionPointerType(this, method);
                break;

            default:
                throw new InternalError("Unhandled handle kind " + handle.Kind);
            }

            Populate(entity);
            return(entity);
        }
コード例 #2
0
        IExtractedEntity CreateGenericHandle(GenericContext gc, Handle handle)
        {
            IExtractedEntity entity;

            switch (handle.Kind)
            {
            case HandleKind.MethodDefinition:
                entity = new DefinitionMethod(gc, (MethodDefinitionHandle)handle);
                break;

            case HandleKind.MemberReference:
                entity = Create(gc, (MemberReferenceHandle)handle);
                break;

            case HandleKind.MethodSpecification:
                entity = new MethodSpecificationMethod(gc, (MethodSpecificationHandle)handle);
                break;

            case HandleKind.FieldDefinition:
                entity = new DefinitionField(gc, (FieldDefinitionHandle)handle);
                break;

            case HandleKind.TypeReference:
                var tr = new TypeReferenceType(this, (TypeReferenceHandle)handle);
                if (tr.TryGetPrimitiveType(out var pt))
                {
                    // Map special names like `System.Int32` to `int`
                    return(pt);
                }
                entity = tr;
                break;

            case HandleKind.TypeSpecification:
                return(Entities.Type.DecodeType(gc, (TypeSpecificationHandle)handle));

            case HandleKind.TypeDefinition:
                entity = new TypeDefinitionType(this, (TypeDefinitionHandle)handle);
                break;

            default:
                throw new InternalError("Unhandled handle kind " + handle.Kind);
            }

            Populate(entity);
            return(entity);
        }