2003-08-28 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Thu, 28 Aug 2003 02:11:46 +0000 (02:11 -0000)
committerMartin Baulig <martin@novell.com>
Thu, 28 Aug 2003 02:11:46 +0000 (02:11 -0000)
* sample-stack.il: Compile this with ilasm: "ilasm /dll
sample-stack.il".

* sample-hello.cs: Compile this with gmcs: "gmcs
/r:sample-stack.dll sample-hello.cs".

svn path=/trunk/mcs/; revision=17683

mcs/gmcs/ChangeLog
mcs/gmcs/sample-hello.cs [new file with mode: 0644]
mcs/gmcs/sample-stack.il [new file with mode: 0644]

index 3c6282e4e019cb60f9c2f7c2dbc0fefc43b23776..947bf7e6ec9331f5a935990816f163d441d3a680 100755 (executable)
@@ -1,3 +1,11 @@
+2003-08-28  Martin Baulig  <martin@ximian.com>
+
+       * sample-stack.il: Compile this with ilasm: "ilasm /dll
+       sample-stack.il".
+
+       * sample-hello.cs: Compile this with gmcs: "gmcs
+       /r:sample-stack.dll sample-hello.cs".
+
 2003-08-28  Martin Baulig  <martin@ximian.com>
 
        * generic.cs (ConstructedType.ResolveAsTypeStep): Actually bind
diff --git a/mcs/gmcs/sample-hello.cs b/mcs/gmcs/sample-hello.cs
new file mode 100644 (file)
index 0000000..8b4e27f
--- /dev/null
@@ -0,0 +1,21 @@
+using System;
+using Generics;
+
+namespace Test
+{
+       public class Bar : Foo
+       {
+               void Foo.Hello (Stack<int> stack)
+               {
+                       Console.WriteLine ("Hello Generic World!");
+                       Console.WriteLine (stack);
+                       Console.WriteLine (stack.GetType ());
+               }
+
+               public static void Main ()
+               {
+                       Foo foo = new Bar ();
+                       Driver.Init (foo);
+               }
+       }
+}
diff --git a/mcs/gmcs/sample-stack.il b/mcs/gmcs/sample-stack.il
new file mode 100644 (file)
index 0000000..e0fb904
--- /dev/null
@@ -0,0 +1,103 @@
+.assembly sample-stack {}
+
+.namespace Generics
+{
+       .class interface public abstract Foo
+       {
+               .method public virtual hidebysig newslot abstract instance default void Hello(class Generics.Stack<int32> stack)
+               {
+               }
+       }
+
+       .class public beforefieldinit Driver extends [mscorlib]System.Object
+       {
+               .field static public class Generics.Stack<int32> int_stack
+               .field static public class Generics.Stack<string> string_stack
+
+               .method public hidebysig specialname rtspecialname instance default void .ctor()
+               {
+                       ldarg.0
+                       call instance void valuetype [corlib]System.Object::.ctor()
+                       ret
+               }
+
+               .method public static void Init (class Generics.Foo foo)
+               {
+                       newobj instance void class Generics.Stack<int32>::.ctor ()
+                       stsfld class Generics.Stack<int32> Generics.Driver::int_stack
+
+                       newobj instance void class Generics.Stack<string>::.ctor ()
+                       stsfld class Generics.Stack<string> Generics.Driver::string_stack
+
+                       ldarg.0
+                       ldsfld class Generics.Stack<int32> Generics.Driver::int_stack
+                       callvirt instance void class Generics.Foo::Hello(class Generics.Stack<int32>)
+
+                       ret
+               }
+       }
+
+       .class public Stack<T> extends [mscorlib]System.Object
+       {
+               .field private int32 size
+               .field private !0[] data
+
+               .method public instance void .ctor ()
+               {
+                       ldarg.0
+                       call instance void [mscorlib]System.Object::.ctor ()
+                       ldarg.0
+                       ldc.i4.s 100
+                       newarr !0
+                       stfld !0[] class Generics.Stack<!0>::data
+                       ldarg.0
+                       ldc.i4.m1
+                       stfld int32 class Generics.Stack<!0>::size
+                       ret
+               }
+
+               .method public instance void Push (!0 item)
+               {
+                       .locals init (int32 temp)
+
+                       ldarg.0
+                       ldfld !0[] class Generics.Stack<!0>::data
+                       ldarg.0
+                       dup
+
+                       ldfld int32 class Generics.Stack<!0>::size
+                       ldc.i4.1
+                       add
+                       dup
+                       stloc.0
+                       stfld int32 class Generics.Stack<!0>::size
+                       ldloc.0
+                       ldarg.1
+                       stelem !0
+                       ret
+               }
+                  
+               .method public instance !0 Pop ()
+               {
+                       .locals init (!0, int32)
+
+                       ldarg.0
+                       ldfld !0[] class Generics.Stack<!0>::data
+                       ldarg.0
+                       dup
+
+                       ldfld int32 class Generics.Stack<!0>::size
+                       dup
+                       stloc.1
+                       ldc.i4.1
+                       sub
+                       stfld int32 class Generics.Stack<!0>::size
+                       ldloc.1
+                       ldelem !0
+                       stloc.0
+                       ldloc.0
+
+                       ret
+               }
+       }
+}