Author: jbevain
Date: 2005-02-26 17:44:29 -0500 (Sat, 26 Feb 2005)
New Revision: 41247

Added:
   trunk/cecil/lib/Mono.Cecil/IMetadataScope.cs
Modified:
   trunk/cecil/lib/Mono.Cecil.Implem/ArrayType.cs
   trunk/cecil/lib/Mono.Cecil.Implem/FunctionPointerType.cs
   trunk/cecil/lib/Mono.Cecil.Implem/LazyReflectionReader.cs
   trunk/cecil/lib/Mono.Cecil.Implem/PinnedType.cs
   trunk/cecil/lib/Mono.Cecil.Implem/PointerType.cs
   trunk/cecil/lib/Mono.Cecil.Implem/ReferenceType.cs
   trunk/cecil/lib/Mono.Cecil.Implem/ReflectionReader.cs
   trunk/cecil/lib/Mono.Cecil.Implem/TypeDefinition.cs
   trunk/cecil/lib/Mono.Cecil.Implem/TypeReference.cs
   trunk/cecil/lib/Mono.Cecil/IAssemblyName.cs
   trunk/cecil/lib/Mono.Cecil/IModuleReference.cs
   trunk/cecil/lib/Mono.Cecil/ITypeReference.cs
   trunk/cecil/lib/cecil.csproj
Log:
add a scope information to types

Modified: trunk/cecil/lib/Mono.Cecil/IAssemblyName.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/IAssemblyName.cs 2005-02-26 22:09:48 UTC (rev 
41246)
+++ trunk/cecil/lib/Mono.Cecil/IAssemblyName.cs 2005-02-26 22:44:29 UTC (rev 
41247)
@@ -14,7 +14,7 @@
 
     using System;
 
-    public interface IAssemblyNameReference : IReflectionStructureVisitable {
+    public interface IAssemblyNameReference : IMetadataScope, 
IReflectionStructureVisitable {
 
         string Name { get; set; }
         string Culture { get; set; }

Added: trunk/cecil/lib/Mono.Cecil/IMetadataScope.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/IMetadataScope.cs        2005-02-26 22:09:48 UTC 
(rev 41246)
+++ trunk/cecil/lib/Mono.Cecil/IMetadataScope.cs        2005-02-26 22:44:29 UTC 
(rev 41247)
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2004 DotNetGuru and the individuals listed
+ * on the ChangeLog entries.
+ *
+ * Authors :
+ *   Jb Evain   ([EMAIL PROTECTED])
+ *
+ * This is a free software distributed under a MIT/X11 license
+ * See LICENSE.MIT file for more details
+ *
+ *****************************************************************************/
+
+namespace Mono.Cecil {
+
+    public interface IMetadataScope {
+    }
+}

Modified: trunk/cecil/lib/Mono.Cecil/IModuleReference.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/IModuleReference.cs      2005-02-26 22:09:48 UTC 
(rev 41246)
+++ trunk/cecil/lib/Mono.Cecil/IModuleReference.cs      2005-02-26 22:44:29 UTC 
(rev 41247)
@@ -12,7 +12,7 @@
 
 namespace Mono.Cecil {
 
-    public interface IModuleReference : IReflectionStructureVisitable {
+    public interface IModuleReference : IMetadataScope, 
IReflectionStructureVisitable {
 
         string Name { get; set; }
     }

Modified: trunk/cecil/lib/Mono.Cecil/ITypeReference.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/ITypeReference.cs        2005-02-26 22:09:48 UTC 
(rev 41246)
+++ trunk/cecil/lib/Mono.Cecil/ITypeReference.cs        2005-02-26 22:44:29 UTC 
(rev 41247)
@@ -13,7 +13,9 @@
 namespace Mono.Cecil {
 
     public interface ITypeReference : IType, IMemberReference, 
ICustomAttributeProvider {
+
         string Namespace { get; set; }
+        IMetadataScope Scope { get; }
 
         string FullName { get; }
     }

Modified: trunk/cecil/lib/Mono.Cecil.Implem/ArrayType.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil.Implem/ArrayType.cs      2005-02-26 22:09:48 UTC 
(rev 41246)
+++ trunk/cecil/lib/Mono.Cecil.Implem/ArrayType.cs      2005-02-26 22:44:29 UTC 
(rev 41247)
@@ -42,6 +42,10 @@
             set { m_elementsType.Namespace = value; }
         }
 
+        public override IMetadataScope Scope {
+            get { return m_elementsType.Scope; }
+        }
+
         public override string FullName {
             get {
                 StringBuilder sb = new StringBuilder ();

Modified: trunk/cecil/lib/Mono.Cecil.Implem/FunctionPointerType.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil.Implem/FunctionPointerType.cs    2005-02-26 
22:09:48 UTC (rev 41246)
+++ trunk/cecil/lib/Mono.Cecil.Implem/FunctionPointerType.cs    2005-02-26 
22:44:29 UTC (rev 41247)
@@ -55,6 +55,10 @@
             set { throw new InvalidOperationException (); }
         }
 
+        public override IMetadataScope Scope {
+            get { return m_function.DeclaringType.Scope; }
+        }
+
         public override string FullName {
             get { return m_function.ToString (); }
         }

Modified: trunk/cecil/lib/Mono.Cecil.Implem/LazyReflectionReader.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil.Implem/LazyReflectionReader.cs   2005-02-26 
22:09:48 UTC (rev 41246)
+++ trunk/cecil/lib/Mono.Cecil.Implem/LazyReflectionReader.cs   2005-02-26 
22:44:29 UTC (rev 41247)
@@ -68,6 +68,8 @@
 
                 //TODO: WRITE HERE
             }
+
+            ext.Loaded = true;
         }
 
         public override void Visit (IOverrideCollection meths)

Modified: trunk/cecil/lib/Mono.Cecil.Implem/PinnedType.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil.Implem/PinnedType.cs     2005-02-26 22:09:48 UTC 
(rev 41246)
+++ trunk/cecil/lib/Mono.Cecil.Implem/PinnedType.cs     2005-02-26 22:44:29 UTC 
(rev 41247)
@@ -31,6 +31,10 @@
             set { m_pinnedType.Namespace = value; }
         }
 
+        public override IMetadataScope Scope {
+            get { return m_pinnedType.Scope; }
+        }
+
         public ITypeReference Type {
             get { return m_pinnedType; }
             set { m_pinnedType = value; }

Modified: trunk/cecil/lib/Mono.Cecil.Implem/PointerType.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil.Implem/PointerType.cs    2005-02-26 22:09:48 UTC 
(rev 41246)
+++ trunk/cecil/lib/Mono.Cecil.Implem/PointerType.cs    2005-02-26 22:44:29 UTC 
(rev 41247)
@@ -31,6 +31,10 @@
             set { m_pointedType.Namespace = value; }
         }
 
+        public override IMetadataScope Scope {
+            get { return m_pointedType.Scope; }
+        }
+
         public ITypeReference ElementType {
             get { return m_pointedType; }
             set { m_pointedType = value; }

Modified: trunk/cecil/lib/Mono.Cecil.Implem/ReferenceType.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil.Implem/ReferenceType.cs  2005-02-26 22:09:48 UTC 
(rev 41246)
+++ trunk/cecil/lib/Mono.Cecil.Implem/ReferenceType.cs  2005-02-26 22:44:29 UTC 
(rev 41247)
@@ -31,6 +31,10 @@
             set { m_type.Namespace = value; }
         }
 
+        public override IMetadataScope Scope {
+            get { return m_type.Scope; }
+        }
+
         public ITypeReference ElementType {
             get { return m_type; }
             set { m_type = value; }

Modified: trunk/cecil/lib/Mono.Cecil.Implem/ReflectionReader.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil.Implem/ReflectionReader.cs       2005-02-26 
22:09:48 UTC (rev 41246)
+++ trunk/cecil/lib/Mono.Cecil.Implem/ReflectionReader.cs       2005-02-26 
22:44:29 UTC (rev 41247)
@@ -191,10 +191,16 @@
 
                 for (int i = 0; i < typesRef.Rows.Count; i++) {
                     TypeRefRow type = typesRef [i];
+                    IMetadataScope scope = null;
+                    if (type.ResolutionScope.TokenType == TokenType.Assembly)
+                        scope = m_module.AssemblyReferences [(int) 
type.ResolutionScope.RID - 1];
+                    else if (type.ResolutionScope.TokenType == 
TokenType.ModuleRef)
+                        scope = m_module.ModuleReferences [(int) 
type.ResolutionScope.RID - 1];
+
                     TypeReference t = new TypeReference (
                         m_root.Streams.StringsHeap [type.Name],
                         m_root.Streams.StringsHeap [type.Namespace],
-                        m_module);
+                        m_module, scope);
 
                     m_typeRefs [i] = t;
                     (m_module.TypeReferences as TypeReferenceCollection) 
[t.FullName] = t;

Modified: trunk/cecil/lib/Mono.Cecil.Implem/TypeDefinition.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil.Implem/TypeDefinition.cs 2005-02-26 22:09:48 UTC 
(rev 41246)
+++ trunk/cecil/lib/Mono.Cecil.Implem/TypeDefinition.cs 2005-02-26 22:44:29 UTC 
(rev 41247)
@@ -114,7 +114,8 @@
             }
         }
 
-        public TypeDefinition (string name, string ns, TypeAttributes attrs, 
ModuleDefinition module) : base (name, ns, module)
+        public TypeDefinition (string name, string ns, TypeAttributes attrs, 
ModuleDefinition module) :
+            base (name, ns, module, module.Assembly.Name)
         {
             m_hasInfo = false;
             m_attributes = attrs;

Modified: trunk/cecil/lib/Mono.Cecil.Implem/TypeReference.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil.Implem/TypeReference.cs  2005-02-26 22:09:48 UTC 
(rev 41246)
+++ trunk/cecil/lib/Mono.Cecil.Implem/TypeReference.cs  2005-02-26 22:44:29 UTC 
(rev 41247)
@@ -21,6 +21,7 @@
         private string m_name;
         private string m_namespace;
         private ITypeReference m_decType;
+        private IMetadataScope m_scope;
 
         private CustomAttributeCollection m_customAttrs;
 
@@ -55,6 +56,14 @@
             }
         }
 
+        public virtual IMetadataScope Scope {
+            get {
+                if (m_decType != null)
+                    return m_decType.Scope;
+                return m_scope;
+            }
+        }
+
         public virtual string FullName {
             get {
                 if (m_decType != null)
@@ -73,9 +82,10 @@
             m_namespace = ns;
         }
 
-        public TypeReference (string name, string ns, ModuleDefinition module) 
: this (name, ns)
+        public TypeReference (string name, string ns, ModuleDefinition module, 
IMetadataScope scope) : this (name, ns)
         {
             m_module = module;
+            m_scope = scope;
         }
 
         public virtual void Accept (IReflectionVisitor visitor)

Modified: trunk/cecil/lib/cecil.csproj
===================================================================
--- trunk/cecil/lib/cecil.csproj        2005-02-26 22:09:48 UTC (rev 41246)
+++ trunk/cecil/lib/cecil.csproj        2005-02-26 22:44:29 UTC (rev 41247)
@@ -246,6 +246,7 @@
         <Compile Include="Mono.Cecil\ILinkedResource.cs"/>
         <Compile Include="Mono.Cecil\ImageFormatException.cs"/>
         <Compile Include="Mono.Cecil\IMember.cs"/>
+        <Compile Include="Mono.Cecil\IMetadataScope.cs"/>
         <Compile Include="Mono.Cecil\IMethod.cs"/>
         <Compile Include="Mono.Cecil\IMethodDefinitionCollection.cs"/>
         <Compile Include="Mono.Cecil\IMethodReturnType.cs"/>

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

Reply via email to