Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PInvokeDelegateWrapperConstructor.cs « IL « Interop « TypeSystem « Common « tools « coreclr « src - github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2e138f6098c7fffbd2d15db3c52d5fdb972b9ee5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using Internal.IL;
using Internal.IL.Stubs;
using Debug = System.Diagnostics.Debug;
using System.Threading;

namespace Internal.TypeSystem.Interop
{
    /// <summary>
    /// Constructor for PInvokeDelegateWrapper which calls into the base class constructor
    /// </summary>
    public partial class PInvokeDelegateWrapperConstructor : ILStubMethod
    {
        public PInvokeDelegateWrapperConstructor(PInvokeDelegateWrapper owningType)
        {
            OwningType = owningType;
        }

        public override TypeDesc OwningType
        {
            get;
        }

        public override string Name
        {
            get
            {
                return ".ctor";
            }
        }

        public override string DiagnosticName
        {
            get
            {
                return ".ctor";
            }
        }

        private MethodSignature _signature;
        public override MethodSignature Signature
        {
            get
            {
                if (_signature == null)
                {
                    _signature = new MethodSignature(MethodSignatureFlags.None, 
                        genericParameterCount: 0,
                        returnType: Context.GetWellKnownType(WellKnownType.Void),
                        parameters: new TypeDesc[] {
                        Context.GetWellKnownType(WellKnownType.IntPtr)
                        });
                }
                return _signature;
            }
        }

        public override TypeSystemContext Context
        {
            get
            {
                return OwningType.Context;
            }
        }

        public override MethodIL EmitIL()
        {
            var emitter = new ILEmitter();
            ILCodeStream codeStream = emitter.NewCodeStream();
            codeStream.EmitLdArg(0);
            codeStream.EmitLdArg(1);
            codeStream.Emit(ILOpcode.call, emitter.NewToken(
                InteropTypes.GetNativeFunctionPointerWrapper(Context).GetMethod(".ctor", Signature)));
            codeStream.Emit(ILOpcode.ret);
            return emitter.Link(this);
        }
    }
}