Author: toshok
Date: 2005-07-05 21:34:38 -0400 (Tue, 05 Jul 2005)
New Revision: 46983
Modified:
trunk/debugger/ChangeLog
trunk/debugger/backends/mono/MonoMember.cs
trunk/debugger/backends/native/NativeEnumType.cs
trunk/debugger/backends/native/NativeStructType.cs
trunk/debugger/frontend/Style.cs
Log:
2005-07-05 Chris Toshok <[EMAIL PROTECTED]>
* backends/mono/MonoMember.cs (MonoFieldInfo): add implementations
of HasConstValue and GetConstValue from ITargetFieldInfo.
* backends/native/NativeEnumType.cs (NativeEnumType..ctor): use
the new NativeFieldInfo ctor.
* backends/native/NativeStructType.cs (NativeFieldInfo): add a new
ctor for fields that have constant values (right now only used by
enums), and add the ITargetFieldInfo "HasConstValue" and
"GetConstValue" implementations.
* frontend/Style.cs (StyleBase): make interpreter protected.
(StyleNative.FormatEnumMember): make this code work for both
native and managed enum types (although the native backend doesn't
provide the needed hooks as yet.)
* interfaces/ITargetStructType.cs (ITargetFieldInfo): add
HasConstValue property and GetConstValue method.
Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog 2005-07-06 00:06:12 UTC (rev 46982)
+++ trunk/debugger/ChangeLog 2005-07-06 01:34:38 UTC (rev 46983)
@@ -1,5 +1,26 @@
2005-07-05 Chris Toshok <[EMAIL PROTECTED]>
+ * backends/mono/MonoMember.cs (MonoFieldInfo): add implementations
+ of HasConstValue and GetConstValue from ITargetFieldInfo.
+
+ * backends/native/NativeEnumType.cs (NativeEnumType..ctor): use
+ the new NativeFieldInfo ctor.
+
+ * backends/native/NativeStructType.cs (NativeFieldInfo): add a new
+ ctor for fields that have constant values (right now only used by
+ enums), and add the ITargetFieldInfo "HasConstValue" and
+ "GetConstValue" implementations.
+
+ * frontend/Style.cs (StyleBase): make interpreter protected.
+ (StyleNative.FormatEnumMember): make this code work for both
+ native and managed enum types (although the native backend doesn't
+ provide the needed hooks as yet.)
+
+ * interfaces/ITargetStructType.cs (ITargetFieldInfo): add
+ HasConstValue property and GetConstValue method.
+
+2005-07-05 Chris Toshok <[EMAIL PROTECTED]>
+
* backends/native/Makefile.am (EXTRA_DIST): add
NativeEnum{Object,Type}.cs
Modified: trunk/debugger/backends/mono/MonoMember.cs
===================================================================
--- trunk/debugger/backends/mono/MonoMember.cs 2005-07-06 00:06:12 UTC (rev
46982)
+++ trunk/debugger/backends/mono/MonoMember.cs 2005-07-06 01:34:38 UTC (rev
46983)
@@ -77,6 +77,28 @@
get { return 0; }
}
+ public bool HasConstValue {
+ get { return FieldInfo.IsLiteral; }
+ }
+
+ public ITargetObject GetConstValue (StackFrame frame)
+ {
+ // this is definitely swayed toward enums,
+ // where we know we can get the const value
+ // from a null instance (i.e. it's a static
+ // field. we need to take into account
+ // finfo.IsStatic, though.
+ if (FieldInfo.DeclaringType.IsEnum) {
+ object value = FieldInfo.GetValue (null);
+
+ return type.File.MonoLanguage.CreateInstance
(frame, (int)value);
+ }
+ else {
+ // XXX
+ return null;
+ }
+ }
+
protected override string MyToString ()
{
return String.Format ("{0}", type);
Modified: trunk/debugger/backends/native/NativeEnumType.cs
===================================================================
--- trunk/debugger/backends/native/NativeEnumType.cs 2005-07-06 00:06:12 UTC
(rev 46982)
+++ trunk/debugger/backends/native/NativeEnumType.cs 2005-07-06 01:34:38 UTC
(rev 46983)
@@ -19,7 +19,7 @@
members = new NativeFieldInfo [element_names.Length];
int i;
for (i = 0; i < element_names.Length; i ++) {
- members[i] = new NativeFieldInfo (this,
element_names[i], i, 0);
+ members[i] = new NativeFieldInfo (this,
element_names[i], i, true, element_values[i]);
}
}
Modified: trunk/debugger/backends/native/NativeStructType.cs
===================================================================
--- trunk/debugger/backends/native/NativeStructType.cs 2005-07-06 00:06:12 UTC
(rev 46982)
+++ trunk/debugger/backends/native/NativeStructType.cs 2005-07-06 01:34:38 UTC
(rev 46983)
@@ -59,6 +59,8 @@
int offset;
int bit_offset, bit_size;
bool is_bitfield;
+ bool has_const_value;
+ int const_value;
public NativeFieldInfo (NativeType type, string name, int
index, int offset)
: base (type, name, index, false)
@@ -75,6 +77,25 @@
this.is_bitfield = true;
}
+ public NativeFieldInfo (NativeType type, string name, int index,
+ bool has_const_value, int const_value)
+ : base (type, name, index, false)
+ {
+ this.has_const_value = has_const_value;
+ this.const_value = const_value;
+ }
+
+ public bool HasConstValue {
+ get {
+ Console.WriteLine ("HasConstvalue = {0}",
has_const_value);
+ return has_const_value;
+ }
+ }
+
+ public ITargetObject GetConstValue (StackFrame frame) {
+ return null;
+ }
+
public int Offset {
get {
return offset;
Modified: trunk/debugger/frontend/Style.cs
===================================================================
--- trunk/debugger/frontend/Style.cs 2005-07-06 00:06:12 UTC (rev 46982)
+++ trunk/debugger/frontend/Style.cs 2005-07-06 01:34:38 UTC (rev 46983)
@@ -227,11 +227,12 @@
protected string FormatEnumMember (string prefix,
ITargetMemberInfo member,
bool is_static, Hashtable
hash)
{
+ ITargetFieldInfo fi = member as ITargetFieldInfo;
string value = "";
- if (member.Handle is FieldInfo) {
- FieldInfo fi = (FieldInfo)member.Handle;
- if (fi.GetValue (null) != null)
- value = String.Format (" = {0}",
(int)fi.GetValue(null));
+ if (fi.HasConstValue) {
+ ITargetObject cv = fi.GetConstValue
(interpreter.GlobalContext.CurrentFrame.Frame);
+ if (cv != null)
+ value = String.Format (" = {0}",
cv.Print());
}
return String.Format ("{0} {1}{2}", prefix,
member.Name, value);
}
@@ -720,7 +721,7 @@
public abstract class StyleBase
{
- Interpreter interpreter;
+ protected Interpreter interpreter;
protected StyleBase (Interpreter interpreter)
{
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches