update Mono.Cecil
authorJb Evain <jbevain@gmail.com>
Thu, 2 Jun 2011 14:39:06 +0000 (16:39 +0200)
committerJb Evain <jbevain@gmail.com>
Thu, 2 Jun 2011 14:39:06 +0000 (16:39 +0200)
127 files changed:
mcs/class/Mono.Cecil/Mono.Cecil.Cil/Code.cs
mcs/class/Mono.Cecil/Mono.Cecil.Cil/CodeReader.cs
mcs/class/Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs
mcs/class/Mono.Cecil/Mono.Cecil.Cil/Document.cs
mcs/class/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandler.cs
mcs/class/Mono.Cecil/Mono.Cecil.Cil/ILProcessor.cs
mcs/class/Mono.Cecil/Mono.Cecil.Cil/Instruction.cs
mcs/class/Mono.Cecil/Mono.Cecil.Cil/MethodBody.cs
mcs/class/Mono.Cecil/Mono.Cecil.Cil/OpCode.cs
mcs/class/Mono.Cecil/Mono.Cecil.Cil/OpCodes.cs
mcs/class/Mono.Cecil/Mono.Cecil.Cil/SequencePoint.cs
mcs/class/Mono.Cecil/Mono.Cecil.Cil/Symbols.cs
mcs/class/Mono.Cecil/Mono.Cecil.Cil/VariableDefinition.cs
mcs/class/Mono.Cecil/Mono.Cecil.Cil/VariableReference.cs
mcs/class/Mono.Cecil/Mono.Cecil.Metadata/BlobHeap.cs
mcs/class/Mono.Cecil/Mono.Cecil.Metadata/Buffers.cs
mcs/class/Mono.Cecil/Mono.Cecil.Metadata/CodedIndex.cs
mcs/class/Mono.Cecil/Mono.Cecil.Metadata/ElementType.cs
mcs/class/Mono.Cecil/Mono.Cecil.Metadata/GuidHeap.cs
mcs/class/Mono.Cecil/Mono.Cecil.Metadata/Heap.cs
mcs/class/Mono.Cecil/Mono.Cecil.Metadata/MetadataToken.cs
mcs/class/Mono.Cecil/Mono.Cecil.Metadata/Row.cs
mcs/class/Mono.Cecil/Mono.Cecil.Metadata/StringHeap.cs
mcs/class/Mono.Cecil/Mono.Cecil.Metadata/TableHeap.cs
mcs/class/Mono.Cecil/Mono.Cecil.Metadata/TokenType.cs
mcs/class/Mono.Cecil/Mono.Cecil.Metadata/UserStringHeap.cs
mcs/class/Mono.Cecil/Mono.Cecil.Metadata/Utilities.cs
mcs/class/Mono.Cecil/Mono.Cecil.PE/BinaryStreamReader.cs
mcs/class/Mono.Cecil/Mono.Cecil.PE/BinaryStreamWriter.cs
mcs/class/Mono.Cecil/Mono.Cecil.PE/ByteBuffer.cs
mcs/class/Mono.Cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs
mcs/class/Mono.Cecil/Mono.Cecil.PE/DataDirectory.cs
mcs/class/Mono.Cecil/Mono.Cecil.PE/Image.cs
mcs/class/Mono.Cecil/Mono.Cecil.PE/ImageReader.cs
mcs/class/Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs
mcs/class/Mono.Cecil/Mono.Cecil.PE/Section.cs
mcs/class/Mono.Cecil/Mono.Cecil.PE/TextMap.cs
mcs/class/Mono.Cecil/Mono.Cecil/ArrayType.cs
mcs/class/Mono.Cecil/Mono.Cecil/AssemblyDefinition.cs
mcs/class/Mono.Cecil/Mono.Cecil/AssemblyFlags.cs
mcs/class/Mono.Cecil/Mono.Cecil/AssemblyHashAlgorithm.cs
mcs/class/Mono.Cecil/Mono.Cecil/AssemblyInfo.cs
mcs/class/Mono.Cecil/Mono.Cecil/AssemblyLinkedResource.cs
mcs/class/Mono.Cecil/Mono.Cecil/AssemblyNameDefinition.cs
mcs/class/Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs
mcs/class/Mono.Cecil/Mono.Cecil/AssemblyReader.cs
mcs/class/Mono.Cecil/Mono.Cecil/AssemblyWriter.cs
mcs/class/Mono.Cecil/Mono.Cecil/BaseAssemblyResolver.cs
mcs/class/Mono.Cecil/Mono.Cecil/CallSite.cs
mcs/class/Mono.Cecil/Mono.Cecil/CustomAttribute.cs
mcs/class/Mono.Cecil/Mono.Cecil/DefaultAssemblyResolver.cs
mcs/class/Mono.Cecil/Mono.Cecil/EmbeddedResource.cs
mcs/class/Mono.Cecil/Mono.Cecil/EventAttributes.cs
mcs/class/Mono.Cecil/Mono.Cecil/EventDefinition.cs
mcs/class/Mono.Cecil/Mono.Cecil/EventReference.cs
mcs/class/Mono.Cecil/Mono.Cecil/ExportedType.cs
mcs/class/Mono.Cecil/Mono.Cecil/FieldAttributes.cs
mcs/class/Mono.Cecil/Mono.Cecil/FieldDefinition.cs
mcs/class/Mono.Cecil/Mono.Cecil/FieldReference.cs
mcs/class/Mono.Cecil/Mono.Cecil/FileAttributes.cs
mcs/class/Mono.Cecil/Mono.Cecil/FunctionPointerType.cs
mcs/class/Mono.Cecil/Mono.Cecil/GenericInstanceMethod.cs
mcs/class/Mono.Cecil/Mono.Cecil/GenericInstanceType.cs
mcs/class/Mono.Cecil/Mono.Cecil/GenericParameter.cs
mcs/class/Mono.Cecil/Mono.Cecil/GenericParameterAttributes.cs
mcs/class/Mono.Cecil/Mono.Cecil/IConstantProvider.cs
mcs/class/Mono.Cecil/Mono.Cecil/ICustomAttributeProvider.cs
mcs/class/Mono.Cecil/Mono.Cecil/IGenericInstance.cs
mcs/class/Mono.Cecil/Mono.Cecil/IGenericParameterProvider.cs
mcs/class/Mono.Cecil/Mono.Cecil/IMarshalInfoProvider.cs
mcs/class/Mono.Cecil/Mono.Cecil/IMemberDefinition.cs
mcs/class/Mono.Cecil/Mono.Cecil/IMetadataScope.cs
mcs/class/Mono.Cecil/Mono.Cecil/IMetadataTokenProvider.cs
mcs/class/Mono.Cecil/Mono.Cecil/IMethodSignature.cs
mcs/class/Mono.Cecil/Mono.Cecil/Import.cs
mcs/class/Mono.Cecil/Mono.Cecil/LinkedResource.cs
mcs/class/Mono.Cecil/Mono.Cecil/ManifestResourceAttributes.cs
mcs/class/Mono.Cecil/Mono.Cecil/MarshalInfo.cs
mcs/class/Mono.Cecil/Mono.Cecil/MemberDefinitionCollection.cs
mcs/class/Mono.Cecil/Mono.Cecil/MemberReference.cs
mcs/class/Mono.Cecil/Mono.Cecil/MetadataResolver.cs
mcs/class/Mono.Cecil/Mono.Cecil/MetadataSystem.cs
mcs/class/Mono.Cecil/Mono.Cecil/MethodAttributes.cs
mcs/class/Mono.Cecil/Mono.Cecil/MethodCallingConvention.cs
mcs/class/Mono.Cecil/Mono.Cecil/MethodDefinition.cs
mcs/class/Mono.Cecil/Mono.Cecil/MethodImplAttributes.cs
mcs/class/Mono.Cecil/Mono.Cecil/MethodReference.cs
mcs/class/Mono.Cecil/Mono.Cecil/MethodReturnType.cs
mcs/class/Mono.Cecil/Mono.Cecil/MethodSemanticsAttributes.cs
mcs/class/Mono.Cecil/Mono.Cecil/MethodSpecification.cs
mcs/class/Mono.Cecil/Mono.Cecil/Modifiers.cs
mcs/class/Mono.Cecil/Mono.Cecil/ModuleDefinition.cs
mcs/class/Mono.Cecil/Mono.Cecil/ModuleKind.cs
mcs/class/Mono.Cecil/Mono.Cecil/ModuleReference.cs
mcs/class/Mono.Cecil/Mono.Cecil/NativeType.cs
mcs/class/Mono.Cecil/Mono.Cecil/PInvokeAttributes.cs
mcs/class/Mono.Cecil/Mono.Cecil/PInvokeInfo.cs
mcs/class/Mono.Cecil/Mono.Cecil/ParameterAttributes.cs
mcs/class/Mono.Cecil/Mono.Cecil/ParameterDefinition.cs
mcs/class/Mono.Cecil/Mono.Cecil/ParameterDefinitionCollection.cs
mcs/class/Mono.Cecil/Mono.Cecil/ParameterReference.cs
mcs/class/Mono.Cecil/Mono.Cecil/PinnedType.cs
mcs/class/Mono.Cecil/Mono.Cecil/PointerType.cs
mcs/class/Mono.Cecil/Mono.Cecil/PropertyAttributes.cs
mcs/class/Mono.Cecil/Mono.Cecil/PropertyDefinition.cs
mcs/class/Mono.Cecil/Mono.Cecil/PropertyReference.cs
mcs/class/Mono.Cecil/Mono.Cecil/ReferenceType.cs
mcs/class/Mono.Cecil/Mono.Cecil/Resource.cs
mcs/class/Mono.Cecil/Mono.Cecil/SecurityDeclaration.cs
mcs/class/Mono.Cecil/Mono.Cecil/SentinelType.cs
mcs/class/Mono.Cecil/Mono.Cecil/TargetRuntime.cs
mcs/class/Mono.Cecil/Mono.Cecil/TypeAttributes.cs
mcs/class/Mono.Cecil/Mono.Cecil/TypeDefinition.cs
mcs/class/Mono.Cecil/Mono.Cecil/TypeDefinitionCollection.cs
mcs/class/Mono.Cecil/Mono.Cecil/TypeParser.cs
mcs/class/Mono.Cecil/Mono.Cecil/TypeReference.cs
mcs/class/Mono.Cecil/Mono.Cecil/TypeSpecification.cs
mcs/class/Mono.Cecil/Mono.Cecil/TypeSystem.cs
mcs/class/Mono.Cecil/Mono.Cecil/VariantType.cs
mcs/class/Mono.Cecil/Mono.Collections.Generic/Collection.cs
mcs/class/Mono.Cecil/Mono.Collections.Generic/ReadOnlyCollection.cs
mcs/class/Mono.Cecil/Mono.Security.Cryptography/CryptoService.cs
mcs/class/Mono.Cecil/Mono/Actions.cs
mcs/class/Mono.Cecil/Mono/Empty.cs
mcs/class/Mono.Cecil/Mono/Funcs.cs
mcs/class/Mono.Cecil/System.Runtime.CompilerServices/ExtensionAttribute.cs
mcs/class/Mono.Cecil/revision

index bd18b842a951850ac72f5c181ed979efb294e51b..fa88b63d67ef9ab52649034c46a75125c00e8edd 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 4cfc7db752f3e64cf718eb43fe2188778b1aa846..61d04d95b4a82320f742b2330db9ca63675cce1c 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -49,18 +49,13 @@ namespace Mono.Cecil.Cil {
                        get { return base.position - start; }
                }
 
-               CodeReader (Section section, MetadataReader reader)
+               public CodeReader (Section section, MetadataReader reader)
                        : base (section.Data)
                {
                        this.code_section = section;
                        this.reader = reader;
                }
 
