Author: martin
Date: 2007-10-09 10:41:26 -0400 (Tue, 09 Oct 2007)
New Revision: 87166
Modified:
trunk/debugger/ChangeLog
trunk/debugger/frontend/ObjectFormatter.cs
trunk/debugger/frontend/Style.cs
trunk/debugger/languages/TargetEnumObject.cs
trunk/debugger/languages/TargetEnumType.cs
trunk/debugger/languages/TargetMember.cs
trunk/debugger/languages/mono/MonoClassObject.cs
trunk/debugger/languages/mono/MonoClassType.cs
trunk/debugger/languages/mono/MonoEnumType.cs
trunk/debugger/languages/mono/MonoMember.cs
trunk/debugger/languages/native/NativeEnumType.cs
Log:
2007-10-09 Martin Baulig <[EMAIL PROTECTED]>
* languages/TargetMember.cs
(TargetEnumInfo): New public abstract class.
* languages/TargetEnumType.cs
(TargetEnumType): Changed the type of `Value' and `Members' from
`TargetFieldInfo' info `TargetEnumInfo'.
* languages/mono/MonoClassType.cs
(MonoClassType): No longer include the fields and methods from our
parent class. We now create our parent class on-the-fly when it's
needed.
Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog 2007-10-09 14:19:17 UTC (rev 87165)
+++ trunk/debugger/ChangeLog 2007-10-09 14:41:26 UTC (rev 87166)
@@ -1,5 +1,19 @@
2007-10-09 Martin Baulig <[EMAIL PROTECTED]>
+ * languages/TargetMember.cs
+ (TargetEnumInfo): New public abstract class.
+
+ * languages/TargetEnumType.cs
+ (TargetEnumType): Changed the type of `Value' and `Members' from
+ `TargetFieldInfo' info `TargetEnumInfo'.
+
+ * languages/mono/MonoClassType.cs
+ (MonoClassType): No longer include the fields and methods from our
+ parent class. We now create our parent class on-the-fly when it's
+ needed.
+
+2007-10-09 Martin Baulig <[EMAIL PROTECTED]>
+
* languages/mono/MonoClassInfo.cs
(MonoClassInfo.ClassType): New public property.
(MonoClassInfo.GetParent): New public method; compute the parent
Modified: trunk/debugger/frontend/ObjectFormatter.cs
===================================================================
--- trunk/debugger/frontend/ObjectFormatter.cs 2007-10-09 14:19:17 UTC (rev
87165)
+++ trunk/debugger/frontend/ObjectFormatter.cs 2007-10-09 14:41:26 UTC (rev
87166)
@@ -249,7 +249,7 @@
object value = fobj.GetObject (target);
SortedList members = new SortedList ();
- foreach (TargetFieldInfo field in eobj.Type.Members)
+ foreach (TargetEnumInfo field in eobj.Type.Members)
members.Add (field.Name, field.ConstValue);
if (!eobj.Type.IsFlagsEnum) {
Modified: trunk/debugger/frontend/Style.cs
===================================================================
--- trunk/debugger/frontend/Style.cs 2007-10-09 14:19:17 UTC (rev 87165)
+++ trunk/debugger/frontend/Style.cs 2007-10-09 14:41:26 UTC (rev 87166)
@@ -347,7 +347,7 @@
sb.Append ("\n" + prefix + "{\n");
- foreach (TargetFieldInfo field in
etype.Members) {
+ foreach (TargetEnumInfo field in etype.Members)
{
sb.Append (FormatEnumMember (target,
prefix, field, false, hash));
if (field !=
etype.Members[etype.Members.Length - 1])
sb.Append (",");
Modified: trunk/debugger/languages/TargetEnumObject.cs
===================================================================
--- trunk/debugger/languages/TargetEnumObject.cs 2007-10-09 14:19:17 UTC
(rev 87165)
+++ trunk/debugger/languages/TargetEnumObject.cs 2007-10-09 14:41:26 UTC
(rev 87166)
@@ -14,7 +14,7 @@
public TargetObject GetValue (TargetMemoryAccess target)
{
- return Type.GetValue (target, Location);
+ return Type.Value.Type.GetObject (target, Location);
}
internal override long GetDynamicSize (TargetMemoryAccess
target, TargetBlob blob,
Modified: trunk/debugger/languages/TargetEnumType.cs
===================================================================
--- trunk/debugger/languages/TargetEnumType.cs 2007-10-09 14:19:17 UTC (rev
87165)
+++ trunk/debugger/languages/TargetEnumType.cs 2007-10-09 14:41:26 UTC (rev
87166)
@@ -12,20 +12,14 @@
get;
}
- public abstract TargetFieldInfo Value {
+ public abstract TargetEnumInfo Value {
get;
}
- public abstract TargetFieldInfo[] Members {
+ public abstract TargetEnumInfo[] Members {
get;
}
- internal TargetObject GetValue (TargetMemoryAccess target,
- TargetLocation location)
- {
- return Value.Type.GetObject (target, location);
- }
-
protected override TargetObject DoGetObject (TargetMemoryAccess
target, TargetLocation location)
{
return new TargetEnumObject (this, location);
Modified: trunk/debugger/languages/TargetMember.cs
===================================================================
--- trunk/debugger/languages/TargetMember.cs 2007-10-09 14:19:17 UTC (rev
87165)
+++ trunk/debugger/languages/TargetMember.cs 2007-10-09 14:41:26 UTC (rev
87166)
@@ -28,6 +28,28 @@
}
[Serializable]
+ public abstract class TargetEnumInfo : TargetMemberInfo
+ {
+ public readonly bool HasConstValue;
+
+ protected TargetEnumInfo (TargetType type, string name, int
index, bool is_static,
+ int position, int offset, bool
has_const_value)
+ : base (type, name, index, is_static)
+ {
+ this.HasConstValue = has_const_value;
+ }
+
+ public abstract object ConstValue {
+ get;
+ }
+
+ protected override string MyToString ()
+ {
+ return String.Format ("{0}:{1}", Type, HasConstValue);
+ }
+ }
+
+ [Serializable]
public abstract class TargetFieldInfo : TargetMemberInfo
{
public readonly int Offset;
Modified: trunk/debugger/languages/mono/MonoClassObject.cs
===================================================================
--- trunk/debugger/languages/mono/MonoClassObject.cs 2007-10-09 14:19:17 UTC
(rev 87165)
+++ trunk/debugger/languages/mono/MonoClassObject.cs 2007-10-09 14:41:26 UTC
(rev 87166)
@@ -48,7 +48,7 @@
public override TargetObject GetField (TargetMemoryAccess
target, TargetFieldInfo field)
{
- return type.GetField (target, Location, field);
+ return ((MonoFieldInfo) field).GetField (target,
Location);
}
public override void SetField (TargetAccess target,
TargetFieldInfo field,
Modified: trunk/debugger/languages/mono/MonoClassType.cs
===================================================================
--- trunk/debugger/languages/mono/MonoClassType.cs 2007-10-09 14:19:17 UTC
(rev 87165)
+++ trunk/debugger/languages/mono/MonoClassType.cs 2007-10-09 14:41:26 UTC
(rev 87166)
@@ -24,8 +24,7 @@
MonoMethodInfo[] static_constructors;
int num_methods = 0, num_smethods = 0;
- int first_method = 0, first_smethod = 0;
- int num_fields = 0, num_sfields = 0, first_field = 0;
+ int num_fields = 0, num_sfields = 0;
Cecil.TypeDefinition type;
MonoSymbolFile file;
@@ -107,12 +106,6 @@
get { return (int) (type.MetadataToken.TokenType +
type.MetadataToken.RID); }
}
- internal int FirstField {
- get {
- return first_field;
- }
- }
-
void get_fields ()
{
if (fields != null)
@@ -128,20 +121,16 @@
fields = new MonoFieldInfo [num_fields];
static_fields = new MonoFieldInfo [num_sfields];
- if (parent_type != null) {
- parent_type.get_fields ();
- first_field = parent_type.first_field +
- parent_type.num_fields +
parent_type.num_sfields;
- }
-
- int pos = 0, spos = 0, i = first_field;
+ int pos = 0, spos = 0, i = 0;
foreach (Cecil.FieldDefinition field in type.Fields) {
TargetType ftype =
File.MonoLanguage.LookupMonoType (field.FieldType);
if (field.IsStatic) {
- static_fields [spos] = new
MonoFieldInfo (ftype, spos, i, field);
+ static_fields [spos] = new
MonoFieldInfo (
+ this, ftype, spos, i, field);
spos++;
} else {
- fields [pos] = new MonoFieldInfo
(ftype, pos, i, field);
+ fields [pos] = new MonoFieldInfo (
+ this, ftype, pos, i, field);
pos++;
}
@@ -198,12 +187,6 @@
methods = new MonoMethodInfo [num_methods];
static_methods = new MonoMethodInfo [num_smethods];
- if (parent_type != null) {
- parent_type.get_methods ();
- first_method = parent_type.CountMethods;
- first_smethod = parent_type.CountStaticMethods;
- }
-
int pos = 0, spos = 0;
foreach (Cecil.MethodDefinition method in type.Methods)
{
if ((method.Attributes &
Cecil.MethodAttributes.SpecialName) != 0)
@@ -454,10 +437,7 @@
{
ResolveClass (target, true);
- if (field.Position < FirstField)
- return parent_type.GetFieldOffset (target,
field);
-
- return class_info.GetFieldOffsets (target)
[field.Position - FirstField];
+ return class_info.GetFieldOffsets (target)
[field.Position];
}
internal TargetObject GetField (TargetMemoryAccess target,
TargetLocation location,
Modified: trunk/debugger/languages/mono/MonoEnumType.cs
===================================================================
--- trunk/debugger/languages/mono/MonoEnumType.cs 2007-10-09 14:19:17 UTC
(rev 87165)
+++ trunk/debugger/languages/mono/MonoEnumType.cs 2007-10-09 14:41:26 UTC
(rev 87166)
@@ -7,8 +7,8 @@
{
internal class MonoEnumType : TargetEnumType
{
- MonoFieldInfo[] fields;
- MonoFieldInfo[] static_fields;
+ MonoEnumInfo[] fields;
+ MonoEnumInfo[] static_fields;
MonoSymbolFile file;
Cecil.TypeDefinition type;
@@ -77,19 +77,20 @@
num_fields++;
}
- fields = new MonoFieldInfo [num_fields];
- static_fields = new MonoFieldInfo [num_sfields];
+ fields = new MonoEnumInfo [num_fields];
+ static_fields = new MonoEnumInfo [num_sfields];
int pos = 0, spos = 0, i = 0;
foreach (Cecil.FieldDefinition field in type.Fields) {
TargetType ftype =
File.MonoLanguage.LookupMonoType (field.FieldType);
if (field.IsStatic) {
- static_fields [spos] = new
MonoFieldInfo (ftype, spos, i, field);
+ static_fields [spos] = new MonoEnumInfo
(
+ this, ftype, spos, i, field);
spos++;
} else {
if (field.Name != "value__")
throw new InternalError ("Mono
enum type has instance field with name other than 'value__'.");
- fields [pos] = new MonoFieldInfo
(ftype, pos, i, field);
+ fields [pos] = new MonoEnumInfo (this,
ftype, pos, i, field);
pos++;
}
@@ -106,14 +107,14 @@
}
}
- public override TargetFieldInfo Value {
+ public override TargetEnumInfo Value {
get {
get_fields ();
return fields[0];
}
}
- public override TargetFieldInfo[] Members {
+ public override TargetEnumInfo[] Members {
get {
get_fields ();
return static_fields;
Modified: trunk/debugger/languages/mono/MonoMember.cs
===================================================================
--- trunk/debugger/languages/mono/MonoMember.cs 2007-10-09 14:19:17 UTC (rev
87165)
+++ trunk/debugger/languages/mono/MonoMember.cs 2007-10-09 14:41:26 UTC (rev
87166)
@@ -9,14 +9,21 @@
{
[NonSerialized]
public readonly Cecil.FieldDefinition FieldInfo;
+ MonoClassType type;
- public MonoFieldInfo (TargetType type, int index, int pos,
+ public MonoFieldInfo (MonoClassType type, TargetType
field_type, int index, int pos,
Cecil.FieldDefinition finfo)
- : base (type, finfo.Name, index, finfo.IsStatic, pos,
0, finfo.HasConstant)
+ : base (field_type, finfo.Name, index, finfo.IsStatic,
pos, 0, finfo.HasConstant)
{
FieldInfo = finfo;
+ this.type = type;
}
+ internal TargetObject GetField (TargetMemoryAccess target,
TargetLocation location)
+ {
+ return type.GetField (target, location, this);
+ }
+
public override object ConstValue {
get {
if (FieldInfo.HasConstant)
@@ -28,6 +35,31 @@
}
[Serializable]
+ internal class MonoEnumInfo : TargetEnumInfo
+ {
+ [NonSerialized]
+ public readonly Cecil.FieldDefinition FieldInfo;
+ MonoEnumType type;
+
+ public MonoEnumInfo (MonoEnumType 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;
+ }
+
+ public override object ConstValue {
+ get {
+ if (FieldInfo.HasConstant)
+ return FieldInfo.Constant;
+ else
+ throw new InvalidOperationException ();
+ }
+ }
+ }
+
+ [Serializable]
internal class MonoMethodInfo : TargetMethodInfo
{
public readonly MonoFunctionType FunctionType;
Modified: trunk/debugger/languages/native/NativeEnumType.cs
===================================================================
--- trunk/debugger/languages/native/NativeEnumType.cs 2007-10-09 14:19:17 UTC
(rev 87165)
+++ trunk/debugger/languages/native/NativeEnumType.cs 2007-10-09 14:41:26 UTC
(rev 87166)
@@ -10,8 +10,8 @@
string[] element_names;
int[] element_values;
- NativeFieldInfo[] members;
- NativeFieldInfo value;
+ NativeEnumInfo[] members;
+ NativeEnumInfo value;
public NativeEnumType (Language language, string name, int size,
string[] element_names, int[]
element_values)
@@ -22,12 +22,12 @@
this.element_names = element_names;
this.element_values = element_values;
- members = new NativeFieldInfo [element_names.Length];
+ members = new NativeEnumInfo [element_names.Length];
for (int i = 0; i < element_names.Length; i++)
- members [i] = new NativeFieldInfo (
- this, element_names [i], i, true,
element_values [i]);
+ members [i] = new NativeEnumInfo (
+ this, element_names [i], i,
element_values [i]);
- value = new NativeFieldInfo (language.IntegerType,
"__value", 0, 0);
+ value = new NativeEnumInfo (language.IntegerType,
"__value", 0, 0);
}
public override bool HasClassType {
@@ -68,13 +68,13 @@
}
}
- public override TargetFieldInfo Value {
+ public override TargetEnumInfo Value {
get {
return value;
}
}
- public override TargetFieldInfo[] Members {
+ public override TargetEnumInfo[] Members {
get {
return members;
}
@@ -86,4 +86,29 @@
}
}
}
+
+ [Serializable]
+ internal class NativeEnumInfo : TargetEnumInfo
+ {
+ int const_value;
+
+ public NativeEnumInfo (TargetType field_type, string name, int
index, int value)
+ : base (field_type, name, index, false, 0, 0, true)
+ {
+ this.const_value = value;
+ }
+
+ public NativeEnumInfo (TargetType field_type, string name, int
index)
+ : base (field_type, name, index, false, 0, 0, false)
+ { }
+
+ public override object ConstValue {
+ get {
+ if (HasConstValue)
+ return const_value;
+ else
+ throw new InvalidOperationException ();
+ }
+ }
+ }
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches