2007-12-06 Jb Evain <jbevain@novell.com>
[mono.git] / mono / tests / field-access.il
blob929303995c4e0f1a19fc3facc023de924c221f12
1 .assembly extern mscorlib {}
3 .assembly 'field-access' {}
5 .class public FieldFail extends [mscorlib]System.Object {
7         .field private static string _sfield
9         .field private string _field
11         .method public specialname rtspecialname instance void  .ctor()
12         {
13                 ldarg.0
14                 call       instance void [mscorlib]System.Object::.ctor()
15                 ret
16         }
19 .class Test {
21         .method static void read_sfield ()
22         {
23                 ldsfld string FieldFail::_sfield
24                 pop
25                 ret
26         }
28         .method static void read_field ()
29         {
30                 .locals (FieldFail ff)
32                 newobj instance void FieldFail::.ctor()
33                 stloc ff
34                 ldloc ff
35                 ldfld string FieldFail::_field
36                 pop
37                 ret
38         }
40         .method static int32 Main ()
41         {
42                 .entrypoint
44                 .try {
45                         call void Test::read_sfield ()
46                         br fail
47                 } catch [mscorlib]System.FieldAccessException {
48                         pop
49                         br continue
50                 } catch [mscorlib]System.Exception {
51                         pop
52                         br fail
53                 }
55 continue:
56                 .try {
57                         call void Test::read_field ()
58                         br fail
59                 } catch [mscorlib]System.FieldAccessException {
60                         pop
61                         br success
62                 } catch [mscorlib]System.Exception {
63                         pop
64                         br fail
65                 }
66                 
67 success:
68                 ldstr "PASS"
69                 call void [mscorlib]System.Console::WriteLine(string)
70                 ldc.i4.0
71                 ret
73 fail:
74                 ldstr "FAIL"
75                 call void [mscorlib]System.Console::WriteLine(string)
76                 ldc.i4.1
77                 ret
78         }