Merge pull request #4033 from ntherning/no-stdcall-for-icalls-on-windows-32-bit
[mono.git] / mcs / class / PEAPI / Metadata.cs
index 5e33ca09a9b75f1989604391cf7763ba7afafc65..d9b17da6a81524be9855bd2ec80234b626f3bc3e 100644 (file)
@@ -94,6 +94,11 @@ namespace PEAPI {
                ForwardRef = 0x10, PreserveSig = 0x0080, InternalCall = 0x1000, 
                Synchronised = 0x0020, Synchronized = 0x0020, NoInLining = 0x0008, Optil = 0x0002}
 
+       /// <summary>
+       /// Storage location for initial field data
+       /// </summary>
+       public enum DataSegment { Data, TLS, CIL }
+
        /// <summary>
        /// Modes for a parameter
        /// </summary>
@@ -458,6 +463,12 @@ namespace PEAPI {
                        ms.WriteByte (1);
                        ms.WriteByte (0);
 
+                       if (c == null) {
+                               ms.WriteByte (0);
+                               ms.WriteByte (0);
+                               return ms.ToArray ();
+                       }
+
                        var sc = c as StringConst;
                        if (sc != null) {
                                string value = sc.val;
@@ -475,12 +486,21 @@ namespace PEAPI {
                        var ac = c as ArrayConstant;
                        if (ac != null) {
                                var bw = new BinaryWriter (ms);
-                               bw.Write (ac.ExplicitSize.Value);
+                               if (ac.ExplicitSize != null)
+                                       bw.Write (ac.ExplicitSize.Value);
                                ac.Write (bw);
                                bw.Write ((short)0);
                                return ms.ToArray ();
                        }
 
+                       var bc = c as DataConstant;
+                       if (bc != null) {
+                               var bw = new BinaryWriter (ms);
+                               bc.Write (bw);
+                               bw.Write ((short)0);
+                               return ms.ToArray ();
+                       }
+
                        throw new NotImplementedException (c.GetType ().ToString ());
                }
 
@@ -3149,7 +3169,7 @@ namespace PEAPI {
 
        }
 
-       public class UIntConst : Constant {
+       public class UIntConst : DataConstant {
                ulong val;
 
                public UIntConst(byte val) 
@@ -5331,12 +5351,20 @@ namespace PEAPI {
 
                                MDTable tabIx = (MDTable)i;
                                if (count > max5BitSmlIx) {
+                                       if (tabIx == MDTable.Method || tabIx == MDTable.Field || tabIx == MDTable.TypeRef ||
+                                               tabIx == MDTable.TypeDef || tabIx == MDTable.Param || tabIx == MDTable.InterfaceImpl ||
+                                               tabIx == MDTable.MemberRef || tabIx == MDTable.Module || tabIx == MDTable.DeclSecurity ||
+                                               tabIx == MDTable.Property || tabIx == MDTable.Event || tabIx == MDTable.StandAloneSig ||
+                                               tabIx == MDTable.ModuleRef || tabIx == MDTable.TypeSpec || tabIx == MDTable.Assembly ||
+                                               tabIx == MDTable.AssemblyRef || tabIx == MDTable.File || tabIx == MDTable.ExportedType ||
+                                               tabIx == MDTable.ManifestResource || tabIx == MDTable.GenericParam)
                                        lgeCIx[(int)CIx.HasCustomAttr] = true;
                                }
                                if (count > max3BitSmlIx) {
-                                       if ((tabIx == MDTable.TypeRef) || (tabIx == MDTable.ModuleRef) || (tabIx == MDTable.Method) || (tabIx == MDTable.TypeSpec) || (tabIx == MDTable.Field)) 
+                                       if (tabIx == MDTable.Method || tabIx == MDTable.MemberRef)
                                                lgeCIx[(int)CIx.CustomAttributeType] = true;
-                                       if ((tabIx == MDTable.Method) || (tabIx == MDTable.MemberRef)) 
+                                       if (tabIx == MDTable.TypeDef || tabIx == MDTable.TypeRef || tabIx == MDTable.ModuleRef ||
+                                               tabIx == MDTable.Method || tabIx == MDTable.TypeSpec)
                                                lgeCIx[(int)CIx.MemberRefParent] = true;
                                }
                                if (count > max2BitSmlIx) {