/
call_missing_method.il
98 lines (82 loc) · 2.19 KB
/
call_missing_method.il
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// CIL which breaks the ECMA-335 rules.
// this CIL should fail verification by a conforming CLI verifier.
.assembly 'call_missing_method_generated'
{
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.class public auto ansi beforefieldinit MissingMember extends [mscorlib]System.Object
{
.method public hidebysig specialname rtspecialname instance default void .ctor () cil managed
{
.maxstack 8
ldarg.0
call instance void object::.ctor()
ret
}
.method static private hidebysig void PrivateMethod () cil managed
{
.maxstack 8
ret
}
.field private int32 privateField
}
.class public auto ansi beforefieldinit Driver extends [mscorlib]System.Object
{
.method public hidebysig specialname rtspecialname instance default void .ctor () cil managed
{
.maxstack 8
ldarg.0
call instance void object::.ctor()
ret
}
.method public static void NoInline() cil managed
{
.maxstack 8
ret
}
.method public static void TestMethod() cil managed
{
.maxstack 8
call void Driver::NoInline()
call int32 MissingMember::Method()
leave END
END:
ret
}
.method public static int32 Main() cil managed
{
.entrypoint
.maxstack 8
.locals init ( class [mscorlib]System.Exception V_0, int32 V_1)
ldc.i4.0
stloc.1
.try {
call void Driver::TestMethod()
ldstr ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>call_missing_method did not throw an exception"
call void class [mscorlib]System.Console::WriteLine(string)
ldc.i4.1
stloc.1
leave END
}
catch [mscorlib]System.Exception {
stloc.0
ldloc.0
callvirt instance class [mscorlib]System.Type class [mscorlib]System.Exception::GetType()
ldtoken [mscorlib]System.MissingMethodException
call class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
beq ARE_EQUAL
ldstr ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>call_missing_method thrown {0} instead of System.MissingMethodException"
ldloc.0
callvirt instance class [mscorlib]System.Type class [mscorlib]System.Exception::GetType()
call void class [mscorlib]System.Console::WriteLine(string, object)
ldc.i4.1
stloc.1
ARE_EQUAL:
leave END
}
END:
ldloc.1
ret
}
}