Author: jbevain
Date: 2006-01-17 12:18:21 -0500 (Tue, 17 Jan 2006)
New Revision: 55684

Modified:
   trunk/cecil/lib/ChangeLog
   trunk/cecil/lib/Mono.Cecil/AssemblyName.cs
   trunk/cecil/lib/Mono.Cecil/IMetadataScope.cs
   trunk/cecil/lib/Mono.Cecil/ModuleReference.cs
   trunk/cecil/lib/Mono.Cecil/ReflectionWriter.cs
   trunk/cecil/lib/Mono.Cecil/StructureReader.cs
Log:
2006-01-18  Jb Evain  <[EMAIL PROTECTED]>

        * Mono.Cecil/ModuleReference.cs
          Mono.Cecil/AssemblyName.cs
          Mono.Cecil/StructureReader.cs
          Mono.Cecil/IMetadataScope.cs:
                Make IMetadataScope implement IMetadataTokenProvider.
        * Mono.Cecil/ReflectionWriter.cs:
                Fix a typo when saving nested type refs.


Modified: trunk/cecil/lib/ChangeLog
===================================================================
--- trunk/cecil/lib/ChangeLog   2006-01-17 17:15:59 UTC (rev 55683)
+++ trunk/cecil/lib/ChangeLog   2006-01-17 17:18:21 UTC (rev 55684)
@@ -1,3 +1,13 @@
+2006-01-18  Jb Evain  <[EMAIL PROTECTED]>
+
+       * Mono.Cecil/ModuleReference.cs
+         Mono.Cecil/AssemblyName.cs
+         Mono.Cecil/StructureReader.cs
+         Mono.Cecil/IMetadataScope.cs:
+               Make IMetadataScope implement IMetadataTokenProvider.
+       * Mono.Cecil/ReflectionWriter.cs:
+               Fix a typo when saving nested type refs.
+
 2006-01-17  Jb Evain  <[EMAIL PROTECTED]>
 
        * Mono.Cecil/ArrayType.cs

Modified: trunk/cecil/lib/Mono.Cecil/AssemblyName.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/AssemblyName.cs  2006-01-17 17:15:59 UTC (rev 
55683)
+++ trunk/cecil/lib/Mono.Cecil/AssemblyName.cs  2006-01-17 17:18:21 UTC (rev 
55684)
@@ -44,6 +44,7 @@
                byte [] m_publicKeyToken;
                AssemblyHashAlgorithm m_hashAlgo;
                byte [] m_hash;
+               MetadataToken m_token;
 
                public string Name {
                        get { return m_name; }
@@ -137,6 +138,11 @@
                        set { m_hash = value; }
                }
 
+               public MetadataToken MetadataToken {
+                       get { return m_token; }
+                       set { m_token = value; }
+               }
+
                public AssemblyNameReference () : this (string.Empty, 
string.Empty, new Version (0, 0, 0, 0))
                {
                }

