/
field-access.il
79 lines (65 loc) · 1.22 KB
/
field-access.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
.assembly extern mscorlib {}
.assembly 'field-access' {}
.class public FieldFail extends [mscorlib]System.Object {
.field private static string _sfield
.field private string _field
.method public specialname rtspecialname instance void .ctor()
{
ldarg.0
call instance void [mscorlib]System.Object::.ctor()
ret
}
}
.class Test {
.method static void read_sfield ()
{
ldsfld string FieldFail::_sfield
pop
ret
}
.method static void read_field ()
{
.locals (FieldFail ff)
newobj instance void FieldFail::.ctor()
stloc ff
ldloc ff
ldfld string FieldFail::_field
pop
ret
}
.method static int32 Main ()
{
.entrypoint
.try {
call void Test::read_sfield ()
br fail
} catch [mscorlib]System.FieldAccessException {
pop
br continue
} catch [mscorlib]System.Exception {
pop
br fail
}
continue:
.try {
call void Test::read_field ()
br fail
} catch [mscorlib]System.FieldAccessException {
pop
br success
} catch [mscorlib]System.Exception {
pop
br fail
}
success:
ldstr "PASS"
call void [mscorlib]System.Console::WriteLine(string)
ldc.i4.0
ret
fail:
ldstr "FAIL"
call void [mscorlib]System.Console::WriteLine(string)
ldc.i4.1
ret
}
}