Pārlūkot izejas kodu

* PEAPI.cs: New GenericMethodSig class for creating generic method
signatures. Use this class instead of GenericTypeInst for creating
generic methods. Fix Generic call conv. according to two of my
docs it is 0x10 and only one says 0x50 so I will go with 0x10.

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

Jackson Harper 22 gadi atpakaļ
vecāks
revīzija
ab06036d9b
2 mainītis faili ar 43 papildinājumiem un 11 dzēšanām
  1. 7 0
      mcs/class/PEAPI/ChangeLog
  2. 36 11
      mcs/class/PEAPI/PEAPI.cs

+ 7 - 0
mcs/class/PEAPI/ChangeLog

@@ -1,3 +1,10 @@
+2003-10-10 Jackson Harper <[email protected]>
+
+	* PEAPI.cs: New GenericMethodSig class for creating generic method
+	signatures. Use this class instead of GenericTypeInst for creating
+	generic methods. Fix Generic call conv. according to two of my
+	docs it is 0x10 and only one says 0x50 so I will go with 0x10.
+	
 2003-10-09 Jackson Harper <[email protected]>
 
 	* PEAPI.cs: Add generic method Mvar type. Add MethodSpec table,

+ 36 - 11
mcs/class/PEAPI/PEAPI.cs

@@ -146,7 +146,32 @@ namespace PEAPI
                           param.TypeSig (str);
             }
   }
-
+
+  public class GenericMethodSig {
+
+          private Type[] gen_param;
+
+          public GenericMethodSig (Type[] gen_param)
+          {
+                  this.gen_param = gen_param;
+          }
+
+          internal void TypeSig (MemoryStream str)
+          {
+                  MetaData.CompressNum ((uint) gen_param.Length, str); // THIS IS NOT RIGHT, but works
+                  MetaData.CompressNum ((uint) gen_param.Length, str);
+                  foreach (Type param in gen_param)
+                          param.TypeSig (str);
+          }
+
+          internal uint GetSigIx (MetaData md)
+          {
+                  MemoryStream sig = new MemoryStream();
+                  TypeSig (sig);
+                  return md.AddToBlobHeap (sig.ToArray());
+          }
+  }
+
         public class Sentinel : Type {
 
             public Sentinel () : base (0x41) { }
@@ -505,7 +530,7 @@ namespace PEAPI
   /// Method call conventions
   /// </summary>
   public enum CallConv { Default, Cdecl, Stdcall, Thiscall, 
-    Fastcall, Vararg, Instance = 0x20, Generic = 0x50, InstanceExplicit = 0x60 }
+    Fastcall, Vararg, Instance = 0x20, Generic = 0x10, InstanceExplicit = 0x60 }
 
   /// <summary>
   /// Type custom modifier
@@ -4048,18 +4073,18 @@ if (rsrc != null)
         internal class MethodSpec : MetaDataElement
         {
                 Method meth;
-                GenericTypeInst type_inst;
-                uint meth_idx;
+                GenericMethodSig g_sig;
+                uint sidx;
 
-                internal MethodSpec (Method meth, GenericTypeInst type_inst) {
+                internal MethodSpec (Method meth, GenericMethodSig g_sig) {
                         this.meth = meth;
-                        this.type_inst = type_inst;
+                        this.g_sig = g_sig;
                         tabIx = MDTable.MethodSpec;
                 }
 
                 internal sealed override void BuildTables (MetaData md) {
                         if (done) return;
-                        meth_idx = meth.GetSigIx (md);
+                        sidx = g_sig.GetSigIx (md);
                         done = true;
                 }
 
@@ -4069,8 +4094,8 @@ if (rsrc != null)
                 }
 
                 internal sealed override void Write (FileImage output) {
-                    output.WriteCodedIndex(CIx.MethodDefOrRef, meth);
-                    output.BlobIndex (meth_idx);
+                    output.WriteCodedIndex (CIx.MethodDefOrRef, meth);
+                    output.BlobIndex (sidx);
                 }
         }
 
@@ -6033,9 +6058,9 @@ if (rsrc != null)
             return field;
     }
 
-    public void AddMethodSpec (Method m, GenericTypeInst type_inst)
+    public void AddMethodSpec (Method m, GenericMethodSig g_sig)
     {
-            MethodSpec ms = new MethodSpec (m, type_inst);
+            MethodSpec ms = new MethodSpec (m, g_sig);
             metaData.AddToTable (MDTable.MethodSpec, ms);
     }