2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / gmcs / sample-stack.il
1 .assembly sample-stack {}
2
3 .namespace Generics
4 {
5         .class interface public abstract Foo
6         {
7                 .method public virtual hidebysig newslot abstract instance default void Hello(class Generics.Stack<int32> stack)
8                 {
9                 }
10         }
11
12         .class public beforefieldinit Driver extends [mscorlib]System.Object
13         {
14                 .field static public class Generics.Stack<int32> int_stack
15                 .field static public class Generics.Stack<string> string_stack
16
17                 .method public hidebysig specialname rtspecialname instance default void .ctor()
18                 {
19                         ldarg.0
20                         call instance void valuetype [corlib]System.Object::.ctor()
21                         ret
22                 }
23
24                 .method public static void Init (class Generics.Foo foo)
25                 {
26                         newobj instance void class Generics.Stack<int32>::.ctor ()
27                         stsfld class Generics.Stack<int32> Generics.Driver::int_stack
28
29                         newobj instance void class Generics.Stack<string>::.ctor ()
30                         stsfld class Generics.Stack<string> Generics.Driver::string_stack
31
32                         ldarg.0
33                         ldsfld class Generics.Stack<int32> Generics.Driver::int_stack
34                         callvirt instance void class Generics.Foo::Hello(class Generics.Stack<int32>)
35
36                         ret
37                 }
38         }
39
40         .class public Stack<T> extends [mscorlib]System.Object
41         {
42                 .field private int32 size
43                 .field private !0[] data
44
45                 .method public instance void .ctor ()
46                 {
47                         ldarg.0
48                         call instance void [mscorlib]System.Object::.ctor ()
49                         ldarg.0
50                         ldc.i4.s 100
51                         newarr !0
52                         stfld !0[] class Generics.Stack<!0>::data
53                         ldarg.0
54                         ldc.i4.m1
55                         stfld int32 class Generics.Stack<!0>::size
56                         ret
57                 }
58
59                 .method public instance void Push (!0 item)
60                 {
61                         .locals init (int32 temp)
62
63                         ldarg.0
64                         ldfld !0[] class Generics.Stack<!0>::data
65                         ldarg.0
66                         dup
67
68                         ldfld int32 class Generics.Stack<!0>::size
69                         ldc.i4.1
70                         add
71                         dup
72                         stloc.0
73                         stfld int32 class Generics.Stack<!0>::size
74                         ldloc.0
75                         ldarg.1
76                         stelem !0
77                         ret
78                 }
79                    
80                 .method public instance !0 Pop ()
81                 {
82                         .locals init (!0, int32)
83
84                         ldarg.0
85                         ldfld !0[] class Generics.Stack<!0>::data
86                         ldarg.0
87                         dup
88
89                         ldfld int32 class Generics.Stack<!0>::size
90                         dup
91                         stloc.1
92                         ldc.i4.1
93                         sub
94                         stfld int32 class Generics.Stack<!0>::size
95                         ldloc.1
96                         ldelem !0
97                         stloc.0
98                         ldloc.0
99
100                         ret
101                 }
102         }
103 }