2 Based on this C#, which is based on MSDN.
4 public delegate void D();
10 public void Instance ()
12 System.Console.WriteLine("Instance {0}", i);
15 public static void Static ()
17 System.Console.WriteLine("Static {0}", 2);
20 public virtual void Virtual ()
22 System.Console.WriteLine("Virtual {0}", i + 2);
28 public static void Main()
31 var d1 = new D (b.Instance);
32 var d2 = new D (B.Static);
33 var d3 = new D (b.Virtual);
41 .assembly extern mscorlib { }
45 .class sealed public D
46 extends [mscorlib]System.MulticastDelegate
48 .method public void '.ctor' (object 'object', native int 'method') runtime { }
49 .method public virtual newslot instance void Invoke () runtime { }
50 .method public virtual newslot instance class [mscorlib]System.IAsyncResult BeginInvoke (class [mscorlib]System.AsyncCallback callback, object 'object') runtime { }
51 .method public virtual newslot instance void EndInvoke (class [mscorlib]System.IAsyncResult result) runtime { }
58 .method public instance void Instance ()
62 ldstr "B.Instance {0}"
65 box [mscorlib]System.Int32
66 call void class [mscorlib]System.Console::WriteLine(string, object)
70 .method public static void Static ()
76 box [mscorlib]System.Int32
77 call void class [mscorlib]System.Console::WriteLine(string, object)
81 .method public virtual newslot instance void Virtual1 ()
85 call void class [mscorlib]System.Console::WriteLine(string)
89 .method public virtual newslot instance void Virtual ()
98 box [mscorlib]System.Int32
99 call void class [mscorlib]System.Console::WriteLine(string, object)
103 .method public specialname rtspecialname instance void .ctor ()
111 call instance void object::.ctor()
120 .method public instance void Instance ()
124 ldstr "C.Instance {0}"
127 box [mscorlib]System.Int32
128 call void class [mscorlib]System.Console::WriteLine(string, object)
132 .method public static void Static ()
138 box [mscorlib]System.Int32
139 call void class [mscorlib]System.Console::WriteLine(string, object)
143 .method public virtual newslot instance void Virtual ()
147 ldstr "C.Virtual {0}"
152 box [mscorlib]System.Int32
153 call void class [mscorlib]System.Console::WriteLine(string, object)
157 .method public specialname rtspecialname instance void .ctor ()
165 call instance void object::.ctor()
173 .method public static void Main ()
184 // pad out locals to hit the assert
185 class C v00, class C v01, class C v02, class C v03, class C v04, class C v05, class C v06, class C v07,
186 class C v08, class C v09, class C v0A, class C v0B, class C v0C, class C v0D, class C v0E, class C v0F,
187 class C v10, class C v11, class C v12, class C v13, class C v14, class C v15, class C v16, class C v17,
188 class C v18, class C v19, class C v1A, class C v1B, class C v1C, class C v1D, class C v1E, class C v1F,
189 class C v20, class C v21, class C v22, class C v23, class C v24, class C v25, class C v26, class C v27
193 newobj instance void class B::'.ctor'()
197 newobj instance void class C::.ctor()
200 // d1 = new D (b, B::Instance)
202 ldftn instance void class B::Instance()
203 newobj instance void class D::.ctor(object, native int)
206 // d2 = new D (null, B::Static)
208 ldftn void class B::Static()
209 newobj instance void class D::.ctor(object, native int)
212 // d3 = new D (c, {c, B::Virtual}) but JIT sees b
214 dup // the dup the code is/was looking back for
217 // Let's put in 0x25 that isn't dup.
218 // And mess up the compile-time but not runtime stack.
219 // Mislead the JIT and there is a runtime crash.
225 ldvirtftn instance void class B::Virtual1()
226 newobj instance void class D::.ctor(object, native int)
231 callvirt instance void class D::Invoke()
235 callvirt instance void class D::Invoke()
239 callvirt instance void class D::Invoke()