* gen-extern-type.il: New. Test for ref to an external generic type.
authorAnkit Jain <radical@corewars.org>
Thu, 5 Jan 2006 10:06:52 +0000 (10:06 -0000)
committerAnkit Jain <radical@corewars.org>
Thu, 5 Jan 2006 10:06:52 +0000 (10:06 -0000)
* gen-array1.il, gen-array-2.il: New. Test for duplicate typespecs for
generic types and arrays of the same.
* gen-interf-1.il, gen-interf-2.il: New. Test for inheriting from a generic
base class and implementing generic interfaces.
* gen-struct.il: New. Test for generic valuetype.
* gen-local.il: New. No entry in the TypeSpec table should be emitted if a
generic type is referenced only as a local var.
* one.cs, two.cs: Updated to include types required the new tests.

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

mcs/ilasm/tests/ChangeLog
mcs/ilasm/tests/gen-array1.il [new file with mode: 0644]
mcs/ilasm/tests/gen-array2.il [new file with mode: 0644]
mcs/ilasm/tests/gen-extern-type.il [new file with mode: 0644]
mcs/ilasm/tests/gen-interf-1.il [new file with mode: 0644]
mcs/ilasm/tests/gen-interf-2.il [new file with mode: 0644]
mcs/ilasm/tests/gen-local.il [new file with mode: 0644]
mcs/ilasm/tests/gen-struct.il [new file with mode: 0644]
mcs/ilasm/tests/one.cs
mcs/ilasm/tests/two.cs

index 45d345077145086c5f9c20ad05ef7e860bf5c511..ca6809a26e8c328f818d5ab08286b1be2a6d5451 100644 (file)
@@ -1,3 +1,15 @@
+2006-01-05  Ankit Jain  <jankit@novell.com>
+
+       * gen-extern-type.il: New. Test for ref to an external generic type.
+       * gen-array1.il, gen-array-2.il: New. Test for duplicate typespecs for
+       generic types and arrays of the same.
+       * gen-interf-1.il, gen-interf-2.il: New. Test for inheriting from a generic
+       base class and implementing generic interfaces.
+       * gen-struct.il: New. Test for generic valuetype.
+       * gen-local.il: New. No entry in the TypeSpec table should be emitted if a
+       generic type is referenced only as a local var.
+       * one.cs, two.cs: Updated to include types required the new tests.
+
 2006-01-03  Ankit Jain  <jankit@novell.com>
 
        * gen-dotted-name.il: New. Test for dotted-name of a generic type.
diff --git a/mcs/ilasm/tests/gen-array1.il b/mcs/ilasm/tests/gen-array1.il
new file mode 100644 (file)
index 0000000..51dec68
--- /dev/null
@@ -0,0 +1,62 @@
+// Test that no duplicate TypeSpec entries are emitted 
+//
+// Multiple instaces of generic type class g<T>, with the same
+// argument (int32). Only one typespec should be emitted and shared by all these.
+
+.assembly extern mscorlib
+{
+  .ver 2:0:0:0
+}
+.assembly 'gen-array-1'
+{
+  .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() =  (
+               01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
+               63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01       ) // ceptionThrows.
+
+  .ver  0:0:0:0
+}
+.module arr.exe
+
+  .class private auto ansi beforefieldinit g`1<T>
+       extends [mscorlib]System.Object
+  {
+    .method public hidebysig  specialname  rtspecialname 
+           instance default void .ctor ()  cil managed 
+    {
+       .maxstack 8
+       IL_0000:  ldarg.0 
+       IL_0001:  call instance void object::.ctor()
+       IL_0006:  ret 
+    }
+  }
+
+  .class private auto ansi beforefieldinit test
+       extends [mscorlib]System.Object
+  {
+    .method public static  hidebysig 
+           default void Main ()  cil managed 
+    {
+       .entrypoint
+       .maxstack 3
+       .locals init (
+               /* Multiple generic instances with same argument */
+               class g`1<int32>[]      V_0,
+               class g`1<int32>[][]    V_1,
+               class g`1<int32>        V_2,
+               class g`1<int32>[]      V_3,
+               class g`1<class g`1<int32>>     V_4,
+               class g`1<class g`1<int32>>[]   V_5,
+               class g`1<class g`1<int32>>[][] V_6,
+               class g`1<class g`1<int32>[]>[][]       V_7,
+               class g`1<class g`1<int32>[][]>[][]     V_8)
+       IL_0000:  ldc.i4.s 0x36
+       IL_0002:  newarr class g`1<int32>
+       IL_0007:  stloc.0 
+       IL_0008:  ldloc.0 
+       IL_0009:  ldc.i4.0 
+       IL_000a:  newobj instance void class g`1<int32>::.ctor()
+       IL_000f:  stelem.ref 
+       IL_0010:  ret 
+    }
+
+  }
diff --git a/mcs/ilasm/tests/gen-array2.il b/mcs/ilasm/tests/gen-array2.il
new file mode 100644 (file)
index 0000000..4528bb0
--- /dev/null
@@ -0,0 +1,52 @@
+// Test that no duplicate TypeSpec entries are emitted 
+//
+// Multiple instaces of generic type class [one]gen<T> from an *external* assembly, with the same
+// argument (int32). Only one typespec should be emitted and shared by all these.
+
+.assembly extern mscorlib
+{
+  .ver 2:0:0:0
+}
+.assembly extern one
+{
+}
+.assembly 'gen-array2'
+{
+  .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() =  (
+               01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
+               63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01       ) // ceptionThrows.
+
+  .ver  0:0:0:0
+}
+.module arr.exe
+
+  .class private auto ansi beforefieldinit test
+       extends [mscorlib]System.Object
+  {
+    .method public static  hidebysig 
+           default void Main ()  cil managed 
+    {
+       .entrypoint
+       .maxstack 3
+       .locals init (
+               /* Multiple generic instances with same argument */
+               class [one]gen`1<int32>[]       V_0,
+               class [one]gen`1<int32>[][]     V_1,
+               class [one]gen`1<int32> V_2,
+               class [one]gen`1<int32>[]       V_3,
+               class [one]gen`1<class [one]gen`1<int32>>       V_4,
+               class [one]gen`1<class [one]gen`1<int32>>[]     V_5,
+               class [one]gen`1<class [one]gen`1<int32>>[][]   V_6,
+               class [one]gen`1<class [one]gen`1<int32>[]>[][] V_7,
+               class [one]gen`1<class [one]gen`1<int32>[][]>[][]       V_8)
+       IL_0000:  ldc.i4.s 0x36
+       IL_0002:  newarr class [one]gen`1<int32>
+       IL_0007:  stloc.0 
+       IL_0008:  ldloc.0 
+       IL_0009:  ldc.i4.0 
+       IL_000a:  newobj instance void class [one]gen`1<int32>::.ctor()
+       IL_000f:  stelem.ref 
+       IL_0010:  ret 
+    }
+
+  }
diff --git a/mcs/ilasm/tests/gen-extern-type.il b/mcs/ilasm/tests/gen-extern-type.il
new file mode 100644 (file)
index 0000000..215cb52
--- /dev/null
@@ -0,0 +1,51 @@
+// Test for Ref to external generic types\r
+\r
+.assembly extern mscorlib\r
+{\r
+  .ver 2:0:0:0\r
+}\r
+.assembly extern one\r
+{\r
+  .ver 0:0:0:0\r
+}\r
+.assembly 'gen-extern-type'\r
+{\r
+  .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78\r
+                                                                                                             63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 )\r
+  .ver 0:0:0:0\r
+}\r
+\r
+.module use.exe\r
+\r
+.class private auto ansi beforefieldinit test\r
+       extends [mscorlib]System.Object\r
+{\r
+  .method public hidebysig specialname rtspecialname \r
+          instance void  .ctor() cil managed\r
+  {\r
+    .maxstack  8\r
+    IL_0000:  ldarg.0\r
+    IL_0001:  call       instance void [mscorlib]System.Object::.ctor()\r
+    IL_0006:  ret\r
+  }\r
+\r
+  .method public hidebysig static void  Main() cil managed\r
+  {\r
+    .entrypoint\r
+    .maxstack  3\r
+    .locals init (class [one]ns.gen_m`1<int32>[] V_0)\r
+    IL_0000:  ldc.i4.5\r
+    IL_0001:  newarr     class [one]ns.gen_m`1<int32>\r
+    IL_0006:  stloc.0\r
+    IL_0007:  ldloc.0\r
+    IL_0008:  ldc.i4.0\r
+    IL_0009:  newobj     instance void class [one]ns.gen_m`1<int32>::.ctor()\r
+    IL_000e:  stelem.ref\r
+    IL_000f:  ldstr      "asd"\r
+    IL_0014:  call       void class [one]ns.gen_m`1<int32>::foo<string>(!!0)\r
+    IL_0019:  ldc.i4.5\r
+    IL_001a:  call       void class [one]ns.gen_m`1<int32>::foo<int32,string>(!!0)\r
+    IL_001f:  ret\r
+  }\r
+\r
+}\r
diff --git a/mcs/ilasm/tests/gen-interf-1.il b/mcs/ilasm/tests/gen-interf-1.il
new file mode 100644 (file)
index 0000000..29a3c1e
--- /dev/null
@@ -0,0 +1,49 @@
+// Test for : inheriting generic base class and implementing generic interfaces
+
+.assembly extern mscorlib
+{
+  .ver 2:0:0:0
+}
+.assembly 'gen-interf-1'
+{
+  .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() =  (
+               01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
+               63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01       ) // ceptionThrows.
+
+  .ver  0:0:0:0
+}
+.module interf.exe
+
+  .class interface private auto ansi abstract IGen`1<T>
+  {
+  }
+
+  .class interface private auto ansi abstract IFen`1<T>
+  {
+  }
+
+  .class interface private auto ansi abstract ISimple
+  {
+  }
+
+  .class private auto ansi beforefieldinit cbase`1<Z>
+       extends [mscorlib]System.Object
+  {
+    .method public hidebysig  specialname  rtspecialname 
+           instance default void .ctor ()  cil managed 
+    {
+       .locals init (class cbase`1<int32>[] c)
+       .maxstack 8
+       IL_0000:  ldarg.0 
+       IL_0001:  call instance void object::.ctor()
+       IL_0006:  ret 
+    }
+    
+   }
+
+  /* Inherits a generic base class and implements generic interfaces */
+  .class private auto ansi beforefieldinit gen_another`2<A,B>
+       extends class cbase`1<!1>
+       implements class IGen`1<!0>, class IFen`1<!1>, ISimple  {
+
+   }
diff --git a/mcs/ilasm/tests/gen-interf-2.il b/mcs/ilasm/tests/gen-interf-2.il
new file mode 100644 (file)
index 0000000..204e6ac
--- /dev/null
@@ -0,0 +1,30 @@
+// Test for : inheriting generic (external) base class and implementing (external) generic interfaces
+
+.assembly extern mscorlib
+{
+  .ver 2:0:0:0
+}
+.assembly extern one
+{
+}
+.assembly 'gen-interf-2'
+{
+  .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() =  (
+               01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
+               63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01       ) // ceptionThrows.
+
+  .ver  0:0:0:0
+}
+.module interf.exe
+
+
+  .class interface private auto ansi abstract ISimple
+  {
+
+  }
+
+  .class private auto ansi beforefieldinit gen_another`2<A,B>
+       extends class [one]gen`1<!0>
+       implements class [one]If1`1<!0>, class [one]If2`1<!1>, ISimple, [one]If3  {
+
+  }
diff --git a/mcs/ilasm/tests/gen-local.il b/mcs/ilasm/tests/gen-local.il
new file mode 100644 (file)
index 0000000..9fb0821
--- /dev/null
@@ -0,0 +1,49 @@
+// No entry in the TypeSpec table should be emitted for generic types (g<> and gen<>)
+// referenced in local var sig as it(GenericInst) is emitted the sig itself, and not a TypeSpec token
+
+.assembly extern mscorlib
+{
+  .ver 2:0:0:0
+}
+.assembly extern one
+{
+}
+
+.assembly 'gen-local'
+{
+  .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() =  (
+               01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
+               63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01       ) // ceptionThrows.
+
+  .ver  0:0:0:0
+}
+.module 'gen-local.exe'
+
+  .class private auto ansi beforefieldinit g`1<T>
+       extends [mscorlib]System.Object
+  {
+    .method public hidebysig  specialname  rtspecialname 
+           instance default void .ctor ()  cil managed 
+    {
+       .maxstack 8
+       IL_0000:  ldarg.0 
+       IL_0001:  call instance void object::.ctor()
+       IL_0006:  ret 
+    }
+  }
+
+  .class private auto ansi beforefieldinit test
+       extends [mscorlib]System.Object
+  {
+    .method public static  hidebysig 
+           default void Main ()  cil managed 
+    {
+       .entrypoint
+       .maxstack 3
+       .locals init (
+               class g`1<string> V_0,
+               class [one]gen`1<string> V_1)
+       IL_0010:  ret 
+    }
+
+  }
diff --git a/mcs/ilasm/tests/gen-struct.il b/mcs/ilasm/tests/gen-struct.il
new file mode 100644 (file)
index 0000000..de33fcb
--- /dev/null
@@ -0,0 +1,47 @@
+// Test for generic valuetypes
+
+.assembly extern mscorlib
+{
+  .ver 2:0:0:0
+}
+.assembly extern one
+{
+  .ver 0:0:0:0
+}
+.assembly 'gen-struct'
+{
+  .custom instance void class [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() =  (
+               01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
+               63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01       ) // ceptionThrows.
+
+  .ver  0:0:0:0
+}
+.module 'gen-struct.exe'
+
+  .class private auto ansi beforefieldinit test
+       extends [mscorlib]System.Object
+  {
+
+    .method public hidebysig  specialname  rtspecialname 
+           instance default void .ctor ()  cil managed 
+    {
+       .maxstack 8
+       IL_0000:  ldarg.0 
+       IL_0001:  call instance void object::.ctor()
+       IL_0006:  ret 
+    }
+
+    .method public static  hidebysig 
+           default void Main ()  cil managed 
+    {
+       .entrypoint
+       .maxstack 1
+       .locals init (
+               valuetype [one]gen_struct`1<string>     V_0)
+       IL_0000:  ldloca.s 0
+       IL_0002:  initobj valuetype [one]gen_struct`1<string>
+       IL_0008:  call void valuetype [one]gen_struct`1<int32>::foo()
+       IL_000d:  ret 
+    }
+
+  }
index 8a96733efc846333577f6f429c0fb37269c0247c..e0037294fd49b898df7e9eba922625bc11c619fe 100644 (file)
@@ -2,3 +2,38 @@ public class outer {
        public class inner {
        }
 }
+
+public class gen <T> {
+       public static void foo ()
+       {
+       }
+}
+
+namespace ns {
+       public class gen_m <T> {
+               public static void foo ()
+               {
+               }
+               public static void foo <A> (A _a)
+               {
+               }
+               public static void foo <A, B> (A _a)
+               {
+               }
+       }
+}
+
+public interface If1 <T> {
+}
+
+public interface If2 <T> {
+}
+
+public interface If3 {
+}
+       
+public struct gen_struct <T> {
+       public static void foo ()
+       {
+       }
+}
index 8a96733efc846333577f6f429c0fb37269c0247c..9f84911b76909a5f6066992be9b0acb1504732d6 100644 (file)
@@ -2,3 +2,6 @@ public class outer {
        public class inner {
        }
 }
+
+public class gen <T> {
+}