Author: toshok
Date: 2005-07-13 18:15:05 -0400 (Wed, 13 Jul 2005)
New Revision: 47286

Modified:
   branches/debugger-cecil/backends/mono/MonoArrayType.cs
   branches/debugger-cecil/backends/mono/MonoClassType.cs
   branches/debugger-cecil/backends/mono/MonoEnumType.cs
   branches/debugger-cecil/backends/mono/MonoFunctionType.cs
   branches/debugger-cecil/backends/mono/MonoFundamentalType.cs
   branches/debugger-cecil/backends/mono/MonoLanguageBackend.cs
   branches/debugger-cecil/backends/mono/MonoMember.cs
   branches/debugger-cecil/backends/mono/MonoObjectType.cs
   branches/debugger-cecil/backends/mono/MonoOpaqueType.cs
   branches/debugger-cecil/backends/mono/MonoStringType.cs
   branches/debugger-cecil/backends/mono/MonoSymbolFile.cs
   branches/debugger-cecil/backends/mono/MonoType.cs
Log:
initial (uncompiling) conversion to Cecil

Modified: branches/debugger-cecil/backends/mono/MonoArrayType.cs
===================================================================
--- branches/debugger-cecil/backends/mono/MonoArrayType.cs      2005-07-13 
20:21:01 UTC (rev 47285)
+++ branches/debugger-cecil/backends/mono/MonoArrayType.cs      2005-07-13 
22:15:05 UTC (rev 47286)
@@ -1,6 +1,7 @@
 using System;
 using System.Text;
 using C = Mono.CompilerServices.SymbolWriter;