Modified: trunk/cecil/lib/Mono.Cecil/IMetadataScope.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/IMetadataScope.cs        2006-01-17 17:15:59 UTC 
(rev 55683)
+++ trunk/cecil/lib/Mono.Cecil/IMetadataScope.cs        2006-01-17 17:18:21 UTC 
(rev 55684)
@@ -28,7 +28,7 @@
 
 namespace Mono.Cecil {
 
-       public interface IMetadataScope {
+       public interface IMetadataScope : IMetadataTokenProvider {
                string Name { get; set; }
        }
 }

Modified: trunk/cecil/lib/Mono.Cecil/ModuleReference.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/ModuleReference.cs       2006-01-17 17:15:59 UTC 
(rev 55683)
+++ trunk/cecil/lib/Mono.Cecil/ModuleReference.cs       2006-01-17 17:18:21 UTC 
(rev 55684)
@@ -29,16 +29,23 @@
 namespace Mono.Cecil {
 
        using Mono.Cecil;
+       using Mono.Cecil.Metadata;
 
        public class ModuleReference : IModuleReference {
 
                string m_name;
+               MetadataToken m_token;
 
                public string Name {
                        get { return m_name; }
                        set { m_name = value; }
                }
 
+               public MetadataToken MetadataToken {
+                       get { return m_token; }
+                       set { m_token = value; }
+               }
+
                public ModuleReference (string name)
                {
                        m_name = name;

Modified: trunk/cecil/lib/Mono.Cecil/ReflectionWriter.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/ReflectionWriter.cs      2006-01-17 17:15:59 UTC 
(rev 55683)
+++ trunk/cecil/lib/Mono.Cecil/ReflectionWriter.cs      2006-01-17 17:18:21 UTC 
(rev 55684)
@@ -265,7 +265,7 @@
 
                                if (t.DeclaringType != null)
                                        scope = new MetadataToken 
(TokenType.TypeRef, GetRidFor (t.DeclaringType));
-                               if (t.Scope is AssemblyNameReference)
+                               else if (t.Scope is AssemblyNameReference)
                                        scope = new MetadataToken 
(TokenType.AssemblyRef,
                                                GetRidFor 
((AssemblyNameReference) t.Scope));
                                else if (t.Scope is ModuleDefinition)

Modified: trunk/cecil/lib/Mono.Cecil/StructureReader.cs
===================================================================
--- trunk/cecil/lib/Mono.Cecil/StructureReader.cs       2006-01-17 17:15:59 UTC 
(rev 55683)
+++ trunk/cecil/lib/Mono.Cecil/StructureReader.cs       2006-01-17 17:18:21 UTC 
(rev 55684)
@@ -98,6 +98,7 @@
                                arow.MajorVersion, arow.MinorVersion,
                                arow.BuildNumber, arow.RevisionNumber);
                        name.HashAlgorithm = arow.HashAlgId;
+                       name.MetadataToken = new MetadataToken 
(TokenType.Assembly, 1);
                }
 
                public override void VisitAssemblyNameReferenceCollection 
(AssemblyNameReferenceCollection names)
@@ -115,6 +116,7 @@
                                                                 
arRow.BuildNumber, arRow.RevisionNumber));
                                aname.PublicKeyToken = 
m_img.MetadataRoot.Streams.BlobHeap.Read (arRow.PublicKeyOrToken);
                                aname.Hash = 
m_img.MetadataRoot.Streams.BlobHeap.Read (arRow.HashValue);
+                               aname.MetadataToken = new MetadataToken 
(TokenType.AssemblyRef, (uint) i + 1);
                                names.Add (aname);
                        }
                }
@@ -176,6 +178,7 @@
                        string name = m_img.MetadataRoot.Streams.StringsHeap 
[mr.Name];
                        ModuleDefinition main = new ModuleDefinition (name, 
m_asmDef, m_ir, true);
                        main.Mvid = m_img.MetadataRoot.Streams.GuidHeap 
[mr.Mvid];
+                       main.MetadataToken = new MetadataToken 
(TokenType.Module, 1);
                        modules.Add (main);
                        m_module = main;
                        m_module.Accept (this);
@@ -218,8 +221,9 @@
                        ModuleRefTable mrTable = m_tHeap 
[typeof(ModuleRefTable)] as ModuleRefTable;
                        for (int i = 0; i < mrTable.Rows.Count; i++) {
                                ModuleRefRow mrRow = mrTable [i];
-                               modules.Add (
-                                       new ModuleReference 
(m_img.MetadataRoot.Streams.StringsHeap [mrRow.Name]));
+                               ModuleReference mod = new ModuleReference 
(m_img.MetadataRoot.Streams.StringsHeap [mrRow.Name]);
+                               mod.MetadataToken = new MetadataToken 
(TokenType.ModuleRef, (uint) i + 1);
+                               modules.Add (mod);
                        }
                }
 

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

Reply via email to