-               public static CodeReader CreateCodeReader (MetadataReader metadata)
-               {
-                       return new CodeReader (metadata.image.MetadataSection, metadata);
-               }
-
                public MethodBody ReadMethodBody (MethodDefinition method)
                {
                        this.method = method;
@@ -364,7 +359,6 @@ namespace Mono.Cecil.Cil {
                                break;
                        case ExceptionHandlerType.Filter:
                                handler.FilterStart = GetInstruction (ReadInt32 ());
-                               handler.FilterEnd = handler.HandlerStart.Previous;
                                break;
                        default:
                                Advance (4);
index 8bf072241dbdf045dfefcbf485ee3970a24657ac..2412034386cb8985b6d09129567c96d157fa334e 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -510,7 +510,7 @@ namespace Mono.Cecil.Cil {
                                        return true;
 
                                if (handler.HandlerType == ExceptionHandlerType.Filter
-                                       && IsFatRange (handler.FilterStart, handler.FilterEnd))
+                                       && IsFatRange (handler.FilterStart, handler.HandlerStart))
                                        return true;
                        }
 
index e46d2c1d8241e456e039c0cd092c39ee73549b61..6648b7aacc37ee53927e8b528377b1c352d3175d 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index a76f8f397b206d1e7e61f0e317dd78e37d2388bf..c61ff235efb2b264713598f8c1a7fe8aea792158 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -40,7 +40,6 @@ namespace Mono.Cecil.Cil {
                Instruction try_start;
                Instruction try_end;
                Instruction filter_start;
-               Instruction filter_end;
                Instruction handler_start;
                Instruction handler_end;
 
@@ -62,11 +61,6 @@ namespace Mono.Cecil.Cil {
                        set { filter_start = value; }
                }
 
-               public Instruction FilterEnd {
-                       get { return filter_end; }
-                       set { filter_end = value; }
-               }
-
                public Instruction HandlerStart {
                        get { return handler_start; }
                        set { handler_start = value; }
index 1300b3e6bb11825d6b0a902f1724ce819c223d20..cd5dbb40fe6442a32f524667a0014b8f69a28487 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index e8d36c4b38493a9752673ff8b5754354d7617441..c28d4c99291d7692595037ad1ea1653854c033f7 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index b57900e5ac4935dd01e5e7dfcea85a0712c51ab1..4ae749b93afa270a7a56347625ab742e2a56b1d9 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index aad4ba4b9d0eaa9b890c8dc35435b2eb660e83b8..1a14421300dceaf6c76fae02f0ca09bb455c67c0 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -116,7 +116,7 @@ namespace Mono.Cecil.Cil {
                readonly byte stack_behavior_push;
 
                public string Name {
-                       get { return OpCodeNames.names [op1 == 0xff ? op2 : op2 + 256]; }
+                       get { return OpCodeNames.names [(int) Code]; }
                }
 
                public int Size {
@@ -132,7 +132,7 @@ namespace Mono.Cecil.Cil {
                }
 
                public short Value {
-                       get { return (short) ((op1 << 8) | op2); }
+                       get { return op1 == 0xff ? op2 : (short) ((op1 << 8) | op2); }
                }
 
                public Code Code {
@@ -214,311 +214,242 @@ namespace Mono.Cecil.Cil {
 
        static class OpCodeNames {
 
-               internal static readonly string [] names = {
-                       "nop",
-                       "break",
-                       "ldarg.0",
-                       "ldarg.1",
-                       "ldarg.2",
-                       "ldarg.3",
-                       "ldloc.0",
-                       "ldloc.1",
-                       "ldloc.2",
-                       "ldloc.3",
-                       "stloc.0",
-                       "stloc.1",
-                       "stloc.2",
-                       "stloc.3",
-                       "ldarg.s",
-                       "ldarga.s",
-                       "starg.s",
-                       "ldloc.s",
-                       "ldloca.s",
-                       "stloc.s",
-                       "ldnull",
-                       "ldc.i4.m1",
-                       "ldc.i4.0",
-                       "ldc.i4.1",
-                       "ldc.i4.2",
-                       "ldc.i4.3",
-                       "ldc.i4.4",
-                       "ldc.i4.5",
-                       "ldc.i4.6",
-                       "ldc.i4.7",
-                       "ldc.i4.8",
-                       "ldc.i4.s",
-                       "ldc.i4",
-                       "ldc.i8",
-                       "ldc.r4",
-                       "ldc.r8",
-                       null,
-                       "dup",
-                       "pop",
-                       "jmp",
-                       "call",
-                       "calli",
-                       "ret",
-                       "br.s",
-                       "brfalse.s",
-                       "brtrue.s",
-                       "beq.s",
-                       "bge.s",
-                       "bgt.s",
-                       "ble.s",
-                       "blt.s",
-                       "bne.un.s",
-                       "bge.un.s",
-                       "bgt.un.s",
-                       "ble.un.s",
-                       "blt.un.s",
-                       "br",
-                       "brfalse",
-                       "brtrue",
-                       "beq",
-                       "bge",
-                       "bgt",
-                       "ble",
-                       "blt",
-                       "bne.un",
-                       "bge.un",
-                       "bgt.un",
-                       "ble.un",
-                       "blt.un",
-                       "switch",
-                       "ldind.i1",
-                       "ldind.u1",
-                       "ldind.i2",
-                       "ldind.u2",
-                       "ldind.i4",
-                       "ldind.u4",
-                       "ldind.i8",
-                       "ldind.i",
-                       "ldind.r4",
-                       "ldind.r8",
-                       "ldind.ref",
-                       "stind.ref",
-                       "stind.i1",
-                       "stind.i2",
-                       "stind.i4",
-                       "stind.i8",
-                       "stind.r4",
-                       "stind.r8",
-                       "add",
-                       "sub",
-                       "mul",
-                       "div",
-                       "div.un",
-                       "rem",
-                       "rem.un",
-                       "and",
-                       "or",
-                       "xor",
-                       "shl",
-                       "shr",
-                       "shr.un",
-                       "neg",
-                       "not",
-                       "conv.i1",
-                       "conv.i2",
-                       "conv.i4",
-                       "conv.i8",
-                       "conv.r4",
-                       "conv.r8",
-                       "conv.u4",
-                       "conv.u8",
-                       "callvirt",
-                       "cpobj",
-                       "ldobj",
-                       "ldstr",
-                       "newobj",
-                       "castclass",
-                       "isinst",
-                       "conv.r.un",
-                       null,
-                       null,
-                       "unbox",
-                       "throw",
-                       "ldfld",
-                       "ldflda",
-                       "stfld",
-                       "ldsfld",
-                       "ldsflda",
-                       "stsfld",
-                       "stobj",
-                       "conv.ovf.i1.un",
-                       "conv.ovf.i2.un",
-                       "conv.ovf.i4.un",
-                       "conv.ovf.i8.un",
-                       "conv.ovf.u1.un",
-                       "conv.ovf.u2.un",
-                       "conv.ovf.u4.un",
-                       "conv.ovf.u8.un",
-                       "conv.ovf.i.un",
-                       "conv.ovf.u.un",
-                       "box",
-                       "newarr",
-                       "ldlen",
-                       "ldelema",
-                       "ldelem.i1",
-                       "ldelem.u1",
-                       "ldelem.i2",
-                       "ldelem.u2",
-                       "ldelem.i4",
-                       "ldelem.u4",
-                       "ldelem.i8",
-                       "ldelem.i",
-                       "ldelem.r4",
-                       "ldelem.r8",
-                       "ldelem.ref",
-                       "stelem.i",
-                       "stelem.i1",
-                       "stelem.i2",
-                       "stelem.i4",
-                       "stelem.i8",
-                       "stelem.r4",
-                       "stelem.r8",
-                       "stelem.ref",
-                       "ldelem.any",
-                       "stelem.any",
-                       "unbox.any",
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       "conv.ovf.i1",
-                       "conv.ovf.u1",
-                       "conv.ovf.i2",
-                       "conv.ovf.u2",
-                       "conv.ovf.i4",
-                       "conv.ovf.u4",
-                       "conv.ovf.i8",
-                       "conv.ovf.u8",
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       "refanyval",
-                       "ckfinite",
-                       null,
-                       null,
-                       "mkrefany",
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       "ldtoken",
-                       "conv.u2",
-                       "conv.u1",
-                       "conv.i",
-                       "conv.ovf.i",
-                       "conv.ovf.u",
-                       "add.ovf",
-                       "add.ovf.un",
-                       "mul.ovf",
-                       "mul.ovf.un",
-                       "sub.ovf",
-                       "sub.ovf.un",
-                       "endfinally",
-                       "leave",
-                       "leave.s",
-                       "stind.i",
-                       "conv.u",
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       "prefix7",
-                       "prefix6",
-                       "prefix5",
-                       "prefix4",
-                       "prefix3",
-                       "prefix2",
-                       "prefix1",
-                       "prefixref",
-                       "arglist",
-                       "ceq",
-                       "cgt",
-                       "cgt.un",
-                       "clt",
-                       "clt.un",
-                       "ldftn",
-                       "ldvirtftn",
-                       null,
-                       "ldarg",
-                       "ldarga",
-                       "starg",
-                       "ldloc",
-                       "ldloca",
-                       "stloc",
-                       "localloc",
-                       null,
-                       "endfilter",
-                       "unaligned.",
-                       "volatile.",
-                       "tail.",
-                       "initobj",
-                       "constrained.",
-                       "cpblk",
-                       "initblk",
-                       "no.",          // added by spouliot to match Cecil existing definitions
-                       "rethrow",
-                       null,
-                       "sizeof",
-                       "refanytype",
-                       "readonly.",    // added by spouliot to match Cecil existing definitions
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-                       null,
-               };
+               internal static readonly string [] names;
+
+               static OpCodeNames ()
+               {
+                       var table = new byte [] {
+                               3, 110, 111, 112,
+                               5, 98, 114, 101, 97, 107,
+                               7, 108, 100, 97, 114, 103, 46, 48,
+                               7, 108, 100, 97, 114, 103, 46, 49,
+                               7, 108, 100, 97, 114, 103, 46, 50,
+                               7, 108, 100, 97, 114, 103, 46, 51,
+                               7, 108, 100, 108, 111, 99, 46, 48,
+                               7, 108, 100, 108, 111, 99, 46, 49,
+                               7, 108, 100, 108, 111, 99, 46, 50,
+                               7, 108, 100, 108, 111, 99, 46, 51,
+                               7, 115, 116, 108, 111, 99, 46, 48,
+                               7, 115, 116, 108, 111, 99, 46, 49,
+                               7, 115, 116, 108, 111, 99, 46, 50,
+                               7, 115, 116, 108, 111, 99, 46, 51,
+                               7, 108, 100, 97, 114, 103, 46, 115,
+                               8, 108, 100, 97, 114, 103, 97, 46, 115,
+                               7, 115, 116, 97, 114, 103, 46, 115,
+                               7, 108, 100, 108, 111, 99, 46, 115,
+                               8, 108, 100, 108, 111, 99, 97, 46, 115,
+                               7, 115, 116, 108, 111, 99, 46, 115,
+                               6, 108, 100, 110, 117, 108, 108,
+                               9, 108, 100, 99, 46, 105, 52, 46, 109, 49,
+                               8, 108, 100, 99, 46, 105, 52, 46, 48,
+                               8, 108, 100, 99, 46, 105, 52, 46, 49,
+                               8, 108, 100, 99, 46, 105, 52, 46, 50,
+                               8, 108, 100, 99, 46, 105, 52, 46, 51,
+                               8, 108, 100, 99, 46, 105, 52, 46, 52,
+                               8, 108, 100, 99, 46, 105, 52, 46, 53,
+                               8, 108, 100, 99, 46, 105, 52, 46, 54,
+                               8, 108, 100, 99, 46, 105, 52, 46, 55,
+                               8, 108, 100, 99, 46, 105, 52, 46, 56,
+                               8, 108, 100, 99, 46, 105, 52, 46, 115,
+                               6, 108, 100, 99, 46, 105, 52,
+                               6, 108, 100, 99, 46, 105, 56,
+                               6, 108, 100, 99, 46, 114, 52,
+                               6, 108, 100, 99, 46, 114, 56,
+                               3, 100, 117, 112,
+                               3, 112, 111, 112,
+                               3, 106, 109, 112,
+                               4, 99, 97, 108, 108,
+                               5, 99, 97, 108, 108, 105,
+                               3, 114, 101, 116,
+                               4, 98, 114, 46, 115,
+                               9, 98, 114, 102, 97, 108, 115, 101, 46, 115,
+                               8, 98, 114, 116, 114, 117, 101, 46, 115,
+                               5, 98, 101, 113, 46, 115,
+                               5, 98, 103, 101, 46, 115,
+                               5, 98, 103, 116, 46, 115,
+                               5, 98, 108, 101, 46, 115,
+                               5, 98, 108, 116, 46, 115,
+                               8, 98, 110, 101, 46, 117, 110, 46, 115,
+                               8, 98, 103, 101, 46, 117, 110, 46, 115,
+                               8, 98, 103, 116, 46, 117, 110, 46, 115,
+                               8, 98, 108, 101, 46, 117, 110, 46, 115,
+                               8, 98, 108, 116, 46, 117, 110, 46, 115,
+                               2, 98, 114,
+                               7, 98, 114, 102, 97, 108, 115, 101,
+                               6, 98, 114, 116, 114, 117, 101,
+                               3, 98, 101, 113,
+                               3, 98, 103, 101,
+                               3, 98, 103, 116,
+                               3, 98, 108, 101,
+                               3, 98, 108, 116,
+                               6, 98, 110, 101, 46, 117, 110,
+                               6, 98, 103, 101, 46, 117, 110,
+                               6, 98, 103, 116, 46, 117, 110,
+                               6, 98, 108, 101, 46, 117, 110,
+                               6, 98, 108, 116, 46, 117, 110,
+                               6, 115, 119, 105, 116, 99, 104,
+                               8, 108, 100, 105, 110, 100, 46, 105, 49,
+                               8, 108, 100, 105, 110, 100, 46, 117, 49,
+                               8, 108, 100, 105, 110, 100, 46, 105, 50,
+                               8, 108, 100, 105, 110, 100, 46, 117, 50,
+                               8, 108, 100, 105, 110, 100, 46, 105, 52,
+                               8, 108, 100, 105, 110, 100, 46, 117, 52,
+                               8, 108, 100, 105, 110, 100, 46, 105, 56,
+                               7, 108, 100, 105, 110, 100, 46, 105,
+                               8, 108, 100, 105, 110, 100, 46, 114, 52,
+                               8, 108, 100, 105, 110, 100, 46, 114, 56,
+                               9, 108, 100, 105, 110, 100, 46, 114, 101, 102,
+                               9, 115, 116, 105, 110, 100, 46, 114, 101, 102,
+                               8, 115, 116, 105, 110, 100, 46, 105, 49,
+                               8, 115, 116, 105, 110, 100, 46, 105, 50,
+                               8, 115, 116, 105, 110, 100, 46, 105, 52,
+                               8, 115, 116, 105, 110, 100, 46, 105, 56,
+                               8, 115, 116, 105, 110, 100, 46, 114, 52,
+                               8, 115, 116, 105, 110, 100, 46, 114, 56,
+                               3, 97, 100, 100,
+                               3, 115, 117, 98,
+                               3, 109, 117, 108,
+                               3, 100, 105, 118,
+                               6, 100, 105, 118, 46, 117, 110,
+                               3, 114, 101, 109,
+                               6, 114, 101, 109, 46, 117, 110,
+                               3, 97, 110, 100,
+                               2, 111, 114,
+                               3, 120, 111, 114,
+                               3, 115, 104, 108,
+                               3, 115, 104, 114,
+                               6, 115, 104, 114, 46, 117, 110,
+                               3, 110, 101, 103,
+                               3, 110, 111, 116,
+                               7, 99, 111, 110, 118, 46, 105, 49,
+                               7, 99, 111, 110, 118, 46, 105, 50,
+                               7, 99, 111, 110, 118, 46, 105, 52,
+                               7, 99, 111, 110, 118, 46, 105, 56,
+                               7, 99, 111, 110, 118, 46, 114, 52,
+                               7, 99, 111, 110, 118, 46, 114, 56,
+                               7, 99, 111, 110, 118, 46, 117, 52,
+                               7, 99, 111, 110, 118, 46, 117, 56,
+                               8, 99, 97, 108, 108, 118, 105, 114, 116,
+                               5, 99, 112, 111, 98, 106,
+                               5, 108, 100, 111, 98, 106,
+                               5, 108, 100, 115, 116, 114,
+                               6, 110, 101, 119, 111, 98, 106,
+                               9, 99, 97, 115, 116, 99, 108, 97, 115, 115,
+                               6, 105, 115, 105, 110, 115, 116,
+                               9, 99, 111, 110, 118, 46, 114, 46, 117, 110,
+                               5, 117, 110, 98, 111, 120,
+                               5, 116, 104, 114, 111, 119,
+                               5, 108, 100, 102, 108, 100,
+                               6, 108, 100, 102, 108, 100, 97,
+                               5, 115, 116, 102, 108, 100,
+                               6, 108, 100, 115, 102, 108, 100,
+                               7, 108, 100, 115, 102, 108, 100, 97,
+                               6, 115, 116, 115, 102, 108, 100,
+                               5, 115, 116, 111, 98, 106,
+                               14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 49, 46, 117, 110,
+                               14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 50, 46, 117, 110,
+                               14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 52, 46, 117, 110,
+                               14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 56, 46, 117, 110,
+                               14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 49, 46, 117, 110,
+                               14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 50, 46, 117, 110,
+                               14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 52, 46, 117, 110,
+                               14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 56, 46, 117, 110,
+                               13, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 46, 117, 110,
+                               13, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 46, 117, 110,
+                               3, 98, 111, 120,
+                               6, 110, 101, 119, 97, 114, 114,
+                               5, 108, 100, 108, 101, 110,
+                               7, 108, 100, 101, 108, 101, 109, 97,
+                               9, 108, 100, 101, 108, 101, 109, 46, 105, 49,
+                               9, 108, 100, 101, 108, 101, 109, 46, 117, 49,
+                               9, 108, 100, 101, 108, 101, 109, 46, 105, 50,
+                               9, 108, 100, 101, 108, 101, 109, 46, 117, 50,
+                               9, 108, 100, 101, 108, 101, 109, 46, 105, 52,
+                               9, 108, 100, 101, 108, 101, 109, 46, 117, 52,
+                               9, 108, 100, 101, 108, 101, 109, 46, 105, 56,
+                               8, 108, 100, 101, 108, 101, 109, 46, 105,
+                               9, 108, 100, 101, 108, 101, 109, 46, 114, 52,
+                               9, 108, 100, 101, 108, 101, 109, 46, 114, 56,
+                               10, 108, 100, 101, 108, 101, 109, 46, 114, 101, 102,
+                               8, 115, 116, 101, 108, 101, 109, 46, 105,
+                               9, 115, 116, 101, 108, 101, 109, 46, 105, 49,
+                               9, 115, 116, 101, 108, 101, 109, 46, 105, 50,
+                               9, 115, 116, 101, 108, 101, 109, 46, 105, 52,
+                               9, 115, 116, 101, 108, 101, 109, 46, 105, 56,
+                               9, 115, 116, 101, 108, 101, 109, 46, 114, 52,
+                               9, 115, 116, 101, 108, 101, 109, 46, 114, 56,
+                               10, 115, 116, 101, 108, 101, 109, 46, 114, 101, 102,
+                               10, 108, 100, 101, 108, 101, 109, 46, 97, 110, 121,
+                               10, 115, 116, 101, 108, 101, 109, 46, 97, 110, 121,
+                               9, 117, 110, 98, 111, 120, 46, 97, 110, 121,
+                               11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 49,
+                               11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 49,
+                               11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 50,
+                               11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 50,
+                               11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 52,
+                               11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 52,
+                               11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 56,
+                               11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 56,
+                               9, 114, 101, 102, 97, 110, 121, 118, 97, 108,
+                               8, 99, 107, 102, 105, 110, 105, 116, 101,
+                               8, 109, 107, 114, 101, 102, 97, 110, 121,
+                               7, 108, 100, 116, 111, 107, 101, 110,
+                               7, 99, 111, 110, 118, 46, 117, 50,
+                               7, 99, 111, 110, 118, 46, 117, 49,
+                               6, 99, 111, 110, 118, 46, 105,
+                               10, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105,
+                               10, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117,
+                               7, 97, 100, 100, 46, 111, 118, 102,
+                               10, 97, 100, 100, 46, 111, 118, 102, 46, 117, 110,
+                               7, 109, 117, 108, 46, 111, 118, 102,
+                               10, 109, 117, 108, 46, 111, 118, 102, 46, 117, 110,
+                               7, 115, 117, 98, 46, 111, 118, 102,
+                               10, 115, 117, 98, 46, 111, 118, 102, 46, 117, 110,
+                               10, 101, 110, 100, 102, 105, 110, 97, 108, 108, 121,
+                               5, 108, 101, 97, 118, 101,
+                               7, 108, 101, 97, 118, 101, 46, 115,
+                               7, 115, 116, 105, 110, 100, 46, 105,
+                               6, 99, 111, 110, 118, 46, 117,
+                               7, 97, 114, 103, 108, 105, 115, 116,
+                               3, 99, 101, 113,
+                               3, 99, 103, 116,
+                               6, 99, 103, 116, 46, 117, 110,
+                               3, 99, 108, 116,
+                               6, 99, 108, 116, 46, 117, 110,
+                               5, 108, 100, 102, 116, 110,
+                               9, 108, 100, 118, 105, 114, 116, 102, 116, 110,
+                               5, 108, 100, 97, 114, 103,
+                               6, 108, 100, 97, 114, 103, 97,
+                               5, 115, 116, 97, 114, 103,
+                               5, 108, 100, 108, 111, 99,
+                               6, 108, 100, 108, 111, 99, 97,
+                               5, 115, 116, 108, 111, 99,
+                               8, 108, 111, 99, 97, 108, 108, 111, 99,
+                               9, 101, 110, 100, 102, 105, 108, 116, 101, 114,
+                               10, 117, 110, 97, 108, 105, 103, 110, 101, 100, 46,
+                               9, 118, 111, 108, 97, 116, 105, 108, 101, 46,
+                               5, 116, 97, 105, 108, 46,
+                               7, 105, 110, 105, 116, 111, 98, 106,
+                               12, 99, 111, 110, 115, 116, 114, 97, 105, 110, 101, 100, 46,
+                               5, 99, 112, 98, 108, 107,
+                               7, 105, 110, 105, 116, 98, 108, 107,
+                               3, 110, 111, 46,
+                               7, 114, 101, 116, 104, 114, 111, 119,
+                               6, 115, 105, 122, 101, 111, 102,
+                               10, 114, 101, 102, 97, 110, 121, 116, 121, 112, 101,
+                               9, 114, 101, 97, 100, 111, 110, 108, 121, 46,
+                       };
+
+                       names = new string [219];
+
+                       for (int i = 0, p = 0; i < names.Length; i++) {
+                               var buffer = new char [table [p++]];
+
+                               for (int j = 0; j < buffer.Length; j++)
+                                       buffer [j] = (char) table [p++];
+
+                               names [i] = new string (buffer);
+                       }
+               }
        }
 }
index ce468a19c42305348b44b52734ed9800a0da9e7a..85712ec8b8223b8d36b6894d1e86b76e9fb170c3 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 189b5f52bb1680d387fc62c8c6278e853ff0e781..ef87e30f13609ef1fa61b776e88c61688ebe66eb 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index ba2e694fc2b444a602535bd817a51a6c91881cdc..426c4a7e1fea167957fa9b7ff6c305571a876f20 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -151,10 +151,15 @@ namespace Mono.Cecil.Cil {
                        get { return local_var_token; }
                }
 
-               public MethodSymbols (string methodName)
+               internal MethodSymbols (string methodName)
                {
                        this.method_name = methodName;
                }
+
+               public MethodSymbols (MetadataToken methodToken)
+               {
+                       this.method_token = methodToken;
+               }
        }
 
        public delegate Instruction InstructionMapper (int offset);
index 690543e975d88e9fe697cfb76bb0fc1206a514ea..f501bca6e727af5ad725fbd26ee4215545658f60 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 545384550034fb7c29af94e7b4bc4582cfcf100e..ce0b4cdb4cf6cc46f60947e7ceef34d155616962 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 81c775e01840468aece9265b229483d12d52a477..e7e2928c82ae538640bbae3936b0b91bcec9264b 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index e8759d7426d32dfff9811b6a619412e7b4b318b8..1c54fdb3651609f70aa38da0c5e80a5125d7d750 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -261,7 +261,7 @@ namespace Mono.Cecil.Metadata {
        abstract class HeapBuffer : ByteBuffer {
 
                public bool IsLarge {
-                       get { return base.length > 65536; }
+                       get { return base.length > 65535; }
                }
 
                public abstract bool IsEmpty { get; }
index 62677263d4112001565c3770bac3e05340e2c2b4..3e30fd87f9597be6d89f89dccd2af09eb3fce2e8 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 1ede042b50d65320b47bd5cf677023fa8b4a130c..72fc1ccaf23f08b87d76934bf8d1f025d24c7c12 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 19acdab51216f03f03c18556070ed01cc63c7656..1adc0795ee9ab9faadd813c0bdc1cbd58c053813 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index e7ff72059b11dfbbb847030bc1f9513c4e660598..bc21acde2507ee782df35ff62b9160db73c1f3a4 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 8c1338e948252d7469cf851ee47d7b942e033330..bda56b0f4fafc4dd5d7511a447790526725ca292 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index ab491a6e2ad8cc5d26bf2dfc096e8c26db3526ee..dfda00a7778dd3e197b820e94e7247f742cba2e1 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 85a289213c516cadd031a13e6a506c384719a34a..4a0a0af4359913f37a0cea95c081163de100fa29 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index cc441db25fea44b022d80e986059095535935742..9bc0edd36c157caf421a8685da671b580cdd7d1f 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -62,6 +62,8 @@ namespace Mono.Cecil.Metadata {
                TypeSpec = 0x1b,
                ImplMap = 0x1c,
                FieldRVA = 0x1d,
+               EncLog = 0x1e,
+               EncMap = 0x1f,
                Assembly = 0x20,
                AssemblyProcessor = 0x21,
                AssemblyOS = 0x22,
@@ -88,53 +90,9 @@ namespace Mono.Cecil.Metadata {
                public long Valid;
                public long Sorted;
 
-               public static readonly Table [] TableIdentifiers = new [] {
-                       Table.Module,
-                       Table.TypeRef,
-                       Table.TypeDef,
-                       Table.FieldPtr,
-                       Table.Field,
-                       Table.MethodPtr,
-                       Table.Method,
-                       Table.ParamPtr,
-                       Table.Param,
-                       Table.InterfaceImpl,
-                       Table.MemberRef,
-                       Table.Constant,
-                       Table.CustomAttribute,
-                       Table.FieldMarshal,
-                       Table.DeclSecurity,
-                       Table.ClassLayout,
-                       Table.FieldLayout,
-                       Table.StandAloneSig,
-                       Table.EventMap,
-                       Table.EventPtr,
-                       Table.Event,
-                       Table.PropertyMap,
-                       Table.PropertyPtr,
-                       Table.Property,
-                       Table.MethodSemantics,
-                       Table.MethodImpl,
-                       Table.ModuleRef,
-                       Table.TypeSpec,
-                       Table.ImplMap,
-                       Table.FieldRVA,
-                       Table.Assembly,
-                       Table.AssemblyProcessor,
-                       Table.AssemblyOS,
-                       Table.AssemblyRef,
-                       Table.AssemblyRefProcessor,
-                       Table.AssemblyRefOS,
-                       Table.File,
-                       Table.ExportedType,
-                       Table.ManifestResource,
-                       Table.NestedClass,
-                       Table.GenericParam,
-                       Table.MethodSpec,
-                       Table.GenericParamConstraint,
-               };
+               public const int TableCount = 45;
 
-               public readonly TableInformation [] Tables = new TableInformation [45];
+               public readonly TableInformation [] Tables = new TableInformation [TableCount];
 
                public TableInformation this [Table table] {
                        get { return Tables [(int) table]; }
index f822b6dd9fd849d3c18a6df1b0cf1c6f280668d6..2c2010ff9710afdc0fff1c1f411100bfc7a3dcc8 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 7353cb7057cbc341315efca12e359bf02be277f0..59105087ff3413919c1b4f34bf35e4f99928d7bb 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 496c61b51f74e01ea04e225d12883f3db955d707..d752b24b110c1f3501ba503b7724398c05c6d24b 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 8f5b38e16c6ba246aa38e03d64ffdf2528d8cfcd..ec2477c3ad5633da737269cafda0bab435a7b6e3 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 37189cb66668bbb80d5c921c7151f375284633a1..2bf6cccfa1973a9b32ceffc56cacddbc05b61745 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 4303b6d56f941de4a020f476261c88627e553bfb..1f94cde0083acf266d935cef052b9d3580f3cd18 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index fe56a6f18eead025a19ffd72ec7793b9fd4cd79e..70e89164c290a65b8aa5362789b717def6dc8ad8 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 5ba2d2d55a98ca530575b716aac0c3c560f071ab..fedd0e2ddecf08367a0adf35017c7bc2be8c443d 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 11aba8fd206525f58e9de46ca5e06f29ea9022da..9a04494f01f72079c149f0910a97169fa84fb713 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index a228c1ffec6d3ac98bf861196546d4caa0507cba..ebd4c6b85fa6c77e11853853d226538b07430261 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -416,12 +416,11 @@ namespace Mono.Cecil.PE {
                        // Sorted                       8
                        heap.Sorted = ReadInt64 ();
 
-                       for (int i = 0; i < TableHeap.TableIdentifiers.Length; i++) {
-                               var table = TableHeap.TableIdentifiers [i];
-                               if (!heap.HasTable (table))
+                       for (int i = 0; i < TableHeap.TableCount; i++) {
+                               if (!heap.HasTable ((Table) i))
                                        continue;
 
-                               heap.Tables [(int) table].Length = ReadUInt32 ();
+                               heap.Tables [i].Length = ReadUInt32 ();
                        }
 
                        SetIndexSize (image.StringHeap, sizes, 0x1);
@@ -459,8 +458,8 @@ namespace Mono.Cecil.PE {
                        var heap = image.TableHeap;
                        var tables = heap.Tables;
 
-                       for (int i = 0; i < TableHeap.TableIdentifiers.Length; i++) {
-                               var table = TableHeap.TableIdentifiers [i];
+                       for (int i = 0; i < TableHeap.TableCount; i++) {
+                               var table = (Table) i;
                                if (!heap.HasTable (table))
                                        continue;
 
@@ -595,6 +594,10 @@ namespace Mono.Cecil.PE {
                                        size = 4        // RVA
                                                + GetTableIndexSize (Table.Field);      // Field
                                        break;
+                               case Table.EncLog:
+                               case Table.EncMap:
+                                       size = 4;
+                                       break;
                                case Table.Assembly:
                                        size = 16 // HashAlgId 4, Version 4 * 2, Flags 4
                                                + blobidx_size  // PublicKey
@@ -655,12 +658,10 @@ namespace Mono.Cecil.PE {
                                        throw new NotSupportedException ();
                                }
 
-                               int index = (int) table;
-
-                               tables [index].RowSize = (uint) size;
-                               tables [index].Offset = offset;
+                               tables [i].RowSize = (uint) size;
+                               tables [i].Offset = offset;
 
-                               offset += (uint) size * tables [index].Length;
+                               offset += (uint) size * tables [i].Length;
                        }
                }
 
index 939de6b952f0754e2643c089e0fd4edd7df67aac..6f921d9b58080599ea63b8ff3811cc379134d88e 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 54935f9898fff8926171bf732c54c2e8eb97e72c..6a4c7bab7928c5340349d880e79841af7b158f43 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index daeda0cffe235faf6bf8aae29d09f2cee487bb74..047a4c1d47379db2a101bd91cce4aab4c50271de 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index e3a060f7b33226236b6a0601437ea744a13b4a42..55c59d87281933b47a0365540f66b91db50eab01 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index bb757d38ce80fb403a0623ee2ce99f09f61e26c0..f1b5d25e4e739bd0dfa202af2a4113a745037bf9 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -64,7 +64,7 @@ namespace Mono.Cecil {
                                if (main_module.HasImage)
                                        return modules = main_module.Read (this, (_, reader) => reader.ReadModules ());
 
-                               return modules = new Collection<ModuleDefinition> { main_module };
+                               return modules = new Collection<ModuleDefinition> (1) { main_module };
                        }
                }
 
index 6d04c59c4c6714797149990478514f88b6e9031e..e466e784410959a704e48f72d7609b5e328cc9d5 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 0e7bf838beebf801a2794a12c1ee9202984170aa..79a5699db6c387f1514d1b1ac55200b228621705 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index b7019815b31948a8e808a29a8a805007735ac863..ffac8eab69051d5667a098afa74fe5aafc9f0d2a 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 68e44f80bfcf09b245f599b4a7b7683075656cbe..4d8bac0bbba8c86da61483e201fdb87fcf8e217a 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 4756cb81a3a44d0ad03159eb05442960b4b9d515..dc6b9057f9222042334e5f2aa22ab036445f1a38 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 2798082ba2fd45596b857773c1919e68e4928ead..c252c52d4f010b284d296364d14936e683d89d5b 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 57c3c15a8e2d59dc2a50ee47091a76f74ad7a62b..96d0e5ad60128ef4894bb184d091dda729289bdb 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -374,7 +374,7 @@ namespace Mono.Cecil {
                        this.image = module.Image;
                        this.module = module;
                        this.metadata = module.MetadataSystem;
-                       this.code = CodeReader.CreateCodeReader (this);
+                       this.code = new CodeReader (image.MetadataSection, this);
                }
 
                int GetCodedIndexSize (CodedIndex index)
@@ -487,27 +487,40 @@ namespace Mono.Cecil {
                        return module;
                }
 
-               public Collection<AssemblyNameReference> ReadAssemblyReferences ()
+               void InitializeAssemblyReferences ()
                {
+                       if (metadata.AssemblyReferences != null)
+                               return;
+
                        int length = MoveTo (Table.AssemblyRef);
-                       var references = new Collection<AssemblyNameReference> (length);
+                       var references = metadata.AssemblyReferences = new AssemblyNameReference [length];
 
-                       for (uint i = 1; i <= length; i++) {
+                       for (uint i = 0; i < length; i++) {
                                var reference = new AssemblyNameReference ();
-                               reference.token = new MetadataToken (TokenType.AssemblyRef, i);
+                               reference.token = new MetadataToken (TokenType.AssemblyRef, i + 1);
 
                                PopulateVersionAndFlags (reference);
 
-                               reference.PublicKeyToken = ReadBlob ();
+                               var key_or_token = ReadBlob ();
+
+                               if (reference.HasPublicKey)
+                                       reference.PublicKey = key_or_token;
+                               else
+                                       reference.PublicKeyToken = key_or_token;
 
                                PopulateNameAndCulture (reference);
 
                                reference.Hash = ReadBlob ();
 
-                               references.Add (reference);
+                               references [i] = reference;
                        }
+               }
 
-                       return references;
+               public Collection<AssemblyNameReference> ReadAssemblyReferences ()
+               {
+                       InitializeAssemblyReferences ();
+
+                       return new Collection<AssemblyNameReference> (metadata.AssemblyReferences);
                }
 
                public MethodDefinition ReadEntryPoint ()
@@ -555,19 +568,27 @@ namespace Mono.Cecil {
                        return Path.Combine (path, name);
                }
 
-               public Collection<ModuleReference> ReadModuleReferences ()
+               void InitializeModuleReferences ()
                {
+                       if (metadata.ModuleReferences != null)
+                               return;
+
                        int length = MoveTo (Table.ModuleRef);
-                       var references = new Collection<ModuleReference> (length);
+                       var references = metadata.ModuleReferences = new ModuleReference [length];
 
-                       for (uint i = 1; i <= length; i++) {
+                       for (uint i = 0; i < length; i++) {
                                var reference = new ModuleReference (ReadString ());
-                               reference.token = new MetadataToken (TokenType.ModuleRef, i);
+                               reference.token = new MetadataToken (TokenType.ModuleRef, i + 1);
 
-                               references.Add (reference);
+                               references [i] = reference;
                        }
+               }
 
-                       return references;
+               public Collection<ModuleReference> ReadModuleReferences ()
+               {
+                       InitializeModuleReferences ();
+
+                       return new Collection<ModuleReference> (metadata.ModuleReferences);
                }
 
                public bool HasFileResource ()
@@ -682,9 +703,24 @@ namespace Mono.Cecil {
                                types.Add (type);
                        }
 
+                       if (image.HasTable (Table.MethodPtr) || image.HasTable (Table.FieldPtr))
+                               CompleteTypes ();
+
                        return types;
                }
 
+               void CompleteTypes ()
+               {
+                       var types = metadata.Types;
+
+                       for (int i = 0; i < types.Length; i++) {
+                               var type = types [i];
+
+                               InitializeCollection (type.Fields);
+                               InitializeCollection (type.Methods);
+                       }
+               }
+
                void InitializeTypeDefinitions ()
                {
                        if (metadata.Types != null)
@@ -1003,13 +1039,12 @@ namespace Mono.Cecil {
                IMetadataScope GetTypeReferenceScope (MetadataToken scope)
                {
                        switch (scope.TokenType) {
-                       // FIXME: both assembly refs and module refs should be in their
-                       // own arrays, in case of someone modify the collections before
-                       // this code is called
                        case TokenType.AssemblyRef:
-                               return module.AssemblyReferences [(int) scope.RID - 1];
+                               InitializeAssemblyReferences ();
+                               return metadata.AssemblyReferences [(int) scope.RID - 1];
                        case TokenType.ModuleRef:
-                               return module.ModuleReferences [(int) scope.RID - 1];
+                               InitializeModuleReferences ();
+                               return metadata.ModuleReferences [(int) scope.RID - 1];
                        case TokenType.Module:
                                return module;
                        default:
@@ -1108,14 +1143,19 @@ namespace Mono.Cecil {
                        var fields = new MemberDefinitionCollection<FieldDefinition> (type, (int) fields_range.Length);
                        this.context = type;
 
-                       MoveTo (Table.Field, fields_range.Start);
-                       for (uint i = 0; i < fields_range.Length; i++)
-                               fields.Add (ReadField (fields_range.Start + i));
+                       if (!MoveTo (Table.FieldPtr, fields_range.Start)) {
+                               if (!MoveTo (Table.Field, fields_range.Start))
+                                       return fields;
+
+                               for (uint i = 0; i < fields_range.Length; i++)
+                                       ReadField (fields_range.Start + i, fields);
+                       } else
+                               ReadPointers (Table.FieldPtr, Table.Field, fields_range, fields, ReadField);
 
                        return fields;
                }
 
-               FieldDefinition ReadField (uint field_rid)
+               void ReadField (uint field_rid, Collection<FieldDefinition> fields)
                {
                        var attributes = (FieldAttributes) ReadUInt16 ();
                        var name = ReadString ();
@@ -1125,7 +1165,10 @@ namespace Mono.Cecil {
                        field.token = new MetadataToken (TokenType.Field, field_rid);
                        metadata.AddFieldDefinition (field);
 
-                       return field;
+                       if (IsDeleted (field))
+                               return;
+
+                       fields.Add (field);
                }
 
                void InitializeFields ()
@@ -1293,18 +1336,24 @@ namespace Mono.Cecil {
 
                        metadata.RemoveEventsRange (type);
 
-                       if (range.Length == 0 || !MoveTo (Table.Event, range.Start))
+                       if (range.Length == 0)
                                return events;
 
                        this.context = type;
 
-                       for (uint i = 0; i < range.Length; i++)
-                               events.Add (ReadEvent (range.Start + i));
+                       if (!MoveTo (Table.EventPtr, range.Start)) {
+                               if (!MoveTo (Table.Event, range.Start))
+                                       return events;
+
+                               for (uint i = 0; i < range.Length; i++)
+                                       ReadEvent (range.Start + i, events);
+                       } else
+                               ReadPointers (Table.EventPtr, Table.Event, range, events, ReadEvent);
 
                        return events;
                }
 
-               EventDefinition ReadEvent (uint event_rid)
+               void ReadEvent (uint event_rid, Collection<EventDefinition> events)
                {
                        var attributes = (EventAttributes) ReadUInt16 ();
                        var name = ReadString ();
@@ -1312,7 +1361,11 @@ namespace Mono.Cecil {
 
                        var @event = new EventDefinition (name, attributes, event_type);
                        @event.token = new MetadataToken (TokenType.Event, event_rid);
-                       return @event;
+
+                       if (IsDeleted (@event))
+                               return;
+
+                       events.Add (@event);
                }
 
                void InitializeEvents ()
@@ -1360,18 +1413,23 @@ namespace Mono.Cecil {
 
                        var properties = new MemberDefinitionCollection<PropertyDefinition> (type, (int) range.Length);
 
-                       if (range.Length == 0 || !MoveTo (Table.Property, range.Start))
+                       if (range.Length == 0)
                                return properties;
 
                        this.context = type;
 
-                       for (uint i = 0; i < range.Length; i++)
-                               properties.Add (ReadProperty (range.Start + i));
+                       if (!MoveTo (Table.PropertyPtr, range.Start)) {
+                               if (!MoveTo (Table.Property, range.Start))
+                                       return properties;
+                               for (uint i = 0; i < range.Length; i++)
+                                       ReadProperty (range.Start + i, properties);
+                       } else
+                               ReadPointers (Table.PropertyPtr, Table.Property, range, properties, ReadProperty);
 
                        return properties;
                }
 
-               PropertyDefinition ReadProperty (uint property_rid)
+               void ReadProperty (uint property_rid, Collection<PropertyDefinition> properties)
                {
                        var attributes = (PropertyAttributes) ReadUInt16 ();
                        var name = ReadString ();
@@ -1393,7 +1451,10 @@ namespace Mono.Cecil {
                        property.HasThis = has_this;
                        property.token = new MetadataToken (TokenType.Property, property_rid);
 
-                       return property;
+                       if (IsDeleted (property))
+                               return;
+
+                       properties.Add (property);
                }
 
                void InitializeProperties ()
@@ -1562,14 +1623,36 @@ namespace Mono.Cecil {
                                return new MemberDefinitionCollection<MethodDefinition> (type);
 
                        var methods = new MemberDefinitionCollection<MethodDefinition> (type, (int) methods_range.Length);
+                       if (!MoveTo (Table.MethodPtr, methods_range.Start)) {
+                               if (!MoveTo (Table.Method, methods_range.Start))
+                                       return methods;
 
-                       MoveTo (Table.Method, methods_range.Start);
-                       for (uint i = 0; i < methods_range.Length; i++)
-                               ReadMethod (methods_range.Start + i, methods);
+                               for (uint i = 0; i < methods_range.Length; i++)
+                                       ReadMethod (methods_range.Start + i, methods);
+                       } else
+                               ReadPointers (Table.MethodPtr, Table.Method, methods_range, methods, ReadMethod);
 
                        return methods;
                }
 
+               void ReadPointers<TMember> (Table ptr, Table table, Range range, Collection<TMember> members, Action<uint, Collection<TMember>> reader)
+                       where TMember : IMemberDefinition
+               {
+                       for (uint i = 0; i < range.Length; i++) {
+                               MoveTo (ptr, range.Start + i);
+
+                               var rid = ReadTableIndex (table);
+                               MoveTo (table, rid);
+
+                               reader (rid, members);
+                       }
+               }
+
+               static bool IsDeleted (IMemberDefinition member)
+               {
+                       return member.IsSpecialName && member.Name == "_Deleted";
+               }
+
                void InitializeMethods ()
                {
                        if (metadata.Methods != null)
@@ -1587,6 +1670,9 @@ namespace Mono.Cecil {
                        method.Name = ReadString ();
                        method.token = new MetadataToken (TokenType.Method, method_rid);
 
+                       if (IsDeleted (method))
+                               return;
+
                        methods.Add (method); // attach method
 
                        var signature = ReadBlobIndex ();
@@ -1607,22 +1693,44 @@ namespace Mono.Cecil {
 
                void ReadParameters (MethodDefinition method, Range param_range)
                {
-                       MoveTo (Table.Param, param_range.Start);
-                       for (uint i = 0; i < param_range.Length; i++) {
-                               var attributes = (ParameterAttributes) ReadUInt16 ();
-                               var sequence = ReadUInt16 ();
-                               var name = ReadString ();
+                       if (!MoveTo (Table.ParamPtr, param_range.Start)) {
+                               if (!MoveTo (Table.Param, param_range.Start))
+                                       return;
+
+                               for (uint i = 0; i < param_range.Length; i++)
+                                       ReadParameter (param_range.Start + i, method);
+                       } else
+                               ReadParameterPointers (method, param_range);
+               }
+
+               void ReadParameterPointers (MethodDefinition method, Range range)
+               {
+                       for (uint i = 0; i < range.Length; i++) {
+                               MoveTo (Table.ParamPtr, range.Start + i);
+
+                               var rid = ReadTableIndex (Table.Param);
 
-                               var parameter = sequence == 0
-                                       ? method.MethodReturnType.Parameter
-                                       : method.Parameters [sequence - 1];
+                               MoveTo (Table.Param, rid);
 
-                               parameter.token = new MetadataToken (TokenType.Param, param_range.Start + i);
-                               parameter.Name = name;
-                               parameter.Attributes = attributes;
+                               ReadParameter (rid, method);
                        }
                }
 
+               void ReadParameter (uint param_rid, MethodDefinition method)
+               {
+                       var attributes = (ParameterAttributes) ReadUInt16 ();
+                       var sequence = ReadUInt16 ();
+                       var name = ReadString ();
+
+                       var parameter = sequence == 0
+                               ? method.MethodReturnType.Parameter
+                               : method.Parameters [sequence - 1];
+
+                       parameter.token = new MetadataToken (TokenType.Param, param_rid);
+                       parameter.Name = name;
+                       parameter.Attributes = attributes;
+               }
+
                void ReadMethodSignature (uint signature, IMethodSignature method)
                {
                        var reader = ReadSignature (signature);
@@ -1749,7 +1857,7 @@ namespace Mono.Cecil {
                                        range.Length++;
                        }
 
-                       if (owner != MetadataToken.Zero)
+                       if (owner != MetadataToken.Zero && !ranges.ContainsKey (owner))
                                ranges.Add (owner, range);
 
                        return ranges;
@@ -2382,7 +2490,7 @@ namespace Mono.Cecil {
                                return;
                        }
 
-                       reader.ReadByte ();
+                       reader.position++;
                        var count = reader.ReadCompressedUInt32 ();
                        var attributes = new Collection<SecurityAttribute> ((int) count);
 
@@ -2442,7 +2550,7 @@ namespace Mono.Cecil {
                                        break;
                                }
 
-                               var exported_type = new ExportedType (@namespace, name, scope) {
+                               var exported_type = new ExportedType (@namespace, name, module, scope) {
                                        Attributes = attributes,
                                        Identifier = (int) identifier,
                                        DeclaringType = declaring_type,
@@ -2457,21 +2565,24 @@ namespace Mono.Cecil {
 
                IMetadataScope GetExportedTypeScope (MetadataToken token)
                {
+                       var position = this.position;
+                       IMetadataScope scope;
+
                        switch (token.TokenType) {
                        case TokenType.AssemblyRef:
-                               return module.AssemblyReferences [(int) token.RID - 1];
+                               InitializeAssemblyReferences ();
+                               scope = metadata.AssemblyReferences [(int) token.RID - 1];
+                               break;
                        case TokenType.File:
-                               var position = this.position;
-                               var reference = GetModuleReferenceFromFile (token);
-                               this.position = position;
-
-                               if (reference == null)
-                                       throw new NotSupportedException ();
-
-                               return reference;
+                               InitializeModuleReferences ();
+                               scope = GetModuleReferenceFromFile (token);
+                               break;
                        default:
                                throw new NotSupportedException ();
                        }
+
+                       this.position = position;
+                       return scope;
                }
 
                ModuleReference GetModuleReferenceFromFile (MetadataToken token)
@@ -2483,16 +2594,15 @@ namespace Mono.Cecil {
                        var file_name = ReadString ();
                        var modules = module.ModuleReferences;
 
-                       ModuleReference reference = null;
+                       ModuleReference reference;
                        for (int i = 0; i < modules.Count; i++) {
-                               var module_reference = modules [i];
-                               if (module_reference.Name != file_name)
-                                       continue;
-
-                               reference = module_reference;
-                               break;
+                               reference = modules [i];
+                               if (reference.Name == file_name)
+                                       return reference;
                        }
 
+                       reference = new ModuleReference (file_name);
+                       modules.Add (reference);
                        return reference;
                }
 
@@ -2684,9 +2794,21 @@ namespace Mono.Cecil {
                public void ReadMethodSignature (IMethodSignature method)
                {
                        var calling_convention = ReadByte ();
+
+                       const byte has_this = 0x20;
+                       const byte explicit_this = 0x40;
+
+                       if ((calling_convention & has_this) != 0) {
+                               method.HasThis = true;
+                               calling_convention = (byte) (calling_convention & ~has_this);
+                       }
+
+                       if ((calling_convention & explicit_this) != 0) {
+                               method.ExplicitThis = true;
+                               calling_convention = (byte) (calling_convention & ~explicit_this);
+                       }
+
                        method.CallingConvention = (MethodCallingConvention) calling_convention;
-                       method.HasThis = (calling_convention & 0x20) != 0;
-                       method.ExplicitThis = (calling_convention & 0x40) != 0;
 
                        var generic_context = method as MethodReference;
                        if (generic_context != null)
@@ -2699,8 +2821,6 @@ namespace Mono.Cecil {
                                        CheckGenericContext (generic_context, (int) arity -1 );
                        }
 
-                       // TODO: more call_conv
-
                        var param_count = ReadCompressedUInt32 ();
 
                        method.MethodReturnType.ReturnType = ReadTypeSignature ();
index 8dd9145083c6d556359fb455a8f2c28e2196b0c4..f05bf821cefe055148b565f5fb1d0b78af60dd9c 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -1932,21 +1932,13 @@ namespace Mono.Cecil {
                SignatureWriter GetSecurityDeclarationSignature (SecurityDeclaration declaration)
                {
                        var signature = CreateSignatureWriter ();
-                       if (!declaration.resolved) {
-                               signature.WriteBytes (declaration.GetBlob ());
-                               return signature;
-                       }
-
-                       signature.WriteByte ((byte) '.');
-
-                       var attributes = declaration.security_attributes;
-                       if (attributes == null)
-                               throw new NotSupportedException ();
 
-                       signature.WriteCompressedUInt32 ((uint) attributes.Count);
-
-                       for (int i = 0; i < attributes.Count; i++)
-                               signature.WriteSecurityAttribute (attributes [i]);
+                       if (!declaration.resolved)
+                               signature.WriteBytes (declaration.GetBlob ());
+                       else if (module.Runtime < TargetRuntime.Net_2_0)
+                               signature.WriteXmlSecurityDeclaration (declaration);
+                       else
+                               signature.WriteSecurityDeclaration (declaration);
 
                        return signature;
                }
@@ -2449,7 +2441,7 @@ namespace Mono.Cecil {
                        WriteCustomAttributeFixedArgument (argument.Type, argument);
                }
 
-               public void WriteSecurityAttribute (SecurityAttribute attribute)
+               void WriteSecurityAttribute (SecurityAttribute attribute)
                {
                        WriteTypeReference (attribute.AttributeType);
 
@@ -2469,6 +2461,49 @@ namespace Mono.Cecil {
                        WriteBytes (buffer);
                }
 
+               public void WriteSecurityDeclaration (SecurityDeclaration declaration)
+               {
+                       WriteByte ((byte) '.');
+
+                       var attributes = declaration.security_attributes;
+                       if (attributes == null)
+                               throw new NotSupportedException ();
+
+                       WriteCompressedUInt32 ((uint) attributes.Count);
+
+                       for (int i = 0; i < attributes.Count; i++)
+                               WriteSecurityAttribute (attributes [i]);
+               }
+
+               public void WriteXmlSecurityDeclaration (SecurityDeclaration declaration)
+               {
+                       var xml = GetXmlSecurityDeclaration (declaration);
+                       if (xml == null)
+                               throw new NotSupportedException ();
+
+                       WriteBytes (Encoding.Unicode.GetBytes (xml));
+               }
+
+               static string GetXmlSecurityDeclaration (SecurityDeclaration declaration)
+               {
+                       if (declaration.security_attributes == null || declaration.security_attributes.Count != 1)
+                               return null;
+
+                       var attribute = declaration.security_attributes [0];
+
+                       if (!attribute.AttributeType.IsTypeOf ("System.Security.Permissions", "PermissionSetAttribute"))
+                               return null;
+
+                       if (attribute.properties == null || attribute.properties.Count != 1)
+                               return null;
+
+                       var property = attribute.properties [0];
+                       if (property.Name != "XML")
+                               return null;
+
+                       return (string) property.Argument.Value;
+               }
+
                void WriteTypeReference (TypeReference type)
                {
                        WriteUTF8String (TypeParser.ToParseable (type));
index e449a032331cd746f204d082998e04ccb200ed1a..140cc96c0b75562f3eead60140e08003c3fb1229 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -51,6 +51,21 @@ namespace Mono.Cecil {
                }
        }
 
+       public class AssemblyResolutionException : FileNotFoundException {
+
+               readonly AssemblyNameReference reference;
+
+               public AssemblyNameReference AssemblyReference {
+                       get { return reference; }
+               }
+
+               public AssemblyResolutionException (AssemblyNameReference reference)
+                       : base (string.Format ("Failed to resolve assembly: '{0}'", reference))
+               {
+                       this.reference = reference;
+               }
+       }
+
        public abstract class BaseAssemblyResolver : IAssemblyResolver {
 
                static readonly bool on_mono = Type.GetType ("Mono.Runtime") != null;
@@ -152,7 +167,7 @@ namespace Mono.Cecil {
                                        return assembly;
                        }
 
-                       throw new FileNotFoundException ("Could not resolve: " + name);
+                       throw new AssemblyResolutionException (name);
                }
 
                AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable<string> directories, ReaderParameters parameters)
@@ -318,10 +333,11 @@ namespace Mono.Cecil {
 
                static string GetAssemblyFile (AssemblyNameReference reference, string prefix, string gac)
                {
-                       var gac_folder = new StringBuilder ();
-                       gac_folder.Append (prefix);
-                       gac_folder.Append (reference.Version);
-                       gac_folder.Append ("__");
+                       var gac_folder = new StringBuilder ()
+                               .Append (prefix)
+                               .Append (reference.Version)
+                               .Append ("__");
+
                        for (int i = 0; i < reference.PublicKeyToken.Length; i++)
                                gac_folder.Append (reference.PublicKeyToken [i].ToString ("x2"));
 
index 4430bd871cca414e195d6776bd222f9f354909a9..2d4ed4175980cc3402cc5e4f057adc00621dfeb4 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 using System;
 using System.Text;
 
+using Mono.Collections.Generic;
+
 namespace Mono.Cecil {
 
-       public sealed class CallSite : MethodReference {
+       public sealed class CallSite : IMethodSignature {
+
+               readonly MethodReference signature;
 
-               public override string FullName {
+               public bool HasThis {
+                       get { return signature.HasThis; }
+                       set { signature.HasThis = value; }
+               }
+
+               public bool ExplicitThis {
+                       get { return signature.ExplicitThis; }
+                       set { signature.ExplicitThis = value; }
+               }
+
+               public MethodCallingConvention CallingConvention {
+                       get { return signature.CallingConvention; }
+                       set { signature.CallingConvention = value; }
+               }
+
+               public bool HasParameters {
+                       get { return signature.HasParameters; }
+               }
+
+               public Collection<ParameterDefinition> Parameters {
+                       get { return signature.Parameters; }
+               }
+
+               public TypeReference ReturnType {
+                       get { return signature.MethodReturnType.ReturnType; }
+                       set { signature.MethodReturnType.ReturnType = value; }
+               }
+
+               public MethodReturnType MethodReturnType {
+                       get { return signature.MethodReturnType; }
+               }
+
+               public string Name {
+                       get { return string.Empty; }
+                       set { throw new InvalidOperationException (); }
+               }
+
+               public string Namespace {
+                       get { return string.Empty; }
+                       set { throw new InvalidOperationException (); }
+               }
+
+               public ModuleDefinition Module {
+                       get { return ReturnType.Module; }
+               }
+
+               public IMetadataScope Scope {
+                       get { return signature.ReturnType.Scope; }
+               }
+
+               public MetadataToken MetadataToken {
+                       get { return signature.token; }
+                       set { signature.token = value; }
+               }
+
+               public string FullName {
                        get {
                                var signature = new StringBuilder ();
                                signature.Append (ReturnType.FullName);
@@ -42,13 +101,24 @@ namespace Mono.Cecil {
                        }
                }
 
-               public override ModuleDefinition Module {
-                       get { return ReturnType.Module; }
+               internal CallSite ()
+               {
+                       this.signature = new MethodReference ();
+                       this.signature.token = new MetadataToken (TokenType.Signature, 0);
+               }
+
+               public CallSite (TypeReference returnType)
+                       : this ()
+               {
+                       if (returnType == null)
+                               throw new ArgumentNullException ("returnType");
+
+                       this.signature.ReturnType = returnType;
                }
 
-               public override MethodDefinition Resolve ()
+               public override string ToString ()
                {
-                       return null;
+                       return FullName;
                }
        }
 }
index 40b32ebdb1a7504b49cf53beb8ff106204b07d53..310f7258910f9ff5572d5d894c93c2d4ee4592d8 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index cac7974f9e7dc32258dacb1febcfd0857522853f..93d249391506728b10c0508895aec2e86b02b3f6 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index bb9f1f957852bd2bebd8aabc52f3c7b827872c30..e12dd0b37899cf40fd6d6fe73278ca361c2423b0 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index b5b097d4f57068df9b96829b3c545e4561e6c1d6..815efa57b7fc4c9824035a0b5cd0ee6ae75dfcb5 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 7a80aa06d822f27492d92930b1571bc1d88301e2..565186c5d785d9ffacf63850a18a6c70ad0f584d 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -159,5 +159,10 @@ namespace Mono.Cecil {
 
                        module.Read (this, (@event, reader) => reader.ReadMethods (@event));
                }
+
+               public override EventDefinition Resolve ()
+               {
+                       return this;
+               }
        }
 }
index e1435dac9cb8703b073592e5a9860ca4a4cbc865..8952002d6c2e4c8f5d3b5815ce622b6061afb290 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -51,5 +51,7 @@ namespace Mono.Cecil {
 
                        event_type = eventType;
                }
+
+               public abstract EventDefinition Resolve ();
        }
 }
index a1e793a1975b08e632530dd1d8c93fa60de5a49b..c25f8d05eac56df8d80d8537023fce6026ff1e92 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -36,6 +36,7 @@ namespace Mono.Cecil {
                string name;
                uint attributes;
                IMetadataScope scope;
+               ModuleDefinition module;
                int identifier;
                ExportedType declaring_type;
                internal MetadataToken token;
@@ -220,16 +221,29 @@ namespace Mono.Cecil {
                        }
                }
 
-               public ExportedType (string @namespace, string name, IMetadataScope scope)
+               public ExportedType (string @namespace, string name, ModuleDefinition module, IMetadataScope scope)
                {
                        this.@namespace = @namespace;
                        this.name = name;
                        this.scope = scope;
+                       this.module = module;
                }
 
                public override string ToString ()
                {
                        return FullName;
                }
+
+               public TypeDefinition Resolve ()
+               {
+                       return module.Resolve (CreateReference ());
+               }
+
+               internal TypeReference CreateReference ()
+               {
+                       return new TypeReference (@namespace, name, module, scope) {
+                               DeclaringType = declaring_type != null ? declaring_type.CreateReference () : null,
+                       };
+               }
        }
 }
index 947a8770af07fedbe7d473ba8ebb2ff00866e1cc..dd6bf361dc13b9a3cc485abea6a580063e3dbe50 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index c60a940051c83107a8f14fa6deffe58d7cc5cb5e..29a1bc12cef9965b1b837bd95a4ab81277aed669 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 1c812bb90eff23188c3c2da8779fd33cb4057f35..be58d3d0630ac221c85e089db8a53880acaafe6a 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 6c2781c624469b20d5951018591120eebb26693f..4d3b6ca7ff7718d6e46d6cf86d0964f363688b4b 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index f7bf08c3f9aa80b4dc4e59ae1416e20ed2ced466..db80f76215e5cd718a41f4189fa32fdc2a53b328 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index d5d8d4ecd4986083f777b1054782b6f0236db748..dbe720df56001fde4e490775dceaca01479363f6 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -42,12 +42,7 @@ namespace Mono.Cecil {
                }
 
                public Collection<TypeReference> GenericArguments {
-                       get {
-                               if (arguments == null)
-                                       arguments = new Collection<TypeReference> ();
-
-                               return arguments;
-                       }
+                       get { return arguments ?? (arguments = new Collection<TypeReference> ()); }
                }
 
                public override bool IsGenericInstance {
index 46c048bcd3ece6e55025363cf66f860821912cab..6554ff0e89c0cb6fb12f703a681e1ea97aca41e2 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -44,12 +44,7 @@ namespace Mono.Cecil {
                }
 
                public Collection<TypeReference> GenericArguments {
-                       get {
-                               if (arguments == null)
-                                       arguments = new Collection<TypeReference> ();
-
-                               return arguments;
-                       }
+                       get { return arguments ?? (arguments = new Collection<TypeReference> ()); }
                }
 
                public override TypeReference DeclaringType {
index d3e5a15d5d473ae520f905809bb0a77bc786f352..2d0c19031d421ffdd011274a36a00ae222023472 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -97,10 +97,6 @@ namespace Mono.Cecil {
                        get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); }
                }
 
-               internal new bool HasImage {
-                       get { return Module != null && Module.HasImage; }
-               }
-
                public override IMetadataScope Scope {
                        get {
                                if (owner.GenericParameterType == GenericParameterType.Method)
index 89996140e724f8c5a0f313b6f1a32f1c606c6fb4..6d77956de3961ebd25eb9047e0595e4e0ea6092f 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index e3338cf20d34302e18912a6b781faf9c6d4db382..8bcd7d7f02ee8758121f30ffe6890d54a09d99c0 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 08e5f925abb9248bf7d3e35b185b529082216d81..2e3e8e5e75fc767bb42d4e42a20d95c11b892957 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 2750ad0a696b4bbc0425cdecd7f923fe33c38613..edc406ca10a95fafe510d84030fd0f0d28fd8be2 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 27d1669fcd8ffec71c822c62f09f78322303bdf5..4fc4ce1b9b03eeb0acd6dae8ed4d18aa4b7363c7 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index a3bba6d0d6acd13c469c0a2acf9efcbf1012e251..de83cf632e55faa4974fdb6a8c1a7428b0943e0b 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 09878f78f99e5472cd92af51340ef2e201ee2db2..ee73d9da49beb8288b5aa83c689ea77772606345 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index f0ab506e5476973a171e5e55f758f8c295db9d8e..04a0228105c1490ecc2add5e0e0458cc9619c995 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index ff777248189afbf638ce1eb15d2e5dc689a76068..6621835b2938b2f424e79a7300816be6efe87f2a 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 6bae56adca0030e91df04169455d0c4260e5aac3..491deec5db0c46e43ecdabe79c0ab238fe6e287b 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 93e700e8a9e67ca3f403c8772387adf251a40ce6..2a8293c0c32193f3d6578acec9ebebd8090ecfc3 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index a5530fc13c8912af767c10d42e2529e76f1bcfa2..16c1d59b5a081c17341cf6971a417da60010ac57 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index d72d1d0c74192492d2b46d72adc24dc54c516677..7d6bb190f441132be22fcb20c9cb39f262404318 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 1fce23a8d782ae2d27feff87ef985a97a32b5182..9d58738923515608424ec7506fef7454cd3d76af 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 1e703026e696025d16c3e4af9477d702cfa8d445..707f36fb97b6a4654516a42b82b852f1e8df53c6 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index b3edf39972c755b6d5f1e13578f1b891ef5a4ce0..b658c513deecc9f2eb6a04eb7b8676cb103ac930 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 2ce17553ba7c0965b4ab0fe4241e986c1eab346c..0b912e362c2f4dc9ddb3c70b751a3350f4505dc6 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -69,16 +69,16 @@ namespace Mono.Cecil {
                                if (assembly == null)
                                        return null;
 
-                               return GetType (assembly.MainModule, type);
+                               return GetType (resolver, assembly.MainModule, type);
                        case MetadataScopeType.ModuleDefinition:
-                               return GetType ((ModuleDefinition) scope, type);
+                               return GetType (resolver, (ModuleDefinition) scope, type);
                        case MetadataScopeType.ModuleReference:
                                var modules = type.Module.Assembly.Modules;
                                var module_ref = (ModuleReference) scope;
                                for (int i = 0; i < modules.Count; i++) {
                                        var netmodule = modules [i];
                                        if (netmodule.Name == module_ref.Name)
-                                               return GetType (netmodule, type);
+                                               return GetType (resolver, netmodule, type);
                                }
                                break;
                        }
@@ -86,6 +86,31 @@ namespace Mono.Cecil {
                        throw new NotSupportedException ();
                }
 
+               static TypeDefinition GetType (IAssemblyResolver resolver, ModuleDefinition module, TypeReference reference)
+               {
+                       var type = GetType (module, reference);
+                       if (type != null)
+                               return type;
+
+                       if (!module.HasExportedTypes)
+                               return null;
+
+                       var exported_types = module.ExportedTypes;
+
+                       for (int i = 0; i < exported_types.Count; i++) {
+                               var exported_type = exported_types [i];
+                               if (exported_type.Name != reference.Name)
+                                       continue;
+
+                               if (exported_type.Namespace != reference.Namespace)
+                                       continue;
+
+                               return exported_type.Resolve ();
+                       }
+
+                       return null;
+               }
+
                static TypeDefinition GetType (ModuleDefinition module, TypeReference type)
                {
                        if (!type.IsNested)
@@ -181,6 +206,12 @@ namespace Mono.Cecil {
                                if (method.Name != reference.Name)
                                        continue;
 
+                               if (method.HasGenericParameters != reference.HasGenericParameters)
+                                       continue;
+
+                               if (method.HasGenericParameters && method.GenericParameters.Count != reference.GenericParameters.Count)
+                                       continue;
+
                                if (!AreSame (method.ReturnType, reference.ReturnType))
                                        continue;
 
@@ -250,12 +281,6 @@ namespace Mono.Cecil {
 
                static bool AreSame (GenericInstanceType a, GenericInstanceType b)
                {
-                       if (!a.HasGenericArguments)
-                               return !b.HasGenericArguments;
-
-                       if (!b.HasGenericArguments)
-                               return false;
-
                        if (a.GenericArguments.Count != b.GenericArguments.Count)
                                return false;
 
@@ -273,6 +298,12 @@ namespace Mono.Cecil {
 
                static bool AreSame (TypeReference a, TypeReference b)
                {
+                       if (ReferenceEquals (a, b))
+                               return true;
+
+                       if (a == null || b == null)
+                               return false;
+
                        if (a.etype != b.etype)
                                return false;
 
@@ -282,7 +313,12 @@ namespace Mono.Cecil {
                        if (a.IsTypeSpecification ())
                                return AreSame ((TypeSpecification) a, (TypeSpecification) b);
 
-                       return a.FullName == b.FullName;
+                       if (a.Name != b.Name || a.Namespace != b.Namespace)
+                               return false;
+
+                       //TODO: check scope
+
+                       return AreSame (a.DeclaringType, b.DeclaringType);
                }
        }
 }
index e2196afbf68b50db2274bb3590209a2d7ce21660..bfe7fc58f8fc907a5dc306b37c3b763a95b42304 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -46,6 +46,9 @@ namespace Mono.Cecil {
 
        sealed class MetadataSystem {
 
+               internal AssemblyNameReference [] AssemblyReferences;
+               internal ModuleReference [] ModuleReferences;
+
                internal TypeDefinition [] Types;
                internal TypeReference [] TypeReferences;
 
index 3446702b5a4757a0855662f48599143c9ba54f59..626a97b3ea8977c346a70440b8c2628a0db81402 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index c96dc1cf25fb624c9cc205a12d527861ab7eae22..bd7188dbec26cabc2475bcdc7eec5ee72385bab4 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 3b74e5a7dbd676afe3108cde0f24144b1cff620f..cbda745b7ea88355da012f4bdbed1bf085c21041 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 8a2b422cc7b8035938378eb9d5fe87f056daeb34..94d8771a9b3e1343e5ccdad800ae3bc85642073f 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 6a9dbe926543933c1b1a6b9e251f44bda339c352..21de336735c4d8d2d0348dec75493ed23d6853de 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 045b9a876f8542455a7cc4b4ab4fac82a4760f22..f2d3c00f89ee78085a6e5810c25c8a1eb4580a8b 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index f44a3fa8126410a907c7af61a5cad9be4de8ecf0..dd0f4742c0abc7d963ba4bde8889b159dbb02052 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index e907d6cc0058f0f9451a52099013716e1c7a3408..73b5c14ad65c46307144385b3ed0ea5729506156 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index f7ff611acbb427fddb28285602677a46580816ea..ad31bc04f15521dcc654f50c76b603c1b83bd2ef 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 7c793f5a250eb689834774287511a4617397baf0..ecfbf82b80d5b8ef8885d004b220d62e435652b8 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -439,7 +439,7 @@ namespace Mono.Cecil {
                        if (!HasImage)
                                return false;
 
-                       return Read (this, (_, reader) => reader.GetTypeReference (scope, fullName) != null);
+                       return GetTypeReference (scope, fullName) != null;
                }
 
                public bool TryGetTypeReference (string fullName, out TypeReference type)
@@ -456,7 +456,12 @@ namespace Mono.Cecil {
                                return false;
                        }
 
-                       return (type = Read (this, (_, reader) => reader.GetTypeReference (scope, fullName))) != null;
+                       return (type = GetTypeReference (scope, fullName)) != null;
+               }
+
+               TypeReference GetTypeReference (string scope, string fullname)
+               {
+                       return Read (new Row<string, string> (scope, fullname), (row, reader) => reader.GetTypeReference (row.Col1, row.Col2));
                }
 
                public IEnumerable<TypeReference> GetTypeReferences ()
@@ -493,6 +498,26 @@ namespace Mono.Cecil {
                        return ((TypeDefinitionCollection) this.Types).GetType (@namespace ?? string.Empty, name);
                }
 
+               public IEnumerable<TypeDefinition> GetTypes ()
+               {
+                       return GetTypes (Types);
+               }
+
+               static IEnumerable<TypeDefinition> GetTypes (Collection<TypeDefinition> types)
+               {
+                       for (int i = 0; i < types.Count; i++) {
+                               var type = types [i];
+
+                               yield return type;
+
+                               if (!type.HasNestedTypes)
+                                       continue;
+
+                               foreach (var nested in GetTypes (type.NestedTypes))
+                                       yield return nested;
+                       }
+               }
+
                static void CheckFullName (string fullName)
                {
                        if (fullName == null)
@@ -755,7 +780,7 @@ namespace Mono.Cecil {
 
                public IMetadataTokenProvider LookupToken (MetadataToken token)
                {
-                       return Read (this, (_, reader) => reader.LookupToken (token));
+                       return Read (token, (t, reader) => reader.LookupToken (t));
                }
 
                internal TRet Read<TItem, TRet> (TItem item, Func<TItem, MetadataReader, TRet> read)
index eb57890a9b7604e88dedd4c2c8f65b1ff84f2638..e5f745824c5001057638d56da39ab0b7d79daeca 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 0b6e49aba171a6d3d261f799a4954fe0b954c20c..3934b3ceb839dd6f15428d7968be12bdb4b3b8c2 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index afa107f0764346e634bdfa55f15cc6ada6a77ef1..88da9805e87b2c7aad9dbaca6ae885c9682ba6d8 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index fc94692537f34ec0043a6b5a8860bf9d423f71bd..bb36838253d93560292a624c7eb0f067dc9962b9 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -53,7 +53,7 @@ namespace Mono.Cecil {
 
                BestFitMask                     = 0x0030,
                BestFitEnabled          = 0x0010,
-               BestFidDisabled         = 0x0020,
+               BestFitDisabled         = 0x0020,
 
                ThrowOnUnmappableCharMask = 0x3000,
                ThrowOnUnmappableCharEnabled = 0x1000,
index 53aae2c38dec1594bbd49a643761af1aad571061..cfd817c8d05ee72e83f3bfe90c4b9d81c89b2ef6 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -106,14 +106,14 @@ namespace Mono.Cecil {
                        set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvFastcall, value); }
                }
 
-               public bool IsBestFistEnabled {
+               public bool IsBestFitEnabled {
                        get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitEnabled); }
                        set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitEnabled, value); }
                }
 
-               public bool IsBestFistDisabled {
-                       get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFidDisabled); }
-                       set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFidDisabled, value); }
+               public bool IsBestFitDisabled {
+                       get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitDisabled); }
+                       set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitDisabled, value); }
                }
 
                public bool IsThrowOnUnmappableCharEnabled {
index 8c12b548173572c4e9454a270b9e9fc1c551b219..e0bc825d8b3416819089d8ded1ca90e89243a8d3 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 059f257fc3b02495b01a9600ea122e590ab249d8..8902615bbdd6314780152b2483d6714e92e53f6b 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -49,6 +49,15 @@ namespace Mono.Cecil {
                        get { return method; }
                }
 
+               public int Sequence {
+                       get {
+                               if (method == null)
+                                       return -1;
+
+                               return method.HasThis ? index + 1 : index;
+                       }
+               }
+
                public bool HasConstant {
                        get {
                                ResolveConstant ();
index 86538bb9abf599676b7be2a4244f55bc0bf565bb..bd8b1c1390e9b02a040840235ac8f4c302b0dfe8 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index cfe648f2e05630afe38d23b7921eab3c66896462..46b057cd9f3dfb77f4af39f196e06f6f9e1f1c7f 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index d5e7a80c09a9743386b49b1fe1b332765ec86376..ff59cfb7e18cf6d9fd6776ec4d11b86b840f2f06 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 54ab77519a856f8bf50617543b8f42a4a8308ae0..a142e144095404a3184907caef9b07339f1d34f1 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index ad6fd9e8f04f7289688b541c2e6fde6f9eb6ffd5..1be0413f287b03fbc07790e205ec02562fa78fd5 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 835a929a7612c14903a04beaa09250e718bcc04e..42878a0948a1c618b6da40ee65b4380a06d3de6a 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -127,6 +127,8 @@ namespace Mono.Cecil {
 
                public bool HasParameters {
                        get {
+                               InitializeMethods ();
+
                                if (get_method != null)
                                        return get_method.HasParameters;
 
@@ -254,5 +256,10 @@ namespace Mono.Cecil {
 
                        module.Read (this, (property, reader) => reader.ReadMethods (property));
                }
+
+               public override PropertyDefinition Resolve ()
+               {
+                       return this;
+               }
        }
 }
index 5022cd326c946db67bdac84a499c646093e9b824..0dcfc952fef8c5fbab1f8154648c33734a2c402b 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -53,5 +53,7 @@ namespace Mono.Cecil {
 
                        property_type = propertyType;
                }
+
+               public abstract PropertyDefinition Resolve ();
        }
 }
index 3a6b326d49cc54d3dd2928e6c8231ad62ee0bec5..7940c617c7882e3750f427e5930780ac4877387d 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 0432ae78986e7cc71b57694f5df987ad8a3a3f0f..eff7f41aa1c37aba8ef20305f3708dad35a70d5f 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 4e57adae3e134e24f3f7fa212f83044b594ce09d..ecafbc24a6bebb2fbe50d398bbda25149e492616 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -142,7 +142,7 @@ namespace Mono.Cecil {
                        if (!HasImage || signature == 0)
                                throw new NotSupportedException ();
 
-                       return module.Read (this, (declaration, reader) => reader.ReadSecurityDeclarationBlob (declaration.signature)); ;
+                       return module.Read (this, (declaration, reader) => reader.ReadSecurityDeclarationBlob (declaration.signature));
                }
 
                void Resolve ()
index d0d5a1d1ea8fc456856d3eaa06623e2d5b6b576e..664d75bfd89cdd34274a2338f1eec16a9124f961 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 9931fc6113d472d42365154c8f4126056d2134a1..9b49a5f77e29b9ccc2e0b562d0db35326cce30c8 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 6e263e8e64c6695f362a417efde47a1b38d025fd..bc4e18f33620da20c42104015a54601446c8fe10 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index c83531a0567a5adf8ff038b2733b1f948cbc9541..a1575e1b0ec70f3975ccca8a766cdf3e75dceeb3 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -161,10 +161,6 @@ namespace Mono.Cecil {
                        }
                }
 
-               internal new bool HasImage {
-                       get { return Module != null && Module.HasImage; }
-               }
-
                public bool HasMethods {
                        get {
                                if (methods != null)
index 702fe271e6afefc87cc1510d9ed2076bebc71eb5..eae712282f91d4f7f552411f42466cabdc43e6ed 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index df6acf3e8df99015a60acef8cf9f2ce975e1b239..733c422d2a70a55ae247f808dffe4384982027ac 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -356,6 +356,7 @@ namespace Mono.Cecil {
                        SplitFullName (type_info.type_fullname, out @namespace, out name);
 
                        var type = new TypeReference (@namespace, name, module, scope);
+                       MetadataSystem.TryProcessPrimitiveType (type);
 
                        AdjustGenericParameters (type);
 
index 596ae699499c16bf0c882e381c89566392de6e97..f4861245f42e5179bef096e4af7621b35f70e211 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index da4e726437485c1621f3da2ff837b69f11498516..aa9b653f07a7e9bd68da083608eddf5ffa2e1ed9 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 0b0ba91b9b58ac10bfc8ed97b4328406c8ca2a21..dc20b7b161187b28d69e7424b8d79555dc0eaaa5 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -47,7 +47,7 @@ namespace Mono.Cecil {
                                if (metadata.Types == null)
                                        Initialize (module.Types);
 
-                               return module.Read (this, (_, reader) => {
+                               return module.Read (new Row<string, string> (@namespace, name), (row, reader) => {
                                        var types = reader.metadata.Types;
 
                                        for (int i = 0; i < types.Length; i++) {
@@ -56,7 +56,7 @@ namespace Mono.Cecil {
 
                                                var type = types [i];
 
-                                               if (type.Name == name && type.Namespace == @namespace)
+                                               if (type.Name == row.Col2 && type.Namespace == row.Col1)
                                                        return type;
                                        }
 
index 86d6daaa6a662ed5177724b5d7f8df399652c276..76562f6e6f7ac30e90702b777e152100e59fb563 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 1137978aa3607c00190e114054fe5a28e016ec6d..4d927176081a93b396f8dc76ea023d8d7bee7a72 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -115,6 +115,9 @@ namespace Mono.Collections.Generic {
 
                public Collection (ICollection<T> items)
                {
+                       if (items == null)
+                               throw new ArgumentNullException ("items");
+
                        this.items = new T [items.Count];
                        items.CopyTo (this.items, 0);
                        this.size = this.items.Length;
index 35c9cd8dde8353588cf392bb8eaabc28ce6e0b86..7f24df699e2ae061050d59087182a5a5d1fc7ac2 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 
 using System;
 using System.Collections;
+using System .Collections.Generic;
 
 namespace Mono.Collections.Generic {
 
-       public sealed class ReadOnlyCollection<T> : Collection<T>, IList {
+       public sealed class ReadOnlyCollection<T> : Collection<T>, ICollection<T>, IList {
 
                static ReadOnlyCollection<T> empty;
 
@@ -39,6 +40,14 @@ namespace Mono.Collections.Generic {
                        get { return empty ?? (empty = new ReadOnlyCollection<T> ()); }
                }
 
+               bool ICollection<T>.IsReadOnly {
+                       get { return true; }
+               }
+
+               bool IList.IsFixedSize {
+                       get { return true; }
+               }
+
                bool IList.IsReadOnly {
                        get { return true; }
                }
@@ -52,8 +61,7 @@ namespace Mono.Collections.Generic {
                        if (array == null)
                                throw new ArgumentNullException ();
 
-                       this.items = array;
-                       this.size = array.Length;
+                       Initialize (array, array.Length);
                }
 
                public ReadOnlyCollection (Collection<T> collection)
@@ -61,8 +69,14 @@ namespace Mono.Collections.Generic {
                        if (collection == null)
                                throw new ArgumentNullException ();
 
-                       this.items = collection.items;
-                       this.size = collection.size;
+                       Initialize (collection.items, collection.size);
+               }
+
+               void Initialize (T [] items, int size)
+               {
+                       this.items = new T [size];
+                       Array.Copy (items, 0, this.items, 0, size);
+                       this.size = size;
                }
 
                internal override void Grow (int desired)
index f504f5eb62d89d38a6cd434cffc1a2fdd2435d94..58b6cfabc6d9ed7b06f969ba0d735783695e1757 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index 071b149885a19dcd031146b5717fd536318e8d4a..756438f84e32af760bf09f97ca3a3822144e4136 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -30,7 +30,7 @@
 
 namespace Mono {
        //delegate void Action ();
-       //delegate void Action<T1, T2> (T1 arg1, T2 arg2);
+       delegate void Action<T1, T2> (T1 arg1, T2 arg2);
        //delegate void Action<T1, T2, T3> (T1 arg1, T2 arg2, T3 arg3);
        //delegate void Action<T1, T2, T3, T4> (T1 arg1, T2 arg2, T3 arg3, T4 arg4);
 }
index 70739af582caa32cd113b06115270a3583444bd1..d043a35fa5d979c0ee9715199f5286d1b99a7ca1 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -26,9 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
-using System.Collections;
-using System.Collections.Generic;
+using Mono.Collections.Generic;
 
 namespace Mono {
 
@@ -47,9 +45,9 @@ namespace Mono.Cecil {
                        return self == null || self.Length == 0;
                }
 
-               public static bool IsNullOrEmpty<T> (this ICollection<T> self)
+               public static bool IsNullOrEmpty<T> (this Collection<T> self)
                {
-                       return self == null || self.Count == 0;
+                       return self == null || self.size == 0;
                }
        }
 }
index 40f2225956299ffd314d625001daeea7b0354f61..87bc6e977300ed322a13385ff72ad41b5360a311 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index ae79cda721b643e020f97871ec86f15bd7c2e808..bb24f980d2ed36d440127aa987d0f658271d21ff 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
index c2b2017289b416c9d65c07345006a56ecc354179..0de762b41372facf2b84226a0b5b7112203bc544 100644 (file)
@@ -1 +1 @@
-5f427237847cd9acb3bb14317c83f7c67a04ab41
+90e481c594502333d400226b3d4198dfd26964b2