+using Cecil = Mono.Cecil;
 
 namespace Mono.Debugger.Languages.Mono
 {
@@ -24,13 +25,13 @@
                protected MonoType element_type;
                protected MonoArrayType subarray_type;
 
-               public MonoArrayType (MonoSymbolFile file, Type type)
+               public MonoArrayType (MonoSymbolFile file, Cecil.IArrayType 
type)
                        : base (file, TargetObjectKind.Array, type)
                {
-                       this.Rank = type.GetArrayRank ();
+                       this.Rank = type.Rank;
                        this.Dimension = 0;
 
-                       element_type = file.LookupMonoType (type.GetElementType 
());
+                       element_type = file.LookupMonoType (type.ElementType);
 
                        if (Dimension + 1 < Rank)
                                subarray_type = new MonoArrayType (this);

Modified: branches/debugger-cecil/backends/mono/MonoClassType.cs
===================================================================
--- branches/debugger-cecil/backends/mono/MonoClassType.cs      2005-07-13 
20:21:01 UTC (rev 47285)
+++ branches/debugger-cecil/backends/mono/MonoClassType.cs      2005-07-13 
22:15:05 UTC (rev 47286)
@@ -1,7 +1,7 @@
 using System;
 using System.Text;
-using R = System.Reflection;
 using C = Mono.CompilerServices.SymbolWriter;
+using Cecil = Mono.Cecil;
 
 namespace Mono.Debugger.Languages.Mono
 {
@@ -18,11 +18,14 @@
                MonoMethodInfo[] constructors;
                MonoMethodInfo[] static_constructors;
 
+               Cecil.ITypeDefinition type;
                MonoClassType parent_type;
 
-               public MonoClassType (MonoSymbolFile file, Type type)
+               public MonoClassType (MonoSymbolFile file, 
Cecil.ITypeDefinition type)
                        : base (file, TargetObjectKind.Class, type)
                {
+                       this.type = type;
+
                        if (type.BaseType != null)
                                parent_type = file.MonoLanguage.LookupMonoType 
(type.BaseType) as MonoClassType;
                }
@@ -46,11 +49,11 @@
 
                        int num_fields = 0, num_sfields = 0;
 
-                       R.FieldInfo[] finfo = type.GetFields (
-                               R.BindingFlags.DeclaredOnly | 
R.BindingFlags.Static | R.BindingFlags.Instance |
-                               R.BindingFlags.Public | 
R.BindingFlags.NonPublic);
+                       foreach (Cecil.IFieldDefinition field in type.Fields) {
+                               if (!finfo.Attributes & 
(Cecil.FieldAttributes.FieldAccessMask | Cecil.FieldAttributes.Static |
+                                                        
Cecil.FieldAttributes.Instance))
+                                 continue;
 
-                       foreach (R.FieldInfo field in finfo) {
                                if (field.IsStatic)
                                        num_sfields++;
                                else
@@ -60,15 +63,21 @@
                        fields = new MonoFieldInfo [num_fields];
                        static_fields = new MonoFieldInfo [num_sfields];
 
-                       int pos = 0, spos = 0;
-                       for (int i = 0; i < finfo.Length; i++) {
-                               if (finfo [i].IsStatic) {
-                                       static_fields [spos] = new 
MonoFieldInfo (File, spos, i, finfo [i]);
+                       int pos = 0, spos = 0, i = 0;
+                       foreach (Cecil.IFieldDefinition field in type.Fields) {
+                               if (!field.Attributes & 
(Cecil.FieldAttributes.FieldAccessMask | Cecil.FieldAttributes.Static |
+                                                        
Cecil.FieldAttributes.Instance))
+                                 continue;
+
+                               if (field.IsStatic) {
+                                       static_fields [spos] = new 
MonoFieldInfo (File, spos, i, field);
                                        spos++;
                                } else {
-                                       fields [pos] = new MonoFieldInfo (File, 
pos, i, finfo [i]);
+                                       fields [pos] = new MonoFieldInfo (File, 
pos, i, field);
                                        pos++;
                                }
+
+                               i++;
                        }
                }
 
@@ -109,13 +118,11 @@
                                return;
 
                        int num_methods = 0, num_smethods = 0;
-
-                       R.MethodInfo[] minfo = type.GetMethods (
-                               R.BindingFlags.DeclaredOnly | 
R.BindingFlags.Static | R.BindingFlags.Instance |
-                               R.BindingFlags.Public | 
R.BindingFlags.NonPublic);
-
-                       foreach (R.MethodInfo method in minfo) {
-                               if ((method.Attributes & 
R.MethodAttributes.SpecialName) != 0)
+                       foreach (Cecil.IMethod method in type.Methods) {
+                               if (!method.Attributes & 
(Cecil.MethodAttributes.MemberAccessMask | Cecil.MethodAttributes.Static |
+                                                         
Cecil.MethodAttributes.Instance))
+                                 continue;
+                               if ((method.Attributes & 
Cecil.MethodAttributes.SpecialName) != 0)
                                        continue;
                                if (method.IsStatic)
                                        num_smethods++;
@@ -126,17 +133,22 @@
                        methods = new MonoMethodInfo [num_methods];
                        static_methods = new MonoMethodInfo [num_smethods];
 
-                       int pos = 0, spos = 0;
-                       for (int i = 0; i < minfo.Length; i++) {
-                               if ((minfo [i].Attributes & 
R.MethodAttributes.SpecialName) != 0)
+                       int pos = 0, spos = 0, i = 0;
+                       foreach (Cecil.IMethod method in type.Methods) {
+                               if (!method.Attributes & 
(Cecil.MethodAttributes.MemberAccessMask | Cecil.MethodAttributes.Static |
+                                                         
Cecil.MethodAttributes.Instance))
+                                 continue;
+                               if ((method.Attributes & 
Cecil.MethodAttributes.SpecialName) != 0)
                                        continue;
-                               if (minfo [i].IsStatic) {
-                                       static_methods [spos] = new 
MonoMethodInfo (this, spos, minfo [i]);
+                               if (method.IsStatic) {
+                                       static_methods [spos] = new 
MonoMethodInfo (this, spos, method);
                                        spos++;
                                } else {
-                                       methods [pos] = new MonoMethodInfo 
(this, pos, minfo [i]);
+                                       methods [pos] = new MonoMethodInfo 
(this, pos, method);
                                        pos++;
                                }
+
+                               i++;
                        }
                }
 
@@ -180,26 +192,50 @@
 
                void get_properties ()
                {
+                       int i;
                        if (properties != null)
                                return;
 
-                       R.PropertyInfo[] pinfo = type.GetProperties (
-                               R.BindingFlags.DeclaredOnly | 
R.BindingFlags.Instance |
-                               R.BindingFlags.Public | 
R.BindingFlags.NonPublic);
+                       int num_sproperties = 0, num_properties = 0;
 
-                       properties = new MonoPropertyInfo [pinfo.Length];
+                       for (i = 0; i < type.Properties.Count; i++) {
+                               IMethodDefinition m = 
type.Properties[i].GetMethod;
+                               if (m == null) m = type.Properties[i].SetMethod;
 
-                       for (int i = 0; i < pinfo.Length; i++)
-                               properties [i] = new MonoPropertyInfo (this, i, 
pinfo [i], false);
+                               if (!m.Attributes & 
(Cecil.MethodAttributes.MemberAccessMask | Cecil.MethodAttributes.Static |
+                                                    
Cecil.MethodAttributes.Instance))
+                                       continue;
 
-                       pinfo = type.GetProperties (
-                               R.BindingFlags.DeclaredOnly | 
R.BindingFlags.Static |
-                               R.BindingFlags.Public | 
R.BindingFlags.NonPublic);
+                               if (m.IsStatic)
+                                       num_sproperties++;
+                               else
+                                       num_properties++;
+                       }
 
-                       static_properties = new MonoPropertyInfo [pinfo.Length];
+                       properties = new MonoPropertyInfo [num_properties];
+                       static_properties = new MonoPropertyInfo 
[num_sproperties];
 
-                       for (int i = 0; i < pinfo.Length; i++)
-                               static_properties [i] = new MonoPropertyInfo 
(this, i, pinfo [i], true);
+                       int pos = 0, spos = 0;
+                       i = 0;
+                       foreach (IPropertyDefinition prop in type.Properties) {
+                               IMethodDefinition m = 
type.Properties[i].GetMethod;
+                               if (m == null) m = type.Properties[i].SetMethod;
+
+                               if (!m.Attributes & 
(Cecil.MethodAttributes.MemberAccessMask | Cecil.MethodAttributes.Static |
+                                                    
Cecil.MethodAttributes.Instance))
+                                       continue;
+
+                               if (m.IsStatic) {
+                                       static_properties [spos] = new 
MonoPropertyInfo (this, spos, prop, true);
+                                       spos++;
+                               }
+                               else {
+                                       static_properties [pos] = new 
MonoPropertyInfo (this, spos, prop, false);
+                                       pos++;
+                               }
+
+                               i ++;
+                       }
                }
 
                internal MonoPropertyInfo[] Properties {
@@ -232,26 +268,47 @@
 
                void get_events ()
                {
+                       int i;
                        if (events != null)
                                return;
 
-                       R.EventInfo[] einfo = type.GetEvents (
-                               R.BindingFlags.DeclaredOnly | 
R.BindingFlags.Instance |
-                               R.BindingFlags.Public | 
R.BindingFlags.NonPublic);
+                       int num_sevents = 0, num_events = 0;
+                       for (i = 0; i < type.Events.Count; i++) {
+                               IMethodDefinition m = type.Events[i].AddMethod;
 
-                       events = new MonoEventInfo [einfo.Length];
+                               if (!m.Attributes & 
(Cecil.MethodAttributes.MemberAccessMask | Cecil.MethodAttributes.Static |
+                                                    
Cecil.MethodAttributes.Instance))
+                                       continue;
 
-                       for (int i = 0; i < einfo.Length; i++)
-                               events [i] = new MonoEventInfo (this, i, einfo 
[i], false);
+                               if (m.IsStatic)
+                                       num_sevents++;
+                               else
+                                       num_events++;
+                       }
 
-                       einfo = type.GetEvents (
-                               R.BindingFlags.DeclaredOnly | 
R.BindingFlags.Static |
-                               R.BindingFlags.Public | 
R.BindingFlags.NonPublic);
+                       events = new MonoEventInfo [num_events];
+                       static_events = new MonoEventInfo [num_sevents];
 
-                       static_events = new MonoEventInfo [einfo.Length];
+                       int pos = 0, spos = 0;
+                       i = 0;
+                       foreach (IEventDefinition ev in type.Events) {
+                               IMethodDefinition m = type.Events[i].AddMethod;
 
-                       for (int i = 0; i < einfo.Length; i++)
-                               static_events [i] = new MonoEventInfo (this, i, 
einfo [i], true);
+                               if (!m.Attributes & 
(Cecil.MethodAttributes.MemberAccessMask | Cecil.MethodAttributes.Static |
+                                                    
Cecil.MethodAttributes.Instance))
+                                       continue;
+
+                               if (m.IsStatic) {
+                                       static_events [spos] = new 
MonoEventInfo (this, spos, ev, true);
+                                       spos++;
+                               }
+                               else {
+                                       static_events [pos] = new MonoEventInfo 
(this, spos, ev, false);
+                                       pos++;
+                               }
+
+                               i ++;
+                       }
                }
 
                public ITargetEventInfo[] Events {
@@ -281,29 +338,27 @@
 
                        int num_ctors = 0, num_sctors = 0;
 
-                       R.ConstructorInfo[] minfo = type.GetConstructors (
-                               R.BindingFlags.DeclaredOnly | 
R.BindingFlags.Static | R.BindingFlags.Instance |
-                               R.BindingFlags.Public | 
R.BindingFlags.NonPublic);
-
-                       foreach (R.ConstructorInfo method in minfo) {
+                       foreach (Cecil.IMethod method in type.Constructors) {
                                if (method.IsStatic)
                                        num_sctors++;
                                else
                                        num_ctors++;
                        }
 
-                       constructors = new MonoMethodInfo [num_ctors];
-                       static_constructors = new MonoMethodInfo [num_sctors];
+                       constructors = new MonoMethodInfo [num_methods];
+                       static_constructors = new MonoMethodInfo [num_smethods];
 
-                       int pos = 0, spos = 0;
-                       for (int i = 0; i < minfo.Length; i++) {
-                               if (minfo [i].IsStatic) {
-                                       static_constructors [spos] = new 
MonoMethodInfo (this, spos, minfo [i]);
+                       int pos = 0, spos = 0, i = 0;
+                       foreach (Cecil.IMethod method in type.Constructors) {
+                               if (method.IsStatic) {
+                                       static_constructors [spos] = new 
MonoMethodInfo (this, spos, method);
                                        spos++;
                                } else {
-                                       constructors [pos] = new MonoMethodInfo 
(this, pos, minfo [i]);
+                                       constructors [pos] = new MonoMethodInfo 
(this, pos, method);
                                        pos++;
                                }
+
+                               i++;
                        }
                }
 

Modified: branches/debugger-cecil/backends/mono/MonoEnumType.cs
===================================================================
--- branches/debugger-cecil/backends/mono/MonoEnumType.cs       2005-07-13 
20:21:01 UTC (rev 47285)
+++ branches/debugger-cecil/backends/mono/MonoEnumType.cs       2005-07-13 
22:15:05 UTC (rev 47286)
@@ -1,7 +1,7 @@
 using System;
 using System.Text;
-using R = System.Reflection;
 using C = Mono.CompilerServices.SymbolWriter;
+using Cecil = Mono.Cecil;
 
 namespace Mono.Debugger.Languages.Mono
 {
@@ -10,9 +10,13 @@
                MonoFieldInfo[] fields;
                MonoFieldInfo[] static_fields;
 
-               public MonoEnumType (MonoSymbolFile file, Type type)
+               Cecil.ITypeDefinition type;
+
+               public MonoEnumType (MonoSymbolFile file, Cecil.ITypeDefinition 
type)
                        : base (file, TargetObjectKind.Enum, type)
-               { }
+               {
+                       this.type = type;
+               }
 
                public override bool IsByRef {
                        get { return !type.IsValueType; }
@@ -25,11 +29,11 @@
 
                        int num_fields = 0, num_sfields = 0;
 
-                       R.FieldInfo[] finfo = type.GetFields (
-                               R.BindingFlags.DeclaredOnly | 
R.BindingFlags.Static | R.BindingFlags.Instance |
-                               R.BindingFlags.Public | 
R.BindingFlags.NonPublic);
+                       foreach (Cecil.IFieldDefinition field in type.Fields) {
+                               if (!finfo.Attributes & 
(Cecil.FieldAttributes.FieldAccessMask | Cecil.FieldAttributes.Static |
+                                                        
Cecil.FieldAttributes.Instance))
+                                 continue;
 
-                       foreach (R.FieldInfo field in finfo) {
                                if (field.IsStatic)
                                        num_sfields++;
                                else
@@ -39,8 +43,8 @@
                        fields = new MonoFieldInfo [num_fields];
                        static_fields = new MonoFieldInfo [num_sfields];
 
-                       int pos = 0, spos = 0;
-                       for (int i = 0; i < finfo.Length; i++) {
+                       int pos = 0, spos = 0, i = 0;
+                       foreach (Cecil.IFieldDefinition field in type.Fields) {
                                if (finfo [i].IsStatic) {
                                        static_fields [spos] = new 
MonoFieldInfo (File, spos, i, finfo [i]);
                                        spos++;
@@ -50,6 +54,8 @@
                                        fields [pos] = new MonoFieldInfo (File, 
pos, i, finfo [i]);
                                        pos++;
                                }
+
+                               i++;
                        }
                        if (pos > 1)
                                throw new InternalError ("Mono enum type has 
more than one instance field.");

Modified: branches/debugger-cecil/backends/mono/MonoFunctionType.cs
===================================================================
--- branches/debugger-cecil/backends/mono/MonoFunctionType.cs   2005-07-13 
20:21:01 UTC (rev 47285)
+++ branches/debugger-cecil/backends/mono/MonoFunctionType.cs   2005-07-13 
22:15:05 UTC (rev 47286)
@@ -1,40 +1,39 @@
 using System;
 using System.Collections;
-using R = System.Reflection;
 using C = Mono.CompilerServices.SymbolWriter;
+using Cecil = Mono.Cecil;
 
 namespace Mono.Debugger.Languages.Mono
 {
        internal class MonoFunctionType : MonoType, ITargetFunctionType
        {
                MonoClassType klass;
-               R.MethodBase method_info;
+               Cecil.IMethodDefinition method_info;
                MonoType return_type;
                MonoType[] parameter_types;
                bool has_return_type;
                int index;
 
-               public MonoFunctionType (MonoSymbolFile file, MonoClassType 
klass, R.MethodBase mbase, int index)
-                       : base (file, TargetObjectKind.Function, 
mbase.ReflectedType)
+               public MonoFunctionType (MonoSymbolFile file, MonoClassType 
klass, Cecil.IMethodDefinition mdef, int index)
+                       : base (file, TargetObjectKind.Function, 
mdef.DeclaringType)
                {
                        this.klass = klass;
-                       this.method_info = mbase;
+                       this.method_info = mdef;
                        this.index = index;
 
                        Type rtype;
-                       if (mbase is R.ConstructorInfo) {
-                               rtype = mbase.DeclaringType;
+                       if (mdef is R.ConstructorInfo) {
+                               rtype = mdef.DeclaringType;
                                has_return_type = true;
                        } else {
-                               rtype = ((R.MethodInfo) mbase).ReturnType;
+                               rtype = mdef.ReturnType.ReturnType;
                                has_return_type = rtype != typeof (void);
                        }
                        return_type = file.LookupMonoType (rtype);
 
-                       R.ParameterInfo[] pinfo = mbase.GetParameters ();
-                       parameter_types = new MonoType [pinfo.Length];
-                       for (int i = 0; i < parameter_types.Length; i++)
-                               parameter_types [i] = file.LookupMonoType 
(pinfo [i].ParameterType);
+                       parameter_types = new MonoType [mdef.Parameters.Count];
+                       for (int i = 0; i < mdef.Parameters.Count; i++)
+                               parameter_types [i] = file.LookupMonoType 
(mdef.Parameters[i].ParameterType);
                }
 
                public override bool IsByRef {

Modified: branches/debugger-cecil/backends/mono/MonoFundamentalType.cs
===================================================================
--- branches/debugger-cecil/backends/mono/MonoFundamentalType.cs        
2005-07-13 20:21:01 UTC (rev 47285)
+++ branches/debugger-cecil/backends/mono/MonoFundamentalType.cs        
2005-07-13 22:15:05 UTC (rev 47286)
@@ -8,9 +8,12 @@
                protected readonly int size;
                protected readonly TargetAddress klass_address;
 
-               public MonoFundamentalType (MonoSymbolFile file, Type type, int 
size, TargetAddress klass)
+               protected readonly Cecil.ITypeDefinition type;
+
+               public MonoFundamentalType (MonoSymbolFile file, 
Cecil.ITypeDefinition type, int size, TargetAddress klass)
                        : base (file, TargetObjectKind.Fundamental, type)
                {
+                       this.type = type;
                        this.size = size;
                        this.klass_address = klass;
                        this.Heap = file.MonoLanguage.DataHeap;

Modified: branches/debugger-cecil/backends/mono/MonoLanguageBackend.cs
===================================================================
--- branches/debugger-cecil/backends/mono/MonoLanguageBackend.cs        
2005-07-13 20:21:01 UTC (rev 47285)
+++ branches/debugger-cecil/backends/mono/MonoLanguageBackend.cs        
2005-07-13 22:15:05 UTC (rev 47286)
@@ -1,7 +1,6 @@
 using System;
 using System.IO;
 using System.Text;
-using R = System.Reflection;
 using System.Runtime.InteropServices;
 using System.Collections;
 using System.Threading;
@@ -273,7 +272,7 @@
                        return true;
                }
 
-               public MonoType LookupMonoType (Type type)
+               public MonoType LookupMonoType (Cecil.ITypeReference type)
                {
                        MonoSymbolFile file = (MonoSymbolFile) assembly_hash 
[type.Assembly];
                        if (file == null) {

Modified: branches/debugger-cecil/backends/mono/MonoMember.cs
===================================================================
--- branches/debugger-cecil/backends/mono/MonoMember.cs 2005-07-13 20:21:01 UTC 
(rev 47285)
+++ branches/debugger-cecil/backends/mono/MonoMember.cs 2005-07-13 22:15:05 UTC 
(rev 47286)
@@ -1,20 +1,20 @@
 using System;
 using System.Text;
-using R = System.Reflection;
 using C = Mono.CompilerServices.SymbolWriter;
+using Cecil = Mono.Cecil;
 
 namespace Mono.Debugger.Languages.Mono
 {
        internal abstract class MonoMember : ITargetMemberInfo
        {
                public readonly MonoSymbolFile File;
-               public readonly R.MemberInfo MemberInfo;
+               public readonly Cecil.IMemberReference MemberInfo;
                public readonly int Index;
                public readonly int Position;
                public readonly bool IsStatic;
 
-               public MonoMember (MonoSymbolFile file, R.MemberInfo minfo, int 
index, int pos,
-                                        bool is_static)
+               public MonoMember (MonoSymbolFile file, Cecil.IMemberReference 
minfo, int index, int pos,
+                                  bool is_static)
                {
                        this.File = file;
                        this.MemberInfo = minfo;
@@ -56,9 +56,9 @@
        {
                MonoType type;
 
-               public readonly R.FieldInfo FieldInfo;
+               public readonly Cecil.IFieldDefinition FieldInfo;
 
-               public MonoFieldInfo (MonoSymbolFile file, int index, int pos, 
R.FieldInfo finfo)
+               public MonoFieldInfo (MonoSymbolFile file, int index, int pos, 
Cecil.IFieldDefinition finfo)
                        : base (file, finfo, index, pos, finfo.IsStatic)
                {
                        FieldInfo = finfo;
@@ -85,7 +85,7 @@
                        // field.  we need to take into account
                        // finfo.IsStatic, though.
                        if (FieldInfo.DeclaringType.IsEnum) {
-                               object value = FieldInfo.GetValue (null);
+                               object value = FieldInfo.Constant;
                          
                                return type.File.MonoLanguage.CreateInstance 
(frame, (int)value);
                        }
@@ -103,11 +103,11 @@
 
        internal class MonoMethodInfo : MonoMember, ITargetMethodInfo
        {
-               public readonly R.MethodBase MethodInfo;
+               public readonly Cecil.IMethodDefinition MethodInfo;
                public readonly MonoFunctionType FunctionType;
                public readonly MonoClassType Klass;
 
-               internal MonoMethodInfo (MonoClassType klass, int index, 
R.MethodBase minfo)
+               internal MonoMethodInfo (MonoClassType klass, int index, 
Cecil.IMethodDefinition minfo)
                        : base (klass.File, minfo, index, 
C.MonoDebuggerSupport.GetMethodIndex (minfo),
                                minfo.IsStatic)
                {
@@ -130,7 +130,7 @@
                        get {
                                StringBuilder sb = new StringBuilder ();
                                bool first = true;
-                               foreach (R.ParameterInfo pinfo in 
MethodInfo.GetParameters ()) {
+                               foreach (Cecil.IParameterDefinition pinfo in 
MethodInfo.Parameters) {
                                        if (first)
                                                first = false;
                                        else
@@ -161,10 +161,10 @@
        {
                MonoType type;
                public readonly MonoClassType Klass;
-               public readonly R.EventInfo EventInfo;
+               public readonly Cecil.IEventDefinition EventInfo;
                public readonly MonoFunctionType AddType, RemoveType;
 
-               internal MonoEventInfo (MonoClassType klass, int index, 
R.EventInfo einfo,
+               internal MonoEventInfo (MonoClassType klass, int index, 
Cecil.IEventDefinition einfo,
                                        bool is_static)
                        : base (klass.File, einfo, index, index, is_static)
                {
@@ -173,13 +173,13 @@
                        Klass = klass;
 
                        EventInfo = einfo;
-                       type = File.MonoLanguage.LookupMonoType 
(einfo.EventHandlerType);
+                       type = File.MonoLanguage.LookupMonoType 
(einfo.EventType);
 
-                       R.MethodInfo add = EventInfo.GetAddMethod ();
+                       Cecil.IMethodDefinition add = EventInfo.AddMethod;
                        pos = C.MonoDebuggerSupport.GetMethodIndex (add);
                        AddType = new MonoFunctionType (File, Klass, add, pos - 
1);
 
-                       R.MethodInfo remove = EventInfo.GetRemoveMethod ();
+                       Cecil.IMethodDefinition remove = EventInfo.RemoveMethod;
                        pos = C.MonoDebuggerSupport.GetMethodIndex (remove);
                        RemoveType = new MonoFunctionType (File, Klass, remove, 
pos - 1);
                }
@@ -210,10 +210,10 @@
        {
                MonoType type;
                public readonly MonoClassType Klass;
-               public readonly R.PropertyInfo PropertyInfo;
+               public readonly Cecil.IPropertyDefinition PropertyInfo;
                public readonly MonoFunctionType GetterType, SetterType;
 
-               internal MonoPropertyInfo (MonoClassType klass, int index, 
R.PropertyInfo pinfo,
+               internal MonoPropertyInfo (MonoClassType klass, int index, 
Cecil.IPropertyDefinition pinfo,
                                           bool is_static)
                        : base (klass.File, pinfo, index, index, is_static)
                {
@@ -221,14 +221,14 @@
                        PropertyInfo = pinfo;
                        type = File.MonoLanguage.LookupMonoType 
(pinfo.PropertyType);
 
-                       if (PropertyInfo.CanRead) {
-                               R.MethodInfo getter = PropertyInfo.GetGetMethod 
(true);
+                       if (PropertyInfo.GetMethod != null) {
+                               Cecil.IMethodDefinition getter = 
PropertyInfo.GetMethod;
                                int pos = C.MonoDebuggerSupport.GetMethodIndex 
(getter);
                                GetterType = new MonoFunctionType (File, Klass, 
getter, pos - 1);
                        }
 
-                       if (PropertyInfo.CanWrite) {
-                               R.MethodInfo setter = PropertyInfo.GetSetMethod 
(true);
+                       if (PropertyInfo.SetMethod != null) {
+                               Cecil.IMethodDefinition setter = 
PropertyInfo.SetMethod;
                                int pos = C.MonoDebuggerSupport.GetMethodIndex 
(setter);
                                SetterType = new MonoFunctionType (File, Klass, 
setter, pos - 1);
                        }
@@ -239,12 +239,12 @@
                }
 
                public bool CanRead {
-                       get { return PropertyInfo.CanRead; }
+                       get { return PropertyInfo.GetMethod != null; }
                }
 
                ITargetFunctionType ITargetPropertyInfo.Getter {
                        get {
-                               if (!CanRead)
+                               if (PropertyInfo.GetMethod == null)
                                        throw new InvalidOperationException ();
 
                                return GetterType;
@@ -252,14 +252,12 @@
                }
 
                public bool CanWrite {
-                       get {
-                               return PropertyInfo.CanWrite;
-                       }
+                       get { return PropertyInfo.SetMethod != null; }
                }
 
                ITargetFunctionType ITargetPropertyInfo.Setter {
                        get {
-                               if (!CanWrite)
+                               if (PropertyInfo.SetMethod == null)
                                        throw new InvalidOperationException ();
 
                                return SetterType;
@@ -268,7 +266,7 @@
 
                internal ITargetObject Get (TargetLocation location)
                {
-                       if (!PropertyInfo.CanRead)
+                       if (PropertyInfo.GetMethod == null)
                                throw new InvalidOperationException ();
 
                        MonoFunctionTypeInfo getter = GetterType.GetTypeInfo () 
as MonoFunctionTypeInfo;
@@ -285,7 +283,7 @@
 
                internal ITargetObject Get (StackFrame frame)
                {
-                       if (!PropertyInfo.CanRead)
+                       if (PropertyInfo.SetMethod == null)
                                throw new InvalidOperationException ();
 
                        MonoFunctionTypeInfo getter = GetterType.GetTypeInfo () 
as MonoFunctionTypeInfo;

Modified: branches/debugger-cecil/backends/mono/MonoObjectType.cs
===================================================================
--- branches/debugger-cecil/backends/mono/MonoObjectType.cs     2005-07-13 
20:21:01 UTC (rev 47285)
+++ branches/debugger-cecil/backends/mono/MonoObjectType.cs     2005-07-13 
22:15:05 UTC (rev 47286)
@@ -1,4 +1,5 @@
 using System;
+using Cecil = Mono.Cecil;
 
 namespace Mono.Debugger.Languages.Mono
 {
@@ -7,7 +8,7 @@
                int size;
                TargetAddress klass_address;
 
-               public MonoObjectType (MonoSymbolFile file, Type type, int 
size, TargetAddress klass)
+               public MonoObjectType (MonoSymbolFile file, 
Cecil.ITypeReference type, int size, TargetAddress klass)
                        : base (file, TargetObjectKind.Pointer, type)
                {
                        this.size = size;

Modified: branches/debugger-cecil/backends/mono/MonoOpaqueType.cs
===================================================================
--- branches/debugger-cecil/backends/mono/MonoOpaqueType.cs     2005-07-13 
20:21:01 UTC (rev 47285)
+++ branches/debugger-cecil/backends/mono/MonoOpaqueType.cs     2005-07-13 
22:15:05 UTC (rev 47286)
@@ -1,11 +1,12 @@
 using System;
+using Cecil = Mono.Cecil;
 
 namespace Mono.Debugger.Languages.Mono
 {
        internal class MonoOpaqueType : MonoType
        {
-               public MonoOpaqueType (MonoSymbolFile file, Type type)
-                       : base (file, TargetObjectKind.Opaque, type)
+               public MonoOpaqueType (MonoSymbolFile file, 
Cecil.ITypeReference typeref)
+                       : base (file, TargetObjectKind.Opaque, typeref)
                { }
 
                public override bool IsByRef {

Modified: branches/debugger-cecil/backends/mono/MonoStringType.cs
===================================================================
--- branches/debugger-cecil/backends/mono/MonoStringType.cs     2005-07-13 
20:21:01 UTC (rev 47285)
+++ branches/debugger-cecil/backends/mono/MonoStringType.cs     2005-07-13 
22:15:05 UTC (rev 47286)
@@ -1,4 +1,5 @@
 using System;
+using Cecil = Mono.Cecil;
 
 namespace Mono.Debugger.Languages.Mono
 {
@@ -8,7 +9,7 @@
 
                protected readonly TargetAddress CreateString;
 
-               public MonoStringType (MonoSymbolFile file, Type type, int 
object_size,
+               public MonoStringType (MonoSymbolFile file, 
Cecil.ITypeDefinition type, int object_size,
                                       int size, TargetAddress klass)
                        : base (file, type, size, klass)
                {
@@ -25,7 +26,7 @@
                        get { return true; }
                }
 
-               new public static bool Supports (Type type)
+               new public static bool Supports (Cecil.ITypeReference type)
                {
                        return type == typeof (string);
                }

Modified: branches/debugger-cecil/backends/mono/MonoSymbolFile.cs
===================================================================
--- branches/debugger-cecil/backends/mono/MonoSymbolFile.cs     2005-07-13 
20:21:01 UTC (rev 47285)
+++ branches/debugger-cecil/backends/mono/MonoSymbolFile.cs     2005-07-13 
22:15:05 UTC (rev 47286)
@@ -1,7 +1,6 @@
 using System;
 using System.Collections;
 using System.Text;
-using R = System.Reflection;
 using C = Mono.CompilerServices.SymbolWriter;
 using Mono.Debugger;
 using Mono.Debugger.Backends;
@@ -201,8 +200,8 @@
        internal class MonoSymbolFile : Module, ISymbolFile, 
ISimpleSymbolTable, IDisposable
        {
                internal readonly int Index;
-               internal readonly R.Assembly Assembly;
-               internal readonly R.Module Module;
+               internal readonly Cecil.IAssemblyDefinition Assembly;
+               internal readonly Cecil.IMethodDefinition Module;
                internal readonly TargetAddress MonoImage;
                internal readonly string ImageFile;
                internal readonly C.MonoSymbolFile File;
@@ -252,20 +251,20 @@
                        MonoImage = memory.ReadAddress (address);
                        address += address_size;
 
-                       Assembly = R.Assembly.LoadFrom (ImageFile);
-                       Module = Assembly.GetModules () [0];
+                       Assembly = Cecil.AssemblyFactory.GetAssembly 
(ImageFile);
+                       Module = Assembly.MainModule;
 
                        Report.Debug (DebugFlags.JitSymtab, "SYMBOL TABLE 
READER: {0}", ImageFile);
 
                        try {
-                               File = C.MonoSymbolFile.ReadSymbolFile 
(Assembly);
+                               File = C.MonoSymbolFile.ReadSymbolFile 
(ImageFile);
                        } catch (Exception ex) {
                                Console.WriteLine (ex.Message);
                        }
 
                        symtab = new MonoSymbolTable (this);
 
-                       name = Assembly.GetName (true).Name;
+                       name = Assembly.Name.FullName;
 
                        backend.ModuleManager.AddModule (this);
 
@@ -345,19 +344,26 @@
                        }
                }
 
-               public MonoType LookupMonoType (Type type)
+               public MonoType LookupMonoType (Cecil.ITypeReference type)
                {
                        MonoType result = (MonoType) type_hash [type];
                        if (result != null)
                                return result;
 
-                       int rank = type.GetArrayRank ();
-                       if (rank > 0)
-                               result = new MonoArrayType (this, type);
+                       if (type is Cecil.IArrayType)
+                               result = new MonoArrayType (this, 
(Cecil.IArrayType)type);
+                       else if (type is Cecil.ITypeDefinition)
+                               result = new MonoClassType (this, 
(Cecil.ITypeDefinition)type);
+#if CECIL_NOTYET
                        else if (type.IsEnum)
                                result = new MonoEnumType (this, type);
-                       else
-                               result = new MonoClassType (this, type);
+#endif
+                       else {
+                               // XXX should this be here?  do we ever
+                               // call LookupMonoType on something that
+                               // won't be defined?
+                               result = new MonoOpaqueType (this, type);
+                       }
 
                        type_hash.Add (type, result);
                        return result;
@@ -463,15 +469,15 @@
                        C.MethodEntry entry = File.GetMethod (index);
                        C.MethodSourceEntry source = File.GetMethodSource 
(index);
 
-                       R.MethodBase mbase = C.MonoDebuggerSupport.GetMethod (
+                       Cecil.IMethodDefinition mdef = 
C.MonoDebuggerSupport.GetMethod (
                                File.Assembly, entry.Token);
 
-                       StringBuilder sb = new StringBuilder 
(mbase.DeclaringType.FullName);
+                       StringBuilder sb = new StringBuilder 
(mdef.DeclaringType.FullName);
                        sb.Append (".");
-                       sb.Append (mbase.Name);
+                       sb.Append (mdef.Name);
                        sb.Append ("(");
                        bool first = true;
-                       foreach (R.ParameterInfo param in mbase.GetParameters 
()) {
+                       foreach (Cecil.Parameter param in mdef.Parameters) {
                                if (first)
                                        first = false;
                                else
@@ -541,10 +547,10 @@
                        SourceMethod method = GetSourceMethod (index);
                        C.MethodEntry entry = File.GetMethod (index);
 
-                       R.MethodBase mbase = C.MonoDebuggerSupport.GetMethod (
+                       Cecil.IMethodDefinition mdef = 
C.MonoDebuggerSupport.GetMethod (
                                File.Assembly, entry.Token);
 
-                       mono_method = new MonoMethod (this, method, entry, 
mbase);
+                       mono_method = new MonoMethod (this, method, entry, 
mdef);
                        method_hash.Add (index, mono_method);
                        return mono_method;
                }
@@ -606,7 +612,7 @@
                        MonoSymbolFile file;
                        SourceMethod info;
                        C.MethodEntry method;
-                       R.MethodBase rmethod;
+                       Cecil.IMethodDefinition mdef;
                        MonoClassType decl_type;
                        MonoType[] param_types;
                        MonoType[] local_types;
@@ -619,17 +625,17 @@
                        Hashtable load_handlers;
 
                        public MonoMethod (MonoSymbolFile file, SourceMethod 
info,
-                                          C.MethodEntry method, R.MethodBase 
rmethod)
+                                          C.MethodEntry method, 
Cecil.IMethodDefinition mdef)
                                : base (info.Name, file.ImageFile, file)
                        {
                                this.file = file;
                                this.info = info;
                                this.method = method;
-                               this.rmethod = rmethod;
+                               this.mdef = mdef;
                        }
 
                        public override object MethodHandle {
-                               get { return rmethod; }
+                               get { return mdef; }
                        }
 
                        public void Load (TargetBinaryReader dynamic_reader, 
AddressDomain domain)
@@ -656,11 +662,11 @@
                                if (has_variables || !is_loaded)
                                        return;
 
-                               R.ParameterInfo[] param_info = 
rmethod.GetParameters ();
-                               param_types = new MonoType [param_info.Length];
-                               parameters = new IVariable [param_info.Length];
-                               for (int i = 0; i < param_info.Length; i++) {
-                                       Type type = param_info 
[i].ParameterType;
+                               Cecil.IParameterCollection param_info = 
mdef.Parameters;
+                               param_types = new MonoType [param_info.Count];
+                               parameters = new IVariable [param_info.Count];
+                               for (int i = 0; i < param_info.Count; i++) {
+                                       Cecil.ITypeReference type = param_info 
[i].ParameterType;
 
                                        param_types [i] = 
file.MonoLanguage.LookupMonoType (type);
 
@@ -674,8 +680,8 @@
                                locals = new IVariable [method.NumLocals];
                                for (int i = 0; i < method.NumLocals; i++) {
                                        C.LocalVariableEntry local = 
method.Locals [i];
-                                       Type type = 
C.MonoDebuggerSupport.GetLocalTypeFromSignature (
-                                               file.Assembly, local.Signature);
+                                       Cecil.ITypeReference type = 
C.MonoDebuggerSupport.GetLocalTypeFromSignature (
+                                                                               
             file.Assembly, local.Signature);
 
                                        local_types [i] = 
file.MonoLanguage.LookupMonoType (type);
 
@@ -695,7 +701,7 @@
                                        }
                                }
 
-                               decl_type = (MonoClassType) 
file.MonoLanguage.LookupMonoType (rmethod.DeclaringType);
+                               decl_type = (MonoClassType) 
file.MonoLanguage.LookupMonoType (mdef.DeclaringType);
 
                                if (address.HasThis)
                                        this_var = new MonoVariable (
@@ -803,15 +809,14 @@
                                                                object 
user_data)
                        {
                                StringBuilder sb = new StringBuilder ();
-                               sb.Append (rmethod.ReflectedType.FullName);
+                               sb.Append (rmethod.DeclaringType.FullName);
                                sb.Append (":");
                                sb.Append (rmethod.Name);
                                sb.Append ("(");
-                               R.ParameterInfo[] pi = rmethod.GetParameters ();
-                               for (int i = 0; i < pi.Length; i++) {
+                               for (int i = 0; i < rmethod.Parameters.Count; 
i++) {
                                        if (i > 0)
                                                sb.Append (",");
-                                       sb.Append (GetTypeSignature (pi 
[i].ParameterType).Replace ('+','/'));
+                                       sb.Append (GetTypeSignature 
(rmethod.Parameters[i].ParameterType).Replace ('+','/'));
                                }
                                sb.Append (")");
                                string full_name = sb.ToString ();

Modified: branches/debugger-cecil/backends/mono/MonoType.cs
===================================================================
--- branches/debugger-cecil/backends/mono/MonoType.cs   2005-07-13 20:21:01 UTC 
(rev 47285)
+++ branches/debugger-cecil/backends/mono/MonoType.cs   2005-07-13 22:15:05 UTC 
(rev 47286)
@@ -1,23 +1,24 @@
 using System;
+using Mono.Cecil;
 
 namespace Mono.Debugger.Languages.Mono
 {
        internal abstract class MonoType : ITargetType
        {
-               protected readonly Type type;
+               protected readonly Cecil.ITypeReference typeref;
                protected readonly MonoSymbolFile file;
                protected readonly TargetObjectKind kind;
                protected MonoTypeInfo type_info;
 
-               public MonoType (MonoSymbolFile file, TargetObjectKind kind, 
Type type)
+               public MonoType (MonoSymbolFile file, TargetObjectKind kind, 
Cecil.ITypeReference typeref)
                {
                        this.file = file;
-                       this.type = type;
+                       this.typeref = typeref;
                        this.kind = kind;
                }
 
-               public Type Type {
-                       get { return type; }
+               public Cecil.ITypeReference Type {
+                       get { return typeref; }
                }
 
                public TargetObjectKind Kind {
@@ -29,15 +30,15 @@
                }
 
                public virtual string Name {
-                       get { return type.FullName; }
+                       get { return typeref.FullName; }
                }
 
                object ITargetType.TypeHandle {
-                       get { return type; }
+                       get { return typeref; }
                }
 
-               public Type TypeHandle {
-                       get { return type; }
+               public Cecil.ITypeReference TypeHandle {
+                       get { return typeref; }
                }
 
                public abstract bool IsByRef {

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

Reply via email to