Author: martin
Date: 2007-10-09 13:01:20 -0400 (Tue, 09 Oct 2007)
New Revision: 87195

Modified:
   trunk/debugger/ChangeLog
   trunk/debugger/frontend/Style.cs
   trunk/debugger/languages/mono/MonoClassInfo.cs
   trunk/debugger/languages/mono/MonoClassObject.cs
   trunk/debugger/languages/mono/MonoClassType.cs
   trunk/debugger/languages/mono/MonoLanguageBackend.cs
   trunk/debugger/languages/mono/MonoMember.cs
Log:
2007-10-09  Martin Baulig  <[EMAIL PROTECTED]>

        * languages/mono/MonoClassInfo.cs
        (MonoClassInfo): Moved the implementations of GetField(),
        SetField(), GetStaticField() and SetStaticField() here from
        `MonoClassType'.

        * languages/mono/MonoClassType.cs
        (MonoClassType): Moved all the code dealing with fields into
        `MonoClassInfo'.        



Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog    2007-10-09 16:41:51 UTC (rev 87194)
+++ trunk/debugger/ChangeLog    2007-10-09 17:01:20 UTC (rev 87195)
@@ -1,5 +1,16 @@
 2007-10-09  Martin Baulig  <[EMAIL PROTECTED]>
 
+       * languages/mono/MonoClassInfo.cs
+       (MonoClassInfo): Moved the implementations of GetField(),
+       SetField(), GetStaticField() and SetStaticField() here from
+       `MonoClassType'.
+
+       * languages/mono/MonoClassType.cs
+       (MonoClassType): Moved all the code dealing with fields into
+       `MonoClassInfo'.        
+
+2007-10-09  Martin Baulig  <[EMAIL PROTECTED]>
+
        * languages/TargetMember.cs
        (TargetEnumInfo): New public abstract class.
 

Modified: trunk/debugger/frontend/Style.cs
===================================================================
--- trunk/debugger/frontend/Style.cs    2007-10-09 16:41:51 UTC (rev 87194)
+++ trunk/debugger/frontend/Style.cs    2007-10-09 17:01:20 UTC (rev 87195)
@@ -222,14 +222,13 @@
                }
 
                protected string FormatEnumMember (Thread target, string prefix,
-                                                  TargetMemberInfo member, 
bool is_static,
+                                                  TargetEnumInfo info, bool 
is_static,
                                                   Hashtable hash)
                {
-                       TargetFieldInfo fi = member as TargetFieldInfo;
                        string value = "";
-                       if (fi.HasConstValue)
-                               value = String.Format (" = {0}", fi.ConstValue);
-                       return String.Format ("{0}   {1}{2}", prefix, 
member.Name, value);
+                       if (info.HasConstValue)
+                               value = String.Format (" = {0}", 
info.ConstValue);
+                       return String.Format ("{0}   {1}{2}", prefix, 
info.Name, value);
                }
 
                protected string FormatMember (string prefix, TargetMemberInfo 
member,

Modified: trunk/debugger/languages/mono/MonoClassInfo.cs
===================================================================
--- trunk/debugger/languages/mono/MonoClassInfo.cs      2007-10-09 16:41:51 UTC 
(rev 87194)
+++ trunk/debugger/languages/mono/MonoClassInfo.cs      2007-10-09 17:01:20 UTC 
(rev 87195)
@@ -17,6 +17,7 @@
 
                MonoClassInfo parent_info;
                TargetAddress parent_klass = TargetAddress.Null;
+               TargetType[] field_types;
                int[] field_offsets;
                Hashtable methods;
 
@@ -111,19 +112,100 @@
                                field_info, field_count * 
metadata.FieldInfoSize));
 
                        field_offsets = new int [field_count];
+                       field_types = new TargetType [field_count];
+
                        for (int i = 0; i < field_count; i++) {
                                int offset = i * metadata.FieldInfoSize;
+
+                               TargetAddress type_addr = 
field_blob.PeekAddress (
+                                       offset + metadata.FieldInfoTypeOffset);
+                               field_types [i] = MonoRuntime.ReadType (
+                                       SymbolFile.MonoLanguage, target, 
type_addr);
                                field_offsets [i] = field_blob.PeekInteger (
                                        offset + 
metadata.FieldInfoOffsetOffset);
                        }
                }
 
-               public int[] GetFieldOffsets (TargetMemoryAccess target)
+               public TargetObject GetField (TargetMemoryAccess target, 
TargetLocation location,
+                                             TargetFieldInfo field)
                {
                        get_field_offsets (target);
-                       return field_offsets;
+
+                       int offset = field_offsets [field.Position];
+                       TargetType type = field_types [field.Position];
+
+                       if (!ClassType.IsByRef)
+                               offset -= 2 * 
target.TargetInfo.TargetAddressSize;
+                       TargetLocation field_loc = location.GetLocationAtOffset 
(offset);
+
+                       if (type.IsByRef)
+                               field_loc = field_loc.GetDereferencedLocation 
();
+
+                       if (field_loc.HasAddress && field_loc.GetAddress 
(target).IsNull)
+                               return null;
+
+                       return type.GetObject (target, field_loc);
                }
 
