[Mono.Debugger.Soft] Reverted non-working support for MethodMirror.IsGenericMethod...
[mono.git] / mcs / class / IKVM.Reflection / FieldSignature.cs
index 0a4ff94a29e03c0dced8e08c932b12352cfa853c..481fc6158917599d273c3658f9258df5d5bb9695 100644 (file)
@@ -34,19 +34,17 @@ namespace IKVM.Reflection
        sealed class FieldSignature : Signature
        {
                private readonly Type fieldType;
-               private readonly Type[] optionalCustomModifiers;
-               private readonly Type[] requiredCustomModifiers;
+               private readonly CustomModifiers mods;
 
-               internal static FieldSignature Create(Type fieldType, Type[] optionalCustomModifiers, Type[] requiredCustomModifiers)
+               internal static FieldSignature Create(Type fieldType, CustomModifiers customModifiers)
                {
-                       return new FieldSignature(fieldType, Util.Copy(optionalCustomModifiers), Util.Copy(requiredCustomModifiers));
+                       return new FieldSignature(fieldType, customModifiers);
                }
 
-               private FieldSignature(Type fieldType, Type[] optionalCustomModifiers, Type[] requiredCustomModifiers)
+               private FieldSignature(Type fieldType, CustomModifiers mods)
                {
                        this.fieldType = fieldType;
-                       this.optionalCustomModifiers = optionalCustomModifiers;
-                       this.requiredCustomModifiers = requiredCustomModifiers;
+                       this.mods = mods;
                }
 
                public override bool Equals(object obj)
@@ -54,13 +52,12 @@ namespace IKVM.Reflection
                        FieldSignature other = obj as FieldSignature;
                        return other != null
                                && other.fieldType.Equals(fieldType)
-                               && Util.ArrayEquals(other.optionalCustomModifiers, optionalCustomModifiers)
-                               && Util.ArrayEquals(other.requiredCustomModifiers, requiredCustomModifiers);
+                               && other.mods.Equals(mods);
                }
 
                public override int GetHashCode()
                {
-                       return fieldType.GetHashCode() ^ Util.GetHashCode(optionalCustomModifiers) ^ Util.GetHashCode(requiredCustomModifiers);
+                       return fieldType.GetHashCode() ^ mods.GetHashCode();
                }
 
                internal Type FieldType
@@ -68,22 +65,16 @@ namespace IKVM.Reflection
                        get { return fieldType; }
                }
 
-               internal Type[] GetOptionalCustomModifiers()
+               internal CustomModifiers GetCustomModifiers()
                {
-                       return Util.Copy(optionalCustomModifiers);
-               }
-
-               internal Type[] GetRequiredCustomModifiers()
-               {
-                       return Util.Copy(requiredCustomModifiers);
+                       return mods;
                }
 
                internal FieldSignature ExpandTypeParameters(Type declaringType)
                {
                        return new FieldSignature(
                                fieldType.BindTypeParameters(declaringType),
-                               BindTypeParameters(declaringType, optionalCustomModifiers),
-                               BindTypeParameters(declaringType, requiredCustomModifiers));
+                               mods.Bind(declaringType));
                }
 
                internal static FieldSignature ReadSig(ModuleReader module, ByteReader br, IGenericContext context)
@@ -92,19 +83,15 @@ namespace IKVM.Reflection
                        {
                                throw new BadImageFormatException();
                        }
-                       Type fieldType;
-                       Type[] optionalCustomModifiers;
-                       Type[] requiredCustomModifiers;
-                       ReadCustomModifiers(module, br, context, out requiredCustomModifiers, out optionalCustomModifiers);
-                       fieldType = ReadType(module, br, context);
-                       return new FieldSignature(fieldType, optionalCustomModifiers, requiredCustomModifiers);
+                       CustomModifiers mods = CustomModifiers.Read(module, br, context);
+                       Type fieldType = ReadType(module, br, context);
+                       return new FieldSignature(fieldType, mods);
                }
 
                internal override void WriteSig(ModuleBuilder module, ByteBuffer bb)
                {
                        bb.Write(FIELD);
-                       WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_OPT, optionalCustomModifiers);
-                       WriteCustomModifiers(module, bb, ELEMENT_TYPE_CMOD_REQD, requiredCustomModifiers);
+                       WriteCustomModifiers(module, bb, mods);
                        WriteType(module, bb, fieldType);
                }
        }