+               public void SetField (TargetAccess target, TargetLocation 
location,
+                                     TargetFieldInfo field, TargetObject obj)
+               {
+                       get_field_offsets (target);
+
+                       int offset = field_offsets [field.Position];
+                       TargetType type = field_types [field.Position];
+
+                       if (!ClassType.IsByRef)
+                               offset -= 2 * 
target.TargetInfo.TargetAddressSize;
+                       TargetLocation field_loc = location.GetLocationAtOffset 
(offset);
+
+                       if (type.IsByRef)
+                               field_loc = field_loc.GetDereferencedLocation 
();
+
+                       type.SetObject (target, field_loc, obj);
+               }
+
+               public TargetObject GetStaticField (Thread target, 
TargetFieldInfo field)
+               {
+                       get_field_offsets (target);
+
+                       int offset = field_offsets [field.Position];
+                       TargetType type = field_types [field.Position];
+
+                       TargetAddress data_address = target.CallMethod (
+                               
SymbolFile.MonoLanguage.MonoDebuggerInfo.ClassGetStaticFieldData,
+                               KlassAddress, 0);
+
+                       TargetLocation location = new AbsoluteTargetLocation 
(data_address);
+                       TargetLocation field_loc = location.GetLocationAtOffset 
(offset);
+
+                       if (type.IsByRef)
+                               field_loc = field_loc.GetDereferencedLocation 
();
+
+                       return type.GetObject (target, field_loc);
+               }
+
+               public void SetStaticField (Thread target, TargetFieldInfo 
field,
+                                           TargetObject obj)
+               {
+                       get_field_offsets (target);
+
+                       int offset = field_offsets [field.Position];
+                       TargetType type = field_types [field.Position];
+
+                       TargetAddress data_address = target.CallMethod (
+                               
SymbolFile.MonoLanguage.MonoDebuggerInfo.ClassGetStaticFieldData,
+                               KlassAddress, 0);
+
+                       TargetLocation location = new AbsoluteTargetLocation 
(data_address);
+                       TargetLocation field_loc = location.GetLocationAtOffset 
(offset);
+
+                       if (type.IsByRef)
+                               field_loc = field_loc.GetDereferencedLocation 
();
+
+                       type.SetObject (target, field_loc, obj);
+               }
+
                void get_methods (TargetMemoryAccess target)
                {
                        if (methods != null)

Modified: trunk/debugger/languages/mono/MonoClassObject.cs
===================================================================
--- trunk/debugger/languages/mono/MonoClassObject.cs    2007-10-09 16:41:51 UTC 
(rev 87194)
+++ trunk/debugger/languages/mono/MonoClassObject.cs    2007-10-09 17:01:20 UTC 
(rev 87195)
@@ -48,13 +48,13 @@
 
                public override TargetObject GetField (TargetMemoryAccess 
target, TargetFieldInfo field)
                {
-                       return ((MonoFieldInfo) field).GetField (target, 
Location);
+                       return ((MonoFieldInfo) field).DeclaringType.GetField 
(target, Location, field);
                }
 
                public override void SetField (TargetAccess target, 
TargetFieldInfo field,
                                               TargetObject obj)
                {
-                       type.SetField (target, Location, field, obj);
+                       ((MonoFieldInfo) field).DeclaringType.SetField (target, 
Location, field, obj);
                }
 
                internal TargetAddress GetKlassAddress (TargetMemoryAccess 
target)

Modified: trunk/debugger/languages/mono/MonoClassType.cs
===================================================================
--- trunk/debugger/languages/mono/MonoClassType.cs      2007-10-09 16:41:51 UTC 
(rev 87194)
+++ trunk/debugger/languages/mono/MonoClassType.cs      2007-10-09 17:01:20 UTC 
(rev 87195)
@@ -433,77 +433,31 @@
                        return null;
                }
 
-               int GetFieldOffset (TargetMemoryAccess target, TargetFieldInfo 
field)
+               internal TargetObject GetField (TargetMemoryAccess target, 
TargetLocation location,
+                                               TargetFieldInfo field)
                {
                        ResolveClass (target, true);
-
-                       return class_info.GetFieldOffsets (target) 
[field.Position];
+                       return class_info.GetField (target, location, field);
                }
 
-               internal TargetObject GetField (TargetMemoryAccess target, 
TargetLocation location,
-                                               TargetFieldInfo finfo)
-               {
-                       int offset = GetFieldOffset (target, finfo);
-                       if (!IsByRef)
-                               offset -= 2 * 
target.TargetInfo.TargetAddressSize;
-                       TargetLocation field_loc = location.GetLocationAtOffset 
(offset);
-
-                       if (finfo.Type.IsByRef)
-                               field_loc = field_loc.GetDereferencedLocation 
();
-
-                       if (field_loc.HasAddress && field_loc.GetAddress 
(target).IsNull)
-                               return null;
-
-                       return finfo.Type.GetObject (target, field_loc);
-               }
-
                internal void SetField (TargetAccess target, TargetLocation 
location,
-                                       TargetFieldInfo finfo, TargetObject obj)
+                                       TargetFieldInfo field, TargetObject obj)
                {
-                       int offset = GetFieldOffset (target, finfo);
-                       if (!IsByRef)
-                               offset -= 2 * 
target.TargetInfo.TargetAddressSize;
-                       TargetLocation field_loc = location.GetLocationAtOffset 
(offset);
-
-                       if (finfo.Type.IsByRef)
-                               field_loc = field_loc.GetDereferencedLocation 
();
-
-                       finfo.Type.SetObject (target, field_loc, obj);
+                       ResolveClass (target, true);
+                       class_info.SetField (target, location, field, obj);
                }
 
-               public override TargetObject GetStaticField (Thread target, 
TargetFieldInfo finfo)
+               public override TargetObject GetStaticField (Thread target, 
TargetFieldInfo field)
                {
-                       int offset = GetFieldOffset (target, finfo);
-
-                       TargetAddress data_address = target.CallMethod (
-                               
File.MonoLanguage.MonoDebuggerInfo.ClassGetStaticFieldData,
-                               class_info.KlassAddress, 0);
-
-                       TargetLocation location = new AbsoluteTargetLocation 
(data_address);
-                       TargetLocation field_loc = location.GetLocationAtOffset 
(offset);
-
-                       if (finfo.Type.IsByRef)
-                               field_loc = field_loc.GetDereferencedLocation 
();
-
-                       return finfo.Type.GetObject (target, field_loc);
+                       ResolveClass (target, true);
+                       return class_info.GetStaticField (target, field);
                }
 
-               public override void SetStaticField (Thread target, 
TargetFieldInfo finfo,
+               public override void SetStaticField (Thread target, 
TargetFieldInfo field,
                                                     TargetObject obj)
                {
-                       int offset = GetFieldOffset (target, finfo);
-
-                       TargetAddress data_address = target.CallMethod (
-                               
File.MonoLanguage.MonoDebuggerInfo.ClassGetStaticFieldData,
-                               class_info.KlassAddress, 0);
-
-                       TargetLocation location = new AbsoluteTargetLocation 
(data_address);
-                       TargetLocation field_loc = location.GetLocationAtOffset 
(offset);
-
-                       if (finfo.Type.IsByRef)
-                               field_loc = field_loc.GetDereferencedLocation 
();
-
-                       finfo.Type.SetObject (target, field_loc, obj);
+                       ResolveClass (target, true);
+                       class_info.SetStaticField (target, field, obj);
                }
 
                internal MonoClassObject GetCurrentObject (TargetMemoryAccess 
target, TargetLocation location)

Modified: trunk/debugger/languages/mono/MonoLanguageBackend.cs
===================================================================
--- trunk/debugger/languages/mono/MonoLanguageBackend.cs        2007-10-09 
16:41:51 UTC (rev 87194)
+++ trunk/debugger/languages/mono/MonoLanguageBackend.cs        2007-10-09 
17:01:20 UTC (rev 87195)
@@ -350,7 +350,7 @@
                                if (info == null)
                                        return null;
 
-                               type = info.SymbolFile.LookupMonoClass 
(info.CecilType);
+                               type = info.SymbolFile.LookupMonoType 
(info.CecilType);
                        } catch {
                                return null;
                        }

Modified: trunk/debugger/languages/mono/MonoMember.cs
===================================================================
--- trunk/debugger/languages/mono/MonoMember.cs 2007-10-09 16:41:51 UTC (rev 
87194)
+++ trunk/debugger/languages/mono/MonoMember.cs 2007-10-09 17:01:20 UTC (rev 
87195)
@@ -9,21 +9,16 @@
        {
                [NonSerialized]
                public readonly Cecil.FieldDefinition FieldInfo;
-               MonoClassType type;
+               public readonly MonoClassType DeclaringType;
 
                public MonoFieldInfo (MonoClassType type, TargetType 
field_type, int index, int pos,
                                      Cecil.FieldDefinition finfo)
                        : base (field_type, finfo.Name, index, finfo.IsStatic, 
pos, 0, finfo.HasConstant)
                {
                        FieldInfo = finfo;
-                       this.type = type;
+                       DeclaringType = type;
                }
 
-               internal TargetObject GetField (TargetMemoryAccess target, 
TargetLocation location)
-               {
-                       return type.GetField (target, location, this);
-               }
-
                public override object ConstValue {
                        get {
                                if (FieldInfo.HasConstant)

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to