Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-addins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJb Evain <jbevain@gmail.com>2010-11-24 13:59:14 +0300
committerJb Evain <jbevain@gmail.com>2010-11-24 13:59:14 +0300
commite857d35a9198ac3f02a9717000164bf2c5007d15 (patch)
tree9126358a3a5f4d59a8a1148fcfc6b64bd6351053
parentdbff314578ce5513cb0bd026a43b7897399a5bd3 (diff)
parent2e33023838643d1a3a623a42ee2aec5919ca8d25 (diff)
Merge branch 'cecil-light'
-rw-r--r--Mono.Addins.CecilReflector/Makefile.am265
-rw-r--r--Mono.Addins.CecilReflector/Mono.Addins.CecilReflector.csproj356
-rw-r--r--Mono.Addins.CecilReflector/Mono.Addins.CecilReflector/Reflector.cs107
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/.gitignore7
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/AUTHORS1
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/ChangeLog3920
-rwxr-xr-xMono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-attributes.rb226
-rwxr-xr-xMono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-sources.rb14
-rwxr-xr-xMono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-tests.rb61
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-types.rb262
-rwxr-xr-xMono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen.rb161
-rwxr-xr-xMono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-mig.rb159
-rwxr-xr-xMono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-update-rev51
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil.xml608
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/BaseMetadataVisitor.cs112
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Code.cs37
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/CodedIndex.cs38
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/IMetadataVisitor.cs65
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/IndexedCollection.cs296
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataRowReader.cs110
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataRowWriter.cs145
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataTableReader.cs97
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataTableWriter.cs98
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/NamedCollection.cs232
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/OpCodes.cs67
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Table.cs81
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Tests.cs116
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Utilities.cs211
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Makefile12
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/BaseImageVisitor.cs101
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CLIHeader.cs68
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CopyImageVisitor.cs119
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DOSHeader.cs75
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DataDirectory.cs87
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugHeader.cs73
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugStoreType.cs45
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ExportTable.cs59
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitable.cs35
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitor.cs51
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IHeader.cs34
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Image.cs236
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageCharacteristics.cs57
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageFormatException.cs53
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs139
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageReader.cs472
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageWriter.cs427
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Imports.cs98
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/MemoryBinaryWriter.cs70
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEFileHeader.cs58
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEOptionalHeader.cs200
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RVA.cs115
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryEntry.cs66
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryString.cs45
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryTable.cs56
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceReader.cs143
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceWriter.cs216
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RuntimeImage.cs37
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Section.cs66
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCharacteristics.cs70
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCollection.cs114
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SubSystem.cs45
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/BaseCodeVisitor.cs73
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CilWorker.cs357
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Code.cs5
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeReader.cs745
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs824
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Document.cs83
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentHashAlgorithm.cs36
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguage.cs47
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguageVendor.cs37
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentType.cs38
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandler.cs70
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerCollection.cs93
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerType.cs37
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/GuidAttribute.cs91
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitable.cs34
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitor.cs45
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ILProcessor.cs278
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IScopeProvider.cs35
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolReader.cs37
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolStoreFactory.cs36
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolWriter.cs37
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IVariableDefinitionProvider.cs35
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Instruction.cs284
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/InstructionCollection.cs94
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodBody.cs618
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodDataSection.cs37
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodHeader.cs37
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCode.cs471
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodeType.cs39
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodes.cs1551
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OperandType.cs53
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Scope.cs79
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ScopeCollection.cs93
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SequencePoint.cs44
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/StackBehaviour.cs62
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SymbolStoreHelper.cs77
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Symbols.cs272
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinition.cs21
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinitionCollection.cs93
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableReference.cs48
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Assembly.cs88
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyOS.cs80
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyProcessor.cs78
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRef.cs88
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefOS.cs81
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefProcessor.cs79
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BaseMetadataVisitor.cs448
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BlobHeap.cs33
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Buffers.cs373
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ClassLayout.cs80
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CodedIndex.cs7
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Constant.cs80
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CultureUtils.cs83
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CustomAttribute.cs80
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/DeclSecurity.cs82
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ElementType.cs112
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Event.cs82
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventMap.cs79
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventPtr.cs78
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ExportedType.cs84
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Field.cs82
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldLayout.cs79
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldMarshal.cs79
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldPtr.cs78
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldRVA.cs81
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/File.cs82
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParam.cs83
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParamConstraint.cs79
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GuidHeap.cs47
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Heap.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitable.cs)26
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataRow.cs33
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataTable.cs35
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitor.cs149
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ImplMap.cs83
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/InterfaceImpl.cs79
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ManifestResource.cs83
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MemberRef.cs80
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataHeap.cs92
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataInitializer.cs77
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataReader.cs229
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRoot.cs99
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowReader.cs367
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowWriter.cs796
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStream.cs90
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStreamCollection.cs145
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableReader.cs769
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableWriter.cs602
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataToken.cs60
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataWriter.cs506
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Method.cs87
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodImpl.cs80
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodPtr.cs78
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSemantics.cs82
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSpec.cs79
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Module.cs82
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ModuleRef.cs78
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/NestedClass.cs79
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Param.cs82
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ParamPtr.cs78
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Property.cs82
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyMap.cs79
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyPtr.cs78
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Row.cs170
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/RowCollection.cs125
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StandAloneSig.cs78
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StringHeap.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StringsHeap.cs)65
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableCollection.cs115
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableHeap.cs153
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TablesHeap.cs73
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TokenType.cs52
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeDef.cs85
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeRef.cs80
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeSpec.cs78
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/UserStringHeap.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataFormatException.cs)36
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/UserStringsHeap.cs72
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Utilities.cs746
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/BinaryStreamReader.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodDefSig.cs)21
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/BinaryStreamWriter.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseReflectionReader.cs)51
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ByteBuffer.cs342
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionException.cs)40
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/DataDirectory.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Signature.cs)28
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/Image.cs159
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageReader.cs678
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs820
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/Section.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/FlowControl.cs)27
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/TextMap.cs129
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Array.cs43
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ArrayShape.cs43
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/BaseSignatureVisitor.cs53
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Constraint.cs37
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomAttrib.cs80
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomMod.cs48
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FieldSig.cs50
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FnPtr.cs41
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericArg.cs41
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInst.cs46
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInstSignature.cs40
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitable.cs35
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitor.cs39
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/InputOutputItem.cs38
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/LocalVarSig.cs58
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MVar.cs42
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MarshalSig.cs93
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodRefSig.cs49
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSig.cs50
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSpec.cs40
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Param.cs33
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/PropertySig.cs52
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Ptr.cs43
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/RetType.cs39
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SigType.cs42
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureReader.cs961
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureWriter.cs564
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SzArray.cs42
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/TypeSpec.cs36
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ValueType.cs41
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Var.cs42
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.csproj341
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.dll.sources311
-rwxr-xr-xMono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.nunit9
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.sln85
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs452
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayType.cs142
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyDefinition.cs181
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFactory.cs176
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFlags.cs12
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyHashAlgorithm.cs3
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyInfo.cs26
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyLinkedResource.cs24
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameDefinition.cs20
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs262
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReferenceCollection.cs93
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyReader.cs3007
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyWriter.cs2522
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseAssemblyResolver.cs262
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseReflectionVisitor.cs188
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseStructureVisitor.cs96
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CallSite.cs80
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CompactFrameworkCompatibility.cs68
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Constants.cs65
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstraintCollection.cs88
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstructorCollection.cs175
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttribute.cs224
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttributeCollection.cs93
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultAssemblyResolver.cs39
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultImporter.cs230
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EmbeddedResource.cs58
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventAttributes.cs7
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinition.cs172
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinitionCollection.cs137
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventReference.cs23
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExportedType.cs235
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExternTypeCollection.cs214
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldAttributes.cs8
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinition.cs344
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinitionCollection.cs137
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldReference.cs49
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FileAttributes.cs4
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FunctionPointerType.cs96
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericArgumentCollection.cs88
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericContext.cs92
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceMethod.cs83
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceType.cs66
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameter.cs213
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterAttributes.cs6
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterCollection.cs93
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAnnotationProvider.cs37
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAssemblyResolver.cs36
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IConstantProvider.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasConstant.cs)22
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ICustomAttributeProvider.cs33
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IDetailReader.cs48
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericInstance.cs37
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericParameterProvider.cs44
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasMarshalSpec.cs35
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasSecurity.cs35
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IImporter.cs37
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMarshalInfoProvider.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayDimension.cs)40
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberDefinition.cs68
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberReference.cs36
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataScope.cs9
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataTokenProvider.cs4
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMethodSignature.cs38
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitable.cs36
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitor.cs49
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitable.cs36
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitor.cs71
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IRequireResolving.cs37
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Import.cs568
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ImportContext.cs67
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/InterfaceCollection.cs93
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/LinkedResource.cs27
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ManifestResourceAttributes.cs10
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalInfo.cs171
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalSpec.cs171
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberDefinitionCollection.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayDimensionCollection.cs)66
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReference.cs71
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReferenceCollection.cs93
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataResolver.cs270
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataSystem.cs374
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodAttributes.cs11
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodCallingConvention.cs4
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinition.cs637
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinitionCollection.cs185
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodImplAttributes.cs7
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReference.cs200
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReturnType.cs93
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSemanticsAttributes.cs9
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSpecification.cs55
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Modifiers.cs106
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinition.cs978
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinitionCollection.cs93
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleKind.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyKind.cs)24
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReference.cs43
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReferenceCollection.cs93
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NativeType.cs56
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NestedTypeCollection.cs128
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NullReferenceImporter.cs50
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/OverrideCollection.cs93
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeAttributes.cs17
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeInfo.cs170
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterAttributes.cs6
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinition.cs164
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinitionCollection.cs67
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterReference.cs61
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PinnedType.cs20
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PointerType.cs24
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyAttributes.cs7
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinition.cs299
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinitionCollection.cs138
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyReference.cs23
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReferenceType.cs28
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionController.cs62
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionHelper.cs395
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionReader.cs1179
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionWriter.cs1522
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Resource.cs61
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ResourceCollection.cs93
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityAction.cs48
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclaration.cs168
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationCollection.cs157
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationReader.cs160
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SentinelType.cs20
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureReader.cs274
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureWriter.cs246
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TableComparers.cs276
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TargetRuntime.cs9
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeAttributes.cs9
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinition.cs614
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinitionCollection.cs190
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeParser.cs557
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReference.cs252
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReferenceCollection.cs214
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSpecification.cs60
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSystem.cs272
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/VariantType.cs23
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Collections.Generic/Collection.cs410
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Collections.Generic/ReadOnlyCollection.cs98
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoConvert.cs243
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoService.cs177
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/ChangeLog34
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/MiniParser.cs621
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SecurityParser.cs109
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SmallXmlParser.cs637
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono/Actions.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceNode.cs)26
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono/Empty.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/HashCodeProvider.cs)27
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/Mono/Funcs.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDataEntry.cs)31
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/NEWS3
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/NOTES.txt189
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/README78
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/System.Runtime.CompilerServices/ExtensionAttribute.cs (renamed from Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Class.cs)19
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/TODO19
-rwxr-xr-xMono.Addins.CecilReflector/Mono.Cecil/configure43
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/default.build84
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/mono-cecil.pc.in8
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/mono.snkbin0 -> 596 bytes
-rw-r--r--Mono.Addins.CecilReflector/Mono.Cecil/standalone.make23
377 files changed, 20119 insertions, 41582 deletions
diff --git a/Mono.Addins.CecilReflector/Makefile.am b/Mono.Addins.CecilReflector/Makefile.am
index e46c1ba..d8bf822 100644
--- a/Mono.Addins.CecilReflector/Makefile.am
+++ b/Mono.Addins.CecilReflector/Makefile.am
@@ -1,7 +1,7 @@
KEY_FILE=$(top_srcdir)/mono-addins.snk
ASSEMBLY_COMPILER_COMMAND = @MCS@
-ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG
+ASSEMBLY_COMPILER_FLAGS = -keyfile:$(KEY_FILE) -noconfig -codepage:utf8 -warn:4 -debug -d:DEBUG -d:READ_ONLY -d:NET_3_5
ASSEMBLY = ../bin/Mono.Addins.CecilReflector.dll
ASSEMBLY_NAME=Mono.Addins.CecilReflector
COMPILE_TARGET = library
@@ -14,263 +14,90 @@ all: $(ASSEMBLY)
FILES = \
AssemblyInfo.cs \
Mono.Addins.CecilReflector/Reflector.cs \
- Mono.Cecil/Mono.Cecil.Binary/BaseImageVisitor.cs \
- Mono.Cecil/Mono.Cecil.Binary/CLIHeader.cs \
- Mono.Cecil/Mono.Cecil.Binary/CopyImageVisitor.cs \
- Mono.Cecil/Mono.Cecil.Binary/DataDirectory.cs \
- Mono.Cecil/Mono.Cecil.Binary/DebugHeader.cs \
- Mono.Cecil/Mono.Cecil.Binary/DebugStoreType.cs \
- Mono.Cecil/Mono.Cecil.Binary/DOSHeader.cs \
- Mono.Cecil/Mono.Cecil.Binary/ExportTable.cs \
- Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitable.cs \
- Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitor.cs \
- Mono.Cecil/Mono.Cecil.Binary/IHeader.cs \
- Mono.Cecil/Mono.Cecil.Binary/Image.cs \
- Mono.Cecil/Mono.Cecil.Binary/ImageCharacteristics.cs \
- Mono.Cecil/Mono.Cecil.Binary/ImageFormatException.cs \
- Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs \
- Mono.Cecil/Mono.Cecil.Binary/ImageReader.cs \
- Mono.Cecil/Mono.Cecil.Binary/ImageWriter.cs \
- Mono.Cecil/Mono.Cecil.Binary/Imports.cs \
- Mono.Cecil/Mono.Cecil.Binary/MemoryBinaryWriter.cs \
- Mono.Cecil/Mono.Cecil.Binary/PEFileHeader.cs \
- Mono.Cecil/Mono.Cecil.Binary/PEOptionalHeader.cs \
- Mono.Cecil/Mono.Cecil.Binary/ResourceDataEntry.cs \
- Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryEntry.cs \
- Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryString.cs \
- Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryTable.cs \
- Mono.Cecil/Mono.Cecil.Binary/ResourceNode.cs \
- Mono.Cecil/Mono.Cecil.Binary/ResourceReader.cs \
- Mono.Cecil/Mono.Cecil.Binary/ResourceWriter.cs \
- Mono.Cecil/Mono.Cecil.Binary/RuntimeImage.cs \
- Mono.Cecil/Mono.Cecil.Binary/RVA.cs \
- Mono.Cecil/Mono.Cecil.Binary/Section.cs \
- Mono.Cecil/Mono.Cecil.Binary/SectionCharacteristics.cs \
- Mono.Cecil/Mono.Cecil.Binary/SectionCollection.cs \
- Mono.Cecil/Mono.Cecil.Binary/SubSystem.cs \
- Mono.Cecil/Mono.Cecil.Cil/BaseCodeVisitor.cs \
- Mono.Cecil/Mono.Cecil.Cil/CilWorker.cs \
Mono.Cecil/Mono.Cecil.Cil/Code.cs \
Mono.Cecil/Mono.Cecil.Cil/CodeReader.cs \
Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs \
Mono.Cecil/Mono.Cecil.Cil/Document.cs \
- Mono.Cecil/Mono.Cecil.Cil/DocumentHashAlgorithm.cs \
- Mono.Cecil/Mono.Cecil.Cil/DocumentLanguage.cs \
- Mono.Cecil/Mono.Cecil.Cil/DocumentLanguageVendor.cs \
- Mono.Cecil/Mono.Cecil.Cil/DocumentType.cs \
Mono.Cecil/Mono.Cecil.Cil/ExceptionHandler.cs \
- Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerCollection.cs \
- Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerType.cs \
- Mono.Cecil/Mono.Cecil.Cil/FlowControl.cs \
- Mono.Cecil/Mono.Cecil.Cil/GuidAttribute.cs \
- Mono.Cecil/Mono.Cecil.Cil/ICodeVisitable.cs \
- Mono.Cecil/Mono.Cecil.Cil/ICodeVisitor.cs \
+ Mono.Cecil/Mono.Cecil.Cil/ILProcessor.cs \
Mono.Cecil/Mono.Cecil.Cil/Instruction.cs \
- Mono.Cecil/Mono.Cecil.Cil/InstructionCollection.cs \
- Mono.Cecil/Mono.Cecil.Cil/IScopeProvider.cs \
- Mono.Cecil/Mono.Cecil.Cil/ISymbolReader.cs \
- Mono.Cecil/Mono.Cecil.Cil/ISymbolStoreFactory.cs \
- Mono.Cecil/Mono.Cecil.Cil/ISymbolWriter.cs \
- Mono.Cecil/Mono.Cecil.Cil/IVariableDefinitionProvider.cs \
Mono.Cecil/Mono.Cecil.Cil/MethodBody.cs \
- Mono.Cecil/Mono.Cecil.Cil/MethodDataSection.cs \
- Mono.Cecil/Mono.Cecil.Cil/MethodHeader.cs \
Mono.Cecil/Mono.Cecil.Cil/OpCode.cs \
Mono.Cecil/Mono.Cecil.Cil/OpCodes.cs \
- Mono.Cecil/Mono.Cecil.Cil/OpCodeType.cs \
- Mono.Cecil/Mono.Cecil.Cil/OperandType.cs \
- Mono.Cecil/Mono.Cecil.Cil/Scope.cs \
- Mono.Cecil/Mono.Cecil.Cil/ScopeCollection.cs \
Mono.Cecil/Mono.Cecil.Cil/SequencePoint.cs \
- Mono.Cecil/Mono.Cecil.Cil/StackBehaviour.cs \
- Mono.Cecil/Mono.Cecil.Cil/SymbolStoreHelper.cs \
+ Mono.Cecil/Mono.Cecil.Cil/Symbols.cs \
Mono.Cecil/Mono.Cecil.Cil/VariableDefinition.cs \
- Mono.Cecil/Mono.Cecil.Cil/VariableDefinitionCollection.cs \
Mono.Cecil/Mono.Cecil.Cil/VariableReference.cs \
- Mono.Cecil/Mono.Cecil.Metadata/Assembly.cs \
- Mono.Cecil/Mono.Cecil.Metadata/AssemblyOS.cs \
- Mono.Cecil/Mono.Cecil.Metadata/AssemblyProcessor.cs \
- Mono.Cecil/Mono.Cecil.Metadata/AssemblyRef.cs \
- Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefOS.cs \
- Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefProcessor.cs \
- Mono.Cecil/Mono.Cecil.Metadata/BaseMetadataVisitor.cs \
Mono.Cecil/Mono.Cecil.Metadata/BlobHeap.cs \
- Mono.Cecil/Mono.Cecil.Metadata/ClassLayout.cs \
+ Mono.Cecil/Mono.Cecil.Metadata/Buffers.cs \
Mono.Cecil/Mono.Cecil.Metadata/CodedIndex.cs \
- Mono.Cecil/Mono.Cecil.Metadata/Constant.cs \
- Mono.Cecil/Mono.Cecil.Metadata/CultureUtils.cs \
- Mono.Cecil/Mono.Cecil.Metadata/CustomAttribute.cs \
- Mono.Cecil/Mono.Cecil.Metadata/DeclSecurity.cs \
Mono.Cecil/Mono.Cecil.Metadata/ElementType.cs \
- Mono.Cecil/Mono.Cecil.Metadata/Event.cs \
- Mono.Cecil/Mono.Cecil.Metadata/EventMap.cs \
- Mono.Cecil/Mono.Cecil.Metadata/EventPtr.cs \
- Mono.Cecil/Mono.Cecil.Metadata/ExportedType.cs \
- Mono.Cecil/Mono.Cecil.Metadata/Field.cs \
- Mono.Cecil/Mono.Cecil.Metadata/FieldLayout.cs \
- Mono.Cecil/Mono.Cecil.Metadata/FieldMarshal.cs \
- Mono.Cecil/Mono.Cecil.Metadata/FieldPtr.cs \
- Mono.Cecil/Mono.Cecil.Metadata/FieldRVA.cs \
- Mono.Cecil/Mono.Cecil.Metadata/File.cs \
- Mono.Cecil/Mono.Cecil.Metadata/GenericParam.cs \
- Mono.Cecil/Mono.Cecil.Metadata/GenericParamConstraint.cs \
Mono.Cecil/Mono.Cecil.Metadata/GuidHeap.cs \
- Mono.Cecil/Mono.Cecil.Metadata/IMetadataRow.cs \
- Mono.Cecil/Mono.Cecil.Metadata/IMetadataTable.cs \
- Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitable.cs \
- Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitor.cs \
- Mono.Cecil/Mono.Cecil.Metadata/ImplMap.cs \
- Mono.Cecil/Mono.Cecil.Metadata/InterfaceImpl.cs \
- Mono.Cecil/Mono.Cecil.Metadata/ManifestResource.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MemberRef.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MetadataFormatException.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MetadataHeap.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MetadataInitializer.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MetadataReader.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MetadataRoot.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MetadataRowReader.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MetadataRowWriter.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MetadataStream.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MetadataStreamCollection.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MetadataTableReader.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MetadataTableWriter.cs \
+ Mono.Cecil/Mono.Cecil.Metadata/Heap.cs \
Mono.Cecil/Mono.Cecil.Metadata/MetadataToken.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MetadataWriter.cs \
- Mono.Cecil/Mono.Cecil.Metadata/Method.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MethodImpl.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MethodPtr.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MethodSemantics.cs \
- Mono.Cecil/Mono.Cecil.Metadata/MethodSpec.cs \
- Mono.Cecil/Mono.Cecil.Metadata/Module.cs \
- Mono.Cecil/Mono.Cecil.Metadata/ModuleRef.cs \
- Mono.Cecil/Mono.Cecil.Metadata/NestedClass.cs \
- Mono.Cecil/Mono.Cecil.Metadata/Param.cs \
- Mono.Cecil/Mono.Cecil.Metadata/ParamPtr.cs \
- Mono.Cecil/Mono.Cecil.Metadata/Property.cs \
- Mono.Cecil/Mono.Cecil.Metadata/PropertyMap.cs \
- Mono.Cecil/Mono.Cecil.Metadata/PropertyPtr.cs \
- Mono.Cecil/Mono.Cecil.Metadata/RowCollection.cs \
- Mono.Cecil/Mono.Cecil.Metadata/StandAloneSig.cs \
- Mono.Cecil/Mono.Cecil.Metadata/StringsHeap.cs \
- Mono.Cecil/Mono.Cecil.Metadata/TableCollection.cs \
- Mono.Cecil/Mono.Cecil.Metadata/TablesHeap.cs \
+ Mono.Cecil/Mono.Cecil.Metadata/Row.cs \
+ Mono.Cecil/Mono.Cecil.Metadata/StringHeap.cs \
+ Mono.Cecil/Mono.Cecil.Metadata/TableHeap.cs \
Mono.Cecil/Mono.Cecil.Metadata/TokenType.cs \
- Mono.Cecil/Mono.Cecil.Metadata/TypeDef.cs \
- Mono.Cecil/Mono.Cecil.Metadata/TypeRef.cs \
- Mono.Cecil/Mono.Cecil.Metadata/TypeSpec.cs \
- Mono.Cecil/Mono.Cecil.Metadata/UserStringsHeap.cs \
+ Mono.Cecil/Mono.Cecil.Metadata/UserStringHeap.cs \
Mono.Cecil/Mono.Cecil.Metadata/Utilities.cs \
- Mono.Cecil/Mono.Cecil.Signatures/Array.cs \
- Mono.Cecil/Mono.Cecil.Signatures/ArrayShape.cs \
- Mono.Cecil/Mono.Cecil.Signatures/BaseSignatureVisitor.cs \
- Mono.Cecil/Mono.Cecil.Signatures/Class.cs \
- Mono.Cecil/Mono.Cecil.Signatures/Constraint.cs \
- Mono.Cecil/Mono.Cecil.Signatures/CustomAttrib.cs \
- Mono.Cecil/Mono.Cecil.Signatures/CustomMod.cs \
- Mono.Cecil/Mono.Cecil.Signatures/FieldSig.cs \
- Mono.Cecil/Mono.Cecil.Signatures/FnPtr.cs \
- Mono.Cecil/Mono.Cecil.Signatures/GenericArg.cs \
- Mono.Cecil/Mono.Cecil.Signatures/GenericInst.cs \
- Mono.Cecil/Mono.Cecil.Signatures/GenericInstSignature.cs \
- Mono.Cecil/Mono.Cecil.Signatures/InputOutputItem.cs \
- Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitable.cs \
- Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitor.cs \
- Mono.Cecil/Mono.Cecil.Signatures/LocalVarSig.cs \
- Mono.Cecil/Mono.Cecil.Signatures/MarshalSig.cs \
- Mono.Cecil/Mono.Cecil.Signatures/MethodDefSig.cs \
- Mono.Cecil/Mono.Cecil.Signatures/MethodRefSig.cs \
- Mono.Cecil/Mono.Cecil.Signatures/MethodSig.cs \
- Mono.Cecil/Mono.Cecil.Signatures/MethodSpec.cs \
- Mono.Cecil/Mono.Cecil.Signatures/MVar.cs \
- Mono.Cecil/Mono.Cecil.Signatures/Param.cs \
- Mono.Cecil/Mono.Cecil.Signatures/PropertySig.cs \
- Mono.Cecil/Mono.Cecil.Signatures/Ptr.cs \
- Mono.Cecil/Mono.Cecil.Signatures/RetType.cs \
- Mono.Cecil/Mono.Cecil.Signatures/Signature.cs \
- Mono.Cecil/Mono.Cecil.Signatures/SignatureReader.cs \
- Mono.Cecil/Mono.Cecil.Signatures/SignatureWriter.cs \
- Mono.Cecil/Mono.Cecil.Signatures/SigType.cs \
- Mono.Cecil/Mono.Cecil.Signatures/SzArray.cs \
- Mono.Cecil/Mono.Cecil.Signatures/TypeSpec.cs \
- Mono.Cecil/Mono.Cecil.Signatures/ValueType.cs \
- Mono.Cecil/Mono.Cecil.Signatures/Var.cs \
- Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs \
- Mono.Cecil/Mono.Cecil/ArrayDimension.cs \
- Mono.Cecil/Mono.Cecil/ArrayDimensionCollection.cs \
+ Mono.Cecil/Mono.Cecil.PE/BinaryStreamReader.cs \
+ Mono.Cecil/Mono.Cecil.PE/BinaryStreamWriter.cs \
+ Mono.Cecil/Mono.Cecil.PE/ByteBuffer.cs \
+ Mono.Cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs \
+ Mono.Cecil/Mono.Cecil.PE/DataDirectory.cs \
+ Mono.Cecil/Mono.Cecil.PE/Image.cs \
+ Mono.Cecil/Mono.Cecil.PE/ImageReader.cs \
+ Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs \
+ Mono.Cecil/Mono.Cecil.PE/Section.cs \
+ Mono.Cecil/Mono.Cecil.PE/TextMap.cs \
Mono.Cecil/Mono.Cecil/ArrayType.cs \
Mono.Cecil/Mono.Cecil/AssemblyDefinition.cs \
- Mono.Cecil/Mono.Cecil/AssemblyFactory.cs \
Mono.Cecil/Mono.Cecil/AssemblyFlags.cs \
Mono.Cecil/Mono.Cecil/AssemblyHashAlgorithm.cs \
- Mono.Cecil/Mono.Cecil/AssemblyKind.cs \
Mono.Cecil/Mono.Cecil/AssemblyLinkedResource.cs \
Mono.Cecil/Mono.Cecil/AssemblyNameDefinition.cs \
Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs \
- Mono.Cecil/Mono.Cecil/AssemblyNameReferenceCollection.cs \
+ Mono.Cecil/Mono.Cecil/AssemblyReader.cs \
+ Mono.Cecil/Mono.Cecil/AssemblyWriter.cs \
Mono.Cecil/Mono.Cecil/BaseAssemblyResolver.cs \
- Mono.Cecil/Mono.Cecil/BaseReflectionReader.cs \
- Mono.Cecil/Mono.Cecil/BaseReflectionVisitor.cs \
- Mono.Cecil/Mono.Cecil/BaseStructureVisitor.cs \
Mono.Cecil/Mono.Cecil/CallSite.cs \
- Mono.Cecil/Mono.Cecil/CompactFrameworkCompatibility.cs \
- Mono.Cecil/Mono.Cecil/Constants.cs \
- Mono.Cecil/Mono.Cecil/ConstraintCollection.cs \
- Mono.Cecil/Mono.Cecil/ConstructorCollection.cs \
Mono.Cecil/Mono.Cecil/CustomAttribute.cs \
- Mono.Cecil/Mono.Cecil/CustomAttributeCollection.cs \
Mono.Cecil/Mono.Cecil/DefaultAssemblyResolver.cs \
- Mono.Cecil/Mono.Cecil/DefaultImporter.cs \
Mono.Cecil/Mono.Cecil/EmbeddedResource.cs \
Mono.Cecil/Mono.Cecil/EventAttributes.cs \
Mono.Cecil/Mono.Cecil/EventDefinition.cs \
- Mono.Cecil/Mono.Cecil/EventDefinitionCollection.cs \
Mono.Cecil/Mono.Cecil/EventReference.cs \
- Mono.Cecil/Mono.Cecil/ExternTypeCollection.cs \
+ Mono.Cecil/Mono.Cecil/ExportedType.cs \
Mono.Cecil/Mono.Cecil/FieldAttributes.cs \
Mono.Cecil/Mono.Cecil/FieldDefinition.cs \
- Mono.Cecil/Mono.Cecil/FieldDefinitionCollection.cs \
Mono.Cecil/Mono.Cecil/FieldReference.cs \
Mono.Cecil/Mono.Cecil/FileAttributes.cs \
Mono.Cecil/Mono.Cecil/FunctionPointerType.cs \
- Mono.Cecil/Mono.Cecil/GenericArgumentCollection.cs \
- Mono.Cecil/Mono.Cecil/GenericContext.cs \
Mono.Cecil/Mono.Cecil/GenericInstanceMethod.cs \
Mono.Cecil/Mono.Cecil/GenericInstanceType.cs \
Mono.Cecil/Mono.Cecil/GenericParameter.cs \
Mono.Cecil/Mono.Cecil/GenericParameterAttributes.cs \
- Mono.Cecil/Mono.Cecil/GenericParameterCollection.cs \
- Mono.Cecil/Mono.Cecil/HashCodeProvider.cs \
- Mono.Cecil/Mono.Cecil/IAnnotationProvider.cs \
- Mono.Cecil/Mono.Cecil/IAssemblyResolver.cs \
+ Mono.Cecil/Mono.Cecil/IConstantProvider.cs \
Mono.Cecil/Mono.Cecil/ICustomAttributeProvider.cs \
- Mono.Cecil/Mono.Cecil/IDetailReader.cs \
Mono.Cecil/Mono.Cecil/IGenericInstance.cs \
Mono.Cecil/Mono.Cecil/IGenericParameterProvider.cs \
- Mono.Cecil/Mono.Cecil/IHasConstant.cs \
- Mono.Cecil/Mono.Cecil/IHasMarshalSpec.cs \
- Mono.Cecil/Mono.Cecil/IHasSecurity.cs \
- Mono.Cecil/Mono.Cecil/IImporter.cs \
+ Mono.Cecil/Mono.Cecil/IMarshalInfoProvider.cs \
Mono.Cecil/Mono.Cecil/IMemberDefinition.cs \
- Mono.Cecil/Mono.Cecil/IMemberReference.cs \
Mono.Cecil/Mono.Cecil/IMetadataScope.cs \
Mono.Cecil/Mono.Cecil/IMetadataTokenProvider.cs \
Mono.Cecil/Mono.Cecil/IMethodSignature.cs \
- Mono.Cecil/Mono.Cecil/ImportContext.cs \
- Mono.Cecil/Mono.Cecil/InterfaceCollection.cs \
- Mono.Cecil/Mono.Cecil/IReflectionStructureVisitable.cs \
- Mono.Cecil/Mono.Cecil/IReflectionStructureVisitor.cs \
- Mono.Cecil/Mono.Cecil/IReflectionVisitable.cs \
- Mono.Cecil/Mono.Cecil/IReflectionVisitor.cs \
- Mono.Cecil/Mono.Cecil/IRequireResolving.cs \
+ Mono.Cecil/Mono.Cecil/Import.cs \
Mono.Cecil/Mono.Cecil/LinkedResource.cs \
Mono.Cecil/Mono.Cecil/ManifestResourceAttributes.cs \
- Mono.Cecil/Mono.Cecil/MarshalSpec.cs \
+ Mono.Cecil/Mono.Cecil/MarshalInfo.cs \
+ Mono.Cecil/Mono.Cecil/MemberDefinitionCollection.cs \
Mono.Cecil/Mono.Cecil/MemberReference.cs \
- Mono.Cecil/Mono.Cecil/MemberReferenceCollection.cs \
+ Mono.Cecil/Mono.Cecil/MetadataResolver.cs \
+ Mono.Cecil/Mono.Cecil/MetadataSystem.cs \
Mono.Cecil/Mono.Cecil/MethodAttributes.cs \
Mono.Cecil/Mono.Cecil/MethodCallingConvention.cs \
Mono.Cecil/Mono.Cecil/MethodDefinition.cs \
- Mono.Cecil/Mono.Cecil/MethodDefinitionCollection.cs \
Mono.Cecil/Mono.Cecil/MethodImplAttributes.cs \
Mono.Cecil/Mono.Cecil/MethodReference.cs \
Mono.Cecil/Mono.Cecil/MethodReturnType.cs \
@@ -278,13 +105,9 @@ FILES = \
Mono.Cecil/Mono.Cecil/MethodSpecification.cs \
Mono.Cecil/Mono.Cecil/Modifiers.cs \
Mono.Cecil/Mono.Cecil/ModuleDefinition.cs \
- Mono.Cecil/Mono.Cecil/ModuleDefinitionCollection.cs \
+ Mono.Cecil/Mono.Cecil/ModuleKind.cs \
Mono.Cecil/Mono.Cecil/ModuleReference.cs \
- Mono.Cecil/Mono.Cecil/ModuleReferenceCollection.cs \
Mono.Cecil/Mono.Cecil/NativeType.cs \
- Mono.Cecil/Mono.Cecil/NestedTypeCollection.cs \
- Mono.Cecil/Mono.Cecil/NullReferenceImporter.cs \
- Mono.Cecil/Mono.Cecil/OverrideCollection.cs \
Mono.Cecil/Mono.Cecil/ParameterAttributes.cs \
Mono.Cecil/Mono.Cecil/ParameterDefinition.cs \
Mono.Cecil/Mono.Cecil/ParameterDefinitionCollection.cs \
@@ -295,35 +118,27 @@ FILES = \
Mono.Cecil/Mono.Cecil/PointerType.cs \
Mono.Cecil/Mono.Cecil/PropertyAttributes.cs \
Mono.Cecil/Mono.Cecil/PropertyDefinition.cs \
- Mono.Cecil/Mono.Cecil/PropertyDefinitionCollection.cs \
Mono.Cecil/Mono.Cecil/PropertyReference.cs \
Mono.Cecil/Mono.Cecil/ReferenceType.cs \
- Mono.Cecil/Mono.Cecil/ReflectionController.cs \
- Mono.Cecil/Mono.Cecil/ReflectionException.cs \
- Mono.Cecil/Mono.Cecil/ReflectionHelper.cs \
- Mono.Cecil/Mono.Cecil/ReflectionReader.cs \
- Mono.Cecil/Mono.Cecil/ReflectionWriter.cs \
Mono.Cecil/Mono.Cecil/Resource.cs \
- Mono.Cecil/Mono.Cecil/ResourceCollection.cs \
- Mono.Cecil/Mono.Cecil/SecurityAction.cs \
Mono.Cecil/Mono.Cecil/SecurityDeclaration.cs \
- Mono.Cecil/Mono.Cecil/SecurityDeclarationCollection.cs \
- Mono.Cecil/Mono.Cecil/SecurityDeclarationReader.cs \
Mono.Cecil/Mono.Cecil/SentinelType.cs \
- Mono.Cecil/Mono.Cecil/StructureReader.cs \
- Mono.Cecil/Mono.Cecil/StructureWriter.cs \
- Mono.Cecil/Mono.Cecil/TableComparers.cs \
Mono.Cecil/Mono.Cecil/TargetRuntime.cs \
Mono.Cecil/Mono.Cecil/TypeAttributes.cs \
Mono.Cecil/Mono.Cecil/TypeDefinition.cs \
Mono.Cecil/Mono.Cecil/TypeDefinitionCollection.cs \
+ Mono.Cecil/Mono.Cecil/TypeParser.cs \
Mono.Cecil/Mono.Cecil/TypeReference.cs \
- Mono.Cecil/Mono.Cecil/TypeReferenceCollection.cs \
Mono.Cecil/Mono.Cecil/TypeSpecification.cs \
+ Mono.Cecil/Mono.Cecil/TypeSystem.cs \
Mono.Cecil/Mono.Cecil/VariantType.cs \
- Mono.Cecil/Mono.Xml/MiniParser.cs \
- Mono.Cecil/Mono.Xml/SecurityParser.cs \
- Mono.Cecil/Mono.Xml/SmallXmlParser.cs
+ Mono.Cecil/Mono.Collections.Generic/Collection.cs \
+ Mono.Cecil/Mono.Security.Cryptography/CryptoConvert.cs \
+ Mono.Cecil/Mono.Security.Cryptography/CryptoService.cs \
+ Mono.Cecil/Mono/Actions.cs \
+ Mono.Cecil/Mono/Empty.cs \
+ Mono.Cecil/Mono/Funcs.cs \
+ Mono.Cecil/System.Runtime.CompilerServices/ExtensionAttribute.cs
DATA_FILES =
@@ -333,7 +148,7 @@ EXTRAS =
REFERENCES = \
-r:../bin/Mono.Addins.dll \
- -r:System
+ -r:System.Core
DLL_REFERENCES =
diff --git a/Mono.Addins.CecilReflector/Mono.Addins.CecilReflector.csproj b/Mono.Addins.CecilReflector/Mono.Addins.CecilReflector.csproj
index 3190eef..aebf8a7 100644
--- a/Mono.Addins.CecilReflector/Mono.Addins.CecilReflector.csproj
+++ b/Mono.Addins.CecilReflector/Mono.Addins.CecilReflector.csproj
@@ -17,6 +17,7 @@
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin</OutputPath>
+ <DefineConstants>READ_ONLY</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
@@ -26,6 +27,7 @@
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin</OutputPath>
+ <DefineConstants>READ_ONLY</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
@@ -41,333 +43,141 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <Compile Include="Mono.Cecil\Mono.Cecil\AggressiveReflectionReader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ArrayDimension.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ArrayDimensionCollection.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Cil\Code.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Cil\CodeWriter.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Cil\CodeReader.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Cil\Document.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Cil\ExceptionHandler.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Cil\ILProcessor.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Cil\Instruction.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Cil\MethodBody.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Cil\OpCode.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Cil\OpCodes.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Cil\SequencePoint.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Cil\Symbols.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Cil\VariableDefinition.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Cil\VariableReference.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\BlobHeap.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\Buffers.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\CodedIndex.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\ElementType.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\GuidHeap.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\Heap.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataToken.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\Row.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\StringHeap.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\TableHeap.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\TokenType.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\UserStringHeap.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\Utilities.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.PE\BinaryStreamReader.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.PE\BinaryStreamWriter.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.PE\ByteBufferEqualityComparer.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.PE\ByteBuffer.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.PE\DataDirectory.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.PE\Image.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.PE\ImageReader.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.PE\ImageWriter.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.PE\Section.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil.PE\TextMap.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\ArrayType.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\AssemblyDefinition.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\AssemblyFactory.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\AssemblyFlags.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\AssemblyHashAlgorithm.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\AssemblyKind.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\AssemblyInfo.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\AssemblyLinkedResource.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\AssemblyNameDefinition.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\AssemblyNameReference.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\AssemblyNameReferenceCollection.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\AssemblyReader.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\AssemblyWriter.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\BaseAssemblyResolver.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\BaseReflectionReader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\BaseReflectionVisitor.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\BaseStructureVisitor.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\CallSite.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\CompactFrameworkCompatibility.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\Constants.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ConstraintCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ConstructorCollection.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\TypeParser.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\Import.cs" />
+ <Compile Include="Mono.Cecil\Mono.Collections.Generic\Collection.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\ExportedType.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\SecurityDeclaration.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\CustomAttribute.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\CustomAttributeCollection.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\DefaultAssemblyResolver.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\DefaultImporter.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\EmbeddedResource.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\EventAttributes.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\EventDefinition.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\EventDefinitionCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\EventReference.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ExternTypeCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\FieldAttributes.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\FieldDefinition.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\FieldDefinitionCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\FieldReference.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\FileAttributes.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\FunctionPointerType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\GenericArgumentCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\GenericContext.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\GenericInstanceMethod.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\GenericInstanceType.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\GenericParameter.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\GenericParameterAttributes.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\GenericParameterCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\HashCodeProvider.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IAnnotationProvider.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IAssemblyResolver.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\IConstantProvider.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\ICustomAttributeProvider.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IDetailReader.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\IGenericInstance.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\IGenericParameterProvider.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IHasConstant.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IHasMarshalSpec.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IHasSecurity.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IImporter.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IMemberDefinition.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IMemberReference.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IMetadataScope.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IMetadataTokenProvider.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\IMarshalInfoProvider.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\MarshalInfo.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\MetadataResolver.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\Modifiers.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\NativeType.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\PinnedType.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\MetadataSystem.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\IMethodSignature.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ImportContext.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\InterfaceCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IReflectionStructureVisitable.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IReflectionStructureVisitor.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IReflectionVisitable.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IReflectionVisitor.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\IRequireResolving.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\ParameterDefinitionCollection.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\EmbeddedResource.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\EventAttributes.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\EventDefinition.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\EventReference.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\FieldAttributes.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\FieldDefinition.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\FieldReference.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\IMemberDefinition.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\LinkedResource.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ManifestResourceAttributes.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\MarshalSpec.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\MemberReference.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\MemberReferenceCollection.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\MethodAttributes.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\MethodCallingConvention.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\MethodDefinition.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\MethodDefinitionCollection.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\MethodImplAttributes.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\MethodReference.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\MethodReturnType.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\MethodSemanticsAttributes.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\MethodSpecification.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\Modifiers.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ModuleDefinition.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ModuleDefinitionCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ModuleReference.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ModuleReferenceCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\NativeType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\NestedTypeCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\NullReferenceImporter.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\OverrideCollection.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\ParameterAttributes.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\ParameterDefinition.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ParameterDefinitionCollection.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\ParameterReference.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\PinnedType.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\PInvokeAttributes.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\PInvokeInfo.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\PointerType.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\PropertyAttributes.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\PropertyDefinition.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\PropertyDefinitionCollection.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\PropertyReference.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\ReferenceType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ReflectionController.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ReflectionException.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ReflectionHelper.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ReflectionReader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ReflectionWriter.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\IMetadataScope.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\IMetadataTokenProvider.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\ManifestResourceAttributes.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\ModuleReference.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\MemberDefinitionCollection.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\ModuleDefinition.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\ModuleKind.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\Resource.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\ResourceCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\SecurityAction.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\SecurityDeclaration.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\SecurityDeclarationCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\SecurityDeclarationReader.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\SentinelType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\StructureReader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\StructureWriter.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\TableComparers.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\TargetRuntime.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\TypeAttributes.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\TypeDefinition.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\TypeDefinitionCollection.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\TypeReference.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil\TypeReferenceCollection.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\TypeSpecification.cs" />
+ <Compile Include="Mono.Cecil\Mono.Cecil\TypeSystem.cs" />
<Compile Include="Mono.Cecil\Mono.Cecil\VariantType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\BaseImageVisitor.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\CLIHeader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\CopyImageVisitor.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\DataDirectory.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\DebugHeader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\DebugStoreType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\DOSHeader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\ExportTable.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\IBinaryVisitable.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\IBinaryVisitor.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\IHeader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\Image.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\ImageCharacteristics.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\ImageFormatException.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\ImageInitializer.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\ImageReader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\ImageWriter.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\Imports.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\MemoryBinaryWriter.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\PEFileHeader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\PEOptionalHeader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\ResourceDataEntry.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\ResourceDirectoryEntry.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\ResourceDirectoryString.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\ResourceDirectoryTable.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\ResourceNode.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\ResourceReader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\ResourceWriter.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\RuntimeImage.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\RVA.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\Section.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\SectionCharacteristics.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\SectionCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Binary\SubSystem.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\BaseCodeVisitor.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\CilWorker.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\Code.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\CodeReader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\CodeWriter.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\Document.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\DocumentHashAlgorithm.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\DocumentLanguage.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\DocumentLanguageVendor.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\DocumentType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\ExceptionHandler.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\ExceptionHandlerCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\ExceptionHandlerType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\FlowControl.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\GuidAttribute.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\ICodeVisitable.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\ICodeVisitor.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\Instruction.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\InstructionCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\IScopeProvider.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\ISymbolReader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\ISymbolStoreFactory.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\ISymbolWriter.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\IVariableDefinitionProvider.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\MethodBody.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\MethodDataSection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\MethodHeader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\OpCode.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\OpCodes.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\OpCodeType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\OperandType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\Scope.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\ScopeCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\SequencePoint.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\StackBehaviour.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\SymbolStoreHelper.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\VariableDefinition.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\VariableDefinitionCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Cil\VariableReference.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\Assembly.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\AssemblyOS.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\AssemblyProcessor.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\AssemblyRef.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\AssemblyRefOS.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\AssemblyRefProcessor.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\BaseMetadataVisitor.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\BlobHeap.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\ClassLayout.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\CodedIndex.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\Constant.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\CultureUtils.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\CustomAttribute.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\DeclSecurity.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\ElementType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\Event.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\EventMap.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\EventPtr.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\ExportedType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\Field.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\FieldLayout.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\FieldMarshal.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\FieldPtr.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\FieldRVA.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\File.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\GenericParam.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\GenericParamConstraint.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\GuidHeap.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\IMetadataRow.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\IMetadataTable.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\IMetadataVisitable.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\IMetadataVisitor.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\ImplMap.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\InterfaceImpl.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\ManifestResource.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MemberRef.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataFormatException.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataHeap.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataInitializer.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataReader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataRoot.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataRowReader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataRowWriter.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataStream.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataStreamCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataTableReader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataTableWriter.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataToken.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MetadataWriter.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\Method.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MethodImpl.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MethodPtr.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MethodSemantics.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\MethodSpec.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\Module.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\ModuleRef.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\NestedClass.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\Param.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\ParamPtr.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\Property.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\PropertyMap.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\PropertyPtr.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\RowCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\StandAloneSig.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\StringsHeap.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\TableCollection.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\TablesHeap.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\TokenType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\TypeDef.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\TypeRef.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\TypeSpec.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\UserStringsHeap.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Metadata\Utilities.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\Array.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\ArrayShape.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\BaseSignatureVisitor.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\Class.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\Constraint.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\CustomAttrib.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\CustomMod.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\FieldSig.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\FnPtr.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\GenericArg.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\GenericInst.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\GenericInstSignature.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\InputOutputItem.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\ISignatureVisitable.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\ISignatureVisitor.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\LocalVarSig.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\MarshalSig.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\MethodDefSig.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\MethodRefSig.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\MethodSig.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\MethodSpec.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\MVar.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\Param.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\PropertySig.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\Ptr.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\RetType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\Signature.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\SignatureReader.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\SignatureWriter.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\SigType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\SzArray.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\TypeSpec.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\ValueType.cs" />
- <Compile Include="Mono.Cecil\Mono.Cecil.Signatures\Var.cs" />
- <Compile Include="Mono.Cecil\Mono.Xml\MiniParser.cs" />
- <Compile Include="Mono.Cecil\Mono.Xml\SecurityParser.cs" />
- <Compile Include="Mono.Cecil\Mono.Xml\SmallXmlParser.cs" />
+ <Compile Include="Mono.Cecil\Mono.Collections.Generic\ReadOnlyCollection.cs" />
+ <Compile Include="Mono.Cecil\Mono.Security.Cryptography\CryptoConvert.cs" />
+ <Compile Include="Mono.Cecil\Mono.Security.Cryptography\CryptoService.cs" />
+ <Compile Include="Mono.Cecil\System.Runtime.CompilerServices\ExtensionAttribute.cs" />
+ <Compile Include="Mono.Cecil\Mono\Actions.cs" />
+ <Compile Include="Mono.Cecil\Mono\Empty.cs" />
+ <Compile Include="Mono.Cecil\Mono\Funcs.cs" />
<Compile Include="Mono.Addins.CecilReflector\Reflector.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
- <None Include="Mono.Cecil\Mono.Xml\ChangeLog" />
- <None Include="Mono.Cecil\AUTHORS" />
- <None Include="Mono.Cecil\ChangeLog" />
- <None Include="Mono.Cecil\configure" />
- <None Include="Mono.Cecil\default.build" />
- <None Include="Mono.Cecil\Makefile" />
- <None Include="Mono.Cecil\Mono.Cecil.csproj" />
- <None Include="Mono.Cecil\Mono.Cecil.dll.sources" />
- <None Include="Mono.Cecil\mono-cecil.pc.in" />
- <None Include="Mono.Cecil\NEWS" />
- <None Include="Mono.Cecil\README" />
- <None Include="Mono.Cecil\standalone.make" />
- <None Include="Mono.Cecil\TODO" />
+ <Content Include="NOTES.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="mono.snk" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
diff --git a/Mono.Addins.CecilReflector/Mono.Addins.CecilReflector/Reflector.cs b/Mono.Addins.CecilReflector/Mono.Addins.CecilReflector/Reflector.cs
index 02b5ea1..c81925e 100644
--- a/Mono.Addins.CecilReflector/Mono.Addins.CecilReflector/Reflector.cs
+++ b/Mono.Addins.CecilReflector/Mono.Addins.CecilReflector/Reflector.cs
@@ -80,14 +80,14 @@ namespace Mono.Addins.CecilReflector
object ob;
- if (att.ConstructorParameters.Count > 0) {
- object[] cargs = new object [att.ConstructorParameters.Count];
- att.ConstructorParameters.CopyTo (cargs, 0);
+ if (att.ConstructorArguments.Count > 0) {
+ object[] cargs = new object [att.ConstructorArguments.Count];
ArrayList typeParameters = null;
// Constructor parameters of type System.Type can't be set because types from the assembly
// can't be loaded. The parameter value will be set later using a type name property.
for (int n=0; n<cargs.Length; n++) {
+ cargs [n] = att.ConstructorArguments [n].Value;
string atype = att.Constructor.Parameters[n].ParameterType.FullName;
if (atype == "System.Type") {
if (typeParameters == null)
@@ -112,28 +112,32 @@ namespace Mono.Addins.CecilReflector
string propName = ciParams[ip].Name;
propName = char.ToUpper (propName [0]) + propName.Substring (1) + "Name";
PropertyInfo pi = attype.GetProperty (propName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
- pi.SetValue (ob, (string) att.ConstructorParameters [ip], null);
+
if (pi == null)
throw new InvalidOperationException ("Property '" + propName + "' not found in type '" + attype + "'.");
+
+ pi.SetValue (ob, ((TypeReference) att.ConstructorArguments [ip].Value).FullName, null);
}
}
} else {
ob = Activator.CreateInstance (attype);
}
- foreach (DictionaryEntry de in att.Properties) {
- string pname = (string)de.Key;
+ foreach (Mono.Cecil.CustomAttributeNamedArgument namedArgument in att.Properties) {
+ string pname = namedArgument.Name;
PropertyInfo prop = attype.GetProperty (pname);
if (prop != null) {
if (prop.PropertyType == typeof(System.Type)) {
// We can't load the type. We have to use the typeName property instead.
pname += "Name";
prop = attype.GetProperty (pname, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
- }
- if (prop == null) {
- throw new InvalidOperationException ("Property '" + pname + "' not found in type '" + attype + "'.");
- }
- prop.SetValue (ob, de.Value, null);
+
+ if (prop == null)
+ throw new InvalidOperationException ("Property '" + pname + "' not found in type '" + attype + "'.");
+
+ prop.SetValue (ob, ((TypeReference) namedArgument.Argument.Value).FullName, null);
+ } else
+ prop.SetValue (ob, namedArgument.Argument.Value, null);
}
}
return ob;
@@ -166,22 +170,23 @@ namespace Mono.Addins.CecilReflector
MA.CustomAttribute ConvertToRawAttribute (CustomAttribute att, string expectedType)
{
TypeDefinition attType = FindTypeDefinition (att.Constructor.DeclaringType.Module.Assembly, att.Constructor.DeclaringType);
+
if (attType == null || !TypeIsAssignableFrom (expectedType, attType))
return null;
MA.CustomAttribute mat = new MA.CustomAttribute ();
mat.TypeName = att.Constructor.DeclaringType.FullName;
- if (att.ConstructorParameters.Count > 0) {
- IList cargs = att.ConstructorParameters;
+ if (att.ConstructorArguments.Count > 0) {
+ var arguments = att.ConstructorArguments;
MethodReference constructor = FindConstructor (att);
if (constructor == null)
throw new InvalidOperationException ("Custom attribute constructor not found");
- for (int n=0; n<cargs.Count; n++) {
+ for (int n=0; n<arguments.Count; n++) {
ParameterDefinition par = constructor.Parameters[n];
- object val = cargs [n];
+ object val = arguments [n].Value;
if (val != null) {
string name = par.Name;
NodeAttributeAttribute bat = (NodeAttributeAttribute) GetCustomAttribute (par, typeof(NodeAttributeAttribute), false);
@@ -192,36 +197,33 @@ namespace Mono.Addins.CecilReflector
}
}
- foreach (DictionaryEntry de in att.Properties) {
- string pname = (string)de.Key;
- object val = de.Value;
+ foreach (Mono.Cecil.CustomAttributeNamedArgument namedArgument in att.Properties) {
+ string pname = namedArgument.Name;
+ object val = namedArgument.Argument.Value;
if (val == null)
continue;
foreach (TypeDefinition td in GetInheritanceChain (attType)) {
- bool propFound = false;
- foreach (PropertyDefinition prop in td.Properties.GetProperties (pname)) {
- NodeAttributeAttribute bat = (NodeAttributeAttribute) GetCustomAttribute (prop, typeof(NodeAttributeAttribute), false);
- if (bat != null) {
- string name = string.IsNullOrEmpty (bat.Name) ? prop.Name : bat.Name;
- mat.Add (name, Convert.ToString (val, System.Globalization.CultureInfo.InvariantCulture));
- propFound = true;
- break;
- }
+ PropertyDefinition prop = GetMember (td.Properties, pname);
+ if (prop == null)
+ continue;
+
+ NodeAttributeAttribute bat = (NodeAttributeAttribute) GetCustomAttribute (prop, typeof(NodeAttributeAttribute), false);
+ if (bat != null) {
+ string name = string.IsNullOrEmpty (bat.Name) ? prop.Name : bat.Name;
+ mat.Add (name, Convert.ToString (val, System.Globalization.CultureInfo.InvariantCulture));
}
- if (propFound)
- break;
}
}
- foreach (DictionaryEntry de in att.Fields) {
- string pname = (string)de.Key;
- object val = de.Value;
+ foreach (Mono.Cecil.CustomAttributeNamedArgument namedArgument in att.Fields) {
+ string pname = namedArgument.Name;
+ object val = namedArgument.Argument.Value;
if (val == null)
continue;
foreach (TypeDefinition td in GetInheritanceChain (attType)) {
- FieldDefinition field = td.Fields.GetField (pname);
+ FieldDefinition field = GetMember (td.Fields, pname);
if (field != null) {
NodeAttributeAttribute bat = (NodeAttributeAttribute) GetCustomAttribute (field, typeof(NodeAttributeAttribute), false);
if (bat != null) {
@@ -231,8 +233,18 @@ namespace Mono.Addins.CecilReflector
}
}
}
+
return mat;
}
+
+ static TMember GetMember<TMember> (ICollection<TMember> members, string name) where TMember : class, IMemberDefinition
+ {
+ foreach (var member in members)
+ if (member.Name == name)
+ return member;
+
+ return null;
+ }
IEnumerable<TypeDefinition> GetInheritanceChain (TypeDefinition td)
{
@@ -250,7 +262,10 @@ namespace Mono.Addins.CecilReflector
// name and custom attributes. Since we need the full info, we have to look it up in the declaring type.
TypeDefinition atd = FindTypeDefinition (att.Constructor.DeclaringType.Module.Assembly, att.Constructor.DeclaringType);
- foreach (MethodReference met in atd.Constructors) {
+ foreach (MethodReference met in atd.Methods) {
+ if (met.Name != ".ctor")
+ continue;
+
if (met.Parameters.Count == att.Constructor.Parameters.Count) {
for (int n = met.Parameters.Count - 1; n >= 0; n--) {
if (met.Parameters[n].ParameterType.FullName != att.Constructor.Parameters[n].ParameterType.FullName)
@@ -262,8 +277,6 @@ namespace Mono.Addins.CecilReflector
}
return null;
}
-
-
public object LoadAssembly (string file)
{
@@ -275,7 +288,7 @@ namespace Mono.Addins.CecilReflector
AssemblyDefinition adef = (AssemblyDefinition) cachedAssemblies [file];
if (adef != null)
return adef;
- adef = AssemblyFactory.GetAssembly (file);
+ adef = AssemblyDefinition.ReadAssembly (file);
if (adef != null && cache)
cachedAssemblies [file] = adef;
return adef;
@@ -298,7 +311,7 @@ namespace Mono.Addins.CecilReflector
foreach (Resource res in adef.MainModule.Resources) {
EmbeddedResource r = res as EmbeddedResource;
if (r != null && r.Name == resourceName)
- return new System.IO.MemoryStream (r.Data);
+ return r.GetResourceStream ();
}
throw new InvalidOperationException ("Resource not found: " + resourceName);
}
@@ -315,10 +328,7 @@ namespace Mono.Addins.CecilReflector
public System.Collections.IEnumerable GetAssemblyTypes (object asm)
{
- TypeDefinitionCollection types = ((AssemblyDefinition)asm).MainModule.Types;
- foreach (IAnnotationProvider t in types)
- t.Annotations [typeof(AssemblyDefinition)] = asm;
- return types;
+ return ((AssemblyDefinition)asm).MainModule.Types;
}
public System.Collections.IEnumerable GetAssemblyReferences (object asm)
@@ -331,18 +341,16 @@ namespace Mono.Addins.CecilReflector
if (typeName.IndexOf ('`') != -1) {
foreach (TypeDefinition td in ((AssemblyDefinition)asm).MainModule.Types) {
if (td.FullName == typeName) {
- IAnnotationProvider at = td;
- at.Annotations [typeof(AssemblyDefinition)] = asm;
return td;
}
}
}
- IAnnotationProvider t = ((AssemblyDefinition)asm).MainModule.Types [typeName];
+ TypeDefinition t = ((AssemblyDefinition)asm).MainModule.GetType (typeName);
if (t != null) {
- t.Annotations [typeof(AssemblyDefinition)] = asm;
return t;
- } else
+ } else {
return null;
+ }
}
public object GetCustomAttribute (object obj, Type type, bool inherit)
@@ -371,9 +379,7 @@ namespace Mono.Addins.CecilReflector
AssemblyDefinition GetAssemblyDefinition (TypeDefinition t)
{
- IAnnotationProvider aprov = (IAnnotationProvider) t;
- AssemblyDefinition ad = (AssemblyDefinition) aprov.Annotations [typeof(AssemblyDefinition)];
- return ad ?? t.Module.Assembly;
+ return t.Module.Assembly;
}
public System.Collections.IEnumerable GetBaseTypeFullNameList (object type)
@@ -469,6 +475,5 @@ namespace Mono.Addins.CecilReflector
{
return ((FieldDefinition)field).FieldType.FullName;
}
-
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/.gitignore b/Mono.Addins.CecilReflector/Mono.Cecil/.gitignore
new file mode 100644
index 0000000..3629e37
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/.gitignore
@@ -0,0 +1,7 @@
+bin
+obj
+*.suo
+*.user
+*.pidb
+*.userprefs
+*.xml
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/AUTHORS b/Mono.Addins.CecilReflector/Mono.Cecil/AUTHORS
deleted file mode 100644
index c05a391..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/AUTHORS
+++ /dev/null
@@ -1 +0,0 @@
-Jb Evain (jbevain@gmail.com)
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/ChangeLog b/Mono.Addins.CecilReflector/Mono.Cecil/ChangeLog
deleted file mode 100644
index 1cd2ca6..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/ChangeLog
+++ /dev/null
@@ -1,3920 +0,0 @@
-2008-02-06 Lluis Sanchez Gual <lluis@novell.com>
-
- * configure, Mono.Cecil.dll.sources, default.build, Mono.Cecil.csproj,
- AUTHORS, Mono.Cecil, Mono.Cecil/InterfaceCollection.cs,
- Mono.Cecil/GenericParameter.cs, Mono.Cecil/AssemblyLinkedResource.cs,
- Mono.Cecil/ModuleReferenceCollection.cs, Mono.Cecil/ArrayType.cs,
- Mono.Cecil/MethodSpecification.cs,
- Mono.Cecil/ICustomAttributeProvider.cs, Mono.Cecil/TypeSpecification.cs,
- Mono.Cecil/IReflectionVisitor.cs, Mono.Cecil/ReflectionHelper.cs,
- Mono.Cecil/OverrideCollection.cs, Mono.Cecil/BaseAssemblyResolver.cs,
- Mono.Cecil/CallSite.cs, Mono.Cecil/ArrayDimensionCollection.cs,
- Mono.Cecil/SecurityDeclarationReader.cs,
- Mono.Cecil/GenericInstanceType.cs, Mono.Cecil/ModuleReference.cs,
- Mono.Cecil/ParameterDefinitionCollection.cs,
- Mono.Cecil/IReflectionVisitable.cs,
- Mono.Cecil/EventDefinitionCollection.cs,
- Mono.Cecil/FieldDefinitionCollection.cs,
- Mono.Cecil/PropertyDefinitionCollection.cs,
- Mono.Cecil/ModuleDefinitionCollection.cs, Mono.Cecil/IImporter.cs,
- Mono.Cecil/IMethodSignature.cs, Mono.Cecil/TypeReferenceCollection.cs,
- Mono.Cecil/PInvokeAttributes.cs, Mono.Cecil/ArrayDimension.cs,
- Mono.Cecil/ParameterAttributes.cs, Mono.Cecil/FunctionPointerType.cs,
- Mono.Cecil/GenericParameterCollection.cs,
- Mono.Cecil/PropertyAttributes.cs, Mono.Cecil/AssemblyInfo.cs,
- Mono.Cecil/FieldDefinition.cs, Mono.Cecil/StructureWriter.cs,
- Mono.Cecil/CustomAttribute.cs, Mono.Cecil/TypeReference.cs,
- Mono.Cecil/GenericInstanceMethod.cs,
- Mono.Cecil/MemberReferenceCollection.cs,
- Mono.Cecil/IReflectionStructureVisitor.cs,
- Mono.Cecil/BaseReflectionReader.cs,
- Mono.Cecil/AssemblyNameReferenceCollection.cs,
- Mono.Cecil/IHasSecurity.cs, Mono.Cecil/MethodCallingConvention.cs,
- Mono.Cecil/ReflectionReader.cs, Mono.Cecil/MethodReturnType.cs,
- Mono.Cecil/NativeType.cs, Mono.Cecil/AssemblyDefinition.cs,
- Mono.Cecil/IMemberDefinition.cs, Mono.Cecil/TypeDefinition.cs,
- Mono.Cecil/IHasConstant.cs, Mono.Cecil/IMemberReference.cs,
- Mono.Cecil/IMetadataTokenProvider.cs, Mono.Cecil/DefaultImporter.cs,
- Mono.Cecil/IHasMarshalSpec.cs, Mono.Cecil/BaseStructureVisitor.cs,
- Mono.Cecil/Constants.cs, Mono.Cecil/SecurityDeclaration.cs,
- Mono.Cecil/LinkedResource.cs, Mono.Cecil/ImportContext.cs,
- Mono.Cecil/AssemblyKind.cs, Mono.Cecil/FileAttributes.cs,
- Mono.Cecil/FieldAttributes.cs, Mono.Cecil/AssemblyHashAlgorithm.cs,
- Mono.Cecil/CompactFrameworkCompatibility.cs,
- Mono.Cecil/ReferenceType.cs, Mono.Cecil/PropertyReference.cs,
- Mono.Cecil/ResourceCollection.cs, Mono.Cecil/AssemblyFactory.cs,
- Mono.Cecil/ReflectionException.cs, Mono.Cecil/IGenericInstance.cs,
- Mono.Cecil/NullReferenceImporter.cs, Mono.Cecil/PinnedType.cs,
- Mono.Cecil/PointerType.cs, Mono.Cecil/ExternTypeCollection.cs,
- Mono.Cecil/GenericParameterAttributes.cs,
- Mono.Cecil/IReflectionStructureVisitable.cs,
- Mono.Cecil/TypeAttributes.cs, Mono.Cecil/AssemblyNameDefinition.cs,
- Mono.Cecil/SecurityDeclarationCollection.cs,
- Mono.Cecil/TargetRuntime.cs, Mono.Cecil/GenericArgumentCollection.cs,
- Mono.Cecil/IAnnotationProvider.cs, Mono.Cecil/AssemblyNameReference.cs,
- Mono.Cecil/ConstraintCollection.cs, Mono.Cecil/EventReference.cs,
- Mono.Cecil/EmbeddedResource.cs, Mono.Cecil/BaseReflectionVisitor.cs,
- Mono.Cecil/CustomAttributeCollection.cs, Mono.Cecil/SentinelType.cs,
- Mono.Cecil/StructureReader.cs, Mono.Cecil/ManifestResourceAttributes.cs,
- Mono.Cecil/MethodDefinition.cs, Mono.Cecil/EventDefinition.cs,
- Mono.Cecil/ModuleDefinition.cs, Mono.Cecil/ReflectionController.cs,
- Mono.Cecil/MethodReference.cs, Mono.Cecil/MarshalSpec.cs,
- Mono.Cecil/TypeDefinitionCollection.cs, Mono.Cecil/VariantType.cs,
- Mono.Cecil/IAssemblyResolver.cs, Mono.Cecil/IRequireResolving.cs,
- Mono.Cecil/IMetadataScope.cs, Mono.Cecil/MemberReference.cs,
- Mono.Cecil/Resource.cs, Mono.Cecil/PInvokeInfo.cs,
- Mono.Cecil/ReflectionWriter.cs, Mono.Cecil/HashCodeProvider.cs,
- Mono.Cecil/AggressiveReflectionReader.cs, Mono.Cecil/IDetailReader.cs,
- Mono.Cecil/FieldReference.cs, Mono.Cecil/SecurityAction.cs,
- Mono.Cecil/MethodDefinitionCollection.cs,
- Mono.Cecil/MethodImplAttributes.cs, Mono.Cecil/GenericContext.cs,
- Mono.Cecil/Modifiers.cs, Mono.Cecil/MethodAttributes.cs,
- Mono.Cecil/EventAttributes.cs, Mono.Cecil/ParameterDefinition.cs,
- Mono.Cecil/AssemblyFlags.cs, Mono.Cecil/PropertyDefinition.cs,
- Mono.Cecil/MethodSemanticsAttributes.cs,
- Mono.Cecil/ParameterReference.cs, Mono.Cecil/NestedTypeCollection.cs,
- Mono.Cecil/IGenericParameterProvider.cs,
- Mono.Cecil/ConstructorCollection.cs, Mono.Cecil/TableComparers.cs,
- Mono.Cecil/DefaultAssemblyResolver.cs, ChangeLog, mono-cecil.pc.in,
- Mono.Cecil.Cil, Mono.Cecil.Cil/OpCodeType.cs,
- Mono.Cecil.Cil/Document.cs, Mono.Cecil.Cil/Instruction.cs,
- Mono.Cecil.Cil/SequencePoint.cs, Mono.Cecil.Cil/MethodHeader.cs,
- Mono.Cecil.Cil/DocumentHashAlgorithm.cs,
- Mono.Cecil.Cil/ExceptionHandler.cs, Mono.Cecil.Cil/IScopeProvider.cs,
- Mono.Cecil.Cil/CodeReader.cs, Mono.Cecil.Cil/CilWorker.cs,
- Mono.Cecil.Cil/ISymbolReader.cs, Mono.Cecil.Cil/ICodeVisitor.cs,
- Mono.Cecil.Cil/VariableReference.cs, Mono.Cecil.Cil/CodeWriter.cs,
- Mono.Cecil.Cil/FlowControl.cs, Mono.Cecil.Cil/OpCode.cs,
- Mono.Cecil.Cil/VariableDefinitionCollection.cs, Mono.Cecil.Cil/Code.cs,
- Mono.Cecil.Cil/ISymbolWriter.cs, Mono.Cecil.Cil/GuidAttribute.cs,
- Mono.Cecil.Cil/DocumentType.cs, Mono.Cecil.Cil/DocumentLanguage.cs,
- Mono.Cecil.Cil/IVariableDefinitionProvider.cs,
- Mono.Cecil.Cil/SymbolStoreHelper.cs,
- Mono.Cecil.Cil/ISymbolStoreFactory.cs,
- Mono.Cecil.Cil/ScopeCollection.cs, Mono.Cecil.Cil/BaseCodeVisitor.cs,
- Mono.Cecil.Cil/ICodeVisitable.cs, Mono.Cecil.Cil/OperandType.cs,
- Mono.Cecil.Cil/OpCodes.cs, Mono.Cecil.Cil/InstructionCollection.cs,
- Mono.Cecil.Cil/MethodBody.cs, Mono.Cecil.Cil/ExceptionHandlerType.cs,
- Mono.Cecil.Cil/VariableDefinition.cs,
- Mono.Cecil.Cil/MethodDataSection.cs,
- Mono.Cecil.Cil/DocumentLanguageVendor.cs,
- Mono.Cecil.Cil/ExceptionHandlerCollection.cs, Mono.Cecil.Cil/Scope.cs,
- Mono.Cecil.Cil/StackBehaviour.cs, README, standalone.make, CodeGen,
- CodeGen/cecil-gen.rb, CodeGen/cecil-gen-tests.rb,
- CodeGen/cecil-update-rev, CodeGen/cecil-gen-sources.rb,
- CodeGen/cecil-gen-types.rb, CodeGen/cecil-mig.rb,
- CodeGen/cecil-gen-attributes.rb, CodeGen/cecil.xml, CodeGen/templates,
- CodeGen/templates/MetadataTableReader.cs,
- CodeGen/templates/BaseMetadataVisitor.cs,
- CodeGen/templates/Utilities.cs, CodeGen/templates/MetadataRowReader.cs,
- CodeGen/templates/IndexedCollection.cs, CodeGen/templates/OpCodes.cs,
- CodeGen/templates/NamedCollection.cs, CodeGen/templates/Tests.cs,
- CodeGen/templates/MetadataRowWriter.cs,
- CodeGen/templates/MetadataTableWriter.cs,
- CodeGen/templates/CodedIndex.cs, CodeGen/templates/Table.cs,
- CodeGen/templates/IMetadataVisitor.cs, CodeGen/templates/Code.cs,
- Mono.Cecil.Metadata, Mono.Cecil.Metadata/Assembly.cs,
- Mono.Cecil.Metadata/PropertyMap.cs,
- Mono.Cecil.Metadata/InterfaceImpl.cs,
- Mono.Cecil.Metadata/MetadataInitializer.cs,
- Mono.Cecil.Metadata/ParamPtr.cs, Mono.Cecil.Metadata/Constant.cs,
- Mono.Cecil.Metadata/BaseMetadataVisitor.cs,
- Mono.Cecil.Metadata/MethodSpec.cs,
- Mono.Cecil.Metadata/IMetadataVisitable.cs,
- Mono.Cecil.Metadata/DeclSecurity.cs, Mono.Cecil.Metadata/TypeDef.cs,
- Mono.Cecil.Metadata/GenericParamConstraint.cs,
- Mono.Cecil.Metadata/MethodImpl.cs, Mono.Cecil.Metadata/EventPtr.cs,
- Mono.Cecil.Metadata/NestedClass.cs,
- Mono.Cecil.Metadata/MetadataTableReader.cs,
- Mono.Cecil.Metadata/AssemblyRefProcessor.cs,
- Mono.Cecil.Metadata/AssemblyRef.cs,
- Mono.Cecil.Metadata/AssemblyRefOS.cs, Mono.Cecil.Metadata/Method.cs,
- Mono.Cecil.Metadata/RowCollection.cs,
- Mono.Cecil.Metadata/MetadataTableWriter.cs,
- Mono.Cecil.Metadata/StringsHeap.cs,
- Mono.Cecil.Metadata/MetadataRowReader.cs,
- Mono.Cecil.Metadata/ElementType.cs, Mono.Cecil.Metadata/ExportedType.cs,
- Mono.Cecil.Metadata/CustomAttribute.cs, Mono.Cecil.Metadata/Param.cs,
- Mono.Cecil.Metadata/MetadataReader.cs,
- Mono.Cecil.Metadata/ClassLayout.cs,
- Mono.Cecil.Metadata/MetadataRowWriter.cs,
- Mono.Cecil.Metadata/MetadataFormatException.cs,
- Mono.Cecil.Metadata/PropertyPtr.cs, Mono.Cecil.Metadata/Utilities.cs,
- Mono.Cecil.Metadata/BlobHeap.cs, Mono.Cecil.Metadata/MetadataWriter.cs,
- Mono.Cecil.Metadata/AssemblyOS.cs, Mono.Cecil.Metadata/IMetadataRow.cs,
- Mono.Cecil.Metadata/MetadataToken.cs, Mono.Cecil.Metadata/ModuleRef.cs,
- Mono.Cecil.Metadata/MetadataRoot.cs,
- Mono.Cecil.Metadata/UserStringsHeap.cs,
- Mono.Cecil.Metadata/FieldMarshal.cs,
- Mono.Cecil.Metadata/GenericParam.cs, Mono.Cecil.Metadata/ImplMap.cs,
- Mono.Cecil.Metadata/TableCollection.cs,
- Mono.Cecil.Metadata/CultureUtils.cs, Mono.Cecil.Metadata/CodedIndex.cs,
- Mono.Cecil.Metadata/TablesHeap.cs,
- Mono.Cecil.Metadata/MetadataStreamCollection.cs,
- Mono.Cecil.Metadata/FieldPtr.cs, Mono.Cecil.Metadata/TypeRef.cs,
- Mono.Cecil.Metadata/MetadataHeap.cs,
- Mono.Cecil.Metadata/ManifestResource.cs,
- Mono.Cecil.Metadata/AssemblyProcessor.cs, Mono.Cecil.Metadata/File.cs,
- Mono.Cecil.Metadata/EventMap.cs, Mono.Cecil.Metadata/Event.cs,
- Mono.Cecil.Metadata/FieldLayout.cs, Mono.Cecil.Metadata/TokenType.cs,
- Mono.Cecil.Metadata/Field.cs, Mono.Cecil.Metadata/Property.cs,
- Mono.Cecil.Metadata/Module.cs, Mono.Cecil.Metadata/GuidHeap.cs,
- Mono.Cecil.Metadata/MethodSemantics.cs,
- Mono.Cecil.Metadata/StandAloneSig.cs, Mono.Cecil.Metadata/FieldRVA.cs,
- Mono.Cecil.Metadata/MetadataStream.cs, Mono.Cecil.Metadata/TypeSpec.cs,
- Mono.Cecil.Metadata/IMetadataTable.cs, Mono.Cecil.Metadata/MemberRef.cs,
- Mono.Cecil.Metadata/MethodPtr.cs,
- Mono.Cecil.Metadata/IMetadataVisitor.cs, TODO, Mono.Xml,
- Mono.Cecil.Signatures, Mono.Cecil.Signatures/BaseSignatureVisitor.cs,
- Mono.Cecil.Signatures/ISignatureVisitable.cs,
- Mono.Cecil.Signatures/MethodRefSig.cs,
- Mono.Cecil.Signatures/CustomAttrib.cs,
- Mono.Cecil.Signatures/FieldSig.cs, Mono.Cecil.Signatures/Var.cs,
- Mono.Cecil.Signatures/FnPtr.cs, Mono.Cecil.Signatures/SzArray.cs,
- Mono.Cecil.Signatures/MethodSpec.cs,
- Mono.Cecil.Signatures/ArrayShape.cs, Mono.Cecil.Signatures/Ptr.cs,
- Mono.Cecil.Signatures/MVar.cs, Mono.Cecil.Signatures/GenericArg.cs,
- Mono.Cecil.Signatures/LocalVarSig.cs, Mono.Cecil.Signatures/Array.cs,
- Mono.Cecil.Signatures/ValueType.cs, Mono.Cecil.Signatures/MethodSig.cs,
- Mono.Cecil.Signatures/SigType.cs,
- Mono.Cecil.Signatures/SignatureReader.cs,
- Mono.Cecil.Signatures/Constraint.cs,
- Mono.Cecil.Signatures/PropertySig.cs,
- Mono.Cecil.Signatures/MarshalSig.cs,
- Mono.Cecil.Signatures/ISignatureVisitor.cs,
- Mono.Cecil.Signatures/RetType.cs,
- Mono.Cecil.Signatures/GenericInstSignature.cs,
- Mono.Cecil.Signatures/TypeSpec.cs,
- Mono.Cecil.Signatures/SignatureWriter.cs,
- Mono.Cecil.Signatures/InputOutputItem.cs,
- Mono.Cecil.Signatures/Param.cs, Mono.Cecil.Signatures/Signature.cs,
- Mono.Cecil.Signatures/MethodDefSig.cs, Mono.Cecil.Signatures/Class.cs,
- Mono.Cecil.Signatures/GenericInst.cs,
- Mono.Cecil.Signatures/CustomMod.cs, Mono.Cecil.Binary,
- Mono.Cecil.Binary/PEFileHeader.cs,
- Mono.Cecil.Binary/SectionCollection.cs,
- Mono.Cecil.Binary/ResourceDirectoryTable.cs,
- Mono.Cecil.Binary/ResourceWriter.cs, Mono.Cecil.Binary/RuntimeImage.cs,
- Mono.Cecil.Binary/ExportTable.cs, Mono.Cecil.Binary/BaseImageVisitor.cs,
- Mono.Cecil.Binary/ResourceNode.cs, Mono.Cecil.Binary/Imports.cs,
- Mono.Cecil.Binary/ResourceDirectoryEntry.cs,
- Mono.Cecil.Binary/DOSHeader.cs, Mono.Cecil.Binary/DebugHeader.cs,
- Mono.Cecil.Binary/SectionCharacteristics.cs,
- Mono.Cecil.Binary/ResourceDirectoryString.cs,
- Mono.Cecil.Binary/ResourceDataEntry.cs, Mono.Cecil.Binary/Section.cs,
- Mono.Cecil.Binary/DebugStoreType.cs, Mono.Cecil.Binary/ImageReader.cs,
- Mono.Cecil.Binary/ImageFormatException.cs,
- Mono.Cecil.Binary/IBinaryVisitor.cs,
- Mono.Cecil.Binary/ImageCharacteristics.cs,
- Mono.Cecil.Binary/ImageWriter.cs, Mono.Cecil.Binary/CLIHeader.cs,
- Mono.Cecil.Binary/Image.cs, Mono.Cecil.Binary/PEOptionalHeader.cs,
- Mono.Cecil.Binary/ImageInitializer.cs, Mono.Cecil.Binary/RVA.cs,
- Mono.Cecil.Binary/CopyImageVisitor.cs,
- Mono.Cecil.Binary/DataDirectory.cs, Mono.Cecil.Binary/SubSystem.cs,
- Mono.Cecil.Binary/IBinaryVisitable.cs, Mono.Cecil.Binary/IHeader.cs,
- Mono.Cecil.Binary/MemoryBinaryWriter.cs,
- Mono.Cecil.Binary/ResourceReader.cs, NEWS, Makefile: Added support for
- pluggable add-in assembly reflectors. Implemented an add-in assembly
- reflector based on Cecil.
-
-2007-10-31 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil.Binary/ImageReader.cs: fix for the case where
- the export table export zero functions.
-
-2007-10-18 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil.Cil/MethodBody.cs: Add an Optimize method which
- is the opposite of Simplify. Based on a patch by Carlo.
-
- * Mono.Cecil.Cil/CodeWriter.cs: don't care about reducing MaxStack.
-
-2007-10-11 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/TypeReference.cs: add a IsNested helper property.
-
- * Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- Integrate patch for Carlo, start working on enum writing
- in custom attribute.
-
-2007-10-09 Nestor Salceda <nestor.salceda@gmail.com>
-
- * mono-cecil.pc.in: Updated the version number.
-
-2007-10-09 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil.Cil/Instruction.cs
- Mono.Cecil.Cil/CodeWriter.cs:
- Move CodeWriter.GetSize (Instruction) to Instruction.
-
- Integration of patches from Carlo Kok <ck@remobjects.com>:
-
- * Mono.Cecil.Cil/Document.cs
- Mono.Cecil.Cil/DocumentType.cs
- Mono.Cecil.Cil/DocumentLanguage.cs
- Mono.Cecil.Cil/DocumentLanguageVendor.cs:
- Use plain guids for Document properties so it's easy
- for third party document providers to use their own.
-
- * Mono.Cecil/ParameterDefinition.cs:
- Clean or set the HasFieldMarshal flag when setting
- MarshalSpecs on parameters.
-
- * Mono.Cecil/AssemblyNameReference.cs:
- Protect against null culture.
-
- * Mono.Cecil/FieldDefinition.cs:
- Clean or set the HasFieldMarshal flag when setting
- MarshalSpecs on fields.
-
- * Mono.Cecil/GenericInstanceType.cs:
- Properly initialize the IsValueType from the element type.
-
-2007-10-09 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/ReflectionWriter.cs: check for duplicates
- in the MemberRef row.
-
-2007-10-08 Sebastien Pouliot <sebastien@ximian.com>
-
- * standalone.make: Revert changes so standalone Cecil (in SVN) can
- be built using this Makefile (required for Gendarme);
- * README: Update build and bug instructions.
-
-2007-10-07 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/BaseAssemblyResolver.cs: first lookup assemblies
- in the specified directories before trying the framework dir.
-
-2007-10-06 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil.Cil/OpCode.cs: make that a struct again, it
- make the 2.1 profile explode. Will investigate why.
-
-2007-10-06 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/MethodCallingConvention.cs: Not a [Flag]
-
-2007-10-05 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil.Cil/OpCode.cs: Change OpCode from struct to class
- to avoid copying everything everytime.
-
-2007-09-28 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/SecurityDeclarationReader.cs:
- Adapt patch from Carlo Kok <ck@remobjects.com>.
- Properly read unicode string constants.
-
- * Mono.Cecil/SecurityDeclarationReader.cs:
- Adapt patch from Carlo Kok <ck@remobjects.com>.
- For some MS assemblies, the security declaration contains
- one zero byte.
-
-2007-09-24 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/ModuleDefinition.cs: after a FullLoad, the symbol
- reader is not needed anymore.
-
-2007-09-18 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil.Cil/MethodBody.cs:
- Adapt a patch from Ivan <ivanjh@gmail.com>.
- Fix cloning of the This parameter.
-
-2007-09-12 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/ReflectionReader.cs
- Mono.Cecil.Signatures/SignatureReader.cs
- Mono.Cecil.Signatures/TypeSpec.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- Deal with custom mods on typespecs.
-
-2007-09-12 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil.Binary/ImageReader.cs: some 64bits assemblies
- have a strange header without import tables.
-
-2007-09-09 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/GenericContext.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/DefaultImporter.cs:
- Better handling of generic instances of references, where
- the number of generic parameters is not known.
-
-2007-09-06 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/MethodDefinition: add Is** methods for MethodImplAttributes.
-
-2007-09-04 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/ReflectionWriter.cs:
- Adapt a patch by Ewout Prangsma <ewout@tallapplications.com>.
- Cache the typespec tokens instead of the typespec themselves
- because GenericParameters are somethimes considered as typespecs.
-
-2007-08-28 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil.Cil/CodeWriter.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil.Cil/SymbolStoreHelper.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- Generate proper variables signatures for symbols
- stores.
-
-2007-08-19 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil.Cil/CodeReader.cs:
- Deal with generic exceptions.
-
-2007-08-15 Jb Evain <jbevain@novell.com>
-
- * CodeGen/cecil.xml,
- Mono.Cecil.Cil/OpCodes.cs:
- Fix bug spotted by Jesse Jones, ldelem.any has a
- stack behavior pop of popref, popi.
-
-2007-08-15 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/TypeReference.cs
- Mono.Cecil/TypeSpecification.cs:
- TypeSpecification.Module return the module of the elemen
- type now.
-
-2007-08-13 Rodrigo B. de Oliveira <rodrigobamboo@gmail.com>
-
- * default.build
- Mono.Cecil/AssemblyInfo.cs:
- Ability to pass custom defines to the c# compiler through
- the csc.defines property. KEYFILE can be used to force
- an AssemblyKeyFile attribute on AssemblyInfo.cs so strongly
- signed versions of Mono.Cecil can be produced on .net 1.1,
- cf 1.0 and cf 2.0.
-
-2007-08-13 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil.Cil/CilWorker.cs:
- Fix InsertBefore.
-
-2007-08-06 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil.Cil/CilWorker.cs:
- Fix the linked list after an InsertBefore, InsertAfter.
-
-2007-08-02 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/GenericParameter.cs
- Mono.Cecil/FieldDefinition.cs
- Mono.Cecil/TypeDefinition.cs
- Mono.Cecil/MethodDefinition.cs
- Mono.Cecil/EventDefinition.cs
- Mono.Cecil/PInvokeInfo.cs
- Mono.Cecil/Resource.cs
- Mono.Cecil/ParameterDefinition.cs
- Mono.Cecil/PropertyDefinition.cs:
-
- Add Isxxx properties based on the xxxAttributes enums.
-
-2007-07-23 Raja R Harinath <rharinath@novell.com>
-
- Fix 'make warnings'.
- * Makefile (LIBRARY_PACKAGE): Set to none.
- (install-local): Remove.
-
-2007-07-21 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/TypeReference.cs
- Mono.Cecil/TypeSpecification.cs:
- Add a new GetOriginalType () method.
-
- * Mono.Cecil/MethodReference.cs
- Mono.Cecil/MethodSpecification.cs:
- Add a new GetOriginalMethod () method.
-
-2007-07-19 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/AssemblyFactory.cs
- Mono.Cecil.Binary/Image.cs:
- Update the fileinfo after writing an assembly
- to a file.
-
-2007-07-19 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/ReflectionReader.cs
- Mono.Cecil.Cil/CodeReader.cs
- Mono.Cecil.Signature/SignatureReader.cs:
- Better handling of the sentil in the varargs methods.
-
- * Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/SentinelType.cs
- Mono.Cecil.Cil/CodeWriter.cs:
- Mono.Cecil.Signatures/SignatureReader.cs:
- Fix handling of varargs methods.
-
-2007-07-18 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil.Cil/CodeReader.cs
- Mono.Cecil.Cil/CodeWriter.cs:
- Deal with non-sense instructions that some
- obfuscators emit.
-
- * Mono.Cecil/AggressiveReflectionReader.cs:
- Deal with out of range properties.
- * Mono.Cecil.Metadata/StringsHeap.cs:
- Deal with out of range string indexes.
-
-2007-07-17 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/AggressiveReflectionReader.cs:
- Add some gards against zeroed tokens.
-
- * Mono.Cecil.Metadata/Utilities.cs:
- Return zero instead of throwing on invalid tags.
- Allow Cecil to read assemblies partially broken
- by some obfuscators.
-
-2007-07-14 Gert Driesen <drieseng@users.sourceforge.net>
-
- * default.build: Fix relative path to key. Avoid use of ugly foreach
- contruct. Spaces to tabs.
- * Mono.Cecil.csproj: Fix relative path to key.
- * standalone.make: Fix relative path to key and config.make.
-
-2007-07-03 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/BaseAssemblyResolver.cs:
- Expose a way to add default directories
- where the assemblies are first looked for.
-
-2007-06-20 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/IReferenceImporter.cs => IImporter.cs
- Mono.Cecil/DefaultReferenceImporter.cs => DefaultImporter.cs
-
- * Mono.Cecil/ReflectionHelper.cs
- Mono.Cecil/DefaultReferenceImporter.cs
- Mono.Cecil/ModuleDefinition.cs:
- Move Cecil types import logic into
- the DefaultReferenceImporter.
-
- Needed by the merger and the extractor.
-
-2007-06-19 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil.Cil/MethodBody.cs:
- Avoid invalid cast by properly simplifying
- instructions.
-
- * Mono.Cecil.Cil/OpCodes.cs:
- CodeGen/cecil.xml:
- leave.s is a macro instruction.
-
- * Mono.Cecil/TypeDefinition.cs
- Mono.Cecil/ParameterDefinition.cs:
- Fix cloning.
-
-2007-06-18 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/ReflectionReader.cs:
- Fix custom mods for fields ref.
-
-2007-06-13 Jb Evain <jbevain@novell.com>
-
- Integrated patches by:
- Paul Apostolescu <papostolescu@fortifysoftware.com>
-
- * patch3:
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- In named args, objects are encoded as boxed.
-
- * patch1:
- Mono.Cecil/IMemberDefinition.cs
- Mono.Cecil/Constants.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/AggressiveReflectionReader.cs:
- Do not take into account special _Deleted
- members.
-
- * patch6:
- Mono.Cecil/StructureReader.cs:
- Read the flags of the references as well.
-
- * patch5:
- Mono.Cecil.Metadata/UserStringsHeap.cs:
- Don't bother getting a string from the bytes
- if the length is < 2 (0, or 0 + an encoding flag)
-
- * patch4:
- Mono.Cecil/ReflectionHelper.cs:
- Update the value type flags of types
- when they are imported if the type
- reference was first seen as a type reference.
-
- * patch2:
- Mono.Cecil.Signature/SignatureWriter.cs:
- Patch to handle nullref values for types in
- custom attributes arguments.
-
-2007-06-13 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/StructureWriter.cs,
- Mono.Cecil/ReflectionWriter.cs:
- Revert the on demand creation of memberref.
-
-2007-06-12 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/CallSite.cs
- Mono.Cecil/ModuleReference.cs
- Mono.Cecil/CustomAttribute.cs
- Mono.Cecil/AssemblyDefinition.cs
- Mono.Cecil/SecurityDeclaration.cs
- Mono.Cecil/AssemblyNameReference.cs
- Mono.Cecil/MemberReference.cs
- Mono.Cecil/Resource.cs
- Mono.Cecil/ParameterReference.cs:
- Implement explicitely IAnnotationProvider.
-
-2007-06-05 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/AssemblyNameReference.cs:
- Cache the fullname when possible.
-
-2007-05-31 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/ModuleDefinition.cs:
- Add types to the module and members to the context
- on inject.
-
- * Mono.Cecil/BaseAssemblyResolver.cs:
- Improve resolve, works for people requiring
- .net 1.0 assemblies when they only have 1.1.
-
-2007-05-30 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/DefaultAssemblyResolver.cs:
- Add a RegisterAssembly method to register an
- assembly to the cache without having to resolve it.
-
- * Mono.Cecil/DefaultReferenceImporter.cs:
- Make methods virtual.
-
- * Mono.Cecil.dll.sources
- Mono.Cecil.csproj
- Mono.Cecil/ReflectionHelper.cs
- Mono.Cecil/IReferenceImporter.cs
- Mono.Cecil/FieldDefinition.cs
- Mono.Cecil/CustomAttribute.cs
- Mono.Cecil/ImportContext.cs
- Mono.Cecil/NullReferenceImporter.cs
- Mono.Cecil/MethodDefinition.cs
- Mono.Cecil/EventDefinition.cs
- Mono.Cecil/ReflectionController.cs
- Mono.Cecil/ModuleDefinition.cs
- Mono.Cecil/GenericContext.cs
- Mono.Cecil/DefaultReferenceImporter.cs
- Mono.Cecil/PropertyDefinition.cs:
- Provide a IReferenceImporter to customize how
- types are injected from an assembly to another.
-
-2007-05-28 Jb Evain <jbevain@novell.com>
-
- * Borrow annotations concept from boo ast node.
- Should be useful for the linker.
-
-2007-05-23 Jb Evain <jbevain@novell.com>
-
- * Mono.Cecil/StructureWriter.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil.Cil/CodeWriter.cs:
- Emit MemberReferences rows on demand.
-
-2007-05-16 Jb Evain <jb@nurv.fr>
-
- * Mono.Cecil.Binary/ImageReader.cs:
- Fix reading of the debug header for
- headers half way emitted by .net SRE.
-
- * Mono.Cecil/BaseAssemblyResolver:
- try to resolve unversionned assemblies.
-
-2007-05-09 Jb Evain <jb@nurv.fr>
-
- * Mono.Cecil.Binary/Image.cs:
- Throw when rva cannot be resolved.
-
- * Mono.Cecil.csproj
- Mono.Cecil.Binary/ExportTable.cs
- Mono.Cecil.Binary/BaseImageVisitor.cs
- Mono.Cecil.Binary/ImageReader.cs
- Mono.Cecil.Binary/IBinaryVisitor.cs
- Mono.Cecil.Binary/Image.cs
- Mono.Cecil.Binary/ImageInitializer.cs
- Mono.Cecil/StructureReader.cs
- Mono.Cecil/ReflectionWriter.cs:
- When present, read the export table, so that people
- reading non managed assemblies can use the Mono.Cecil.Binary
- stuff.
-
- Fix the bug when section name is 8 char long.
-
- Based on a patch by Pavel Savara <pavel.savara@gmail.com>.
-
-2007-04-27 Jb Evain <jb@nurv.fr>
-
- * Mono.Cecil/AssemblyNameReference.cs:
- Allow the computation of pktoken on CF_2_0.
-
-2007-04-25 Jb Evain <jb@nurv.fr>
-
- * Mono.Cecil/ModuleDefinition.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil.Cil/ISymbolWriter.cs
- Mono.Cecil.Signatures/SignatureWriter.cs
- Start working on local var debug infos emitting.
-
-2007-04-08 Jb Evain <jb@nurv.fr>
-
- * Mono.Cecil/ParameterAttributes.cs:
- ParameterAttributes.None
-
-2007-03-30 Jb Evain <jb@nurv.fr>
-
- * Collections:
- Remove uneeded tests as an optimizations.
- Based on a suggestion by Carlo Kok <ck@remobjects.com>.
-
- * Mono.Cecil.Metadata/StringsHeap.cs:
- Optimize GetStringAt, patch by:
- Carlo Kok <ck@remobjects.com>
-
-2007-03-22 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/AssemblyInfo.cs:
- Bump to 0.5.0.0 for the sake of our packagers friends.
- Re-Bump to 0.5.0.1.
-
- * Mono.Cecil/StructureWriter.cs:
- Throw a NotSupportedException instead of a NIE
- for mixed mode assemblies.
-
-2007-03-20 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Metadata/MetadataWriter.cs:
- Correct epilog for unicode user strings heap.
-
-2007-03-16 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Cil/CodeReader.cs
- Mono.Cecil.Cil/MethodBody.cs:
- Add a MethodBody.Simplify method to expand
- macros.
-
- * Mono.Cecil.dll.sources
- Mono.Cecil.csproj
- Mono.Cecil.Cil/OpCode.cs
- Mono.Cecil.Cil/OpCodes.cs
- Mono.Cecil.Cil/Code.cs
- CodeGen/cecil-gen.rb
- CodeGen/templates/OpCodes.cs
- CodeGen/templates/Code.cs:
- Add a Code enumeration to simplify working with
- OpCodes.
-
-2007-03-12 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Metadata/UserStringsHeap.cs:
- Avoid trailing blank on some systems.
-
-2007-02-22 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionWriter.cs:
- Deal with sentinels on simple methodrefs.
-
-2007-02-22 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.dll.sources
- Mono.Cecil.csproj
- CodeGen/cecil.xml
- Mono.Cecil.Metadata/ParamPtr.cs
- Mono.Cecil.Metadata/MethodSpec.cs
- Mono.Cecil.Metadata/BaseMetadataVisitor.cs
- Mono.Cecil.Metadata/EventPtr.cs
- Mono.Cecil.Metadata/MetadataTableReader.cs
- Mono.Cecil.Metadata/MetadataTableWriter.cs
- Mono.Cecil.Metadata/MetadataRowReader.cs
- Mono.Cecil.Metadata/MetadataRowWriter.cs
- Mono.Cecil.Metadata/PropertyPtr.cs
- Mono.Cecil.Metadata/FieldPtr.cs
- Mono.Cecil.Metadata/MethodPtr.cs
- Mono.Cecil.Metadata/IMetadataVisitor.cs:
- Add *Ptr table definitions.
-
- * Mono.Cecil.dll.sources
- Mono.Cecil.csproj
- Mono.Cecil/CallSite.cs
- Mono.Cecil/IMethodSignature.cs
- Mono.Cecil/SentinelType.cs
- Mono.Cecil/FunctionPointerType.cs
- Mono.Cecil/MethodReference.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil.Cil/CodeReader.cs
- Mono.Cecil.Cil/CodeWriter.cs:
- Implement support for writing function pointers.
- Based on a patch by Argiris Kirtzidis <akyrtzi@gmail.com>
-
- * Mono.Cecil/Constants.cs:
- Make it public due to some demands.
-
-2007-02-21 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Signatures/SignatureReader.cs:
- do not read enums if the resolution is not forced until
- cecil knows how to write them.
-
- * Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil.Signatures/SzArray.cs
- Mono.Cecil.Signatures/Array.cs
- Mono.Cecil.Signatures/SignatureReader.cs
- Mono.Cecil.Signatures/TypeSpec.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- handle custom mods on arrays signatures.
-
- * Mono.Cecil/ReflectionReader.cs:
- Handle fields TypeSpecs that have an initial value.
- Based on a patch by Argiris Kirtzidis <akyrtzi@gmail.com>
-
-2007-01-29 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Metadata/MetadataWriter.cs:
- Save a byte ! Yeah !
-
-2006-12-18 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionReader.cs:
- Fix a bug in reading MemberRef pointing to MethodDef.
-
-2006-12-16 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/StructureReader.cs:
- Prevent a NRE if we're reading a multi module
- assembly through a stream if a module is not find.
- Fix #80273.
-
-2006-12-07 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionWriter.cs:
- Allow an AssemblyDefinition to be written
- more than once.
-
-2006-12-05 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionWriter.cs:
- Deal with nullref default parameters.
-
-2006-12-03 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionWriter.cs:
- Handle constant where the parameter is object
- and the signature is something else.
-
-2006-11-27 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/TypeDefinitionCollection.cs
- CodeGen/templates/NamedCollection.cs:
- Allow multiple typedefs with the same namespace+name
- to be able to read unvalid assemblies.
-
- * Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil.Signatures/PropertySig.cs
- Mono.Cecil.Signatures/SignatureReader.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- - Deal with modifiers on properties.
- - Deal with non standard signatures when the byref
- flag is placed after the custom modifiers.
- Mono.Cecil/StructureReader.cs:
- - Properly detect wether an assembli is a dll or not.
-
- Based on a patch by Argiris Kirtzidis <akyrtzi@gmail.com>.
-
-2006-11-25 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil.Signatures/GenericArg.cs
- Mono.Cecil.Signatures/GenericInstSignature.cs
- Mono.Cecil.Signatures/SignatureReader.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- Deal with modifiers for generic arguments.
- Based on a patch by Argiris Kirtzidis <akyrtzi@gmail.com>.
-
- * Mono.Cecil.Binary/ImageWriter.cs:
- Fix a bug in writing rsrc sections.
-
- * Mono.Cecil.Cil/CodeReader.cs:
- Do some refactoring.
-
- * Mono.Cecil.Metadata/MetadataToken.cs:
- Add a ctor to get a MetadataToken
- from an integer token.
-
-2006-11-22 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Cil/GuidAttribute.cs:
- Fix for CF compilation.
-
-2006-11-16 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/StructureReader.cs:
- If an assembly has no managed assembly defined,
- consider it as a dll.
-
-2006-11-08 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/BaseAssemblyResolver.cs:
- Handles different kind of GAC on Windows.
-
-2006-11-07 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionHelper.cs:
- Don't import the flags of an assembly name reference.
-
-2006-11-03 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/PropertyDefinition.cs:
- Fix property cloning.
- Patch by Alex Prudkiy <prudkiy@mail.ru>
-
-2006-10-26 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionReader.cs:
- Use the proper generic context when reading memberrefs.
-
-2006-10-11 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Cil/Document.cs:
- Complete a little bit.
-
- * Mono.Cecil/SecurityDeclarationReader.cs:
- Get rid of a lot of exceptions when creating the security
- attribute.
-
-2006-10-10 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionReader.cs:
- Mono.Cecil/CustomAttribute.cs:
- Mono.Cecil.Signatures/SignatureReader.cs:
- Mono.Cecil/SecurityDeclarationReader.cs:
- Patch from: Eyal Alaluf <eyala@mainsoft.com>.
- Add support for resolving custom attributes that contain references
- to enum in other assemblies.
-
-2006-10-09 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/IRequireResolving.cs
- Mono.Cecil/CustomAttribute.cs
- Mono.Cecil/SecurityDeclaration.cs
- Mono.Cecil/SecurityDeclarationReader.cs
- Mono.Cecil/AggressiveReflectionReader.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil/ModuleDefinition.cs:
- Introduce the interface IRequireResolving implemented
- by CustomAttribute and SecurityDeclaration for when they can't
- be read without loading another assembly.
-
- * Mono.Cecil/SecurityDeclarationReader.cs:
- Prevent Cecil to crash when it can not get the type
- of the declaration.
-
-2006-10-04 Eyal Alaluf <eyala@mainsoft.com>
-
- * Mono.Cecil/StructureReader.cs:
- Visit the module we load when a DLL has more then 1 module.
- Mono.Cecil/AssemblyNameReference.cs:
- Allow "PublicToken=null" when parsing an assembly full name.
-
-2006-10-03 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/BaseAssemblyResolver.cs
- Mono.Cecil.Binary/ResourceReader.cs:
- CompactFramework fix.
-
-2006-10-02 Jb Evain <jbevain@gmail.com>
-
- * implement IList on the named collections.
-
- * implement the first bits of Win32 resources handling.
-
- * Mono.Cecil/ReflectionHelper.cs:
- It does not make sense to import the assembly flags.
-
-2006-09-28 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/MethodDefinitionCollection.cs
- Mono.Cecil/ConstructorCollection.cs
- Mono.Cecil.Cil/InstructionCollection.cs
- CodeGen/templates/IndexedCollection.cs
- Fix StackOverlow.
-
-2006-09-27 Jb Evain <jbevain@gmail.com>
-
- * *Collection.cs: use CollectionBase when possible.
-
-2006-09-24 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/AssemblyFactory.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil.Cil/ISymbolStoreFactory.cs
- Mono.Cecil.Cil/SymbolStoreHelper.cs:
- Some more work on the debugging infos api.
-
- * Mono.Cecil/MethodDefinitionCollection.cs
- Mono.Cecil/ConstructorCollection.cs
- CodeGen/templates/IndexedCollection.cs:
- Fix the GetConstructor/GetMethod methods.
- Based on a patch by Jon Chambers.
-
-2006-09-20 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/StructureWriter.cs
- Mono.Cecil/ModuleDefinition.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil/AssemblyFactory.cs
- Mono.Cecil.Cil/ISymbolReader.cs
- Mono.Cecil.Cil/CodeWriter.cs
- Mono.Cecil.Cil/ISymbolWriter.cs
- Mono.Cecil.Cil/SymbolStoreHelper.cs:
- Working on the debug infos stuff.
-
- * Mono.Cecil.Signatures/SignatureReader.cs:
- Ensure custom attributes are read when they can be.
- Patch by Sebastien Pouliot.
-
-2006-09-19 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ModuleDefinition.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil.Cil/Document.cs
- Mono.Cecil.Cil/Instruction.cs
- Mono.Cecil.Cil/SequencePoint.cs
- Mono.Cecil.Cil/CodeReader.cs
- Mono.Cecil.Cil/IScopeProvider.cs
- Mono.Cecil.Cil/ISymbolReader.cs
- Mono.Cecil.Cil/CodeWriter.cs
- Mono.Cecil.Cil/ISymbolWriter.cs
- Mono.Cecil.Cil/IVariableDefinitionProvider.cs
- Mono.Cecil.Cil/SymbolStoreHelper.cs
- Mono.Cecil.Cil/ISymbolStoreFactory.cs
- Mono.Cecil.Cil/ScopeCollection.cs
- Mono.Cecil.Cil/Scope.cs:
- Work on the architecture for debugging infos.
-
- * Mono.Cecil.dll.sources
- Mono.Cecil.Cil/Document.cs
- Mono.Cecil.Cil/IVariableDefinitionProvider.cs
- Mono.Cecil.Cil/SequencePoint.cs
- Mono.Cecil.Cil/ScopeCollection.cs
- Mono.Cecil.Cil/BaseCodeVisitor.cs
- Mono.Cecil.Cil/CodeReader.cs
- Mono.Cecil.Cil/IScopeProvider.cs
- Mono.Cecil.Cil/MethodBody.cs
- Mono.Cecil.Cil/ICodeVisitor.cs
- Mono.Cecil.Cil/CodeWriter.cs
- Mono.Cecil.Cil/Scope.cs
- Mono.Cecil.Cil/VariableDefinitionCollection.cs
- CodeGen/cecil.xml:
- First bits of the debug infos stuff.
-
- * Mono.Cecil.Cil/InstructionCollection.cs
- CodeGen/templates/IndexedCollection.cs:
- The outside instruction has an offset of -1.
-
- * Mono.Cecil.Cil/OpCodes.cs
- Mono.Cecil.Cil/CodeReader.cs
- Mono.Cecil.Cil/OpCode.cs
- CodeGen/templates/OpCodes.cs:
- Simpliest way of dealing with different opcodes.
-
-2006-09-07 Jb Evain <jbevain@gmail.com>
-
- * support PE32+ file format.
-
- * Add an Outside instruction to an InstructionCollection.
- Cleaner than the old null instruction.
-
- * Mono.Cecil/MarshalSpec.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/ReflectionWriter.cs
- CodeGen/cecil-mig.rb:
- Refactor names from Desc to Spec.
-
- * *Collection.cs:
- Remove the unused events stuff.
-
-2006-08-31 Jb Evain <jbevain@gmail.com>
-
- * /!\ Breaking changes:
- On the way to Cecil 0.5. Remove meaningless interfaces.
- GenericParamAttributes -> GenericParameterAttributes
- ParamAttributes -> ParamAttributes
-
- I'll provide a migration path with a script.
-
- Please do not use this revision, other changes are on the way.
-
-2006-08-26 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionReader.cs:
- Fix a bug when reading some parameters.
-
-2006-08-26 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Cil/ReflectionWriter.cs:
- Fix the computation of the size of the last opcode in case
- of an exception handler is pointing outside the cil stream.
-
- * Mono.Cecil.Cil/ReflectionWriter.cs:
- Don't use seh tiny headers when the size can't fit in a byte.
-
- * Mono.Cecil.Cil/ReflectionWriter.cs:
- Fix a problem in the computation of the stack when the IL
- is somewhat strange.
-
-2006-08-23 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/AssemblyInfo.cs:
- Cecil 0.4.3 release.
-
-2006-08-21 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Metadata/MetadataWriter.cs:
- Fix a bug in field initial values writing.
-
- * Mono.Cecil/BaseAssemblyResolver.cs:
- Look for assemblies in ./ first
-
-2006-08-17 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/BaseAssemblyResolver.cs:
- Resolve the corlib depending on its version.
-
- * Mono.Cecil/AssemblyName.cs
- Mono.Cecil/BaseAssemblyResolver.cs:
- Implement a AssemblyNameReference.Parse(string)
-
- * Mono.Cecil/TypeReferenceCollection.cs
- Mono.Cecil/ExternTypeCollection.cs
- Mono.Cecil/TypeDefinitionCollection.cs
- CodeGen/templates/NamedCollectionImplem.cs:
- Avoid infinite recursion.
-
- * Mono.Cecil/BaseAssemblyResolver.sc:
- Stay .net 1.1 compatible
-
-2006-08-16 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/IAssemblyResolver.cs
- Mono.Cecil/BaseAssemblyResolver.cs
- Mono.Cecil/DefaultAssemblyResolver.cs
- Mono.Cecil/AssemblyDefinition.cs
- Implement an assembly resolver.
-
- * Mono.Cecil/ReflectionReader.cs:
- Fix the initial value reading.
- Based on a report and a patch of Roei Erez <roeie@mainsoft.com>
-
-2006-08-15 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/TypeReferenceCollection.cs
- Mono.Cecil/ExternTypeCollection.cs
- Mono.Cecil/TypeDefinitionCollection.cs
- CodeGen/templates/NamedCollectionImplem.cs:
- Fix the CopyTo method.
-
-2006-07-19 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/templates/IIndexedCollection.cs
- CodeGen/templates/IndexedCollectionImplem.cs
- Mono.Cecil/IConstructorCollection.cs
- Mono.Cecil/IMethodDefinitionCollection.cs
- Mono.Cecil/MethodDefinitionCollection.cs
- Mono.Cecil/ConstructorCollection.cs:
- Add a GetConstructor(bool,ParameterDefinitionCollection) method
- required by the linker.
-
- * Mono.Cecil.Metadata/MetadataReader.cs
- Mono.Cecil.Metadata/StringsHeap.cs:
- Read the string on demand, based on the index.
- Needed due to some obfuscators that create a string entry like
- xClassName, and make the pointer points to after the x.
-
-2006-07-03 Rodrigo B. de Oliveira <rodrigobamboo@gmail.com>
- * CodeGen/templates/ImageReader.cs
- Mono.Cecil.Binary/ImageReader.cs:
- CompactFramework compatibility.
-
-2006-07-02 Rodrigo B. de Oliveira <rodrigobamboo@gmail.com>
-
- * CodeGen/templates/ImageReader.cs
- Mono.Cecil.Binary/ImageReader.cs:
- Proper FileNotFoundException construction.
-
- * Mono.Cecil/MethodDefinition.cs
- Mono.Cecil/IMethod.cs:
- Helper properties IsInternalCall and IsRuntime.
-
-2006-06-21 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Cil/CilWorker.cs:
- Fix ldc.i4.s emitting.
-
-2006-06-13 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionWriter.cs:
- Fix for compiling on CF 1.
- * Mono.Cecil/StructureReader.cs:
- Fix for a "bug" when csc 7.1 emits an assembly
- with an assembly row, but no blob heap.
- Plus style fix.
-
-2006-06-08 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/IMethod.cs
- Mono.Cecil/MethodDefinition.cs
- Mono.Cecil/ReflectionWriter.cs:
- Add a public HasBody property.
-
-2006-06-07 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/MethodDefinition.cs
- Mono.Cecil/ReflectionWriter.cs:
- Read and write method bodies only when allowed.
-
-2006-05-29 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/IMethodDefinition.cs
- Mono.Cecil/MethodDefinition.cs:
- Remove the useless CreateBody method.
-
-2006-05-27 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/StructureWriter.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/MethodDefinition.cs
- Mono.Cecil.Metadata/MetadataToken.cs
- Mono.Cecil.Signatures/SignatureReader.cs:
- Play better with mixed mode assemblies.
-
- * Mono.Cecil/SecurityDeclarationReader.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil.Signatures/SignatureReader.cs:
- Read/Write this awful load of crap that is sharepoint.
-
-2006-05-22 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Cil/CilWorker.cs:
- Fix #78479. Patch by David Emsellem.
-
-2006-05-20 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/templates/ImageReader.cs
- CodeGen/templates/ImageWriter.cs
- Mono.Cecil/AssemblyFactory.cs
- Mono.Cecil/StructureWriter.cs
- Mono.Cecil/Binary/ImageReader.cs
- Mono.Cecil/Binary/Image.cs
- Mono.Cecil/Binary/ImageWriter.cs
- Mono.Cecil.Metadata/MetadataWriter.cs:
- Optimize assembly writing.
- Add methods to read assemblies from byte arrays.
-
- * Mono.Cecil/StructureWriter.cs:
- Throw an exception when the target is an exe
- and no entry point have been setted.
- * Mono.Cecil/AssemblyFactory.cs:
- Add helpers method to defines assemblies.
- * Mono.Cecil/MethodDefinition.cs:
- Set the hasThis flag to the correct value.
- * Mono.Cecil.Cil/CodeReader.cs:
- Remove old comment.
- * Mono.Xml/SmallXmlParser.cs:
- Make private.
-
-2006-05-18 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/templates/MetadataTableReader.cs
- Mono.Cecil.Metadata/MetadataTableReader.cs
- Mono.Cecil.Metadata/TableCollection.cs
- Mono.Cecil.Metadata/TablesHeap.cs:
- Optimize a little bit.
-
- * CodeGen/templates/MetadataTableWriter.cs
- Mono.Cecil.Metadata/MetadataTableWriter.cs
- Mono.Cecil.Metadata/TableCollection.cs:
- Fix for last changeset.
-
- * Mono.Cecil.Metadata/RIdAttribute.cs:
- deleted.
-
- * Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/StructureReader.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil/AggressiveReflectionReader.cs
- Mono.Cecil.Cil/CodeReader.cs
- CodeGen/templates/Utilities.cs
- CodeGen/templates/MetadataTableReader.cs
- CodeGen/templates/MetadataTableWriter.cs
- CodeGen/templates/Table.cs
- CodeGen/templates/MetadataRowReader.cs
- CodeGen/templates/MetadataRowWriter.cs
- Mono.Cecil.Metadata/Assembly.cs
- Mono.Cecil.Metadata/InterfaceImpl.cs
- Mono.Cecil.Metadata/PropertyMap.cs
- Mono.Cecil.Metadata/Constant.cs
- Mono.Cecil.Metadata/MethodSpec.cs
- Mono.Cecil.Metadata/DeclSecurity.cs
- Mono.Cecil.Metadata/TypeDef.cs
- Mono.Cecil.Metadata/GenericParamConstraint.cs
- Mono.Cecil.Metadata/MethodImpl.cs
- Mono.Cecil.Metadata/NestedClass.cs
- Mono.Cecil.Metadata/MetadataTableReader.cs
- Mono.Cecil.Metadata/AssemblyRefProcessor.cs
- Mono.Cecil.Metadata/AssemblyRef.cs
- Mono.Cecil.Metadata/AssemblyRefOS.cs
- Mono.Cecil.Metadata/Method.cs
- Mono.Cecil.Metadata/MetadataTableWriter.cs
- Mono.Cecil.Metadata/MetadataRowReader.cs
- Mono.Cecil.Metadata/ExportedType.cs
- Mono.Cecil.Metadata/CustomAttribute.cs
- Mono.Cecil.Metadata/Param.cs
- Mono.Cecil.Metadata/ClassLayout.cs
- Mono.Cecil.Metadata/MetadataRowWriter.cs
- Mono.Cecil.Metadata/Utilities.cs
- Mono.Cecil.Metadata/AssemblyOS.cs
- Mono.Cecil.Metadata/ModuleRef.cs
- Mono.Cecil.Metadata/FieldMarshal.cs
- Mono.Cecil.Metadata/GenericParam.cs
- Mono.Cecil.Metadata/ImplMap.cs
- Mono.Cecil.Metadata/TableCollection.cs
- Mono.Cecil.Metadata/TablesHeap.cs
- Mono.Cecil.Metadata/TypeRef.cs
- Mono.Cecil.Metadata/ManifestResource.cs
- Mono.Cecil.Metadata/File.cs
- Mono.Cecil.Metadata/EventMap.cs
- Mono.Cecil.Metadata/AssemblyProcessor.cs
- Mono.Cecil.Metadata/FieldLayout.cs
- Mono.Cecil.Metadata/Event.cs
- Mono.Cecil.Metadata/Field.cs
- Mono.Cecil.Metadata/Property.cs
- Mono.Cecil.Metadata/Module.cs
- Mono.Cecil.Metadata/MethodSemantics.cs
- Mono.Cecil.Metadata/StandAloneSig.cs
- Mono.Cecil.Metadata/FieldRVA.cs
- Mono.Cecil.Metadata/TypeSpec.cs
- Mono.Cecil.Metadata/IMetadataTable.cs
- Mono.Cecil.Metadata/MemberRef.cs:
- Fix the way the metadata tables are handled.
-
- * Mono.Cecil.Signatures/SignatureWriter.cs:
- Fix bug in string writing.
-
-2006-05-12 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/AssemblyInfo.cs:
- Hide the info if Cecil is embedded.
-
-2006-05-09 Jb Evain <jbevain@gmail.com>
-
- * cecil.build: rename to default.build
-
-2006-05-08 Jb Evain <jbevain@gmail.com>
-
- * Makefile:
- Sign the assembly.
-
- * cecil.csproj:
- Add an msbuild file.
-
-2006-05-05 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/AssemblyFactory.cs
- Mono.Cecil/StructureReader.cs
- Mono.Cecil/ModuleDefinition.cs:
- Add an AssemblyFactory.GetAssemblyManifest method.
-
-2006-05-04 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/TableComparers.cs:
- TypeDef.Compare: the name is enough against <Module>.
-
- * Mono.Cecil/ReflectionWriter.cs:
- Fix writing of namedargs in custom attributes.
-
-2006-04-26 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Signatures/SignatureReader.cs:
- Don't create tons of hashtables.
-
-2006-04-24 Jb Evain <jbveain@gmail.com>
-
- * Mono.Cecil.Cil/MethodBody.cs:
- Fix cloning.
-
-2006-04-21 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/AssemblyFactory.cs
- Mono.Cecil.Binary/MemoryBinaryWriter.cs:
- Use MemoryStream::WriteTo when it's possible.
-
-2006-04-21 Rodrigo B. de Oliveira <rodrigobamboo@gmail.com>
-
- * Mono.Cecil/SecurityDeclaration.cs
- Mono.Cecil/ISecurityDeclaration.cs
- Mono.Cecil/SecurityDeclarationCollection.cs
- Mono.Cecil/ModuleDefinition.cs:
- Patch by Almann T. Goo (almann.goo@gmail.com) conditionally
- removing references to PermissionSet when compiling for the CompactFramework.
-
- * Mono.Cecil/CompactFrameworkCompatibility.cs:
- System.Security.PermissionSet definition no longer needed.
-
-2006-04-21 Jb Evain <jbevain@gmail.com>
-
- * *Collection.cs:
- Fix typo in RemoveAt.
-
-2006-04-20 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionWriter.cs:
- Fix writing of complex arrays.
- Now we roundtrip SharpDevelop.
-
- * Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil/TableComparers.cs:
- Ensure <Module> will always be the first type.
- Fix roundtrip of Nemerle.
-
-2006-04-19 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Cil/CodeWriter.cs:
- Handle the case where an handler points after the last
- instruction. Now we roundtrip db4o.
-
- * Mono.Cecil/IIndexedCollection.cs:
- *Collection.cs:
- Make every collection implement an indexed collection.
-
-2006-04-15 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/CustomAttribute.cs:
- Fix handling of types.
-
-2006-04-11 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/FieldDefinition.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/TypeDefinition.cs
- Mono.Cecil/IField.cs
- Mono.Cecil/ITypeDefinition.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil/AggressiveReflectionReader.cs
- Mono.Cecil.Cil/IVariable.cs
- Mono.Cecil.Cil/MethodBody.cs
- Mono.Cecil.Cil/VariableDefinition.cs
- Mono.Cecil.Cil/CodeWriter.cs:
- Don't use interfaces internally.
-
- * Mono.Cecil/TypeReference.cs:
- Make TypeReference extend MemberReference.
-
- * Mono.Cecil/Modifiers.cs
- Mono.Cecil.Cil/CodeReader.cs
- Mono.Cecil.Cil/CodeWriter.cs
- Mono.Cecil.Signatures/LocalVarSig.cs
- Mono.Cecil.Signatures/SignatureReader.cs:
- Fix modifiers on localvar signatures.
- Fix roundtrip of delphi assemblies.
-
- * Mono.Cecil/CustomAttribute.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- Work on complex custom attributes encoding.
-
- * Mono.Cecil/TableComparers.cs:
- Style.
-
-2006-04-09 Eyal Alaluf <eyala@mainsoft.com>
-
- * Mono.Cecil/ReflectionReader.cs
- Cannot assume that TypeRefs are ordered is such a way that an outer
- class index comes always before all its inner classes.
-
-2006-04-06 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- Clean up things a little bit prior ending
- custom attribute encoding.
-
- * Mono.Cecil/ReflectionWriter.cs:
- Write custom attributes of parameters
- onyl when all methods have their tokens.
-
- * Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil/AggressiveReflectionReader.cs:
- Handle custom attributes on generic parameters.
-
-2006-04-05 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionWriter.cs:
- Ensure the param[0] is written when it should be.
-
-2006-04-04 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionHelper.cs:
- Remove an unused hack.
-
- * Mono.Cecil/AssemblyInfo.cs: Go 0.4.1
-
- * Mono.Cecil.Metadata/MetadataHeap.cs
- Mono.Cecil.Metadata/MetadataStream.cs:
- Read #- stream has well.
-
- * Mono.Cecil/ReflectionHelper.cs:
- Implement Import stuff for System.Type and SR.*
-
-2006-04-03 Rodrigo B. de Oliveira <rodrigobamboo@gmail.com>
-
- * Mono.Cecil/SecurityDeclarationReader.cs
- Mono.Cecil/TypeReferenceCollection.cs
- Mono.Cecil/CompactFrameworkCompatibility.cs
- Mono.Cecil/AssemblyFactory.cs
- Mono.Cecil/AssemblyName.cs
- Mono.Cecil/ExternTypeCollection.cs
- Mono.Cecil/TypeDefinitionCollection.cs
- CodeGen/templates/NamedCollectionImplem.cs
- Mono.Cecil.Metadata/CultureUtils.cs
- cecil.build:
- CompactFramework 2.0 support through CF_2_0 compilation symbol.
-
-2006-04-03 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.dll.sources
- Mono.Cecil/GenericParameter.cs
- Mono.Cecil/ReflectionHelper.cs
- Mono.Cecil/FieldDefinition.cs
- Mono.Cecil/CustomAttribute.cs
- Mono.Cecil/TypeDefinition.cs
- Mono.Cecil/IModuleDefinition.cs
- Mono.Cecil/ImportContext.cs
- Mono.Cecil/AssemblyName.cs
- Mono.Cecil/MethodDefinition.cs
- Mono.Cecil/EventDefinition.cs
- Mono.Cecil/ModuleDefinition.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil/GenericContext.cs
- Mono.Cecil/ParameterDefinition.cs
- Mono.Cecil/PropertyDefinition.cs
- Mono.Cecil.Cil/MethodBody.cs:
- Work on generic assemblies manipulation via
- import stuff.
-
-2006-03-31 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/AssemblyFlags.cs:
- Add a Retargetable flag used on the CF.
-
-2006-03-30 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/SecurityDeclarationReader.cs:
- Don't crash if the declaration is empty.
-
- * Mono.Cecil/ParamAttributes.cs:
- Update the Optional flag.
- Mono.Cecil/ReflectionWriter.cs:
- Fix the encoding of nullref.
- Fixes #77959. Based on a patch by
- Armand Du Plessis < armand@dotnet.org.za>
-
-2006-03-29 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/IHasSecurity.cs
- Mono.Cecil/IHasConstant.cs
- Mono.Cecil/IHasMarshalSpec.cs:
- Mono.Cecil/MethodReturnType.cs
- Mono.Cecil/AssemblyDefinition.cs:
- Implement IMetadataTokenProvider.
-
- * Mono.Cecil/StructureReader.cs
- Mono.Cecil/ReflectionWriter.cs:
- Use more the token providers.
-
-2006-03-28 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/MarshalDesc.cs
- Mono.Cecil/IMarshalSpec.cs
- Mono.Cecil/ReflectionWriter.cs:
- Fix round-tripping of assemblies using
- COM stuff.
-
-2006-03-27 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Metadata/MetadataToken.cs:
- Override GetHashCode as we override Equals.
-
- * Mono.Cecil/TableComparers.cs:
- Fix the ordering of generic parameters.
- This revision roundtrips C5. Yeah!
-
- * Mono.Cecil/ReflectionWriter.cs:
- Fix method spec "caching"
- Mono.Cecil.Cil/OpCode.cs:
- Override ToString ();
- Mono.Cecil.Metadata/MetadataToken.cs:
- Implement operator ==
-
- * Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil/TableComparers.cs:
- Better handling of generic tables sorting.
-
- * Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil/TableComparers.cs:
- Sort generic tables as well.
-
-2006-03-27 Rodrigo B. de Oliveira <rodrigobamboo@gmail.com>
- * Mono.Cecil.Metadata/MetadataWriter.cs:
- Use CompactFramework compatible version of
- System.Convert.ToBase64String.
-
-2006-03-27 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.dll.sources
- Mono.Cecil/GenericParameter.cs
- Mono.Cecil/ConstraintCollection.cs
- Mono.Cecil/IGenericParameter.cs
- Mono.Cecil/IConstraintCollection.cs
- CodeGen/cecil.xml:
- Add a ConstraintCollection to be used within
- generic parameters.
-
- * Mono.Cecil/GenericInstanceType.cs:
- Correctly return if the instance is a value type
- or not.
-
-2006-03-25 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ModuleDefinition.cs:
- Support the unreadable security declarations
- when converting one to byte [].
-
- * Mono.Cecil/IModuleDefinition.cs
- Mono.Cecil/ModuleDefinition.cs
- Mono.Cecil/ReflectionWriter.cs:
- Add a FullLoad method on a module.
-
- * Mono.Cecil/StructureWriter.cs
- Mono.Cecil/ReflectionWriter.cs:
- Fix a few bugs in generics type emitting.
-
- * Mono.Cecil.Cil/CodeWriter.cs:
- Cache local sig as well.
-
-2006-03-24 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionWriter.cs:
- Cache method specs as well.
-
- * CodeGen/templates/ImageWriter.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Binary/ImageWriter.cs:
- Replace the foreach char pattern by
- Encoding.GetBytes
-
-2006-03-23 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/TypeReferenceCollection.cs
- Mono.Cecil/ExternTypeCollection.cs
- Mono.Cecil/TypeDefinitionCollection.cs
- CodeGen/templates/NamedCollectionImplem.cs
- CodeGen/templates/ImageReader.cs:
- Ensure type with the same name are added
- to the collection.
-
- * Mono.Cecil.Metadata/MetadataWriter.cs:
- Ensure every blob signature is unique.
-
- * Mono.Cecil/IModuleDefinition.cs
- Mono.Cecil/ModuleDefinition.cs:
- Rename method to avoid confusion.
-
-2006-03-22 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Cil/CodeWriter.cs:
- Precisely detect whether we emit fat seh or not.
-
- * Mono.Cecil/ReflectionWriter.cs:
- Avoid duplicates in the typespec table.
-
-2006-03-21 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionWriter.cs:
- Correctly write generic parameters.
-
- * Mono.Cecil/SecurityDeclarationReader.cs
- Mono.Cecil/SecurityDeclaration.cs
- Mono.Cecil/ReflectionWriter.cs:
- Fix for security declarations reading on .net 2.0.
-
- * Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/GenericContext.cs:
- Fix test case RoundtripTestFixture.boo.
-
-2006-03-20 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Metadata/MetadataReader.cs:
- #Strings heap is utf8, fix #77820.
-
-2006-03-08 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/cecil-gen-tests.rb
- CodeGen/templates/Tests.cs:
- Start of a very small infrastructure to use tests from
- rotor/mono with Cecil.
-
- * Mono.Cecil/IMethod.cs
- Mono.Cecil/TypeDefinition.cs
- Mono.Cecil/MethodDefinition.cs
- Mono.Cecil.Cil/CodeReader.cs
- Mono.Cecil.Cil/CodeWriter.cs:
- Add support for the very special case ldarg 0.
- Patch idea by Vladislav Spivak <spivak@mainsoft.com>
-
-2006-03-07 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/templates/ImageReader.cs
- Mono.Cecil/AssemblyFactory.cs
- Mono.Cecil/StructureReader.cs
- Mono.Cecil.Binary/Image.cs
- Mono.Cecil.Binary/ImageReader.cs:
- Allow users to get a loaded image using
- Image.GetImage as they have no access to
- the ImageReader.
-
-2006-03-06 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Signatures/SignatureReader.cs:
- Fix array reading in custom attributes.
-
-2006-03-06 Joshua Tauberer <tauberer@for.net>
-
- * Mono.Cecil/TypeAttributes.cs: Fixed typo
- in value for Abstract.
-
-2006-02-27 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/templates/IndexedCollectionImplem.cs
- CodeGen/templates/IIndexedCollection.cs
- Mono.Cecil.Cil/InstructionCollection.cs
- Mono.Cecil.Cil/IInstructionCollection.cs:
- Small API fix, prevent the user from not using
- the CilWorker.
-
- * Mono.Cecil.Cil/CodeReader.cs
- Mono.Cecil.Cil/Label.cs:
- Remove Label.
-
- * Mono.Cecil/ReflectionReader.cs:
- Fix typo.
-
-2006-02-20 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Signatures/SignatureWriter.cs:
- Fix a bug when a value is null in a custom attribute.
-
-2006-02-20 Sebastien Pouliot <sebastien@ximian.com>
-
- * Mono.Cecil.Metadata/MetadataWriter.cs:
- Fix GetStrongNameSignatureSize to handle the ECMA pseudo-key.
-
-2006-02-07 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/AssemblyInfos.cs:
- Tag this version 0.3, as users are happy with it.
-
-2006-01-26 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/CustomAttribute.cs:
- Fix cloning of non readable attributes.
-
- * Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil.Signatures/MethodRefSig.cs
- Mono.Cecil.Signatures/SignatureWriter.cs
- Mono.Cecil.Signatures/MethodDefSig.cs:
- Work on generics.
-
- * Mono.Cecil/ArrayType.cs
- Mono.Cecil/ReferenceType.cs
- Mono.Cecil/PointerType.cs:
- Fix names of typespecs.
-
- * Mono.Cecil/TypeReferenceCollection.cs
- Mono.Cecil/ExternTypeCollection.cs
- CodeGen/templates/NamedCollectionImplem.cs:
- Allow multiple key by names in type references.
-
-2006-01-25 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/AssemblyFactory.cs:
- Don't trap exceptions.
-
- * Mono.Cecil/GenericParameter.cs
- Mono.Cecil/IMethod.cs
- Mono.Cecil/GenericInstanceType.cs
- Mono.Cecil/TypeReference.cs
- Mono.Cecil/GenericInstanceMethod.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/TypeDefinition.cs
- Mono.Cecil/IGenericArgumentCollection.cs
- Mono.Cecil/ITypeReference.cs
- Mono.Cecil/IGenericInstance.cs
- Mono.Cecil/GenericArgumentCollection.cs
- Mono.Cecil/MethodDefinition.cs
- Mono.Cecil/MethodReference.cs
- Mono.Cecil/ITypeDefinition.cs
- Mono.Cecil/IGenericArgumentProvider.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil/GenericContext.cs
- CodeGen/cecil.xml:
- Clean the generic api. This is not stable yet.
-
-2006-01-24 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ArrayType.cs:
- Bug reported by Vladislav Spivak (spivak@mainsoft.com).
- Fix a bug in array handling.
- * Mono.Cecil/ConstructorCollection.cs
- CodeGen/templates/IndexedCollectionImplem.cs:
- Bug reported by Oleg Varchovsky (olegv@mainsoft.com).
- Fix the lookup of constructors.
-
-2006-01-19 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/AssemblyName.cs:
- Fix computation of public key token.
-
-2006-01-18 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Cil/CodeWriter.cs
- Mono.Cecil.Metadata/MetadataToken.cs:
- Add an use an ToUInt method and use it.
- CodeGen/templates/DebugHeader.cs
- Mono.Cecil.Binary/DebugHeader.cs:
- Fix the size of the debug header.
-
- * Mono.Cecil/ModuleReference.cs
- Mono.Cecil/AssemblyName.cs
- Mono.Cecil/StructureReader.cs
- Mono.Cecil/IMetadataScope.cs:
- Make IMetadataScope implement IMetadataTokenProvider.
- * Mono.Cecil/ReflectionWriter.cs:
- Fix a typo when saving nested type refs.
-
-2006-01-17 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ArrayType.cs
- Mono.Cecil/ArrayDimension.cs
- Mono.Cecil/ReflectionWriter.cs:
- End arrays support.
-
-2006-01-03 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/GenericParameter.cs
- Mono.Cecil/ReflectionHelper.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/GenericContext.cs:
- Work on generics.
-
-2005-12-31 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionHelper.cs:
- Fix import of type specs.
-
-2005-12-30 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/templates/ImageReader.cs
- Mono.Cecil.Metadata/MetadataReader.cs
- Mono.Cecil.Binary/Image.cs
- Mono.Cecil.Binary/ImageReader.cs:
- Add support to assemblies where the metadata is defined
- outside of the text section. (c++/cli /safe for instance)
-
-2005-12-23 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/AssemblyInfo.cs:
- Version 0.2.2.2 devel.
-
- * Mono.Cecil/AssemblyInfo.cs:
- Version 0.2 to be released.
-
- * Mono.Cecil/ReflectionWriter.cs:
- IGenericInstance are typespecs as well.
-
- * Mono.Cecil/ArrayType.cs:
- Add a single dimension in the default ctor.
- * Mono.Cecil/ReflectionReader.cs:
- Don't manually add the default dimension as it's done
- int the array type ctor.
- * Mono.Cecil/ReflectionHelper.cs:
- Import type specs.
-
-2005-12-22 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionWriter:
- Write pinvoke infos as well.
-
- * Mono.Cecil/ReflectionReader.cs:
- Unsure that primitive value types are viewed as
- value types.
-
- * CodeGen/templates/Section.cs
- CodeGen/templates/ImageReader.cs
- Mono.Cecil.Metadata/MetadataReader.cs
- Mono.Cecil.Binary/Image.cs
- Mono.Cecil.Binary/Section.cs
- Mono.Cecil.Binary/ImageReader.cs:
- Simplify the way you read binary data whithin
- high level layer.
-
- * Mono.Cecil.Cil/CodeReader.cs:
- Make helper methods public static.
- * Mono.Cecil/ReflectionReader.cs:
- Don't try to get the entry point method
- if it don't point on a valid method RID.
-
- * CodeGen/templates/NamedCollectionImplem.cs
- Mono.Cecil/ExternTypeCollection.cs
- Mono.Cecil/TypeDefinitionCollection.cs
- Mono.Cecil/TypeReferenceCollection.cs:
- Don't add existing values.
-
- * Mono.Cecil/ModuleDefinition.cs:
- Protect import from null refs.
-
-2005-12-21 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/StructureWriter.cs:
- Don't increment pdb age. Not Cecil's job.
-
- * Mono.Cecil.Cil/ICilWorker.cs
- Mono.Cecil.Cil/CilWorker.cs:
- Add a new replace method.
-
-2005-12-20 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/StructureWriter.cs:
- Ensure every assembly reference is processed.
-
- * Mono.Cecil/ReflectionHelper.cs:
- Don't assume the cache is magically loaded.
- Aka: most stupid bug of the year.
-
-2005-12-19 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/templates/DebugHeader.cs
- Mono.Cecil.Binary/DebugHeader.cs
- Mono.Cecil.Binary/DebugStoreType.cs:
- New files to store debug header infos.
- * Mono.Cecil.dll.sources: updated
- * CodeGen/cecil.xml
- CodeGen/cecil-gen.rb
- Mono.Cecil/StructureWriter.cs
- Mono.Cecil.Binary/IBinaryVisitor.cs
- Mono.Cecil.Binary/ImageWriter.cs
- Mono.Cecil.Binary/Image.cs
- Mono.Cecil.Binary/ImageInitializer.cs
- Mono.Cecil.Binary/BaseImageVisitor.cs
- Mono.Cecil.Binary/ImageReader.cs
- Mono.Cecil.Metadata/MetadataWriter.cs:
- Read and write debug header.
-
- * CodeGen/templates/ImageWriter.cs
- Mono.Cecil.Binary/ImageWriter.cs:
- Revert revision 54409.
-
-2005-12-14 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Cil/ICilWorker.cs
- Mono.Cecil.Cil/CilWorker.cs:
- Add a remove method.
-
- * CodeGen/templates/ImageWriter.cs
- Mono.Cecil.Binary/ImageWriter.cs:
- Don't allocate potential big arrays here.
-
-2005-12-13 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Metadata/MetadataWriter.cs:
- Set the correct version for .net 2 assemblies.
- Correctly write embedded resources.
- Fix #76963.
-
-2005-12-03 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/MethodSpecification.cs:
- Override the declaring type and the name property to
- match the inner method.
- * Mono.Cecil/GenericInstanceType.cs:
- Correctly set the FullName.
- * Mono.Cecil/GenericInstanceMethod.cs:
- Style.
-
-2005-12-02 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/TypeDefinition.cs:
- Fix interface import. Patch by Thomas Gil.
-
-2005-11-24 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/cecil-gen.rb
- CodeGen/templates/MetadataTableReader.cs
- CodeGen/templates/PEFileHeader.cs
- CodeGen/templates/CLIHeader.cs
- CodeGen/templates/PEOptionalHeader.cs
- CodeGen/templates/Table.cs
- CodeGen/templates/MetadataRowReader.cs
- CodeGen/templates/OpCodes.cs
- CodeGen/templates/Section.cs
- CodeGen/templates/ImageReader.cs:
- Update the codegen engine so that everyone can run it
- without having to install a dependency (eruby).
-
- * Mono.Cecil.Metadata/Utilities.cs: re-codegenerated.
-
-2005-11-23 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/IGenericArgumentProvider.cs
- Style.
- * CodeGen/cecil.xml:
- Mirror Martin's change in the codegen engine.
-
-2005-11-23 Martin Baulig <martin@ximian.com>
-
- Generics API changes:
- TypeReference and MethodReference now contain a
- `GenericArguments' property (of type `GenericArgumentCollection')
- and `GenericParameters' is moved into TypeDefinition/MethodDefinition.
-
- * Mono.Cecil/IGenericArgumentProvider.cs: New file.
- (IGenericArgumentProvider): New public interface.
-
- * Mono.Cecil/IGenericArgumentCollection.cs
- (IGenericArgumentCollection.Container): Changed type from
- `IGenericInstance' -> `IGenericArgumentProvider'.
-
- * Mono.Cecil/IGenericInstance.cs
- (IGenericInstance.Arguments): Renamed to `GenericArguments'.
-
- * Mono.Cecil/ITypeReference.cs
- (ITypeReference): Implement `IGenericArgumentProvider' instead of
- `IGenericParameterProvider'.
-
- * Mono.Cecil/ITypeDefinition.cs
- (ITypeDefinition): Implement `IGenericParameterProvider'.
-
- * Mono.Cecil/IMethod.cs
- (IMethodReference): Implement `IGenericArgumentProvider' instead of
- `IGenericParameterProvider'.
- (IMethodDefinition): Implement `IGenericParameterProvider'.
-
- * Mono.Cecil/TypeReference.cs
- (TypeReference.GenericParameters): Removed.
- (TypeReference.GenericArguments): New public property.
-
- * Mono.Cecil/TypeDefinition.cs
- (TypeDefinition.GenericParameters): New public property.
- (TypeDefinition.OnGenericParameterAdded): If a generic parameter
- is added, also add it to the `GenericArguments'.
-
- * Mono.Cecil/MethodReference.cs
- (MethodReference.GenericParameters): Removed.
- (MethodReference.GenericArguments): New public property.
-
- * Mono.Cecil/MethodDefinition.cs
- (MethodDefinition.GenericParameters): New public property.
- (MethodDefinition.OnGenericParameterAdded): If a generic parameter
- is added, also add it to the `GenericArguments'.
-
- * Mono.Cecil/GenericInstanceType.cs
- (GenericInstanceType): Removed the `m_arguments' field; we now
- inherit the `GenericArguments' property from `TypeReference'.
-
- * Mono.Cecil/GenericInstanceMethod.cs
- (GenericInstanceMethod): Removed the `m_arguments' field; we now
- inherit the `GenericArguments' property from `MethodReference'.
-
- * Mono.Cecil/GenericContext.cs
- (GenericContext): We now operate on type/method references and not
- definitions.
- (GenericContext.Type): Changed type to `TypeReference'.
- (GenericContext.Method): Changed type to `MethodReference'.
-
-2005-11-23 Martin Baulig <martin@ximian.com>
-
- * Mono.Cecil.Metadata/TokenType.cs: Added `GenericParam'.
-
- * Mono.Cecil.Metadata/Utilities.cs
- (GetMetadataToken): In `case CodedIndex.HasCustomAttribute', add
- `TokenType.GenericParam'.
-
-2005-11-22 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/IMethodDefinitionCollection.cs
- Mono.Cecil/MethodDefinitionCollection.cs
- CodeGen/templates/IndexedCollectionImplem.cs
- CodeGen/templates/IIndexedCollection.cs:
- Add a new search method.
- * CodeGen/templates/NamedCollectionImplem.cs
- Mono.Cecil/TypeReferenceCollection.cs
- Mono.Cecil/ExternTypeCollection.cs
- Mono.Cecil/TypeDefinitionCollection.cs:
- Style.
-
-2005-11-13 Rodrigo B. de Oliveira <rodrigobamboo@gmail.com>
- * Mono.Cecil/ReflectionReader.cs
- Fix for NRE when reading assemblies with a field initializer
- pointing to a data section
- (TestCases/Regression/OddInt64Initializer.dll).
-
-2005-11-11 Sebastien Pouliot <sebastien@ximian.com>
-
- * Mono.Cecil.Metadata/MetadataWriter.cs
- Add support for different strongname key size (between 384
- and 16384 bits) as now supported in fx 2.0. Default is still
- 1024 bits.
-
-2005-11-10 Rodrigo B. de Oliveira <rodrigobamboo@gmail.com>
- * Mono.Cecil/CompactFrameworkCompatibility.cs
- Mono.Cecil/SecurityDeclarationReader.cs
- Mono.Cecil/TypeReferenceCollection.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/AssemblyFactory.cs
- Mono.Cecil/AssemblyName.cs
- Mono.Cecil/ExternTypeCollection.cs
- Mono.Cecil/ModuleDefinition.cs
- Mono.Cecil/TypeDefinitionCollection.cs
- CodeGen/templates/NamedCollectionImplem.cs
- CodeGen/templates/ImageReader.cs
- Mono.Cecil.Metadata/MetadataReader.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Metadata/CultureUtils.cs
- Mono.Xml/SecurityParser.cs
- Mono.Xml/SmallXmlParser.cs
- Mono.Cecil.Signatures/SignatureReader.cs
- Mono.Cecil.Binary/ImageReader.cs
- cecil.build
- Implement support for compiling on the CompactFramework
-
-2005-11-08 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/GenericInstanceType.cs
- Mono.Cecil/TypeReference.cs:
- Fix a regression with 2.0 assemblies.
-
-2005-11-03 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/CallSite.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/ICallSite.cs
- Mono.Cecil.Cil/CodeReader.cs
- Mono.Cecil.Cil/CodeWriter.cs
- Mono.Cecil.Signatures/SignatureReader.cs
- Mono.Cecil.dll.sources:
- Implement support for calli opcodes reading.
-
-2005-11-01 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/FunctionPointerType.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil.Signatures/SignatureReader.cs:
- Work on function pointers.
-
- * Mono.Cecil/AssemblyInfo.cs:
- Increase Cecil SVN version.
-
- * Mono.Cecil/ArrayType.cs
- Mono.Cecil/MethodSpecification.cs
- Mono.Cecil/TypeSpecification.cs
- Mono.Cecil/IMethodSpecification.cs
- Mono.Cecil/GenericInstanceType.cs
- Mono.Cecil/IGenericInstanceType.cs
- Mono.Cecil/GenericInstanceMethod.cs
- Mono.Cecil/IModifierType.cs
- Mono.Cecil/IPinnedType.cs
- Mono.Cecil/ReferenceType.cs
- Mono.Cecil/IGenericInstanceMethod.cs
- Mono.Cecil/PinnedType.cs
- Mono.Cecil/PointerType.cs
- Mono.Cecil/IPointerType.cs
- Mono.Cecil/IReferenceType.cs
- Mono.Cecil/IArrayType.cs
- Mono.Cecil/ITypeSpecification.cs
- Mono.Cecil/Modifiers.cs
- Mono.Cecil.dll.sources:
- Uniformize the specification model.
-
-2005-10-31 Jb Evain <jbevain@gmail.com>
-
- * AUTHORS,
- NEWS,
- README,
- TODO,
- Mono.Cecil/AssemblyInfo.cs:
- Cecil 0.1 release.
-
- * Mono.Cecil/ReflectionReader.cs:
- Force value type property on known core types.
-
-2005-10-28 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/TypeReference.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/TypeDefinition.cs
- Mono.Cecil/ModuleDefinition.cs
- Mono.Cecil/ReflectionWriter.cs:
- Uniformize the API.
-
- * Mono.Cecil.Signatures/SignatureWriter.cs:
- Correct a bug in strings encoding in custom attributes.
-
- * CodeGen/templates/ImageWriter.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil/StructureWriter.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil.Binary/ImageWriter.cs:
- Implement a big of public key management,
- here we reserve space for the strong name
- signature if needed.
-
- * Mono.Cecil/StructureWriter.cs
- Mono.Cecil/StructureReader.cs:
- Disable public key writing until
- it is implemented.
-
- * Mono.Cecil/GenericParameter.cs
- Mono.Cecil/TypeReference.cs
- Mono.Cecil/MethodReference.cs:
- Work on generics writing api.
- * Mono.Cecil/ReflectionReader.cs:
- Fix a bug when defining a fresh assembly.
-
- * Mono.Cecil/GenericInstanceType.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil/IGenericParameterProvider.cs
- Mono.Cecil.Signatures/Var.cs
- Mono.Cecil.Signatures/MVar.cs
- Mono.Cecil.Signatures/SignatureReader.cs
- Mono.Cecil.Signatures/SignatureWriter.cs
- Mono.Cecil.Cil/CodeWriter.cs:
- Work on generics writing.
-
-2005-10-27 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Cil/CodeReader.cs
- Mono.Cecil.Cil/CilWorker.cs
- Mono.Cecil.Cil/CodeWriter.cs
- Mono.Cecil.Cil/OpCode.cs:
- Override op == and != on opcodes.
-
- * Mono.Cecil/FieldDefinition.cs
- Mono.Cecil/TypeDefinition.cs
- Mono.Cecil/MethodDefinition.cs
- Mono.Cecil/EventDefinition.cs
- Mono.Cecil/PropertyDefinition.cs:
- Fix setters working on attributes.
-
- * Mono.Cecil.Cil/CodeWriter.cs:
- Compute max stack before writing method.
-
- * Mono.Cecil/GenericContext.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil.Signatures/SignatureReader.cs:
- Work on generics support.
-
- * CodeGen/cecil.xml
- Mono.Cecil/ISecurityDeclarationCollection.cs
- Mono.Cecil/SecurityDeclarationCollection.cs:
- Remove the security declaration from the codegen.
-
-2005-10-27 Sebastien Pouliot <sebastien@ximian.com>
-
- * Mono.Cecil\SecurityDeclaration.cs
- Copy the permission set when cloning.
- * Mono.Cecil\SecurityDeclarationCollection.cs
- Ajusted to use an Hashtable, to Union permission sets on
- the same action and to set/unset HasSecurity when needed.
- * Mono.Cecil\ModuleDefinition.cs:
- Added TODO (remainder) for complete 2.0 format support.
- * Mono.Cecil\ReflectionWriter.cs:
- Move MetadataToken finding outside the loop.
- * Mono.Cecil\ISecurityDeclarationCollection.cs:
- Adjust interface.
-
-2005-10-27 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/TypeDefinition.cs
- Mono.Cecil/MethodDefinition.cs:
- Add generics parameters in visitor path.
-
- * Mono.Cecil/GenericParamAttributes.cs:
- Add new constraints flags.
-
-2005-10-22 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/GenericParameter.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/IGenericParameter.cs
- Mono.Cecil/AggressiveReflectionReader.cs
- Mono.Cecil/GenericContext.cs:
- Support generic parameters constraints.
-
-2005-10-21 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/FieldDefinition.cs
- Mono.Cecil/CustomAttribute.cs
- Mono.Cecil/TypeDefinition.cs
- Mono.Cecil/SecurityDeclaration.cs
- Mono.Cecil/MethodDefinition.cs
- Mono.Cecil/EventDefinition.cs
- Mono.Cecil/ParameterDefinition.cs
- Mono.Cecil/PropertyDefinition.cs:
- Implement ICloneable.
-
- * Mono.Cecil/IAssemblyDefinition.cs:
- Mirror changes on asm kind.
- * Mono.Cecil/StructureReader.cs:
- Fix asm kind detection.
-
- * Mono.Cecil/StructureWriter.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/MethodDefinition.cs
- Mono.Cecil/ReflectionWriter.cs:
- Fix regressions.
- * Mono.Cecil.Cil/MethodBody.cs:
- Fix method cloning.
-
- * CodeGen/templates/MetadataTableReader.cs
- Mono.Cecil.Metadata/MetadataTableReader.cs
- Mono.Cecil.Metadata/MetadataReader.cs:
- Add helpers for reading.
-
- * Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/MethodDefinition.cs
- Mono.Cecil/AggressiveReflectionReader.cs
- Mono.Cecil/GenericContext.cs:
- Working on generic parameters reading.
- Still have troubles reading a 2.0 corlib.
-
- * Mono.Cecil/IHasMarshalSpec.cs:
- API fix.
-
- * Mono.Cecil/ParameterDefinition.cs
- Mono.Cecil.Cil/VariableDefinition.cs:
- Override ToString.
-
-2005-10-20 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Cil/CodeReader.cs
- Mono.Cecil.Cil/CodeWriter.cs
- Mono.Cecil.Cil/ICilWorker.cs
- Mono.Cecil.Cil/CilWorker.cs:
- ShortInlineI operands are signed.
- Spotted by Rodrigo B. de Oliveira.
-
- * CodeGen/templates/OpCodes.cs
- Mono.Cecil.Cil/OpCodes.cs:
- Add 2.0 opcodes.
-
- * Mono.Cecil/StructureWriter.cs
- Mono.Cecil/AssemblyDefinition.cs
- Mono.Cecil/AssemblyFactory.cs
- Mono.Cecil/StructureReader.cs
- Mono.Cecil/ReflectionWriter.cs:
- Handle the assembly kind in a smoothie way.
-
-2005-10-19 Sebastien Pouliot <sebastien@ximian.com>
-
- * Mono.Cecil/AssemblyDefinition.cs: Added an override for ToString to
- ease debugging.
- * Mono.Cecil/ModuleDefinition.cs: Make SecurityDeclaration works with
- 2.0 assemblies.
- * Mono.Cecil/ReflectionReader.cs: Modified BuildSecurityDeclaration
- to use the new SecurityDeclarationReader (supporting both formats).
- * Mono.Cecil/SecurityAction.cs: Removed actions that were "cutted" out
- of 2.0 final.
- * Mono.Cecil/SecurityDeclarationReader.cs: New. Handle both the 1.x
- and 2.0 formats for reading declarative security.
-
-2005-10-18 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/GenericParameter.cs:
- A little change before the fix.
-
- * Mono.Cecil/ReflectionHelper.cs
- Mono.Cecil/MethodDefinition.cs
- Mono.Cecil.Cil/MethodBody.cs:
- Implement method cloning.
-
- * Mono.Cecil/ModuleReference.cs
- Mono.Cecil/FieldDefinition.cs
- Mono.Cecil/TypeReference.cs
- Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/TypeDefinition.cs
- Mono.Cecil/EventDefinition.cs
- Mono.Cecil/ModuleDefinition.cs
- Mono.Cecil/FieldReference.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil/PropertyDefinition.cs
- Mono.Cecil/AssemblyFactory.cs:
- Small API change.
-
- * Mono.Cecil.Cil/CodeReader.cs:
- Fix variables names.
-
- TODO before 0.1:
- Fix generic parameters,
- generic writing,
- constructor changes (with S.Type and SR.*Info)
-
-2005-10-14 Jb Evain <jbevain@gmail.com>
-
- Work on generics support.
-
- * CodeGen/cecil.xml: new collections, coded indexes, opcodes.
-
- * Mono.Cecil/IGenericParameterCollection.cs
- Mono.Cecil/GenericParameterCollection.cs
- Mono.Cecil/IGenericArgumentCollection.cs
- Mono.Cecil/GenericArgumentCollection.cs:
- Added new collections.
-
- * Mono.Cecil.Metadata/Utilities.cs: updated.
- * Mono.Cecil.Metadata/TokenType.cs: added MethodSpec.
-
- * Mono.Cecil/IGenericParameter.cs
- Mono.Cecil/GenericParameter.cs
- Mono.Cecil/IGenericParameterConstraints.cs
- Mono.Cecil/GenericParameterConstraints.cs
- Mono.Cecil/IGenericParameterProvider.cs
- Mono.Cecil/IGenericInstance.cs
- Mono.Cecil/IGenericInstanceType.cs
- Mono.Cecil/GenericInstanceType.cs
- Mono.Cecil/IGenericInstanceMethod.cs
- Mono.Cecil/GenericInstanceMethod.cs:
- Generics API elements.
-
- * Mono.Cecil/IMethod.cs
- Mono.Cecil/MethodReference.cs
- Mono.Cecil/ITypeReference.cs
- Mono.Cecil/TypeReference.cs:
- Implement IGenericParameterProvider
-
- * Mono.Cecil/ReflectionReader.cs
- Mono.Cecil/IReflectionVisitor.cs
- Mono.Cecil/BaseReflectionVisitor.cs
- Mono.Cecil/StructureReader.cs
- Mono.Cecil/AggressiveReflectionReader.cs
- Mono.Cecil/MemberReference.cs:
- Support for the new generics elements.
-
- * Mono.Cecil.Signatures/Var.cs
- Mono.Cecil.Signatures/MVar.cs
- Mono.Cecil.Signatures/GenericInstSignature.cs
- Mono.Cecil.Signatures/GenericInst.cs:
- Added file header.
-
- * Mono.Cecil.Signatures/SignatureReader.cs
- Mono.Cecil.Signatures/GenericInstSignature.cs
- Mono.Cecil.Signatures/MethodDefSig.cs
- Mono.Cecil.Signatures/GenericInst.cs
- Mono.Cecil.Signatures/MethodSpec.cs
- Mono.Cecil/MethodCallingConvention.cs
- Mono.Cecil.Cil/CodeReader.cs:
- Added support for generic signatures.
-
- * Mono.Cecil.Cil/OpCodes.cs:
- Add consrained. opcode.
-
- * Mono.Cecil.dll.sources:
- Updated.
-
- Known problems: !!parameters
-
-2005-10-13 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionHelper.cs
- Mono.Cecil/FieldDefinition.cs
- Mono.Cecil/CustomAttribute.cs
- Mono.Cecil/MethodReturnType.cs
- Mono.Cecil/TypeDefinition.cs
- Mono.Cecil/SecurityDeclaration.cs
- Mono.Cecil/MethodDefinition.cs
- Mono.Cecil/EventDefinition.cs
- Mono.Cecil/ModuleDefinition.cs
- Mono.Cecil/ParameterDefinition.cs
- Mono.Cecil/IMethodReturnType.cs
- Mono.Cecil/PropertyDefinition.cs
- Mono.Cecil.Cil/MethodBody.cs:
- Work on the import.
- * Mono.Cecil/ITypeParameterType.cs
- Mono.Cecil/TypeParameterType.cs:
- Correct the interface.
-
-2005-10-12 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/EventDefinition.cs
- Mono.Cecil/TypeDefinition.cs
- Mono.Cecil/ModuleDefinition.cs
- Mono.Cecil/ReflectionWriter.cs
- Mono.Cecil/PropertyDefinition.cs:
- Small fixes.
-
-2005-09-16 Martin Baulig <martin@ximian.com>
-
- Added generics support to Cecil.
-
- * Mono.Cecil/IGenericInstType.cs: New file.
- * Mono.Cecil/ITypeParameterType.cs: New file.
- * Mono.Cecil/IMethodTypeParameterType.cs: New file.
-
- * Mono.Cecil.Metadata/ElementType.cs
- (ElementType): Added `Var', `MVar' and `GenericInst'.
-
- * Mono.Cecil.Metadata/Utilities.cs
- (Utilities.GetMetadataToken): .NET 2.0 also uses TypeDef's in the
- MemberRefParent.
-
- * Mono.Cecil/GenericInstType.cs: New file.
- * Mono.Cecil/MethodTypeParameterType.cs: New file.
- * Mono.Cecil/TypeParameterType.cs: New file.
-
- * Mono.Cecil.Signatures/Var.cs: New file.
- * Mono.Cecil.Signatures/MVar.cs: New file.
- * Mono.Cecil.Signatures/GenericInst.cs: New file.
- * Mono.Cecil.Signatures/GenericInstSignature.cs: New file.
-
- * Mono.Cecil/ReflectionReader.cs
- (ReflectionReader.GetTypeRefFromSig): Add the new types.
-
- * Mono.Cecil.Signatures/SignatureReader.cs
- (SignatureReader.ReadType): Add the new types.
-
-2005-10-06 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ReflectionHelper.cs
- Mono.Cecil/ModuleDefinition.cs:
- Fix a bug in type importing.
-
-2005-10-06 Jb Evain <jbevain@gmail.com>
-
- * Hopefully, this is the last API change before the release of Cecil 0.1.
- Mono.Cecil.Implem has been moved to Mono.Cecil. The interfaces where
- very convenient for a reading API, it was far less convenient for a
- modification and writing one. The modification API still needs some work,
- but this should be easier this way.
-
-2005-09-27 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Metadata/MetadataReader.cs:
- Fix resources reading.
-
- * Mono.Cecil.Implem/StructureWriter.cs:
- Correctly set the offset of resources in the manifest.
- * Mono.Cecil.Implem/StructureFactories.cs:
- Use correct overrides when creating assembly references.
- * Mono.Cecil.Implem/ReflectionFactories:
- Correctly create type references.
-
-2005-09-06 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/IReflectionFactories.cs
- Mono.Cecil.Implem/ReflectionFactories.cs:
- Allow the creation of reference types for methods
- parameters and return types.
- * Mono.Cecil.Cil/ICilWorker.cs
- Mono.Cecil.Implem/CilWorker.cs
- Mono.Cecil.Implem/CodeReader.cs
- Mono.Cecil.Implem/CodeWriter.cs:
- Global fix on the handling of parameters in instructions.
- * Mono.Cecil.Implem/AssemblyName.cs:
- Correcty write the version of an assembly fullname.
- Spotted by Bruno Cabral.
- * Mono.Cecil.Implem/TypeDefinition.cs:
- Set the declaring type of a nested type on add.
- * Mono.Cecil.Implem/CustomAttribute.cs
- Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/AggressiveReflectionReader.cs
- Mono.Cecil.Signatures/CustomAttrib.cs
- Mono.Cecil.Signatures/SignatureReader.cs:
- Global fix on custom attribute handling. Some
- custom attribute (containing enums) blobs can not be
- decoded.
-
-2005-09-04 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Implem/Instruction.cs:
- Add the setter for IInstruction::OpCode.
-
-2005-09-02 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ICustomAttribute.cs
- Mono.Cecil.Implem/ReflectionFactories.cs
- Mono.Cecil.Implem/CustomAttribute.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- Prepare the work on custom attributes.
- * Mono.Cecil.Cil/IInstruction.cs:
- Let users modify the content of an instruction.
- * Mono.Cecil.Implem/StructureReader.cs:
- Do not try to read 2.0 assemblies.
-
-2005-08-28 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Metadata/MetadataWriter.cs:
- Write the fields initial value back.
- As of this revision, a round tripped mcs
- can compile Cecil.
-
- * Mono.Cecil.Implem/ReflectionWriter.cs:
- Emit things in proper order.
- Mono.Cecil.Implem/CodeReader.cs
- Mono.Cecil.Implem/CodeWriter.cs:
- Correct bug with InlineVar opcodes.
- Emit fat body if maxstack is set.
-
- * Mono.Cecil.Implem/CodeWriter.cs:
- Handle null tokens.
- Mono.Cecil.Metadata/MetadataWriter.cs:
- Allow one empty string in the userstring heap.
-
- * Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/ReflectionWriter.cs:
- Strings constant are unicode.
-
- * Mono.Cecil/LoadingType.cs
- Mono.Cecil/AssemblyFactory.cs
- CodeGen/templates/IndexedCollectionImplem.cs
- CodeGen/templates/LzIndexedCollectionImplem.cs
- CodeGen/cecil.xml
- Mono.Cecil.Implem/InterfaceCollection.cs
- Mono.Cecil.Implem/ILazyLoadable.cs
- Mono.Cecil.Implem/ExternTypeCollection.cs
- Mono.Cecil.Implem/SecurityDeclarationCollection.cs
- Mono.Cecil.Implem/ReflectionHelper.cs
- Mono.Cecil.Implem/OverrideCollection.cs
- Mono.Cecil.Implem/EventDefinitionCollection.cs
- Mono.Cecil.Implem/FieldDefinitionCollection.cs
- Mono.Cecil.Implem/PropertyDefinitionCollection.cs
- Mono.Cecil.Implem/CustomAttributeCollection.cs
- Mono.Cecil.Implem/MethodDefinition.cs
- Mono.Cecil.Implem/EventDefinition.cs
- Mono.Cecil.Implem/FieldDefinition.cs
- Mono.Cecil.Implem/ModuleDefinition.cs
- Mono.Cecil.Implem/ReflectionController.cs
- Mono.Cecil.Implem/TypeReference.cs
- Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/AssemblyDefinition.cs
- Mono.Cecil.Implem/TypeDefinition.cs
- Mono.Cecil.Implem/AggressiveReflectionReader.cs
- Mono.Cecil.Implem/MethodDefinitionCollection.cs
- Mono.Cecil.Implem/LazyReflectionReader.cs
- Mono.Cecil.Implem/ParameterDefinition.cs
- Mono.Cecil.Implem/PropertyDefinition.cs
- Mono.Cecil.Implem/ConstructorCollection.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- Get rid of the complexity introduced by the
- internal lazy loading.
-
- * Mono.Cecil.Implem/EventDefinition.cs
- Mono.Cecil.Implem/PropertyDefinition.cs:
- Fix the behavior of .ToString ().
-
-2005-08-27 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Implem/ReflectionWriter.cs:
- Write back custom attributes of modules and assemblies
- as well as their security declaration.
- * Mono.Cecil.Implem/CodeWriter.cs:
- Fix branches computation.
- Mono.Cecil.Signatures/SignatureReader.cs:
- Disable custom attribute reading cache.
-
- * CodeGen/templates/ImageWriter.cs
- Mono.Cecil.Binary/ImageWriter.cs:
- Compute relocations.
- * Mono.Cecil.Implem/ReflectionFactories.cs:
- Blah.
-
- * Mono.Cecil.Implem/TablesComparer.cs
- Mono.Cecil.Implem/ReflectionWriter.cs:
- Sort all tables that need to be sorted.
-
- * Mono.Cecil.Implem/CodeReader.cs:
- Oops. Add fat exception handlers to the method body.
-
- * CodeGen/templates/ImageWriter.cs
- Mono.Cecil.Implem/StructureWriter.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/TypeDefinition.cs
- Mono.Cecil.Binary/ImageWriter.cs:
- Correct a few bugs: relocations now works.
- Encode enums in custom attributes.
- Compute memberrefs tokens before visitings types.
-
- * Mono.Cecil.Implem/FieldDefinition.cs:
- Correct a bug that causes null ref due to
- the new api.
- * Mono.Cecil.Signatures/SignatureWriter.cs:
- Implement a very little more custom attributes
- writing.
-
-2005-08-26 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/IMemberReferenceCollection.cs
- Mono.Cecil/IReflectionVisitor.cs
- Mono.Cecil/IReflectionFactories.cs
- Mono.Cecil/BaseReflectionVisitor.cs
- Mono.Cecil/IModuleDefinition.cs
- CodeGen/cecil.xml
- Mono.Cecil.Implem/ReflectionFactories.cs
- Mono.Cecil.Implem/ReflectionHelper.cs
- Mono.Cecil.Implem/ModuleDefinition.cs
- Mono.Cecil.Implem/MemberReferenceCollection.cs
- Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/ParameterDefinition.cs:
- Handle member references nicely.
-
- * Mono.Cecil/ICustomAttributeProvider.cs
- Mono.Cecil/IModuleDefinitionCollection.cs
- Mono.Cecil/IReflectionStructureFactories.cs
- Mono.Cecil/IInterfaceCollection.cs
- Mono.Cecil/IMethod.cs
- Mono.Cecil/IReflectionFactories.cs
- Mono.Cecil/INestedTypeCollection.cs
- Mono.Cecil/ITypeReferenceCollection.cs
- Mono.Cecil/IExternTypeCollection.cs
- Mono.Cecil/IAssemblyDefinition.cs
- Mono.Cecil/ITypeDefinition.cs
- Mono.Cecil/ICustomAttribute.cs
- Mono.Cecil/IArrayDimensionCollection.cs
- Mono.Cecil/TypeFactory.cs
- Mono.Cecil/IConstructorCollection.cs
- Mono.Cecil/IHasSecurity.cs
- Mono.Cecil/IMethodDefinitionCollection.cs
- Mono.Cecil/IPropertyDefinitionCollection.cs
- Mono.Cecil/IAssemblyNameReferenceCollection.cs
- Mono.Cecil/IModuleReferenceCollection.cs
- Mono.Cecil/IArrayType.cs
- Mono.Cecil/ISecurityDeclarationCollection.cs
- Mono.Cecil/IModuleDefinition.cs
- Mono.Cecil/IResourceCollection.cs
- Mono.Cecil/IParameterDefinitionCollection.cs
- Mono.Cecil/IEventDefinitionCollection.cs
- Mono.Cecil/ITypeDefinitionCollection.cs
- Mono.Cecil/IFieldDefinitionCollection.cs
- Mono.Cecil/ICustomAttributeCollection.cs
- Mono.Cecil/ISecurityDeclaration.cs
- Mono.Cecil/IOverrideCollection.cs
- Mono.Cecil/ITypeReference.cs
- Mono.Cecil.Cil/IExceptionHandlerCollection.cs
- Mono.Cecil.Cil/IVariableDefinitionCollection.cs
- Mono.Cecil.Cil/IInstructionCollection.cs
- Mono.Cecil.Cil/IMethodBody.cs
- CodeGen/cecil-gen-types.rb
- CodeGen/templates/ImageWriter.cs
- CodeGen/templates/IndexedCollectionImplem.cs
- CodeGen/templates/NamedCollectionImplem.cs
- CodeGen/templates/IIndexedCollection.cs
- CodeGen/templates/LzIndexedCollectionImplem.cs
- CodeGen/templates/INamedCollection.cs
- CodeGen/templates/LzNamedCollectionImplem.cs
- Mono.Cecil.Implem/InterfaceCollection.cs
- Mono.Cecil.Implem/AssemblyLinkedResource.cs
- Mono.Cecil.Implem/ModuleReferenceCollection.cs
- Mono.Cecil.Implem/ExternTypeCollection.cs
- Mono.Cecil.Implem/SecurityDeclarationCollection.cs
- Mono.Cecil.Implem/ReflectionFactories.cs
- Mono.Cecil.Implem/ReflectionHelper.cs
- Mono.Cecil.Implem/OverrideCollection.cs
- Mono.Cecil.Implem/ArrayDimensionCollection.cs
- Mono.Cecil.Implem/EmbeddedResource.cs
- Mono.Cecil.Implem/CilWorker.cs
- Mono.Cecil.Implem/ParameterDefinitionCollection.cs
- Mono.Cecil.Implem/EventDefinitionCollection.cs
- Mono.Cecil.Implem/FieldDefinitionCollection.cs
- Mono.Cecil.Implem/PropertyDefinitionCollection.cs
- Mono.Cecil.Implem/ModuleDefinitionCollection.cs
- Mono.Cecil.Implem/CustomAttributeCollection.cs
- Mono.Cecil.Implem/VariableDefinitionCollection.cs
- Mono.Cecil.Implem/TypeReferenceCollection.cs
- Mono.Cecil.Implem/MemberDefinition.cs
- Mono.Cecil.Implem/StructureReader.cs
- Mono.Cecil.Implem/FunctionPointerType.cs
- Mono.Cecil.Implem/MethodDefinition.cs
- Mono.Cecil.Implem/EventDefinition.cs
- Mono.Cecil.Implem/FieldDefinition.cs
- Mono.Cecil.Implem/InstructionCollection.cs
- Mono.Cecil.Implem/VariableDefinition.cs
- Mono.Cecil.Implem/CustomAttribute.cs
- Mono.Cecil.Implem/ModuleDefinition.cs
- Mono.Cecil.Implem/MethodReference.cs
- Mono.Cecil.Implem/TypeReference.cs
- Mono.Cecil.Implem/StructureFactories.cs
- Mono.Cecil.Implem/TypeDefinitionCollection.cs
- Mono.Cecil.Implem/AssemblyNameReferenceCollection.cs
- Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/MethodReturnType.cs
- Mono.Cecil.Implem/MemberReference.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/Resource.cs
- Mono.Cecil.Implem/AssemblyDefinition.cs
- Mono.Cecil.Implem/TypeDefinition.cs
- Mono.Cecil.Implem/AggressiveReflectionReader.cs
- Mono.Cecil.Implem/CodeReader.cs
- Mono.Cecil.Implem/FieldReference.cs
- Mono.Cecil.Implem/MethodDefinitionCollection.cs
- Mono.Cecil.Implem/LazyReflectionReader.cs
- Mono.Cecil.Implem/LinkedResource.cs
- Mono.Cecil.Implem/ParameterDefinition.cs
- Mono.Cecil.Implem/PropertyDefinition.cs
- Mono.Cecil.Implem/MethodBody.cs
- Mono.Cecil.Implem/NestedTypeCollection.cs
- Mono.Cecil.Implem/ConstructorCollection.cs
- Mono.Cecil.Implem/ResourceCollection.cs
- Mono.Cecil.Implem/ExceptionHandlerCollection.cs
- Mono.Cecil.Binary/ImageWriter.cs
- Mono.Cecil.Binary/ImageReader.cs:
- Fix the writing API before the API freeze. Few things
- are not implemented, see todos.
-
-2005-08-20 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ITypeDefinition.cs
- Mono.Cecil/IModuleDefinition.cs
- Mono.Cecil/ITypeReference.cs
- Mono.Cecil.Implem/ReflectionHelper.cs
- Mono.Cecil.Implem/ModuleDefinition.cs
- Mono.Cecil.Implem/TypeReference.cs
- Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/TypeDefinition.cs:
- Add way to know if a type reference is a
- value type or not. This hack saved my life.
-
- * Mono.Cecil.Implem/CodeWriter.cs:
- Fix typespec emitting.
-
- * Mono.Cecil/IReflectionVisitor.cs
- Mono.Cecil/IMethod.cs
- Mono.Cecil/BaseReflectionVisitor.cs
- Mono.Cecil/ITypeDefinition.cs
- Mono.Cecil/IConstructorCollection.cs
- CodeGen/cecil.xml
- Mono.Cecil.Implem/MethodDefinition.cs
- Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/TypeDefinition.cs
- Mono.Cecil.Implem/ConstructorCollection.cs:
- Support constructors decently.
-
- * CodeGen/templates/Utilities.cs
- Mono.Cecil.Metadata/Utilities.cs:
- Return a null token if the rid of a md token
- is 0. Fix the crash when Mono try to read
- assemblies emitted by Cecil.
-
-2005-08-19 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Implem/ReflectionWriter.cs:
- Set the RVA of a method only if it can
- have a body.
- * Mono.Cecil.Signatures/SignatureReader.cs:
- Remove debugging stuff.
-
- * Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Signatures/SignatureReader.cs:
- Fix custom marshaller reading.
-
- * CodeGen/templates/NamedCollectionImplem.cs
- CodeGen/templates/LzNamedCollectionImplem.cs
- Mono.Cecil.Implem/ExternTypeCollection.cs
- Mono.Cecil.Implem/TypeReferenceCollection.cs
- Mono.Cecil.Implem/TypeDefinitionCollection.cs
- Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/TablesComparer.cs
- Mono.Cecil.Implem/Constants.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- Correct bugs in type* tables generations.
-
- * Mono.Cecil/IModuleDefinitionCollection.cs
- Mono.Cecil/IInterfaceCollection.cs
- Mono.Cecil/INestedTypeCollection.cs
- Mono.Cecil/ITypeReferenceCollection.cs
- Mono.Cecil/IExternTypeCollection.cs
- Mono.Cecil/IArrayDimensionCollection.cs
- Mono.Cecil/IMethodDefinitionCollection.cs
- Mono.Cecil/IPropertyDefinitionCollection.cs
- Mono.Cecil/IAssemblyNameReferenceCollection.cs
- Mono.Cecil/IModuleReferenceCollection.cs
- Mono.Cecil/ISecurityDeclarationCollection.cs
- Mono.Cecil/IResourceCollection.cs
- Mono.Cecil/IParameterDefinitionCollection.cs
- Mono.Cecil/IEventDefinitionCollection.cs
- Mono.Cecil/ITypeDefinitionCollection.cs
- Mono.Cecil/IFieldDefinitionCollection.cs
- Mono.Cecil/ICustomAttributeCollection.cs
- Mono.Cecil/IOverrideCollection.cs
- Mono.Cecil.Cil/IExceptionHandlerCollection.cs
- Mono.Cecil.Cil/IVariableDefinitionCollection.cs
- Mono.Cecil.Cil/IInstructionCollection.cs
- CodeGen/templates/IIndexedCollection.cs
- CodeGen/templates/INamedCollection.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Binary/SubSystem.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- On going change to the writing api. Not setter allowed on
- collections. Work on custom attribute encoding. Remove
- the Flags on Subsystem.
-
- * Mono.Cecil.dll.sources
- Mono.Cecil.Implem/ReflectionHelper.cs
- Mono.Cecil.Implem/TypeReference.cs
- Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/TypeDefinition.cs
- Mono.Cecil.Implem/TablesComparer.cs
- Mono.Cecil.Signatures/SignatureReader.cs:
- Fix the build.
- Stop to prefix typeref by the scope.
- Cecil will have buggy behaviour if it have to handle
- two typeref with the same namespace+name, but for the
- moment, let it like that.
-
- * Mono.Cecil/INestedTypeCollection.cs
- Mono.Cecil/IModuleReference.cs
- Mono.Cecil/ITypeReferenceCollection.cs
- Mono.Cecil/IAssemblyName.cs
- Mono.Cecil/IExternTypeCollection.cs
- Mono.Cecil/IMetadataScope.cs
- Mono.Cecil/IModuleDefinition.cs
- Mono.Cecil/IResourceCollection.cs
- Mono.Cecil/ITypeDefinitionCollection.cs
- CodeGen/templates/NamedCollectionImplem.cs
- CodeGen/templates/INamedCollection.cs
- CodeGen/templates/LzNamedCollectionImplem.cs
- CodeGen/cecil.xml
- Mono.Cecil.Metadata/RowCollection.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Metadata/MetadataToken.cs
- Mono.Cecil.Implem/TablesComparer.cs
- Mono.Cecil.Implem/ExternTypeCollection.cs
- Mono.Cecil.Implem/ReflectionHelper.cs
- Mono.Cecil.Implem/TypeReferenceCollection.cs
- Mono.Cecil.Implem/StructureReader.cs
- Mono.Cecil.Implem/StructureWriter.cs
- Mono.Cecil.Implem/ModuleDefinition.cs
- Mono.Cecil.Implem/TypeReference.cs
- Mono.Cecil.Implem/TypeDefinitionCollection.cs
- Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/TypeDefinition.cs
- Mono.Cecil.Implem/CodeReader.cs
- Mono.Cecil.Implem/CodeWriter.cs
- Mono.Cecil.Implem/Constants.cs
- Mono.Cecil.Implem/NestedTypeCollection.cs
- Mono.Cecil.Implem/ResourceCollection.cs
- Mono.Cecil.Signatures/SignatureReader.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- Correct some part of the API.
- Correct tons of bugs in the writing layer.
-
-2005-08-17 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/IField.cs
- CodeGen/cecil.xml
- Mono.Cecil.Metadata/MetadataReader.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Implem/ReflectionHelper.cs
- Mono.Cecil.Implem/StructureReader.cs
- Mono.Cecil.Implem/FieldDefinition.cs
- Mono.Cecil.Implem/BaseReflectionReader.cs
- Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/TypeDefinition.cs
- Mono.Cecil.Implem/AggressiveReflectionReader.cs
- Mono.Cecil.Implem/CodeReader.cs
- Mono.Cecil.Implem/IDetailReader.cs
- Mono.Cecil.Implem/CodeWriter.cs
- Mono.Cecil.Implem/LazyReflectionReader.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- Work on the working layer. Implement field initial
- data. Bugs.
-
-2005-08-16 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/CodeWriter.cs
- Mono.Cecil.Signatures/SignatureReader.cs:
- Implement local var sig writing.
-
- * Mono.Cecil.Implem/ArrayType.cs:
- Style.
- Mono.Cecil.Implem/ParameterDefinition.cs:
- Correct a bug in module obtention.
- Mono.Cecil.Signatures/SignatureReader.cs:
- Correct a bug in arrays's signature reading.
-
- * Mono.Cecil.dll.sources
- Mono.Cecil/IReflectionVisitor.cs
- Mono.Cecil/IModuleDefinitionCollection.cs
- Mono.Cecil/IInterfaceCollection.cs
- Mono.Cecil/IProperty.cs
- Mono.Cecil/BaseReflectionVisitor.cs
- Mono.Cecil/INestedTypeCollection.cs
- Mono.Cecil/ITypeReferenceCollection.cs
- Mono.Cecil/IParameter.cs
- Mono.Cecil/IExternTypeCollection.cs
- Mono.Cecil/IField.cs
- Mono.Cecil/IArrayDimensionCollection.cs
- Mono.Cecil/IMethodDefinitionCollection.cs
- Mono.Cecil/IPropertyDefinitionCollection.cs
- Mono.Cecil/IAssemblyNameReferenceCollection.cs
- Mono.Cecil/IModuleReferenceCollection.cs
- Mono.Cecil/IHasConstant.cs
- Mono.Cecil/ISecurityDeclarationCollection.cs
- Mono.Cecil/IMetadataTokenProvider.cs
- Mono.Cecil/IModuleDefinition.cs
- Mono.Cecil/BaseStructureVisitor.cs
- Mono.Cecil/IResourceCollection.cs
- Mono.Cecil/IParameterDefinitionCollection.cs
- Mono.Cecil/IEventDefinitionCollection.cs
- Mono.Cecil/ITypeDefinitionCollection.cs
- Mono.Cecil/IFieldDefinitionCollection.cs
- Mono.Cecil/ICustomAttributeCollection.cs
- Mono.Cecil/IOverrideCollection.cs
- Mono.Cecil.Cil/IExceptionHandlerCollection.cs
- Mono.Cecil.Cil/IVariableDefinitionCollection.cs
- Mono.Cecil.Cil/IInstructionCollection.cs
- CodeGen/cecil-gen.rb
- CodeGen/cecil-gen-types.rb
- CodeGen/templates/IndexedCollectionImplem.cs
- CodeGen/templates/NamedCollectionImplem.cs
- CodeGen/templates/IIndexedCollection.cs
- CodeGen/templates/LzIndexedCollectionImplem.cs
- CodeGen/templates/INamedCollection.cs
- CodeGen/templates/LzNamedCollectionImplem.cs
- CodeGen/cecil.xml
- Mono.Cecil.Metadata/MetadataRowWriter.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Implem/InterfaceCollection.cs
- Mono.Cecil.Implem/ModuleReferenceCollection.cs
- Mono.Cecil.Implem/ExternTypeCollection.cs
- Mono.Cecil.Implem/SecurityDeclarationCollection.cs
- Mono.Cecil.Implem/OverrideCollection.cs
- Mono.Cecil.Implem/ParameterDefinitionCollection.cs
- Mono.Cecil.Implem/EventDefinitionCollection.cs
- Mono.Cecil.Implem/FieldDefinitionCollection.cs
- Mono.Cecil.Implem/PropertyDefinitionCollection.cs
- Mono.Cecil.Implem/ModuleDefinitionCollection.cs
- Mono.Cecil.Implem/CustomAttributeCollection.cs
- Mono.Cecil.Implem/VariableDefinitionCollection.cs
- Mono.Cecil.Implem/TypeReferenceCollection.cs
- Mono.Cecil.Implem/StructureReader.cs
- Mono.Cecil.Implem/MethodDefinition.cs
- Mono.Cecil.Implem/EventDefinition.cs
- Mono.Cecil.Implem/FieldDefinition.cs
- Mono.Cecil.Implem/InstructionCollection.cs
- Mono.Cecil.Implem/StructureWriter.cs
- Mono.Cecil.Implem/ModuleDefinition.cs
- Mono.Cecil.Implem/MethodReference.cs
- Mono.Cecil.Implem/TypeReference.cs
- Mono.Cecil.Implem/TypeDefinitionCollection.cs
- Mono.Cecil.Implem/AssemblyNameReferenceCollection.cs
- Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/MethodReturnType.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/AssemblyDefinition.cs
- Mono.Cecil.Implem/TypeDefinition.cs
- Mono.Cecil.Implem/AggressiveReflectionReader.cs
- Mono.Cecil.Implem/MethodDefinitionCollection.cs
- Mono.Cecil.Implem/CodeWriter.cs
- Mono.Cecil.Implem/LazyReflectionReader.cs
- Mono.Cecil.Implem/ParameterDefinition.cs
- Mono.Cecil.Implem/PropertyDefinition.cs
- Mono.Cecil.Implem/NestedTypeCollection.cs
- Mono.Cecil.Implem/ResourceCollection.cs
- Mono.Cecil.Implem/ExceptionHandlerCollection.cs
- Mono.Cecil.Signatures/SignatureReader.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- Working on the writing layer.
- Begin to fix brokens part of the API.
-
-2005-08-15 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/ITypeDefinition.cs
- CodeGen/templates/MetadataTableReader.cs
- CodeGen/templates/PEFileHeader.cs
- CodeGen/templates/ImageWriter.cs
- CodeGen/templates/CLIHeader.cs
- CodeGen/templates/PEOptionalHeader.cs
- CodeGen/templates/MetadataTableWriter.cs
- CodeGen/templates/Table.cs
- CodeGen/templates/MetadataRowReader.cs
- CodeGen/templates/BaseMetadataVisitor.cs
- CodeGen/templates/Section.cs
- CodeGen/templates/MetadataRowWriter.cs
- CodeGen/templates/ImageReader.cs
- CodeGen/templates/IMetadataVisitor.cs
- Mono.Cecil.Metadata/Assembly.cs
- Mono.Cecil.Metadata/PropertyMap.cs
- Mono.Cecil.Metadata/InterfaceImpl.cs
- Mono.Cecil.Metadata/MetadataInitializer.cs
- Mono.Cecil.Metadata/Constant.cs
- Mono.Cecil.Metadata/MethodSpec.cs
- Mono.Cecil.Metadata/BaseMetadataVisitor.cs
- Mono.Cecil.Metadata/DeclSecurity.cs
- Mono.Cecil.Metadata/TypeDef.cs
- Mono.Cecil.Metadata/MethodImpl.cs
- Mono.Cecil.Metadata/GenericParamConstraint.cs
- Mono.Cecil.Metadata/NestedClass.cs
- Mono.Cecil.Metadata/MetadataTableReader.cs
- Mono.Cecil.Metadata/AssemblyRefProcessor.cs
- Mono.Cecil.Metadata/AssemblyRef.cs
- Mono.Cecil.Metadata/AssemblyRefOS.cs
- Mono.Cecil.Metadata/Method.cs
- Mono.Cecil.Metadata/RowCollection.cs
- Mono.Cecil.Metadata/MetadataTableWriter.cs
- Mono.Cecil.Metadata/StringsHeap.cs
- Mono.Cecil.Metadata/MetadataRowReader.cs
- Mono.Cecil.Metadata/ExportedType.cs
- Mono.Cecil.Metadata/CustomAttribute.cs
- Mono.Cecil.Metadata/Param.cs
- Mono.Cecil.Metadata/MetadataReader.cs
- Mono.Cecil.Metadata/ClassLayout.cs
- Mono.Cecil.Metadata/MetadataRowWriter.cs
- Mono.Cecil.Metadata/BlobHeap.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Metadata/AssemblyOS.cs
- Mono.Cecil.Metadata/ModuleRef.cs
- Mono.Cecil.Metadata/MetadataRoot.cs
- Mono.Cecil.Metadata/UserStringsHeap.cs
- Mono.Cecil.Metadata/FieldMarshal.cs
- Mono.Cecil.Metadata/GenericParam.cs
- Mono.Cecil.Metadata/ImplMap.cs
- Mono.Cecil.Metadata/TableCollection.cs
- Mono.Cecil.Metadata/TablesHeap.cs
- Mono.Cecil.Metadata/MetadataStreamCollection.cs
- Mono.Cecil.Metadata/ManifestResource.cs
- Mono.Cecil.Metadata/TypeRef.cs
- Mono.Cecil.Metadata/AssemblyProcessor.cs
- Mono.Cecil.Metadata/EventMap.cs
- Mono.Cecil.Metadata/File.cs
- Mono.Cecil.Metadata/Event.cs
- Mono.Cecil.Metadata/FieldLayout.cs
- Mono.Cecil.Metadata/Field.cs
- Mono.Cecil.Metadata/Property.cs
- Mono.Cecil.Metadata/Module.cs
- Mono.Cecil.Metadata/GuidHeap.cs
- Mono.Cecil.Metadata/MethodSemantics.cs
- Mono.Cecil.Metadata/StandAloneSig.cs
- Mono.Cecil.Metadata/MetadataStream.cs
- Mono.Cecil.Metadata/FieldRVA.cs
- Mono.Cecil.Metadata/TypeSpec.cs
- Mono.Cecil.Metadata/MemberRef.cs
- Mono.Cecil.Metadata/IMetadataVisitor.cs
- Mono.Cecil.Implem/TypeDefinition.cs
- Mono.Cecil.Signatures/MethodRefSig.cs
- Mono.Cecil.Signatures/SignatureReader.cs
- Mono.Cecil.Signatures/FieldSig.cs
- Mono.Cecil.Signatures/PropertySig.cs
- Mono.Cecil.Signatures/ISignatureVisitor.cs
- Mono.Cecil.Signatures/SignatureWriter.cs
- Mono.Cecil.Signatures/MethodDefSig.cs
- Mono.Cecil.Signatures/LocalVarSig.cs
- Mono.Cecil.Binary/PEFileHeader.cs
- Mono.Cecil.Binary/IBinaryVisitor.cs
- Mono.Cecil.Binary/ImageWriter.cs
- Mono.Cecil.Binary/CLIHeader.cs
- Mono.Cecil.Binary/SectionCollection.cs
- Mono.Cecil.Binary/Image.cs
- Mono.Cecil.Binary/PEOptionalHeader.cs
- Mono.Cecil.Binary/ImageInitializer.cs
- Mono.Cecil.Binary/Imports.cs
- Mono.Cecil.Binary/BaseImageVisitor.cs
- Mono.Cecil.Binary/DOSHeader.cs
- Mono.Cecil.Binary/Section.cs
- Mono.Cecil.Binary/ImageReader.cs:
- Apply the new visitor model to the rest of Cecil.
-
- * Mono.Cecil/IReflectionVisitor.cs
- Mono.Cecil/BaseReflectionVisitor.cs
- Mono.Cecil/IReflectionStructureVisitor.cs
- Mono.Cecil/BaseStructureVisitor.cs
- Mono.Cecil.Cil/BaseCodeVisitor.cs
- Mono.Cecil.Cil/ICodeVisitor.cs
- CodeGen/cecil-gen.rb
- CodeGen/cecil-gen-types.rb
- CodeGen/templates/IndexedCollectionImplem.cs
- CodeGen/templates/NamedCollectionImplem.cs
- CodeGen/templates/LzIndexedCollectionImplem.cs
- CodeGen/templates/LzNamedCollectionImplem.cs
- CodeGen/cecil.xml
- Mono.Cecil.Implem/InterfaceCollection.cs
- Mono.Cecil.Implem/AssemblyLinkedResource.cs
- Mono.Cecil.Implem/ModuleReferenceCollection.cs
- Mono.Cecil.Implem/AssemblyName.cs
- Mono.Cecil.Implem/Instruction.cs
- Mono.Cecil.Implem/ExternTypeCollection.cs
- Mono.Cecil.Implem/MarshalDesc.cs
- Mono.Cecil.Implem/SecurityDeclarationCollection.cs
- Mono.Cecil.Implem/OverrideCollection.cs
- Mono.Cecil.Implem/ExceptionHandler.cs
- Mono.Cecil.Implem/EmbeddedResource.cs
- Mono.Cecil.Implem/ModuleReference.cs
- Mono.Cecil.Implem/ParameterDefinitionCollection.cs
- Mono.Cecil.Implem/EventDefinitionCollection.cs
- Mono.Cecil.Implem/FieldDefinitionCollection.cs
- Mono.Cecil.Implem/PropertyDefinitionCollection.cs
- Mono.Cecil.Implem/ModuleDefinitionCollection.cs
- Mono.Cecil.Implem/CustomAttributeCollection.cs
- Mono.Cecil.Implem/VariableDefinitionCollection.cs
- Mono.Cecil.Implem/TypeReferenceCollection.cs
- Mono.Cecil.Implem/StructureReader.cs
- Mono.Cecil.Implem/MethodDefinition.cs
- Mono.Cecil.Implem/EventDefinition.cs
- Mono.Cecil.Implem/FieldDefinition.cs
- Mono.Cecil.Implem/InstructionCollection.cs
- Mono.Cecil.Implem/StructureWriter.cs
- Mono.Cecil.Implem/ModuleDefinition.cs
- Mono.Cecil.Implem/CustomAttribute.cs
- Mono.Cecil.Implem/VariableDefinition.cs
- Mono.Cecil.Implem/TypeReference.cs
- Mono.Cecil.Implem/TypeDefinitionCollection.cs
- Mono.Cecil.Implem/AssemblyNameReferenceCollection.cs
- Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/PInvokeInfo.cs
- Mono.Cecil.Implem/AssemblyDefinition.cs
- Mono.Cecil.Implem/TypeDefinition.cs
- Mono.Cecil.Implem/CodeReader.cs
- Mono.Cecil.Implem/AggressiveReflectionReader.cs
- Mono.Cecil.Implem/MethodDefinitionCollection.cs
- Mono.Cecil.Implem/CodeWriter.cs
- Mono.Cecil.Implem/SecurityDeclaration.cs
- Mono.Cecil.Implem/LazyReflectionReader.cs
- Mono.Cecil.Implem/LinkedResource.cs
- Mono.Cecil.Implem/ParameterDefinition.cs
- Mono.Cecil.Implem/PropertyDefinition.cs
- Mono.Cecil.Implem/MethodBody.cs
- Mono.Cecil.Implem/NestedTypeCollection.cs
- Mono.Cecil.Implem/ResourceCollection.cs
- Mono.Cecil.Implem/ExceptionHandlerCollection.cs:
- BIG changes in the visitor object model. Last one
- was causing ambiguous calls, and does not provides
- differences between an interface and a typedef for
- instance. This is corrected by suffixing the visit
- method by the name of what it is visiting, and by
- configuring some collection to stop the propagation
- of the visitor.
-
- * Mono.Cecil/ITypeDefinition.cs
- Mono.Cecil/IArrayType.cs
- CodeGen/templates/Utilities.cs
- Mono.Cecil.Metadata/Utilities.cs
- Mono.Cecil.Implem/ArrayType.cs
- Mono.Cecil.Implem/TypeReference.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/TypeDefinition.cs
- Mono.Cecil.Implem/CodeWriter.cs
- Mono.Cecil.Implem/Constants.cs
- Mono.Cecil.Signatures/MarshalSig.cs:
- Work on the writing layer goes on.
-
-2005-08-14 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/NativeType.cs
- Mono.Cecil.Signatures/MarshalSig.cs
- Mono.Cecil.Signatures/SignatureWriter.cs
- Mono.Cecil.Signatures/Signature.cs:
- Work on signature writing.
- Mono.Cecil.Implem/MethodDefinition.cs
- Mono.Cecil.Implem/TypeDefinition.cs:
- Correct bugs in setting the hasThis field.
-
- * CodeGen/templates/ImageWriter.cs
- Mono.Cecil.Binary/templates/ImageWriter.cs
- Mono.Cecil/AssemblyKind.cs:
- Make assemblies executable on win32.
- Mono.Cecil.Implem/TypeDefinition.cs:
- Mark new fields as loaded.
- Mono.Cecil.Implem/ReflectionWriter.cs:
- Correct the style to patch provided by
- Sebastien Ros <s.ros@evaluant.com>
-
-2005-08-13 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/IMethod.cs
- Mono.Cecil/ITypeDefinition.cs
- Mono.Cecil/IModuleDefinition.cs
- Mono.Cecil.Cil/OpCode.cs
- Mono.Cecil.Cil/ICilWorker.cs
- CodeGen/templates/ImageReader.cs
- Mono.Cecil.Metadata/MetadataReader.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Metadata/MetadataRoot.cs
- Mono.Cecil.Implem/ReflectionHelper.cs
- Mono.Cecil.Implem/CilWorker.cs
- Mono.Cecil.Implem/StructureReader.cs
- Mono.Cecil.Implem/MethodDefinition.cs
- Mono.Cecil.Implem/StructureWriter.cs
- Mono.Cecil.Implem/ModuleDefinition.cs
- Mono.Cecil.Implem/MethodReference.cs
- Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/TypeDefinition.cs
- Mono.Cecil.Implem/CodeReader.cs
- Mono.Cecil.Implem/CodeWriter.cs
- Mono.Cecil.Implem/Constants.cs
- Mono.Cecil.Implem/ParameterDefinition.cs
- Mono.Cecil.Implem/MethodBody.cs
- Mono.Cecil.Binary/ImageReader.cs
- Mono.Cecil.Binary/MemoryBinaryWriter.cs
- Mono.Cecil.Signatures/SignatureReader.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- On going work on the writing layer.
-
- * Mono.Cecil.Signatures/SignatureReader.cs:
- Fix a bug when reading chars inside a custom
- attribute signature.
-
-2005-08-12 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/AssemblyFactory.cs
- CodeGen/templates/ImageWriter.cs
- CodeGen/templates/MetadataTableWriter.cs
- CodeGen/templates/MetadataRowWriter.cs
- Mono.Cecil.Metadata/MetadataTableWriter.cs
- Mono.Cecil.Metadata/MetadataRowWriter.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Implem/StructureWriter.cs
- Mono.Cecil.Binary/ImageWriter.cs
- Mono.Cecil.Binary/MemoryBinaryWriter.cs:
- Use a custom binary writer instead of the old one.
-
- * Mono.Cecil/IMethod.cs
- Mono.Cecil.Cil/BaseCodeVisitor.cs
- Mono.Cecil.Cil/MethodHeader.cs
- Mono.Cecil.Cil/ICodeVisitor.cs
- Mono.Cecil.Implem/Instruction.cs
- Mono.Cecil.Implem/MethodDefinition.cs
- Mono.Cecil.Implem/FieldDefinition.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/CodeReader.cs
- Mono.Cecil.Implem/CodeWriter.cs
- Mono.Cecil.Implem/MethodBody.cs:
- Ongoing work on the writing layer.
-
- * CodeGen/templates/Utilities.cs
- CodeGen/templates/NamedCollectionImplem.cs
- CodeGen/templates/MetadataRowWriter.cs
- CodeGen/templates/LzNamedCollectionImplem.cs
- CodeGen/cecil.xml
- Mono.Cecil/IMethod.cs
- Mono.Cecil/IAssemblyName.cs
- Mono.Cecil/IModuleDefinition.cs
- Mono.Cecil/AssemblyFactory.cs
- Mono.Cecil.Metadata/MetadataRowWriter.cs
- Mono.Cecil.Metadata/Utilities.cs
- Mono.Cecil.Implem/ReflectionHelper.cs
- Mono.Cecil.Implem/StructureReader.cs
- Mono.Cecil.Implem/MethodDefinition.cs
- Mono.Cecil.Implem/EventDefinition.cs
- Mono.Cecil.Implem/FieldDefinition.cs
- Mono.Cecil.Implem/StructureWriter.cs
- Mono.Cecil.Implem/ModuleDefinition.cs
- Mono.Cecil.Implem/MethodReference.cs
- Mono.Cecil.Implem/TypeDefinitionCollection.cs
- Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/TypeDefinition.cs
- Mono.Cecil.Implem/AggressiveReflectionReader.cs
- Mono.Cecil.Implem/Constants.cs
- Mono.Cecil.Implem/ParameterDefinition.cs
- Mono.Cecil.Implem/PropertyDefinition.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- Ongoing work on the writing layer.
- Some fixes to the reading layer as well.
-
-2005-08-11 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Signatures/SignatureReader.cs:
- Read Array signatures correctly.
-
- * Mono.Cecil/IMethodSignature.cs:
- Remove the setted for the return type.
- * Mono.Cecil.Implem/CilWorker.cs:
- Fix the build. Me idiot!
- * Mono.Cecil.Implem/Constants.cs:
- Remove unexisting type Variant.
- * Mono.Cecil.Implem/ReflectionHelper.cs:
- Complete the helper.
-
-2005-08-10 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Cil/IMethodBody.cs
- Mono.Cecil.Cil/ICilEmitter.cs
- Mono.Cecil.Cil/ICilWorker.cs
- Mono.Cecil.Implem/CilWorker.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/MethodBody.cs
- Mono.Cecil.Implem/CilEmitter.cs
- Mono.Cecil.Signatures/SignatureReader.cs
- Mono.Cecil.Signatures/SignatureWriter.cs:
- Prepare the api for the cil emitting.
-
- * CodeGen/templates/Utilities.cs
- CodeGen/templates/MetadataRowReader.cs
- CodeGen/templates/MetadataRowWriter.cs
- Mono.Cecil.Metadata/Utilities.cs
- Mono.Cecil.Metadata/MetadataRowReader.cs
- Mono.Cecil.Metadata/MetadataRowWriter.cs:
- Fix the build on .net, i was using a sugar
- syntax for delegates that csc does not understand.
- Remove the coded index cache from the static class
- Utilities, and add one per row visitor.
-
- * Mono.Cecil/IMethodReturnType.cs
- Mono.Cecil.Implem/MethodReturnType.cs
- Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/ParameterDefinition.cs:
- Make IMethodReturn type inherits IHasMarshalSpec so
- that users can read marshaling info for return types,
- and implement it.
-
- * CodeGen/templates/ImageWriter.cs
- Mono.Cecil.Binary/ImageWriter.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Implem/ReflectionWriter.cs:
- Cecil now emits assemblies understood by the .net clr.
-
-2005-08-09 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/AssemblyKind.cs
- CodeGen/templates/ImageWriter.cs
- CodeGen/templates/ImageReader.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Binary/ImageWriter.cs
- Mono.Cecil.Binary/ImageInitializer.cs
- Mono.Cecil.Binary/ImageReader.cs:
- Lots of little fixes. Now dumpbin is coherent
- compared with an assembly emitted with csc or mcs
- but still not yet compatible with .net.
-
- * Mono.Cecil.Signatures/SignatureReader.cs:
- Fix an array out of range while trying to read
- fixed arrays signatures
-
- * CodeGen/templates/ImageWriter.cs
- Mono.Cecil.Metadata/MetadataReader.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Implem/AssemblyName.cs
- Mono.Cecil.Implem/StructureReader.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Binary/ImageCharacteristics.cs
- Mono.Cecil.Binary/ImageWriter.cs
- Mono.Cecil.Binary/Image.cs:
- Cecil now emits assemblies that are understood
- by Mono and Cecil itself. Still have troubles
- with Msft CLR.
-
-2005-08-08 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/cecil-gen.rb
- CodeGen/templates/MetadataTableReader.cs
- CodeGen/templates/ImageWriter.cs
- CodeGen/templates/MetadataTableWriter.cs
- CodeGen/templates/BaseMetadataVisitor.cs
- CodeGen/templates/MetadataRowReader.cs
- CodeGen/templates/MetadataRowWriter.cs
- CodeGen/cecil.xml
- Mono.Cecil.Metadata/MetadataInitializer.cs
- Mono.Cecil.Metadata/BaseMetadataVisitor.cs
- Mono.Cecil.Metadata/MetadataTableReader.cs
- Mono.Cecil.Metadata/MetadataTableWriter.cs
- Mono.Cecil.Metadata/MetadataRowReader.cs
- Mono.Cecil.Metadata/MetadataRowWriter.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Binary/ImageWriter.cs
- Mono.Cecil.Binary/CLIHeader.cs
- Mono.Cecil.Binary/ImageInitializer.cs:
- The writing layer almost works.
-
- * Mono.Cecil/AssemblyKind.cs
- Mono.Cecil/TargetRuntime.cs
- Mono.Cecil.dll.sources:
- Add thoses enumes to control assembly writing.
- * Mono.Cecil/AssemblyFactory.cs
- Mono.Cecil/IReflectionVisitor.cs
- Mono.Cecil/BaseReflectionVisitor.cs
- Mono.Cecil/IAssemblyDefinition.cs
- Mono.Cecil/IReflectionStructureVisitor.cs
- Mono.Cecil/BaseStructureVisitor.cs
- CodeGen/templates/ImageWriter.cs
- CodeGen/templates/MetadataTableWriter.cs
- CodeGen/templates/MetadataRowWriter.cs
- CodeGen/templates/LzNamedCollectionImplem.cs
- Mono.Cecil.Metadata/MetadataInitializer.cs
- Mono.Cecil.Metadata/MetadataTableWriter.cs
- Mono.Cecil.Metadata/MetadataRowWriter.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Metadata/MetadataStreamCollection.cs
- Mono.Cecil.Implem/AssemblyName.cs
- Mono.Cecil.Implem/StructureWriter.cs
- Mono.Cecil.Implem/ModuleDefinition.cs
- Mono.Cecil.Implem/TypeDefinitionCollection.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/AssemblyDefinition.cs
- Mono.Cecil.Binary/ImageWriter.cs
- Mono.Cecil.Binary/ImageInitializer.cs
- Mono.Cecil.Binary/Imports.cs:
- Things are now plugged. SaveAssembly will now emits
- a binary file. A broken file, but heh, at least it does.
-
-2005-08-07 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/templates/ImageReader.cs
- CodeGen/templates/ImageWriter.cs
- CodeGen/templates/IMetadataVisitor.cs
- Mono.Cecil.Binary/ImageReader.cs
- Mono.Cecil.Binary/ImageWriter.cs
- Mono.Cecil.Metadata/IMetadataVisitor.cs
- Mono.Cecil.Metadata/BaseMetadataVisitor.cs
- Mono.Cecil.Metadata/MetadataReader.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Metadata/MetadataStreamCollection.cs:
- Simplify IMetadataVisitor.
- Work on the writing layer, closer to have something testable
- than ever.
-
- * CodeGen/cecil.xml
- CodeGen/templates/ImageWriter.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Binary/PEOptionalHeader.cs
- Mono.Cecil.Binary/ImageWriter.cs
- Mono.Cecil.Binary/Imports.cs:
- don't stop don't stop come ON!
-
- * CodeGen/templates/ImageWriter.cs
- CodeGen/templates/ImageReader.cs
- CodeGen/templates/Section.cs
- Mono.Cecil.Binary/Image.cs
- Mono.Cecil.Binary/ImageReader.cs
- Mono.Cecil.Binary/ImageInitializer.cs
- Mono.Cecil.Binary/ImageWriter.cs
- Mono.Cecil.Binary/Section.cs
- Mono.Cecil.Metadata/MetadataReader.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Implem/StructureReader.cs
- Mono.Cecil.Implem/StructureWriter.cs
- Mono.Cecil.Implem/CodeWriter.cs:
- Some writing layer love.
-
- * CodeGen/templates/ImageWriter.cs
- CodeGen/templates/ImageReader.cs
- Mono.Cecil.Binary/Imports.cs
- Mono.Cecil.Binary/ImageReader.cs
- Mono.Cecil.Binary/ImageInitializer.cs
- Mono.Cecil.Binary/ImageWriter.cs:
- Read an write correctly the Hint/Name table
- at the end of the .text section.
-
- * CodeGen/templates/ImageWriter.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Binary/ImageWriter.cs
- Mono.Cecil.Binary/ImageInitializer.cs:
- More writing layer stuff.
-
-2005-08-06 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/templates/ImageWriter.cs
- CodeGen/templates/MetadataTableWriter.cs
- Mono.Cecil.Metadata/MetadataInitializer.cs
- Mono.Cecil.Metadata/MetadataTableWriter.cs
- Mono.Cecil.Metadata/StringsHeap.cs
- Mono.Cecil.Metadata/BlobHeap.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Metadata/UserStringsHeap.cs
- Mono.Cecil.Metadata/TableCollection.cs
- Mono.Cecil.Metadata/TablesHeap.cs
- Mono.Cecil.Metadata/MetadataHeap.cs
- Mono.Cecil.Metadata/GuidHeap.cs
- Mono.Cecil.Metadata/MetadataStream.cs
- Mono.Cecil.Implem/StructureWriter.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/CodeWriter.cs
- Mono.Cecil.Binary/ImageWriter.cs
- Mono.Cecil.Binary/ImageInitializer.cs:
- Playing lego with bricks from the writing layer.
-
- * Mono.Cecil.dll.sources:
- Updated.
- * CodeGen/templates/CLIHeader.cs
- CodeGen/templates/PEOptionalHeader.cs
- Blah.
- * CodeGen/cecil.xml
- Mono.Cecil.Binary/CLIHeader.cs
- Mono.Cecil.Binary/PEOptionalHeader.cs:
- Mono.Cecil.Binary/PEFileHeader.cs
- On going work on the writing layer
-
- * CodeGen/templates/ImageWriter.cs
- CodeGen/templates/ImageReader.cs
- Mono.Cecil.Binary/BaseImageVisitor.cs
- Mono.Cecil.Binary/ImageReader.cs
- Mono.Cecil.Binary/ImageInitializer.cs
- Mono.Cecil.Binary/ImageWriter.cs
- Mono.Cecil.Metadata/BaseMetadataVisitor.cs
- Mono.Cecil.Metadata/MetadataReader.cs
- Mono.Cecil.Metadata/MetadataInitializer.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Metadata/MetadataStream.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/CodeWriter.cs:
- Add helpers visitor.
- On going work on the writing layer.
-
- * CodeGen/templates/Utilities.cs
- CodeGen/templates/MetadataRowReader.cs
- CodeGen/templates/MetadataRowWriter.cs
- Mono.Cecil.Metadata/StringsHeap.cs
- Mono.Cecil.Metadata/MetadataRowReader.cs
- Mono.Cecil.Metadata/MetadataRowWriter.cs
- Mono.Cecil.Metadata/MetadataReader.cs
- Mono.Cecil.Metadata/Utilities.cs
- Mono.Cecil.Metadata/BlobHeap.cs
- Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Metadata/MetadataHeap.cd
- Mono.Cecil.Metadata/GuidHeap.cs:
- On going work on the writing layer.
-
- * CodeGen/templates/MetadataTableWriter.cs
- Mono.Cecil.Metadata/MetadataTableWriter.cs
- Mono.Cecil.Metadata/MetadataWriter.cs:
- On going work on the writing layer.
- * Mono.Cecil.Implem/StructureWriter.cs:
- Correctly override methods
- * CodeGen/templates/MetadataRowWriter.cs
- Mono.Cecil.Metadata/MetadataRowWriter.cs
- Mono.Cecil.Implem/ReflectionWriter.cs:
- Fix build warnings.
-
- * Mono.Cecil/IResource.cs
- Mono.Cecil.Implem/AssemblyLinkedResource.cs
- Mono.Cecil.Implem/EmbeddedResource.cs
- Mono.Cecil.Implem/LinkedResource.cs
- Mono.Cecil.Implem/Resource.cs:
- Rename field Attributes to Flags for the sake of consistency.
- * Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Implem/ReflectionWriter.cs
- Mono.Cecil.Implem/StructureWriter.cs:
- On going work on the writing layer.
- * Mono.Cecil.Implem/StructureReader.cs:
- Style.
-
- * Mono.Cecil/IAssemblyName.cs
- Mono.Cecil.Implem/AssemblyName.cs
- Mono.Cecil.Implem/StructureReader.cs:
- Add an AssemblyFlag property to an IAssemblyNameReference,
- implement it, and read it.
-
-2005-08-04 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Implem/ReflectionReader.cs:
- set a correct name to nameless parameters
-
- * Mono.Cecil.Signatures/SignatureReader.cs:
- don't crash on null custom attributes
-
-2005-08-03 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/templates/OpCodes.cs
- Mono.Cecil.Cil/OpCodes.cs
- Mono.Cecil.Cil/OpCode.cs:
- Revert modifications to reduce code. OpCodes::.ctors were
- not called.
-
- * Mono.Cecil.Implem/ReflectionReader.cs:
- Make sure parameters are read even if there is no
- corresponding Param row. Thanks Cesar for the hint.
-
- * Mono.Cecil.Metadata/MetadataWriter.cs
- Mono.Cecil.Metadata/UserStringsHeap.cs
- Mono.Cecil.Metadata/GuidHeap.cs
- Mono.Cecil.Implem/CodeReader.cs:
- On going work on the writing layer
-
- * CodeGen/cecil-gen.rb
- CodeGen/cecil-gen-sources.rb
- make executable
- * *.*: set svn:eol-style to native
-
- * Mono.Cecil/BaseStructureVisitor.cs
- Mono.Cecil/BaseReflectionVisitor.cs
- Mono.Cecil.Implem/BaseReflectionReader.cs:
- Add empty visitors for the sake of simplicity
- * Mono.Cecil.Implem/StructureReader.cs
- Mono.Cecil.Implem/ReflectionReader.cs:
- Inherit new visitors
-
-2005-08-03 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/AggressiveReflectionReader.cs
- Mono.Cecil.Implem/LazyReflectionReader.cs
- Mono.Cecil.Implem/CodeReader.cs:
- Modify and add helpers to avoid lots of casts.
- Correct a bug in custom attributes attribution.
-
-2005-08-02 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Signatures/TypeSpec.cs:
- Don't restrain the SigType
- * Mono.Cecil.Implem/AggressiveReflectionReader.cs:
- Set PInvokeInfos on the correct method
-
-2005-07-30 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/cecil-gen.rb
- CodeGen/cecil-gen-sources.rb:
- make them executable
- * CodeGen/cecil-gen-types: style
- * CodeGen/templates/ImageWriter.cs
- Mono.Cecil.Binary/ImageWriter.cs:
- Prelimimary work on assembly writing
-
-2005-07-29 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/cecil-gen-types.rb
- CodeGen/templates/MetadataTableWriter.cs
- CodeGen/templates/MetadataRowWriter.cs
- Mono.Cecil/AssemblyFactory.cs
- Mono.Cecil.Metadata/MetadataTableWriter.cs
- Mono.Cecil.Metadata/MetadataRowWriter.cs
- Mono.Cecil.Implem/StructureWriter.cs
- Mono.Cecil.Implem/ReflectionWriter.cs:
- Preliminary work on assembly writing
-
-2005-07-28 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/AssemblyFactory.cs
- Mono.Cecil.Implem/StructureWriter.cs
- Preliminary work on assembly writing
-
- * Mono.Cecil/IMetadataTokenProvider.cs
- Mono.Cecil/IMember.cs
- Mono.Cecil/IParameter.cs:
- Add a MetadataToken property on searchable items
- * Mono.Cecil.Metadata/MetadataToken.cs:
- Add a factory method to create token from row number
- * Mono.Cecil.Implem/TypeReference.cs
- Mono.Cecil.Implem/MemberReference.cs
- Mono.Cecil.Implem/ParameterDefinition.cs:
- Implement the token property
- * Mono.Cecil.Implem/ReflectionReader.cs
- Mono.Cecil.Implem/AggressiveReflectionReader.cs
- Mono.Cecil.Implem/LazyReflectionReader.cs:
- Set the token property on reading
- * Mono.Cecil/IModuleDefinition.cs
- Mono.Cecil.Implem/ModuleDefinition.cs
- Mono.Cecil.Implem/ReflectionReader.cs:
- Add methods to lookup items from their tokens
-
-2005-07-27 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/templates/OpCodes.cs
- Mono.Cecil.Cil/OpCodes.cs
- Mono.Cecil.Cil/OpCode.cs:
- Changes to reduce the size of the cache ctor
-
-2005-07-22 Raja R Harinath <rharinath@novell.com>
-
- * Makefile (MCS): Allow compiler to be overriden.
-
-2005-07-21 Todd Berman <tberman@off.net>
-
- * configure: Add a small stub configure (stolen from mcs) to set the
- prefix.
- * mono-cecil.pc.in: Add a mono-cecil.pc.in to allow for installation
- according to the new "Libraries with Unstable API" Wiki documentation.
- * Makefile: Add an install an a mono-cecil.pc target to allow for
- installation and creation of the pc file.
-
-2005-07-14 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/templates/ImageReader.cs
- Mono.Cecil.Binary/IBinaryVisitor.cs
- Mono.Cecil.Binary/Image.cs
- Mono.Cecil.Binary/ImageInitializer.cs
- Mono.Cecil.Binary/Imports.cs
- Mono.Cecil.Binary/ImageReader.cs:
- Read Imports Tables
-
-2005-07-14 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/cecil-gen.rb:
- make codegen works on ruby 1.8.2
- * CodeGen/templates/*.cs
- Mono.Cecil.Metadata/*.cs:
- style
-
-2005-07-13 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Implem/VariableDefinition.cs:
- set the index field
-
-2005-07-13 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.dll.sources: regenerated
- * Mono.Cecil.Signatures/SignatureReader.cs:
- Fix compilation warnings
- * Mono.Cecil/IArrayType.cs
- Mono.Cecil.Implem/ArrayType.cs:
- Add Rank helper property
- * Mono.Cecil/ITypeDefinition.cs
- Mono.Cecil.Implem/TypeDefinition.cs:
- Add Constructors helper property
-
-2005-07-11 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/IMethod.cs
- Mono.Cecil.Implem/Instruction.cs
- Mono.Cecil.Implem/ExceptionHandler.cs
- Mono.Cecil.Implem/MethodDefinition.cs
- Mono.Cecil.Implem/Label.cs
- Mono.Cecil.Implem/CodeReader.cs
- Mono.Cecil.Implem/MethodBody.cs
- Mono.Cecil.Implem/CilEmitter.cs
- Mono.Cecil.Cil/ILabel.cs
- Mono.Cecil.Cil/IInstruction.cs
- Mono.Cecil.Cil/IExceptionHandler.cs
- Mono.Cecil.Cil/IMethodBody.cs
- Mono.Cecil.Cil/ICilEmitter.cs:
- Preliminary changes on the instruction model before
- changing of latptop
-
-2005-07-08 Jb Evain <jbevain@gmail.com>
-
- * Every generated files: use \n instead of \r\n
-
-2005-07-07 Jb Evain <jbevain@gmail.com>
-
- * *.*: use Mono coding conventions
- * Mono.Xml/*.*: update Mono.Xml from corlib
- * Mono.Cecil.Metadata/CultureUtils.cs:
- Ensure that Cecil works under Mono
-
-2005-07-02 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil/IMethod.cs
- Mono.Cecil/IProperty.cs
- Mono.Cecil/IEvent.cs
- Mono.Cecil/IField.cs
- Mono.Cecil/ITypeDefinition.cs
- Mono.Cecil.Implem/MethodDefinition.cs
- Mono.Cecil.Implem/PropertyDefinition.cs
- Mono.Cecil.Implem/EventDefinition.cs
- Mono.Cecil.Implem/FieldDefinition.cs
- Mono.Cecil.Implem/TypeDefinition.cs:
- Add some funky sugar attributes,
- more to come
-
-2005-07-01 Jb Evain <jbevain@gmail.com>
-
- * CodeGen/cecil-gen.rb,
- CodeGen/templates/MetadataTableWriter.cs,
- CodeGen/templates/MetadataRowWriter.cs,
- Mono.Cecil.Metadata/MetadataTableWriter.cs,
- Mono.Cecil.Metadata/MetadataRowWriter.cs,
- Mono.Cecil.Metadata/MetadataWriter.cs:
- Add metadata writing visitors
- * Mono.Cecil.Metadata/CultureUtils.cs:
- Be sure to use every possible culture infos.
- * Mono.Cecil.Cil/IVariable.cs,
- Mono.Cecil.Implem/VariableDefinition.cs,
- Mono.Cecil.Implem/CodeReader.cs,
- Mono.Cecil.Implem/CilEmitter.cs:
- Add an index property to local variables
- * Mono.Cecil.Metadata/MetadataReader.cs,
- Mono.Cecil.Metadata/MetadataRowReader.cs,
- CodeGen/templates/MetadataRowReader.cs,
- Mono.Cecil.Metadata/TablesHeap.cs:
- Handles null heaps
- * Mono.Cecil.Implem/StructureWriter.cs,
- Mono.Cecil.Implem/ReflectionController.cs,
- Mono.Cecil.Implem/ReflectionWriter.cs:
- Assemble writing classes
-
-2005-06-28 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Implem/ReflectionReader.cs: style
- * Mono.Cecil.Implem/LazyReflectionReader.cs:
- read the last property as well.
-
-2005-06-21 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Implem/ReflectionReader.cs: Correct a bug that prevents
- assemblies to be readed if they have an entrypoint. Suggestion by
- Mario Sopena
- * Mono.Cecil.Implem/CodeReader.cs: Use sbyte not to lose negatives
- offsets. Suggestion by Vladislav Spivak
- * CodeGen/cecil.xml,
- Mono.Cecil.Cil/OpCodes.cs,
- Mono.Cecil.Cil/StackBehaviour.cs: Add an PopAll enumeration value
- for StackBehaviour, and set the StackBehaviourPop property for
- leave and leave.s opcodes to it. Suggested by Vladislav Spivak
-
-2005-06-12 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.Implem/TypeDefinition.cs: Set the declaring type
- to this when defining a nested type.
-
-2005-06-07 Jb Evain <jbevain@gmail.com>
-
- * Mono.Cecil.dll.sources,
- * CodeGen/cecil.xml,
- * Mono.Cecil/IReflectionVisitor.cs,
- * Mono.Cecil/INestedTypeCollection.cs,
- * Mono.Cecil/ITypeDefinition,
- * Mono.Cecil.Implem/ReflectionReader.cs,
- * Mono.Cecil.Implem/ReflectionWriter.cs,
- * Mono.Cecil.Implem/TypeDefinition.cs,
- * Mono.Cecil.Implem/NestedTypeCollection:
- Add a collection of nested types for type definition
-
- * Mono.Cecil.Implem/ModuleDefinition.cs: simplify type creation
-
-2005-06-07 Jb Evain <jbevain@gmail.com>
-
- * ChangeLog: Cecil has now ChangeLogs. Let use them.
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-attributes.rb b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-attributes.rb
deleted file mode 100755
index 4158155..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-attributes.rb
+++ /dev/null
@@ -1,226 +0,0 @@
-#!/usr/bin/env ruby
-
-$providers = []
-
-$mapping = {
- "Assem" => "IsAssembly",
- "FamORAssem" => "IsFamilyOrAssembly",
- "FamANDAssem" => "IsFamilyAndAssembly",
- "NestedFamORAssem" => "IsNestedFamilyOrAssembly",
- "NestedFamANDAssem" => "IsNestedFamilyAndAssembly",
- "RTSpecialName" => "IsRuntimeSpecialName",
- "Compilercontrolled" => "IsCompilerControlled",
- "NotNullableValueTypeConstraint" => "HasNotNullableValueTypeConstraint",
- "ReferenceTypeConstraint" => "HasReferenceTypeConstraint",
- "DefaultConstructorConstraint" => "HasDefaultConstructorConstraint",
- "SupportsLastError" => "SupportsLastError",
- "NoInlining" => "NoInlining",
-}
-
-$black_list = [
- "None", "Unused", "RequireSecObject",
- "HasFieldMarshal", "HasFieldRVA",
- "OPTIL", "MaxMethodImplVal"
-]
-
-class Attribute
-
- attr_accessor(:name)
- attr_accessor(:type)
-
- def initialize(name, type)
- @name = name
- @type = type
- end
-
- def full_name
- "#{@type}.#{@name}"
- end
-
- def to_csharp
-""" public bool #{get_name()} {
-#{getter()}#{setter()} }
-"""
- end
-
- def to_s
- "Attribute #{full_name}"
- end
-
- protected
- def getter
-""" get { return (m_attributes & #{full_name()}) != 0; }
-"""
- end
-
- def setter
-""" set {
- if (value)
- m_attributes |= #{full_name()};
- else
- m_attributes &= ~#{full_name()};
- }
-"""
- end
-
- private
- def get_name
- name = @name
- return $mapping[name] if $mapping.include?(name)
- return name if name.rindex("Has") == 0
- "Is#{name}"
- end
-end
-
-class MaskedAttribute < Attribute
-
- attr_accessor(:mask)
-
- def initialize(name, type, mask)
- super(name, type)
- @mask = mask
- end
-
- def mask_full_name
- "#{@type}.#{@mask}"
- end
-
- def to_s
- "MaskedAttribute #{full_name()}, masked by #{mask_full_name()}"
- end
-
- protected
- def getter
-""" get { return (m_attributes & #{mask_full_name()}) == #{full_name()}; }
-"""
- end
-
- def setter
-""" set {
- if (value) {
- m_attributes &= ~#{mask_full_name()};
- m_attributes |= #{full_name()};
- } else
- m_attributes &= ~(#{mask_full_name()} & #{full_name()});
- }
-"""
- end
-end
-
-class Provider
-
- attr_accessor(:type)
- attr_accessor(:attributes_file)
- attr_accessor(:target_file)
- attr_accessor(:attributes)
-
- def initialize(type, attributes_file, target_file)
- @type = type
- @attributes_file = attributes_file
- @target_file = target_file
- @attributes = []
- end
-
- def parse
- f = File.open(@attributes_file, File::RDONLY)
- have_mask = false
- mask = ""
- f.readlines.each { |line|
- if line.chomp().length == 0
- have_mask = false
- else
- name = get_name(line)
- if not name.nil? and name.index("Mask")
- mask = name
- have_mask = true
- elsif not name.nil?
- attr = nil
- if (have_mask)
- attr = MaskedAttribute.new(name, @type, mask)
- else
- attr = Attribute.new(name, @type)
- end
- @attributes << attr
- end
- end
- }
- f.close
- end
-
- def patch
- buffer = read_target_content()
- buffer = patch_buffer(buffer)
- if buffer != read_target_content()
- puts("#{@target_file} patched")
- write_target_content (buffer)
- end
- end
-
- private
- def patch_buffer(buffer)
- region = "#region " + @type
- endregion = "#endregion"
-
- endpart = buffer[(buffer.index(endregion) - 3)..buffer.length]
-
- rep = buffer[0..(buffer.index(region) + region.length)]
-
- rep += "\n"
-
- @attributes.each { |attr|
- rep += attr.to_csharp
- rep += "\n" if attr != @attributes.last
- }
-
- rep += endpart
-
- rep
- end
-
- def read_target_content
- f = File.new(@target_file, File::RDONLY)
- content = f.readlines.join
- f.close
- content
- end
-
- def write_target_content(content)
- File.open(@target_file, File::WRONLY | File::TRUNC) { |f|
- f.write(content)
- }
- end
-
- def get_name(line)
- pos = line.index("=")
- return nil if not pos
- name = line[0..(pos - 1)].strip
-
- return nil if $black_list.include?(name)
- name
- end
-end
-
-def to_cecil_file(file)
- "../Mono.Cecil/#{file}.cs"
-end
-
-[ "Event", "Field", "Method", "Parameter", "Property", "Type" ].each { |name|
- attributes = "#{name}Attributes"
- definition = "#{name}Definition"
- $providers << Provider.new(attributes, to_cecil_file(attributes), to_cecil_file(definition))
-}
-
-{ "GenericParameter" => "GenericParameter",
- "ManifestResource" => "Resource",
- "PInvoke" => "PInvokeInfo",
-# "MethodImpl" => "MethodDefinition",
-# "MethodSemantics" => "MethodDefinition",
-}.each { |k, v|
- attributes = "#{k}Attributes"
- $providers << Provider.new(attributes, to_cecil_file(attributes), to_cecil_file(v))
-}
-
-$providers.each { |p|
- p.parse
- p.patch
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-sources.rb b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-sources.rb
deleted file mode 100755
index e93b195..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-sources.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env ruby
-
-f = File.new("../Mono.Cecil.dll.sources", File::CREAT | File::WRONLY | File::TRUNC)
-
-[ "Mono.Cecil", "Mono.Cecil.Binary",
- "Mono.Cecil.Metadata", "Mono.Cecil.Cil",
- "Mono.Cecil.Signatures", "Mono.Xml" ].each { |dir|
-
- Dir.foreach("../" + dir) { |file|
- f.print("./#{dir}/#{file}\n") if file[(file.length - 3)..file.length] == ".cs"
- }
-}
-
-f.close
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-tests.rb b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-tests.rb
deleted file mode 100755
index b2ab8ef..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-tests.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'erb'
-
-class Language
-
- attr_reader(:name)
- attr_reader(:compiler)
- attr_reader(:ext)
- attr_reader(:command)
-
- def initialize(name, compiler, ext, command)
- @name = name
- @compiler = compiler
- @ext = ext
- @command = command
- end
-end
-
-class TestCase
-
- attr_reader(:lang)
- attr_reader(:file)
-
- def initialize(lang, file)
- @lang = lang
- @file = file
- end
-
- def method()
- meth = @file.gsub(/[^a-zA-Z1-9]/, "_")
- return meth[1..meth.length] if (meth[0].chr == "_")
- return meth
- end
-end
-
-$languages = [
- Language.new("cil", "ilasm", ".il", "{0} /exe /output:{2} {1}"),
- Language.new("csharp", "mcs", ".cs", "{0} /t:exe /o:{2} {1}")
-]
-
-$tests = [
-]
-
-def analyze(dir)
- $languages.each { |l|
- pattern = File.join(dir, "**", "*" + l.ext)
- Dir[pattern].each { |file|
- $tests.push(TestCase.new(l, File.expand_path(file)))
- }
- }
-end
-
-ARGV.each { |dir|
- analyze(dir)
-}
-
-if $tests.length > 0
- erb = ERB.new(IO.read("./templates/Tests.cs"))
- print(erb.result)
-end
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-types.rb b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-types.rb
deleted file mode 100644
index 2c0e629..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen-types.rb
+++ /dev/null
@@ -1,262 +0,0 @@
-
-# types used in templates
-
-module Cecil
-
- class Evolutive # abstract
-
- attr_reader(:requ)
-
- def initialize(requ)
- @requ = requ
- end
- end
-
- class FieldWorker # abstract
-
- attr_reader(:field_name)
- attr_reader(:property_name)
- attr_reader(:type)
- attr_reader(:ns)
- attr_reader(:size)
- attr_reader(:target)
-
- def initialize(name, type, target)
- @property_name = name
- @target = target
- @field_name = to_field(name)
-
- @objtype = type
-
- ar = type.name.split(".")
- @type = ar.pop()
- @ns = ar.join(".")
-
- @size = type.size
- end
-
- def to_field(name)
- name = String.new(name)
- name[0] = name[0].chr.downcase
- return "m_" + name
- end
-
- def write_binary(inst, writer)
- pre = writer + ".Write ("
- prp = inst + "." + @property_name
- suf = ")"
- return case @type
- when "byte", "ushort", "short", "uint", "int"
- pre + prp + suf
- when "RVA"
- pre + prp + ".Value" + suf
- when "DataDirectory"
- pre + prp + ".VirtualAddress" + suf + ";\n\t\t\t" + pre + prp + ".Size" + suf
- else
- pre + "(" + @objtype.underlying + ") " + prp + suf
- end
- end
-
- def read_binary(inst)
- return case @type
- when "byte"
- inst + ".ReadByte ()"
- when "ushort"
- inst + ".ReadUInt16 ()";
- when "short"
- inst + ".ReadInt16 ()";
- when "uint"
- inst + ".ReadUInt32 ()";
- when "int"
- inst + ".ReadInt32 ()";
- when "RVA"
- "new RVA (" + inst + ".ReadUInt32 ())"
- when "DataDirectory"
- "new DataDirectory (\n new RVA (" + inst + ".ReadUInt32 ()),\n " + inst + ".ReadUInt32 ())"
- else
- "(" + @objtype.name + ") " + case @objtype.underlying
- when "int"
- inst + ".ReadInt32 ()";
- when "short"
- inst + ".ReadInt16 ()";
- when "ushort"
- inst + ".ReadUInt16 ()";
- when "uint"
- inst + ".ReadUInt32 ()";
- end
- end
- end
- end
-
- class Type
-
- attr_reader(:name)
- attr_reader(:size)
- attr_reader(:underlying)
-
- def initialize(name, size, underlying = nil)
- @name = name
- @size = size
- @underlying = underlying
- end
- end
-
- class Table < Evolutive
-
- attr_reader(:ref_ns)
- attr_reader(:rid)
- attr_reader(:name)
- attr_reader(:table_name)
- attr_reader(:row_name)
- attr_reader(:columns)
-
- def initialize(name, rid, requ)
- super(requ)
- @name = name
- @table_name = name + "Table"
- @row_name = name + "Row"
- @rid = rid
- @ref_ns = Array.new
- @columns = Array.new
- end
-
- def add_column(col)
- if (!@ref_ns.include?(col.ns) && col.ns.length != 0 && col.ns != "Mono.Cecil.Metadata") then
- @ref_ns.push(col.ns)
- @ref_ns.sort!()
- end
- @columns.push(col)
- end
-
- def row_size()
- size = 0
- @columns.each { |col|
- size += col.size
- }
- return size
- end
- end
-
- class Column < FieldWorker
-
- def initialize(name, type, target)
- super(name, type, target)
- end
-
- end
-
- class Collection
-
- attr_reader(:type)
- attr_reader(:intf)
- attr_reader(:name)
- attr_reader(:container)
- attr_reader(:container_impl)
- attr_reader(:item_name)
- attr_reader(:visitable)
- attr_reader(:visitor)
- attr_reader(:visitThis)
- attr_reader(:visitItem)
- attr_reader(:lazyload)
- attr_reader(:pathtoloader)
- attr_reader(:target)
- attr_reader(:indexed)
-
- def initialize(type, container, visit, name, lazyload, pathtoloader, target, indexed = false, usecntintf = false)
- @type = type
- basename = (name.nil? ? type : name)
- @intf = "I" + basename + "Collection"
- @name = @intf[1..@intf.length]
- @item_name = basename[0..basename.length]
- @container = container
- @container_impl = usecntintf ? @container : @container[0..@container.length]
- if (!visit.nil?) then
- @visitable = visit + "Visitable"
- @visitor = visit + "Visitor"
- @visitThis = "Visit" + @name
- @visitItem = "Visit" + @item_name
- end
- @lazyload = lazyload
- @pathtoloader = pathtoloader
- @target = target
- @indexed = indexed
- end
- end
-
- class OpCode < Evolutive
-
- attr_reader(:name)
- attr_reader(:field_name)
- attr_reader(:op1)
- attr_reader(:op2)
- attr_reader(:size)
- attr_reader(:flowcontrol)
- attr_reader(:opcodetype)
- attr_reader(:operandtype)
- attr_reader(:stackbehaviourpop)
- attr_reader(:stackbehaviourpush)
-
- def initialize(name, op1, op2, flowcontrol, opcodetype, operandtype, stackbehaviourpop, stackbehaviourpush, requ)
- super(requ)
- @name = name
- @field_name = name_to_prop(name)
- @op1 = op1 ; @op2 = op2
- @size = @op1 == "0xff" ? 1 : 2
- @flowcontrol = "FlowControl." + flowcontrol
- @opcodetype = "OpCodeType." + opcodetype
- @operandtype = "OperandType." + operandtype
- @stackbehaviourpop = "StackBehaviour." + stackbehaviourpop
- @stackbehaviourpush = "StackBehaviour." + stackbehaviourpush
- end
-
- def name_to_prop(name)
- field = ""
- ar = name.split(".")
- ar.each { |part|
- field += part.capitalize()
- field += "_" unless ar.last == part
- }
- return field
- end
- end
-
- class Field < FieldWorker
-
- attr_reader(:default)
-
- def initialize(name, type, default)
- super(name, type, nil)
- @default = default
- end
- end
-
- class CodedIndexTable
-
- attr_reader(:name)
- attr_reader(:tag)
-
- def initialize(name, tag)
- @name = name
- @tag = tag
- end
- end
-
- class CodedIndex < Evolutive
-
- attr_reader(:name)
- attr_reader(:size)
- attr_reader(:tables)
-
- def initialize(name, size, requ)
- super(requ)
- @name = name
- @size = size
- @tables = Array.new
- end
-
- def add_table(name, tag)
- @tables.push(CodedIndexTable.new(name, tag))
- end
- end
-
-end
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen.rb b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen.rb
deleted file mode 100755
index dec7a1f..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-gen.rb
+++ /dev/null
@@ -1,161 +0,0 @@
-#!/usr/bin/env ruby
-# extern libraries used by code generator
-
-require 'erb'
-require 'rexml/document'
-
-# our library
-
-require 'cecil-gen-types'
-
-# time to generate code now
-
-$types = Hash.new
-$tables = Array.new
-$colls = Array.new
-$coded_indexes = Array.new
-$ops = Array.new
-
-doc = REXML::Document.new(File.open("cecil.xml"))
-
-doc.root.each_element("/cecil/types//type") { |node|
- type = Cecil::Type.new(
- node.attribute("name").value,
- node.attribute("size").value.to_i,
- (node.attribute("underlying").nil? ? nil : node.attribute("underlying").value))
- $types[type.name] = type
-}
-
-doc.root.each_element("/cecil/metadata/tables//table") { |node|
- table = Cecil::Table.new(node.attribute("name").value,
- node.attribute("rid").value,
- node.attribute("requires").nil? ? nil : node.attribute("requires").value)
- node.each_element("column") { |col|
- column = Cecil::Column.new(col.attribute("name").value,
- $types[col.attribute("type").value],
- col.attribute("target").nil? ? nil : col.attribute("target").value)
- table.add_column(column)
- }
- $tables.push(table)
-}
-
-$tables.sort!() { |a, b|
- a.name <=> b.name
-}
-
-$stables = $tables.sort { |a, b|
- eval(a.rid) <=> eval(b.rid)
-}
-
-doc.root.each_element("/cecil/metadata/codedindexes//codedindex") { |node|
- ci = Cecil::CodedIndex.new(node.attribute("name").value,
- node.attribute("size").value,
- node.attribute("requires").nil? ? nil : node.attribute("requires").value)
- node.each_element("table") { |table|
- ci.add_table(table.attribute("name").value, table.attribute("tag").value)
- }
- $coded_indexes.push(ci)
-}
-
-doc.root.each_element("/cecil/metadata/opcodes//opcode") { |node|
- $ops.push(Cecil::OpCode.new(node.attribute("name").value, node.attribute("op1").value,
- node.attribute("op2").value, node.attribute("flowcontrol").value,
- node.attribute("opcodetype").value, node.attribute("operandtype").value,
- node.attribute("stackbehaviourpop").value, node.attribute("stackbehaviourpush").value,
- node.attribute("requires").nil? ? nil : node.attribute("requires").value))
-}
-
-$ops.sort!() { |a, b|
- if a.op1 == b.op1
- eval(a.op2) <=> eval(b.op2)
- elsif a.op1 == "0xff"
- -1
- else
- 1
- end
-}
-
-doc.root.each_element("/cecil/collections//collection") { |node|
- $colls.push(Cecil::Collection.new(node.attribute("type").value, node.attribute("container").value,
- (node.attribute("visit").nil? ? nil : node.attribute("visit").value),
- (node.attribute("name").nil? ? nil : node.attribute("name").value),
- (node.attribute("lazyload").nil? ? false : node.attribute("lazyload").value == "true"),
- (node.attribute("pathtoloader").nil? ? nil : node.attribute("pathtoloader").value),
- node.attribute("target").value,
- (node.attribute("indexed").nil? ? false : node.attribute("indexed").value == "true"),
- (node.attribute("usecontainerinterface").nil? ? false : node.attribute("usecontainerinterface").value == "true")))
-}
-
-def cecil_compile(file, template)
-
- erb = ERB.new(IO.read(template))
- res = erb.result
-
- if (!File.exists?(file))
-
- File.open(file, File::CREAT|File::WRONLY|File::TRUNC) { |cur_file|
- cur_file.write(res)
- }
-
- puts("#Created: #{file}")
-
- else
-
- ext = ".tmp"
-
- File.open(file + ext, File::CREAT|File::WRONLY|File::TRUNC) { |temp_file|
- temp_file.write(res)
- }
-
- save = Array.new
-
- [file, file + ext].each { |fileloc|
- File.open(fileloc, File::RDONLY) { |f|
- buf = f.readlines
- buf.each { |line|
- line.chomp!()
- }
- buf = buf.join
- buf = buf[buf.index("SOFTWARE."), buf.length]
- save.push(buf)
- }
- }
-
- if (save[0] != save[1]) then
- File.delete(file) if File.exists?(file)
- File.rename(file + ext, file)
- puts("#Modified: #{file}")
- else
- File.delete(file + ext)
- end
- end
-end
-
-$tables.each { |table|
- $cur_table = table
- filename = "../Mono.Cecil.Metadata/" + table.name + ".cs"
- cecil_compile(filename, "./templates/Table.cs")
-}
-$cur_table = nil
-
-[ "MetadataTableReader.cs", "MetadataRowReader.cs",
- "MetadataTableWriter.cs", "MetadataRowWriter.cs", "BaseMetadataVisitor.cs",
- "CodedIndex.cs", "Utilities.cs" ].each { |file|
- cecil_compile("../Mono.Cecil.Metadata/" + file, "./templates/" + file)
-}
-
-cecil_compile("../Mono.Cecil.Metadata/IMetadataVisitor.cs", "./templates/IMetadataVisitor.cs")
-
-cecil_compile("../Mono.Cecil.Cil/OpCodes.cs", "./templates/OpCodes.cs")
-cecil_compile("../Mono.Cecil.Cil/Code.cs", "./templates/Code.cs")
-
-$colls.each { |coll|
- $cur_coll = coll
- file = "../#{coll.target}/" + coll.name + ".cs"
- type = coll.indexed ? "Indexed" : "Named"
- template = "./templates/#{type}Collection.cs"
-
- cecil_compile(file, template)
-}
-$cur_coll = nil
-
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-mig.rb b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-mig.rb
deleted file mode 100755
index a5104fb..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-mig.rb
+++ /dev/null
@@ -1,159 +0,0 @@
-#!/usr/bin/env ruby
-
-#
-# usage cecil-mig.rb directory
-#
-
-dir = ARGV.length > 0 ? ARGV[0] : "."
-
-$replaces = {
- "GenericParamAttributes" => "GenericParameterAttributes",
- "ParamAttributes" => "ParameterAttributes",
- "IParameterReference" => "ParameterDefinition",
- "IPropertyReference" => "PropertyDefinition",
- "IEventReference" => "EventDefinition",
- "IVariableReference" => "VariableDefinition",
- "IMarshalDesc" => "MarshalSpec",
- "MarshalDesc" => "MarshalSpec",
- "IArrayMarshalDesc" => "ArrayMarshalSpec",
- "ArrayMarshalDesc" => "ArrayMarshalSpec",
- "ICustomMarshalerDesc" => "CustomMarshalerSpec",
- "CustomMarshalerDesc" => "CustomMarshalerSpec",
- "ISafeArrayDesc" => "SafeArraySpec",
- "SafeArrayDesc" => "SafeArraySpec",
- "IFixedArrayDesc" => "FixedArraySpec",
- "FixedArrayDesc" => "FixedArraySpec",
- "IFixedSysStringDesc" => "FixedSysStringSpec",
- "FixedSysStringDesc" => "FixedSysStringSpec",
- "IModifierType" => "ModType"
-}
-
-$collections = [
- "AssemblyNameReferenceCollection",
- "ModuleReferenceCollection",
- "ModuleDefinitionCollection",
- "ResourceCollection",
- "TypeDefinitionCollection",
- "TypeReferenceCollection",
- "InterfaceCollection",
- "ParameterDefinitionCollection",
- "OverrideCollection",
- "MethodDefinitionCollection",
- "ConstructorCollection",
- "EventDefinitionCollection",
- "FieldDefinitionCollection",
- "PropertyDefinitionCollection",
- "InstructionCollection",
- "ExceptionHandlerCollection",
- "VariableDefinitionCollection",
- "ArrayDimensionCollection",
- "CustomAttributeCollection",
- "ExternTypeCollection",
- "NestedTypeCollection",
- "SecurityDeclarationCollection",
- "MemberReferenceCollection",
- "GenericParameterCollection",
- "GenericArgumentCollection",
- "ConstraintCollection"
-]
-
-$types = [
- "AssemblyDefinition",
- "ArrayDimension",
- "ArrayType",
- "AssemblyLinkedResource",
- "AssemblyNameReference",
- "AssemblyNameDefinition",
- "CallSite",
- "CustomAttribute",
- "EmbeddedResource",
- "EventDefinition",
- "EventReference",
- "FieldDefinition",
- "FieldReference",
- "FunctionPointerType",
- "GenericInstanceMethod",
- "GenericInstanceType",
- "GenericParameter",
- "LinkedResource",
- "MethodDefinition",
- "MethodReference",
- "MethodReturnType",
- "ModifierOptional",
- "ModifierRequired",
- "ModuleDefinition",
- "ModuleReference",
- "ParameterDefinition",
- "ParameterReference",
- "PinnedType",
- "PInvokeInfo",
- "PropertyDefinition",
- "PropertyReference",
- "ReferenceType",
- "Resource",
- "SecurityDeclaration",
- "TypeDefinition",
- "TypeReference",
- "TypeSpecification",
-
- "Instruction",
- "ExceptionHandler",
- "MethodBody",
- "VariableDefinition",
- "VariableReference"
-]
-
-def iface(name)
- return "I" + name
-end
-
-def bang(buffer, re, str)
- nl = "([\\W])"
- buffer.gsub!(Regexp.new("#{nl}(#{re})#{nl}"), "\\1" + str + "\\3")
-end
-
-def process_replaces(buffer)
- $replaces.each_key { |key|
- bang(buffer, key, $replaces[key])
- }
-end
-
-def process_collections(buffer)
- $collections.each { |name|
- bang(buffer, iface(name), name)
- }
-end
-
-def process_types(buffer)
- $types.each { |name|
- bang(buffer, iface(name), name)
- }
-end
-
-def process_unbreak(buffer)
- $unbreak.each { |name|
- bang(buffer, name, iface(name))
- }
-end
-
-def process(file)
- buffer = ""
- original = ""
- File.open(file, File::RDONLY) { |f|
- original = f.read()
- buffer = original.clone
- process_replaces(buffer)
- process_collections(buffer)
- process_types(buffer)
- }
-
- File.open(file, File::WRONLY | File::TRUNC) { |f|
- f.write(buffer)
- puts("#{file} processed")
- } if (original != buffer)
-
-end
-
-Dir[File.join(dir, "**", "*.*")].each { |file|
- process(file) if not File.directory?(file)
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-update-rev b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-update-rev
deleted file mode 100755
index c1c1f91..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil-update-rev
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/env ruby
-
-svn = "svn+ssh://mono-cvs.ximian.com/source/"
-info = "Mono.Cecil/AssemblyInfo.cs"
-
-$rev = 0
-
-IO::popen("svn info #{svn}").each { |line|
- $rev = $1.to_i if line =~ /^Revision: ([0-9]+)/
-}
-
-if $rev == 0
- puts "Cannot get last revision"
- exit(1)
-end
-
-def read_file(file)
- content = ""
- f = File.new(file, File::CREAT | File::RDONLY)
- content << f.readlines.join
- f.close
-
- return content
-end
-
-def write_file(file, content)
- File.open(file, File::CREAT | File::WRONLY) { |f|
- f.write(content)
- }
-end
-
-def patch_info(content)
- patched = ""
- content.each_line { |line|
- if not line =~ /AssemblyVersion/
- patched << line
- else
- patched << line.gsub(/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/) {
- next_rev = $rev.next
- cut = 10000
- build_rev = (next_rev / cut).ceil
- revision = next_rev - (build_rev * cut)
- build = (($3.to_i / 100).ceil * 100) + build_rev
- "#{$1.to_s}.#{$2.to_s}.#{build.to_s}.#{(revision).to_s}"
- }
- end
- }
- return patched
-end
-
-write_file(info, patch_info(read_file(info)))
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil.xml b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil.xml
deleted file mode 100644
index 4f548ec..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/cecil.xml
+++ /dev/null
@@ -1,608 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<cecil>
-
- <types>
- <type name="byte" size="1" />
- <type name="ushort" size="2" />
- <type name="short" size="2" />
- <type name="uint" size="4" />
- <type name="int" size="4" />
- <type name="Mono.Cecil.Binary.DataDirectory" size="8" />
- <type name="Mono.Cecil.Binary.ImageCharacteristics" underlying="ushort" size="2" />
- <type name="Mono.Cecil.Binary.DebugStoreType" underlying="uint" size="4" />
- <type name="Mono.Cecil.Binary.SubSystem" underlying="ushort" size="2" />
- <type name="Mono.Cecil.Binary.SectionCharacteristics" underlying="uint" size="4" />
- <type name="Mono.Cecil.Binary.RVA" size="4" />
- <type name="Mono.Cecil.Binary.RuntimeImage" underlying="uint" size="4" />
- <type name="Mono.Cecil.AssemblyHashAlgorithm" underlying="uint" size="4" />
- <type name="Mono.Cecil.AssemblyFlags" underlying="uint" size="4" />
- <type name="Mono.Cecil.EventAttributes" underlying="ushort" size="2" />
- <type name="Mono.Cecil.TypeAttributes" underlying="uint" size="4" />
- <type name="Mono.Cecil.FieldAttributes" underlying="ushort" size="2" />
- <type name="Mono.Cecil.FileAttributes" underlying="uint" size="4" />
- <type name="Mono.Cecil.GenericParameterAttributes" underlying="ushort" size="2" />
- <type name="Mono.Cecil.PInvokeAttributes" underlying="ushort" size="2" />
- <type name="Mono.Cecil.ParameterAttributes" underlying="ushort" size="2" />
- <type name="Mono.Cecil.PropertyAttributes" underlying="ushort" size="2" />
- <type name="Mono.Cecil.ManifestResourceAttributes" underlying="uint" size="4" />
- <type name="Mono.Cecil.MethodAttributes" underlying="ushort" size="2" />
- <type name="Mono.Cecil.MethodImplAttributes" underlying="ushort" size="2" />
- <type name="Mono.Cecil.MethodSemanticsAttributes" underlying="ushort" size="2" />
- <type name="Mono.Cecil.SecurityAction" underlying="short" size="2" />
- <type name="Mono.Cecil.Metadata.ElementType" underlying="ushort" size="2" />
- <type name="Mono.Cecil.Metadata.MetadataToken" underlying="uint" size="4" />
- </types>
-
- <!--
- All details about the Metadata
- reader and writer of Cecil
- -->
- <metadata>
-
- <!--
- This part contains ECMA spec
- about CIL tables and rows positions
- in a valid CLI image
- -->
- <tables>
- <table name="Assembly" rid="0x20">
- <column name="HashAlgId" type="Mono.Cecil.AssemblyHashAlgorithm" />
- <column name="MajorVersion" type="ushort" />
- <column name="MinorVersion" type="ushort" />
- <column name="BuildNumber" type="ushort" />
- <column name="RevisionNumber" type="ushort" />
- <column name="Flags" type="Mono.Cecil.AssemblyFlags" />
- <column name="PublicKey" type="uint" target="BlobHeap" />
- <column name="Name" type="uint" target="StringsHeap" />
- <column name="Culture" type="uint" target="StringsHeap" />
- </table>
- <table name="AssemblyOS" rid="0x22">
- <column name="OSPlatformID" type="uint" />
- <column name="OSMajorVersion" type="uint" />
- <column name="OSMinorVersion" type="uint" />
- </table>
- <table name="AssemblyProcessor" rid="0x21">
- <column name="Processor" type="uint" />
- </table>
- <table name="AssemblyRef" rid="0x23">
- <column name="MajorVersion" type="ushort" />
- <column name="MinorVersion" type="ushort" />
- <column name="BuildNumber" type="ushort" />
- <column name="RevisionNumber" type="ushort" />
- <column name="Flags" type="Mono.Cecil.AssemblyFlags" />
- <column name="PublicKeyOrToken" type="uint" target="BlobHeap" />
- <column name="Name" type="uint" target="StringsHeap" />
- <column name="Culture" type="uint" target="StringsHeap" />
- <column name="HashValue" type="uint" target="BlobHeap" />
- </table>
- <table name="AssemblyRefOS" rid="0x25">
- <column name="OSPlatformID" type="uint" />
- <column name="OSMajorVersion" type="uint" />
- <column name="OSMinorVersion" type="uint" />
- <column name="AssemblyRef" type="uint" target="AssemblyRef" />
- </table>
- <table name="AssemblyRefProcessor" rid="0x24">
- <column name="Processor" type="uint" />
- <column name="AssemblyRef" type="uint" target="AssemblyRef" />
- </table>
- <table name="ClassLayout" rid="0x0f">
- <column name="PackingSize" type="ushort" />
- <column name="ClassSize" type="uint" />
- <column name="Parent" type="uint" target="TypeDef" />
- </table>
- <table name="Constant" rid="0x0b">
- <column name="Type" type="Mono.Cecil.Metadata.ElementType" />
- <column name="Parent" type="Mono.Cecil.Metadata.MetadataToken" target="HasConstant" />
- <column name="Value" type="uint" target="BlobHeap" />
- </table>
- <table name="CustomAttribute" rid="0x0c">
- <column name="Parent" type="Mono.Cecil.Metadata.MetadataToken" target="HasCustomAttribute" />
- <column name="Type" type="Mono.Cecil.Metadata.MetadataToken" target="CustomAttributeType" />
- <column name="Value" type="uint" target="BlobHeap" />
- </table>
- <table name="DeclSecurity" rid="0x0e">
- <column name="Action" type="Mono.Cecil.SecurityAction" />
- <column name="Parent" type="Mono.Cecil.Metadata.MetadataToken" target="HasDeclSecurity" />
- <column name="PermissionSet" type="uint" target="BlobHeap" />
- </table>
- <table name="EventMap" rid="0x12">
- <column name="Parent" type="uint" target="TypeDef" />
- <column name="EventList" type="uint" target="Event" />
- </table>
- <table name="Event" rid="0x14">
- <column name="EventFlags" type="Mono.Cecil.EventAttributes" />
- <column name="Name" type="uint" target="StringsHeap" />
- <column name="EventType" type="Mono.Cecil.Metadata.MetadataToken" target="TypeDefOrRef" />
- </table>
- <table name="EventPtr" rid="0x13">
- <column name="Event" type="uint" target="Event" />
- </table>
- <table name="ExportedType" rid="0x27">
- <column name="Flags" type="Mono.Cecil.TypeAttributes" />
- <column name="TypeDefId" type="uint" />
- <column name="TypeName" type="uint" target="StringsHeap" />
- <column name="TypeNamespace" type="uint" target="StringsHeap" />
- <column name="Implementation" type="Mono.Cecil.Metadata.MetadataToken" target="Implementation" />
- </table>
- <table name="Field" rid="0x04">
- <column name="Flags" type="Mono.Cecil.FieldAttributes" />
- <column name="Name" type="uint" target="StringsHeap" />
- <column name="Signature" type="uint" target="BlobHeap" />
- </table>
- <table name="FieldLayout" rid="0x10">
- <column name="Offset" type="uint" />
- <column name="Field" type="uint" target="Field" />
- </table>
- <table name="FieldMarshal" rid="0x0d">
- <column name="Parent" type="Mono.Cecil.Metadata.MetadataToken" target="HasFieldMarshal" />
- <column name="NativeType" type="uint" target="BlobHeap" />
- </table>
- <table name="FieldPtr" rid="0x03">
- <column name="Field" type="uint" target="Field" />
- </table>
- <table name="FieldRVA" rid="0x1d">
- <column name="RVA" type="Mono.Cecil.Binary.RVA" />
- <column name="Field" type="uint" target="Field" />
- </table>
- <table name="File" rid="0x26">
- <column name="Flags" type="Mono.Cecil.FileAttributes" />
- <column name="Name" type="uint" target="StringsHeap" />
- <column name="HashValue" type="uint" target="BlobHeap" />
- </table>
- <table name="GenericParam" rid="0x2a" requires="NET_2_0">
- <column name="Number" type="ushort" />
- <column name="Flags" type="Mono.Cecil.GenericParameterAttributes" />
- <column name="Owner" type="Mono.Cecil.Metadata.MetadataToken" target="TypeOrMethodDef" />
- <column name="Name" type="uint" target="StringsHeap" />
- </table>
- <table name="GenericParamConstraint" rid="0x2c" requires="NET_2_0">
- <column name="Owner" type="uint" target="GenericParam" />
- <column name="Constraint" type="Mono.Cecil.Metadata.MetadataToken" target="TypeDefOrRef" />
- </table>
- <table name="ImplMap" rid="0x1c">
- <column name="MappingFlags" type="Mono.Cecil.PInvokeAttributes" />
- <column name="MemberForwarded" type="Mono.Cecil.Metadata.MetadataToken" target="MemberForwarded" />
- <column name="ImportName" type="uint" target="StringsHeap" />
- <column name="ImportScope" type="uint" target="ModuleRef" />
- </table>
- <table name="InterfaceImpl" rid="0x09">
- <column name="Class" type="uint" target="TypeDef" />
- <column name="Interface" type="Mono.Cecil.Metadata.MetadataToken" target="TypeDefOrRef" />
- </table>
- <table name="ManifestResource" rid="0x28">
- <column name="Offset" type="uint" />
- <column name="Flags" type="Mono.Cecil.ManifestResourceAttributes" />
- <column name="Name" type="uint" target="StringsHeap" />
- <column name="Implementation" type="Mono.Cecil.Metadata.MetadataToken" target="Implementation" />
- </table>
- <table name="MemberRef" rid="0x0a">
- <column name="Class" type="Mono.Cecil.Metadata.MetadataToken" target="MemberRefParent" />
- <column name="Name" type="uint" target="StringsHeap" />
- <column name="Signature" type="uint" target="BlobHeap" />
- </table>
- <table name="Method" rid="0x06">
- <column name="RVA" type="Mono.Cecil.Binary.RVA" />
- <column name="ImplFlags" type="Mono.Cecil.MethodImplAttributes" />
- <column name="Flags" type="Mono.Cecil.MethodAttributes" />
- <column name="Name" type="uint" target="StringsHeap" />
- <column name="Signature" type="uint" target="BlobHeap" />
- <column name="ParamList" type="uint" target="Param" />
- </table>
- <table name="MethodImpl" rid="0x19">
- <column name="Class" type="uint" target="TypeDef" />
- <column name="MethodBody" type="Mono.Cecil.Metadata.MetadataToken" target="MethodDefOrRef" />
- <column name="MethodDeclaration" type="Mono.Cecil.Metadata.MetadataToken" target="MethodDefOrRef" />
- </table>
- <table name="MethodPtr" rid="0x05">
- <column name="Method" type="uint" target="Method" />
- </table>
- <table name="MethodSemantics" rid="0x18">
- <column name="Semantics" type="Mono.Cecil.MethodSemanticsAttributes" />
- <column name="Method" type="uint" target="Method" />
- <column name="Association" type="Mono.Cecil.Metadata.MetadataToken" target="HasSemantics" />
- </table>
- <table name="MethodSpec" rid="0x2b" requires="NET_2_0">
- <column name="Method" type="Mono.Cecil.Metadata.MetadataToken" target="MethodDefOrRef" />
- <column name="Instantiation" type="uint" target="BlobHeap" />
- </table>
- <table name="Module" rid="0x00">
- <column name="Generation" type="ushort" />
- <column name="Name" type="uint" target="StringsHeap" />
- <column name="Mvid" type="uint" target="GuidHeap" />
- <column name="EncId" type="uint" target="GuidHeap" />
- <column name="EncBaseId" type="uint" target="GuidHeap" />
- </table>
- <table name="ModuleRef" rid="0x1a">
- <column name="Name" type="uint" target="StringsHeap" />
- </table>
- <table name="NestedClass" rid="0x29">
- <column name="NestedClass" type="uint" target="TypeDef" />
- <column name="EnclosingClass" type="uint" target="TypeDef" />
- </table>
- <table name="Param" rid="0x08">
- <column name="Flags" type="Mono.Cecil.ParameterAttributes" />
- <column name="Sequence" type="ushort" />
- <column name="Name" type="uint" target="StringsHeap" />
- </table>
- <table name="ParamPtr" rid="0x07">
- <column name="Param" type="uint" target="Param" />
- </table>
- <table name="Property" rid="0x17">
- <column name="Flags" type="Mono.Cecil.PropertyAttributes" />
- <column name="Name" type="uint" target="StringsHeap" />
- <column name="Type" type="uint" target="BlobHeap" />
- </table>
- <table name="PropertyMap" rid="0x15">
- <column name="Parent" type="uint" target="TypeDef" />
- <column name="PropertyList" type="uint" target="Property" />
- </table>
- <table name="PropertyPtr" rid="0x16">
- <column name="Property" type="uint" target="Property" />
- </table>
- <table name="StandAloneSig" rid="0x11">
- <column name="Signature" type="uint" target="BlobHeap" />
- </table>
- <table name="TypeDef" rid="0x02">
- <column name="Flags" type="Mono.Cecil.TypeAttributes" />
- <column name="Name" type="uint" target="StringsHeap" />
- <column name="Namespace" type="uint" target="StringsHeap" />
- <column name="Extends" type="Mono.Cecil.Metadata.MetadataToken" target="TypeDefOrRef" />
- <column name="FieldList" type="uint" target="Field" />
- <column name="MethodList" type="uint" target="Method" />
- </table>
- <table name="TypeRef" rid="0x01">
- <column name="ResolutionScope" type="Mono.Cecil.Metadata.MetadataToken" target="ResolutionScope" />
- <column name="Name" type="uint" target="StringsHeap" />
- <column name="Namespace" type="uint" target="StringsHeap" />
- </table>
- <table name="TypeSpec" rid="0x1b">
- <column name="Signature" type="uint" target="BlobHeap" />
- </table>
- </tables>
-
- <codedindexes>
- <codedindex name="TypeDefOrRef" size="2">
- <table name="TypeDef" tag="0" />
- <table name="TypeRef" tag="1" />
- <table name="TypeSpec" tag="2" />
- </codedindex>
- <codedindex name="HasConstant" size="2">
- <table name="Field" tag="0" />
- <table name="Param" tag="1" />
- <table name="Property" tag="2" />
- </codedindex>
- <codedindex name="HasCustomAttribute" size="5">
- <table name="Method" tag="0" />
- <table name="Field" tag="1" />
- <table name="TypeRef" tag="2" />
- <table name="TypeDef" tag="3" />
- <table name="Param" tag="4" />
- <table name="InterfaceImpl" tag="5" />
- <table name="MemberRef" tag="6" />
- <table name="Module" tag="7" />
- <table name="DeclSecurity" tag="8" />
- <table name="Property" tag="9" />
- <table name="Event" tag="10" />
- <table name="StandAloneSig" tag="11" />
- <table name="ModuleRef" tag="12" />
- <table name="TypeSpec" tag="13" />
- <table name="Assembly" tag="14" />
- <table name="AssemblyRef" tag="15" />
- <table name="File" tag="16" />
- <table name="ExportedType" tag="17" />
- <table name="ManifestResource" tag="18" />
- <table name="GenericParam" tag="19" />
- </codedindex>
- <codedindex name="HasFieldMarshal" size="1">
- <table name="Field" tag="0" />
- <table name="Param" tag="1" />
- </codedindex>
- <codedindex name="HasDeclSecurity" size="2">
- <table name="TypeDef" tag="0" />
- <table name="Method" tag="1" />
- <table name="Assembly" tag="2" />
- </codedindex>
- <codedindex name="MemberRefParent" size="3">
- <table name="TypeDef" tag="0" />
- <table name="TypeRef" tag="1" />
- <table name="ModuleRef" tag="2" />
- <table name="Method" tag="3" />
- <table name="TypeSpec" tag="4" />
- </codedindex>
- <codedindex name="HasSemantics" size="1">
- <table name="Event" tag="0" />
- <table name="Property" tag="1" />
- </codedindex>
- <codedindex name="MethodDefOrRef" size="1">
- <table name="Method" tag="0" />
- <table name="MemberRef" tag="1" />
- </codedindex>
- <codedindex name="MemberForwarded" size="1">
- <table name="Field" tag="0" />
- <table name="Method" tag="1" />
- </codedindex>
- <codedindex name="Implementation" size="2">
- <table name="File" tag="0" />
- <table name="AssemblyRef" tag="1" />
- <table name="ExportedType" tag="2" />
- </codedindex>
- <codedindex name="CustomAttributeType" size="3">
- <table name="Method" tag="2" />
- <table name="MemberRef" tag="3" />
- </codedindex>
- <codedindex name="ResolutionScope" size="2">
- <table name="Module" tag="0" />
- <table name="ModuleRef" tag="1" />
- <table name="AssemblyRef" tag="2" />
- <table name="TypeRef" tag="3" />
- </codedindex>
- <codedindex name="TypeOrMethodDef" size="1" requires="NET_2_0">
- <table name="TypeDef" tag="0" />
- <table name="Method" tag="1" />
- </codedindex>
- </codedindexes>
-
- <!--
- This part contains all the standards opcodes
- -->
- <opcodes>
- <opcode name="nop" op1="0xff" op2="0x00" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Push0" />
- <opcode name="break" op1="0xff" op2="0x01" flowcontrol="Break" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Push0" />
- <opcode name="ldarg.0" op1="0xff" op2="0x02" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Push1" />
- <opcode name="ldarg.1" op1="0xff" op2="0x03" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Push1" />
- <opcode name="ldarg.2" op1="0xff" op2="0x04" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Push1" />
- <opcode name="ldarg.3" op1="0xff" op2="0x05" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Push1" />
- <opcode name="ldloc.0" op1="0xff" op2="0x06" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Push1" />
- <opcode name="ldloc.1" op1="0xff" op2="0x07" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Push1" />
- <opcode name="ldloc.2" op1="0xff" op2="0x08" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Push1" />
- <opcode name="ldloc.3" op1="0xff" op2="0x09" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Push1" />
- <opcode name="stloc.0" op1="0xff" op2="0x0a" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Push0" />
- <opcode name="stloc.1" op1="0xff" op2="0x0b" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Push0" />
- <opcode name="stloc.2" op1="0xff" op2="0x0c" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Push0" />
- <opcode name="stloc.3" op1="0xff" op2="0x0d" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Push0" />
- <opcode name="ldarg.s" op1="0xff" op2="0x0e" flowcontrol="Next" opcodetype="Macro" operandtype="ShortInlineParam" stackbehaviourpop="Pop0" stackbehaviourpush="Push1" />
- <opcode name="ldarga.s" op1="0xff" op2="0x0f" flowcontrol="Next" opcodetype="Macro" operandtype="ShortInlineParam" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="starg.s" op1="0xff" op2="0x10" flowcontrol="Next" opcodetype="Macro" operandtype="ShortInlineParam" stackbehaviourpop="Pop1" stackbehaviourpush="Push0" />
- <opcode name="ldloc.s" op1="0xff" op2="0x11" flowcontrol="Next" opcodetype="Macro" operandtype="ShortInlineVar" stackbehaviourpop="Pop0" stackbehaviourpush="Push1" />
- <opcode name="ldloca.s" op1="0xff" op2="0x12" flowcontrol="Next" opcodetype="Macro" operandtype="ShortInlineVar" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="stloc.s" op1="0xff" op2="0x13" flowcontrol="Next" opcodetype="Macro" operandtype="ShortInlineVar" stackbehaviourpop="Pop1" stackbehaviourpush="Push0" />
- <opcode name="ldnull" op1="0xff" op2="0x14" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Pushref" />
- <opcode name="ldc.i4.m1" op1="0xff" op2="0x15" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="ldc.i4.0" op1="0xff" op2="0x16" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="ldc.i4.1" op1="0xff" op2="0x17" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="ldc.i4.2" op1="0xff" op2="0x18" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="ldc.i4.3" op1="0xff" op2="0x19" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="ldc.i4.4" op1="0xff" op2="0x1a" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="ldc.i4.5" op1="0xff" op2="0x1b" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="ldc.i4.6" op1="0xff" op2="0x1c" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="ldc.i4.7" op1="0xff" op2="0x1d" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="ldc.i4.8" op1="0xff" op2="0x1e" flowcontrol="Next" opcodetype="Macro" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="ldc.i4.s" op1="0xff" op2="0x1f" flowcontrol="Next" opcodetype="Macro" operandtype="ShortInlineI" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="ldc.i4" op1="0xff" op2="0x20" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineI" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="ldc.i8" op1="0xff" op2="0x21" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineI8" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi8" />
- <opcode name="ldc.r4" op1="0xff" op2="0x22" flowcontrol="Next" opcodetype="Primitive" operandtype="ShortInlineR" stackbehaviourpop="Pop0" stackbehaviourpush="Pushr4" />
- <opcode name="ldc.r8" op1="0xff" op2="0x23" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineR" stackbehaviourpop="Pop0" stackbehaviourpush="Pushr8" />
- <opcode name="dup" op1="0xff" op2="0x25" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Push1_push1" />
- <opcode name="pop" op1="0xff" op2="0x26" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Push0" />
- <opcode name="jmp" op1="0xff" op2="0x27" flowcontrol="Call" opcodetype="Primitive" operandtype="InlineMethod" stackbehaviourpop="Pop0" stackbehaviourpush="Push0" />
- <opcode name="call" op1="0xff" op2="0x28" flowcontrol="Call" opcodetype="Primitive" operandtype="InlineMethod" stackbehaviourpop="Varpop" stackbehaviourpush="Varpush" />
- <opcode name="calli" op1="0xff" op2="0x29" flowcontrol="Call" opcodetype="Primitive" operandtype="InlineSig" stackbehaviourpop="Varpop" stackbehaviourpush="Varpush" />
- <opcode name="ret" op1="0xff" op2="0x2a" flowcontrol="Return" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Varpop" stackbehaviourpush="Push0" />
- <opcode name="br.s" op1="0xff" op2="0x2b" flowcontrol="Branch" opcodetype="Macro" operandtype="ShortInlineBrTarget" stackbehaviourpop="Pop0" stackbehaviourpush="Push0" />
- <opcode name="brfalse.s" op1="0xff" op2="0x2c" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="ShortInlineBrTarget" stackbehaviourpop="Popi" stackbehaviourpush="Push0" />
- <opcode name="brtrue.s" op1="0xff" op2="0x2d" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="ShortInlineBrTarget" stackbehaviourpop="Popi" stackbehaviourpush="Push0" />
- <opcode name="beq.s" op1="0xff" op2="0x2e" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="ShortInlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="bge.s" op1="0xff" op2="0x2f" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="ShortInlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="bgt.s" op1="0xff" op2="0x30" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="ShortInlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="ble.s" op1="0xff" op2="0x31" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="ShortInlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="blt.s" op1="0xff" op2="0x32" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="ShortInlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="bne.un.s" op1="0xff" op2="0x33" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="ShortInlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="bge.un.s" op1="0xff" op2="0x34" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="ShortInlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="bgt.un.s" op1="0xff" op2="0x35" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="ShortInlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="ble.un.s" op1="0xff" op2="0x36" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="ShortInlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="blt.un.s" op1="0xff" op2="0x37" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="ShortInlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="br" op1="0xff" op2="0x38" flowcontrol="Branch" opcodetype="Primitive" operandtype="InlineBrTarget" stackbehaviourpop="Pop0" stackbehaviourpush="Push0" />
- <opcode name="brfalse" op1="0xff" op2="0x39" flowcontrol="Cond_Branch" opcodetype="Primitive" operandtype="InlineBrTarget" stackbehaviourpop="Popi" stackbehaviourpush="Push0" />
- <opcode name="brtrue" op1="0xff" op2="0x3a" flowcontrol="Cond_Branch" opcodetype="Primitive" operandtype="InlineBrTarget" stackbehaviourpop="Popi" stackbehaviourpush="Push0" />
- <opcode name="beq" op1="0xff" op2="0x3b" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="InlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="bge" op1="0xff" op2="0x3c" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="InlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="bgt" op1="0xff" op2="0x3d" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="InlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="ble" op1="0xff" op2="0x3e" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="InlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="blt" op1="0xff" op2="0x3f" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="InlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="bne.un" op1="0xff" op2="0x40" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="InlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="bge.un" op1="0xff" op2="0x41" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="InlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="bgt.un" op1="0xff" op2="0x42" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="InlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="ble.un" op1="0xff" op2="0x43" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="InlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="blt.un" op1="0xff" op2="0x44" flowcontrol="Cond_Branch" opcodetype="Macro" operandtype="InlineBrTarget" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push0" />
- <opcode name="switch" op1="0xff" op2="0x45" flowcontrol="Cond_Branch" opcodetype="Primitive" operandtype="InlineSwitch" stackbehaviourpop="Popi" stackbehaviourpush="Push0" />
- <opcode name="ldind.i1" op1="0xff" op2="0x46" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi" stackbehaviourpush="Pushi" />
- <opcode name="ldind.u1" op1="0xff" op2="0x47" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi" stackbehaviourpush="Pushi" />
- <opcode name="ldind.i2" op1="0xff" op2="0x48" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi" stackbehaviourpush="Pushi" />
- <opcode name="ldind.u2" op1="0xff" op2="0x49" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi" stackbehaviourpush="Pushi" />
- <opcode name="ldind.i4" op1="0xff" op2="0x4a" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi" stackbehaviourpush="Pushi" />
- <opcode name="ldind.u4" op1="0xff" op2="0x4b" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi" stackbehaviourpush="Pushi" />
- <opcode name="ldind.i8" op1="0xff" op2="0x4c" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi" stackbehaviourpush="Pushi8" />
- <opcode name="ldind.i" op1="0xff" op2="0x4d" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi" stackbehaviourpush="Pushi" />
- <opcode name="ldind.r4" op1="0xff" op2="0x4e" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi" stackbehaviourpush="Pushr4" />
- <opcode name="ldind.r8" op1="0xff" op2="0x4f" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi" stackbehaviourpush="Pushr8" />
- <opcode name="ldind.ref" op1="0xff" op2="0x50" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi" stackbehaviourpush="Pushref" />
- <opcode name="stind.ref" op1="0xff" op2="0x51" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi_popi" stackbehaviourpush="Push0" />
- <opcode name="stind.i1" op1="0xff" op2="0x52" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi_popi" stackbehaviourpush="Push0" />
- <opcode name="stind.i2" op1="0xff" op2="0x53" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi_popi" stackbehaviourpush="Push0" />
- <opcode name="stind.i4" op1="0xff" op2="0x54" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi_popi" stackbehaviourpush="Push0" />
- <opcode name="stind.i8" op1="0xff" op2="0x55" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi_popi8" stackbehaviourpush="Push0" />
- <opcode name="stind.r4" op1="0xff" op2="0x56" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi_popr4" stackbehaviourpush="Push0" />
- <opcode name="stind.r8" op1="0xff" op2="0x57" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi_popr8" stackbehaviourpush="Push0" />
- <opcode name="add" op1="0xff" op2="0x58" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="sub" op1="0xff" op2="0x59" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="mul" op1="0xff" op2="0x5a" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="div" op1="0xff" op2="0x5b" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="div.un" op1="0xff" op2="0x5c" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="rem" op1="0xff" op2="0x5d" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="rem.un" op1="0xff" op2="0x5e" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="and" op1="0xff" op2="0x5f" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="or" op1="0xff" op2="0x60" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="xor" op1="0xff" op2="0x61" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="shl" op1="0xff" op2="0x62" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="shr" op1="0xff" op2="0x63" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="shr.un" op1="0xff" op2="0x64" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="neg" op1="0xff" op2="0x65" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Push1" />
- <opcode name="not" op1="0xff" op2="0x66" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Push1" />
- <opcode name="conv.i1" op1="0xff" op2="0x67" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.i2" op1="0xff" op2="0x68" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.i4" op1="0xff" op2="0x69" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.i8" op1="0xff" op2="0x6a" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi8" />
- <opcode name="conv.r4" op1="0xff" op2="0x6b" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushr4" />
- <opcode name="conv.r8" op1="0xff" op2="0x6c" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushr8" />
- <opcode name="conv.u4" op1="0xff" op2="0x6d" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.u8" op1="0xff" op2="0x6e" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi8" />
- <opcode name="callvirt" op1="0xff" op2="0x6f" flowcontrol="Call" opcodetype="Objmodel" operandtype="InlineMethod" stackbehaviourpop="Varpop" stackbehaviourpush="Varpush" />
- <opcode name="cpobj" op1="0xff" op2="0x70" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineType" stackbehaviourpop="Popi_popi" stackbehaviourpush="Push0" />
- <opcode name="ldobj" op1="0xff" op2="0x71" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineType" stackbehaviourpop="Popi" stackbehaviourpush="Push1" />
- <opcode name="ldstr" op1="0xff" op2="0x72" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineString" stackbehaviourpop="Pop0" stackbehaviourpush="Pushref" />
- <opcode name="newobj" op1="0xff" op2="0x73" flowcontrol="Call" opcodetype="Objmodel" operandtype="InlineMethod" stackbehaviourpop="Varpop" stackbehaviourpush="Pushref" />
- <opcode name="castclass" op1="0xff" op2="0x74" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineType" stackbehaviourpop="Popref" stackbehaviourpush="Pushref" />
- <opcode name="isinst" op1="0xff" op2="0x75" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineType" stackbehaviourpop="Popref" stackbehaviourpush="Pushi" />
- <opcode name="conv.r.un" op1="0xff" op2="0x76" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushr8" />
- <opcode name="unbox" op1="0xff" op2="0x79" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineType" stackbehaviourpop="Popref" stackbehaviourpush="Pushi" />
- <opcode name="throw" op1="0xff" op2="0x7a" flowcontrol="Throw" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref" stackbehaviourpush="Push0" />
- <opcode name="ldfld" op1="0xff" op2="0x7b" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineField" stackbehaviourpop="Popref" stackbehaviourpush="Push1" />
- <opcode name="ldflda" op1="0xff" op2="0x7c" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineField" stackbehaviourpop="Popref" stackbehaviourpush="Pushi" />
- <opcode name="stfld" op1="0xff" op2="0x7d" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineField" stackbehaviourpop="Popref_pop1" stackbehaviourpush="Push0" />
- <opcode name="ldsfld" op1="0xff" op2="0x7e" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineField" stackbehaviourpop="Pop0" stackbehaviourpush="Push1" />
- <opcode name="ldsflda" op1="0xff" op2="0x7f" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineField" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="stsfld" op1="0xff" op2="0x80" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineField" stackbehaviourpop="Pop1" stackbehaviourpush="Push0" />
- <opcode name="stobj" op1="0xff" op2="0x81" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineType" stackbehaviourpop="Popi_pop1" stackbehaviourpush="Push0" />
- <opcode name="conv.ovf.i1.un" op1="0xff" op2="0x82" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.ovf.i2.un" op1="0xff" op2="0x83" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.ovf.i4.un" op1="0xff" op2="0x84" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.ovf.i8.un" op1="0xff" op2="0x85" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi8" />
- <opcode name="conv.ovf.u1.un" op1="0xff" op2="0x86" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.ovf.u2.un" op1="0xff" op2="0x87" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.ovf.u4.un" op1="0xff" op2="0x88" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.ovf.u8.un" op1="0xff" op2="0x89" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi8" />
- <opcode name="conv.ovf.i.un" op1="0xff" op2="0x8a" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.ovf.u.un" op1="0xff" op2="0x8b" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="box" op1="0xff" op2="0x8c" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineType" stackbehaviourpop="Pop1" stackbehaviourpush="Pushref" />
- <opcode name="newarr" op1="0xff" op2="0x8d" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineType" stackbehaviourpop="Popi" stackbehaviourpush="Pushref" />
- <opcode name="ldlen" op1="0xff" op2="0x8e" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref" stackbehaviourpush="Pushi" />
- <opcode name="ldelema" op1="0xff" op2="0x8f" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineType" stackbehaviourpop="Popref_popi" stackbehaviourpush="Pushi" />
- <opcode name="ldelem.i1" op1="0xff" op2="0x90" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi" stackbehaviourpush="Pushi" />
- <opcode name="ldelem.u1" op1="0xff" op2="0x91" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi" stackbehaviourpush="Pushi" />
- <opcode name="ldelem.i2" op1="0xff" op2="0x92" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi" stackbehaviourpush="Pushi" />
- <opcode name="ldelem.u2" op1="0xff" op2="0x93" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi" stackbehaviourpush="Pushi" />
- <opcode name="ldelem.i4" op1="0xff" op2="0x94" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi" stackbehaviourpush="Pushi" />
- <opcode name="ldelem.u4" op1="0xff" op2="0x95" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi" stackbehaviourpush="Pushi" />
- <opcode name="ldelem.i8" op1="0xff" op2="0x96" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi" stackbehaviourpush="Pushi8" />
- <opcode name="ldelem.i" op1="0xff" op2="0x97" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi" stackbehaviourpush="Pushi" />
- <opcode name="ldelem.r4" op1="0xff" op2="0x98" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi" stackbehaviourpush="Pushr4" />
- <opcode name="ldelem.r8" op1="0xff" op2="0x99" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi" stackbehaviourpush="Pushr8" />
- <opcode name="ldelem.ref" op1="0xff" op2="0x9a" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi" stackbehaviourpush="Pushref" />
- <opcode name="stelem.i" op1="0xff" op2="0x9b" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi_popi" stackbehaviourpush="Push0" />
- <opcode name="stelem.i1" op1="0xff" op2="0x9c" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi_popi" stackbehaviourpush="Push0" />
- <opcode name="stelem.i2" op1="0xff" op2="0x9d" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi_popi" stackbehaviourpush="Push0" />
- <opcode name="stelem.i4" op1="0xff" op2="0x9e" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi_popi" stackbehaviourpush="Push0" />
- <opcode name="stelem.i8" op1="0xff" op2="0x9f" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi_popi8" stackbehaviourpush="Push0" />
- <opcode name="stelem.r4" op1="0xff" op2="0xa0" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi_popr4" stackbehaviourpush="Push0" />
- <opcode name="stelem.r8" op1="0xff" op2="0xa1" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi_popr8" stackbehaviourpush="Push0" />
- <opcode name="stelem.ref" op1="0xff" op2="0xa2" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Popref_popi_popref" stackbehaviourpush="Push0" />
- <opcode name="ldelem.any" op1="0xff" op2="0xa3" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineType" stackbehaviourpop="Popref_popi" stackbehaviourpush="Push1" requires="NET_2_0" />
- <opcode name="stelem.any" op1="0xff" op2="0xa4" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineType" stackbehaviourpop="Popref_popi_popref" stackbehaviourpush="Push0" requires="NET_2_0" />
- <opcode name="unbox.any" op1="0xff" op2="0xa5" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineType" stackbehaviourpop="Popref" stackbehaviourpush="Push1" requires="NET_2_0" />
- <opcode name="conv.ovf.i1" op1="0xff" op2="0xb3" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.ovf.u1" op1="0xff" op2="0xb4" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.ovf.i2" op1="0xff" op2="0xb5" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.ovf.u2" op1="0xff" op2="0xb6" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.ovf.i4" op1="0xff" op2="0xb7" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.ovf.u4" op1="0xff" op2="0xb8" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.ovf.i8" op1="0xff" op2="0xb9" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi8" />
- <opcode name="conv.ovf.u8" op1="0xff" op2="0xba" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi8" />
- <opcode name="refanyval" op1="0xff" op2="0xc2" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineType" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="ckfinite" op1="0xff" op2="0xc3" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushr8" />
- <opcode name="mkrefany" op1="0xff" op2="0xc6" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineType" stackbehaviourpop="Popi" stackbehaviourpush="Push1" />
- <opcode name="ldtoken" op1="0xff" op2="0xd0" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineTok" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="conv.u2" op1="0xff" op2="0xd1" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.u1" op1="0xff" op2="0xd2" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.i" op1="0xff" op2="0xd3" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.ovf.i" op1="0xff" op2="0xd4" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="conv.ovf.u" op1="0xff" op2="0xd5" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="add.ovf" op1="0xff" op2="0xd6" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="add.ovf.un" op1="0xff" op2="0xd7" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="mul.ovf" op1="0xff" op2="0xd8" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="mul.ovf.un" op1="0xff" op2="0xd9" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="sub.ovf" op1="0xff" op2="0xda" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="sub.ovf.un" op1="0xff" op2="0xdb" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Push1" />
- <opcode name="endfinally" op1="0xff" op2="0xdc" flowcontrol="Return" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Push0" />
- <opcode name="leave" op1="0xff" op2="0xdd" flowcontrol="Branch" opcodetype="Primitive" operandtype="InlineBrTarget" stackbehaviourpop="PopAll" stackbehaviourpush="Push0" />
- <opcode name="leave.s" op1="0xff" op2="0xde" flowcontrol="Branch" opcodetype="Macro" operandtype="ShortInlineBrTarget" stackbehaviourpop="PopAll" stackbehaviourpush="Push0" />
- <opcode name="stind.i" op1="0xff" op2="0xdf" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi_popi" stackbehaviourpush="Push0" />
- <opcode name="conv.u" op1="0xff" op2="0xe0" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="arglist" op1="0xfe" op2="0x00" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="ceq" op1="0xfe" op2="0x01" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Pushi" />
- <opcode name="cgt" op1="0xfe" op2="0x02" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Pushi" />
- <opcode name="cgt.un" op1="0xfe" op2="0x03" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Pushi" />
- <opcode name="clt" op1="0xfe" op2="0x04" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Pushi" />
- <opcode name="clt.un" op1="0xfe" op2="0x05" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1_pop1" stackbehaviourpush="Pushi" />
- <opcode name="ldftn" op1="0xfe" op2="0x06" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineMethod" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="ldvirtftn" op1="0xfe" op2="0x07" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineMethod" stackbehaviourpop="Popref" stackbehaviourpush="Pushi" />
- <opcode name="ldarg" op1="0xfe" op2="0x09" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineParam" stackbehaviourpop="Pop0" stackbehaviourpush="Push1" />
- <opcode name="ldarga" op1="0xfe" op2="0x0a" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineParam" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="starg" op1="0xfe" op2="0x0b" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineParam" stackbehaviourpop="Pop1" stackbehaviourpush="Push0" />
- <opcode name="ldloc" op1="0xfe" op2="0x0c" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineVar" stackbehaviourpop="Pop0" stackbehaviourpush="Push1" />
- <opcode name="ldloca" op1="0xfe" op2="0x0d" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineVar" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="stloc" op1="0xfe" op2="0x0e" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineVar" stackbehaviourpop="Pop1" stackbehaviourpush="Push0" />
- <opcode name="localloc" op1="0xfe" op2="0x0f" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi" stackbehaviourpush="Pushi" />
- <opcode name="endfilter" op1="0xfe" op2="0x11" flowcontrol="Return" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi" stackbehaviourpush="Push0" />
- <opcode name="unaligned." op1="0xfe" op2="0x12" flowcontrol="Meta" opcodetype="Prefix" operandtype="ShortInlineI" stackbehaviourpop="Pop0" stackbehaviourpush="Push0" />
- <opcode name="volatile." op1="0xfe" op2="0x13" flowcontrol="Meta" opcodetype="Prefix" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Push0" />
- <opcode name="tail." op1="0xfe" op2="0x14" flowcontrol="Meta" opcodetype="Prefix" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Push0" />
- <opcode name="initobj" op1="0xfe" op2="0x15" flowcontrol="Next" opcodetype="Objmodel" operandtype="InlineType" stackbehaviourpop="Popi" stackbehaviourpush="Push0" />
- <opcode name="constrained." op1="0xfe" op2="0x16" flowcontrol="Next" opcodetype="Prefix" operandtype="InlineTok" stackbehaviourpop="Pop0" stackbehaviourpush="Push0" />
- <opcode name="cpblk" op1="0xfe" op2="0x17" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi_popi_popi" stackbehaviourpush="Push0" />
- <opcode name="initblk" op1="0xfe" op2="0x18" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Popi_popi_popi" stackbehaviourpush="Push0" />
- <opcode name="no." op1="0xfe" op2="0x19" flowcontrol="Next" opcodetype="Prefix" operandtype="ShortInlineI" stackbehaviourpop="Pop0" stackbehaviourpush="Push0" />
- <opcode name="rethrow" op1="0xfe" op2="0x1a" flowcontrol="Throw" opcodetype="Objmodel" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Push0" />
- <opcode name="sizeof" op1="0xfe" op2="0x1c" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineType" stackbehaviourpop="Pop0" stackbehaviourpush="Pushi" />
- <opcode name="refanytype" op1="0xfe" op2="0x1d" flowcontrol="Next" opcodetype="Primitive" operandtype="InlineNone" stackbehaviourpop="Pop1" stackbehaviourpush="Pushi" />
- <opcode name="readonly." op1="0xfe" op2="0x1e" flowcontrol="Next" opcodetype="Prefix" operandtype="InlineNone" stackbehaviourpop="Pop0" stackbehaviourpush="Push0" />
- </opcodes>
-
- </metadata>
-
- <!--
- This part contains all the collections
- that will be used in the Reflection ns
- -->
- <collections>
- <collection type="AssemblyNameReference" container="ModuleDefinition" visit="IReflectionStructure" target="Mono.Cecil" indexed="true" />
- <collection type="ModuleReference" container="ModuleDefinition" visit="IReflectionStructure" indexed="true" target="Mono.Cecil" />
- <collection type="ModuleDefinition" container="AssemblyDefinition" visit="IReflectionStructure" indexed="true" target="Mono.Cecil" />
- <collection type="Resource" container="ModuleDefinition" visit="IReflectionStructure" target="Mono.Cecil" indexed="true" />
- <collection type="TypeDefinition" container="ModuleDefinition" visit="IReflection" target="Mono.Cecil" />
- <collection type="TypeReference" container="ModuleDefinition" visit="IReflection" target="Mono.Cecil" />
- <collection type="TypeReference" container="TypeDefinition" visit="IReflection" name="Interface" indexed="true" target="Mono.Cecil" />
- <collection type="ParameterDefinition" container="IMemberReference" visit="IReflection" indexed="true" target="Mono.Cecil" />
- <collection type="MethodReference" container="MethodDefinition" visit="IReflection" name="Override" indexed="true" target="Mono.Cecil" />
- <collection type="MethodDefinition" container="TypeDefinition" visit="IReflection" indexed="true" target="Mono.Cecil" />
- <collection type="MethodDefinition" container="TypeDefinition" visit="IReflection" name="Constructor" indexed="true" target="Mono.Cecil" />
- <collection type="EventDefinition" container="TypeDefinition" visit="IReflection" target="Mono.Cecil" indexed="true" />
- <collection type="FieldDefinition" container="TypeDefinition" visit="IReflection" target="Mono.Cecil" indexed="true" />
- <collection type="PropertyDefinition" container="TypeDefinition" visit="IReflection" target="Mono.Cecil" indexed="true" />
- <collection type="Instruction" container="MethodBody" visit="ICode" indexed="true" target="Mono.Cecil.Cil" />
- <collection type="ExceptionHandler" container="MethodBody" visit="ICode" indexed="true" target="Mono.Cecil.Cil" />
- <collection type="VariableDefinition" container="IVariableDefinitionProvider" visit="ICode" indexed="true" target="Mono.Cecil.Cil" />
- <collection type="ArrayDimension" container="ArrayType" target="Mono.Cecil" indexed="true" />
- <!-- modified behaviour
- <collection type="SecurityDeclaration" container="IHasSecurity" usecontainerinterface="true" target="Mono.Cecil" indexed="true" visit="IReflection" />
- -->
- <collection type="CustomAttribute" container="ICustomAttributeProvider" usecontainerinterface="true" target="Mono.Cecil" indexed="true" visit="IReflection" />
- <collection type="TypeReference" container="ModuleDefinition" target="Mono.Cecil" visit="IReflection" name="ExternType" />
- <collection type="TypeDefinition" container="TypeDefinition" target="Mono.Cecil" visit="IReflection" name="NestedType" indexed="true" />
- <collection type="MemberReference" container="ModuleDefinition" target="Mono.Cecil" visit="IReflection" indexed="true" />
- <collection type="GenericParameter" container="IGenericParameterProvider" usecontainerinterface="true" target="Mono.Cecil" indexed="true" visit="IReflection" />
- <collection type="TypeReference" name="GenericArgument" container="IGenericInstance" target="Mono.Cecil" indexed="true" />
- <collection type="TypeReference" name="Constraint" container="GenericParameter" target="Mono.Cecil" indexed="true" />
- <collection type="Scope" container="IScopeProvider" visit="ICode" target="Mono.Cecil.Cil" indexed="true" />
- </collections>
-
-</cecil>
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/BaseMetadataVisitor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/BaseMetadataVisitor.cs
deleted file mode 100644
index c77583f..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/BaseMetadataVisitor.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-//
-// BaseMetadataVisitor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// <%=Time.now%>
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public abstract class BaseMetadataVisitor : IMetadataVisitor {
-
- public virtual void VisitMetadataRoot (MetadataRoot root)
- {
- }
-
- public virtual void VisitMetadataRootHeader (MetadataRoot.MetadataRootHeader header)
- {
- }
-
- public virtual void VisitMetadataStreamCollection (MetadataStreamCollection streams)
- {
- }
-
- public virtual void VisitMetadataStream (MetadataStream stream)
- {
- }
-
- public virtual void VisitMetadataStreamHeader (MetadataStream.MetadataStreamHeader header)
- {
- }
-
- public virtual void VisitGuidHeap (GuidHeap heap)
- {
- }
-
- public virtual void VisitStringsHeap (StringsHeap heap)
- {
- }
-
- public virtual void VisitTablesHeap (TablesHeap heap)
- {
- }
-
- public virtual void VisitBlobHeap (BlobHeap heap)
- {
- }
-
- public virtual void VisitUserStringsHeap (UserStringsHeap heap)
- {
- }
-
- public virtual void TerminateMetadataRoot (MetadataRoot root)
- {
- }
- }
-
- public abstract class BaseMetadataTableVisitor : IMetadataTableVisitor {
-
- public virtual void VisitTableCollection (TableCollection coll)
- {
- }
-
-<% $tables.each { |table| %> public virtual void Visit<%=table.table_name%> (<%=table.table_name%> table)
- {
- }
-
-<% } %> public virtual void TerminateTableCollection (TableCollection coll)
- {
- }
-
- public abstract IMetadataRowVisitor GetRowVisitor();
- }
-
- public abstract class BaseMetadataRowVisitor : IMetadataRowVisitor {
-
- public virtual void VisitRowCollection (RowCollection coll)
- {
- }
-
-<% $tables.each { |table| %> public virtual void Visit<%=table.row_name%> (<%=table.row_name%> row)
- {
- }
-
-<% } %> public virtual void TerminateRowCollection (RowCollection coll)
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Code.cs b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Code.cs
deleted file mode 100644
index 7274f8c..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Code.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// Code.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// <%=Time.now%>
-//
-// (C) 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- public enum Code {
-<% $ops.each { |op| %> <%=op.field_name%>,
-<% } %> }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/CodedIndex.cs b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/CodedIndex.cs
deleted file mode 100644
index 9f6a9d8..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/CodedIndex.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// CodedIndex.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// <%=Time.now%>
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public enum CodedIndex {
-<% $coded_indexes.each { |ci| %> <%=ci.name%><% if ci != $coded_indexes.last %>,<% end %>
-<% }
-%> }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/IMetadataVisitor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/IMetadataVisitor.cs
deleted file mode 100644
index 421f8cc..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/IMetadataVisitor.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-//
-// IMetadataVisitor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// <%=Time.now%>
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public interface IMetadataVisitor {
- void VisitMetadataRoot (MetadataRoot root);
- void VisitMetadataRootHeader (MetadataRoot.MetadataRootHeader header);
- void VisitMetadataStreamCollection (MetadataStreamCollection streams);
- void VisitMetadataStream (MetadataStream stream);
- void VisitMetadataStreamHeader (MetadataStream.MetadataStreamHeader header);
- void VisitGuidHeap (GuidHeap heap);
- void VisitStringsHeap (StringsHeap heap);
- void VisitTablesHeap (TablesHeap heap);
- void VisitBlobHeap (BlobHeap heap);
- void VisitUserStringsHeap (UserStringsHeap heap);
-
- void TerminateMetadataRoot (MetadataRoot root);
- }
-
- public interface IMetadataTableVisitor {
- void VisitTableCollection (TableCollection coll);
-
-<% $tables.each { |table| %> void Visit<%=table.table_name%> (<%=table.table_name%> table);
-<% } %>
- void TerminateTableCollection (TableCollection coll);
- IMetadataRowVisitor GetRowVisitor();
-}
-
- public interface IMetadataRowVisitor {
- void VisitRowCollection (RowCollection coll);
-
-<% $tables.each { |table| %> void Visit<%=table.row_name%> (<%=table.row_name%> row);
-<% } %>
- void TerminateRowCollection (RowCollection coll);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/IndexedCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/IndexedCollection.cs
deleted file mode 100644
index e95e819..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/IndexedCollection.cs
+++ /dev/null
@@ -1,296 +0,0 @@
-//
-// <%=$cur_coll.name%>.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// <%=Time.now%>
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-<%
-def member_visibility()
- return $cur_coll.type == "Instruction" ? "internal" : "public"
-end
-
-def use_event?()
- case $cur_coll.name
- when "NestedTypeCollection", "MethodDefinitionCollection", "ConstructorCollection", "FieldDefinitionCollection", "EventDefinitionCollection", "PropertyDefinitionCollection"
- return true
- end
-
- return false
-end
-
-%>
-namespace <%=$cur_coll.target%> {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class <%=$cur_coll.name%> : CollectionBase<% if (!$cur_coll.visitable.nil?) then %>, <%=$cur_coll.visitable%><% end %> {
-
- <%=$cur_coll.container_impl%> m_container;<%
- if $cur_coll.type == "Instruction" %>
- public readonly Instruction Outside = new Instruction (int.MaxValue, OpCodes.Nop);<% end %>
-
- public <%=$cur_coll.type%> this [int index] {
- get { return List [index] as <%=$cur_coll.type%>; }
- set { List [index] = value; }
- }
-
- public <%=$cur_coll.container%> Container {
- get { return m_container; }
- }
-
- public <%=$cur_coll.name%> (<%=$cur_coll.container_impl%> container)
- {
- m_container = container;
- }
-
- <%= member_visibility() %> void Add (<%=$cur_coll.type%> value)
- {<%
-if use_event?() %>
- Attach (value);
-<% end %>
- List.Add (value);
- }
-<%
-if use_event?() %>
-
- public new void Clear ()
- {
- foreach (<%=$cur_coll.type%> item in this)
- Detach (item);
-
- base.Clear ();
- }
-<% end %>
- public bool Contains (<%=$cur_coll.type%> value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (<%=$cur_coll.type%> value)
- {
- return List.IndexOf (value);
- }
-
- <%= member_visibility() %> void Insert (int index, <%=$cur_coll.type%> value)
- {<%
-if use_event?() %>
- Attach (value);
-<% end %>
- List.Insert (index, value);
- }
-
- <%= member_visibility() %> void Remove (<%=$cur_coll.type%> value)
- {
- List.Remove (value);
-<% if use_event?() %>
- Detach (value);
-<% end %> }
-<%
-if use_event?() %>
-
- <%= member_visibility() %> new void RemoveAt (int index)
- {
- <%=$cur_coll.type%> item = this [index];
- Remove (item);
- }
-<% end %>
- protected override void OnValidate (object o)
- {
- if (! (o is <%=$cur_coll.type%>))
- throw new ArgumentException ("Must be of type " + typeof (<%=$cur_coll.type%>).FullName);
- }
-<%
- case $cur_coll.item_name
- when "MethodDefinition"
-%>
- public MethodDefinition [] GetMethod (string name)
- {
- ArrayList ret = new ArrayList ();
- foreach (MethodDefinition meth in this)
- if (meth.Name == name)
- ret.Add (meth);
-
- return ret.ToArray (typeof (MethodDefinition)) as MethodDefinition [];
- }
-
- internal MethodDefinition GetMethodInternal (string name, IList parameters)
- {
- foreach (MethodDefinition meth in this) {
- if (meth.Name != name || meth.Parameters.Count != parameters.Count)
- continue;
-
- bool match = true;
- for (int i = 0; i < parameters.Count; i++) {
- string pname;
- object param = parameters [i];
- if (param is Type)
- pname = ReflectionHelper.GetTypeSignature (param as Type);
- else if (param is TypeReference)
- pname = (param as TypeReference).FullName;
- else if (param is ParameterDefinition)
- pname = (param as ParameterDefinition).ParameterType.FullName;
- else
- throw new NotSupportedException ();
-
- if (meth.Parameters [i].ParameterType.FullName != pname) {
- match = false;
- break;
- }
- }
-
- if (match)
- return meth;
- }
-
- return null;
- }
-
- public MethodDefinition GetMethod (string name, Type [] parameters)
- {
- return GetMethodInternal (name, parameters);
- }
-
- public MethodDefinition GetMethod (string name, TypeReference [] parameters)
- {
- return GetMethodInternal (name, parameters);
- }
-
- public MethodDefinition GetMethod (string name, ParameterDefinitionCollection parameters)
- {
- return GetMethodInternal (name, parameters);
- }
-<%
- when "FieldDefinition"
-%>
- public FieldDefinition GetField (string name)
- {
- foreach (FieldDefinition field in this)
- if (field.Name == name)
- return field;
-
- return null;
- }
-<%
- when "Constructor"
-%>
- internal MethodDefinition GetConstructorInternal (bool isStatic, IList parameters)
- {
- foreach (MethodDefinition ctor in this) {
- if (ctor.IsStatic != isStatic || ctor.Parameters.Count != parameters.Count)
- continue;
-
- bool match = true;
- for (int i = 0; i < parameters.Count; i++) {
- string pname;
- object param = parameters [i];
- if (param is Type)
- pname = ReflectionHelper.GetTypeSignature (param as Type);
- else if (param is TypeReference)
- pname = (param as TypeReference).FullName;
- else if (param is ParameterDefinition)
- pname = (param as ParameterDefinition).ParameterType.FullName;
- else
- throw new NotSupportedException ();
-
- if (ctor.Parameters [i].ParameterType.FullName != pname) {
- match = false;
- break;
- }
- }
-
- if (match)
- return ctor;
- }
-
- return null;
- }
-
- public MethodDefinition GetConstructor (bool isStatic, Type [] parameters)
- {
- return GetConstructorInternal (isStatic, parameters);
- }
-
- public MethodDefinition GetConstructor (bool isStatic, TypeReference [] parameters)
- {
- return GetConstructorInternal (isStatic, parameters);
- }
-
- public MethodDefinition GetConstructor (bool isStatic, ParameterDefinitionCollection parameters)
- {
- return GetConstructorInternal (isStatic, parameters);
- }
-<%
- when "EventDefinition"
-%>
- public EventDefinition GetEvent (string name)
- {
- foreach (EventDefinition evt in this)
- if (evt.Name == name)
- return evt;
-
- return null;
- }
-<%
- when "PropertyDefinition"
-%>
- public PropertyDefinition [] GetProperties (string name)
- {
- ArrayList ret = new ArrayList ();
- foreach (PropertyDefinition prop in this)
- if (prop.Name == name)
- ret.Add (prop);
-
- return ret.ToArray (typeof (PropertyDefinition)) as PropertyDefinition [];
- }
-<%
- end
-
- if use_event?()
-%>
- void Attach (MemberReference member)
- {
- if (member.DeclaringType != null)
- throw new ReflectionException ("Member already attached, clone it instead");
-
- member.DeclaringType = m_container;
- }
-
- void Detach (MemberReference member)
- {
- member.DeclaringType = null;
- }
-<% end
- if !$cur_coll.visitor.nil? then %>
- public void Accept (<%=$cur_coll.visitor%> visitor)
- {
- visitor.<%=$cur_coll.visitThis%> (this);
- }
-<% end %> }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataRowReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataRowReader.cs
deleted file mode 100644
index fc8d271..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataRowReader.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-//
-// MetadataRowReader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// <%=Time.now%>
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.Collections;
- using System.IO;
-
- using Mono.Cecil.Binary;
-
- class MetadataRowReader : BaseMetadataRowVisitor {
-
- MetadataTableReader m_mtrv;
- BinaryReader m_binaryReader;
- MetadataRoot m_metadataRoot;
- IDictionary m_ciCache;
-
- int m_blobHeapIdxSz;
- int m_stringsHeapIdxSz;
- int m_guidHeapIdxSz;
-
- public MetadataRowReader (MetadataTableReader mtrv)
- {
- m_mtrv = mtrv;
- m_binaryReader = mtrv.GetReader ();
- m_metadataRoot = mtrv.GetMetadataRoot ();
- m_ciCache = new Hashtable ();
- }
-
- int GetIndexSize (int rid)
- {
- return m_mtrv.GetNumberOfRows (rid) < (1 << 16) ? 2 : 4;
- }
-
- int GetCodedIndexSize (CodedIndex ci)
- {
- return Utilities.GetCodedIndexSize (ci,
- new Utilities.TableRowCounter (m_mtrv.GetNumberOfRows), m_ciCache);
- }
-
- uint ReadByIndexSize (int size)
- {
- if (size == 2) {
- return (uint) m_binaryReader.ReadUInt16 ();
- } else if (size == 4) {
- return m_binaryReader.ReadUInt32 ();
- } else {
- throw new MetadataFormatException ("Non valid size for indexing");
- }
- }
-
- public override void VisitRowCollection (RowCollection coll)
- {
- m_blobHeapIdxSz = m_metadataRoot.Streams.BlobHeap != null ?
- m_metadataRoot.Streams.BlobHeap.IndexSize : 2;
- m_stringsHeapIdxSz = m_metadataRoot.Streams.StringsHeap != null ?
- m_metadataRoot.Streams.StringsHeap.IndexSize : 2;
- m_guidHeapIdxSz = m_metadataRoot.Streams.GuidHeap != null ?
- m_metadataRoot.Streams.GuidHeap.IndexSize : 2;
- }
-
-<% $tables.each { |table| %> public override void Visit<%=table.row_name%> (<%=table.row_name%> row)
- {
-<% table.columns.each { |col|
- if (col.target.nil?)
-%> row.<%=col.property_name%> = <%=col.read_binary("m_binaryReader")%>;
-<% elsif (col.target == "BlobHeap")
-%> row.<%=col.property_name%> = ReadByIndexSize (m_blobHeapIdxSz);
-<% elsif (col.target == "StringsHeap")
-%> row.<%=col.property_name%> = ReadByIndexSize (m_stringsHeapIdxSz);
-<% elsif (col.target == "GuidHeap")
-%> row.<%=col.property_name%> = ReadByIndexSize (m_guidHeapIdxSz);
-<% elsif (col.type == "MetadataToken")
-%> row.<%=col.property_name%> = Utilities.GetMetadataToken (CodedIndex.<%=col.target%>,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.<%=col.target%>)));
-<% else
-%> row.<%=col.property_name%> = ReadByIndexSize (GetIndexSize (<%=col.target%>Table.RId));
-<% end
-}%> }
-<% } %> }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataRowWriter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataRowWriter.cs
deleted file mode 100644
index 1ef6ddc..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataRowWriter.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-//
-// MetadataRowWriter.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// <%=Time.now%>
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Binary;
-
- class MetadataRowWriter : BaseMetadataRowVisitor {
-
- MetadataRoot m_root;
- MemoryBinaryWriter m_binaryWriter;
- IDictionary m_ciCache;
-
- int m_blobHeapIdxSz;
- int m_stringsHeapIdxSz;
- int m_guidHeapIdxSz;
-
- public MetadataRowWriter (MetadataTableWriter mtwv)
- {
- m_binaryWriter = mtwv.GetWriter ();
- m_root = mtwv.GetMetadataRoot ();
- m_ciCache = new Hashtable ();
- }
-
- void WriteBlobPointer (uint pointer)
- {
- WriteByIndexSize (pointer, m_blobHeapIdxSz);
- }
-
- void WriteStringPointer (uint pointer)
- {
- WriteByIndexSize (pointer, m_stringsHeapIdxSz);
- }
-
- void WriteGuidPointer (uint pointer)
- {
- WriteByIndexSize (pointer, m_guidHeapIdxSz);
- }
-
- void WriteTablePointer (uint pointer, int rid)
- {
- WriteByIndexSize (pointer, GetNumberOfRows (rid) < (1 << 16) ? 2 : 4);
- }
-
- void WriteMetadataToken (MetadataToken token, CodedIndex ci)
- {
- WriteByIndexSize (Utilities.CompressMetadataToken (ci, token),
- Utilities.GetCodedIndexSize (
- ci, new Utilities.TableRowCounter (GetNumberOfRows), m_ciCache));
- }
-
- int GetNumberOfRows (int rid)
- {
- IMetadataTable t = m_root.Streams.TablesHeap [rid];
- if (t == null || t.Rows == null)
- return 0;
- return t.Rows.Count;
- }
-
- void WriteByIndexSize (uint value, int size)
- {
- if (size == 4)
- m_binaryWriter.Write (value);
- else if (size == 2)
- m_binaryWriter.Write ((ushort) value);
- else
- throw new MetadataFormatException ("Non valid size for indexing");
- }
-
-<% $tables.each { |table|
- parameters = ""
- table.columns.each { |col|
- parameters += col.type
- parameters += " "
- parameters += col.field_name[1..col.field_name.length]
- parameters += ", " if (table.columns.last != col)
- }
-%> public <%=table.row_name%> Create<%=table.row_name%> (<%=parameters%>)
- {
- <%=table.row_name%> row = new <%=table.row_name%> ();
-<% table.columns.each { |col| %> row.<%=col.property_name%> = <%=col.field_name[1..col.field_name.length]%>;
-<% } %> return row;
- }
-
-<% } %> public override void VisitRowCollection (RowCollection coll)
- {
- m_blobHeapIdxSz = m_root.Streams.BlobHeap != null ?
- m_root.Streams.BlobHeap.IndexSize : 2;
- m_stringsHeapIdxSz = m_root.Streams.StringsHeap != null ?
- m_root.Streams.StringsHeap.IndexSize : 2;
- m_guidHeapIdxSz = m_root.Streams.GuidHeap != null ?
- m_root.Streams.GuidHeap.IndexSize : 2;
- }
-
-<% $tables.each { |table| %> public override void Visit<%=table.row_name%> (<%=table.row_name%> row)
- {
-<% table.columns.each { |col|
- if (col.target.nil?)
-%> <%=col.write_binary("row", "m_binaryWriter")%>;
-<% elsif (col.target == "BlobHeap")
-%> WriteBlobPointer (row.<%=col.property_name%>);
-<% elsif (col.target == "StringsHeap")
-%> WriteStringPointer (row.<%=col.property_name%>);
-<% elsif (col.target == "GuidHeap")
-%> WriteGuidPointer (row.<%=col.property_name%>);
-<% elsif (col.type == "MetadataToken")
-%> WriteMetadataToken (row.<%=col.property_name%>, CodedIndex.<%=col.target%>);
-<% else
-%> WriteTablePointer (row.<%=col.property_name%>, <%=col.target%>Table.RId);
-<% end
-}%> }
-
-<% } %> }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataTableReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataTableReader.cs
deleted file mode 100644
index 8f1effc..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataTableReader.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-//
-// MetadataTableReader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// <%=Time.now%>
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.Collections;
- using System.IO;
-
- class MetadataTableReader : BaseMetadataTableVisitor {
-
- MetadataRoot m_metadataRoot;
- TablesHeap m_heap;
- MetadataRowReader m_mrrv;
- BinaryReader m_binaryReader;
-
- int [] m_rows = new int [TablesHeap.MaxTableCount];
-
- public MetadataTableReader (MetadataReader mrv)
- {
- m_metadataRoot = mrv.GetMetadataRoot ();
- m_heap = m_metadataRoot.Streams.TablesHeap;
- m_binaryReader = new BinaryReader (new MemoryStream (m_heap.Data));
- m_binaryReader.BaseStream.Position = 24;
- m_mrrv = new MetadataRowReader (this);
- }
-
- public MetadataRoot GetMetadataRoot ()
- {
- return m_metadataRoot;
- }
-
- public BinaryReader GetReader ()
- {
- return m_binaryReader;
- }
-
- public override IMetadataRowVisitor GetRowVisitor ()
- {
- return m_mrrv;
- }
-
- public int GetNumberOfRows (int rid)
- {
- return m_rows [rid];
- }
-<% $tables.each { |table| %>
- public <%=table.table_name%> Get<%=table.table_name%> ()
- {
- return (<%=table.table_name%>) m_heap [<%=table.table_name%>.RId];
- }
-<% } %>
- public override void VisitTableCollection (TableCollection coll)
- {
-<% $stables.each { |table| %> if (m_heap.HasTable (<%=table.table_name%>.RId)) {
- coll.Add (new <%=table.table_name%> ());
- m_rows [<%=table.table_name%>.RId] = m_binaryReader.ReadInt32 ();
- }
-<% } %> }
-
-<% $tables.each { |table| %> public override void Visit<%=table.table_name%> (<%=table.table_name%> table)
- {
- int number = m_rows [<%=table.table_name%>.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new <%=table.row_name%> ());
- }
-<% } %> }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataTableWriter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataTableWriter.cs
deleted file mode 100644
index 8e03b27..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/MetadataTableWriter.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-//
-// MetadataTableWriter.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// <%=Time.now%>
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Binary;
-
- internal sealed class MetadataTableWriter : BaseMetadataTableVisitor {
-
- MetadataRoot m_root;
- TablesHeap m_heap;
- MetadataRowWriter m_mrrw;
- MemoryBinaryWriter m_binaryWriter;
-
- public MetadataTableWriter (MetadataWriter mrv, MemoryBinaryWriter writer)
- {
- m_root = mrv.GetMetadataRoot ();
- m_heap = m_root.Streams.TablesHeap;
- m_binaryWriter = writer;
- m_mrrw = new MetadataRowWriter (this);
- }
-
- public MetadataRoot GetMetadataRoot ()
- {
- return m_root;
- }
-
- public override IMetadataRowVisitor GetRowVisitor ()
- {
- return m_mrrw;
- }
-
- public MemoryBinaryWriter GetWriter ()
- {
- return m_binaryWriter;
- }
-
- void InitializeTable (IMetadataTable table)
- {
- table.Rows = new RowCollection ();
- m_heap.Valid |= 1L << table.Id;
- m_heap.Tables.Add (table);
- }
-
- void WriteCount (int rid)
- {
- if (m_heap.HasTable (rid))
- m_binaryWriter.Write (m_heap [rid].Rows.Count);
- }
-
-<% $tables.each { |table| %> public <%=table.table_name%> Get<%=table.table_name%> ()
- {
- <%=table.table_name%> table = m_heap [<%=table.table_name%>.RId] as <%=table.table_name%>;
- if (table != null)
- return table;
-
- table = new <%=table.table_name%> ();
- InitializeTable (table);
- return table;
- }
-
-<% } %> public override void VisitTableCollection (TableCollection coll)
- {
-<% $stables.each { |table| %> WriteCount (<%=table.table_name%>.RId);
-<% } %> }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/NamedCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/NamedCollection.cs
deleted file mode 100644
index 64e48de..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/NamedCollection.cs
+++ /dev/null
@@ -1,232 +0,0 @@
-//
-// <%=$cur_coll.name%>.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// <%=Time.now%>
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-<%
-def use_event?()
- case $cur_coll.name
- when "TypeDefinitionCollection", "TypeReferenceCollection", "ExternTypeCollection"
- return true
- end
-
- return false
-end
-%>
-namespace <%=$cur_coll.target%> {
-
- using System;
- using System.Collections;
- using System.Collections.Specialized;
-
- using Mono.Cecil.Cil;
-
- using Hcp = Mono.Cecil.HashCodeProvider;
- using Cmp = System.Collections.Comparer;
-
- public sealed class <%=$cur_coll.name%> : NameObjectCollectionBase, IList<% if (!$cur_coll.visitable.nil?) then %>, <%=$cur_coll.visitable%><% end %> {
-
- <%=$cur_coll.container%> m_container;
-
- public <%=$cur_coll.type%> this [int index] {
- get { return this.BaseGet (index) as <%=$cur_coll.type%>; }
- set { this.BaseSet (index, value); }
- }
-
- public <%=$cur_coll.type%> this [string fullName] {
- get { return this.BaseGet (fullName) as <%=$cur_coll.type%>; }
- set { this.BaseSet (fullName, value); }
- }
-
- public <%=$cur_coll.container%> Container {
- get { return m_container; }
- }
-
- public bool IsSynchronized {
- get { return false; }
- }
-
- public object SyncRoot {
- get { return this; }
- }
-
- bool IList.IsReadOnly {
- get { return false; }
- }
-
- bool IList.IsFixedSize {
- get { return false; }
- }
-
- object IList.this [int index] {
- get { return BaseGet (index); }
- set {
- Check (value);
- BaseSet (index, value);
- }
- }
-
- public <%=$cur_coll.name%> (<%=$cur_coll.container%> container) :
- base (Hcp.Instance, Cmp.Default)
- {
- m_container = container;
- }
-
- public void Add (<%=$cur_coll.type%> value)
- {
- if (value == null)
- throw new ArgumentNullException ("value");
-
- <% if use_event?() %>Attach (value);<% end %>
-
- this.BaseAdd (value.FullName, value);
- }
-
- public void Clear ()
- {<%
- if use_event?() %>
- foreach (<%=$cur_coll.type%> item in this)
- Detach (item);
-<% end %>
- this.BaseClear ();
- }
-
- public bool Contains (<%=$cur_coll.type%> value)
- {
- return Contains (value.FullName);
- }
-
- public bool Contains (string fullName)
- {
- return this.BaseGet (fullName) != null;
- }
-
- public int IndexOf (<%=$cur_coll.type%> value)
- {
- string [] keys = this.BaseGetAllKeys ();
- return Array.IndexOf (keys, value.FullName, 0, keys.Length);
- }
-
- public void Remove (<%=$cur_coll.type%> value)
- {
- this.BaseRemove (value.FullName);
-<% if use_event?() %>
- Detach (value);
-<% end %> }
-
- public void RemoveAt (int index)
- {
- <%=$cur_coll.type%> item = this [index];
- Remove (item);
-<% if use_event?() %>
- Detach (item);
-<% end %> }
-
- public void CopyTo (Array ary, int index)
- {
- this.BaseGetAllValues ().CopyTo (ary, index);
- }
-
- public new IEnumerator GetEnumerator ()
- {
- return this.BaseGetAllValues ().GetEnumerator ();
- }
-<% if !$cur_coll.visitor.nil? then %>
- public void Accept (<%=$cur_coll.visitor%> visitor)
- {
- visitor.<%=$cur_coll.visitThis%> (this);
- }
-<% end %>
-#if CF_1_0 || CF_2_0
- internal object [] BaseGetAllValues ()
- {
- object [] values = new object [this.Count];
- for (int i=0; i < values.Length; ++i) {
- values [i] = this.BaseGet (i);
- }
- return values;
- }
-#endif
-
- void Check (object value)
- {
- if (!(value is <%=$cur_coll.type%>))
- throw new ArgumentException ();
- }
-
- int IList.Add (object value)
- {
- Check (value);
- Add (value as <%=$cur_coll.type%>);
- return 0;
- }
-
- bool IList.Contains (object value)
- {
- Check (value);
- return Contains (value as <%=$cur_coll.type%>);
- }
-
- int IList.IndexOf (object value)
- {
- throw new NotSupportedException ();
- }
-
- void IList.Insert (int index, object value)
- {
- throw new NotSupportedException ();
- }
-
- void IList.Remove (object value)
- {
- Check (value);
- Remove (value as <%=$cur_coll.type%>);
- }
-<%
- if use_event?()
-%>
- void Detach (TypeReference type)
- {
- type.Module = null;
- }
-
- void Attach (TypeReference type)
- {
- if (type.Module != null)
- throw new ReflectionException ("Type is already attached, clone it instead");
-
- type.Module = m_container;<%
- if $cur_coll.type == "TypeDefinition" %>
- type.AttachToScope (m_container);
-<% end %>
- }<%
-
- end
-%>
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/OpCodes.cs b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/OpCodes.cs
deleted file mode 100644
index 5fc727d..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/OpCodes.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-//
-// OpCodes.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// <%=Time.now%>
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-<%
- oboc = Array.new
- tboc = Array.new
- $ops.each { |op|
- if op.op1 == "0xff"
- oboc.push(op)
- else
- tboc.push(op)
- end
- }
-%>
-namespace Mono.Cecil.Cil {
-
- public sealed class OpCodes {
-
- internal static readonly OpCode [] OneByteOpCode = new OpCode [<%=oboc[oboc.length - 1].op2%> + 1];
- internal static readonly OpCode [] TwoBytesOpCode = new OpCode [<%=tboc[tboc.length - 1].op2%> + 1];
-
-<% $ops.each { |op| %> public static readonly OpCode <%=op.field_name%> = new OpCode (
- "<%=op.name%>", <%=op.op1%>, <%=op.op2%>, <%=op.size%>,
- Code.<%=op.field_name%>, <%=op.flowcontrol%>,
- <%=op.opcodetype%>, <%=op.operandtype%>,
- <%=op.stackbehaviourpop%>, <%=op.stackbehaviourpush%>);
-
-<% } %> OpCodes()
- {
- }
-
- public static OpCode GetOpCode (Code code)
- {
- switch (code) {
-<% $ops.each { |op| %> case Code.<%=op.field_name%> : return OpCodes.<%=op.field_name%>;
-<% } %> default : return OpCodes.Nop;
- }
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Table.cs b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Table.cs
deleted file mode 100644
index 17ea97b..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Table.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-//
-// <%=$cur_table.table_name%>.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// <%=Time.now%>
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-<% $cur_table.ref_ns.each { |ns| %>
- using <%=ns%>;
-<% }
-%>
- public sealed class <%=$cur_table.table_name%> : IMetadataTable {
-
- public const int RId = <%=$cur_table.rid%>;
-
- RowCollection m_rows;
-
- public <%=$cur_table.row_name%> this [int index] {
- get { return m_rows [index] as <%=$cur_table.row_name%>; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal <%=$cur_table.table_name%> ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.Visit<%=$cur_table.table_name%> (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class <%=$cur_table.row_name%> : IMetadataRow {
-
-<% $cur_table.columns.each { |col| %> public <%=col.type%> <%=col.property_name%>;
-<% } %>
- internal <%=$cur_table.row_name%> ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.Visit<%=$cur_table.row_name%> (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Tests.cs b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Tests.cs
deleted file mode 100644
index 0cd4e3c..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Tests.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-//
-// Tests.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen-tests.rb do not edit
-// <%=Time.now%>
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Tests {
-
- using System;
- using System.IO;
- using System.Collections;
-
- using NUnit.Framework;
-
- using Mono.Cecil;
-
- class Language {
-
- string m_compiler;
- string m_command;
-
- public string Compiler {
- get { return m_compiler; }
- }
-
- public string Command {
- get { return m_command; }
- }
-
- public Language (string compiler, string command)
- {
- m_compiler = compiler;
- m_command = command;
- }
-
- static IDictionary m_languages = new Hashtable ();
-
- static Language ()
- {
-<%
- $languages.each { |l|
-%>
- m_languages.Add ("<%= l.name %>", new Language (
- "<%= l.compiler %>",
- "<%= l.command %>"
- ));
-<%
- }
-%>
- }
-
- public static Language GetLanguage (string name)
- {
- return (Language) m_languages [name];
- }
- }
-
- class TestCase {
-
- Language m_lang;
- FileInfo m_file;
-
- public TestCase (Language lang, string file)
- {
- m_lang = lang;
- m_file = new FileInfo (file);
- }
- }
-
- [TestFixture]
- class GeneratedTests {
-
- void Test (TestCase test)
- {
- }
-
-<%
- $tests.each { |test|
-%>
- [Test]
- public void <%= test.method %> ()
- {
- Test (new TestCase (
- Language.GetLanguage ("<%= test.lang.name %>"),
- @"<%= test.file %>"));
- }
-<%
- }
-%>
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Utilities.cs b/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Utilities.cs
deleted file mode 100644
index 89f732a..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/CodeGen/templates/Utilities.cs
+++ /dev/null
@@ -1,211 +0,0 @@
-//
-// Utilities.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// <%=Time.now%>
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.Collections;
- using System.IO;
-
- class Utilities {
-
- Utilities ()
- {
- }
-
- public static int ReadCompressedInteger (byte [] data, int pos, out int start)
- {
- int integer = 0;
- start = pos;
- if ((data [pos] & 0x80) == 0) {
- integer = data [pos];
- start++;
- } else if ((data [pos] & 0x40) == 0) {
- integer = (data [start] & ~0x80) << 8;
- integer |= data [pos + 1];
- start += 2;
- } else {
- integer = (data [start] & ~0xc0) << 24;
- integer |= data [pos + 1] << 16;
- integer |= data [pos + 2] << 8;
- integer |= data [pos + 3];
- start += 4;
- }
- return integer;
- }
-
- public static int WriteCompressedInteger (BinaryWriter writer, int value)
- {
- if (value < 0x80)
- writer.Write ((byte) value);
- else if (value < 0x4000) {
- writer.Write ((byte) (0x80 | (value >> 8)));
- writer.Write ((byte) (value & 0xff));
- } else {
- writer.Write ((byte) ((value >> 24) | 0xc0));
- writer.Write ((byte) ((value >> 16) & 0xff));
- writer.Write ((byte) ((value >> 8) & 0xff));
- writer.Write ((byte) (value & 0xff));
- }
- return (int) writer.BaseStream.Position;
- }
-
- public static MetadataToken GetMetadataToken (CodedIndex cidx, uint data)
- {
- uint rid = 0;
- switch (cidx) {
-<% $coded_indexes.each { |ci| %> case CodedIndex.<%=ci.name%> :
- rid = data >> <%=ci.size%>;
- switch (data & <%=(2 ** ci.size.to_i - 1).to_s%>) {
-<% ci.tables.each { |tbl|
- name = tbl.name
- if (name == "DeclSecurity")
- name = "Permission"
- elsif (name == "StandAloneSig")
- name = "Signature"
- end
-%> case <%=tbl.tag%> :
- return new MetadataToken (TokenType.<%=name%>, rid);
-<% }
-%> default :
- return MetadataToken.Zero;
- }
-<% } %> default :
- return MetadataToken.Zero;
- }
- }
-
- public static uint CompressMetadataToken (CodedIndex cidx, MetadataToken token)
- {
- uint ret = 0;
- if (token.RID == 0)
- return ret;
- switch (cidx) {
-<% $coded_indexes.each { |ci| %> case CodedIndex.<%=ci.name%> :
- ret = token.RID << <%=ci.size%>;
- switch (token.TokenType) {
-<% ci.tables.each { |tbl|
- name = tbl.name
- if (name == "DeclSecurity")
- name = "Permission"
- elsif (name == "StandAloneSig")
- name = "Signature"
- end
-%> case TokenType.<%=name%> :
- return ret | <%=tbl.tag%>;
-<% }
-%> default :
- throw new MetadataFormatException("Non valid Token for <%=ci.name%>");
- }
-<% } %> default :
- throw new MetadataFormatException ("Non valid CodedIndex");
- }
- }
-
- internal static Type GetCorrespondingTable (TokenType t)
- {
- switch (t) {
- case TokenType.Assembly :
- return typeof (AssemblyTable);
- case TokenType.AssemblyRef :
- return typeof (AssemblyRefTable);
- case TokenType.CustomAttribute :
- return typeof (CustomAttributeTable);
- case TokenType.Event :
- return typeof (EventTable);
- case TokenType.ExportedType :
- return typeof (ExportedTypeTable);
- case TokenType.Field :
- return typeof (FieldTable);
- case TokenType.File :
- return typeof (FileTable);
- case TokenType.InterfaceImpl :
- return typeof (InterfaceImplTable);
- case TokenType.MemberRef :
- return typeof (MemberRefTable);
- case TokenType.Method :
- return typeof (MethodTable);
- case TokenType.Module :
- return typeof (ModuleTable);
- case TokenType.ModuleRef :
- return typeof (ModuleRefTable);
- case TokenType.Param :
- return typeof (ParamTable);
- case TokenType.Permission :
- return typeof (DeclSecurityTable);
- case TokenType.Property :
- return typeof (PropertyTable);
- case TokenType.Signature :
- return typeof (StandAloneSigTable);
- case TokenType.TypeDef :
- return typeof (TypeDefTable);
- case TokenType.TypeRef :
- return typeof (TypeRefTable);
- case TokenType.TypeSpec :
- return typeof (TypeSpecTable);
- default :
- return null;
- }
- }
-
- internal delegate int TableRowCounter (int rid);
-
- internal static int GetCodedIndexSize (CodedIndex ci, TableRowCounter rowCounter, IDictionary codedIndexCache)
- {
- int bits = 0, max = 0;
- if (codedIndexCache [ci] != null)
- return (int) codedIndexCache [ci];
-
- int res = 0;
- int [] rids;
- switch (ci) {
-<% $coded_indexes.each { |ci| %> case CodedIndex.<%=ci.name%> :
- bits = <%=ci.size%>;
- rids = new int [<%=ci.tables.length%>];
-<% ci.tables.each_with_index { |tbl, i|
-%> rids [<%=i%>] = <%=tbl.name%>Table.RId;
-<% }
-%> break;
-<% } %> default :
- throw new MetadataFormatException ("Non valid CodedIndex");
- }
-
- for (int i = 0; i < rids.Length; i++) {
- int rows = rowCounter (rids [i]);
- if (rows > max) max = rows;
- }
-
- res = max < (1 << (16 - bits)) ? 2 : 4;
- codedIndexCache [ci] = res;
- return res;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Makefile b/Mono.Addins.CecilReflector/Mono.Cecil/Makefile
deleted file mode 100644
index 2277b72..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-thisdir = class/Mono.Cecil
-include ../../build/rules.make
-
-LIBRARY = Mono.Cecil.dll
-LIBRARY_SNK = ../mono.snk
-LIBRARY_PACKAGE = none
-
-LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll -keyfile:$(LIBRARY_SNK)
-
-NO_TEST = yes
-
-include ../../build/library.make
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/BaseImageVisitor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/BaseImageVisitor.cs
deleted file mode 100644
index 610c0be..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/BaseImageVisitor.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-//
-// BaseImageVisitor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 - 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public abstract class BaseImageVisitor : IBinaryVisitor {
-
- public virtual void VisitImage (Image img)
- {
- }
-
- public virtual void VisitDOSHeader (DOSHeader header)
- {
- }
-
- public virtual void VisitPEFileHeader (PEFileHeader header)
- {
- }
-
- public virtual void VisitPEOptionalHeader (PEOptionalHeader header)
- {
- }
-
- public virtual void VisitStandardFieldsHeader (PEOptionalHeader.StandardFieldsHeader header)
- {
- }
-
- public virtual void VisitNTSpecificFieldsHeader (PEOptionalHeader.NTSpecificFieldsHeader header)
- {
- }
-
- public virtual void VisitDataDirectoriesHeader (PEOptionalHeader.DataDirectoriesHeader header)
- {
- }
-
- public virtual void VisitSectionCollection (SectionCollection coll)
- {
- }
-
- public virtual void VisitSection (Section section)
- {
- }
-
- public virtual void VisitImportAddressTable (ImportAddressTable iat)
- {
- }
-
- public virtual void VisitDebugHeader (DebugHeader dh)
- {
- }
-
- public virtual void VisitCLIHeader (CLIHeader header)
- {
- }
-
- public virtual void VisitImportTable (ImportTable it)
- {
- }
-
- public virtual void VisitImportLookupTable (ImportLookupTable ilt)
- {
- }
-
- public virtual void VisitHintNameTable (HintNameTable hnt)
- {
- }
-
- public virtual void VisitExportTable (ExportTable et)
- {
- }
-
- public virtual void TerminateImage (Image img)
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CLIHeader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CLIHeader.cs
deleted file mode 100644
index f92198e..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CLIHeader.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-//
-// CLIHeader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public sealed class CLIHeader : IHeader, IBinaryVisitable {
-
- public uint Cb;
- public ushort MajorRuntimeVersion;
- public ushort MinorRuntimeVersion;
- public DataDirectory Metadata;
- public RuntimeImage Flags;
- public uint EntryPointToken;
- public DataDirectory Resources;
- public DataDirectory StrongNameSignature;
- public DataDirectory CodeManagerTable;
- public DataDirectory VTableFixups;
- public DataDirectory ExportAddressTableJumps;
- public DataDirectory ManagedNativeHeader;
-
- public byte [] ImageHash;
-
- internal CLIHeader ()
- {
- }
-
- public void SetDefaultValues ()
- {
- Cb = 0x48;
- MajorRuntimeVersion = 2;
- MinorRuntimeVersion = 0;
- Flags = RuntimeImage.ILOnly;
- CodeManagerTable = DataDirectory.Zero;
- ExportAddressTableJumps = DataDirectory.Zero;
- ManagedNativeHeader = DataDirectory.Zero;
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitCLIHeader (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CopyImageVisitor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CopyImageVisitor.cs
deleted file mode 100644
index 864fe45..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/CopyImageVisitor.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-//
-// CopyImageVisitor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- class CopyImageVisitor : BaseImageVisitor {
-
- Image m_newImage;
- Image m_originalImage;
-
- public CopyImageVisitor (Image originalImage)
- {
- m_originalImage = originalImage;
- }
-
- public override void VisitImage (Image img)
- {
- m_newImage = img;
- if (m_originalImage.DebugHeader != null)
- m_newImage.AddDebugHeader ();
- }
-
- public override void VisitDebugHeader (DebugHeader dbgHeader)
- {
- DebugHeader old = m_originalImage.DebugHeader;
- dbgHeader.Age = old.Age;
- dbgHeader.Characteristics = old.Characteristics;
- dbgHeader.FileName = old.FileName;
- dbgHeader.Signature = old.Signature;
- dbgHeader.TimeDateStamp = ImageInitializer.TimeDateStampFromEpoch();
- dbgHeader.Type = old.Type;
- }
-
- public override void VisitSectionCollection (SectionCollection sections)
- {
- Section old = null;
- foreach (Section s in m_originalImage.Sections)
- if (s.Name == Section.Resources)
- old = s;
-
- if (old == null)
- return;
-
- Section rsrc = new Section ();
- rsrc.Characteristics = old.Characteristics;
- rsrc.Name = old.Name;
-
- sections.Add (rsrc);
- }
-
- public override void TerminateImage (Image img)
- {
- if (m_originalImage.ResourceDirectoryRoot == null)
- return;
-
- m_newImage.ResourceDirectoryRoot = CloneResourceDirectoryTable (m_originalImage.ResourceDirectoryRoot);
- }
-
- ResourceDirectoryTable CloneResourceDirectoryTable (ResourceDirectoryTable old)
- {
- ResourceDirectoryTable rdt = new ResourceDirectoryTable ();
- foreach (ResourceDirectoryEntry oldEntry in old.Entries)
- rdt.Entries.Add (CloneResourceDirectoryEntry (oldEntry));
-
- return rdt;
- }
-
- ResourceDirectoryEntry CloneResourceDirectoryEntry (ResourceDirectoryEntry old)
- {
- ResourceDirectoryEntry rde;
- if (old.IdentifiedByName)
- rde = new ResourceDirectoryEntry(old.Name);
- else
- rde = new ResourceDirectoryEntry (old.ID);
-
- if (old.Child is ResourceDirectoryTable)
- rde.Child = CloneResourceDirectoryTable (old.Child as ResourceDirectoryTable);
- else
- rde.Child = CloneResourceDataEntry (old.Child as ResourceDataEntry);
-
- return rde;
- }
-
- ResourceDataEntry CloneResourceDataEntry (ResourceDataEntry old)
- {
- ResourceDataEntry rde = new ResourceDataEntry ();
- rde.Size = old.Size;
- rde.Codepage = old.Codepage;
- rde.ResourceData = old.ResourceData;
-
- return rde;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DOSHeader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DOSHeader.cs
deleted file mode 100644
index 8515433..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DOSHeader.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-// DOSHeader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public sealed class DOSHeader : IHeader, IBinaryVisitable {
-
- public byte [] Start;
- public byte [] End;
-
- public uint Lfanew;
-
- internal DOSHeader ()
- {
- }
-
- public void SetDefaultValues ()
- {
- Start = new byte [60] {
- 0x4d, 0x5a, 0x90, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff,
- 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00
- };
- Lfanew = 128;
- End = new byte [64] {
- 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09,
- 0xcd, 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21,
- 0x54, 0x68, 0x69, 0x73, 0x20, 0x70, 0x72,
- 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x20, 0x63,
- 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x20, 0x62,
- 0x65, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x69,
- 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, 0x6d,
- 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a,
- 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00
- };
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitDOSHeader (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DataDirectory.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DataDirectory.cs
deleted file mode 100644
index 9762423..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DataDirectory.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-//
-// DataDirectory.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- using Mono.Cecil.Metadata;
-
- public struct DataDirectory {
-
- public static readonly DataDirectory Zero = new DataDirectory(RVA.Zero, 0);
-
- RVA m_virtualAddress;
- uint m_size;
-
- public RVA VirtualAddress {
- get { return m_virtualAddress; }
- set { m_virtualAddress = value; }
- }
-
- public uint Size {
- get { return m_size; }
- set { m_size = value; }
- }
-
- public DataDirectory (RVA virtualAddress, uint size)
- {
- m_virtualAddress = virtualAddress;
- m_size = size;
- }
-
- public override int GetHashCode ()
- {
- return (m_virtualAddress.GetHashCode () ^ (int) m_size << 1);
- }
-
- public override bool Equals (object other)
- {
- if (other is DataDirectory) {
- DataDirectory odd = (DataDirectory)other;
- return (this.m_virtualAddress == odd.m_virtualAddress &&
- this.m_size == odd.m_size);
- }
- return false;
- }
-
- public override string ToString ()
- {
- return string.Format ("{0} [{1}]",
- m_virtualAddress.ToString (), m_size.ToString ("X"));
- }
-
- public static bool operator == (DataDirectory one, DataDirectory other)
- {
- return one.Equals (other);
- }
-
- public static bool operator != (DataDirectory one, DataDirectory other)
- {
- return !one.Equals (other);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugHeader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugHeader.cs
deleted file mode 100644
index ae4d436..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugHeader.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-// DebugHeader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- using System;
-
- public sealed class DebugHeader : IHeader, IBinaryVisitable {
-
- public uint Characteristics;
- public uint TimeDateStamp;
- public ushort MajorVersion;
- public ushort MinorVersion;
- public DebugStoreType Type;
- public uint SizeOfData;
- public RVA AddressOfRawData;
- public uint PointerToRawData;
-
- public uint Magic;
- public Guid Signature;
- public uint Age;
- public string FileName;
-
- internal DebugHeader ()
- {
- }
-
- public void SetDefaultValues ()
- {
- Characteristics = 0;
-
- this.Magic = 0x53445352;
- this.Age = 0;
- this.Type = DebugStoreType.CodeView;
- this.FileName = string.Empty;
- }
-
- public uint GetSize ()
- {
- return 0x34 + (uint) FileName.Length + 1;
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitDebugHeader (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugStoreType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugStoreType.cs
deleted file mode 100644
index ad9ba97..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/DebugStoreType.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// DebugStoreType.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public enum DebugStoreType : uint {
- Unknown = 0x00000000,
- COFF = 0x00000001,
- CodeView = 0x00000002,
- FPO = 0x00000003,
- Misc = 0x00000004,
- Exception = 0x00000005,
- Fixup = 0x00000006,
- OMAPToSrc = 0x00000007,
- OMAPFromSrc = 0x00000008,
- Borland = 0x00000009,
- Reserved10 = 0x0000000a,
- CLSID = 0x0000000b
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ExportTable.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ExportTable.cs
deleted file mode 100644
index 5032e55..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ExportTable.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-//
-// ExportTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public sealed class ExportTable : IBinaryVisitable {
-
- public uint Characteristics;
- public uint TimeDateStamp;
- public ushort MajorVersion;
- public ushort MinorVersion;
- public string Name;
- public uint Base;
- public uint NumberOfFunctions;
- public uint NumberOfNames;
- public RVA AddressOfFunctions;
- public RVA AddressOfNames;
- public RVA AddressOfNameOrdinals;
-
- public RVA [] AddressesOfFunctions;
- public RVA [] AddressesOfNames;
- public ushort [] NameOrdinals;
- public string [] Names;
-
- internal ExportTable ()
- {
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitExportTable (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitable.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitable.cs
deleted file mode 100644
index 0d3729e..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitable.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// IBinaryVisitable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public interface IBinaryVisitable {
- void Accept (IBinaryVisitor visitor);
- }
-}
-
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitor.cs
deleted file mode 100644
index 5b24836..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IBinaryVisitor.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-//
-// IBinaryVisitor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 - 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public interface IBinaryVisitor {
- void VisitImage (Image img);
- void VisitDOSHeader (DOSHeader header);
- void VisitPEFileHeader (PEFileHeader header);
- void VisitPEOptionalHeader (PEOptionalHeader header);
- void VisitStandardFieldsHeader (PEOptionalHeader.StandardFieldsHeader header);
- void VisitNTSpecificFieldsHeader (PEOptionalHeader.NTSpecificFieldsHeader header);
- void VisitDataDirectoriesHeader (PEOptionalHeader.DataDirectoriesHeader header);
- void VisitSectionCollection (SectionCollection coll);
- void VisitSection (Section section);
- void VisitImportAddressTable (ImportAddressTable iat);
- void VisitDebugHeader (DebugHeader dh);
- void VisitCLIHeader (CLIHeader header);
- void VisitImportTable (ImportTable it);
- void VisitImportLookupTable (ImportLookupTable ilt);
- void VisitHintNameTable (HintNameTable hnt);
- void VisitExportTable (ExportTable et);
-
- void TerminateImage (Image img);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IHeader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IHeader.cs
deleted file mode 100644
index 54f157d..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/IHeader.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-//
-// IHeader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- internal interface IHeader {
- void SetDefaultValues ();
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Image.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Image.cs
deleted file mode 100644
index fdd0200..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Image.cs
+++ /dev/null
@@ -1,236 +0,0 @@
-//
-// Image.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 - 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- using System;
- using System.IO;
-
- using Mono.Cecil.Metadata;
-
- public sealed class Image : IBinaryVisitable {
-
- DOSHeader m_dosHeader;
- PEFileHeader m_peFileHeader;
- PEOptionalHeader m_peOptionalHeader;
-
- SectionCollection m_sections;
- Section m_textSection;
-
- ImportAddressTable m_importAddressTable;
- CLIHeader m_cliHeader;
- ImportTable m_importTable;
- ImportLookupTable m_importLookupTable;
- HintNameTable m_hintNameTable;
- ExportTable m_exportTable;
-
- DebugHeader m_debugHeader;
- MetadataRoot m_mdRoot;
-
- ResourceDirectoryTable m_rsrcRoot;
-
- FileInfo m_img;
-
- public DOSHeader DOSHeader {
- get { return m_dosHeader; }
- }
-
- public PEFileHeader PEFileHeader {
- get { return m_peFileHeader; }
- }
-
- public PEOptionalHeader PEOptionalHeader {
- get { return m_peOptionalHeader; }
- }
-
- public SectionCollection Sections {
- get { return m_sections; }
- }
-
- public Section TextSection {
- get { return m_textSection; }
- set { m_textSection = value; }
- }
-
- public ImportAddressTable ImportAddressTable {
- get { return m_importAddressTable; }
- }
-
- public CLIHeader CLIHeader {
- get { return m_cliHeader; }
- set { m_cliHeader = value; }
- }
-
- public DebugHeader DebugHeader {
- get { return m_debugHeader; }
- set { m_debugHeader = value; }
- }
-
- public MetadataRoot MetadataRoot {
- get { return m_mdRoot; }
- }
-
- public ImportTable ImportTable {
- get { return m_importTable; }
- }
-
- public ImportLookupTable ImportLookupTable {
- get { return m_importLookupTable; }
- }
-
- public HintNameTable HintNameTable {
- get { return m_hintNameTable; }
- }
-
- public ExportTable ExportTable {
- get { return m_exportTable; }
- set { m_exportTable = value; }
- }
-
- internal ResourceDirectoryTable ResourceDirectoryRoot {
- get { return m_rsrcRoot; }
- set { m_rsrcRoot = value; }
- }
-
- public FileInfo FileInformation {
- get { return m_img; }
- }
-
- internal Image ()
- {
- m_dosHeader = new DOSHeader ();
- m_peFileHeader = new PEFileHeader ();
- m_peOptionalHeader = new PEOptionalHeader ();
- m_sections = new SectionCollection ();
- m_importAddressTable = new ImportAddressTable ();
- m_importTable = new ImportTable ();
- m_importLookupTable = new ImportLookupTable ();
- m_hintNameTable = new HintNameTable ();
- m_mdRoot = new MetadataRoot (this);
- }
-
- internal Image (FileInfo img) : this ()
- {
- m_img = img;
- }
-
- public long ResolveVirtualAddress (RVA rva)
- {
- foreach (Section sect in this.Sections) {
- if (rva >= sect.VirtualAddress &&
- rva < sect.VirtualAddress + sect.SizeOfRawData)
-
- return rva + sect.PointerToRawData - sect.VirtualAddress;
- }
-
- throw new ArgumentOutOfRangeException ("Cannot map the rva to any section");
- }
-
- public BinaryReader GetReaderAtVirtualAddress (RVA rva)
- {
- foreach (Section sect in this.Sections) {
- if (rva >= sect.VirtualAddress &&
- rva < sect.VirtualAddress + sect.SizeOfRawData) {
-
- BinaryReader br = new BinaryReader (new MemoryStream (sect.Data));
- br.BaseStream.Position = rva - sect.VirtualAddress;
- return br;
- }
- }
-
- return null;
- }
-
- public void AddDebugHeader ()
- {
- m_debugHeader = new DebugHeader ();
- m_debugHeader.SetDefaultValues ();
- }
-
- internal void SetFileInfo (FileInfo file)
- {
- m_img = file;
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitImage (this);
-
- m_dosHeader.Accept (visitor);
- m_peFileHeader.Accept (visitor);
- m_peOptionalHeader.Accept (visitor);
-
- m_sections.Accept (visitor);
-
- m_importAddressTable.Accept (visitor);
-
- AcceptIfNotNull (m_cliHeader, visitor);
- AcceptIfNotNull (m_debugHeader, visitor);
-
- m_importTable.Accept (visitor);
- m_importLookupTable.Accept (visitor);
- m_hintNameTable.Accept (visitor);
- AcceptIfNotNull (m_exportTable, visitor);
-
- visitor.TerminateImage (this);
- }
-
- static void AcceptIfNotNull (IBinaryVisitable visitable, IBinaryVisitor visitor)
- {
- if (visitable == null)
- return;
-
- visitable.Accept (visitor);
- }
-
- public static Image CreateImage ()
- {
- Image img = new Image ();
-
- ImageInitializer init = new ImageInitializer (img);
- img.Accept (init);
-
- return img;
- }
-
- public static Image GetImage (string file)
- {
- return ImageReader.Read (file).Image;
- }
-
- public static Image GetImage (byte [] image)
- {
- return ImageReader.Read (image).Image;
- }
-
- public static Image GetImage (Stream stream)
- {
- return ImageReader.Read (stream).Image;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageCharacteristics.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageCharacteristics.cs
deleted file mode 100644
index 278b75d..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageCharacteristics.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-// ImageCharacteristics.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- using System;
-
- [Flags]
- public enum ImageCharacteristics : ushort {
- RelocsStripped = 0x0001,
- ExecutableImage = 0x0002,
- LineNumsStripped = 0x0004,
- LocalSymsStripped = 0x0008,
- AggressiveWSTrim = 0x0010,
- LargeAddressAware = 0x0020,
- ReservedForFutureUse = 0x0040,
- BytesReversedLo = 0x0080,
- _32BitsMachine = 0x0100,
- DebugStripped = 0x0200,
- RemovableRunFromSwap = 0x0400,
- NetRunFromSwap = 0x0800,
- System = 0x1000,
- Dll = 0x2000,
- UPSystemOnly = 0x4000,
- BytesReversedHI = 0x8000,
-
- __flags = 0x0002 | 0x0004 | 0x0008 | 0x0100,
-
- CILOnlyDll = 0x2000 | (ushort) __flags,
- CILOnlyExe = __flags
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageFormatException.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageFormatException.cs
deleted file mode 100644
index 1592233..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageFormatException.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// ImageFormatException.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- using System;
-
- public class ImageFormatException : Exception {
-
- internal ImageFormatException () : base()
- {
- }
-
- internal ImageFormatException (string message) : base(message)
- {
- }
-
- internal ImageFormatException (string message, params string[] parameters) :
- base(string.Format(message, parameters))
- {
- }
-
- internal ImageFormatException (string message, Exception inner) :
- base(message, inner)
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs
deleted file mode 100644
index 8424ed1..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageInitializer.cs
+++ /dev/null
@@ -1,139 +0,0 @@
-//
-// ImageInitializer.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- using System;
-
- using Mono.Cecil.Metadata;
-
- class ImageInitializer : BaseImageVisitor {
-
- Image m_image;
- MetadataInitializer m_mdinit;
-
- public Image Image {
- get { return m_image; }
- }
-
- public MetadataInitializer Metadata {
- get { return m_mdinit; }
- }
-
- public ImageInitializer (Image image)
- {
- m_image = image;
- m_image.CLIHeader = new CLIHeader ();
- m_mdinit = new MetadataInitializer (this);
- }
-
- public override void VisitDOSHeader (DOSHeader header)
- {
- header.SetDefaultValues ();
- }
-
- public override void VisitPEOptionalHeader (PEOptionalHeader header)
- {
- header.SetDefaultValues ();
- }
-
- public override void VisitPEFileHeader (PEFileHeader header)
- {
- header.SetDefaultValues ();
- header.TimeDateStamp = TimeDateStampFromEpoch ();
- }
-
- public override void VisitNTSpecificFieldsHeader (PEOptionalHeader.NTSpecificFieldsHeader header)
- {
- header.SetDefaultValues ();
- }
-
- public override void VisitStandardFieldsHeader (PEOptionalHeader.StandardFieldsHeader header)
- {
- header.SetDefaultValues ();
- }
-
- public override void VisitDataDirectoriesHeader (PEOptionalHeader.DataDirectoriesHeader header)
- {
- header.SetDefaultValues ();
- }
-
- public override void VisitSectionCollection (SectionCollection coll)
- {
- Section text = new Section ();
- text.Name = Section.Text;
- text.Characteristics = SectionCharacteristics.ContainsCode |
- SectionCharacteristics.MemoryRead | SectionCharacteristics.MemExecute;
- m_image.TextSection = text;
-
- Section reloc = new Section ();
- reloc.Name = Section.Relocs;
- reloc.Characteristics = SectionCharacteristics.ContainsInitializedData |
- SectionCharacteristics.MemDiscardable | SectionCharacteristics.MemoryRead;
-
- coll.Add (text);
- coll.Add (reloc);
- }
-
- public override void VisitSection (Section sect)
- {
- sect.SetDefaultValues ();
- }
-
- public override void VisitDebugHeader (DebugHeader dh)
- {
- if (dh != null)
- dh.SetDefaultValues ();
- }
-
- public override void VisitCLIHeader (CLIHeader header)
- {
- header.SetDefaultValues ();
- m_image.MetadataRoot.Accept (m_mdinit);
- }
-
- public override void VisitImportTable (ImportTable it)
- {
- it.ImportAddressTable = new RVA (0x2000);
- }
-
- public override void VisitHintNameTable (HintNameTable hnt)
- {
- hnt.Hint = 0;
- hnt.RuntimeLibrary = HintNameTable.RuntimeCorEE;
- hnt.EntryPoint = 0x25ff;
- hnt.RVA = new RVA (0x402000);
- }
-
- public static uint TimeDateStampFromEpoch ()
- {
- return (uint) DateTime.UtcNow.Subtract (
- new DateTime (1970, 1, 1)).TotalSeconds;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageReader.cs
deleted file mode 100644
index 220eb2d..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageReader.cs
+++ /dev/null
@@ -1,472 +0,0 @@
-//
-// ImageReader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 - 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- using System;
- using System.IO;
- using System.Text;
-
- using Mono.Cecil.Metadata;
-
- class ImageReader : BaseImageVisitor {
-
- MetadataReader m_mdReader;
- BinaryReader m_binaryReader;
- Image m_image;
-
- public MetadataReader MetadataReader {
- get { return m_mdReader; }
- }
-
- public Image Image {
- get { return m_image; }
- }
-
- ImageReader (Image img, BinaryReader reader)
- {
- m_image = img;
- m_binaryReader = reader;
- }
-
- static ImageReader Read (Image img, Stream stream)
- {
- ImageReader reader = new ImageReader (img, new BinaryReader (stream));
- img.Accept (reader);
- return reader;
- }
-
- public static ImageReader Read (string file)
- {
- if (file == null)
- throw new ArgumentNullException ("file");
-
- FileInfo fi = new FileInfo (file);
- if (!File.Exists (fi.FullName))
- #if CF_1_0 || CF_2_0
- throw new FileNotFoundException (fi.FullName);
- #else
- throw new FileNotFoundException (string.Format ("File '{0}' not found.", fi.FullName), fi.FullName);
- #endif
-
- return Read (new Image (fi), new FileStream (
- fi.FullName, FileMode.Open,
- FileAccess.Read, FileShare.Read));
- }
-
- public static ImageReader Read (byte [] image)
- {
- if (image == null)
- throw new ArgumentNullException ("image");
-
- if (image.Length == 0)
- throw new ArgumentException ("Empty image array");
-
- return Read (new Image (), new MemoryStream (image));
- }
-
- public static ImageReader Read (Stream stream)
- {
- if (stream == null)
- throw new ArgumentNullException ("stream");
-
- if (!stream.CanRead)
- throw new ArgumentException ("Can not read from stream");
-
- return Read (new Image (), stream);
- }
-
- public BinaryReader GetReader ()
- {
- return m_binaryReader;
- }
-
- public override void VisitImage (Image img)
- {
- m_mdReader = new MetadataReader (this);
- }
-
- void SetPositionToAddress (RVA address)
- {
- m_binaryReader.BaseStream.Position = m_image.ResolveVirtualAddress (address);
- }
-
- public override void VisitDOSHeader (DOSHeader header)
- {
- header.Start = m_binaryReader.ReadBytes (60);
- header.Lfanew = m_binaryReader.ReadUInt32 ();
- header.End = m_binaryReader.ReadBytes (64);
-
- m_binaryReader.BaseStream.Position = header.Lfanew;
-
- if (m_binaryReader.ReadUInt16 () != 0x4550 ||
- m_binaryReader.ReadUInt16 () != 0)
-
- throw new ImageFormatException ("Invalid PE File Signature");
- }
-
- public override void VisitPEFileHeader (PEFileHeader header)
- {
- header.Machine = m_binaryReader.ReadUInt16 ();
- header.NumberOfSections = m_binaryReader.ReadUInt16 ();
- header.TimeDateStamp = m_binaryReader.ReadUInt32 ();
- header.PointerToSymbolTable = m_binaryReader.ReadUInt32 ();
- header.NumberOfSymbols = m_binaryReader.ReadUInt32 ();
- header.OptionalHeaderSize = m_binaryReader.ReadUInt16 ();
- header.Characteristics = (ImageCharacteristics) m_binaryReader.ReadUInt16 ();
- }
-
- ulong ReadIntOrLong ()
- {
- return m_image.PEOptionalHeader.StandardFields.IsPE64 ?
- m_binaryReader.ReadUInt64 () :
- m_binaryReader.ReadUInt32 ();
- }
-
- RVA ReadRVA ()
- {
- return m_binaryReader.ReadUInt32 ();
- }
-
- DataDirectory ReadDataDirectory ()
- {
- return new DataDirectory (ReadRVA (), m_binaryReader.ReadUInt32 ());
- }
-
- public override void VisitNTSpecificFieldsHeader (PEOptionalHeader.NTSpecificFieldsHeader header)
- {
- header.ImageBase = ReadIntOrLong ();
- header.SectionAlignment = m_binaryReader.ReadUInt32 ();
- header.FileAlignment = m_binaryReader.ReadUInt32 ();
- header.OSMajor = m_binaryReader.ReadUInt16 ();
- header.OSMinor = m_binaryReader.ReadUInt16 ();
- header.UserMajor = m_binaryReader.ReadUInt16 ();
- header.UserMinor = m_binaryReader.ReadUInt16 ();
- header.SubSysMajor = m_binaryReader.ReadUInt16 ();
- header.SubSysMinor = m_binaryReader.ReadUInt16 ();
- header.Reserved = m_binaryReader.ReadUInt32 ();
- header.ImageSize = m_binaryReader.ReadUInt32 ();
- header.HeaderSize = m_binaryReader.ReadUInt32 ();
- header.FileChecksum = m_binaryReader.ReadUInt32 ();
- header.SubSystem = (SubSystem) m_binaryReader.ReadUInt16 ();
- header.DLLFlags = m_binaryReader.ReadUInt16 ();
- header.StackReserveSize = ReadIntOrLong ();
- header.StackCommitSize = ReadIntOrLong ();
- header.HeapReserveSize = ReadIntOrLong ();
- header.HeapCommitSize = ReadIntOrLong ();
- header.LoaderFlags = m_binaryReader.ReadUInt32 ();
- header.NumberOfDataDir = m_binaryReader.ReadUInt32 ();
- }
-
- public override void VisitStandardFieldsHeader (PEOptionalHeader.StandardFieldsHeader header)
- {
- header.Magic = m_binaryReader.ReadUInt16 ();
- header.LMajor = m_binaryReader.ReadByte ();
- header.LMinor = m_binaryReader.ReadByte ();
- header.CodeSize = m_binaryReader.ReadUInt32 ();
- header.InitializedDataSize = m_binaryReader.ReadUInt32 ();
- header.UninitializedDataSize = m_binaryReader.ReadUInt32 ();
- header.EntryPointRVA = ReadRVA ();
- header.BaseOfCode = ReadRVA ();
- if (!header.IsPE64)
- header.BaseOfData = ReadRVA ();
- }
-
- public override void VisitDataDirectoriesHeader (PEOptionalHeader.DataDirectoriesHeader header)
- {
- header.ExportTable = ReadDataDirectory ();
- header.ImportTable = ReadDataDirectory ();
- header.ResourceTable = ReadDataDirectory ();
- header.ExceptionTable = ReadDataDirectory ();
- header.CertificateTable = ReadDataDirectory ();
- header.BaseRelocationTable = ReadDataDirectory ();
- header.Debug = ReadDataDirectory ();
- header.Copyright = ReadDataDirectory ();
- header.GlobalPtr = ReadDataDirectory ();
- header.TLSTable = ReadDataDirectory ();
- header.LoadConfigTable = ReadDataDirectory ();
- header.BoundImport = ReadDataDirectory ();
- header.IAT = ReadDataDirectory ();
- header.DelayImportDescriptor = ReadDataDirectory ();
- header.CLIHeader = ReadDataDirectory ();
- header.Reserved = ReadDataDirectory ();
-
- if (header.CLIHeader != DataDirectory.Zero)
- m_image.CLIHeader = new CLIHeader ();
- if (header.ExportTable != DataDirectory.Zero)
- m_image.ExportTable = new ExportTable ();
- }
-
- public override void VisitSectionCollection (SectionCollection coll)
- {
- for (int i = 0; i < m_image.PEFileHeader.NumberOfSections; i++)
- coll.Add (new Section ());
- }
-
- public override void VisitSection (Section sect)
- {
- char [] buffer = new char [8];
- int read = 0;
- while (read < 8) {
- char cur = (char) m_binaryReader.ReadSByte ();
- if (cur == '\0') {
- m_binaryReader.BaseStream.Position += 8 - read - 1;
- break;
- }
- buffer [read++] = cur;
- }
- sect.Name = read == 0 ? string.Empty : new string (buffer, 0, read);
- if (sect.Name == Section.Text)
- m_image.TextSection = sect;
-
- sect.VirtualSize = m_binaryReader.ReadUInt32 ();
- sect.VirtualAddress = ReadRVA ();
- sect.SizeOfRawData = m_binaryReader.ReadUInt32 ();
- sect.PointerToRawData = ReadRVA ();
- sect.PointerToRelocations = ReadRVA ();
- sect.PointerToLineNumbers = ReadRVA ();
- sect.NumberOfRelocations = m_binaryReader.ReadUInt16 ();
- sect.NumberOfLineNumbers = m_binaryReader.ReadUInt16 ();
- sect.Characteristics = (SectionCharacteristics) m_binaryReader.ReadUInt32 ();
-
- long pos = m_binaryReader.BaseStream.Position;
- m_binaryReader.BaseStream.Position = sect.PointerToRawData;
- sect.Data = m_binaryReader.ReadBytes ((int) sect.SizeOfRawData);
- m_binaryReader.BaseStream.Position = pos;
- }
-
- public override void VisitImportAddressTable (ImportAddressTable iat)
- {
- if (m_image.PEOptionalHeader.DataDirectories.IAT.VirtualAddress == RVA.Zero)
- return;
-
- SetPositionToAddress (m_image.PEOptionalHeader.DataDirectories.IAT.VirtualAddress);
-
- iat.HintNameTableRVA = ReadRVA ();
- }
-
- public override void VisitCLIHeader (CLIHeader header)
- {
- if (m_image.PEOptionalHeader.DataDirectories.Debug != DataDirectory.Zero) {
- m_image.DebugHeader = new DebugHeader ();
- VisitDebugHeader (m_image.DebugHeader);
- }
-
- SetPositionToAddress (m_image.PEOptionalHeader.DataDirectories.CLIHeader.VirtualAddress);
- header.Cb = m_binaryReader.ReadUInt32 ();
- header.MajorRuntimeVersion = m_binaryReader.ReadUInt16 ();
- header.MinorRuntimeVersion = m_binaryReader.ReadUInt16 ();
- header.Metadata = ReadDataDirectory ();
- header.Flags = (RuntimeImage) m_binaryReader.ReadUInt32 ();
- header.EntryPointToken = m_binaryReader.ReadUInt32 ();
- header.Resources = ReadDataDirectory ();
- header.StrongNameSignature = ReadDataDirectory ();
- header.CodeManagerTable = ReadDataDirectory ();
- header.VTableFixups = ReadDataDirectory ();
- header.ExportAddressTableJumps = ReadDataDirectory ();
- header.ManagedNativeHeader = ReadDataDirectory ();
-
- if (header.StrongNameSignature != DataDirectory.Zero) {
- SetPositionToAddress (header.StrongNameSignature.VirtualAddress);
- header.ImageHash = m_binaryReader.ReadBytes ((int) header.StrongNameSignature.Size);
- } else
- header.ImageHash = new byte [0];
-
- SetPositionToAddress (m_image.CLIHeader.Metadata.VirtualAddress);
- m_image.MetadataRoot.Accept (m_mdReader);
- }
-
- public override void VisitDebugHeader (DebugHeader header)
- {
- if (m_image.PEOptionalHeader.DataDirectories.Debug == DataDirectory.Zero)
- return;
-
- long pos = m_binaryReader.BaseStream.Position;
-
- SetPositionToAddress (m_image.PEOptionalHeader.DataDirectories.Debug.VirtualAddress);
- header.Characteristics = m_binaryReader.ReadUInt32 ();
- header.TimeDateStamp = m_binaryReader.ReadUInt32 ();
- header.MajorVersion = m_binaryReader.ReadUInt16 ();
- header.MinorVersion = m_binaryReader.ReadUInt16 ();
- header.Type = (DebugStoreType) m_binaryReader.ReadUInt32 ();
- header.SizeOfData = m_binaryReader.ReadUInt32 ();
- header.AddressOfRawData = ReadRVA ();
- header.PointerToRawData = m_binaryReader.ReadUInt32 ();
-
- m_binaryReader.BaseStream.Position = header.PointerToRawData;
-
- header.Magic = m_binaryReader.ReadUInt32 ();
- header.Signature = new Guid (m_binaryReader.ReadBytes (16));
- header.Age = m_binaryReader.ReadUInt32 ();
- header.FileName = ReadZeroTerminatedString ();
-
- m_binaryReader.BaseStream.Position = pos;
- }
-
- string ReadZeroTerminatedString ()
- {
- StringBuilder sb = new StringBuilder ();
- while (true) {
- byte chr = m_binaryReader.ReadByte ();
- if (chr == 0)
- break;
- sb.Append ((char) chr);
- }
- return sb.ToString ();
- }
-
- public override void VisitImportTable (ImportTable it)
- {
- if (m_image.PEOptionalHeader.DataDirectories.ImportTable.VirtualAddress == RVA.Zero)
- return;
-
- SetPositionToAddress (m_image.PEOptionalHeader.DataDirectories.ImportTable.VirtualAddress);
-
- it.ImportLookupTable = ReadRVA ();
- it.DateTimeStamp = m_binaryReader.ReadUInt32 ();
- it.ForwardChain = m_binaryReader.ReadUInt32 ();
- it.Name = ReadRVA ();
- it.ImportAddressTable = ReadRVA ();
- }
-
- public override void VisitImportLookupTable (ImportLookupTable ilt)
- {
- if (m_image.ImportTable.ImportLookupTable == RVA.Zero)
- return;
-
- SetPositionToAddress (m_image.ImportTable.ImportLookupTable);
-
- ilt.HintNameRVA = ReadRVA ();
- }
-
- public override void VisitHintNameTable (HintNameTable hnt)
- {
- if (m_image.ImportAddressTable.HintNameTableRVA == RVA.Zero)
- return;
-
- SetPositionToAddress (m_image.ImportAddressTable.HintNameTableRVA);
-
- hnt.Hint = m_binaryReader.ReadUInt16 ();
-
- byte [] bytes = m_binaryReader.ReadBytes (11);
- hnt.RuntimeMain = Encoding.ASCII.GetString (bytes, 0, bytes.Length);
-
- SetPositionToAddress (m_image.ImportTable.Name);
-
- bytes = m_binaryReader.ReadBytes (11);
- hnt.RuntimeLibrary = Encoding.ASCII.GetString (bytes, 0, bytes.Length);
-
- SetPositionToAddress (m_image.PEOptionalHeader.StandardFields.EntryPointRVA);
- hnt.EntryPoint = m_binaryReader.ReadUInt16 ();
- hnt.RVA = ReadRVA ();
- }
-
- public override void VisitExportTable (ExportTable et)
- {
- SetPositionToAddress (m_image.PEOptionalHeader.DataDirectories.ExportTable.VirtualAddress);
-
- et.Characteristics = m_binaryReader.ReadUInt32 ();
- et.TimeDateStamp = m_binaryReader.ReadUInt32 ();
- et.MajorVersion = m_binaryReader.ReadUInt16 ();
- et.MinorVersion = m_binaryReader.ReadUInt16 ();
-
- //et.Name =
- m_binaryReader.ReadUInt32 ();
-
- et.Base = m_binaryReader.ReadUInt32 ();
- et.NumberOfFunctions = m_binaryReader.ReadUInt32 ();
- et.NumberOfNames = m_binaryReader.ReadUInt32 ();
- et.AddressOfFunctions = m_binaryReader.ReadUInt32 ();
- et.AddressOfNames = m_binaryReader.ReadUInt32 ();
- et.AddressOfNameOrdinals = m_binaryReader.ReadUInt32 ();
-
- et.AddressesOfFunctions = ReadArrayOfRVA (et.AddressOfFunctions, et.NumberOfFunctions);
- et.AddressesOfNames = ReadArrayOfRVA (et.AddressOfNames, et.NumberOfNames);
- et.NameOrdinals = ReadArrayOfUInt16 (et.AddressOfNameOrdinals, et.NumberOfNames);
- et.Names = new string [et.NumberOfFunctions];
-
- for (int i = 0; i < et.NumberOfFunctions; i++) {
- if (et.AddressesOfFunctions [i] == 0)
- continue;
-
- et.Names [i] = ReadFunctionName (et, i);
- }
- }
-
- string ReadFunctionName (ExportTable et, int index)
- {
- for (int i = 0; i < et.NumberOfNames; i++) {
- if (et.NameOrdinals [i] != index)
- continue;
-
- SetPositionToAddress (et.AddressesOfNames [i]);
- return ReadZeroTerminatedString ();
- }
-
- return string.Empty;
- }
-
- ushort [] ReadArrayOfUInt16 (RVA position, uint length)
- {
- if (position == RVA.Zero)
- return new ushort [0];
-
- SetPositionToAddress (position);
- ushort [] array = new ushort [length];
- for (int i = 0; i < length; i++)
- array [i] = m_binaryReader.ReadUInt16 ();
-
- return array;
- }
-
- RVA [] ReadArrayOfRVA (RVA position, uint length)
- {
- if (position == RVA.Zero)
- return new RVA [0];
-
- SetPositionToAddress (position);
- RVA [] addresses = new RVA [length];
- for (int i = 0; i < length; i++)
- addresses [i] = m_binaryReader.ReadUInt32 ();
-
- return addresses;
- }
-
- public override void TerminateImage(Image img)
- {
- m_binaryReader.Close ();
-
- try {
- ResourceReader resReader = new ResourceReader (img);
- img.ResourceDirectoryRoot = resReader.Read ();
- } catch {
- img.ResourceDirectoryRoot = null;
- }
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageWriter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageWriter.cs
deleted file mode 100644
index 495b3ed..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ImageWriter.cs
+++ /dev/null
@@ -1,427 +0,0 @@
-//
-// ImageWriter.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- using System.IO;
- using System.Text;
-
- using Mono.Cecil.Metadata;
-
- class ImageWriter : BaseImageVisitor {
-
- Image m_img;
- AssemblyKind m_kind;
- MetadataWriter m_mdWriter;
- BinaryWriter m_binaryWriter;
-
- Section m_textSect;
- MemoryBinaryWriter m_textWriter;
- Section m_relocSect;
- MemoryBinaryWriter m_relocWriter;
- Section m_rsrcSect;
- MemoryBinaryWriter m_rsrcWriter;
-
- public ImageWriter (MetadataWriter writer, AssemblyKind kind, BinaryWriter bw)
- {
- m_mdWriter= writer;
- m_img = writer.GetMetadataRoot ().GetImage ();
- m_kind = kind;
- m_binaryWriter = bw;
-
- m_textWriter = new MemoryBinaryWriter ();
- m_textWriter.BaseStream.Position = 80;
- m_relocWriter = new MemoryBinaryWriter ();
- }
-
- public Image GetImage ()
- {
- return m_img;
- }
-
- public MemoryBinaryWriter GetTextWriter ()
- {
- return m_textWriter;
- }
-
- public uint GetAligned (uint integer, uint alignWith)
- {
- return (integer + alignWith - 1) & ~(alignWith - 1);
- }
-
- public void Initialize ()
- {
- Image img = m_img;
- ResourceWriter resWriter = null;
-
- uint sectAlign = img.PEOptionalHeader.NTSpecificFields.SectionAlignment;
- uint fileAlign = img.PEOptionalHeader.NTSpecificFields.FileAlignment;
-
- m_textSect = img.TextSection;
- foreach (Section s in img.Sections) {
- if (s.Name == Section.Relocs)
- m_relocSect = s;
- else if (s.Name == Section.Resources) {
- m_rsrcSect = s;
- m_rsrcWriter = new MemoryBinaryWriter ();
-
- resWriter = new ResourceWriter (img, m_rsrcSect, m_rsrcWriter);
- resWriter.Write ();
- }
- }
-
- // size computations, fields setting, etc.
- uint nbSects = (uint) img.Sections.Count;
- img.PEFileHeader.NumberOfSections = (ushort) nbSects;
-
- // build the reloc section data
- uint relocSize = 12;
- m_relocWriter.Write ((uint) 0);
- m_relocWriter.Write (relocSize);
- m_relocWriter.Write ((ushort) 0);
- m_relocWriter.Write ((ushort) 0);
-
- m_textSect.VirtualSize = (uint) m_textWriter.BaseStream.Length;
- m_relocSect.VirtualSize = (uint) m_relocWriter.BaseStream.Length;
- if (m_rsrcSect != null)
- m_rsrcSect.VirtualSize = (uint) m_rsrcWriter.BaseStream.Length;
-
- // start counting before sections headers
- // section start + section header sixe * number of sections
- uint headersEnd = 0x178 + 0x28 * nbSects;
- uint fileOffset = headersEnd;
- uint sectOffset = sectAlign;
- uint imageSize = 0;
-
- foreach (Section sect in img.Sections) {
- fileOffset = GetAligned (fileOffset, fileAlign);
- sectOffset = GetAligned (sectOffset, sectAlign);
-
- sect.PointerToRawData = new RVA (fileOffset);
- sect.VirtualAddress = new RVA (sectOffset);
- sect.SizeOfRawData = GetAligned (sect.VirtualSize, fileAlign);
-
- fileOffset += sect.SizeOfRawData;
- sectOffset += sect.SizeOfRawData;
- imageSize += GetAligned (sect.SizeOfRawData, sectAlign);
- }
-
- if (m_textSect.VirtualAddress.Value != 0x2000)
- throw new ImageFormatException ("Wrong RVA for .text section");
-
- if (resWriter != null)
- resWriter.Patch ();
-
- img.PEOptionalHeader.StandardFields.CodeSize = GetAligned (
- m_textSect.SizeOfRawData, fileAlign);
- img.PEOptionalHeader.StandardFields.InitializedDataSize = m_textSect.SizeOfRawData;
- if (m_rsrcSect != null)
- img.PEOptionalHeader.StandardFields.InitializedDataSize += m_rsrcSect.SizeOfRawData;
- img.PEOptionalHeader.StandardFields.BaseOfCode = m_textSect.VirtualAddress;
- img.PEOptionalHeader.StandardFields.BaseOfData = m_relocSect.VirtualAddress;
-
- imageSize += headersEnd;
- img.PEOptionalHeader.NTSpecificFields.ImageSize = GetAligned (imageSize, sectAlign);
-
- img.PEOptionalHeader.DataDirectories.BaseRelocationTable = new DataDirectory (
- m_relocSect.VirtualAddress, m_relocSect.VirtualSize);
- if (m_rsrcSect != null)
- img.PEOptionalHeader.DataDirectories.ResourceTable = new DataDirectory (
- m_rsrcSect.VirtualAddress, (uint) m_rsrcWriter.BaseStream.Length);
-
- if (m_kind == AssemblyKind.Dll) {
- img.PEFileHeader.Characteristics = ImageCharacteristics.CILOnlyDll;
- img.HintNameTable.RuntimeMain = HintNameTable.RuntimeMainDll;
- img.PEOptionalHeader.NTSpecificFields.DLLFlags = 0x400;
- } else {
- img.PEFileHeader.Characteristics = ImageCharacteristics.CILOnlyExe;
- img.HintNameTable.RuntimeMain = HintNameTable.RuntimeMainExe;
- }
-
- switch (m_kind) {
- case AssemblyKind.Dll :
- case AssemblyKind.Console :
- img.PEOptionalHeader.NTSpecificFields.SubSystem = SubSystem.WindowsCui;
- break;
- case AssemblyKind.Windows :
- img.PEOptionalHeader.NTSpecificFields.SubSystem = SubSystem.WindowsGui;
- break;
- }
-
- RVA importTable = new RVA (img.TextSection.VirtualAddress + m_mdWriter.ImportTablePosition);
-
- img.PEOptionalHeader.DataDirectories.ImportTable = new DataDirectory (importTable, 0x57);
-
- img.ImportTable.ImportLookupTable = new RVA ((uint) importTable + 0x28);
-
- img.ImportLookupTable.HintNameRVA = img.ImportAddressTable.HintNameTableRVA =
- new RVA ((uint) img.ImportTable.ImportLookupTable + 0x14);
- img.ImportTable.Name = new RVA ((uint) img.ImportLookupTable.HintNameRVA + 0xe);
- }
-
- public override void VisitDOSHeader (DOSHeader header)
- {
- m_binaryWriter.Write (header.Start);
- m_binaryWriter.Write (header.Lfanew);
- m_binaryWriter.Write (header.End);
-
- m_binaryWriter.Write ((ushort) 0x4550);
- m_binaryWriter.Write ((ushort) 0);
- }
-
- public override void VisitPEFileHeader (PEFileHeader header)
- {
- m_binaryWriter.Write (header.Machine);
- m_binaryWriter.Write (header.NumberOfSections);
- m_binaryWriter.Write (header.TimeDateStamp);
- m_binaryWriter.Write (header.PointerToSymbolTable);
- m_binaryWriter.Write (header.NumberOfSymbols);
- m_binaryWriter.Write (header.OptionalHeaderSize);
- m_binaryWriter.Write ((ushort) header.Characteristics);
- }
-
- public override void VisitNTSpecificFieldsHeader (PEOptionalHeader.NTSpecificFieldsHeader header)
- {
- WriteIntOrLong (header.ImageBase);
- m_binaryWriter.Write (header.SectionAlignment);
- m_binaryWriter.Write (header.FileAlignment);
- m_binaryWriter.Write (header.OSMajor);
- m_binaryWriter.Write (header.OSMinor);
- m_binaryWriter.Write (header.UserMajor);
- m_binaryWriter.Write (header.UserMinor);
- m_binaryWriter.Write (header.SubSysMajor);
- m_binaryWriter.Write (header.SubSysMinor);
- m_binaryWriter.Write (header.Reserved);
- m_binaryWriter.Write (header.ImageSize);
- m_binaryWriter.Write (header.HeaderSize);
- m_binaryWriter.Write (header.FileChecksum);
- m_binaryWriter.Write ((ushort) header.SubSystem);
- m_binaryWriter.Write (header.DLLFlags);
- WriteIntOrLong (header.StackReserveSize);
- WriteIntOrLong (header.StackCommitSize);
- WriteIntOrLong (header.HeapReserveSize);
- WriteIntOrLong (header.HeapCommitSize);
- m_binaryWriter.Write (header.LoaderFlags);
- m_binaryWriter.Write (header.NumberOfDataDir);
- }
-
- public override void VisitStandardFieldsHeader (PEOptionalHeader.StandardFieldsHeader header)
- {
- m_binaryWriter.Write (header.Magic);
- m_binaryWriter.Write (header.LMajor);
- m_binaryWriter.Write (header.LMinor);
- m_binaryWriter.Write (header.CodeSize);
- m_binaryWriter.Write (header.InitializedDataSize);
- m_binaryWriter.Write (header.UninitializedDataSize);
- m_binaryWriter.Write (header.EntryPointRVA.Value);
- m_binaryWriter.Write (header.BaseOfCode.Value);
- if (!header.IsPE64)
- m_binaryWriter.Write (header.BaseOfData.Value);
- }
-
- void WriteIntOrLong (ulong value)
- {
- if (m_img.PEOptionalHeader.StandardFields.IsPE64)
- m_binaryWriter.Write (value);
- else
- m_binaryWriter.Write ((uint) value);
- }
-
- public override void VisitDataDirectoriesHeader (PEOptionalHeader.DataDirectoriesHeader header)
- {
- m_binaryWriter.Write (header.ExportTable.VirtualAddress);
- m_binaryWriter.Write (header.ExportTable.Size);
- m_binaryWriter.Write (header.ImportTable.VirtualAddress);
- m_binaryWriter.Write (header.ImportTable.Size);
- m_binaryWriter.Write (header.ResourceTable.VirtualAddress);
- m_binaryWriter.Write (header.ResourceTable.Size);
- m_binaryWriter.Write (header.ExceptionTable.VirtualAddress);
- m_binaryWriter.Write (header.ExceptionTable.Size);
- m_binaryWriter.Write (header.CertificateTable.VirtualAddress);
- m_binaryWriter.Write (header.CertificateTable.Size);
- m_binaryWriter.Write (header.BaseRelocationTable.VirtualAddress);
- m_binaryWriter.Write (header.BaseRelocationTable.Size);
- m_binaryWriter.Write (header.Debug.VirtualAddress);
- m_binaryWriter.Write (header.Debug.Size);
- m_binaryWriter.Write (header.Copyright.VirtualAddress);
- m_binaryWriter.Write (header.Copyright.Size);
- m_binaryWriter.Write (header.GlobalPtr.VirtualAddress);
- m_binaryWriter.Write (header.GlobalPtr.Size);
- m_binaryWriter.Write (header.TLSTable.VirtualAddress);
- m_binaryWriter.Write (header.TLSTable.Size);
- m_binaryWriter.Write (header.LoadConfigTable.VirtualAddress);
- m_binaryWriter.Write (header.LoadConfigTable.Size);
- m_binaryWriter.Write (header.BoundImport.VirtualAddress);
- m_binaryWriter.Write (header.BoundImport.Size);
- m_binaryWriter.Write (header.IAT.VirtualAddress);
- m_binaryWriter.Write (header.IAT.Size);
- m_binaryWriter.Write (header.DelayImportDescriptor.VirtualAddress);
- m_binaryWriter.Write (header.DelayImportDescriptor.Size);
- m_binaryWriter.Write (header.CLIHeader.VirtualAddress);
- m_binaryWriter.Write (header.CLIHeader.Size);
- m_binaryWriter.Write (header.Reserved.VirtualAddress);
- m_binaryWriter.Write (header.Reserved.Size);
- }
-
- public override void VisitSection (Section sect)
- {
- m_binaryWriter.Write (Encoding.ASCII.GetBytes (sect.Name));
- int more = 8 - sect.Name.Length;
- for (int i = 0; i < more; i++)
- m_binaryWriter.Write ((byte) 0);
-
- m_binaryWriter.Write (sect.VirtualSize);
- m_binaryWriter.Write (sect.VirtualAddress.Value);
- m_binaryWriter.Write (sect.SizeOfRawData);
- m_binaryWriter.Write (sect.PointerToRawData.Value);
- m_binaryWriter.Write (sect.PointerToRelocations.Value);
- m_binaryWriter.Write (sect.PointerToLineNumbers.Value);
- m_binaryWriter.Write (sect.NumberOfRelocations);
- m_binaryWriter.Write (sect.NumberOfLineNumbers);
- m_binaryWriter.Write ((uint) sect.Characteristics);
- }
-
- public override void VisitImportAddressTable (ImportAddressTable iat)
- {
- m_textWriter.BaseStream.Position = 0;
- m_textWriter.Write (iat.HintNameTableRVA.Value);
- m_textWriter.Write (new byte [4]);
- }
-
- public override void VisitCLIHeader (CLIHeader header)
- {
- m_textWriter.Write (header.Cb);
- m_textWriter.Write (header.MajorRuntimeVersion);
- m_textWriter.Write (header.MinorRuntimeVersion);
- m_textWriter.Write (header.Metadata.VirtualAddress);
- m_textWriter.Write (header.Metadata.Size);
- m_textWriter.Write ((uint) header.Flags);
- m_textWriter.Write (header.EntryPointToken);
- m_textWriter.Write (header.Resources.VirtualAddress);
- m_textWriter.Write (header.Resources.Size);
- m_textWriter.Write (header.StrongNameSignature.VirtualAddress);
- m_textWriter.Write (header.StrongNameSignature.Size);
- m_textWriter.Write (header.CodeManagerTable.VirtualAddress);
- m_textWriter.Write (header.CodeManagerTable.Size);
- m_textWriter.Write (header.VTableFixups.VirtualAddress);
- m_textWriter.Write (header.VTableFixups.Size);
- m_textWriter.Write (header.ExportAddressTableJumps.VirtualAddress);
- m_textWriter.Write (header.ExportAddressTableJumps.Size);
- m_textWriter.Write (header.ManagedNativeHeader.VirtualAddress);
- m_textWriter.Write (header.ManagedNativeHeader.Size);
- }
-
- public override void VisitDebugHeader (DebugHeader header)
- {
- m_textWriter.BaseStream.Position = m_mdWriter.DebugHeaderPosition;
- uint sizeUntilData = 0x1c;
- header.AddressOfRawData = m_img.TextSection.VirtualAddress + m_mdWriter.DebugHeaderPosition + sizeUntilData;
- header.PointerToRawData = 0x200 + m_mdWriter.DebugHeaderPosition + sizeUntilData;
- header.SizeOfData = 0x18 + (uint) header.FileName.Length + 1;
-
- m_textWriter.Write (header.Characteristics);
- m_textWriter.Write (header.TimeDateStamp);
- m_textWriter.Write (header.MajorVersion);
- m_textWriter.Write (header.MinorVersion);
- m_textWriter.Write ((uint) header.Type);
- m_textWriter.Write (header.SizeOfData);
- m_textWriter.Write (header.AddressOfRawData.Value);
- m_textWriter.Write (header.PointerToRawData);
-
- m_textWriter.Write (header.Magic);
- m_textWriter.Write (header.Signature.ToByteArray ());
- m_textWriter.Write (header.Age);
- m_textWriter.Write (Encoding.ASCII.GetBytes (header.FileName));
- m_textWriter.Write ((byte) 0);
- }
-
- public override void VisitImportTable (ImportTable it)
- {
- m_textWriter.BaseStream.Position = m_mdWriter.ImportTablePosition;
- m_textWriter.Write (it.ImportLookupTable.Value);
- m_textWriter.Write (it.DateTimeStamp);
- m_textWriter.Write (it.ForwardChain);
- m_textWriter.Write (it.Name.Value);
- m_textWriter.Write (it.ImportAddressTable.Value);
- m_textWriter.Write (new byte [20]);
- }
-
- public override void VisitImportLookupTable (ImportLookupTable ilt)
- {
- m_textWriter.Write (ilt.HintNameRVA.Value);
- m_textWriter.Write (new byte [16]);
- }
-
- public override void VisitHintNameTable (HintNameTable hnt)
- {
- m_textWriter.Write (hnt.Hint);
- m_textWriter.Write (Encoding.ASCII.GetBytes (hnt.RuntimeMain));
- m_textWriter.Write ('\0');
- m_textWriter.Write (Encoding.ASCII.GetBytes (hnt.RuntimeLibrary));
- m_textWriter.Write ('\0');
- m_textWriter.Write (new byte [4]);
-
- // patch header with ep rva
- RVA ep = m_img.TextSection.VirtualAddress +
- (uint) m_textWriter.BaseStream.Position;
- long pos = m_binaryWriter.BaseStream.Position;
- m_binaryWriter.BaseStream.Position = 0xa8;
- m_binaryWriter.Write (ep.Value);
- m_binaryWriter.BaseStream.Position = pos;
-
- // patch reloc Sect with ep
- uint reloc = (ep.Value + 2) % 0x1000;
- uint rva = (ep.Value + 2) - reloc;
-
- m_relocWriter.BaseStream.Position = 0;
- m_relocWriter.Write (rva);
- m_relocWriter.BaseStream.Position = 8;
- m_relocWriter.Write ((ushort) ((3 << 12) | reloc));
-
- m_textWriter.Write (hnt.EntryPoint);
- m_textWriter.Write (hnt.RVA);
- }
-
- public override void TerminateImage (Image img)
- {
- m_binaryWriter.BaseStream.Position = 0x200;
-
- WriteSection (m_textSect, m_textWriter);
- WriteSection (m_relocSect, m_relocWriter);
- if (m_rsrcSect != null)
- WriteSection (m_rsrcSect, m_rsrcWriter);
- }
-
- void WriteSection (Section sect, MemoryBinaryWriter sectWriter)
- {
- sectWriter.MemoryStream.WriteTo (m_binaryWriter.BaseStream);
- m_binaryWriter.Write (new byte [
- sect.SizeOfRawData - sectWriter.BaseStream.Length]);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Imports.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Imports.cs
deleted file mode 100644
index 021cb39..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Imports.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-//
-// Imports.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public sealed class ImportAddressTable : IBinaryVisitable {
-
- public RVA HintNameTableRVA;
-
- internal ImportAddressTable ()
- {
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitImportAddressTable (this);
- }
- }
-
- public sealed class ImportTable : IBinaryVisitable {
-
- public RVA ImportLookupTable;
- public uint DateTimeStamp;
- public uint ForwardChain;
- public RVA Name;
- public RVA ImportAddressTable;
-
- internal ImportTable ()
- {
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitImportTable (this);
- }
- }
-
- public sealed class ImportLookupTable : IBinaryVisitable {
-
- public RVA HintNameRVA;
-
- internal ImportLookupTable ()
- {
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitImportLookupTable (this);
- }
- }
-
- public sealed class HintNameTable : IBinaryVisitable {
-
- public const string RuntimeMainExe = "_CorExeMain";
- public const string RuntimeMainDll = "_CorDllMain";
- public const string RuntimeCorEE = "mscoree.dll";
-
- public ushort Hint;
- public string RuntimeMain;
- public string RuntimeLibrary;
- public ushort EntryPoint;
- public RVA RVA;
-
- internal HintNameTable ()
- {
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitHintNameTable (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/MemoryBinaryWriter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/MemoryBinaryWriter.cs
deleted file mode 100644
index 12c8156..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/MemoryBinaryWriter.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-//
-// MemoryBinaryWriter.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- using System.IO;
- using System.Text;
-
- internal sealed class MemoryBinaryWriter : BinaryWriter {
-
- public MemoryStream MemoryStream {
- get { return (MemoryStream) this.BaseStream; }
- }
-
- public MemoryBinaryWriter () : base (new MemoryStream ())
- {
- }
-
- public MemoryBinaryWriter (Encoding enc) : base (new MemoryStream (), enc)
- {
- }
-
- public void Empty ()
- {
- this.BaseStream.Position = 0;
- this.BaseStream.SetLength (0);
- }
-
- public void Write (MemoryBinaryWriter writer)
- {
- writer.MemoryStream.WriteTo (this.BaseStream);
- }
-
- public byte [] ToArray ()
- {
- return this.MemoryStream.ToArray ();
- }
-
- public void QuadAlign ()
- {
- this.BaseStream.Position += 3;
- this.BaseStream.Position &= ~3;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEFileHeader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEFileHeader.cs
deleted file mode 100644
index f38ee62..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEFileHeader.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// PEFileHeader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public sealed class PEFileHeader : IHeader, IBinaryVisitable {
-
- public ushort Machine;
- public ushort NumberOfSections;
- public uint TimeDateStamp;
- public uint PointerToSymbolTable;
- public uint NumberOfSymbols;
- public ushort OptionalHeaderSize;
- public ImageCharacteristics Characteristics;
-
- internal PEFileHeader ()
- {
- }
-
- public void SetDefaultValues ()
- {
- Machine = 0x14c;
- PointerToSymbolTable = 0;
- NumberOfSymbols = 0;
- OptionalHeaderSize = 0xe0;
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitPEFileHeader (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEOptionalHeader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEOptionalHeader.cs
deleted file mode 100644
index 0f27ff7..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/PEOptionalHeader.cs
+++ /dev/null
@@ -1,200 +0,0 @@
-//
-// PEOptionalHeader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public sealed class PEOptionalHeader : IHeader, IBinaryVisitable {
-
- public StandardFieldsHeader StandardFields;
- public NTSpecificFieldsHeader NTSpecificFields;
- public DataDirectoriesHeader DataDirectories;
-
- internal PEOptionalHeader ()
- {
- StandardFields = new StandardFieldsHeader ();
- NTSpecificFields = new NTSpecificFieldsHeader ();
- DataDirectories = new DataDirectoriesHeader ();
- }
-
- public void SetDefaultValues ()
- {
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitPEOptionalHeader (this);
-
- StandardFields.Accept (visitor);
- NTSpecificFields.Accept (visitor);
- DataDirectories.Accept (visitor);
- }
-
- public sealed class StandardFieldsHeader : IHeader, IBinaryVisitable {
-
- public ushort Magic;
- public byte LMajor;
- public byte LMinor;
- public uint CodeSize;
- public uint InitializedDataSize;
- public uint UninitializedDataSize;
- public RVA EntryPointRVA;
- public RVA BaseOfCode;
- public RVA BaseOfData;
-
- public bool IsPE64 {
- get { return Magic == 0x20b; }
- set {
- if (value)
- Magic = 0x20b;
- else
- Magic = 0x10b;
- }
- }
-
- internal StandardFieldsHeader ()
- {
- }
-
- public void SetDefaultValues ()
- {
- Magic = 0x10b;
- LMajor = 6;
- LMinor = 0;
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitStandardFieldsHeader (this);
- }
- }
-
- public sealed class NTSpecificFieldsHeader : IHeader, IBinaryVisitable {
-
- public ulong ImageBase;
- public uint SectionAlignment;
- public uint FileAlignment;
- public ushort OSMajor;
- public ushort OSMinor;
- public ushort UserMajor;
- public ushort UserMinor;
- public ushort SubSysMajor;
- public ushort SubSysMinor;
- public uint Reserved;
- public uint ImageSize;
- public uint HeaderSize;
- public uint FileChecksum;
- public SubSystem SubSystem;
- public ushort DLLFlags;
- public ulong StackReserveSize;
- public ulong StackCommitSize;
- public ulong HeapReserveSize;
- public ulong HeapCommitSize;
- public uint LoaderFlags;
- public uint NumberOfDataDir;
-
- internal NTSpecificFieldsHeader ()
- {
- }
-
- public void SetDefaultValues ()
- {
- ImageBase = 0x400000;
- SectionAlignment = 0x2000;
- FileAlignment = 0x200;
- OSMajor = 4;
- OSMinor = 0;
- UserMajor = 0;
- UserMinor = 0;
- SubSysMajor = 4;
- SubSysMinor = 0;
- Reserved = 0;
- HeaderSize = 0x200;
- FileChecksum = 0;
- DLLFlags = 0;
- StackReserveSize = 0x100000;
- StackCommitSize = 0x1000;
- HeapReserveSize = 0x100000;
- HeapCommitSize = 0x1000;
- LoaderFlags = 0;
- NumberOfDataDir = 0x10;
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitNTSpecificFieldsHeader (this);
- }
- }
-
- public sealed class DataDirectoriesHeader : IHeader, IBinaryVisitable {
-
- public DataDirectory ExportTable;
- public DataDirectory ImportTable;
- public DataDirectory ResourceTable;
- public DataDirectory ExceptionTable;
- public DataDirectory CertificateTable;
- public DataDirectory BaseRelocationTable;
- public DataDirectory Debug;
- public DataDirectory Copyright;
- public DataDirectory GlobalPtr;
- public DataDirectory TLSTable;
- public DataDirectory LoadConfigTable;
- public DataDirectory BoundImport;
- public DataDirectory IAT;
- public DataDirectory DelayImportDescriptor;
- public DataDirectory CLIHeader;
- public DataDirectory Reserved;
-
- internal DataDirectoriesHeader ()
- {
- }
-
- public void SetDefaultValues ()
- {
- ExportTable = DataDirectory.Zero;
- ResourceTable = DataDirectory.Zero;
- ExceptionTable = DataDirectory.Zero;
- CertificateTable = DataDirectory.Zero;
- Debug = DataDirectory.Zero;
- Copyright = DataDirectory.Zero;
- GlobalPtr = DataDirectory.Zero;
- TLSTable = DataDirectory.Zero;
- LoadConfigTable = DataDirectory.Zero;
- BoundImport = DataDirectory.Zero;
- IAT = new DataDirectory (new RVA (0x2000), 8);
- DelayImportDescriptor = DataDirectory.Zero;
- CLIHeader = new DataDirectory (new RVA (0x2008), 0x48);
- Reserved = DataDirectory.Zero;
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitDataDirectoriesHeader (this);
- }
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RVA.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RVA.cs
deleted file mode 100644
index 09fae0d..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RVA.cs
+++ /dev/null
@@ -1,115 +0,0 @@
-//
-// RVA.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public struct RVA {
-
- public static readonly RVA Zero = new RVA (0);
-
- uint m_rva;
-
- public uint Value {
- get { return m_rva; }
- set { m_rva = value; }
- }
-
- public RVA (uint rva)
- {
- m_rva = rva;
- }
-
- public override int GetHashCode ()
- {
- return (int) m_rva;
- }
-
- public override bool Equals (object other)
- {
- if (other is RVA)
- return this.m_rva == ((RVA) other).m_rva;
-
- return false;
- }
-
- public override string ToString ()
- {
- return string.Format ("0x{0}", m_rva.ToString ("X"));
- }
-
- public static bool operator == (RVA one, RVA other)
- {
- return one.Equals (other);
- }
-
- public static bool operator != (RVA one, RVA other)
- {
- return !one.Equals (other);
- }
-
- public static bool operator < (RVA one, RVA other)
- {
- return one.m_rva < other.m_rva;
- }
-
- public static bool operator > (RVA one, RVA other)
- {
- return one.m_rva > other.m_rva;
- }
-
- public static bool operator <= (RVA one, RVA other)
- {
- return one.m_rva <= other.m_rva;
- }
-
- public static bool operator >= (RVA one, RVA other)
- {
- return one.m_rva >= other.m_rva;
- }
-
- public static RVA operator + (RVA rva, uint x)
- {
- return new RVA (rva.m_rva + x);
- }
-
- public static RVA operator - (RVA rva, uint x)
- {
- return new RVA (rva.m_rva - x);
- }
-
- public static implicit operator RVA (uint val)
- {
- return val == 0 ? RVA.Zero : new RVA (val);
- }
-
- public static implicit operator uint (RVA rva)
- {
- return rva.m_rva;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryEntry.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryEntry.cs
deleted file mode 100644
index 5588b3c..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryEntry.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-//
-// ResourceDirectoryEntry.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public class ResourceDirectoryEntry : ResourceNode {
-
- private bool m_idByName;
-
- public int ID;
- public ResourceDirectoryString Name;
-
- public bool IdentifiedByName {
- get { return m_idByName; }
- }
-
- public ResourceNode Child;
-
- public ResourceDirectoryEntry (ResourceDirectoryString name)
- {
- this.Name = name;
- m_idByName = true;
- }
-
- public ResourceDirectoryEntry (ResourceDirectoryString name, int offset) : base (offset)
- {
- this.Name = name;
- m_idByName = true;
- }
-
- public ResourceDirectoryEntry (int id)
- {
- this.ID = id;
- }
-
- public ResourceDirectoryEntry (int id, int offset) : base (offset)
- {
- this.ID = id;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryString.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryString.cs
deleted file mode 100644
index 8c006e0..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryString.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// ResourceDirectoryString.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public class ResourceDirectoryString : ResourceNode {
-
- public string String;
-
- public ResourceDirectoryString (string str)
- {
- this.String = str;
- }
-
- public ResourceDirectoryString (string str, int offset) : base (offset)
- {
- this.String = str;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryTable.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryTable.cs
deleted file mode 100644
index 12517bf..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDirectoryTable.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-//
-// ResourceDirectoryTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- using System.Collections;
-
- public class ResourceDirectoryTable : ResourceNode {
-
- private ArrayList m_entries;
-
- public uint Characteristics;
- public uint TimeDateStamp;
- public ushort MajorVersion;
- public ushort MinorVersion;
-
- public IList Entries {
- get { return m_entries; }
- }
-
- public ResourceDirectoryTable (int offset) : base (offset)
- {
- m_entries = new ArrayList ();
- }
-
- public ResourceDirectoryTable ()
- {
- m_entries = new ArrayList ();
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceReader.cs
deleted file mode 100644
index 60d16e7..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceReader.cs
+++ /dev/null
@@ -1,143 +0,0 @@
-//
-// ResourceReader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- using System.IO;
- using System.Text;
-
- class ResourceReader {
-
- Image m_img;
- Section m_rsrc;
- BinaryReader m_reader;
-
- public ResourceReader (Image img)
- {
- m_img = img;
- }
-
- public ResourceDirectoryTable Read ()
- {
- m_rsrc = GetResourceSection ();
- if (m_rsrc == null)
- return null;
-
- m_reader = new BinaryReader (new MemoryStream (m_rsrc.Data));
- return ReadDirectoryTable ();
- }
-
- Section GetResourceSection ()
- {
- foreach (Section s in m_img.Sections)
- if (s.Name == Section.Resources)
- return s;
-
- return null;
- }
-
- int GetOffset ()
- {
- return (int) m_reader.BaseStream.Position;
- }
-
- ResourceDirectoryTable ReadDirectoryTable ()
- {
- ResourceDirectoryTable rdt = new ResourceDirectoryTable (GetOffset ());
- rdt.Characteristics = m_reader.ReadUInt32 ();
- rdt.TimeDateStamp = m_reader.ReadUInt32 ();
- rdt.MajorVersion = m_reader.ReadUInt16 ();
- rdt.MinorVersion = m_reader.ReadUInt16 ();
- ushort nameEntries = m_reader.ReadUInt16 ();
- ushort idEntries = m_reader.ReadUInt16 ();
-
- for (int i = 0; i < nameEntries; i++)
- rdt.Entries.Add (ReadDirectoryEntry ());
-
- for (int i = 0; i < idEntries; i++)
- rdt.Entries.Add (ReadDirectoryEntry ());
-
- return rdt;
- }
-
- ResourceDirectoryEntry ReadDirectoryEntry ()
- {
- uint name = m_reader.ReadUInt32 ();
- uint child = m_reader.ReadUInt32 ();
-
- ResourceDirectoryEntry rde;
- if ((name & 0x80000000) != 0)
- rde = new ResourceDirectoryEntry (ReadDirectoryString ((int) name & 0x7fffffff), GetOffset ());
- else
- rde = new ResourceDirectoryEntry ((int) name & 0x7fffffff, GetOffset ());
-
- long pos = m_reader.BaseStream.Position;
- m_reader.BaseStream.Position = child & 0x7fffffff;
-
- if ((child & 0x80000000) != 0)
- rde.Child = ReadDirectoryTable ();
- else
- rde.Child = ReadDataEntry ();
-
- m_reader.BaseStream.Position = pos;
-
- return rde;
- }
-
- ResourceDirectoryString ReadDirectoryString (int offset)
- {
- long pos = m_reader.BaseStream.Position;
- m_reader.BaseStream.Position = offset;
-
- byte [] str = m_reader.ReadBytes (m_reader.ReadUInt16 ());
-
- ResourceDirectoryString rds = new ResourceDirectoryString (
- Encoding.Unicode.GetString (str, 0, str.Length),
- GetOffset ());
-
- m_reader.BaseStream.Position = pos;
-
- return rds;
- }
-
- ResourceNode ReadDataEntry ()
- {
- ResourceDataEntry rde = new ResourceDataEntry (GetOffset ());
- rde.Data = m_reader.ReadUInt32 ();
- rde.Size = m_reader.ReadUInt32 ();
- rde.Codepage = m_reader.ReadUInt32 ();
- rde.Reserved = m_reader.ReadUInt32 ();
-
- BinaryReader dataReader = m_img.GetReaderAtVirtualAddress (rde.Data);
- rde.ResourceData = dataReader.ReadBytes ((int) rde.Size);
- dataReader.Close ();
-
- return rde;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceWriter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceWriter.cs
deleted file mode 100644
index 8965f64..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceWriter.cs
+++ /dev/null
@@ -1,216 +0,0 @@
-//
-// ResourceWriter.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Text;
-
-namespace Mono.Cecil.Binary {
-
- using System.Collections;
-
- class ResourceWriter {
-
- Image m_img;
- Section m_rsrc;
- MemoryBinaryWriter m_writer;
-
- ArrayList m_dataEntries;
- ArrayList m_stringEntries;
-
- long m_pos;
-
- public ResourceWriter (Image img, Section rsrc, MemoryBinaryWriter writer)
- {
- m_img = img;
- m_rsrc = rsrc;
- m_writer = writer;
-
- m_dataEntries = new ArrayList ();
- m_stringEntries = new ArrayList ();
- }
-
- public void Write ()
- {
- if (m_img.ResourceDirectoryRoot == null)
- return;
-
- ComputeOffset (m_img.ResourceDirectoryRoot);
- WriteResourceDirectoryTable (m_img.ResourceDirectoryRoot);
- }
-
- public void Patch ()
- {
- foreach (ResourceDataEntry rde in m_dataEntries) {
- GotoOffset (rde.Offset);
- m_writer.Write ((uint) rde.Data + m_rsrc.VirtualAddress);
- RestoreOffset ();
- }
- }
-
- void ComputeOffset (ResourceDirectoryTable root)
- {
- int offset = 0;
-
- Queue directoryTables = new Queue ();
- directoryTables.Enqueue (root);
-
- while (directoryTables.Count > 0) {
- ResourceDirectoryTable rdt = directoryTables.Dequeue () as ResourceDirectoryTable;
- rdt.Offset = offset;
- offset += 16;
-
- foreach (ResourceDirectoryEntry rde in rdt.Entries) {
- rde.Offset = offset;
- offset += 8;
- if (rde.IdentifiedByName)
- m_stringEntries.Add (rde.Name);
-
- if (rde.Child is ResourceDirectoryTable)
- directoryTables.Enqueue (rde.Child);
- else
- m_dataEntries.Add (rde.Child);
- }
- }
-
- foreach (ResourceDataEntry rde in m_dataEntries) {
- rde.Offset = offset;
- offset += 16;
- }
-
- foreach (ResourceDirectoryString rds in m_stringEntries) {
- rds.Offset = offset;
- byte [] str = Encoding.Unicode.GetBytes (rds.String);
- offset += 2 + str.Length;
-
- offset += 3;
- offset &= ~3;
- }
-
- foreach (ResourceDataEntry rde in m_dataEntries) {
- rde.Data = (uint) offset;
-
- offset += rde.ResourceData.Length;
- offset += 3;
- offset &= ~3;
- }
-
- m_writer.Write (new byte [offset]);
- }
-
- void WriteResourceDirectoryTable (ResourceDirectoryTable rdt)
- {
- GotoOffset (rdt.Offset);
-
- m_writer.Write (rdt.Characteristics);
- m_writer.Write (rdt.TimeDateStamp);
- m_writer.Write (rdt.MajorVersion);
- m_writer.Write (rdt.MinorVersion);
-
- ResourceDirectoryEntry [] namedEntries = GetEntries (rdt, true);
- ResourceDirectoryEntry [] idEntries = GetEntries (rdt, false);
-
- m_writer.Write ((ushort) namedEntries.Length);
- m_writer.Write ((ushort) idEntries.Length);
-
- foreach (ResourceDirectoryEntry rde in namedEntries)
- WriteResourceDirectoryEntry (rde);
-
- foreach (ResourceDirectoryEntry rde in idEntries)
- WriteResourceDirectoryEntry (rde);
-
- RestoreOffset ();
- }
-
- ResourceDirectoryEntry [] GetEntries (ResourceDirectoryTable rdt, bool identifiedByName)
- {
- ArrayList entries = new ArrayList ();
- foreach (ResourceDirectoryEntry rde in rdt.Entries)
- if (rde.IdentifiedByName == identifiedByName)
- entries.Add (rde);
-
- return entries.ToArray (typeof (ResourceDirectoryEntry)) as ResourceDirectoryEntry [];
- }
-
- void WriteResourceDirectoryEntry (ResourceDirectoryEntry rde)
- {
- GotoOffset (rde.Offset);
-
- if (rde.IdentifiedByName) {
- m_writer.Write ((uint) rde.Name.Offset | 0x80000000);
- WriteResourceDirectoryString (rde.Name);
- } else
- m_writer.Write ((uint) rde.ID);
-
- if (rde.Child is ResourceDirectoryTable) {
- m_writer.Write((uint) rde.Child.Offset | 0x80000000);
- WriteResourceDirectoryTable (rde.Child as ResourceDirectoryTable);
- } else {
- m_writer.Write (rde.Child.Offset);
- WriteResourceDataEntry (rde.Child as ResourceDataEntry);
- }
-
- RestoreOffset ();
- }
-
- void WriteResourceDataEntry (ResourceDataEntry rde)
- {
- GotoOffset (rde.Offset);
-
- m_writer.Write (0);
- m_writer.Write ((uint) rde.ResourceData.Length);
- m_writer.Write (rde.Codepage);
- m_writer.Write (rde.Reserved);
-
- m_writer.BaseStream.Position = rde.Data;
- m_writer.Write (rde.ResourceData);
-
- RestoreOffset ();
- }
-
- void WriteResourceDirectoryString (ResourceDirectoryString name)
- {
- GotoOffset (name.Offset);
-
- byte [] str = Encoding.Unicode.GetBytes (name.String);
- m_writer.Write ((ushort) str.Length);
- m_writer.Write (str);
-
- RestoreOffset ();
- }
-
- void GotoOffset (int offset)
- {
- m_pos = m_writer.BaseStream.Position;
- m_writer.BaseStream.Position = offset;
- }
-
- void RestoreOffset ()
- {
- m_writer.BaseStream.Position = m_pos;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RuntimeImage.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RuntimeImage.cs
deleted file mode 100644
index 8866ebb..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/RuntimeImage.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// RuntimeImage.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public enum RuntimeImage : uint {
- ILOnly = 0x0000001,
- F32BitsRequired = 0x0000002,
- StrongNameSigned = 0x0000008,
- TrackDebugData = 0x00010000
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Section.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Section.cs
deleted file mode 100644
index a05714b..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/Section.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-//
-// Section.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public sealed class Section : IHeader, IBinaryVisitable {
-
- public const string Text = ".text";
- public const string Resources = ".rsrc";
- public const string Relocs = ".reloc";
- public const string SData = ".sdata";
-
- public uint VirtualSize;
- public RVA VirtualAddress;
- public uint SizeOfRawData;
- public RVA PointerToRawData;
- public RVA PointerToRelocations;
- public RVA PointerToLineNumbers;
- public ushort NumberOfRelocations;
- public ushort NumberOfLineNumbers;
- public SectionCharacteristics Characteristics;
-
- public string Name;
- public byte [] Data;
-
- internal Section ()
- {
- }
-
- public void SetDefaultValues ()
- {
- PointerToLineNumbers = RVA.Zero;
- NumberOfLineNumbers = 0;
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitSection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCharacteristics.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCharacteristics.cs
deleted file mode 100644
index 66d97ed..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCharacteristics.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-//
-// SectionCharacteristics.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- using System;
-
- [Flags]
- public enum SectionCharacteristics : uint {
- TypeNoPad = 0x0000008,
- ContainsCode = 0x00000020,
- ContainsInitializedData = 0x00000040,
- ContainsUninitializedData = 0x00000080,
- LnkOther = 0x0000100,
- LnkInfo = 0x000200,
- LnkRemove = 0x0000800,
- LnkCOMDAT = 0x00001000,
- GPRel = 0x00008000,
- MemPurgeable = 0x00020000,
- MemLocked = 0x00040000,
- MemPreload = 0x00080000,
- Align1Bytes = 0x00100000,
- Align2Bytes = 0x00200000,
- Align4Bytes = 0x00300000,
- Align8Bytes = 0x00400000,
- Align16Bytes = 0x00500000,
- Align32Bytes = 0x00600000,
- Align64Bytes = 0x00700000,
- Align128Bytes = 0x00800000,
- Align256Bytes = 0x00900000,
- Align512Bytes = 0x00a00000,
- Align1024Bytes = 0x00b00000,
- Align2048Bytes = 0x00c00000,
- Align4096Bytes = 0x00d00000,
- Align8192Bytes = 0x00e00000,
- LnkNRelocOvfl = 0x01000000,
- MemDiscardable = 0x02000000,
- MemNotCached = 0x04000000,
- MemNotPaged = 0x08000000,
- MemShared = 0x10000000,
- MemExecute = 0x20000000,
- MemoryRead = 0x40000000,
- MemoryWrite = 0x80000000
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCollection.cs
deleted file mode 100644
index 2d90eee..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SectionCollection.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-//
-// SectionCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- using System;
- using System.Collections;
-
- public sealed class SectionCollection : ICollection, IBinaryVisitable {
-
- IList m_items;
-
- public Section this [int index]
- {
- get { return m_items [index] as Section; }
- set { m_items [index] = value; }
- }
-
- public int Count {
- get { return m_items.Count; }
- }
-
- public bool IsSynchronized {
- get { return false; }
- }
-
- public object SyncRoot {
- get { return this; }
- }
-
- internal SectionCollection ()
- {
- m_items = new ArrayList (4);
- }
-
- internal void Add (Section value)
- {
- m_items.Add (value);
- }
-
- internal void Clear ()
- {
- m_items.Clear ();
- }
-
- public bool Contains (Section value)
- {
- return m_items.Contains (value);
- }
-
- public int IndexOf (Section value)
- {
- return m_items.IndexOf (value);
- }
-
- internal void Insert (int index, Section value)
- {
- m_items.Insert (index, value);
- }
-
- internal void Remove (Section value)
- {
- m_items.Remove (value);
- }
-
- internal void RemoveAt (int index)
- {
- m_items.Remove (index);
- }
-
- public void CopyTo (Array ary, int index)
- {
- m_items.CopyTo (ary, index);
- }
-
- public IEnumerator GetEnumerator ()
- {
- return m_items.GetEnumerator ();
- }
-
- public void Accept (IBinaryVisitor visitor)
- {
- visitor.VisitSectionCollection (this);
-
- for (int i = 0; i < m_items.Count; i++)
- this [i].Accept (visitor);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SubSystem.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SubSystem.cs
deleted file mode 100644
index 2cab910..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/SubSystem.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// SubSystem.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Binary {
-
- public enum SubSystem : ushort {
- Unknown = 0x0,
- Native = 0x1,
- WindowsGui = 0x2,
- WindowsCui = 0x3,
- PosixCui = 0x7,
- WindowsCeGui = 0x9,
- EfiApplication = 0x10,
- EfiBootServiceDriver = 0x11,
- EfiRuntimeDriver = 0x12,
- EfiRom = 0x13,
- Xbox = 0x14,
- NexusAgent = 0x15
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/BaseCodeVisitor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/BaseCodeVisitor.cs
deleted file mode 100644
index d6e5051..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/BaseCodeVisitor.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-// BaseCodeVisitor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- public abstract class BaseCodeVisitor : ICodeVisitor {
-
- public virtual void VisitMethodBody (MethodBody body)
- {
- }
-
- public virtual void VisitInstructionCollection (InstructionCollection instructions)
- {
- }
-
- public virtual void VisitInstruction (Instruction instr)
- {
- }
-
- public virtual void VisitExceptionHandlerCollection (ExceptionHandlerCollection seh)
- {
- }
-
- public virtual void VisitExceptionHandler (ExceptionHandler eh)
- {
- }
-
- public virtual void VisitVariableDefinitionCollection (VariableDefinitionCollection variables)
- {
- }
-
- public virtual void VisitVariableDefinition (VariableDefinition var)
- {
- }
-
- public virtual void VisitScopeCollection (ScopeCollection scopes)
- {
- }
-
- public virtual void VisitScope (Scope s)
- {
- }
-
- public virtual void TerminateMethodBody (MethodBody body)
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CilWorker.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CilWorker.cs
deleted file mode 100644
index fbdc0ee..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CilWorker.cs
+++ /dev/null
@@ -1,357 +0,0 @@
-//
-// CilWorker.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- using System;
- using SR = System.Reflection;
-
- public sealed class CilWorker {
-
- MethodBody m_mbody;
- InstructionCollection m_instrs;
-
- internal CilWorker (MethodBody body)
- {
- m_mbody = body;
- m_instrs = m_mbody.Instructions;
- }
-
- public MethodBody GetBody ()
- {
- return m_mbody;
- }
-
- public Instruction Create (OpCode opcode)
- {
- if (opcode.OperandType != OperandType.InlineNone)
- throw new ArgumentException ("opcode");
-
- return FinalCreate (opcode);
- }
-
- public Instruction Create (OpCode opcode, TypeReference type)
- {
- if (opcode.OperandType != OperandType.InlineType &&
- opcode.OperandType != OperandType.InlineTok)
- throw new ArgumentException ("opcode");
-
- return FinalCreate (opcode, type);
- }
-
- public Instruction Create (OpCode opcode, MethodReference meth)
- {
- if (opcode.OperandType != OperandType.InlineMethod &&
- opcode.OperandType != OperandType.InlineTok)
- throw new ArgumentException ("opcode");
-
- return FinalCreate (opcode, meth);
- }
-
- public Instruction Create (OpCode opcode, FieldReference field)
- {
- if (opcode.OperandType != OperandType.InlineField &&
- opcode.OperandType != OperandType.InlineTok)
- throw new ArgumentException ("opcode");
-
- return FinalCreate (opcode, field);
- }
-
- public Instruction Create (OpCode opcode, string str)
- {
- if (opcode.OperandType != OperandType.InlineString)
- throw new ArgumentException ("opcode");
-
- return FinalCreate (opcode, str);
- }
-
- public Instruction Create (OpCode opcode, sbyte b)
- {
- if (opcode.OperandType != OperandType.ShortInlineI &&
- opcode != OpCodes.Ldc_I4_S)
- throw new ArgumentException ("opcode");
-
- return FinalCreate (opcode, b);
- }
-
- public Instruction Create (OpCode opcode, byte b)
- {
- if (opcode.OperandType != OperandType.ShortInlineI ||
- opcode == OpCodes.Ldc_I4_S)
- throw new ArgumentException ("opcode");
-
- return FinalCreate (opcode, b);
- }
-
- public Instruction Create (OpCode opcode, int i)
- {
- if (opcode.OperandType != OperandType.InlineI)
- throw new ArgumentException ("opcode");
-
- return FinalCreate (opcode, i);
- }
-
- public Instruction Create (OpCode opcode, long l)
- {
- if (opcode.OperandType != OperandType.InlineI8)
- throw new ArgumentException ("opcode");
-
- return FinalCreate (opcode, l);
- }
-
- public Instruction Create (OpCode opcode, float f)
- {
- if (opcode.OperandType != OperandType.ShortInlineR)
- throw new ArgumentException ("opcode");
-
- return FinalCreate (opcode, f);
- }
-
- public Instruction Create (OpCode opcode, double d)
- {
- if (opcode.OperandType != OperandType.InlineR)
- throw new ArgumentException ("opcode");
-
- return FinalCreate (opcode, d);
- }
-
- public Instruction Create (OpCode opcode, Instruction label)
- {
- if (opcode.OperandType != OperandType.InlineBrTarget &&
- opcode.OperandType != OperandType.ShortInlineBrTarget)
- throw new ArgumentException ("opcode");
-
- return FinalCreate (opcode, label);
- }
-
- public Instruction Create (OpCode opcode, Instruction [] labels)
- {
- if (opcode.OperandType != OperandType.InlineSwitch)
- throw new ArgumentException ("opcode");
-
- return FinalCreate (opcode, labels);
- }
-
- public Instruction Create (OpCode opcode, VariableDefinition var)
- {
- if (opcode.OperandType != OperandType.ShortInlineVar &&
- opcode.OperandType != OperandType.InlineVar)
- throw new ArgumentException ("opcode");
-
- return FinalCreate (opcode, var);
- }
-
- public Instruction Create (OpCode opcode, ParameterDefinition param)
- {
- if (opcode.OperandType != OperandType.ShortInlineParam &&
- opcode.OperandType != OperandType.InlineParam)
- throw new ArgumentException ("opcode");
-
- return FinalCreate (opcode, param);
- }
-
- Instruction FinalCreate (OpCode opcode)
- {
- return FinalCreate (opcode, null);
- }
-
- Instruction FinalCreate (OpCode opcode, object operand)
- {
- return new Instruction (opcode, operand);
- }
-
- public Instruction Emit (OpCode opcode)
- {
- Instruction instr = Create (opcode);
- Append (instr);
- return instr;
- }
-
- public Instruction Emit (OpCode opcode, TypeReference type)
- {
- Instruction instr = Create (opcode, type);
- Append (instr);
- return instr;
- }
-
- public Instruction Emit (OpCode opcode, MethodReference meth)
- {
- Instruction instr = Create (opcode, meth);
- Append (instr);
- return instr;
- }
-
- public Instruction Emit (OpCode opcode, FieldReference field)
- {
- Instruction instr = Create (opcode, field);
- Append (instr);
- return instr;
- }
-
- public Instruction Emit (OpCode opcode, string str)
- {
- Instruction instr = Create (opcode, str);
- Append (instr);
- return instr;
- }
-
- public Instruction Emit (OpCode opcode, byte b)
- {
- Instruction instr = Create (opcode, b);
- Append (instr);
- return instr;
- }
-
- public Instruction Emit (OpCode opcode, sbyte b)
- {
- Instruction instr = Create (opcode, b);
- Append (instr);
- return instr;
- }
-
- public Instruction Emit (OpCode opcode, int i)
- {
- Instruction instr = Create (opcode, i);
- Append (instr);
- return instr;
- }
-
- public Instruction Emit (OpCode opcode, long l)
- {
- Instruction instr = Create (opcode, l);
- Append (instr);
- return instr;
- }
-
- public Instruction Emit (OpCode opcode, float f)
- {
- Instruction instr = Create (opcode, f);
- Append (instr);
- return instr;
- }
-
- public Instruction Emit (OpCode opcode, double d)
- {
- Instruction instr = Create (opcode, d);
- Append (instr);
- return instr;
- }
-
- public Instruction Emit (OpCode opcode, Instruction target)
- {
- Instruction instr = Create (opcode, target);
- Append (instr);
- return instr;
- }
-
- public Instruction Emit (OpCode opcode, Instruction [] targets)
- {
- Instruction instr = Create (opcode, targets);
- Append (instr);
- return instr;
- }
-
- public Instruction Emit (OpCode opcode, VariableDefinition var)
- {
- Instruction instr = Create (opcode, var);
- Append (instr);
- return instr;
- }
-
- public Instruction Emit (OpCode opcode, ParameterDefinition param)
- {
- Instruction instr = Create (opcode, param);
- Append (instr);
- return instr;
- }
-
- public void InsertBefore (Instruction target, Instruction instr)
- {
- int index = m_instrs.IndexOf (target);
- if (index == -1)
- throw new ArgumentOutOfRangeException ("Target instruction not in method body");
-
- m_instrs.Insert (index, instr);
- instr.Previous = target.Previous;
- if (target.Previous != null)
- target.Previous.Next = instr;
- target.Previous = instr;
- instr.Next = target;
- }
-
- public void InsertAfter (Instruction target, Instruction instr)
- {
- int index = m_instrs.IndexOf (target);
- if (index == -1)
- throw new ArgumentOutOfRangeException ("Target instruction not in method body");
-
- m_instrs.Insert (index + 1, instr);
- instr.Next = target.Next;
- if (target.Next != null)
- target.Next.Previous = instr;
- target.Next = instr;
- instr.Previous = target;
- }
-
- public void Append (Instruction instr)
- {
- Instruction last = null, current = instr;
- if (m_instrs.Count > 0)
- last = m_instrs [m_instrs.Count - 1];
-
- if (last != null) {
- last.Next = instr;
- current.Previous = last;
- }
-
- m_instrs.Add (current);
- }
-
- public void Replace (Instruction old, Instruction instr)
- {
- int index = m_instrs.IndexOf (old);
- if (index == -1)
- throw new ArgumentOutOfRangeException ("Target instruction not in method body");
-
- InsertAfter (old, instr);
- Remove (old);
- }
-
- public void Remove (Instruction instr)
- {
- if (!m_instrs.Contains (instr))
- throw new ArgumentException ("Instruction not in method body");
-
- if (instr.Previous != null)
- instr.Previous.Next = instr.Next;
- if (instr.Next != null)
- instr.Next.Previous = instr.Previous;
- m_instrs.Remove (instr);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Code.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Code.cs
index af70ab5..bd18b84 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Code.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Code.cs
@@ -4,10 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Fri Mar 16 15:37:23 +0100 2007
-//
-// (C) 2007 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeReader.cs
index 20b1654..c780cc7 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeReader.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeReader.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 - 2007 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,330 +26,575 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
+using Mono.Cecil.PE;
+using Mono.Collections.Generic;
+
+using RVA = System.UInt32;
+
namespace Mono.Cecil.Cil {
- using System;
- using System.Collections;
- using System.IO;
+ sealed class CodeReader : ByteBuffer {
+
+ readonly internal MetadataReader reader;
+
+ int start;
+ Section code_section;
- using Mono.Cecil;
- using Mono.Cecil.Metadata;
- using Mono.Cecil.Signatures;
+ MethodDefinition method;
+ MethodBody body;
+
+ int Offset {
+ get { return base.position - start; }
+ }
+
+ 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;
+ this.body = new MethodBody (method);
+
+ reader.context = method;
+
+ ReadMethodBody ();
+
+ return this.body;
+ }
- class CodeReader : BaseCodeVisitor {
+ public void MoveTo (int rva)
+ {
+ if (!IsInSection (rva)) {
+ code_section = reader.image.GetSectionAtVirtualAddress ((uint) rva);
+ Reset (code_section.Data);
+ }
- ReflectionReader m_reflectReader;
- MetadataRoot m_root;
+ base.position = rva - (int) code_section.VirtualAddress;
+ }
- public CodeReader (ReflectionReader reflectReader)
+ bool IsInSection (int rva)
{
- m_reflectReader = reflectReader;
- m_root = m_reflectReader.MetadataRoot;
+ return code_section.VirtualAddress <= rva && rva < code_section.VirtualAddress + code_section.SizeOfRawData;
}
- public override void VisitMethodBody (MethodBody body)
+ void ReadMethodBody ()
{
- MethodDefinition meth = body.Method;
- MethodBody methBody = body;
- BinaryReader br = m_reflectReader.Module.ImageReader.MetadataReader.GetDataReader (meth.RVA);
+ MoveTo (method.RVA);
- // lets read the method
- IDictionary instrs;
- int flags = br.ReadByte ();
+ var flags = ReadByte ();
switch (flags & 0x3) {
- case (int) MethodHeader.TinyFormat :
- methBody.CodeSize = flags >> 2;
- methBody.MaxStack = 8;
- ReadCilBody (methBody, br, out instrs);
+ case 0x2: // tiny
+ body.code_size = flags >> 2;
+ body.MaxStackSize = 8;
+ ReadCode ();
break;
- case (int) MethodHeader.FatFormat :
- br.BaseStream.Position--;
- int fatflags = br.ReadUInt16 ();
- //int headersize = (fatflags >> 12) & 0xf;
- methBody.MaxStack = br.ReadUInt16 ();
- methBody.CodeSize = br.ReadInt32 ();
- methBody.LocalVarToken = br.ReadInt32 ();
- body.InitLocals = (fatflags & (int) MethodHeader.InitLocals) != 0;
- VisitVariableDefinitionCollection (methBody.Variables);
- ReadCilBody (methBody, br, out instrs);
- if ((fatflags & (int) MethodHeader.MoreSects) != 0)
- ReadSection (methBody, br, instrs);
+ case 0x3: // fat
+ base.position--;
+ ReadFatMethod ();
break;
+ default:
+ throw new InvalidOperationException ();
}
- if (m_reflectReader.SymbolReader != null)
- m_reflectReader.SymbolReader.Read (methBody);
+ var symbol_reader = reader.module.SymbolReader;
+
+ if (symbol_reader != null) {
+ var instructions = body.Instructions;
+ symbol_reader.Read (body, offset => GetInstruction (instructions, offset));
+ }
}
- public static uint GetRid (int token)
+ void ReadFatMethod ()
{
- return (uint) token & 0x00ffffff;
+ var flags = ReadUInt16 ();
+ body.max_stack_size = ReadUInt16 ();
+ body.code_size = (int) ReadUInt32 ();
+ body.local_var_token = new MetadataToken (ReadUInt32 ());
+ body.init_locals = (flags & 0x10) != 0;
+
+ if (body.LocalVarToken.RID != 0)
+ body.variables = ReadVariables (body.local_var_token);
+
+ ReadCode ();
+
+ if ((flags & 0x8) != 0)
+ ReadSection ();
}
- public static ParameterDefinition GetParameter (MethodBody body, int index)
+ public VariableDefinitionCollection ReadVariables (MetadataToken local_var_token)
{
- if (body.Method.HasThis) {
- if (index == 0)
- return body.Method.This;
- index--;
- }
+ var position = reader.position;
+ var variables = reader.ReadVariables (local_var_token);
+ reader.position = position;
- return body.Method.Parameters [index];
+ return variables;
}
- public static VariableDefinition GetVariable (MethodBody body, int index)
+ void ReadCode ()
{
- return body.Variables [index];
+ start = position;
+ var code_size = body.code_size;
+ var end = start + code_size;
+ var instructions = body.instructions = new InstructionCollection (code_size / 3);
+
+ while (position < end) {
+ var offset = base.position - start;
+ var opcode = ReadOpCode ();
+ var current = new Instruction (offset, opcode);
+
+ if (opcode.OperandType != OperandType.InlineNone)
+ current.operand = ReadOperand (current);
+
+ instructions.Add (current);
+ }
+
+ ResolveBranches (instructions);
}
- void ReadCilBody (MethodBody body, BinaryReader br, out IDictionary instructions)
+ OpCode ReadOpCode ()
{
- long start = br.BaseStream.Position;
- Instruction last = null;
- InstructionCollection code = body.Instructions;
- instructions = new Hashtable ();
- GenericContext context = new GenericContext (body.Method);
+ var il_opcode = ReadByte ();
+ return il_opcode != 0xfe
+ ? OpCodes.OneByteOpCode [il_opcode]
+ : OpCodes.TwoBytesOpCode [ReadByte ()];
+ }
- while (br.BaseStream.Position < start + body.CodeSize) {
- OpCode op;
- long offset = br.BaseStream.Position - start;
- int cursor = br.ReadByte ();
- if (cursor == 0xfe)
- op = OpCodes.TwoBytesOpCode [br.ReadByte ()];
- else
- op = OpCodes.OneByteOpCode [cursor];
+ object ReadOperand (Instruction instruction)
+ {
+ switch (instruction.opcode.OperandType) {
+ case OperandType.InlineSwitch:
+ var length = ReadInt32 ();
+ var base_offset = Offset + (4 * length);
+ var branches = new int [length];
+ for (int i = 0; i < length; i++)
+ branches [i] = base_offset + ReadInt32 ();
+ return branches;
+ case OperandType.ShortInlineBrTarget:
+ return ReadSByte () + Offset;
+ case OperandType.InlineBrTarget:
+ return ReadInt32 () + Offset;
+ case OperandType.ShortInlineI:
+ if (instruction.opcode == OpCodes.Ldc_I4_S)
+ return ReadSByte ();
+
+ return ReadByte ();
+ case OperandType.InlineI:
+ return ReadInt32 ();
+ case OperandType.ShortInlineR:
+ return ReadSingle ();
+ case OperandType.InlineR:
+ return ReadDouble ();
+ case OperandType.InlineI8:
+ return ReadInt64 ();
+ case OperandType.ShortInlineVar:
+ return GetVariable (ReadByte ());
+ case OperandType.InlineVar:
+ return GetVariable (ReadUInt16 ());
+ case OperandType.ShortInlineArg:
+ return GetParameter (ReadByte ());
+ case OperandType.InlineArg:
+ return GetParameter (ReadUInt16 ());
+ case OperandType.InlineSig:
+ return GetCallSite (ReadToken ());
+ case OperandType.InlineString:
+ return GetString (ReadToken ());
+ case OperandType.InlineTok:
+ case OperandType.InlineType:
+ case OperandType.InlineMethod:
+ case OperandType.InlineField:
+ return reader.LookupToken (ReadToken ());
+ default:
+ throw new NotSupportedException ();
+ }
+ }
- Instruction instr = new Instruction ((int) offset, op);
- switch (op.OperandType) {
- case OperandType.InlineNone :
- break;
- case OperandType.InlineSwitch :
- uint length = br.ReadUInt32 ();
- int [] branches = new int [length];
- int [] buf = new int [length];
- for (int i = 0; i < length; i++)
- buf [i] = br.ReadInt32 ();
- for (int i = 0; i < length; i++)
- branches [i] = Convert.ToInt32 (br.BaseStream.Position - start + buf [i]);
- instr.Operand = branches;
- break;
- case OperandType.ShortInlineBrTarget :
- sbyte sbrtgt = br.ReadSByte ();
- instr.Operand = Convert.ToInt32 (br.BaseStream.Position - start + sbrtgt);
- break;
- case OperandType.InlineBrTarget :
- int brtgt = br.ReadInt32 ();
- instr.Operand = Convert.ToInt32 (br.BaseStream.Position - start + brtgt);
- break;
- case OperandType.ShortInlineI :
- if (op == OpCodes.Ldc_I4_S)
- instr.Operand = br.ReadSByte ();
- else
- instr.Operand = br.ReadByte ();
- break;
- case OperandType.ShortInlineVar :
- instr.Operand = GetVariable (body, br.ReadByte ());
- break;
- case OperandType.ShortInlineParam :
- instr.Operand = GetParameter (body, br.ReadByte ());
- break;
- case OperandType.InlineSig :
- instr.Operand = GetCallSiteAt (br.ReadInt32 (), context);
- break;
- case OperandType.InlineI :
- instr.Operand = br.ReadInt32 ();
- break;
- case OperandType.InlineVar :
- instr.Operand = GetVariable (body, br.ReadInt16 ());
- break;
- case OperandType.InlineParam :
- instr.Operand = GetParameter (body, br.ReadInt16 ());
- break;
- case OperandType.InlineI8 :
- instr.Operand = br.ReadInt64 ();
- break;
- case OperandType.ShortInlineR :
- instr.Operand = br.ReadSingle ();
- break;
- case OperandType.InlineR :
- instr.Operand = br.ReadDouble ();
- break;
- case OperandType.InlineString :
- instr.Operand = m_root.Streams.UserStringsHeap [GetRid (br.ReadInt32 ())];
- break;
- case OperandType.InlineField :
- case OperandType.InlineMethod :
- case OperandType.InlineType :
- case OperandType.InlineTok :
- MetadataToken token = new MetadataToken (br.ReadInt32 ());
- switch (token.TokenType) {
- case TokenType.TypeDef:
- instr.Operand = m_reflectReader.GetTypeDefAt (token.RID);
- break;
- case TokenType.TypeRef:
- instr.Operand = m_reflectReader.GetTypeRefAt (token.RID);
- break;
- case TokenType.TypeSpec:
- instr.Operand = m_reflectReader.GetTypeSpecAt (token.RID, context);
- break;
- case TokenType.Field:
- instr.Operand = m_reflectReader.GetFieldDefAt (token.RID);
- break;
- case TokenType.Method:
- instr.Operand = m_reflectReader.GetMethodDefAt (token.RID);
- break;
- case TokenType.MethodSpec:
- instr.Operand = m_reflectReader.GetMethodSpecAt (token.RID, context);
- break;
- case TokenType.MemberRef:
- instr.Operand = m_reflectReader.GetMemberRefAt (token.RID, context);
- break;
- default:
- throw new ReflectionException ("Wrong token: " + token);
- }
- break;
- }
+ public string GetString (MetadataToken token)
+ {
+ return reader.image.UserStringHeap.Read (token.RID);
+ }
- instructions.Add (instr.Offset, instr);
+ public ParameterDefinition GetParameter (int index)
+ {
+ return body.GetParameter (index);
+ }
- if (last != null) {
- last.Next = instr;
- instr.Previous = last;
- }
+ public VariableDefinition GetVariable (int index)
+ {
+ return body.Variables [index];
+ }
- last = instr;
+ public CallSite GetCallSite (MetadataToken token)
+ {
+ return reader.ReadCallSite (token);
+ }
- code.Add (instr);
- }
+ void ResolveBranches (Collection<Instruction> instructions)
+ {
+ var items = instructions.items;
+ var size = instructions.size;
- // resolve branches
- foreach (Instruction i in code) {
- switch (i.OpCode.OperandType) {
+ for (int i = 0; i < size; i++) {
+ var instruction = items [i];
+ switch (instruction.opcode.OperandType) {
case OperandType.ShortInlineBrTarget:
case OperandType.InlineBrTarget:
- i.Operand = GetInstruction (body, instructions, (int) i.Operand);
+ instruction.operand = GetInstruction ((int) instruction.operand);
break;
case OperandType.InlineSwitch:
- int [] lbls = (int []) i.Operand;
- Instruction [] instrs = new Instruction [lbls.Length];
- for (int j = 0; j < lbls.Length; j++)
- instrs [j] = GetInstruction (body, instructions, lbls [j]);
- i.Operand = instrs;
+ var offsets = (int []) instruction.operand;
+ var branches = new Instruction [offsets.Length];
+ for (int j = 0; j < offsets.Length; j++)
+ branches [j] = GetInstruction (offsets [j]);
+
+ instruction.operand = branches;
break;
}
}
}
- static Instruction GetInstruction (MethodBody body, IDictionary instructions, int offset)
+ Instruction GetInstruction (int offset)
{
- Instruction instruction = instructions [offset] as Instruction;
- if (instruction != null)
- return instruction;
+ return GetInstruction (body.Instructions, offset);
+ }
- return body.Instructions.Outside;
+ static Instruction GetInstruction (Collection<Instruction> instructions, int offset)
+ {
+ var size = instructions.size;
+ var items = instructions.items;
+ if (offset < 0 || offset > items [size - 1].offset)
+ return null;
+
+ int min = 0;
+ int max = size - 1;
+ while (min <= max) {
+ int mid = min + ((max - min) / 2);
+ var instruction = items [mid];
+ var instruction_offset = instruction.offset;
+
+ if (offset == instruction_offset)
+ return instruction;
+
+ if (offset < instruction_offset)
+ max = mid - 1;
+ else
+ min = mid + 1;
+ }
+
+ return null;
}
- void ReadSection (MethodBody body, BinaryReader br, IDictionary instructions)
+ void ReadSection ()
{
- br.BaseStream.Position += 3;
- br.BaseStream.Position &= ~3;
+ Align (4);
- byte flags = br.ReadByte ();
- if ((flags & (byte) MethodDataSection.FatFormat) == 0) {
- int length = br.ReadByte () / 12;
- br.ReadBytes (2);
+ const byte fat_format = 0x40;
+ const byte more_sects = 0x80;
- for (int i = 0; i < length; i++) {
- ExceptionHandler eh = new ExceptionHandler (
- (ExceptionHandlerType) (br.ReadInt16 () & 0x7));
- eh.TryStart = GetInstruction (body, instructions, Convert.ToInt32 (br.ReadInt16 ()));
- eh.TryEnd = GetInstruction (body, instructions, eh.TryStart.Offset + Convert.ToInt32 (br.ReadByte ()));
- eh.HandlerStart = GetInstruction (body, instructions, Convert.ToInt32 (br.ReadInt16 ()));
- eh.HandlerEnd = GetInstruction (body, instructions, eh.HandlerStart.Offset + Convert.ToInt32 (br.ReadByte ()));
- ReadExceptionHandlerEnd (eh, br, body, instructions);
- body.ExceptionHandlers.Add (eh);
- }
- } else {
- br.BaseStream.Position--;
- int length = (br.ReadInt32 () >> 8) / 24;
- if ((flags & (int) MethodDataSection.EHTable) == 0)
- br.ReadBytes (length * 24);
- for (int i = 0; i < length; i++) {
- ExceptionHandler eh = new ExceptionHandler (
- (ExceptionHandlerType) (br.ReadInt32 () & 0x7));
- eh.TryStart = GetInstruction (body, instructions, br.ReadInt32 ());
- eh.TryEnd = GetInstruction (body, instructions, eh.TryStart.Offset + br.ReadInt32 ());
- eh.HandlerStart = GetInstruction (body, instructions, br.ReadInt32 ());
- eh.HandlerEnd = GetInstruction (body, instructions, eh.HandlerStart.Offset + br.ReadInt32 ());
- ReadExceptionHandlerEnd(eh, br, body, instructions);
- body.ExceptionHandlers.Add (eh);
- }
- }
+ var flags = ReadByte ();
+ if ((flags & fat_format) == 0)
+ ReadSmallSection ();
+ else
+ ReadFatSection ();
+
+ if ((flags & more_sects) != 0)
+ ReadSection ();
+ }
+
+ void ReadSmallSection ()
+ {
+ var count = ReadByte () / 12;
+ Advance (2);
- if ((flags & (byte) MethodDataSection.MoreSects) != 0)
- ReadSection (body, br, instructions);
+ ReadExceptionHandlers (
+ count,
+ () => (int) ReadUInt16 (),
+ () => (int) ReadByte ());
}
- void ReadExceptionHandlerEnd (ExceptionHandler eh, BinaryReader br, MethodBody body, IDictionary instructions)
+ void ReadFatSection ()
{
- switch (eh.Type) {
- case ExceptionHandlerType.Catch :
- MetadataToken token = new MetadataToken (br.ReadInt32 ());
- eh.CatchType = m_reflectReader.GetTypeDefOrRef (token, new GenericContext (body.Method));
+ position--;
+ var count = (ReadInt32 () >> 8) / 24;
+
+ ReadExceptionHandlers (
+ count,
+ ReadInt32,
+ ReadInt32);
+ }
+
+ // inline ?
+ void ReadExceptionHandlers (int count, Func<int> read_entry, Func<int> read_length)
+ {
+ for (int i = 0; i < count; i++) {
+ var handler = new ExceptionHandler (
+ (ExceptionHandlerType) (read_entry () & 0x7));
+
+ handler.TryStart = GetInstruction (read_entry ());
+ handler.TryEnd = GetInstruction (handler.TryStart.Offset + read_length ());
+
+ handler.HandlerStart = GetInstruction (read_entry ());
+ handler.HandlerEnd = GetInstruction (handler.HandlerStart.Offset + read_length ());
+
+ ReadExceptionHandlerSpecific (handler);
+
+ this.body.ExceptionHandlers.Add (handler);
+ }
+ }
+
+ void ReadExceptionHandlerSpecific (ExceptionHandler handler)
+ {
+ switch (handler.HandlerType) {
+ case ExceptionHandlerType.Catch:
+ handler.CatchType = (TypeReference) reader.LookupToken (ReadToken ());
+ break;
+ case ExceptionHandlerType.Filter:
+ handler.FilterStart = GetInstruction (ReadInt32 ());
+ handler.FilterEnd = handler.HandlerStart.Previous;
+ break;
+ default:
+ Advance (4);
break;
- case ExceptionHandlerType.Filter :
- eh.FilterStart = GetInstruction (body, instructions, br.ReadInt32 ());
- eh.FilterEnd = GetInstruction (body, instructions, eh.HandlerStart.Previous.Offset);
+ }
+ }
+
+ void Align (int align)
+ {
+ align--;
+ Advance (((position + align) & ~align) - position);
+ }
+
+ public MetadataToken ReadToken ()
+ {
+ return new MetadataToken (ReadUInt32 ());
+ }
+
+#if !READ_ONLY
+
+ public ByteBuffer PatchRawMethodBody (MethodDefinition method, CodeWriter writer, out MethodSymbols symbols)
+ {
+ var buffer = new ByteBuffer ();
+ symbols = new MethodSymbols (method.Name);
+
+ this.method = method;
+ reader.context = method;
+
+ MoveTo (method.RVA);
+
+ var flags = ReadByte ();
+
+ MetadataToken local_var_token;
+
+ switch (flags & 0x3) {
+ case 0x2: // tiny
+ buffer.WriteByte (flags);
+ local_var_token = MetadataToken.Zero;
+ symbols.code_size = flags >> 2;
+ PatchRawCode (buffer, symbols.code_size, writer);
break;
- default :
- br.ReadInt32 ();
+ case 0x3: // fat
+ base.position--;
+
+ PatchRawFatMethod (buffer, symbols, writer, out local_var_token);
break;
+ default:
+ throw new NotSupportedException ();
+ }
+
+ var symbol_reader = reader.module.SymbolReader;
+ if (symbol_reader != null && writer.metadata.write_symbols) {
+ symbols.method_token = GetOriginalToken (writer.metadata, method);
+ symbols.local_var_token = local_var_token;
+ symbol_reader.Read (symbols);
}
+
+ return buffer;
+ }
+
+ void PatchRawFatMethod (ByteBuffer buffer, MethodSymbols symbols, CodeWriter writer, out MetadataToken local_var_token)
+ {
+ var flags = ReadUInt16 ();
+ buffer.WriteUInt16 (flags);
+ buffer.WriteUInt16 (ReadUInt16 ());
+ symbols.code_size = ReadInt32 ();
+ buffer.WriteInt32 (symbols.code_size);
+ local_var_token = ReadToken ();
+
+ if (local_var_token.RID > 0) {
+ var variables = symbols.variables = ReadVariables (local_var_token);
+ buffer.WriteUInt32 (variables != null
+ ? writer.GetStandAloneSignature (symbols.variables).ToUInt32 ()
+ : 0);
+ } else
+ buffer.WriteUInt32 (0);
+
+ PatchRawCode (buffer, symbols.code_size, writer);
+
+ if ((flags & 0x8) != 0)
+ PatchRawSection (buffer, writer.metadata);
}
- CallSite GetCallSiteAt (int token, GenericContext context)
+ static MetadataToken GetOriginalToken (MetadataBuilder metadata, MethodDefinition method)
{
- StandAloneSigTable sasTable = m_reflectReader.TableReader.GetStandAloneSigTable ();
- MethodSig ms = m_reflectReader.SigReader.GetStandAloneMethodSig (
- sasTable [(int) GetRid (token) - 1].Signature);
- CallSite cs = new CallSite (ms.HasThis, ms.ExplicitThis,
- ms.MethCallConv, m_reflectReader.GetMethodReturnType (ms, context));
- cs.MetadataToken = new MetadataToken (token);
+ MetadataToken original;
+ if (metadata.TryGetOriginalMethodToken (method.token, out original))
+ return original;
+
+ return MetadataToken.Zero;
+ }
+
+ void PatchRawCode (ByteBuffer buffer, int code_size, CodeWriter writer)
+ {
+ var metadata = writer.metadata;
+ buffer.WriteBytes (ReadBytes (code_size));
+ var end = buffer.position;
+ buffer.position -= code_size;
+
+ while (buffer.position < end) {
+ OpCode opcode;
+ var il_opcode = buffer.ReadByte ();
+ if (il_opcode != 0xfe) {
+ opcode = OpCodes.OneByteOpCode [il_opcode];
+ } else {
+ var il_opcode2 = buffer.ReadByte ();
+ opcode = OpCodes.TwoBytesOpCode [il_opcode2];
+ }
- for (int i = 0; i < ms.ParamCount; i++) {
- Param p = ms.Parameters [i];
- cs.Parameters.Add (m_reflectReader.BuildParameterDefinition (i, p, context));
+ switch (opcode.OperandType) {
+ case OperandType.ShortInlineI:
+ case OperandType.ShortInlineBrTarget:
+ case OperandType.ShortInlineVar:
+ case OperandType.ShortInlineArg:
+ buffer.position += 1;
+ break;
+ case OperandType.InlineVar:
+ case OperandType.InlineArg:
+ buffer.position += 2;
+ break;
+ case OperandType.InlineBrTarget:
+ case OperandType.ShortInlineR:
+ case OperandType.InlineI:
+ buffer.position += 4;
+ break;
+ case OperandType.InlineI8:
+ case OperandType.InlineR:
+ buffer.position += 8;
+ break;
+ case OperandType.InlineSwitch:
+ var length = buffer.ReadInt32 ();
+ buffer.position += length * 4;
+ break;
+ case OperandType.InlineString:
+ var @string = GetString (new MetadataToken (buffer.ReadUInt32 ()));
+ buffer.position -= 4;
+ buffer.WriteUInt32 (
+ new MetadataToken (
+ TokenType.String,
+ metadata.user_string_heap.GetStringIndex (@string)).ToUInt32 ());
+ break;
+ case OperandType.InlineSig:
+ var call_site = GetCallSite (new MetadataToken (buffer.ReadUInt32 ()));
+ buffer.position -= 4;
+ buffer.WriteUInt32 (writer.GetStandAloneSignature (call_site).ToUInt32 ());
+ break;
+ case OperandType.InlineTok:
+ case OperandType.InlineType:
+ case OperandType.InlineMethod:
+ case OperandType.InlineField:
+ var provider = reader.LookupToken (new MetadataToken (buffer.ReadUInt32 ()));
+ buffer.position -= 4;
+ buffer.WriteUInt32 (metadata.LookupToken (provider).ToUInt32 ());
+ break;
+ }
}
+ }
+
+ void PatchRawSection (ByteBuffer buffer, MetadataBuilder metadata)
+ {
+ var position = base.position;
+ Align (4);
+ buffer.WriteBytes (base.position - position);
+
+ const byte fat_format = 0x40;
+ const byte more_sects = 0x80;
+
+ var flags = ReadByte ();
+ if ((flags & fat_format) == 0) {
+ buffer.WriteByte (flags);
+ PatchRawSmallSection (buffer, metadata);
+ } else
+ PatchRawFatSection (buffer, metadata);
+
+ if ((flags & more_sects) != 0)
+ PatchRawSection (buffer, metadata);
+ }
+
+ void PatchRawSmallSection (ByteBuffer buffer, MetadataBuilder metadata)
+ {
+ var length = ReadByte ();
+ buffer.WriteByte (length);
+ Advance (2);
+
+ buffer.WriteUInt16 (0);
- ReflectionReader.CreateSentinelIfNeeded (cs, ms);
+ var count = length / 12;
- return cs;
+ PatchRawExceptionHandlers (buffer, metadata, count, false);
}
- public override void VisitVariableDefinitionCollection (VariableDefinitionCollection variables)
+ void PatchRawFatSection (ByteBuffer buffer, MetadataBuilder metadata)
{
- MethodBody body = variables.Container as MethodBody;
- if (body == null || body.LocalVarToken == 0)
- return;
+ position--;
+ var length = ReadInt32 ();
+ buffer.WriteInt32 (length);
- StandAloneSigTable sasTable = m_reflectReader.TableReader.GetStandAloneSigTable ();
- StandAloneSigRow sasRow = sasTable [(int) GetRid (body.LocalVarToken) - 1];
- LocalVarSig sig = m_reflectReader.SigReader.GetLocalVarSig (sasRow.Signature);
- for (int i = 0; i < sig.Count; i++) {
- LocalVarSig.LocalVariable lv = sig.LocalVariables [i];
- TypeReference varType = m_reflectReader.GetTypeRefFromSig (
- lv.Type, new GenericContext (body.Method));
+ var count = (length >> 8) / 24;
- if (lv.ByRef)
- varType = new ReferenceType (varType);
- if ((lv.Constraint & Constraint.Pinned) != 0)
- varType = new PinnedType (varType);
+ PatchRawExceptionHandlers (buffer, metadata, count, true);
+ }
- varType = m_reflectReader.GetModifierType (lv.CustomMods, varType);
+ void PatchRawExceptionHandlers (ByteBuffer buffer, MetadataBuilder metadata, int count, bool fat_entry)
+ {
+ const int fat_entry_size = 16;
+ const int small_entry_size = 6;
+
+ for (int i = 0; i < count; i++) {
+ ExceptionHandlerType handler_type;
+ if (fat_entry) {
+ var type = ReadUInt32 ();
+ handler_type = (ExceptionHandlerType) (type & 0x7);
+ buffer.WriteUInt32 (type);
+ } else {
+ var type = ReadUInt16 ();
+ handler_type = (ExceptionHandlerType) (type & 0x7);
+ buffer.WriteUInt16 (type);
+ }
- body.Variables.Add (new VariableDefinition (
- string.Concat ("V_", i), i, body.Method, varType));
+ buffer.WriteBytes (ReadBytes (fat_entry ? fat_entry_size : small_entry_size));
+
+ switch (handler_type) {
+ case ExceptionHandlerType.Catch:
+ var exception = reader.LookupToken (ReadToken ());
+ buffer.WriteUInt32 (metadata.LookupToken (exception).ToUInt32 ());
+ break;
+ default:
+ buffer.WriteUInt32 (ReadUInt32 ());
+ break;
+ }
}
}
+
+#endif
+
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs
index 446b9a2..8bf0722 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/CodeWriter.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 - 2007 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,437 +26,613 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil.Cil {
+using System;
+using System.Collections.Generic;
- using System;
- using System.Collections;
+using Mono.Collections.Generic;
- using Mono.Cecil;
- using Mono.Cecil.Binary;
- using Mono.Cecil.Metadata;
- using Mono.Cecil.Signatures;
+using Mono.Cecil.Metadata;
+using Mono.Cecil.PE;
- class CodeWriter : BaseCodeVisitor {
+using RVA = System.UInt32;
- ReflectionWriter m_reflectWriter;
- MemoryBinaryWriter m_binaryWriter;
- MemoryBinaryWriter m_codeWriter;
+#if !READ_ONLY
- IDictionary m_localSigCache;
- IDictionary m_standaloneSigCache;
+namespace Mono.Cecil.Cil {
- public CodeWriter (ReflectionWriter reflectWriter, MemoryBinaryWriter writer)
- {
- m_reflectWriter = reflectWriter;
- m_binaryWriter = writer;
- m_codeWriter = new MemoryBinaryWriter ();
+ sealed class CodeWriter : ByteBuffer {
- m_localSigCache = new Hashtable ();
- m_standaloneSigCache = new Hashtable ();
+ readonly RVA code_base;
+ internal readonly MetadataBuilder metadata;
+ readonly Dictionary<uint, MetadataToken> standalone_signatures;
+
+ RVA current;
+ MethodBody body;
+
+ public CodeWriter (MetadataBuilder metadata)
+ : base (0)
+ {
+ this.code_base = metadata.text_map.GetNextRVA (TextSegment.CLIHeader);
+ this.current = code_base;
+ this.metadata = metadata;
+ this.standalone_signatures = new Dictionary<uint, MetadataToken> ();
}
- public RVA WriteMethodBody (MethodDefinition meth)
+ public RVA WriteMethodBody (MethodDefinition method)
{
- if (meth.Body == null)
- return RVA.Zero;
+ var rva = BeginMethod ();
+
+ if (IsUnresolved (method)) {
+ if (method.rva == 0)
+ return 0;
+
+ WriteUnresolvedMethodBody (method);
+ } else {
+ if (IsEmptyMethodBody (method.Body))
+ return 0;
+
+ WriteResolvedMethodBody (method);
+ }
+
+ Align (4);
- RVA ret = m_reflectWriter.MetadataWriter.GetDataCursor ();
- meth.Body.Accept (this);
- return ret;
+ EndMethod ();
+ return rva;
}
- public override void VisitMethodBody (MethodBody body)
+ static bool IsEmptyMethodBody (MethodBody body)
{
- m_codeWriter.Empty ();
+ return body.instructions.IsNullOrEmpty ()
+ && body.variables.IsNullOrEmpty ();
}
- void WriteToken (MetadataToken token)
+ static bool IsUnresolved (MethodDefinition method)
{
- if (token.RID == 0)
- m_codeWriter.Write (0);
- else
- m_codeWriter.Write (token.ToUInt ());
+ return method.HasBody && method.HasImage && method.body == null;
}
- static int GetParameterIndex (MethodBody body, ParameterDefinition p)
+ void WriteUnresolvedMethodBody (MethodDefinition method)
{
- int idx = body.Method.Parameters.IndexOf (p);
- if (idx == -1 && p == body.Method.This)
- return 0;
- if (body.Method.HasThis)
- idx++;
+ var code_reader = metadata.module.Read (method, (_, reader) => reader.code);
+
+ MethodSymbols symbols;
+ var buffer = code_reader.PatchRawMethodBody (method, this, out symbols);
+
+ WriteBytes (buffer);
+
+ if (symbols.instructions.IsNullOrEmpty ())
+ return;
- return idx;
+ symbols.method_token = method.token;
+ symbols.local_var_token = GetLocalVarToken (buffer, symbols);
+
+ var symbol_writer = metadata.symbol_writer;
+ if (symbol_writer != null)
+ symbol_writer.Write (symbols);
}
- public override void VisitInstructionCollection (InstructionCollection instructions)
+ static MetadataToken GetLocalVarToken (ByteBuffer buffer, MethodSymbols symbols)
{
- MethodBody body = instructions.Container;
- long start = m_codeWriter.BaseStream.Position;
+ if (symbols.variables.IsNullOrEmpty ())
+ return MetadataToken.Zero;
- ComputeMaxStack (instructions);
+ buffer.position = 8;
+ return new MetadataToken (buffer.ReadUInt32 ());
+ }
- foreach (Instruction instr in instructions) {
+ void WriteResolvedMethodBody (MethodDefinition method)
+ {
+ body = method.Body;
+ ComputeHeader ();
+ if (RequiresFatHeader ())
+ WriteFatHeader ();
+ else
+ WriteByte ((byte) (0x2 | (body.CodeSize << 2))); // tiny
- instr.Offset = (int) (m_codeWriter.BaseStream.Position - start);
+ WriteInstructions ();
- if (instr.OpCode.Size == 1)
- m_codeWriter.Write (instr.OpCode.Op2);
- else {
- m_codeWriter.Write (instr.OpCode.Op1);
- m_codeWriter.Write (instr.OpCode.Op2);
- }
+ if (body.HasExceptionHandlers)
+ WriteExceptionHandlers ();
- if (instr.OpCode.OperandType != OperandType.InlineNone &&
- instr.Operand == null)
- throw new ReflectionException ("OpCode {0} have null operand", instr.OpCode.Name);
+ var symbol_writer = metadata.symbol_writer;
+ if (symbol_writer != null)
+ symbol_writer.Write (body);
+ }
- switch (instr.OpCode.OperandType) {
- case OperandType.InlineNone :
- break;
- case OperandType.InlineSwitch :
- Instruction [] targets = (Instruction []) instr.Operand;
- for (int i = 0; i < targets.Length + 1; i++)
- m_codeWriter.Write ((uint) 0);
- break;
- case OperandType.ShortInlineBrTarget :
- m_codeWriter.Write ((byte) 0);
- break;
- case OperandType.InlineBrTarget :
- m_codeWriter.Write (0);
- break;
- case OperandType.ShortInlineI :
- if (instr.OpCode == OpCodes.Ldc_I4_S)
- m_codeWriter.Write ((sbyte) instr.Operand);
- else
- m_codeWriter.Write ((byte) instr.Operand);
- break;
- case OperandType.ShortInlineVar :
- m_codeWriter.Write ((byte) body.Variables.IndexOf (
- (VariableDefinition) instr.Operand));
- break;
- case OperandType.ShortInlineParam :
- m_codeWriter.Write ((byte) GetParameterIndex (body, (ParameterDefinition) instr.Operand));
- break;
- case OperandType.InlineSig :
- WriteToken (GetCallSiteToken ((CallSite) instr.Operand));
- break;
- case OperandType.InlineI :
- m_codeWriter.Write ((int) instr.Operand);
- break;
- case OperandType.InlineVar :
- m_codeWriter.Write ((short) body.Variables.IndexOf (
- (VariableDefinition) instr.Operand));
- break;
- case OperandType.InlineParam :
- m_codeWriter.Write ((short) GetParameterIndex (
- body, (ParameterDefinition) instr.Operand));
- break;
- case OperandType.InlineI8 :
- m_codeWriter.Write ((long) instr.Operand);
- break;
- case OperandType.ShortInlineR :
- m_codeWriter.Write ((float) instr.Operand);
- break;
- case OperandType.InlineR :
- m_codeWriter.Write ((double) instr.Operand);
- break;
- case OperandType.InlineString :
- WriteToken (new MetadataToken (TokenType.String,
- m_reflectWriter.MetadataWriter.AddUserString (instr.Operand as string)));
- break;
- case OperandType.InlineField :
- case OperandType.InlineMethod :
- case OperandType.InlineType :
- case OperandType.InlineTok :
- if (instr.Operand is TypeReference)
- WriteToken (m_reflectWriter.GetTypeDefOrRefToken (
- instr.Operand as TypeReference));
- else if (instr.Operand is GenericInstanceMethod)
- WriteToken (m_reflectWriter.GetMethodSpecToken (instr.Operand as GenericInstanceMethod));
- else if (instr.Operand is MemberReference)
- WriteToken (m_reflectWriter.GetMemberRefToken ((MemberReference) instr.Operand));
- else if (instr.Operand is IMetadataTokenProvider)
- WriteToken (((IMetadataTokenProvider) instr.Operand).MetadataToken);
- else
- throw new ReflectionException (
- string.Format ("Wrong operand for {0} OpCode: {1}",
- instr.OpCode.OperandType,
- instr.Operand.GetType ().FullName));
- break;
- }
+ void WriteFatHeader ()
+ {
+ var body = this.body;
+ byte flags = 0x3; // fat
+ if (body.InitLocals)
+ flags |= 0x10; // init locals
+ if (body.HasExceptionHandlers)
+ flags |= 0x8; // more sections
+
+ WriteByte (flags);
+ WriteByte (0x30);
+ WriteInt16 ((short) body.max_stack_size);
+ WriteInt32 (body.code_size);
+ body.local_var_token = body.HasVariables
+ ? GetStandAloneSignature (body.Variables)
+ : MetadataToken.Zero;
+ WriteMetadataToken (body.local_var_token);
+ }
+
+ void WriteInstructions ()
+ {
+ var instructions = body.Instructions;
+ var items = instructions.items;
+ var size = instructions.size;
+
+ for (int i = 0; i < size; i++) {
+ var instruction = items [i];
+ WriteOpCode (instruction.opcode);
+ WriteOperand (instruction);
}
+ }
- // patch branches
- long pos = m_codeWriter.BaseStream.Position;
-
- foreach (Instruction instr in instructions) {
- switch (instr.OpCode.OperandType) {
- case OperandType.InlineSwitch :
- m_codeWriter.BaseStream.Position = instr.Offset + instr.OpCode.Size;
- Instruction [] targets = (Instruction []) instr.Operand;
- m_codeWriter.Write ((uint) targets.Length);
- foreach (Instruction tgt in targets)
- m_codeWriter.Write ((tgt.Offset - (instr.Offset +
- instr.OpCode.Size + (4 * (targets.Length + 1)))));
- break;
- case OperandType.ShortInlineBrTarget :
- m_codeWriter.BaseStream.Position = instr.Offset + instr.OpCode.Size;
- m_codeWriter.Write ((byte) (((Instruction) instr.Operand).Offset -
- (instr.Offset + instr.OpCode.Size + 1)));
- break;
- case OperandType.InlineBrTarget :
- m_codeWriter.BaseStream.Position = instr.Offset + instr.OpCode.Size;
- m_codeWriter.Write(((Instruction) instr.Operand).Offset -
- (instr.Offset + instr.OpCode.Size + 4));
- break;
- }
+ void WriteOpCode (OpCode opcode)
+ {
+ if (opcode.Size == 1) {
+ WriteByte (opcode.Op2);
+ } else {
+ WriteByte (opcode.Op1);
+ WriteByte (opcode.Op2);
}
+ }
+
+ void WriteOperand (Instruction instruction)
+ {
+ var opcode = instruction.opcode;
+ var operand_type = opcode.OperandType;
+ if (operand_type == OperandType.InlineNone)
+ return;
- m_codeWriter.BaseStream.Position = pos;
+ var operand = instruction.operand;
+ if (operand == null)
+ throw new ArgumentException ();
+
+ switch (operand_type) {
+ case OperandType.InlineSwitch: {
+ var targets = (Instruction []) operand;
+ WriteInt32 (targets.Length);
+ var diff = instruction.Offset + opcode.Size + (4 * (targets.Length + 1));
+ for (int i = 0; i < targets.Length; i++)
+ WriteInt32 (GetTargetOffset (targets [i]) - diff);
+ break;
+ }
+ case OperandType.ShortInlineBrTarget: {
+ var target = (Instruction) operand;
+ WriteSByte ((sbyte) (GetTargetOffset (target) - (instruction.Offset + opcode.Size + 1)));
+ break;
+ }
+ case OperandType.InlineBrTarget: {
+ var target = (Instruction) operand;
+ WriteInt32 (GetTargetOffset (target) - (instruction.Offset + opcode.Size + 4));
+ break;
+ }
+ case OperandType.ShortInlineVar:
+ WriteByte ((byte) GetVariableIndex ((VariableDefinition) operand));
+ break;
+ case OperandType.ShortInlineArg:
+ WriteByte ((byte) GetParameterIndex ((ParameterDefinition) operand));
+ break;
+ case OperandType.InlineVar:
+ WriteInt16 ((short) GetVariableIndex ((VariableDefinition) operand));
+ break;
+ case OperandType.InlineArg:
+ WriteInt16 ((short) GetParameterIndex ((ParameterDefinition) operand));
+ break;
+ case OperandType.InlineSig:
+ WriteMetadataToken (GetStandAloneSignature ((CallSite) operand));
+ break;
+ case OperandType.ShortInlineI:
+ if (opcode == OpCodes.Ldc_I4_S)
+ WriteSByte ((sbyte) operand);
+ else
+ WriteByte ((byte) operand);
+ break;
+ case OperandType.InlineI:
+ WriteInt32 ((int) operand);
+ break;
+ case OperandType.InlineI8:
+ WriteInt64 ((long) operand);
+ break;
+ case OperandType.ShortInlineR:
+ WriteSingle ((float) operand);
+ break;
+ case OperandType.InlineR:
+ WriteDouble ((double) operand);
+ break;
+ case OperandType.InlineString:
+ WriteMetadataToken (
+ new MetadataToken (
+ TokenType.String,
+ GetUserStringIndex ((string) operand)));
+ break;
+ case OperandType.InlineType:
+ case OperandType.InlineField:
+ case OperandType.InlineMethod:
+ case OperandType.InlineTok:
+ WriteMetadataToken (metadata.LookupToken ((IMetadataTokenProvider) operand));
+ break;
+ default:
+ throw new ArgumentException ();
+ }
}
- MetadataToken GetCallSiteToken (CallSite cs)
+ int GetTargetOffset (Instruction instruction)
{
- uint sig;
- int sentinel = cs.GetSentinel ();
- if (sentinel > 0)
- sig = m_reflectWriter.SignatureWriter.AddMethodDefSig (
- m_reflectWriter.GetMethodDefSig (cs));
- else
- sig = m_reflectWriter.SignatureWriter.AddMethodRefSig (
- m_reflectWriter.GetMethodRefSig (cs));
+ if (instruction == null) {
+ var last = body.instructions [body.instructions.size - 1];
+ return last.offset + last.GetSize ();
+ }
- if (m_standaloneSigCache.Contains (sig))
- return (MetadataToken) m_standaloneSigCache [sig];
+ return instruction.offset;
+ }
- StandAloneSigTable sasTable = m_reflectWriter.MetadataTableWriter.GetStandAloneSigTable ();
- StandAloneSigRow sasRow = m_reflectWriter.MetadataRowWriter.CreateStandAloneSigRow (sig);
+ uint GetUserStringIndex (string @string)
+ {
+ if (@string == null)
+ return 0;
- sasTable.Rows.Add(sasRow);
+ return metadata.user_string_heap.GetStringIndex (@string);
+ }
- MetadataToken token = new MetadataToken (TokenType.Signature, (uint) sasTable.Rows.Count);
- m_standaloneSigCache [sig] = token;
- return token;
+ static int GetVariableIndex (VariableDefinition variable)
+ {
+ return variable.Index;
}
- static int GetLength (Instruction start, Instruction end, InstructionCollection instructions)
+ int GetParameterIndex (ParameterDefinition parameter)
{
- Instruction last = instructions [instructions.Count - 1];
- return (end == instructions.Outside ? last.Offset + last.GetSize () : end.Offset) - start.Offset;
+ if (body.method.HasThis) {
+ if (parameter == body.this_parameter)
+ return 0;
+
+ return parameter.Index + 1;
+ }
+
+ return parameter.Index;
}
- static bool IsRangeFat (Instruction start, Instruction end, InstructionCollection instructions)
+ bool RequiresFatHeader ()
{
- return GetLength (start, end, instructions) >= 256 ||
- start.Offset >= 65536;
+ var body = this.body;
+ return body.CodeSize >= 64
+ || body.InitLocals
+ || body.HasVariables
+ || body.HasExceptionHandlers
+ || body.MaxStackSize > 8;
}
- static bool IsFat (ExceptionHandlerCollection seh)
+ void ComputeHeader ()
{
- for (int i = 0; i < seh.Count; i++) {
- ExceptionHandler eh = seh [i];
- if (IsRangeFat (eh.TryStart, eh.TryEnd, seh.Container.Instructions))
- return true;
+ int offset = 0;
+ var instructions = body.instructions;
+ var items = instructions.items;
+ var count = instructions.size;
+ var stack_size = 0;
+ var max_stack = 0;
+ Dictionary<Instruction, int> stack_sizes = null;
+
+ if (body.HasExceptionHandlers)
+ ComputeExceptionHandlerStackSize (ref stack_sizes);
+
+ for (int i = 0; i < count; i++) {
+ var instruction = items [i];
+ instruction.offset = offset;
+ offset += instruction.GetSize ();
+
+ ComputeStackSize (instruction, ref stack_sizes, ref stack_size, ref max_stack);
+ }
- if (IsRangeFat (eh.HandlerStart, eh.HandlerEnd, seh.Container.Instructions))
- return true;
+ body.code_size = offset;
+ body.max_stack_size = max_stack;
+ }
+
+ void ComputeExceptionHandlerStackSize (ref Dictionary<Instruction, int> stack_sizes)
+ {
+ var exception_handlers = body.ExceptionHandlers;
+
+ for (int i = 0; i < exception_handlers.Count; i++) {
+ var exception_handler = exception_handlers [i];
- switch (eh.Type) {
- case ExceptionHandlerType.Filter :
- if (IsRangeFat (eh.FilterStart, eh.FilterEnd, seh.Container.Instructions))
- return true;
+ switch (exception_handler.HandlerType) {
+ case ExceptionHandlerType.Catch:
+ AddExceptionStackSize (exception_handler.HandlerStart, ref stack_sizes);
+ break;
+ case ExceptionHandlerType.Filter:
+ AddExceptionStackSize (exception_handler.FilterStart, ref stack_sizes);
+ AddExceptionStackSize (exception_handler.HandlerStart, ref stack_sizes);
break;
}
}
+ }
- return false;
+ static void AddExceptionStackSize (Instruction handler_start, ref Dictionary<Instruction, int> stack_sizes)
+ {
+ if (handler_start == null)
+ return;
+
+ if (stack_sizes == null)
+ stack_sizes = new Dictionary<Instruction, int> ();
+
+ stack_sizes [handler_start] = 1;
}
- void WriteExceptionHandlerCollection (ExceptionHandlerCollection seh)
+ static void ComputeStackSize (Instruction instruction, ref Dictionary<Instruction, int> stack_sizes, ref int stack_size, ref int max_stack)
{
- m_codeWriter.QuadAlign ();
+ int computed_size;
+ if (stack_sizes != null && stack_sizes.TryGetValue (instruction, out computed_size))
+ stack_size = computed_size;
- if (seh.Count < 0x15 && !IsFat (seh)) {
- m_codeWriter.Write ((byte) MethodDataSection.EHTable);
- m_codeWriter.Write ((byte) (seh.Count * 12 + 4));
- m_codeWriter.Write (new byte [2]);
- foreach (ExceptionHandler eh in seh) {
- m_codeWriter.Write ((ushort) eh.Type);
- m_codeWriter.Write ((ushort) eh.TryStart.Offset);
- m_codeWriter.Write ((byte) (eh.TryEnd.Offset - eh.TryStart.Offset));
- m_codeWriter.Write ((ushort) eh.HandlerStart.Offset);
- m_codeWriter.Write ((byte) GetLength (eh.HandlerStart, eh.HandlerEnd, seh.Container.Instructions));
- WriteHandlerSpecific (eh);
- }
- } else {
- m_codeWriter.Write ((byte) (MethodDataSection.FatFormat | MethodDataSection.EHTable));
- WriteFatBlockSize (seh);
- foreach (ExceptionHandler eh in seh) {
- m_codeWriter.Write ((uint) eh.Type);
- m_codeWriter.Write ((uint) eh.TryStart.Offset);
- m_codeWriter.Write ((uint) (eh.TryEnd.Offset - eh.TryStart.Offset));
- m_codeWriter.Write ((uint) eh.HandlerStart.Offset);
- m_codeWriter.Write ((uint) GetLength (eh.HandlerStart, eh.HandlerEnd, seh.Container.Instructions));
- WriteHandlerSpecific (eh);
- }
+ max_stack = System.Math.Max (max_stack, stack_size);
+ ComputeStackDelta (instruction, ref stack_size);
+ max_stack = System.Math.Max (max_stack, stack_size);
+
+ CopyBranchStackSize (instruction, ref stack_sizes, stack_size);
+ ComputeStackSize (instruction, ref stack_size);
+ }
+
+ static void CopyBranchStackSize (Instruction instruction, ref Dictionary<Instruction, int> stack_sizes, int stack_size)
+ {
+ if (stack_size == 0)
+ return;
+
+ switch (instruction.opcode.OperandType) {
+ case OperandType.ShortInlineBrTarget:
+ case OperandType.InlineBrTarget:
+ CopyBranchStackSize (ref stack_sizes, (Instruction) instruction.operand, stack_size);
+ break;
+ case OperandType.InlineSwitch:
+ var targets = (Instruction[]) instruction.operand;
+ for (int i = 0; i < targets.Length; i++)
+ CopyBranchStackSize (ref stack_sizes, targets [i], stack_size);
+ break;
+ }
+ }
+
+ static void CopyBranchStackSize (ref Dictionary<Instruction, int> stack_sizes, Instruction target, int stack_size)
+ {
+ if (stack_sizes == null)
+ stack_sizes = new Dictionary<Instruction, int> ();
+
+ int branch_stack_size = stack_size;
+
+ int computed_size;
+ if (stack_sizes.TryGetValue (target, out computed_size))
+ branch_stack_size = System.Math.Max (branch_stack_size, computed_size);
+
+ stack_sizes [target] = branch_stack_size;
+ }
+
+ static void ComputeStackSize (Instruction instruction, ref int stack_size)
+ {
+ switch (instruction.opcode.FlowControl) {
+ case FlowControl.Branch:
+ case FlowControl.Break:
+ case FlowControl.Throw:
+ case FlowControl.Return:
+ stack_size = 0;
+ break;
}
}
- void WriteFatBlockSize (ExceptionHandlerCollection seh)
+ static void ComputeStackDelta (Instruction instruction, ref int stack_size)
{
- int size = seh.Count * 24 + 4;
- m_codeWriter.Write ((byte) (size & 0xff));
- m_codeWriter.Write ((byte) ((size >> 8) & 0xff));
- m_codeWriter.Write ((byte) ((size >> 16) & 0xff));
+ switch (instruction.opcode.FlowControl) {
+ case FlowControl.Call: {
+ var method = (IMethodSignature) instruction.operand;
+ stack_size -= (method.HasParameters ? method.Parameters.Count : 0)
+ + (method.HasThis && instruction.opcode.Code != Code.Newobj ? 1 : 0);
+ stack_size += (method.ReturnType.etype == ElementType.Void ? 0 : 1)
+ + (method.HasThis && instruction.opcode.Code == Code.Newobj ? 1 : 0);
+ break;
+ }
+ default:
+ ComputePopDelta (instruction.opcode.StackBehaviourPop, ref stack_size);
+ ComputePushDelta (instruction.opcode.StackBehaviourPush, ref stack_size);
+ break;
+ }
}
- void WriteHandlerSpecific (ExceptionHandler eh)
+ static void ComputePopDelta (StackBehaviour pop_behavior, ref int stack_size)
{
- switch (eh.Type) {
- case ExceptionHandlerType.Catch :
- WriteToken (eh.CatchType.MetadataToken);
+ switch (pop_behavior) {
+ case StackBehaviour.Popi:
+ case StackBehaviour.Popref:
+ case StackBehaviour.Pop1:
+ stack_size--;
break;
- case ExceptionHandlerType.Filter :
- m_codeWriter.Write ((uint) eh.FilterStart.Offset);
+ case StackBehaviour.Pop1_pop1:
+ case StackBehaviour.Popi_pop1:
+ case StackBehaviour.Popi_popi:
+ case StackBehaviour.Popi_popi8:
+ case StackBehaviour.Popi_popr4:
+ case StackBehaviour.Popi_popr8:
+ case StackBehaviour.Popref_pop1:
+ case StackBehaviour.Popref_popi:
+ stack_size -= 2;
break;
- default :
- m_codeWriter.Write (0);
+ case StackBehaviour.Popi_popi_popi:
+ case StackBehaviour.Popref_popi_popi:
+ case StackBehaviour.Popref_popi_popi8:
+ case StackBehaviour.Popref_popi_popr4:
+ case StackBehaviour.Popref_popi_popr8:
+ case StackBehaviour.Popref_popi_popref:
+ stack_size -= 3;
+ break;
+ case StackBehaviour.PopAll:
+ stack_size = 0;
break;
}
}
- public override void VisitVariableDefinitionCollection (VariableDefinitionCollection variables)
+ static void ComputePushDelta (StackBehaviour push_behaviour, ref int stack_size)
{
- MethodBody body = variables.Container as MethodBody;
- if (body == null)
- return;
+ switch (push_behaviour) {
+ case StackBehaviour.Push1:
+ case StackBehaviour.Pushi:
+ case StackBehaviour.Pushi8:
+ case StackBehaviour.Pushr4:
+ case StackBehaviour.Pushr8:
+ case StackBehaviour.Pushref:
+ stack_size++;
+ break;
+ case StackBehaviour.Push1_push1:
+ stack_size += 2;
+ break;
+ }
+ }
- uint sig = m_reflectWriter.SignatureWriter.AddLocalVarSig (
- GetLocalVarSig (variables));
+ void WriteExceptionHandlers ()
+ {
+ Align (4);
- if (m_localSigCache.Contains (sig)) {
- body.LocalVarToken = (int) m_localSigCache [sig];
- return;
+ var handlers = body.ExceptionHandlers;
+
+ if (handlers.Count < 0x15 && !RequiresFatSection (handlers))
+ WriteSmallSection (handlers);
+ else
+ WriteFatSection (handlers);
+ }
+
+ static bool RequiresFatSection (Collection<ExceptionHandler> handlers)
+ {
+ for (int i = 0; i < handlers.Count; i++) {
+ var handler = handlers [i];
+
+ if (IsFatRange (handler.TryStart, handler.TryEnd))
+ return true;
+
+ if (IsFatRange (handler.HandlerStart, handler.HandlerEnd))
+ return true;
+
+ if (handler.HandlerType == ExceptionHandlerType.Filter
+ && IsFatRange (handler.FilterStart, handler.FilterEnd))
+ return true;
}
- StandAloneSigTable sasTable = m_reflectWriter.MetadataTableWriter.GetStandAloneSigTable ();
- StandAloneSigRow sasRow = m_reflectWriter.MetadataRowWriter.CreateStandAloneSigRow (
- sig);
+ return false;
+ }
+
+ static bool IsFatRange (Instruction start, Instruction end)
+ {
+ if (end == null)
+ return true;
- sasTable.Rows.Add (sasRow);
- body.LocalVarToken = sasTable.Rows.Count;
- m_localSigCache [sig] = body.LocalVarToken;
+ return end.Offset - start.Offset > 255 || start.Offset > 65535;
}
- public override void TerminateMethodBody (MethodBody body)
+ void WriteSmallSection (Collection<ExceptionHandler> handlers)
{
- long pos = m_binaryWriter.BaseStream.Position;
+ const byte eh_table = 0x1;
- if (body.Variables.Count > 0 || body.ExceptionHandlers.Count > 0
- || m_codeWriter.BaseStream.Length >= 64 || body.MaxStack > 8) {
+ WriteByte (eh_table);
+ WriteByte ((byte) (handlers.Count * 12 + 4));
+ WriteBytes (2);
- MethodHeader header = MethodHeader.FatFormat;
- if (body.InitLocals)
- header |= MethodHeader.InitLocals;
- if (body.ExceptionHandlers.Count > 0)
- header |= MethodHeader.MoreSects;
+ WriteExceptionHandlers (
+ handlers,
+ i => WriteUInt16 ((ushort) i),
+ i => WriteByte ((byte) i));
+ }
- m_binaryWriter.Write ((byte) header);
- m_binaryWriter.Write ((byte) 0x30); // (header size / 4) << 4
- m_binaryWriter.Write ((short) body.MaxStack);
- m_binaryWriter.Write ((int) m_codeWriter.BaseStream.Length);
- m_binaryWriter.Write (((int) TokenType.Signature | body.LocalVarToken));
+ void WriteFatSection (Collection<ExceptionHandler> handlers)
+ {
+ const byte eh_table = 0x1;
+ const byte fat_format = 0x40;
- WriteExceptionHandlerCollection (body.ExceptionHandlers);
- } else
- m_binaryWriter.Write ((byte) ((byte) MethodHeader.TinyFormat |
- m_codeWriter.BaseStream.Length << 2));
+ WriteByte (eh_table | fat_format);
- m_binaryWriter.Write (m_codeWriter);
- m_binaryWriter.QuadAlign ();
+ int size = handlers.Count * 24 + 4;
+ WriteByte ((byte) (size & 0xff));
+ WriteByte ((byte) ((size >> 8) & 0xff));
+ WriteByte ((byte) ((size >> 16) & 0xff));
- m_reflectWriter.MetadataWriter.AddData (
- (int) (m_binaryWriter.BaseStream.Position - pos));
+ WriteExceptionHandlers (handlers, WriteInt32, WriteInt32);
}
- public LocalVarSig.LocalVariable GetLocalVariableSig (VariableDefinition var)
+ void WriteExceptionHandlers (Collection<ExceptionHandler> handlers, Action<int> write_entry, Action<int> write_length)
{
- LocalVarSig.LocalVariable lv = new LocalVarSig.LocalVariable ();
- TypeReference type = var.VariableType;
+ for (int i = 0; i < handlers.Count; i++) {
+ var handler = handlers [i];
+
+ write_entry ((int) handler.HandlerType);
- lv.CustomMods = m_reflectWriter.GetCustomMods (type);
+ write_entry (handler.TryStart.Offset);
+ write_length (GetTargetOffset (handler.TryEnd) - handler.TryStart.Offset);
- if (type is PinnedType) {
- lv.Constraint |= Constraint.Pinned;
- type = (type as PinnedType).ElementType;
+ write_entry (handler.HandlerStart.Offset);
+ write_length (GetTargetOffset (handler.HandlerEnd) - handler.HandlerStart.Offset);
+
+ WriteExceptionHandlerSpecific (handler);
}
+ }
- if (type is ReferenceType) {
- lv.ByRef = true;
- type = (type as ReferenceType).ElementType;
+ void WriteExceptionHandlerSpecific (ExceptionHandler handler)
+ {
+ switch (handler.HandlerType) {
+ case ExceptionHandlerType.Catch:
+ WriteMetadataToken (metadata.LookupToken (handler.CatchType));
+ break;
+ case ExceptionHandlerType.Filter:
+ WriteInt32 (handler.FilterStart.Offset);
+ break;
+ default:
+ WriteInt32 (0);
+ break;
}
+ }
- lv.Type = m_reflectWriter.GetSigType (type);
+ public MetadataToken GetStandAloneSignature (Collection<VariableDefinition> variables)
+ {
+ var signature = metadata.GetLocalVariableBlobIndex (variables);
- return lv;
+ return GetStandAloneSignatureToken (signature);
}
- public LocalVarSig GetLocalVarSig (VariableDefinitionCollection vars)
+ public MetadataToken GetStandAloneSignature (CallSite call_site)
{
- LocalVarSig lvs = new LocalVarSig ();
- lvs.CallingConvention |= 0x7;
- lvs.Count = vars.Count;
- lvs.LocalVariables = new LocalVarSig.LocalVariable [lvs.Count];
- for (int i = 0; i < lvs.Count; i++) {
- lvs.LocalVariables [i] = GetLocalVariableSig (vars [i]);
- }
+ var signature = metadata.GetCallSiteBlobIndex (call_site);
+ var token = GetStandAloneSignatureToken (signature);
+ call_site.MetadataToken = token;
+ return token;
+ }
- return lvs;
+ MetadataToken GetStandAloneSignatureToken (uint signature)
+ {
+ MetadataToken token;
+ if (standalone_signatures.TryGetValue (signature, out token))
+ return token;
+
+ token = new MetadataToken (TokenType.Signature, metadata.AddStandAloneSignature (signature));
+ standalone_signatures.Add (signature, token);
+ return token;
}
- static void ComputeMaxStack (InstructionCollection instructions)
+ RVA BeginMethod ()
{
- InstructionCollection ehs = new InstructionCollection (null);
- foreach (ExceptionHandler eh in instructions.Container.ExceptionHandlers) {
- switch (eh.Type) {
- case ExceptionHandlerType.Catch :
- ehs.Add (eh.HandlerStart);
- break;
- case ExceptionHandlerType.Filter :
- ehs.Add (eh.FilterStart);
- break;
- }
- }
+ return current;
+ }
- int max = 0;
- foreach (Instruction instr in instructions) {
- if (ehs.Contains (instr))
- max++;
-
- switch (instr.OpCode.StackBehaviourPush) {
- case StackBehaviour.Push1:
- case StackBehaviour.Pushi:
- case StackBehaviour.Pushi8:
- case StackBehaviour.Pushr4:
- case StackBehaviour.Pushr8:
- case StackBehaviour.Pushref:
- case StackBehaviour.Varpush:
- max++;
- break;
- case StackBehaviour.Push1_push1:
- max += 2;
- break;
- }
+ void WriteMetadataToken (MetadataToken token)
+ {
+ WriteUInt32 (token.ToUInt32 ());
+ }
- if (instr.OpCode.OperandType == OperandType.InlineMethod) {
- IMethodSignature signature = instr.Operand as IMethodSignature;
- if (signature != null && signature.ReturnType.ReturnType.FullName != Constants.Void)
- max++;
- }
- }
+ void Align (int align)
+ {
+ align--;
+ WriteBytes (((position + align) & ~align) - position);
+ }
- instructions.Container.MaxStack = max;
+ void EndMethod ()
+ {
+ current = (RVA) (code_base + position);
}
}
}
+
+#endif
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Document.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Document.cs
index 1b40c44..e46d2c1 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Document.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Document.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2006 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,55 +26,86 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
namespace Mono.Cecil.Cil {
- using System;
+ public enum DocumentType {
+ Other,
+ Text,
+ }
+
+ public enum DocumentHashAlgorithm {
+ None,
+ MD5,
+ SHA1,
+ }
+
+ public enum DocumentLanguage {
+ Other,
+ C,
+ Cpp,
+ CSharp,
+ Basic,
+ Java,
+ Cobol,
+ Pascal,
+ Cil,
+ JScript,
+ Smc,
+ MCpp,
+ }
+
+ public enum DocumentLanguageVendor {
+ Other,
+ Microsoft,
+ }
- public class Document {
+ public sealed class Document {
- string m_url;
+ string url;
- Guid m_type;
- DocumentHashAlgorithm m_hashAlgorithm;
- Guid m_language;
- Guid m_languageVendor;
+ byte type;
+ byte hash_algorithm;
+ byte language;
+ byte language_vendor;
- byte [] m_hash;
+ byte [] hash;
public string Url {
- get { return m_url; }
- set { m_url = value; }
+ get { return url; }
+ set { url = value; }
}
- public Guid Type {
- get { return m_type; }
- set { m_type = value; }
+ public DocumentType Type {
+ get { return (DocumentType) type; }
+ set { type = (byte) value; }
}
public DocumentHashAlgorithm HashAlgorithm {
- get { return m_hashAlgorithm; }
- set { m_hashAlgorithm = value; }
+ get { return (DocumentHashAlgorithm) hash_algorithm; }
+ set { hash_algorithm = (byte) value; }
}
- public Guid Language {
- get { return m_language; }
- set { m_language = value; }
+ public DocumentLanguage Language {
+ get { return (DocumentLanguage) language; }
+ set { language = (byte) value; }
}
- public Guid LanguageVendor {
- get { return m_languageVendor; }
- set { m_languageVendor = value; }
+ public DocumentLanguageVendor LanguageVendor {
+ get { return (DocumentLanguageVendor) language_vendor; }
+ set { language_vendor = (byte) value; }
}
public byte [] Hash {
- get { return m_hash; }
- set { m_hash = value; }
+ get { return hash; }
+ set { hash = value; }
}
public Document (string url)
{
- m_url = url;
- m_hash = new byte [0];
+ this.url = url;
+ this.hash = Empty<byte>.Array;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentHashAlgorithm.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentHashAlgorithm.cs
deleted file mode 100644
index cd5791f..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentHashAlgorithm.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// DocumentHashAlgorithm.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- public enum DocumentHashAlgorithm {
- [Guid (0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] None,
- [Guid (0x406ea660, 0x64cf, 0x4c82, 0xb6, 0xf0, 0x42, 0xd4, 0x81, 0x72, 0xa7, 0x99)] MD5,
- [Guid (0xff1816ec, 0xaa5e, 0x4d10, 0x87, 0xf7, 0x6f, 0x49, 0x63, 0x83, 0x34, 0x60)] SHA1
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguage.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguage.cs
deleted file mode 100644
index 2839948..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguage.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// DocumentLanguage.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- using System;
-
- public abstract class DocumentLanguage {
- public static readonly Guid None = new Guid (0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x0, 0x00, 0x00, 0x00, 0x00, 0x00);
- public static readonly Guid C = new Guid (0x63a08714, 0xfc37, 0x11d2, 0x90, 0x4c, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1);
- public static readonly Guid Cpp = new Guid (0x3a12d0b7, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2);
- public static readonly Guid CSharp = new Guid (0x3f5162f8, 0x07c6, 0x11d3, 0x90, 0x53, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1);
- public static readonly Guid Basic = new Guid (0x3a12d0b8, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2);
- public static readonly Guid Java = new Guid (0x3a12d0b4, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2);
- public static readonly Guid Cobol = new Guid (0xaf046cd1, 0xd0e1, 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc);
- public static readonly Guid Pascal = new Guid (0xaf046cd2, 0xd0e1, 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc);
- public static readonly Guid CIL = new Guid (0xaf046cd3, 0xd0e1, 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc);
- public static readonly Guid JScript = new Guid (0x3a12d0b6, 0xc26c, 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2);
- public static readonly Guid SMC = new Guid (0xd9b9f7b, 0x6611, 0x11d3, 0xbd, 0x2a, 0x0, 0x0, 0xf8, 0x8, 0x49, 0xbd);
- public static readonly Guid MCpp = new Guid (0x4b35fde8, 0x07c6, 0x11d3, 0x90, 0x53, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguageVendor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguageVendor.cs
deleted file mode 100644
index e36edef..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentLanguageVendor.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// DocumentLanguageVendor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- using System;
-
- public abstract class DocumentLanguageVendor {
- public static readonly Guid Other = new Guid (0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
- public static readonly Guid Microsoft = new Guid (0x994b45c4, 0xe6e9, 0x11d2, 0x90, 0x3f, 0x00, 0xc0, 0x4f, 0xa3, 0x02, 0xa1);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentType.cs
deleted file mode 100644
index 9df7764..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/DocumentType.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// DocumentType.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- using System;
-
- public abstract class DocumentType {
-
- public static readonly Guid Other = new Guid (0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
- public static readonly Guid Text = new Guid (0x5a869d0b, 0x6611, 0x11d3, 0xbd, 0x2a, 0x00, 0x00, 0xf8, 0x08, 0x49, 0xbd);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandler.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandler.cs
index d1ee7bf..a76f8f3 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandler.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandler.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,68 +28,68 @@
namespace Mono.Cecil.Cil {
- using Mono.Cecil;
+ public enum ExceptionHandlerType {
+ Catch = 0,
+ Filter = 1,
+ Finally = 2,
+ Fault = 4,
+ }
- public sealed class ExceptionHandler : ICodeVisitable {
+ public sealed class ExceptionHandler {
- Instruction m_tryStart;
- Instruction m_tryEnd;
- Instruction m_filterStart;
- Instruction m_filterEnd;
- Instruction m_handlerStart;
- Instruction m_handlerEnd;
+ Instruction try_start;
+ Instruction try_end;
+ Instruction filter_start;
+ Instruction filter_end;
+ Instruction handler_start;
+ Instruction handler_end;
- TypeReference m_catchType;
- ExceptionHandlerType m_type;
+ TypeReference catch_type;
+ ExceptionHandlerType handler_type;
public Instruction TryStart {
- get { return m_tryStart; }
- set { m_tryStart = value; }
+ get { return try_start; }
+ set { try_start = value; }
}
public Instruction TryEnd {
- get { return m_tryEnd; }
- set { m_tryEnd = value; }
+ get { return try_end; }
+ set { try_end = value; }
}
public Instruction FilterStart {
- get { return m_filterStart; }
- set { m_filterStart = value; }
+ get { return filter_start; }
+ set { filter_start = value; }
}
public Instruction FilterEnd {
- get { return m_filterEnd; }
- set { m_filterEnd = value; }
+ get { return filter_end; }
+ set { filter_end = value; }
}
public Instruction HandlerStart {
- get { return m_handlerStart; }
- set { m_handlerStart = value; }
+ get { return handler_start; }
+ set { handler_start = value; }
}
public Instruction HandlerEnd {
- get { return m_handlerEnd; }
- set { m_handlerEnd = value; }
+ get { return handler_end; }
+ set { handler_end = value; }
}
public TypeReference CatchType {
- get { return m_catchType; }
- set { m_catchType = value; }
- }
-
- public ExceptionHandlerType Type {
- get { return m_type; }
- set { m_type = value; }
+ get { return catch_type; }
+ set { catch_type = value; }
}
- public ExceptionHandler (ExceptionHandlerType type)
- {
- m_type = type;
+ public ExceptionHandlerType HandlerType {
+ get { return handler_type; }
+ set { handler_type = value; }
}
- public void Accept (ICodeVisitor visitor)
+ public ExceptionHandler (ExceptionHandlerType handlerType)
{
- visitor.VisitExceptionHandler (this);
+ this.handler_type = handlerType;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerCollection.cs
deleted file mode 100644
index dd2b11a..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerCollection.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// ExceptionHandlerCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:53 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class ExceptionHandlerCollection : CollectionBase, ICodeVisitable {
-
- MethodBody m_container;
-
- public ExceptionHandler this [int index] {
- get { return List [index] as ExceptionHandler; }
- set { List [index] = value; }
- }
-
- public MethodBody Container {
- get { return m_container; }
- }
-
- public ExceptionHandlerCollection (MethodBody container)
- {
- m_container = container;
- }
-
- public void Add (ExceptionHandler value)
- {
- List.Add (value);
- }
-
- public bool Contains (ExceptionHandler value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (ExceptionHandler value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, ExceptionHandler value)
- {
- List.Insert (index, value);
- }
-
- public void Remove (ExceptionHandler value)
- {
- List.Remove (value);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is ExceptionHandler))
- throw new ArgumentException ("Must be of type " + typeof (ExceptionHandler).FullName);
- }
-
- public void Accept (ICodeVisitor visitor)
- {
- visitor.VisitExceptionHandlerCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerType.cs
deleted file mode 100644
index 28b8b7c..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ExceptionHandlerType.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// ExceptionHandlerType.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- public enum ExceptionHandlerType {
- Catch = 0x0000,
- Filter = 0x0001,
- Finally = 0x0002,
- Fault = 0x0004
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/GuidAttribute.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/GuidAttribute.cs
deleted file mode 100644
index d071f8f..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/GuidAttribute.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-//
-// GuidAttribute.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- using System;
- using System.Reflection;
-
- [AttributeUsage (AttributeTargets.Field)]
- public class GuidAttribute : Attribute {
-
- private Guid m_guid;
-
- public Guid Guid {
- get { return m_guid; }
- }
-
- GuidAttribute ()
- {
- m_guid = new Guid ();
- }
-
- public GuidAttribute (
- uint a,
- ushort b,
- ushort c,
- byte d,
- byte e,
- byte f,
- byte g,
- byte h,
- byte i,
- byte j,
- byte k)
- {
- m_guid = new Guid ((int) a, (short) b, (short) c, d, e, f, g, h, i, j, k);
- }
-
- public static int GetValueFromGuid (Guid id, Type enumeration)
- {
- foreach (FieldInfo fi in enumeration.GetFields (BindingFlags.Static | BindingFlags.Public))
- if (id == GetGuidAttribute (fi).Guid)
- return (int) fi.GetValue (null);
-
- return -1;
- }
-
- public static Guid GetGuidFromValue (int value, Type enumeration)
- {
- foreach (FieldInfo fi in enumeration.GetFields (BindingFlags.Static | BindingFlags.Public))
- if (value == (int) fi.GetValue (null))
- return GetGuidAttribute (fi).Guid;
-
- return new Guid ();
- }
-
- static GuidAttribute GetGuidAttribute (FieldInfo fi)
- {
- GuidAttribute [] attributes = fi.GetCustomAttributes (typeof (GuidAttribute), false) as GuidAttribute [];
- if (attributes == null || attributes.Length != 1)
- return new GuidAttribute ();
-
- return attributes [0];
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitable.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitable.cs
deleted file mode 100644
index 91571d8..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitable.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-//
-// ICodeVisitable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- public interface ICodeVisitable {
- void Accept (ICodeVisitor visitor);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitor.cs
deleted file mode 100644
index c02335e..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ICodeVisitor.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// ICodeVisitor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- public interface ICodeVisitor {
-
- void VisitMethodBody (MethodBody body);
- void VisitInstructionCollection (InstructionCollection instructions);
- void VisitInstruction (Instruction instr);
- void VisitExceptionHandlerCollection (ExceptionHandlerCollection seh);
- void VisitExceptionHandler (ExceptionHandler eh);
- void VisitVariableDefinitionCollection (VariableDefinitionCollection variables);
- void VisitVariableDefinition (VariableDefinition var);
- void VisitScopeCollection (ScopeCollection scopes);
- void VisitScope (Scope scope);
-
- void TerminateMethodBody (MethodBody body);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ILProcessor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ILProcessor.cs
new file mode 100644
index 0000000..1300b3e
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ILProcessor.cs
@@ -0,0 +1,278 @@
+//
+// ILProcessor.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+using Mono.Collections.Generic;
+
+namespace Mono.Cecil.Cil {
+
+ public sealed class ILProcessor {
+
+ readonly MethodBody body;
+ readonly Collection<Instruction> instructions;
+
+ public MethodBody Body {
+ get { return body; }
+ }
+
+ internal ILProcessor (MethodBody body)
+ {
+ this.body = body;
+ this.instructions = body.Instructions;
+ }
+
+ public Instruction Create (OpCode opcode)
+ {
+ return Instruction.Create (opcode);
+ }
+
+ public Instruction Create (OpCode opcode, TypeReference type)
+ {
+ return Instruction.Create (opcode, type);
+ }
+
+ public Instruction Create (OpCode opcode, CallSite site)
+ {
+ return Instruction.Create (opcode, site);
+ }
+
+ public Instruction Create (OpCode opcode, MethodReference method)
+ {
+ return Instruction.Create (opcode, method);
+ }
+
+ public Instruction Create (OpCode opcode, FieldReference field)
+ {
+ return Instruction.Create (opcode, field);
+ }
+
+ public Instruction Create (OpCode opcode, string value)
+ {
+ return Instruction.Create (opcode, value);
+ }
+
+ public Instruction Create (OpCode opcode, sbyte value)
+ {
+ return Instruction.Create (opcode, value);
+ }
+
+ public Instruction Create (OpCode opcode, byte value)
+ {
+ if (opcode.OperandType == OperandType.ShortInlineVar)
+ return Instruction.Create (opcode, body.Variables [value]);
+
+ if (opcode.OperandType == OperandType.ShortInlineArg)
+ return Instruction.Create (opcode, body.GetParameter (value));
+
+ return Instruction.Create (opcode, value);
+ }
+
+ public Instruction Create (OpCode opcode, int value)
+ {
+ if (opcode.OperandType == OperandType.InlineVar)
+ return Instruction.Create (opcode, body.Variables [value]);
+
+ if (opcode.OperandType == OperandType.InlineArg)
+ return Instruction.Create (opcode, body.GetParameter (value));
+
+ return Instruction.Create (opcode, value);
+ }
+
+ public Instruction Create (OpCode opcode, long value)
+ {
+ return Instruction.Create (opcode, value);
+ }
+
+ public Instruction Create (OpCode opcode, float value)
+ {
+ return Instruction.Create (opcode, value);
+ }
+
+ public Instruction Create (OpCode opcode, double value)
+ {
+ return Instruction.Create (opcode, value);
+ }
+
+ public Instruction Create (OpCode opcode, Instruction target)
+ {
+ return Instruction.Create (opcode, target);
+ }
+
+ public Instruction Create (OpCode opcode, Instruction [] targets)
+ {
+ return Instruction.Create (opcode, targets);
+ }
+
+ public Instruction Create (OpCode opcode, VariableDefinition variable)
+ {
+ return Instruction.Create (opcode, variable);
+ }
+
+ public Instruction Create (OpCode opcode, ParameterDefinition parameter)
+ {
+ return Instruction.Create (opcode, parameter);
+ }
+
+ public void Emit (OpCode opcode)
+ {
+ Append (Create (opcode));
+ }
+
+ public void Emit (OpCode opcode, TypeReference type)
+ {
+ Append (Create (opcode, type));
+ }
+
+ public void Emit (OpCode opcode, MethodReference method)
+ {
+ Append (Create (opcode, method));
+ }
+
+ public void Emit (OpCode opcode, CallSite site)
+ {
+ Append (Create (opcode, site));
+ }
+
+ public void Emit (OpCode opcode, FieldReference field)
+ {
+ Append (Create (opcode, field));
+ }
+
+ public void Emit (OpCode opcode, string value)
+ {
+ Append (Create (opcode, value));
+ }
+
+ public void Emit (OpCode opcode, byte value)
+ {
+ Append (Create (opcode, value));
+ }
+
+ public void Emit (OpCode opcode, sbyte value)
+ {
+ Append (Create (opcode, value));
+ }
+
+ public void Emit (OpCode opcode, int value)
+ {
+ Append (Create (opcode, value));
+ }
+
+ public void Emit (OpCode opcode, long value)
+ {
+ Append (Create (opcode, value));
+ }
+
+ public void Emit (OpCode opcode, float value)
+ {
+ Append (Create (opcode, value));
+ }
+
+ public void Emit (OpCode opcode, double value)
+ {
+ Append (Create (opcode, value));
+ }
+
+ public void Emit (OpCode opcode, Instruction target)
+ {
+ Append (Create (opcode, target));
+ }
+
+ public void Emit (OpCode opcode, Instruction [] targets)
+ {
+ Append (Create (opcode, targets));
+ }
+
+ public void Emit (OpCode opcode, VariableDefinition variable)
+ {
+ Append (Create (opcode, variable));
+ }
+
+ public void Emit (OpCode opcode, ParameterDefinition parameter)
+ {
+ Append (Create (opcode, parameter));
+ }
+
+ public void InsertBefore (Instruction target, Instruction instruction)
+ {
+ if (target == null)
+ throw new ArgumentNullException ("target");
+ if (instruction == null)
+ throw new ArgumentNullException ("instruction");
+
+ var index = instructions.IndexOf (target);
+ if (index == -1)
+ throw new ArgumentOutOfRangeException ("target");
+
+ instructions.Insert (index, instruction);
+ }
+
+ public void InsertAfter (Instruction target, Instruction instruction)
+ {
+ if (target == null)
+ throw new ArgumentNullException ("target");
+ if (instruction == null)
+ throw new ArgumentNullException ("instruction");
+
+ var index = instructions.IndexOf (target);
+ if (index == -1)
+ throw new ArgumentOutOfRangeException ("target");
+
+ instructions.Insert (index + 1, instruction);
+ }
+
+ public void Append (Instruction instruction)
+ {
+ if (instruction == null)
+ throw new ArgumentNullException ("instruction");
+
+ instructions.Add (instruction);
+ }
+
+ public void Replace (Instruction target, Instruction instruction)
+ {
+ if (target == null)
+ throw new ArgumentNullException ("target");
+ if (instruction == null)
+ throw new ArgumentNullException ("instruction");
+
+ InsertAfter (target, instruction);
+ Remove (target);
+ }
+
+ public void Remove (Instruction instruction)
+ {
+ if (instruction == null)
+ throw new ArgumentNullException ("instruction");
+
+ if (!instructions.Remove (instruction))
+ throw new ArgumentOutOfRangeException ("instruction");
+ }
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IScopeProvider.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IScopeProvider.cs
deleted file mode 100644
index f7db241..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IScopeProvider.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// Document.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- public interface IScopeProvider {
-
- ScopeCollection Scopes { get; }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolReader.cs
deleted file mode 100644
index 817788c..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolReader.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// ISymbolReader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- using System;
-
- public interface ISymbolReader : IDisposable {
-
- void Read (MethodBody body);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolStoreFactory.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolStoreFactory.cs
deleted file mode 100644
index 945c7a0..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolStoreFactory.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// ISymbolStoreFactory.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- public interface ISymbolStoreFactory {
-
- ISymbolReader CreateReader (ModuleDefinition module, string assemblyFileName);
- ISymbolWriter CreateWriter (ModuleDefinition module, string assemblyFileName);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolWriter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolWriter.cs
deleted file mode 100644
index 83fab55..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ISymbolWriter.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// ISymbolWriter.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 - 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- using System;
-
- public interface ISymbolWriter : IDisposable {
-
- void Write (MethodBody body, byte [][] variables);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IVariableDefinitionProvider.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IVariableDefinitionProvider.cs
deleted file mode 100644
index 9f64797..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/IVariableDefinitionProvider.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// IVariableDefinitionProvider.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- public interface IVariableDefinitionProvider {
-
- VariableDefinitionCollection Variables { get; }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Instruction.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Instruction.cs
index 7e9a5de..e8d36c4 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Instruction.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Instruction.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,80 +26,74 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+using System.Text;
+
namespace Mono.Cecil.Cil {
- public sealed class Instruction : ICodeVisitable {
+ public sealed class Instruction {
- int m_offset;
- OpCode m_opCode;
- object m_operand;
+ internal int offset;
+ internal OpCode opcode;
+ internal object operand;
- Instruction m_previous;
- Instruction m_next;
+ internal Instruction previous;
+ internal Instruction next;
- SequencePoint m_sequencePoint;
+ SequencePoint sequence_point;
public int Offset {
- get { return m_offset; }
- set { m_offset = value; }
+ get { return offset; }
+ set { offset = value; }
}
public OpCode OpCode {
- get { return m_opCode; }
- set { m_opCode = value; }
+ get { return opcode; }
+ set { opcode = value; }
}
public object Operand {
- get { return m_operand; }
- set { m_operand = value; }
+ get { return operand; }
+ set { operand = value; }
}
public Instruction Previous {
- get { return m_previous; }
- set { m_previous = value; }
+ get { return previous; }
+ set { previous = value; }
}
public Instruction Next {
- get { return m_next; }
- set { m_next = value; }
+ get { return next; }
+ set { next = value; }
}
public SequencePoint SequencePoint {
- get { return m_sequencePoint; }
- set { m_sequencePoint = value; }
- }
-
- internal Instruction (int offset, OpCode opCode, object operand) : this (offset, opCode)
- {
- m_operand = operand;
+ get { return sequence_point; }
+ set { sequence_point = value; }
}
internal Instruction (int offset, OpCode opCode)
{
- m_offset = offset;
- m_opCode = opCode;
- }
-
- internal Instruction (OpCode opCode, object operand) : this (0, opCode, operand)
- {
+ this.offset = offset;
+ this.opcode = opCode;
}
- internal Instruction (OpCode opCode) : this (0, opCode)
+ internal Instruction (OpCode opcode, object operand)
{
+ this.opcode = opcode;
+ this.operand = operand;
}
public int GetSize ()
{
- int size = m_opCode.Size;
+ int size = opcode.Size;
- switch (m_opCode.OperandType) {
+ switch (opcode.OperandType) {
case OperandType.InlineSwitch:
- size += (1 + ((Instruction []) m_operand).Length) * 4;
- break;
+ return size + (1 + ((Instruction []) operand).Length) * 4;
case OperandType.InlineI8:
case OperandType.InlineR:
- size += 8;
- break;
+ return size + 8;
case OperandType.InlineBrTarget:
case OperandType.InlineField:
case OperandType.InlineI:
@@ -108,26 +102,220 @@ namespace Mono.Cecil.Cil {
case OperandType.InlineTok:
case OperandType.InlineType:
case OperandType.ShortInlineR:
- size += 4;
- break;
- case OperandType.InlineParam:
+ case OperandType.InlineSig:
+ return size + 4;
+ case OperandType.InlineArg:
case OperandType.InlineVar:
- size += 2;
- break;
+ return size + 2;
case OperandType.ShortInlineBrTarget:
case OperandType.ShortInlineI:
- case OperandType.ShortInlineParam:
+ case OperandType.ShortInlineArg:
case OperandType.ShortInlineVar:
- size += 1;
+ return size + 1;
+ default:
+ return size;
+ }
+ }
+
+ public override string ToString ()
+ {
+ var instruction = new StringBuilder ();
+
+ AppendLabel (instruction, this);
+ instruction.Append (':');
+ instruction.Append (' ');
+ instruction.Append (opcode.Name);
+
+ if (operand == null)
+ return instruction.ToString ();
+
+ instruction.Append (' ');
+
+ switch (opcode.OperandType) {
+ case OperandType.ShortInlineBrTarget:
+ case OperandType.InlineBrTarget:
+ AppendLabel (instruction, (Instruction) operand);
+ break;
+ case OperandType.InlineSwitch:
+ var labels = (Instruction []) operand;
+ for (int i = 0; i < labels.Length; i++) {
+ if (i > 0)
+ instruction.Append (',');
+
+ AppendLabel (instruction, labels [i]);
+ }
+ break;
+ case OperandType.InlineString:
+ instruction.Append ('\"');
+ instruction.Append (operand);
+ instruction.Append ('\"');
+ break;
+ default:
+ instruction.Append (operand);
break;
}
- return size;
+ return instruction.ToString ();
+ }
+
+ static void AppendLabel (StringBuilder builder, Instruction instruction)
+ {
+ builder.Append ("IL_");
+ builder.Append (instruction.offset.ToString ("x4"));
+ }
+
+ public static Instruction Create (OpCode opcode)
+ {
+ if (opcode.OperandType != OperandType.InlineNone)
+ throw new ArgumentException ("opcode");
+
+ return new Instruction (opcode, null);
+ }
+
+ public static Instruction Create (OpCode opcode, TypeReference type)
+ {
+ if (type == null)
+ throw new ArgumentNullException ("type");
+ if (opcode.OperandType != OperandType.InlineType &&
+ opcode.OperandType != OperandType.InlineTok)
+ throw new ArgumentException ("opcode");
+
+ return new Instruction (opcode, type);
+ }
+
+ public static Instruction Create (OpCode opcode, CallSite site)
+ {
+ if (site == null)
+ throw new ArgumentNullException ("site");
+ if (opcode.Code != Code.Calli)
+ throw new ArgumentException ("code");
+
+ return new Instruction (opcode, site);
+ }
+
+ public static Instruction Create (OpCode opcode, MethodReference method)
+ {
+ if (method == null)
+ throw new ArgumentNullException ("method");
+ if (opcode.OperandType != OperandType.InlineMethod &&
+ opcode.OperandType != OperandType.InlineTok)
+ throw new ArgumentException ("opcode");
+
+ return new Instruction (opcode, method);
}
- public void Accept (ICodeVisitor visitor)
+ public static Instruction Create (OpCode opcode, FieldReference field)
{
- visitor.VisitInstruction (this);
+ if (field == null)
+ throw new ArgumentNullException ("field");
+ if (opcode.OperandType != OperandType.InlineField &&
+ opcode.OperandType != OperandType.InlineTok)
+ throw new ArgumentException ("opcode");
+
+ return new Instruction (opcode, field);
+ }
+
+ public static Instruction Create (OpCode opcode, string value)
+ {
+ if (value == null)
+ throw new ArgumentNullException ("value");
+ if (opcode.OperandType != OperandType.InlineString)
+ throw new ArgumentException ("opcode");
+
+ return new Instruction (opcode, value);
+ }
+
+ public static Instruction Create (OpCode opcode, sbyte value)
+ {
+ if (opcode.OperandType != OperandType.ShortInlineI &&
+ opcode != OpCodes.Ldc_I4_S)
+ throw new ArgumentException ("opcode");
+
+ return new Instruction (opcode, value);
+ }
+
+ public static Instruction Create (OpCode opcode, byte value)
+ {
+ if (opcode.OperandType != OperandType.ShortInlineI ||
+ opcode == OpCodes.Ldc_I4_S)
+ throw new ArgumentException ("opcode");
+
+ return new Instruction (opcode, value);
+ }
+
+ public static Instruction Create (OpCode opcode, int value)
+ {
+ if (opcode.OperandType != OperandType.InlineI)
+ throw new ArgumentException ("opcode");
+
+ return new Instruction (opcode, value);
+ }
+
+ public static Instruction Create (OpCode opcode, long value)
+ {
+ if (opcode.OperandType != OperandType.InlineI8)
+ throw new ArgumentException ("opcode");
+
+ return new Instruction (opcode, value);
+ }
+
+ public static Instruction Create (OpCode opcode, float value)
+ {
+ if (opcode.OperandType != OperandType.ShortInlineR)
+ throw new ArgumentException ("opcode");
+
+ return new Instruction (opcode, value);
+ }
+
+ public static Instruction Create (OpCode opcode, double value)
+ {
+ if (opcode.OperandType != OperandType.InlineR)
+ throw new ArgumentException ("opcode");
+
+ return new Instruction (opcode, value);
+ }
+
+ public static Instruction Create (OpCode opcode, Instruction target)
+ {
+ if (target == null)
+ throw new ArgumentNullException ("target");
+ if (opcode.OperandType != OperandType.InlineBrTarget &&
+ opcode.OperandType != OperandType.ShortInlineBrTarget)
+ throw new ArgumentException ("opcode");
+
+ return new Instruction (opcode, target);
+ }
+
+ public static Instruction Create (OpCode opcode, Instruction [] targets)
+ {
+ if (targets == null)
+ throw new ArgumentNullException ("targets");
+ if (opcode.OperandType != OperandType.InlineSwitch)
+ throw new ArgumentException ("opcode");
+
+ return new Instruction (opcode, targets);
+ }
+
+ public static Instruction Create (OpCode opcode, VariableDefinition variable)
+ {
+ if (variable == null)
+ throw new ArgumentNullException ("variable");
+ if (opcode.OperandType != OperandType.ShortInlineVar &&
+ opcode.OperandType != OperandType.InlineVar)
+ throw new ArgumentException ("opcode");
+
+ return new Instruction (opcode, variable);
+ }
+
+ public static Instruction Create (OpCode opcode, ParameterDefinition parameter)
+ {
+ if (parameter == null)
+ throw new ArgumentNullException ("parameter");
+ if (opcode.OperandType != OperandType.ShortInlineArg &&
+ opcode.OperandType != OperandType.InlineArg)
+ throw new ArgumentException ("opcode");
+
+ return new Instruction (opcode, parameter);
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/InstructionCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/InstructionCollection.cs
deleted file mode 100644
index 190750b..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/InstructionCollection.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-//
-// InstructionCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Thu Sep 28 17:54:43 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class InstructionCollection : CollectionBase, ICodeVisitable {
-
- MethodBody m_container;
- public readonly Instruction Outside = new Instruction (int.MaxValue, OpCodes.Nop);
-
- public Instruction this [int index] {
- get { return List [index] as Instruction; }
- set { List [index] = value; }
- }
-
- public MethodBody Container {
- get { return m_container; }
- }
-
- public InstructionCollection (MethodBody container)
- {
- m_container = container;
- }
-
- internal void Add (Instruction value)
- {
- List.Add (value);
- }
-
- public bool Contains (Instruction value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (Instruction value)
- {
- return List.IndexOf (value);
- }
-
- internal void Insert (int index, Instruction value)
- {
- List.Insert (index, value);
- }
-
- internal void Remove (Instruction value)
- {
- List.Remove (value);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is Instruction))
- throw new ArgumentException ("Must be of type " + typeof (Instruction).FullName);
- }
-
- public void Accept (ICodeVisitor visitor)
- {
- visitor.VisitInstructionCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodBody.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodBody.cs
index a20617a..b57900e 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodBody.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodBody.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,557 +26,205 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil.Cil {
+using System;
+
+using Mono.Collections.Generic;
- using Mono.Cecil;
+namespace Mono.Cecil.Cil {
- public sealed class MethodBody : IVariableDefinitionProvider, IScopeProvider, ICodeVisitable {
+ public sealed class MethodBody : IVariableDefinitionProvider {
- MethodDefinition m_method;
- int m_maxStack;
- int m_codeSize;
- bool m_initLocals;
- int m_localVarToken;
+ readonly internal MethodDefinition method;
- InstructionCollection m_instructions;
- ExceptionHandlerCollection m_exceptions;
- VariableDefinitionCollection m_variables;
- ScopeCollection m_scopes;
+ internal ParameterDefinition this_parameter;
+ internal int max_stack_size;
+ internal int code_size;
+ internal bool init_locals;
+ internal MetadataToken local_var_token;
- private CilWorker m_cilWorker;
+ internal Collection<Instruction> instructions;
+ internal Collection<ExceptionHandler> exceptions;
+ internal Collection<VariableDefinition> variables;
+ Scope scope;
public MethodDefinition Method {
- get { return m_method; }
+ get { return method; }
}
- public int MaxStack {
- get { return m_maxStack; }
- set { m_maxStack = value; }
+ public int MaxStackSize {
+ get { return max_stack_size; }
+ set { max_stack_size = value; }
}
public int CodeSize {
- get { return m_codeSize; }
- set { m_codeSize = value; }
+ get { return code_size; }
}
public bool InitLocals {
- get { return m_initLocals; }
- set { m_initLocals = value; }
+ get { return init_locals; }
+ set { init_locals = value; }
}
- internal int LocalVarToken {
- get { return m_localVarToken; }
- set { m_localVarToken = value; }
+ public MetadataToken LocalVarToken {
+ get { return local_var_token; }
+ set { local_var_token = value; }
}
- public CilWorker CilWorker {
- get {
- if (m_cilWorker == null)
- m_cilWorker = new CilWorker (this);
- return m_cilWorker;
- }
- set { m_cilWorker = value; }
+ public Collection<Instruction> Instructions {
+ get { return instructions ?? (instructions = new InstructionCollection ()); }
}
- public InstructionCollection Instructions {
- get { return m_instructions; }
+ public bool HasExceptionHandlers {
+ get { return !exceptions.IsNullOrEmpty (); }
}
- public ExceptionHandlerCollection ExceptionHandlers {
- get { return m_exceptions; }
+ public Collection<ExceptionHandler> ExceptionHandlers {
+ get { return exceptions ?? (exceptions = new Collection<ExceptionHandler> ()); }
}
- public VariableDefinitionCollection Variables {
- get { return m_variables; }
+ public bool HasVariables {
+ get { return !variables.IsNullOrEmpty (); }
}
- public ScopeCollection Scopes {
- get { return m_scopes; }
+ public Collection<VariableDefinition> Variables {
+ get { return variables ?? (variables = new VariableDefinitionCollection ()); }
}
- public MethodBody (MethodDefinition meth)
- {
- m_method = meth;
- m_instructions = new InstructionCollection (this);
- m_exceptions = new ExceptionHandlerCollection (this);
- m_variables = new VariableDefinitionCollection (this);
- m_scopes = new ScopeCollection (this);
+ public Scope Scope {
+ get { return scope; }
+ set { scope = value; }
}
- internal static Instruction GetInstruction (MethodBody oldBody, MethodBody newBody, Instruction i)
- {
- int pos = oldBody.Instructions.IndexOf (i);
- if (pos > -1 && pos < newBody.Instructions.Count)
- return newBody.Instructions [pos];
+ public ParameterDefinition ThisParameter {
+ get {
+ if (method == null || method.DeclaringType == null)
+ throw new NotSupportedException ();
- return newBody.Instructions.Outside;
+ return this_parameter ?? (this_parameter = new ParameterDefinition ("0", ParameterAttributes.None, method.DeclaringType));
+ }
}
- internal static MethodBody Clone (MethodBody body, MethodDefinition parent, ImportContext context)
+ public MethodBody (MethodDefinition method)
{
- MethodBody nb = new MethodBody (parent);
- nb.MaxStack = body.MaxStack;
- nb.InitLocals = body.InitLocals;
- nb.CodeSize = body.CodeSize;
-
- foreach (VariableDefinition var in body.Variables)
- nb.Variables.Add (new VariableDefinition (
- context.Import (var.VariableType)));
-
- foreach (Instruction instr in body.Instructions) {
- Instruction ni = new Instruction (instr.OpCode);
-
- switch (instr.OpCode.OperandType) {
- case OperandType.InlineParam :
- case OperandType.ShortInlineParam :
- if (instr.Operand == body.Method.This)
- ni.Operand = nb.Method.This;
- else {
- int param = body.Method.Parameters.IndexOf ((ParameterDefinition) instr.Operand);
- ni.Operand = parent.Parameters [param];
- }
- break;
- case OperandType.InlineVar :
- case OperandType.ShortInlineVar :
- int var = body.Variables.IndexOf ((VariableDefinition) instr.Operand);
- ni.Operand = nb.Variables [var];
- break;
- case OperandType.InlineField :
- ni.Operand = context.Import ((FieldReference) instr.Operand);
- break;
- case OperandType.InlineMethod :
- ni.Operand = context.Import ((MethodReference) instr.Operand);
- break;
- case OperandType.InlineType :
- ni.Operand = context.Import ((TypeReference) instr.Operand);
- break;
- case OperandType.InlineTok :
- if (instr.Operand is TypeReference)
- ni.Operand = context.Import ((TypeReference) instr.Operand);
- else if (instr.Operand is FieldReference)
- ni.Operand = context.Import ((FieldReference) instr.Operand);
- else if (instr.Operand is MethodReference)
- ni.Operand = context.Import ((MethodReference) instr.Operand);
- break;
- case OperandType.ShortInlineBrTarget :
- case OperandType.InlineBrTarget :
- break;
- default :
- ni.Operand = instr.Operand;
- break;
- }
-
- nb.Instructions.Add (ni);
- }
+ this.method = method;
+ }
- for (int i = 0; i < body.Instructions.Count; i++) {
- Instruction instr = nb.Instructions [i];
- if (instr.OpCode.OperandType != OperandType.ShortInlineBrTarget &&
- instr.OpCode.OperandType != OperandType.InlineBrTarget)
- continue;
+ public ILProcessor GetILProcessor ()
+ {
+ return new ILProcessor (this);
+ }
+ }
- instr.Operand = GetInstruction (body, nb, (Instruction) body.Instructions [i].Operand);
- }
+ public interface IVariableDefinitionProvider {
+ bool HasVariables { get; }
+ Collection<VariableDefinition> Variables { get; }
+ }
- foreach (ExceptionHandler eh in body.ExceptionHandlers) {
- ExceptionHandler neh = new ExceptionHandler (eh.Type);
- neh.TryStart = GetInstruction (body, nb, eh.TryStart);
- neh.TryEnd = GetInstruction (body, nb, eh.TryEnd);
- neh.HandlerStart = GetInstruction (body, nb, eh.HandlerStart);
- neh.HandlerEnd = GetInstruction (body, nb, eh.HandlerEnd);
-
- switch (eh.Type) {
- case ExceptionHandlerType.Catch :
- neh.CatchType = context.Import (eh.CatchType);
- break;
- case ExceptionHandlerType.Filter :
- neh.FilterStart = GetInstruction (body, nb, eh.FilterStart);
- neh.FilterEnd = GetInstruction (body, nb, eh.FilterEnd);
- break;
- }
-
- nb.ExceptionHandlers.Add (neh);
- }
+ class VariableDefinitionCollection : Collection<VariableDefinition> {
- return nb;
+ internal VariableDefinitionCollection ()
+ {
}
- public void Modify ()
+ internal VariableDefinitionCollection (int capacity)
+ : base (capacity)
{
- foreach (Instruction i in this.Instructions) {
- if (i.OpCode.OpCodeType != OpCodeType.Macro)
- continue;
-
- switch (i.OpCode.Code) {
- case Code.Ldarg_0 :
- Modify (i, OpCodes.Ldarg,
- CodeReader.GetParameter (this, 0));
- break;
- case Code.Ldarg_1 :
- Modify (i, OpCodes.Ldarg,
- CodeReader.GetParameter (this, 1));
- break;
- case Code.Ldarg_2 :
- Modify (i, OpCodes.Ldarg,
- CodeReader.GetParameter (this, 2));
- break;
- case Code.Ldarg_3 :
- Modify (i, OpCodes.Ldarg,
- CodeReader.GetParameter (this, 3));
- break;
- case Code.Ldloc_0 :
- Modify (i, OpCodes.Ldloc,
- CodeReader.GetVariable (this, 0));
- break;
- case Code.Ldloc_1 :
- Modify (i, OpCodes.Ldloc,
- CodeReader.GetVariable (this, 1));
- break;
- case Code.Ldloc_2 :
- Modify (i, OpCodes.Ldloc,
- CodeReader.GetVariable (this, 2));
- break;
- case Code.Ldloc_3 :
- Modify (i, OpCodes.Ldloc,
- CodeReader.GetVariable (this, 3));
- break;
- case Code.Stloc_0 :
- Modify (i, OpCodes.Stloc,
- CodeReader.GetVariable (this, 0));
- break;
- case Code.Stloc_1 :
- Modify (i, OpCodes.Stloc,
- CodeReader.GetVariable (this, 1));
- break;
- case Code.Stloc_2 :
- Modify (i, OpCodes.Stloc,
- CodeReader.GetVariable (this, 2));
- break;
- case Code.Stloc_3 :
- Modify (i, OpCodes.Stloc,
- CodeReader.GetVariable (this, 3));
- break;
- case Code.Ldarg_S :
- i.OpCode = OpCodes.Ldarg;
- break;
- case Code.Ldarga_S :
- i.OpCode = OpCodes.Ldarga;
- break;
- case Code.Starg_S :
- i.OpCode = OpCodes.Starg;
- break;
- case Code.Ldloc_S :
- i.OpCode = OpCodes.Ldloc;
- break;
- case Code.Ldloca_S :
- i.OpCode = OpCodes.Ldloca;
- break;
- case Code.Stloc_S :
- i.OpCode = OpCodes.Stloc;
- break;
- case Code.Ldc_I4_M1 :
- Modify (i, OpCodes.Ldc_I4, -1);
- break;
- case Code.Ldc_I4_0 :
- Modify (i, OpCodes.Ldc_I4, 0);
- break;
- case Code.Ldc_I4_1 :
- Modify (i, OpCodes.Ldc_I4, 1);
- break;
- case Code.Ldc_I4_2 :
- Modify (i, OpCodes.Ldc_I4, 2);
- break;
- case Code.Ldc_I4_3 :
- Modify (i, OpCodes.Ldc_I4, 3);
- break;
- case Code.Ldc_I4_4 :
- Modify (i, OpCodes.Ldc_I4, 4);
- break;
- case Code.Ldc_I4_5 :
- Modify (i, OpCodes.Ldc_I4, 5);
- break;
- case Code.Ldc_I4_6 :
- Modify (i, OpCodes.Ldc_I4, 6);
- break;
- case Code.Ldc_I4_7 :
- Modify (i, OpCodes.Ldc_I4, 7);
- break;
- case Code.Ldc_I4_8 :
- Modify (i, OpCodes.Ldc_I4, 8);
- break;
- case Code.Ldc_I4_S :
- i.OpCode = OpCodes.Ldc_I4;
- i.Operand = (int) (sbyte) i.Operand;
- break;
- case Code.Br_S :
- i.OpCode = OpCodes.Br;
- break;
- case Code.Brfalse_S :
- i.OpCode = OpCodes.Brfalse;
- break;
- case Code.Brtrue_S :
- i.OpCode = OpCodes.Brtrue;
- break;
- case Code.Beq_S :
- i.OpCode = OpCodes.Beq;
- break;
- case Code.Bge_S :
- i.OpCode = OpCodes.Bge;
- break;
- case Code.Bgt_S :
- i.OpCode = OpCodes.Bgt;
- break;
- case Code.Ble_S :
- i.OpCode = OpCodes.Ble;
- break;
- case Code.Blt_S :
- i.OpCode = OpCodes.Blt;
- break;
- case Code.Bne_Un_S :
- i.OpCode = OpCodes.Bne_Un;
- break;
- case Code.Bge_Un_S :
- i.OpCode = OpCodes.Bge_Un;
- break;
- case Code.Bgt_Un_S :
- i.OpCode = OpCodes.Bgt_Un;
- break;
- case Code.Ble_Un_S :
- i.OpCode = OpCodes.Ble_Un;
- break;
- case Code.Blt_Un_S :
- i.OpCode = OpCodes.Blt_Un;
- break;
- case Code.Leave_S :
- i.OpCode = OpCodes.Leave;
- break;
- }
- }
}
- public void Optimize ()
+ protected override void OnAdd (VariableDefinition item, int index)
{
- foreach (Instruction instr in m_instructions) {
- int index;
- switch (instr.OpCode.Code) {
- case Code.Ldarg:
- index = m_method.Parameters.IndexOf ((ParameterDefinition) instr.Operand);
- if (index == -1 && instr.Operand == m_method.This)
- index = 0;
- else if (m_method.HasThis)
- index++;
-
- switch (index) {
- case 0:
- Modify (instr, OpCodes.Ldarg_0, null);
- break;
- case 1:
- Modify (instr, OpCodes.Ldarg_1, null);
- break;
- case 2:
- Modify (instr, OpCodes.Ldarg_2, null);
- break;
- case 3:
- Modify (instr, OpCodes.Ldarg_3, null);
- break;
- default:
- if (index < 256)
- Modify (instr, OpCodes.Ldarg_S, instr.Operand);
- break;
- }
- break;
- case Code.Ldloc:
- index = m_variables.IndexOf ((VariableDefinition) instr.Operand);
- switch (index) {
- case 0:
- Modify (instr, OpCodes.Ldloc_0, null);
- break;
- case 1:
- Modify (instr, OpCodes.Ldloc_1, null);
- break;
- case 2:
- Modify (instr, OpCodes.Ldloc_2, null);
- break;
- case 3:
- Modify (instr, OpCodes.Ldloc_3, null);
- break;
- default:
- if (index < 256)
- Modify (instr, OpCodes.Ldloc_S, instr.Operand);
- break;
- }
- break;
- case Code.Stloc:
- index = m_variables.IndexOf ((VariableDefinition) instr.Operand);
- switch (index) {
- case 0:
- Modify (instr, OpCodes.Stloc_0, null);
- break;
- case 1:
- Modify (instr, OpCodes.Stloc_1, null);
- break;
- case 2:
- Modify (instr, OpCodes.Stloc_2, null);
- break;
- case 3:
- Modify (instr, OpCodes.Stloc_3, null);
- break;
- default:
- if (index < 256)
- Modify (instr, OpCodes.Stloc_S, instr.Operand);
- break;
- }
- break;
- case Code.Ldarga:
- index = m_method.Parameters.IndexOf ((ParameterDefinition) instr.Operand);
- if (index == -1 && instr.Operand == m_method.This)
- index = 0;
- else if (m_method.HasThis)
- index++;
- if (index < 256)
- Modify (instr, OpCodes.Ldarga_S, instr.Operand);
- break;
- case Code.Ldloca:
- if (m_variables.IndexOf ((VariableDefinition) instr.Operand) < 256)
- Modify (instr, OpCodes.Ldloca_S, instr.Operand);
- break;
- case Code.Ldc_I4:
- int i = (int) instr.Operand;
- switch (i) {
- case -1:
- Modify (instr, OpCodes.Ldc_I4_M1, null);
- break;
- case 0:
- Modify (instr, OpCodes.Ldc_I4_0, null);
- break;
- case 1:
- Modify (instr, OpCodes.Ldc_I4_1, null);
- break;
- case 2:
- Modify (instr, OpCodes.Ldc_I4_2, null);
- break;
- case 3:
- Modify (instr, OpCodes.Ldc_I4_3, null);
- break;
- case 4:
- Modify (instr, OpCodes.Ldc_I4_4, null);
- break;
- case 5:
- Modify (instr, OpCodes.Ldc_I4_5, null);
- break;
- case 6:
- Modify (instr, OpCodes.Ldc_I4_6, null);
- break;
- case 7:
- Modify (instr, OpCodes.Ldc_I4_7, null);
- break;
- case 8:
- Modify (instr, OpCodes.Ldc_I4_8, null);
- break;
- default:
- if (i >= -128 || i < 128)
- Modify (instr, OpCodes.Ldc_I4_S, (sbyte) i);
- break;
- }
- break;
- }
- }
+ item.index = index;
+ }
+
+ protected override void OnInsert (VariableDefinition item, int index)
+ {
+ item.index = index;
- OptimizeBranches ();
+ for (int i = index; i < size; i++)
+ items [i].index = i + 1;
}
- void OptimizeBranches ()
+ protected override void OnSet (VariableDefinition item, int index)
{
- ComputeOffsets ();
+ item.index = index;
+ }
- foreach (Instruction instr in m_instructions) {
- if (instr.OpCode.OperandType != OperandType.InlineBrTarget)
- continue;
+ protected override void OnRemove (VariableDefinition item, int index)
+ {
+ item.index = -1;
- if (OptimizeBranch (instr))
- ComputeOffsets ();
- }
+ for (int i = index + 1; i < size; i++)
+ items [i].index = i - 1;
}
+ }
+
+ class InstructionCollection : Collection<Instruction> {
- static bool OptimizeBranch (Instruction instr)
+ internal InstructionCollection ()
{
- int offset = ((Instruction) instr.Operand).Offset - (instr.Offset + instr.OpCode.Size + 4);
- if (! (offset >= -128 && offset <= 127))
- return false;
-
- switch (instr.OpCode.Code) {
- case Code.Br:
- instr.OpCode = OpCodes.Br_S;
- break;
- case Code.Brfalse:
- instr.OpCode = OpCodes.Brfalse_S;
- break;
- case Code.Brtrue:
- instr.OpCode = OpCodes.Brtrue_S;
- break;
- case Code.Beq:
- instr.OpCode = OpCodes.Beq_S;
- break;
- case Code.Bge:
- instr.OpCode = OpCodes.Bge_S;
- break;
- case Code.Bgt:
- instr.OpCode = OpCodes.Bgt_S;
- break;
- case Code.Ble:
- instr.OpCode = OpCodes.Ble_S;
- break;
- case Code.Blt:
- instr.OpCode = OpCodes.Blt_S;
- break;
- case Code.Bne_Un:
- instr.OpCode = OpCodes.Bne_Un_S;
- break;
- case Code.Bge_Un:
- instr.OpCode = OpCodes.Bge_Un_S;
- break;
- case Code.Bgt_Un:
- instr.OpCode = OpCodes.Bgt_Un_S;
- break;
- case Code.Ble_Un:
- instr.OpCode = OpCodes.Ble_Un_S;
- break;
- case Code.Blt_Un:
- instr.OpCode = OpCodes.Blt_Un_S;
- break;
- case Code.Leave:
- instr.OpCode = OpCodes.Leave_S;
- break;
- }
+ }
- return true;
+ internal InstructionCollection (int capacity)
+ : base (capacity)
+ {
+ }
+
+ protected override void OnAdd (Instruction item, int index)
+ {
+ if (index == 0)
+ return;
+
+ var previous = items [index - 1];
+ previous.next = item;
+ item.previous = previous;
}
- void ComputeOffsets ()
+ protected override void OnInsert (Instruction item, int index)
{
- int offset = 0;
+ if (size == 0)
+ return;
+
+ var current = items [index];
+ if (current == null) {
+ var last = items [index - 1];
+ last.next = item;
+ item.previous = last;
+ return;
+ }
- foreach (Instruction instr in m_instructions) {
- instr.Offset = offset;
- offset += instr.GetSize ();
+ var previous = current.previous;
+ if (previous != null) {
+ previous.next = item;
+ item.previous = previous;
}
+
+ current.previous = item;
+ item.next = current;
}
- static void Modify (Instruction i, OpCode op, object operand)
+ protected override void OnSet (Instruction item, int index)
{
- i.OpCode = op;
- i.Operand = operand;
+ var current = items [index];
+
+ item.previous = current.previous;
+ item.next = current.next;
+
+ current.previous = null;
+ current.next = null;
}
- public void Accept (ICodeVisitor visitor)
+ protected override void OnRemove (Instruction item, int index)
{
- visitor.VisitMethodBody (this);
- m_variables.Accept (visitor);
- m_instructions.Accept (visitor);
- m_exceptions.Accept (visitor);
- m_scopes.Accept (visitor);
+ var previous = item.previous;
+ if (previous != null)
+ previous.next = item.next;
+
+ var next = item.next;
+ if (next != null)
+ next.previous = item.previous;
- visitor.TerminateMethodBody (this);
+ item.previous = null;
+ item.next = null;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodDataSection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodDataSection.cs
deleted file mode 100644
index 295ccdb..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodDataSection.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// MethodDataSection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- internal enum MethodDataSection : ushort {
- EHTable = 0x1,
- OptILTable = 0x2,
- FatFormat = 0x40,
- MoreSects = 0x80
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodHeader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodHeader.cs
deleted file mode 100644
index c90ce2f..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/MethodHeader.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// MethodHeader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- internal enum MethodHeader : ushort {
- TinyFormat = 0x2,
- FatFormat = 0x3,
- MoreSects = 0x8,
- InitLocals = 0x10
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCode.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCode.cs
index c6d0417..aad4ba4 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCode.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCode.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,79 +28,148 @@
namespace Mono.Cecil.Cil {
- public struct OpCode {
+ public enum FlowControl {
+ Branch,
+ Break,
+ Call,
+ Cond_Branch,
+ Meta,
+ Next,
+ Phi,
+ Return,
+ Throw,
+ }
- string m_name;
- byte m_op1;
- byte m_op2;
- int m_size;
+ public enum OpCodeType {
+ Annotation,
+ Macro,
+ Nternal,
+ Objmodel,
+ Prefix,
+ Primitive,
+ }
+
+ public enum OperandType {
+ InlineBrTarget,
+ InlineField,
+ InlineI,
+ InlineI8,
+ InlineMethod,
+ InlineNone,
+ InlinePhi,
+ InlineR,
+ InlineSig,
+ InlineString,
+ InlineSwitch,
+ InlineTok,
+ InlineType,
+ InlineVar,
+ InlineArg,
+ ShortInlineBrTarget,
+ ShortInlineI,
+ ShortInlineR,
+ ShortInlineVar,
+ ShortInlineArg,
+ }
+
+ public enum StackBehaviour {
+ Pop0,
+ Pop1,
+ Pop1_pop1,
+ Popi,
+ Popi_pop1,
+ Popi_popi,
+ Popi_popi8,
+ Popi_popi_popi,
+ Popi_popr4,
+ Popi_popr8,
+ Popref,
+ Popref_pop1,
+ Popref_popi,
+ Popref_popi_popi,
+ Popref_popi_popi8,
+ Popref_popi_popr4,
+ Popref_popi_popr8,
+ Popref_popi_popref,
+ PopAll,
+ Push0,
+ Push1,
+ Push1_push1,
+ Pushi,
+ Pushi8,
+ Pushr4,
+ Pushr8,
+ Pushref,
+ Varpop,
+ Varpush,
+ }
+
+ public struct OpCode {
- Code m_code;
- FlowControl m_flowControl;
- OpCodeType m_opCodeType;
- OperandType m_operandType;
- StackBehaviour m_stackBehaviourPop;
- StackBehaviour m_stackBehaviourPush;
+ readonly byte op1;
+ readonly byte op2;
+ readonly byte code;
+ readonly byte flow_control;
+ readonly byte opcode_type;
+ readonly byte operand_type;
+ readonly byte stack_behavior_pop;
+ readonly byte stack_behavior_push;
public string Name {
- get { return m_name; }
+ get { return OpCodeNames.names [op1 == 0xff ? op2 : op2 + 256]; }
}
public int Size {
- get { return m_size; }
+ get { return op1 == 0xff ? 1 : 2; }
}
public byte Op1 {
- get { return m_op1; }
+ get { return op1; }
}
public byte Op2 {
- get { return m_op2; }
+ get { return op2; }
}
public short Value {
- get { return m_size == 1 ? m_op2 : (short) ((m_op1 << 8) | m_op2); }
+ get { return (short) ((op1 << 8) | op2); }
}
public Code Code {
- get { return m_code; }
+ get { return (Code) code; }
}
public FlowControl FlowControl {
- get { return m_flowControl; }
+ get { return (FlowControl) flow_control; }
}
public OpCodeType OpCodeType {
- get { return m_opCodeType; }
+ get { return (OpCodeType) opcode_type; }
}
public OperandType OperandType {
- get { return m_operandType; }
+ get { return (OperandType) operand_type; }
}
public StackBehaviour StackBehaviourPop {
- get { return m_stackBehaviourPop; }
+ get { return (StackBehaviour) stack_behavior_pop; }
}
public StackBehaviour StackBehaviourPush {
- get { return m_stackBehaviourPush; }
+ get { return (StackBehaviour) stack_behavior_push; }
}
- internal OpCode (string name, byte op1, byte op2, int size,
- Code code, FlowControl flowControl,
- OpCodeType opCodeType, OperandType operandType,
- StackBehaviour pop, StackBehaviour push)
+ internal OpCode (int x, int y)
{
- m_name = name;
- m_op1 = op1;
- m_op2 = op2;
- m_size = size;
- m_code = code;
- m_flowControl = flowControl;
- m_opCodeType = opCodeType;
- m_operandType = operandType;
- m_stackBehaviourPop = pop;
- m_stackBehaviourPush = push;
+ this.op1 = (byte) ((x >> 0) & 0xff);
+ this.op2 = (byte) ((x >> 8) & 0xff);
+ this.code = (byte) ((x >> 16) & 0xff);
+ this.flow_control = (byte) ((x >> 24) & 0xff);
+
+ this.opcode_type = (byte) ((y >> 0) & 0xff);
+ this.operand_type = (byte) ((y >> 8) & 0xff);
+ this.stack_behavior_pop = (byte) ((y >> 16) & 0xff);
+ this.stack_behavior_push = (byte) ((y >> 24) & 0xff);
if (op1 == 0xff)
OpCodes.OneByteOpCode [op2] = this;
@@ -110,30 +179,346 @@ namespace Mono.Cecil.Cil {
public override int GetHashCode ()
{
- return this.Value;
+ return Value;
}
public override bool Equals (object obj)
{
if (!(obj is OpCode))
return false;
- OpCode v = (OpCode) obj;
- return v.m_op1 == m_op1 && v.m_op2 == m_op2;
+
+ var opcode = (OpCode) obj;
+ return op1 == opcode.op1 && op2 == opcode.op2;
+ }
+
+ public bool Equals (OpCode opcode)
+ {
+ return op1 == opcode.op1 && op2 == opcode.op2;
}
public static bool operator == (OpCode one, OpCode other)
{
- return one.Equals (other);
+ return one.op1 == other.op1 && one.op2 == other.op2;
}
public static bool operator != (OpCode one, OpCode other)
{
- return !one.Equals (other);
+ return one.op1 != other.op1 || one.op2 != other.op2;
}
public override string ToString ()
{
- return m_name;
+ return Name;
}
}
+
+ 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,
+ };
+ }
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodeType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodeType.cs
deleted file mode 100644
index c6106d9..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodeType.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// OpCodeType.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- public enum OpCodeType {
- Annotation,
- Macro,
- Nternal,
- Objmodel,
- Prefix,
- Primitive
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodes.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodes.cs
index fa3b0b2..ce468a1 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodes.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OpCodes.cs
@@ -4,10 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Sat Aug 18 08:11:28 +0200 2007
-//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -31,1553 +28,885 @@
namespace Mono.Cecil.Cil {
- public sealed class OpCodes {
+ public static class OpCodes {
internal static readonly OpCode [] OneByteOpCode = new OpCode [0xe0 + 1];
internal static readonly OpCode [] TwoBytesOpCode = new OpCode [0x1e + 1];
public static readonly OpCode Nop = new OpCode (
- "nop", 0xff, 0x00, 1,
- Code.Nop, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Push0);
+ 0xff << 0 | 0x00 << 8 | (byte) Code.Nop << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Break = new OpCode (
- "break", 0xff, 0x01, 1,
- Code.Break, FlowControl.Break,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Push0);
+ 0xff << 0 | 0x01 << 8 | (byte) Code.Break << 16 | (byte) FlowControl.Break << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Ldarg_0 = new OpCode (
- "ldarg.0", 0xff, 0x02, 1,
- Code.Ldarg_0, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Push1);
+ 0xff << 0 | 0x02 << 8 | (byte) Code.Ldarg_0 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Ldarg_1 = new OpCode (
- "ldarg.1", 0xff, 0x03, 1,
- Code.Ldarg_1, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Push1);
+ 0xff << 0 | 0x03 << 8 | (byte) Code.Ldarg_1 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Ldarg_2 = new OpCode (
- "ldarg.2", 0xff, 0x04, 1,
- Code.Ldarg_2, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Push1);
+ 0xff << 0 | 0x04 << 8 | (byte) Code.Ldarg_2 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Ldarg_3 = new OpCode (
- "ldarg.3", 0xff, 0x05, 1,
- Code.Ldarg_3, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Push1);
+ 0xff << 0 | 0x05 << 8 | (byte) Code.Ldarg_3 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Ldloc_0 = new OpCode (
- "ldloc.0", 0xff, 0x06, 1,
- Code.Ldloc_0, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Push1);
+ 0xff << 0 | 0x06 << 8 | (byte) Code.Ldloc_0 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Ldloc_1 = new OpCode (
- "ldloc.1", 0xff, 0x07, 1,
- Code.Ldloc_1, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Push1);
+ 0xff << 0 | 0x07 << 8 | (byte) Code.Ldloc_1 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Ldloc_2 = new OpCode (
- "ldloc.2", 0xff, 0x08, 1,
- Code.Ldloc_2, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Push1);
+ 0xff << 0 | 0x08 << 8 | (byte) Code.Ldloc_2 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Ldloc_3 = new OpCode (
- "ldloc.3", 0xff, 0x09, 1,
- Code.Ldloc_3, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Push1);
+ 0xff << 0 | 0x09 << 8 | (byte) Code.Ldloc_3 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Stloc_0 = new OpCode (
- "stloc.0", 0xff, 0x0a, 1,
- Code.Stloc_0, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x0a << 8 | (byte) Code.Stloc_0 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stloc_1 = new OpCode (
- "stloc.1", 0xff, 0x0b, 1,
- Code.Stloc_1, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x0b << 8 | (byte) Code.Stloc_1 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stloc_2 = new OpCode (
- "stloc.2", 0xff, 0x0c, 1,
- Code.Stloc_2, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x0c << 8 | (byte) Code.Stloc_2 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stloc_3 = new OpCode (
- "stloc.3", 0xff, 0x0d, 1,
- Code.Stloc_3, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x0d << 8 | (byte) Code.Stloc_3 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Ldarg_S = new OpCode (
- "ldarg.s", 0xff, 0x0e, 1,
- Code.Ldarg_S, FlowControl.Next,
- OpCodeType.Macro, OperandType.ShortInlineParam,
- StackBehaviour.Pop0, StackBehaviour.Push1);
+ 0xff << 0 | 0x0e << 8 | (byte) Code.Ldarg_S << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineArg << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Ldarga_S = new OpCode (
- "ldarga.s", 0xff, 0x0f, 1,
- Code.Ldarga_S, FlowControl.Next,
- OpCodeType.Macro, OperandType.ShortInlineParam,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0x0f << 8 | (byte) Code.Ldarga_S << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineArg << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Starg_S = new OpCode (
- "starg.s", 0xff, 0x10, 1,
- Code.Starg_S, FlowControl.Next,
- OpCodeType.Macro, OperandType.ShortInlineParam,
- StackBehaviour.Pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x10 << 8 | (byte) Code.Starg_S << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineArg << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Ldloc_S = new OpCode (
- "ldloc.s", 0xff, 0x11, 1,
- Code.Ldloc_S, FlowControl.Next,
- OpCodeType.Macro, OperandType.ShortInlineVar,
- StackBehaviour.Pop0, StackBehaviour.Push1);
+ 0xff << 0 | 0x11 << 8 | (byte) Code.Ldloc_S << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineVar << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Ldloca_S = new OpCode (
- "ldloca.s", 0xff, 0x12, 1,
- Code.Ldloca_S, FlowControl.Next,
- OpCodeType.Macro, OperandType.ShortInlineVar,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0x12 << 8 | (byte) Code.Ldloca_S << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineVar << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Stloc_S = new OpCode (
- "stloc.s", 0xff, 0x13, 1,
- Code.Stloc_S, FlowControl.Next,
- OpCodeType.Macro, OperandType.ShortInlineVar,
- StackBehaviour.Pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x13 << 8 | (byte) Code.Stloc_S << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineVar << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Ldnull = new OpCode (
- "ldnull", 0xff, 0x14, 1,
- Code.Ldnull, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Pushref);
+ 0xff << 0 | 0x14 << 8 | (byte) Code.Ldnull << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushref << 24);
public static readonly OpCode Ldc_I4_M1 = new OpCode (
- "ldc.i4.m1", 0xff, 0x15, 1,
- Code.Ldc_I4_M1, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0x15 << 8 | (byte) Code.Ldc_I4_M1 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldc_I4_0 = new OpCode (
- "ldc.i4.0", 0xff, 0x16, 1,
- Code.Ldc_I4_0, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0x16 << 8 | (byte) Code.Ldc_I4_0 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldc_I4_1 = new OpCode (
- "ldc.i4.1", 0xff, 0x17, 1,
- Code.Ldc_I4_1, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0x17 << 8 | (byte) Code.Ldc_I4_1 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldc_I4_2 = new OpCode (
- "ldc.i4.2", 0xff, 0x18, 1,
- Code.Ldc_I4_2, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0x18 << 8 | (byte) Code.Ldc_I4_2 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldc_I4_3 = new OpCode (
- "ldc.i4.3", 0xff, 0x19, 1,
- Code.Ldc_I4_3, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0x19 << 8 | (byte) Code.Ldc_I4_3 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldc_I4_4 = new OpCode (
- "ldc.i4.4", 0xff, 0x1a, 1,
- Code.Ldc_I4_4, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0x1a << 8 | (byte) Code.Ldc_I4_4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldc_I4_5 = new OpCode (
- "ldc.i4.5", 0xff, 0x1b, 1,
- Code.Ldc_I4_5, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0x1b << 8 | (byte) Code.Ldc_I4_5 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldc_I4_6 = new OpCode (
- "ldc.i4.6", 0xff, 0x1c, 1,
- Code.Ldc_I4_6, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0x1c << 8 | (byte) Code.Ldc_I4_6 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldc_I4_7 = new OpCode (
- "ldc.i4.7", 0xff, 0x1d, 1,
- Code.Ldc_I4_7, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0x1d << 8 | (byte) Code.Ldc_I4_7 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldc_I4_8 = new OpCode (
- "ldc.i4.8", 0xff, 0x1e, 1,
- Code.Ldc_I4_8, FlowControl.Next,
- OpCodeType.Macro, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0x1e << 8 | (byte) Code.Ldc_I4_8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldc_I4_S = new OpCode (
- "ldc.i4.s", 0xff, 0x1f, 1,
- Code.Ldc_I4_S, FlowControl.Next,
- OpCodeType.Macro, OperandType.ShortInlineI,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0x1f << 8 | (byte) Code.Ldc_I4_S << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineI << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldc_I4 = new OpCode (
- "ldc.i4", 0xff, 0x20, 1,
- Code.Ldc_I4, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineI,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0x20 << 8 | (byte) Code.Ldc_I4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineI << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldc_I8 = new OpCode (
- "ldc.i8", 0xff, 0x21, 1,
- Code.Ldc_I8, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineI8,
- StackBehaviour.Pop0, StackBehaviour.Pushi8);
+ 0xff << 0 | 0x21 << 8 | (byte) Code.Ldc_I8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineI8 << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi8 << 24);
public static readonly OpCode Ldc_R4 = new OpCode (
- "ldc.r4", 0xff, 0x22, 1,
- Code.Ldc_R4, FlowControl.Next,
- OpCodeType.Primitive, OperandType.ShortInlineR,
- StackBehaviour.Pop0, StackBehaviour.Pushr4);
+ 0xff << 0 | 0x22 << 8 | (byte) Code.Ldc_R4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.ShortInlineR << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushr4 << 24);
public static readonly OpCode Ldc_R8 = new OpCode (
- "ldc.r8", 0xff, 0x23, 1,
- Code.Ldc_R8, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineR,
- StackBehaviour.Pop0, StackBehaviour.Pushr8);
+ 0xff << 0 | 0x23 << 8 | (byte) Code.Ldc_R8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineR << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushr8 << 24);
public static readonly OpCode Dup = new OpCode (
- "dup", 0xff, 0x25, 1,
- Code.Dup, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Push1_push1);
+ 0xff << 0 | 0x25 << 8 | (byte) Code.Dup << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push1_push1 << 24);
public static readonly OpCode Pop = new OpCode (
- "pop", 0xff, 0x26, 1,
- Code.Pop, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x26 << 8 | (byte) Code.Pop << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Jmp = new OpCode (
- "jmp", 0xff, 0x27, 1,
- Code.Jmp, FlowControl.Call,
- OpCodeType.Primitive, OperandType.InlineMethod,
- StackBehaviour.Pop0, StackBehaviour.Push0);
+ 0xff << 0 | 0x27 << 8 | (byte) Code.Jmp << 16 | (byte) FlowControl.Call << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineMethod << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Call = new OpCode (
- "call", 0xff, 0x28, 1,
- Code.Call, FlowControl.Call,
- OpCodeType.Primitive, OperandType.InlineMethod,
- StackBehaviour.Varpop, StackBehaviour.Varpush);
+ 0xff << 0 | 0x28 << 8 | (byte) Code.Call << 16 | (byte) FlowControl.Call << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineMethod << 8 | (byte) StackBehaviour.Varpop << 16 | (byte) StackBehaviour.Varpush << 24);
public static readonly OpCode Calli = new OpCode (
- "calli", 0xff, 0x29, 1,
- Code.Calli, FlowControl.Call,
- OpCodeType.Primitive, OperandType.InlineSig,
- StackBehaviour.Varpop, StackBehaviour.Varpush);
+ 0xff << 0 | 0x29 << 8 | (byte) Code.Calli << 16 | (byte) FlowControl.Call << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineSig << 8 | (byte) StackBehaviour.Varpop << 16 | (byte) StackBehaviour.Varpush << 24);
public static readonly OpCode Ret = new OpCode (
- "ret", 0xff, 0x2a, 1,
- Code.Ret, FlowControl.Return,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Varpop, StackBehaviour.Push0);
+ 0xff << 0 | 0x2a << 8 | (byte) Code.Ret << 16 | (byte) FlowControl.Return << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Varpop << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Br_S = new OpCode (
- "br.s", 0xff, 0x2b, 1,
- Code.Br_S, FlowControl.Branch,
- OpCodeType.Macro, OperandType.ShortInlineBrTarget,
- StackBehaviour.Pop0, StackBehaviour.Push0);
+ 0xff << 0 | 0x2b << 8 | (byte) Code.Br_S << 16 | (byte) FlowControl.Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Brfalse_S = new OpCode (
- "brfalse.s", 0xff, 0x2c, 1,
- Code.Brfalse_S, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.ShortInlineBrTarget,
- StackBehaviour.Popi, StackBehaviour.Push0);
+ 0xff << 0 | 0x2c << 8 | (byte) Code.Brfalse_S << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Brtrue_S = new OpCode (
- "brtrue.s", 0xff, 0x2d, 1,
- Code.Brtrue_S, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.ShortInlineBrTarget,
- StackBehaviour.Popi, StackBehaviour.Push0);
+ 0xff << 0 | 0x2d << 8 | (byte) Code.Brtrue_S << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Beq_S = new OpCode (
- "beq.s", 0xff, 0x2e, 1,
- Code.Beq_S, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.ShortInlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x2e << 8 | (byte) Code.Beq_S << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Bge_S = new OpCode (
- "bge.s", 0xff, 0x2f, 1,
- Code.Bge_S, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.ShortInlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x2f << 8 | (byte) Code.Bge_S << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Bgt_S = new OpCode (
- "bgt.s", 0xff, 0x30, 1,
- Code.Bgt_S, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.ShortInlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x30 << 8 | (byte) Code.Bgt_S << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Ble_S = new OpCode (
- "ble.s", 0xff, 0x31, 1,
- Code.Ble_S, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.ShortInlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x31 << 8 | (byte) Code.Ble_S << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Blt_S = new OpCode (
- "blt.s", 0xff, 0x32, 1,
- Code.Blt_S, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.ShortInlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x32 << 8 | (byte) Code.Blt_S << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Bne_Un_S = new OpCode (
- "bne.un.s", 0xff, 0x33, 1,
- Code.Bne_Un_S, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.ShortInlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x33 << 8 | (byte) Code.Bne_Un_S << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Bge_Un_S = new OpCode (
- "bge.un.s", 0xff, 0x34, 1,
- Code.Bge_Un_S, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.ShortInlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x34 << 8 | (byte) Code.Bge_Un_S << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Bgt_Un_S = new OpCode (
- "bgt.un.s", 0xff, 0x35, 1,
- Code.Bgt_Un_S, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.ShortInlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x35 << 8 | (byte) Code.Bgt_Un_S << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Ble_Un_S = new OpCode (
- "ble.un.s", 0xff, 0x36, 1,
- Code.Ble_Un_S, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.ShortInlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x36 << 8 | (byte) Code.Ble_Un_S << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Blt_Un_S = new OpCode (
- "blt.un.s", 0xff, 0x37, 1,
- Code.Blt_Un_S, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.ShortInlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x37 << 8 | (byte) Code.Blt_Un_S << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Br = new OpCode (
- "br", 0xff, 0x38, 1,
- Code.Br, FlowControl.Branch,
- OpCodeType.Primitive, OperandType.InlineBrTarget,
- StackBehaviour.Pop0, StackBehaviour.Push0);
+ 0xff << 0 | 0x38 << 8 | (byte) Code.Br << 16 | (byte) FlowControl.Branch << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Brfalse = new OpCode (
- "brfalse", 0xff, 0x39, 1,
- Code.Brfalse, FlowControl.Cond_Branch,
- OpCodeType.Primitive, OperandType.InlineBrTarget,
- StackBehaviour.Popi, StackBehaviour.Push0);
+ 0xff << 0 | 0x39 << 8 | (byte) Code.Brfalse << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Brtrue = new OpCode (
- "brtrue", 0xff, 0x3a, 1,
- Code.Brtrue, FlowControl.Cond_Branch,
- OpCodeType.Primitive, OperandType.InlineBrTarget,
- StackBehaviour.Popi, StackBehaviour.Push0);
+ 0xff << 0 | 0x3a << 8 | (byte) Code.Brtrue << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Beq = new OpCode (
- "beq", 0xff, 0x3b, 1,
- Code.Beq, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.InlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x3b << 8 | (byte) Code.Beq << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Bge = new OpCode (
- "bge", 0xff, 0x3c, 1,
- Code.Bge, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.InlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x3c << 8 | (byte) Code.Bge << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Bgt = new OpCode (
- "bgt", 0xff, 0x3d, 1,
- Code.Bgt, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.InlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x3d << 8 | (byte) Code.Bgt << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Ble = new OpCode (
- "ble", 0xff, 0x3e, 1,
- Code.Ble, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.InlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x3e << 8 | (byte) Code.Ble << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Blt = new OpCode (
- "blt", 0xff, 0x3f, 1,
- Code.Blt, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.InlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x3f << 8 | (byte) Code.Blt << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Bne_Un = new OpCode (
- "bne.un", 0xff, 0x40, 1,
- Code.Bne_Un, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.InlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x40 << 8 | (byte) Code.Bne_Un << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Bge_Un = new OpCode (
- "bge.un", 0xff, 0x41, 1,
- Code.Bge_Un, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.InlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x41 << 8 | (byte) Code.Bge_Un << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Bgt_Un = new OpCode (
- "bgt.un", 0xff, 0x42, 1,
- Code.Bgt_Un, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.InlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x42 << 8 | (byte) Code.Bgt_Un << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Ble_Un = new OpCode (
- "ble.un", 0xff, 0x43, 1,
- Code.Ble_Un, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.InlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x43 << 8 | (byte) Code.Ble_Un << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Blt_Un = new OpCode (
- "blt.un", 0xff, 0x44, 1,
- Code.Blt_Un, FlowControl.Cond_Branch,
- OpCodeType.Macro, OperandType.InlineBrTarget,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x44 << 8 | (byte) Code.Blt_Un << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Switch = new OpCode (
- "switch", 0xff, 0x45, 1,
- Code.Switch, FlowControl.Cond_Branch,
- OpCodeType.Primitive, OperandType.InlineSwitch,
- StackBehaviour.Popi, StackBehaviour.Push0);
+ 0xff << 0 | 0x45 << 8 | (byte) Code.Switch << 16 | (byte) FlowControl.Cond_Branch << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineSwitch << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Ldind_I1 = new OpCode (
- "ldind.i1", 0xff, 0x46, 1,
- Code.Ldind_I1, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi, StackBehaviour.Pushi);
+ 0xff << 0 | 0x46 << 8 | (byte) Code.Ldind_I1 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldind_U1 = new OpCode (
- "ldind.u1", 0xff, 0x47, 1,
- Code.Ldind_U1, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi, StackBehaviour.Pushi);
+ 0xff << 0 | 0x47 << 8 | (byte) Code.Ldind_U1 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldind_I2 = new OpCode (
- "ldind.i2", 0xff, 0x48, 1,
- Code.Ldind_I2, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi, StackBehaviour.Pushi);
+ 0xff << 0 | 0x48 << 8 | (byte) Code.Ldind_I2 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldind_U2 = new OpCode (
- "ldind.u2", 0xff, 0x49, 1,
- Code.Ldind_U2, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi, StackBehaviour.Pushi);
+ 0xff << 0 | 0x49 << 8 | (byte) Code.Ldind_U2 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldind_I4 = new OpCode (
- "ldind.i4", 0xff, 0x4a, 1,
- Code.Ldind_I4, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi, StackBehaviour.Pushi);
+ 0xff << 0 | 0x4a << 8 | (byte) Code.Ldind_I4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldind_U4 = new OpCode (
- "ldind.u4", 0xff, 0x4b, 1,
- Code.Ldind_U4, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi, StackBehaviour.Pushi);
+ 0xff << 0 | 0x4b << 8 | (byte) Code.Ldind_U4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldind_I8 = new OpCode (
- "ldind.i8", 0xff, 0x4c, 1,
- Code.Ldind_I8, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi, StackBehaviour.Pushi8);
+ 0xff << 0 | 0x4c << 8 | (byte) Code.Ldind_I8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi8 << 24);
public static readonly OpCode Ldind_I = new OpCode (
- "ldind.i", 0xff, 0x4d, 1,
- Code.Ldind_I, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi, StackBehaviour.Pushi);
+ 0xff << 0 | 0x4d << 8 | (byte) Code.Ldind_I << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldind_R4 = new OpCode (
- "ldind.r4", 0xff, 0x4e, 1,
- Code.Ldind_R4, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi, StackBehaviour.Pushr4);
+ 0xff << 0 | 0x4e << 8 | (byte) Code.Ldind_R4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushr4 << 24);
public static readonly OpCode Ldind_R8 = new OpCode (
- "ldind.r8", 0xff, 0x4f, 1,
- Code.Ldind_R8, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi, StackBehaviour.Pushr8);
+ 0xff << 0 | 0x4f << 8 | (byte) Code.Ldind_R8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushr8 << 24);
public static readonly OpCode Ldind_Ref = new OpCode (
- "ldind.ref", 0xff, 0x50, 1,
- Code.Ldind_Ref, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi, StackBehaviour.Pushref);
+ 0xff << 0 | 0x50 << 8 | (byte) Code.Ldind_Ref << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushref << 24);
public static readonly OpCode Stind_Ref = new OpCode (
- "stind.ref", 0xff, 0x51, 1,
- Code.Stind_Ref, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi_popi, StackBehaviour.Push0);
+ 0xff << 0 | 0x51 << 8 | (byte) Code.Stind_Ref << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stind_I1 = new OpCode (
- "stind.i1", 0xff, 0x52, 1,
- Code.Stind_I1, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi_popi, StackBehaviour.Push0);
+ 0xff << 0 | 0x52 << 8 | (byte) Code.Stind_I1 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stind_I2 = new OpCode (
- "stind.i2", 0xff, 0x53, 1,
- Code.Stind_I2, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi_popi, StackBehaviour.Push0);
+ 0xff << 0 | 0x53 << 8 | (byte) Code.Stind_I2 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stind_I4 = new OpCode (
- "stind.i4", 0xff, 0x54, 1,
- Code.Stind_I4, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi_popi, StackBehaviour.Push0);
+ 0xff << 0 | 0x54 << 8 | (byte) Code.Stind_I4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stind_I8 = new OpCode (
- "stind.i8", 0xff, 0x55, 1,
- Code.Stind_I8, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi_popi8, StackBehaviour.Push0);
+ 0xff << 0 | 0x55 << 8 | (byte) Code.Stind_I8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi8 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stind_R4 = new OpCode (
- "stind.r4", 0xff, 0x56, 1,
- Code.Stind_R4, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi_popr4, StackBehaviour.Push0);
+ 0xff << 0 | 0x56 << 8 | (byte) Code.Stind_R4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popr4 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stind_R8 = new OpCode (
- "stind.r8", 0xff, 0x57, 1,
- Code.Stind_R8, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi_popr8, StackBehaviour.Push0);
+ 0xff << 0 | 0x57 << 8 | (byte) Code.Stind_R8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popr8 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Add = new OpCode (
- "add", 0xff, 0x58, 1,
- Code.Add, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0x58 << 8 | (byte) Code.Add << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Sub = new OpCode (
- "sub", 0xff, 0x59, 1,
- Code.Sub, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0x59 << 8 | (byte) Code.Sub << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Mul = new OpCode (
- "mul", 0xff, 0x5a, 1,
- Code.Mul, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0x5a << 8 | (byte) Code.Mul << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Div = new OpCode (
- "div", 0xff, 0x5b, 1,
- Code.Div, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0x5b << 8 | (byte) Code.Div << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Div_Un = new OpCode (
- "div.un", 0xff, 0x5c, 1,
- Code.Div_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0x5c << 8 | (byte) Code.Div_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Rem = new OpCode (
- "rem", 0xff, 0x5d, 1,
- Code.Rem, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0x5d << 8 | (byte) Code.Rem << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Rem_Un = new OpCode (
- "rem.un", 0xff, 0x5e, 1,
- Code.Rem_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0x5e << 8 | (byte) Code.Rem_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode And = new OpCode (
- "and", 0xff, 0x5f, 1,
- Code.And, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0x5f << 8 | (byte) Code.And << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Or = new OpCode (
- "or", 0xff, 0x60, 1,
- Code.Or, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0x60 << 8 | (byte) Code.Or << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Xor = new OpCode (
- "xor", 0xff, 0x61, 1,
- Code.Xor, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0x61 << 8 | (byte) Code.Xor << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Shl = new OpCode (
- "shl", 0xff, 0x62, 1,
- Code.Shl, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0x62 << 8 | (byte) Code.Shl << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Shr = new OpCode (
- "shr", 0xff, 0x63, 1,
- Code.Shr, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0x63 << 8 | (byte) Code.Shr << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Shr_Un = new OpCode (
- "shr.un", 0xff, 0x64, 1,
- Code.Shr_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0x64 << 8 | (byte) Code.Shr_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Neg = new OpCode (
- "neg", 0xff, 0x65, 1,
- Code.Neg, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0x65 << 8 | (byte) Code.Neg << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Not = new OpCode (
- "not", 0xff, 0x66, 1,
- Code.Not, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0x66 << 8 | (byte) Code.Not << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Conv_I1 = new OpCode (
- "conv.i1", 0xff, 0x67, 1,
- Code.Conv_I1, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0x67 << 8 | (byte) Code.Conv_I1 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_I2 = new OpCode (
- "conv.i2", 0xff, 0x68, 1,
- Code.Conv_I2, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0x68 << 8 | (byte) Code.Conv_I2 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_I4 = new OpCode (
- "conv.i4", 0xff, 0x69, 1,
- Code.Conv_I4, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0x69 << 8 | (byte) Code.Conv_I4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_I8 = new OpCode (
- "conv.i8", 0xff, 0x6a, 1,
- Code.Conv_I8, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi8);
+ 0xff << 0 | 0x6a << 8 | (byte) Code.Conv_I8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi8 << 24);
public static readonly OpCode Conv_R4 = new OpCode (
- "conv.r4", 0xff, 0x6b, 1,
- Code.Conv_R4, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushr4);
+ 0xff << 0 | 0x6b << 8 | (byte) Code.Conv_R4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushr4 << 24);
public static readonly OpCode Conv_R8 = new OpCode (
- "conv.r8", 0xff, 0x6c, 1,
- Code.Conv_R8, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushr8);
+ 0xff << 0 | 0x6c << 8 | (byte) Code.Conv_R8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushr8 << 24);
public static readonly OpCode Conv_U4 = new OpCode (
- "conv.u4", 0xff, 0x6d, 1,
- Code.Conv_U4, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0x6d << 8 | (byte) Code.Conv_U4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_U8 = new OpCode (
- "conv.u8", 0xff, 0x6e, 1,
- Code.Conv_U8, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi8);
+ 0xff << 0 | 0x6e << 8 | (byte) Code.Conv_U8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi8 << 24);
public static readonly OpCode Callvirt = new OpCode (
- "callvirt", 0xff, 0x6f, 1,
- Code.Callvirt, FlowControl.Call,
- OpCodeType.Objmodel, OperandType.InlineMethod,
- StackBehaviour.Varpop, StackBehaviour.Varpush);
+ 0xff << 0 | 0x6f << 8 | (byte) Code.Callvirt << 16 | (byte) FlowControl.Call << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineMethod << 8 | (byte) StackBehaviour.Varpop << 16 | (byte) StackBehaviour.Varpush << 24);
public static readonly OpCode Cpobj = new OpCode (
- "cpobj", 0xff, 0x70, 1,
- Code.Cpobj, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineType,
- StackBehaviour.Popi_popi, StackBehaviour.Push0);
+ 0xff << 0 | 0x70 << 8 | (byte) Code.Cpobj << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popi_popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Ldobj = new OpCode (
- "ldobj", 0xff, 0x71, 1,
- Code.Ldobj, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineType,
- StackBehaviour.Popi, StackBehaviour.Push1);
+ 0xff << 0 | 0x71 << 8 | (byte) Code.Ldobj << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Ldstr = new OpCode (
- "ldstr", 0xff, 0x72, 1,
- Code.Ldstr, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineString,
- StackBehaviour.Pop0, StackBehaviour.Pushref);
+ 0xff << 0 | 0x72 << 8 | (byte) Code.Ldstr << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineString << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushref << 24);
public static readonly OpCode Newobj = new OpCode (
- "newobj", 0xff, 0x73, 1,
- Code.Newobj, FlowControl.Call,
- OpCodeType.Objmodel, OperandType.InlineMethod,
- StackBehaviour.Varpop, StackBehaviour.Pushref);
+ 0xff << 0 | 0x73 << 8 | (byte) Code.Newobj << 16 | (byte) FlowControl.Call << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineMethod << 8 | (byte) StackBehaviour.Varpop << 16 | (byte) StackBehaviour.Pushref << 24);
public static readonly OpCode Castclass = new OpCode (
- "castclass", 0xff, 0x74, 1,
- Code.Castclass, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineType,
- StackBehaviour.Popref, StackBehaviour.Pushref);
+ 0xff << 0 | 0x74 << 8 | (byte) Code.Castclass << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Pushref << 24);
public static readonly OpCode Isinst = new OpCode (
- "isinst", 0xff, 0x75, 1,
- Code.Isinst, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineType,
- StackBehaviour.Popref, StackBehaviour.Pushi);
+ 0xff << 0 | 0x75 << 8 | (byte) Code.Isinst << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_R_Un = new OpCode (
- "conv.r.un", 0xff, 0x76, 1,
- Code.Conv_R_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushr8);
+ 0xff << 0 | 0x76 << 8 | (byte) Code.Conv_R_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushr8 << 24);
public static readonly OpCode Unbox = new OpCode (
- "unbox", 0xff, 0x79, 1,
- Code.Unbox, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineType,
- StackBehaviour.Popref, StackBehaviour.Pushi);
+ 0xff << 0 | 0x79 << 8 | (byte) Code.Unbox << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Throw = new OpCode (
- "throw", 0xff, 0x7a, 1,
- Code.Throw, FlowControl.Throw,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref, StackBehaviour.Push0);
+ 0xff << 0 | 0x7a << 8 | (byte) Code.Throw << 16 | (byte) FlowControl.Throw << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Ldfld = new OpCode (
- "ldfld", 0xff, 0x7b, 1,
- Code.Ldfld, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineField,
- StackBehaviour.Popref, StackBehaviour.Push1);
+ 0xff << 0 | 0x7b << 8 | (byte) Code.Ldfld << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineField << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Ldflda = new OpCode (
- "ldflda", 0xff, 0x7c, 1,
- Code.Ldflda, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineField,
- StackBehaviour.Popref, StackBehaviour.Pushi);
+ 0xff << 0 | 0x7c << 8 | (byte) Code.Ldflda << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineField << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Stfld = new OpCode (
- "stfld", 0xff, 0x7d, 1,
- Code.Stfld, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineField,
- StackBehaviour.Popref_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x7d << 8 | (byte) Code.Stfld << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineField << 8 | (byte) StackBehaviour.Popref_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Ldsfld = new OpCode (
- "ldsfld", 0xff, 0x7e, 1,
- Code.Ldsfld, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineField,
- StackBehaviour.Pop0, StackBehaviour.Push1);
+ 0xff << 0 | 0x7e << 8 | (byte) Code.Ldsfld << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineField << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Ldsflda = new OpCode (
- "ldsflda", 0xff, 0x7f, 1,
- Code.Ldsflda, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineField,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0x7f << 8 | (byte) Code.Ldsflda << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineField << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Stsfld = new OpCode (
- "stsfld", 0xff, 0x80, 1,
- Code.Stsfld, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineField,
- StackBehaviour.Pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x80 << 8 | (byte) Code.Stsfld << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineField << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stobj = new OpCode (
- "stobj", 0xff, 0x81, 1,
- Code.Stobj, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineType,
- StackBehaviour.Popi_pop1, StackBehaviour.Push0);
+ 0xff << 0 | 0x81 << 8 | (byte) Code.Stobj << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popi_pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Conv_Ovf_I1_Un = new OpCode (
- "conv.ovf.i1.un", 0xff, 0x82, 1,
- Code.Conv_Ovf_I1_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0x82 << 8 | (byte) Code.Conv_Ovf_I1_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_Ovf_I2_Un = new OpCode (
- "conv.ovf.i2.un", 0xff, 0x83, 1,
- Code.Conv_Ovf_I2_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0x83 << 8 | (byte) Code.Conv_Ovf_I2_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_Ovf_I4_Un = new OpCode (
- "conv.ovf.i4.un", 0xff, 0x84, 1,
- Code.Conv_Ovf_I4_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0x84 << 8 | (byte) Code.Conv_Ovf_I4_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_Ovf_I8_Un = new OpCode (
- "conv.ovf.i8.un", 0xff, 0x85, 1,
- Code.Conv_Ovf_I8_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi8);
+ 0xff << 0 | 0x85 << 8 | (byte) Code.Conv_Ovf_I8_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi8 << 24);
public static readonly OpCode Conv_Ovf_U1_Un = new OpCode (
- "conv.ovf.u1.un", 0xff, 0x86, 1,
- Code.Conv_Ovf_U1_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0x86 << 8 | (byte) Code.Conv_Ovf_U1_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_Ovf_U2_Un = new OpCode (
- "conv.ovf.u2.un", 0xff, 0x87, 1,
- Code.Conv_Ovf_U2_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0x87 << 8 | (byte) Code.Conv_Ovf_U2_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_Ovf_U4_Un = new OpCode (
- "conv.ovf.u4.un", 0xff, 0x88, 1,
- Code.Conv_Ovf_U4_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0x88 << 8 | (byte) Code.Conv_Ovf_U4_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_Ovf_U8_Un = new OpCode (
- "conv.ovf.u8.un", 0xff, 0x89, 1,
- Code.Conv_Ovf_U8_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi8);
+ 0xff << 0 | 0x89 << 8 | (byte) Code.Conv_Ovf_U8_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi8 << 24);
public static readonly OpCode Conv_Ovf_I_Un = new OpCode (
- "conv.ovf.i.un", 0xff, 0x8a, 1,
- Code.Conv_Ovf_I_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0x8a << 8 | (byte) Code.Conv_Ovf_I_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_Ovf_U_Un = new OpCode (
- "conv.ovf.u.un", 0xff, 0x8b, 1,
- Code.Conv_Ovf_U_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0x8b << 8 | (byte) Code.Conv_Ovf_U_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Box = new OpCode (
- "box", 0xff, 0x8c, 1,
- Code.Box, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineType,
- StackBehaviour.Pop1, StackBehaviour.Pushref);
+ 0xff << 0 | 0x8c << 8 | (byte) Code.Box << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushref << 24);
public static readonly OpCode Newarr = new OpCode (
- "newarr", 0xff, 0x8d, 1,
- Code.Newarr, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineType,
- StackBehaviour.Popi, StackBehaviour.Pushref);
+ 0xff << 0 | 0x8d << 8 | (byte) Code.Newarr << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushref << 24);
public static readonly OpCode Ldlen = new OpCode (
- "ldlen", 0xff, 0x8e, 1,
- Code.Ldlen, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref, StackBehaviour.Pushi);
+ 0xff << 0 | 0x8e << 8 | (byte) Code.Ldlen << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldelema = new OpCode (
- "ldelema", 0xff, 0x8f, 1,
- Code.Ldelema, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineType,
- StackBehaviour.Popref_popi, StackBehaviour.Pushi);
+ 0xff << 0 | 0x8f << 8 | (byte) Code.Ldelema << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldelem_I1 = new OpCode (
- "ldelem.i1", 0xff, 0x90, 1,
- Code.Ldelem_I1, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi, StackBehaviour.Pushi);
+ 0xff << 0 | 0x90 << 8 | (byte) Code.Ldelem_I1 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldelem_U1 = new OpCode (
- "ldelem.u1", 0xff, 0x91, 1,
- Code.Ldelem_U1, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi, StackBehaviour.Pushi);
+ 0xff << 0 | 0x91 << 8 | (byte) Code.Ldelem_U1 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldelem_I2 = new OpCode (
- "ldelem.i2", 0xff, 0x92, 1,
- Code.Ldelem_I2, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi, StackBehaviour.Pushi);
+ 0xff << 0 | 0x92 << 8 | (byte) Code.Ldelem_I2 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldelem_U2 = new OpCode (
- "ldelem.u2", 0xff, 0x93, 1,
- Code.Ldelem_U2, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi, StackBehaviour.Pushi);
+ 0xff << 0 | 0x93 << 8 | (byte) Code.Ldelem_U2 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldelem_I4 = new OpCode (
- "ldelem.i4", 0xff, 0x94, 1,
- Code.Ldelem_I4, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi, StackBehaviour.Pushi);
+ 0xff << 0 | 0x94 << 8 | (byte) Code.Ldelem_I4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldelem_U4 = new OpCode (
- "ldelem.u4", 0xff, 0x95, 1,
- Code.Ldelem_U4, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi, StackBehaviour.Pushi);
+ 0xff << 0 | 0x95 << 8 | (byte) Code.Ldelem_U4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldelem_I8 = new OpCode (
- "ldelem.i8", 0xff, 0x96, 1,
- Code.Ldelem_I8, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi, StackBehaviour.Pushi8);
+ 0xff << 0 | 0x96 << 8 | (byte) Code.Ldelem_I8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi8 << 24);
public static readonly OpCode Ldelem_I = new OpCode (
- "ldelem.i", 0xff, 0x97, 1,
- Code.Ldelem_I, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi, StackBehaviour.Pushi);
+ 0xff << 0 | 0x97 << 8 | (byte) Code.Ldelem_I << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldelem_R4 = new OpCode (
- "ldelem.r4", 0xff, 0x98, 1,
- Code.Ldelem_R4, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi, StackBehaviour.Pushr4);
+ 0xff << 0 | 0x98 << 8 | (byte) Code.Ldelem_R4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushr4 << 24);
public static readonly OpCode Ldelem_R8 = new OpCode (
- "ldelem.r8", 0xff, 0x99, 1,
- Code.Ldelem_R8, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi, StackBehaviour.Pushr8);
+ 0xff << 0 | 0x99 << 8 | (byte) Code.Ldelem_R8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushr8 << 24);
public static readonly OpCode Ldelem_Ref = new OpCode (
- "ldelem.ref", 0xff, 0x9a, 1,
- Code.Ldelem_Ref, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi, StackBehaviour.Pushref);
+ 0xff << 0 | 0x9a << 8 | (byte) Code.Ldelem_Ref << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Pushref << 24);
public static readonly OpCode Stelem_I = new OpCode (
- "stelem.i", 0xff, 0x9b, 1,
- Code.Stelem_I, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi_popi, StackBehaviour.Push0);
+ 0xff << 0 | 0x9b << 8 | (byte) Code.Stelem_I << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stelem_I1 = new OpCode (
- "stelem.i1", 0xff, 0x9c, 1,
- Code.Stelem_I1, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi_popi, StackBehaviour.Push0);
+ 0xff << 0 | 0x9c << 8 | (byte) Code.Stelem_I1 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stelem_I2 = new OpCode (
- "stelem.i2", 0xff, 0x9d, 1,
- Code.Stelem_I2, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi_popi, StackBehaviour.Push0);
+ 0xff << 0 | 0x9d << 8 | (byte) Code.Stelem_I2 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stelem_I4 = new OpCode (
- "stelem.i4", 0xff, 0x9e, 1,
- Code.Stelem_I4, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi_popi, StackBehaviour.Push0);
+ 0xff << 0 | 0x9e << 8 | (byte) Code.Stelem_I4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stelem_I8 = new OpCode (
- "stelem.i8", 0xff, 0x9f, 1,
- Code.Stelem_I8, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi_popi8, StackBehaviour.Push0);
+ 0xff << 0 | 0x9f << 8 | (byte) Code.Stelem_I8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popi8 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stelem_R4 = new OpCode (
- "stelem.r4", 0xff, 0xa0, 1,
- Code.Stelem_R4, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi_popr4, StackBehaviour.Push0);
+ 0xff << 0 | 0xa0 << 8 | (byte) Code.Stelem_R4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popr4 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stelem_R8 = new OpCode (
- "stelem.r8", 0xff, 0xa1, 1,
- Code.Stelem_R8, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi_popr8, StackBehaviour.Push0);
+ 0xff << 0 | 0xa1 << 8 | (byte) Code.Stelem_R8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popr8 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stelem_Ref = new OpCode (
- "stelem.ref", 0xff, 0xa2, 1,
- Code.Stelem_Ref, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Popref_popi_popref, StackBehaviour.Push0);
+ 0xff << 0 | 0xa2 << 8 | (byte) Code.Stelem_Ref << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popref_popi_popref << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Ldelem_Any = new OpCode (
- "ldelem.any", 0xff, 0xa3, 1,
- Code.Ldelem_Any, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineType,
- StackBehaviour.Popref_popi, StackBehaviour.Push1);
+ 0xff << 0 | 0xa3 << 8 | (byte) Code.Ldelem_Any << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popref_popi << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Stelem_Any = new OpCode (
- "stelem.any", 0xff, 0xa4, 1,
- Code.Stelem_Any, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineType,
- StackBehaviour.Popref_popi_popref, StackBehaviour.Push0);
+ 0xff << 0 | 0xa4 << 8 | (byte) Code.Stelem_Any << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popref_popi_popref << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Unbox_Any = new OpCode (
- "unbox.any", 0xff, 0xa5, 1,
- Code.Unbox_Any, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineType,
- StackBehaviour.Popref, StackBehaviour.Push1);
+ 0xff << 0 | 0xa5 << 8 | (byte) Code.Unbox_Any << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Conv_Ovf_I1 = new OpCode (
- "conv.ovf.i1", 0xff, 0xb3, 1,
- Code.Conv_Ovf_I1, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0xb3 << 8 | (byte) Code.Conv_Ovf_I1 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_Ovf_U1 = new OpCode (
- "conv.ovf.u1", 0xff, 0xb4, 1,
- Code.Conv_Ovf_U1, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0xb4 << 8 | (byte) Code.Conv_Ovf_U1 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_Ovf_I2 = new OpCode (
- "conv.ovf.i2", 0xff, 0xb5, 1,
- Code.Conv_Ovf_I2, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0xb5 << 8 | (byte) Code.Conv_Ovf_I2 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_Ovf_U2 = new OpCode (
- "conv.ovf.u2", 0xff, 0xb6, 1,
- Code.Conv_Ovf_U2, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0xb6 << 8 | (byte) Code.Conv_Ovf_U2 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_Ovf_I4 = new OpCode (
- "conv.ovf.i4", 0xff, 0xb7, 1,
- Code.Conv_Ovf_I4, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0xb7 << 8 | (byte) Code.Conv_Ovf_I4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_Ovf_U4 = new OpCode (
- "conv.ovf.u4", 0xff, 0xb8, 1,
- Code.Conv_Ovf_U4, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0xb8 << 8 | (byte) Code.Conv_Ovf_U4 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_Ovf_I8 = new OpCode (
- "conv.ovf.i8", 0xff, 0xb9, 1,
- Code.Conv_Ovf_I8, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi8);
+ 0xff << 0 | 0xb9 << 8 | (byte) Code.Conv_Ovf_I8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi8 << 24);
public static readonly OpCode Conv_Ovf_U8 = new OpCode (
- "conv.ovf.u8", 0xff, 0xba, 1,
- Code.Conv_Ovf_U8, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi8);
+ 0xff << 0 | 0xba << 8 | (byte) Code.Conv_Ovf_U8 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi8 << 24);
public static readonly OpCode Refanyval = new OpCode (
- "refanyval", 0xff, 0xc2, 1,
- Code.Refanyval, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineType,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0xc2 << 8 | (byte) Code.Refanyval << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ckfinite = new OpCode (
- "ckfinite", 0xff, 0xc3, 1,
- Code.Ckfinite, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushr8);
+ 0xff << 0 | 0xc3 << 8 | (byte) Code.Ckfinite << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushr8 << 24);
public static readonly OpCode Mkrefany = new OpCode (
- "mkrefany", 0xff, 0xc6, 1,
- Code.Mkrefany, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineType,
- StackBehaviour.Popi, StackBehaviour.Push1);
+ 0xff << 0 | 0xc6 << 8 | (byte) Code.Mkrefany << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Ldtoken = new OpCode (
- "ldtoken", 0xff, 0xd0, 1,
- Code.Ldtoken, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineTok,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xff << 0 | 0xd0 << 8 | (byte) Code.Ldtoken << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineTok << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_U2 = new OpCode (
- "conv.u2", 0xff, 0xd1, 1,
- Code.Conv_U2, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0xd1 << 8 | (byte) Code.Conv_U2 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_U1 = new OpCode (
- "conv.u1", 0xff, 0xd2, 1,
- Code.Conv_U1, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0xd2 << 8 | (byte) Code.Conv_U1 << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_I = new OpCode (
- "conv.i", 0xff, 0xd3, 1,
- Code.Conv_I, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0xd3 << 8 | (byte) Code.Conv_I << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_Ovf_I = new OpCode (
- "conv.ovf.i", 0xff, 0xd4, 1,
- Code.Conv_Ovf_I, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0xd4 << 8 | (byte) Code.Conv_Ovf_I << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Conv_Ovf_U = new OpCode (
- "conv.ovf.u", 0xff, 0xd5, 1,
- Code.Conv_Ovf_U, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0xd5 << 8 | (byte) Code.Conv_Ovf_U << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Add_Ovf = new OpCode (
- "add.ovf", 0xff, 0xd6, 1,
- Code.Add_Ovf, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0xd6 << 8 | (byte) Code.Add_Ovf << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Add_Ovf_Un = new OpCode (
- "add.ovf.un", 0xff, 0xd7, 1,
- Code.Add_Ovf_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0xd7 << 8 | (byte) Code.Add_Ovf_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Mul_Ovf = new OpCode (
- "mul.ovf", 0xff, 0xd8, 1,
- Code.Mul_Ovf, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0xd8 << 8 | (byte) Code.Mul_Ovf << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Mul_Ovf_Un = new OpCode (
- "mul.ovf.un", 0xff, 0xd9, 1,
- Code.Mul_Ovf_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0xd9 << 8 | (byte) Code.Mul_Ovf_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Sub_Ovf = new OpCode (
- "sub.ovf", 0xff, 0xda, 1,
- Code.Sub_Ovf, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0xda << 8 | (byte) Code.Sub_Ovf << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Sub_Ovf_Un = new OpCode (
- "sub.ovf.un", 0xff, 0xdb, 1,
- Code.Sub_Ovf_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Push1);
+ 0xff << 0 | 0xdb << 8 | (byte) Code.Sub_Ovf_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Endfinally = new OpCode (
- "endfinally", 0xff, 0xdc, 1,
- Code.Endfinally, FlowControl.Return,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Push0);
+ 0xff << 0 | 0xdc << 8 | (byte) Code.Endfinally << 16 | (byte) FlowControl.Return << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Leave = new OpCode (
- "leave", 0xff, 0xdd, 1,
- Code.Leave, FlowControl.Branch,
- OpCodeType.Primitive, OperandType.InlineBrTarget,
- StackBehaviour.PopAll, StackBehaviour.Push0);
+ 0xff << 0 | 0xdd << 8 | (byte) Code.Leave << 16 | (byte) FlowControl.Branch << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineBrTarget << 8 | (byte) StackBehaviour.PopAll << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Leave_S = new OpCode (
- "leave.s", 0xff, 0xde, 1,
- Code.Leave_S, FlowControl.Branch,
- OpCodeType.Macro, OperandType.ShortInlineBrTarget,
- StackBehaviour.PopAll, StackBehaviour.Push0);
+ 0xff << 0 | 0xde << 8 | (byte) Code.Leave_S << 16 | (byte) FlowControl.Branch << 24,
+ (byte) OpCodeType.Macro << 0 | (byte) OperandType.ShortInlineBrTarget << 8 | (byte) StackBehaviour.PopAll << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Stind_I = new OpCode (
- "stind.i", 0xff, 0xdf, 1,
- Code.Stind_I, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi_popi, StackBehaviour.Push0);
+ 0xff << 0 | 0xdf << 8 | (byte) Code.Stind_I << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Conv_U = new OpCode (
- "conv.u", 0xff, 0xe0, 1,
- Code.Conv_U, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xff << 0 | 0xe0 << 8 | (byte) Code.Conv_U << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Arglist = new OpCode (
- "arglist", 0xfe, 0x00, 2,
- Code.Arglist, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xfe << 0 | 0x00 << 8 | (byte) Code.Arglist << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ceq = new OpCode (
- "ceq", 0xfe, 0x01, 2,
- Code.Ceq, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Pushi);
+ 0xfe << 0 | 0x01 << 8 | (byte) Code.Ceq << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Cgt = new OpCode (
- "cgt", 0xfe, 0x02, 2,
- Code.Cgt, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Pushi);
+ 0xfe << 0 | 0x02 << 8 | (byte) Code.Cgt << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Cgt_Un = new OpCode (
- "cgt.un", 0xfe, 0x03, 2,
- Code.Cgt_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Pushi);
+ 0xfe << 0 | 0x03 << 8 | (byte) Code.Cgt_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Clt = new OpCode (
- "clt", 0xfe, 0x04, 2,
- Code.Clt, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Pushi);
+ 0xfe << 0 | 0x04 << 8 | (byte) Code.Clt << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Clt_Un = new OpCode (
- "clt.un", 0xfe, 0x05, 2,
- Code.Clt_Un, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1_pop1, StackBehaviour.Pushi);
+ 0xfe << 0 | 0x05 << 8 | (byte) Code.Clt_Un << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1_pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldftn = new OpCode (
- "ldftn", 0xfe, 0x06, 2,
- Code.Ldftn, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineMethod,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xfe << 0 | 0x06 << 8 | (byte) Code.Ldftn << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineMethod << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldvirtftn = new OpCode (
- "ldvirtftn", 0xfe, 0x07, 2,
- Code.Ldvirtftn, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineMethod,
- StackBehaviour.Popref, StackBehaviour.Pushi);
+ 0xfe << 0 | 0x07 << 8 | (byte) Code.Ldvirtftn << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineMethod << 8 | (byte) StackBehaviour.Popref << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Ldarg = new OpCode (
- "ldarg", 0xfe, 0x09, 2,
- Code.Ldarg, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineParam,
- StackBehaviour.Pop0, StackBehaviour.Push1);
+ 0xfe << 0 | 0x09 << 8 | (byte) Code.Ldarg << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineArg << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Ldarga = new OpCode (
- "ldarga", 0xfe, 0x0a, 2,
- Code.Ldarga, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineParam,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xfe << 0 | 0x0a << 8 | (byte) Code.Ldarga << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineArg << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Starg = new OpCode (
- "starg", 0xfe, 0x0b, 2,
- Code.Starg, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineParam,
- StackBehaviour.Pop1, StackBehaviour.Push0);
+ 0xfe << 0 | 0x0b << 8 | (byte) Code.Starg << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineArg << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Ldloc = new OpCode (
- "ldloc", 0xfe, 0x0c, 2,
- Code.Ldloc, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineVar,
- StackBehaviour.Pop0, StackBehaviour.Push1);
+ 0xfe << 0 | 0x0c << 8 | (byte) Code.Ldloc << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineVar << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push1 << 24);
public static readonly OpCode Ldloca = new OpCode (
- "ldloca", 0xfe, 0x0d, 2,
- Code.Ldloca, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineVar,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xfe << 0 | 0x0d << 8 | (byte) Code.Ldloca << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineVar << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Stloc = new OpCode (
- "stloc", 0xfe, 0x0e, 2,
- Code.Stloc, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineVar,
- StackBehaviour.Pop1, StackBehaviour.Push0);
+ 0xfe << 0 | 0x0e << 8 | (byte) Code.Stloc << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineVar << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Localloc = new OpCode (
- "localloc", 0xfe, 0x0f, 2,
- Code.Localloc, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi, StackBehaviour.Pushi);
+ 0xfe << 0 | 0x0f << 8 | (byte) Code.Localloc << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Endfilter = new OpCode (
- "endfilter", 0xfe, 0x11, 2,
- Code.Endfilter, FlowControl.Return,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi, StackBehaviour.Push0);
+ 0xfe << 0 | 0x11 << 8 | (byte) Code.Endfilter << 16 | (byte) FlowControl.Return << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Unaligned = new OpCode (
- "unaligned.", 0xfe, 0x12, 2,
- Code.Unaligned, FlowControl.Meta,
- OpCodeType.Prefix, OperandType.ShortInlineI,
- StackBehaviour.Pop0, StackBehaviour.Push0);
+ 0xfe << 0 | 0x12 << 8 | (byte) Code.Unaligned << 16 | (byte) FlowControl.Meta << 24,
+ (byte) OpCodeType.Prefix << 0 | (byte) OperandType.ShortInlineI << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Volatile = new OpCode (
- "volatile.", 0xfe, 0x13, 2,
- Code.Volatile, FlowControl.Meta,
- OpCodeType.Prefix, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Push0);
+ 0xfe << 0 | 0x13 << 8 | (byte) Code.Volatile << 16 | (byte) FlowControl.Meta << 24,
+ (byte) OpCodeType.Prefix << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Tail = new OpCode (
- "tail.", 0xfe, 0x14, 2,
- Code.Tail, FlowControl.Meta,
- OpCodeType.Prefix, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Push0);
+ 0xfe << 0 | 0x14 << 8 | (byte) Code.Tail << 16 | (byte) FlowControl.Meta << 24,
+ (byte) OpCodeType.Prefix << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Initobj = new OpCode (
- "initobj", 0xfe, 0x15, 2,
- Code.Initobj, FlowControl.Next,
- OpCodeType.Objmodel, OperandType.InlineType,
- StackBehaviour.Popi, StackBehaviour.Push0);
+ 0xfe << 0 | 0x15 << 8 | (byte) Code.Initobj << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Constrained = new OpCode (
- "constrained.", 0xfe, 0x16, 2,
- Code.Constrained, FlowControl.Next,
- OpCodeType.Prefix, OperandType.InlineTok,
- StackBehaviour.Pop0, StackBehaviour.Push0);
+ 0xfe << 0 | 0x16 << 8 | (byte) Code.Constrained << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Prefix << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Cpblk = new OpCode (
- "cpblk", 0xfe, 0x17, 2,
- Code.Cpblk, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi_popi_popi, StackBehaviour.Push0);
+ 0xfe << 0 | 0x17 << 8 | (byte) Code.Cpblk << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi_popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Initblk = new OpCode (
- "initblk", 0xfe, 0x18, 2,
- Code.Initblk, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Popi_popi_popi, StackBehaviour.Push0);
+ 0xfe << 0 | 0x18 << 8 | (byte) Code.Initblk << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Popi_popi_popi << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode No = new OpCode (
- "no.", 0xfe, 0x19, 2,
- Code.No, FlowControl.Next,
- OpCodeType.Prefix, OperandType.ShortInlineI,
- StackBehaviour.Pop0, StackBehaviour.Push0);
+ 0xfe << 0 | 0x19 << 8 | (byte) Code.No << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Prefix << 0 | (byte) OperandType.ShortInlineI << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Rethrow = new OpCode (
- "rethrow", 0xfe, 0x1a, 2,
- Code.Rethrow, FlowControl.Throw,
- OpCodeType.Objmodel, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Push0);
+ 0xfe << 0 | 0x1a << 8 | (byte) Code.Rethrow << 16 | (byte) FlowControl.Throw << 24,
+ (byte) OpCodeType.Objmodel << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24);
public static readonly OpCode Sizeof = new OpCode (
- "sizeof", 0xfe, 0x1c, 2,
- Code.Sizeof, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineType,
- StackBehaviour.Pop0, StackBehaviour.Pushi);
+ 0xfe << 0 | 0x1c << 8 | (byte) Code.Sizeof << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineType << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Refanytype = new OpCode (
- "refanytype", 0xfe, 0x1d, 2,
- Code.Refanytype, FlowControl.Next,
- OpCodeType.Primitive, OperandType.InlineNone,
- StackBehaviour.Pop1, StackBehaviour.Pushi);
+ 0xfe << 0 | 0x1d << 8 | (byte) Code.Refanytype << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Primitive << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop1 << 16 | (byte) StackBehaviour.Pushi << 24);
public static readonly OpCode Readonly = new OpCode (
- "readonly.", 0xfe, 0x1e, 2,
- Code.Readonly, FlowControl.Next,
- OpCodeType.Prefix, OperandType.InlineNone,
- StackBehaviour.Pop0, StackBehaviour.Push0);
-
- OpCodes()
- {
- }
-
- public static OpCode GetOpCode (Code code)
- {
- switch (code) {
- case Code.Nop : return OpCodes.Nop;
- case Code.Break : return OpCodes.Break;
- case Code.Ldarg_0 : return OpCodes.Ldarg_0;
- case Code.Ldarg_1 : return OpCodes.Ldarg_1;
- case Code.Ldarg_2 : return OpCodes.Ldarg_2;
- case Code.Ldarg_3 : return OpCodes.Ldarg_3;
- case Code.Ldloc_0 : return OpCodes.Ldloc_0;
- case Code.Ldloc_1 : return OpCodes.Ldloc_1;
- case Code.Ldloc_2 : return OpCodes.Ldloc_2;
- case Code.Ldloc_3 : return OpCodes.Ldloc_3;
- case Code.Stloc_0 : return OpCodes.Stloc_0;
- case Code.Stloc_1 : return OpCodes.Stloc_1;
- case Code.Stloc_2 : return OpCodes.Stloc_2;
- case Code.Stloc_3 : return OpCodes.Stloc_3;
- case Code.Ldarg_S : return OpCodes.Ldarg_S;
- case Code.Ldarga_S : return OpCodes.Ldarga_S;
- case Code.Starg_S : return OpCodes.Starg_S;
- case Code.Ldloc_S : return OpCodes.Ldloc_S;
- case Code.Ldloca_S : return OpCodes.Ldloca_S;
- case Code.Stloc_S : return OpCodes.Stloc_S;
- case Code.Ldnull : return OpCodes.Ldnull;
- case Code.Ldc_I4_M1 : return OpCodes.Ldc_I4_M1;
- case Code.Ldc_I4_0 : return OpCodes.Ldc_I4_0;
- case Code.Ldc_I4_1 : return OpCodes.Ldc_I4_1;
- case Code.Ldc_I4_2 : return OpCodes.Ldc_I4_2;
- case Code.Ldc_I4_3 : return OpCodes.Ldc_I4_3;
- case Code.Ldc_I4_4 : return OpCodes.Ldc_I4_4;
- case Code.Ldc_I4_5 : return OpCodes.Ldc_I4_5;
- case Code.Ldc_I4_6 : return OpCodes.Ldc_I4_6;
- case Code.Ldc_I4_7 : return OpCodes.Ldc_I4_7;
- case Code.Ldc_I4_8 : return OpCodes.Ldc_I4_8;
- case Code.Ldc_I4_S : return OpCodes.Ldc_I4_S;
- case Code.Ldc_I4 : return OpCodes.Ldc_I4;
- case Code.Ldc_I8 : return OpCodes.Ldc_I8;
- case Code.Ldc_R4 : return OpCodes.Ldc_R4;
- case Code.Ldc_R8 : return OpCodes.Ldc_R8;
- case Code.Dup : return OpCodes.Dup;
- case Code.Pop : return OpCodes.Pop;
- case Code.Jmp : return OpCodes.Jmp;
- case Code.Call : return OpCodes.Call;
- case Code.Calli : return OpCodes.Calli;
- case Code.Ret : return OpCodes.Ret;
- case Code.Br_S : return OpCodes.Br_S;
- case Code.Brfalse_S : return OpCodes.Brfalse_S;
- case Code.Brtrue_S : return OpCodes.Brtrue_S;
- case Code.Beq_S : return OpCodes.Beq_S;
- case Code.Bge_S : return OpCodes.Bge_S;
- case Code.Bgt_S : return OpCodes.Bgt_S;
- case Code.Ble_S : return OpCodes.Ble_S;
- case Code.Blt_S : return OpCodes.Blt_S;
- case Code.Bne_Un_S : return OpCodes.Bne_Un_S;
- case Code.Bge_Un_S : return OpCodes.Bge_Un_S;
- case Code.Bgt_Un_S : return OpCodes.Bgt_Un_S;
- case Code.Ble_Un_S : return OpCodes.Ble_Un_S;
- case Code.Blt_Un_S : return OpCodes.Blt_Un_S;
- case Code.Br : return OpCodes.Br;
- case Code.Brfalse : return OpCodes.Brfalse;
- case Code.Brtrue : return OpCodes.Brtrue;
- case Code.Beq : return OpCodes.Beq;
- case Code.Bge : return OpCodes.Bge;
- case Code.Bgt : return OpCodes.Bgt;
- case Code.Ble : return OpCodes.Ble;
- case Code.Blt : return OpCodes.Blt;
- case Code.Bne_Un : return OpCodes.Bne_Un;
- case Code.Bge_Un : return OpCodes.Bge_Un;
- case Code.Bgt_Un : return OpCodes.Bgt_Un;
- case Code.Ble_Un : return OpCodes.Ble_Un;
- case Code.Blt_Un : return OpCodes.Blt_Un;
- case Code.Switch : return OpCodes.Switch;
- case Code.Ldind_I1 : return OpCodes.Ldind_I1;
- case Code.Ldind_U1 : return OpCodes.Ldind_U1;
- case Code.Ldind_I2 : return OpCodes.Ldind_I2;
- case Code.Ldind_U2 : return OpCodes.Ldind_U2;
- case Code.Ldind_I4 : return OpCodes.Ldind_I4;
- case Code.Ldind_U4 : return OpCodes.Ldind_U4;
- case Code.Ldind_I8 : return OpCodes.Ldind_I8;
- case Code.Ldind_I : return OpCodes.Ldind_I;
- case Code.Ldind_R4 : return OpCodes.Ldind_R4;
- case Code.Ldind_R8 : return OpCodes.Ldind_R8;
- case Code.Ldind_Ref : return OpCodes.Ldind_Ref;
- case Code.Stind_Ref : return OpCodes.Stind_Ref;
- case Code.Stind_I1 : return OpCodes.Stind_I1;
- case Code.Stind_I2 : return OpCodes.Stind_I2;
- case Code.Stind_I4 : return OpCodes.Stind_I4;
- case Code.Stind_I8 : return OpCodes.Stind_I8;
- case Code.Stind_R4 : return OpCodes.Stind_R4;
- case Code.Stind_R8 : return OpCodes.Stind_R8;
- case Code.Add : return OpCodes.Add;
- case Code.Sub : return OpCodes.Sub;
- case Code.Mul : return OpCodes.Mul;
- case Code.Div : return OpCodes.Div;
- case Code.Div_Un : return OpCodes.Div_Un;
- case Code.Rem : return OpCodes.Rem;
- case Code.Rem_Un : return OpCodes.Rem_Un;
- case Code.And : return OpCodes.And;
- case Code.Or : return OpCodes.Or;
- case Code.Xor : return OpCodes.Xor;
- case Code.Shl : return OpCodes.Shl;
- case Code.Shr : return OpCodes.Shr;
- case Code.Shr_Un : return OpCodes.Shr_Un;
- case Code.Neg : return OpCodes.Neg;
- case Code.Not : return OpCodes.Not;
- case Code.Conv_I1 : return OpCodes.Conv_I1;
- case Code.Conv_I2 : return OpCodes.Conv_I2;
- case Code.Conv_I4 : return OpCodes.Conv_I4;
- case Code.Conv_I8 : return OpCodes.Conv_I8;
- case Code.Conv_R4 : return OpCodes.Conv_R4;
- case Code.Conv_R8 : return OpCodes.Conv_R8;
- case Code.Conv_U4 : return OpCodes.Conv_U4;
- case Code.Conv_U8 : return OpCodes.Conv_U8;
- case Code.Callvirt : return OpCodes.Callvirt;
- case Code.Cpobj : return OpCodes.Cpobj;
- case Code.Ldobj : return OpCodes.Ldobj;
- case Code.Ldstr : return OpCodes.Ldstr;
- case Code.Newobj : return OpCodes.Newobj;
- case Code.Castclass : return OpCodes.Castclass;
- case Code.Isinst : return OpCodes.Isinst;
- case Code.Conv_R_Un : return OpCodes.Conv_R_Un;
- case Code.Unbox : return OpCodes.Unbox;
- case Code.Throw : return OpCodes.Throw;
- case Code.Ldfld : return OpCodes.Ldfld;
- case Code.Ldflda : return OpCodes.Ldflda;
- case Code.Stfld : return OpCodes.Stfld;
- case Code.Ldsfld : return OpCodes.Ldsfld;
- case Code.Ldsflda : return OpCodes.Ldsflda;
- case Code.Stsfld : return OpCodes.Stsfld;
- case Code.Stobj : return OpCodes.Stobj;
- case Code.Conv_Ovf_I1_Un : return OpCodes.Conv_Ovf_I1_Un;
- case Code.Conv_Ovf_I2_Un : return OpCodes.Conv_Ovf_I2_Un;
- case Code.Conv_Ovf_I4_Un : return OpCodes.Conv_Ovf_I4_Un;
- case Code.Conv_Ovf_I8_Un : return OpCodes.Conv_Ovf_I8_Un;
- case Code.Conv_Ovf_U1_Un : return OpCodes.Conv_Ovf_U1_Un;
- case Code.Conv_Ovf_U2_Un : return OpCodes.Conv_Ovf_U2_Un;
- case Code.Conv_Ovf_U4_Un : return OpCodes.Conv_Ovf_U4_Un;
- case Code.Conv_Ovf_U8_Un : return OpCodes.Conv_Ovf_U8_Un;
- case Code.Conv_Ovf_I_Un : return OpCodes.Conv_Ovf_I_Un;
- case Code.Conv_Ovf_U_Un : return OpCodes.Conv_Ovf_U_Un;
- case Code.Box : return OpCodes.Box;
- case Code.Newarr : return OpCodes.Newarr;
- case Code.Ldlen : return OpCodes.Ldlen;
- case Code.Ldelema : return OpCodes.Ldelema;
- case Code.Ldelem_I1 : return OpCodes.Ldelem_I1;
- case Code.Ldelem_U1 : return OpCodes.Ldelem_U1;
- case Code.Ldelem_I2 : return OpCodes.Ldelem_I2;
- case Code.Ldelem_U2 : return OpCodes.Ldelem_U2;
- case Code.Ldelem_I4 : return OpCodes.Ldelem_I4;
- case Code.Ldelem_U4 : return OpCodes.Ldelem_U4;
- case Code.Ldelem_I8 : return OpCodes.Ldelem_I8;
- case Code.Ldelem_I : return OpCodes.Ldelem_I;
- case Code.Ldelem_R4 : return OpCodes.Ldelem_R4;
- case Code.Ldelem_R8 : return OpCodes.Ldelem_R8;
- case Code.Ldelem_Ref : return OpCodes.Ldelem_Ref;
- case Code.Stelem_I : return OpCodes.Stelem_I;
- case Code.Stelem_I1 : return OpCodes.Stelem_I1;
- case Code.Stelem_I2 : return OpCodes.Stelem_I2;
- case Code.Stelem_I4 : return OpCodes.Stelem_I4;
- case Code.Stelem_I8 : return OpCodes.Stelem_I8;
- case Code.Stelem_R4 : return OpCodes.Stelem_R4;
- case Code.Stelem_R8 : return OpCodes.Stelem_R8;
- case Code.Stelem_Ref : return OpCodes.Stelem_Ref;
- case Code.Ldelem_Any : return OpCodes.Ldelem_Any;
- case Code.Stelem_Any : return OpCodes.Stelem_Any;
- case Code.Unbox_Any : return OpCodes.Unbox_Any;
- case Code.Conv_Ovf_I1 : return OpCodes.Conv_Ovf_I1;
- case Code.Conv_Ovf_U1 : return OpCodes.Conv_Ovf_U1;
- case Code.Conv_Ovf_I2 : return OpCodes.Conv_Ovf_I2;
- case Code.Conv_Ovf_U2 : return OpCodes.Conv_Ovf_U2;
- case Code.Conv_Ovf_I4 : return OpCodes.Conv_Ovf_I4;
- case Code.Conv_Ovf_U4 : return OpCodes.Conv_Ovf_U4;
- case Code.Conv_Ovf_I8 : return OpCodes.Conv_Ovf_I8;
- case Code.Conv_Ovf_U8 : return OpCodes.Conv_Ovf_U8;
- case Code.Refanyval : return OpCodes.Refanyval;
- case Code.Ckfinite : return OpCodes.Ckfinite;
- case Code.Mkrefany : return OpCodes.Mkrefany;
- case Code.Ldtoken : return OpCodes.Ldtoken;
- case Code.Conv_U2 : return OpCodes.Conv_U2;
- case Code.Conv_U1 : return OpCodes.Conv_U1;
- case Code.Conv_I : return OpCodes.Conv_I;
- case Code.Conv_Ovf_I : return OpCodes.Conv_Ovf_I;
- case Code.Conv_Ovf_U : return OpCodes.Conv_Ovf_U;
- case Code.Add_Ovf : return OpCodes.Add_Ovf;
- case Code.Add_Ovf_Un : return OpCodes.Add_Ovf_Un;
- case Code.Mul_Ovf : return OpCodes.Mul_Ovf;
- case Code.Mul_Ovf_Un : return OpCodes.Mul_Ovf_Un;
- case Code.Sub_Ovf : return OpCodes.Sub_Ovf;
- case Code.Sub_Ovf_Un : return OpCodes.Sub_Ovf_Un;
- case Code.Endfinally : return OpCodes.Endfinally;
- case Code.Leave : return OpCodes.Leave;
- case Code.Leave_S : return OpCodes.Leave_S;
- case Code.Stind_I : return OpCodes.Stind_I;
- case Code.Conv_U : return OpCodes.Conv_U;
- case Code.Arglist : return OpCodes.Arglist;
- case Code.Ceq : return OpCodes.Ceq;
- case Code.Cgt : return OpCodes.Cgt;
- case Code.Cgt_Un : return OpCodes.Cgt_Un;
- case Code.Clt : return OpCodes.Clt;
- case Code.Clt_Un : return OpCodes.Clt_Un;
- case Code.Ldftn : return OpCodes.Ldftn;
- case Code.Ldvirtftn : return OpCodes.Ldvirtftn;
- case Code.Ldarg : return OpCodes.Ldarg;
- case Code.Ldarga : return OpCodes.Ldarga;
- case Code.Starg : return OpCodes.Starg;
- case Code.Ldloc : return OpCodes.Ldloc;
- case Code.Ldloca : return OpCodes.Ldloca;
- case Code.Stloc : return OpCodes.Stloc;
- case Code.Localloc : return OpCodes.Localloc;
- case Code.Endfilter : return OpCodes.Endfilter;
- case Code.Unaligned : return OpCodes.Unaligned;
- case Code.Volatile : return OpCodes.Volatile;
- case Code.Tail : return OpCodes.Tail;
- case Code.Initobj : return OpCodes.Initobj;
- case Code.Constrained : return OpCodes.Constrained;
- case Code.Cpblk : return OpCodes.Cpblk;
- case Code.Initblk : return OpCodes.Initblk;
- case Code.No : return OpCodes.No;
- case Code.Rethrow : return OpCodes.Rethrow;
- case Code.Sizeof : return OpCodes.Sizeof;
- case Code.Refanytype : return OpCodes.Refanytype;
- case Code.Readonly : return OpCodes.Readonly;
- default : return OpCodes.Nop;
- }
- }
+ 0xfe << 0 | 0x1e << 8 | (byte) Code.Readonly << 16 | (byte) FlowControl.Next << 24,
+ (byte) OpCodeType.Prefix << 0 | (byte) OperandType.InlineNone << 8 | (byte) StackBehaviour.Pop0 << 16 | (byte) StackBehaviour.Push0 << 24);
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OperandType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OperandType.cs
deleted file mode 100644
index 938b2b9..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/OperandType.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// OperandType.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- public enum OperandType {
- InlineBrTarget,
- InlineField,
- InlineI,
- InlineI8,
- InlineMethod,
- InlineNone,
- InlinePhi,
- InlineR,
- InlineSig,
- InlineString,
- InlineSwitch,
- InlineTok,
- InlineType,
- InlineVar,
- InlineParam,
- ShortInlineBrTarget,
- ShortInlineI,
- ShortInlineR,
- ShortInlineVar,
- ShortInlineParam
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Scope.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Scope.cs
deleted file mode 100644
index ce4068c..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Scope.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// Scope.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- public class Scope : IScopeProvider, IVariableDefinitionProvider, ICodeVisitable {
-
- Instruction m_start;
- Instruction m_end;
-
- Scope m_parent;
- ScopeCollection m_scopes;
-
- VariableDefinitionCollection m_variables;
-
- public Instruction Start {
- get { return m_start; }
- set { m_start = value; }
- }
-
- public Instruction End {
- get { return m_end; }
- set { m_end = value; }
- }
-
- public Scope Parent {
- get { return m_parent; }
- set { m_parent = value; }
- }
-
- public ScopeCollection Scopes {
- get {
- if (m_scopes == null)
- m_scopes = new ScopeCollection (this);
-
- return m_scopes;
- }
- }
-
- public VariableDefinitionCollection Variables {
- get {
- if (m_variables == null)
- m_variables = new VariableDefinitionCollection (this);
-
- return m_variables;
- }
- }
-
- public void Accept (ICodeVisitor visitor)
- {
- visitor.VisitScope (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ScopeCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ScopeCollection.cs
deleted file mode 100644
index 6872e70..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/ScopeCollection.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// ScopeCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:54 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class ScopeCollection : CollectionBase, ICodeVisitable {
-
- IScopeProvider m_container;
-
- public Scope this [int index] {
- get { return List [index] as Scope; }
- set { List [index] = value; }
- }
-
- public IScopeProvider Container {
- get { return m_container; }
- }
-
- public ScopeCollection (IScopeProvider container)
- {
- m_container = container;
- }
-
- public void Add (Scope value)
- {
- List.Add (value);
- }
-
- public bool Contains (Scope value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (Scope value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, Scope value)
- {
- List.Insert (index, value);
- }
-
- public void Remove (Scope value)
- {
- List.Remove (value);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is Scope))
- throw new ArgumentException ("Must be of type " + typeof (Scope).FullName);
- }
-
- public void Accept (ICodeVisitor visitor)
- {
- visitor.VisitScopeCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SequencePoint.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SequencePoint.cs
index 81dc110..189b5f5 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SequencePoint.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SequencePoint.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2006 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,51 +28,43 @@
namespace Mono.Cecil.Cil {
- public class SequencePoint {
+ public sealed class SequencePoint {
- Document m_document;
+ Document document;
- int m_startLine;
- int m_startColumn;
- int m_endLine;
- int m_endColumn;
+ int start_line;
+ int start_column;
+ int end_line;
+ int end_column;
public int StartLine {
- get { return m_startLine; }
- set { m_startLine = value; }
+ get { return start_line; }
+ set { start_line = value; }
}
public int StartColumn {
- get { return m_startColumn; }
- set { m_startColumn = value; }
+ get { return start_column; }
+ set { start_column = value; }
}
public int EndLine {
- get { return m_endLine; }
- set { m_endLine = value; }
+ get { return end_line; }
+ set { end_line = value; }
}
public int EndColumn {
- get { return m_endColumn; }
- set { m_endColumn = value; }
+ get { return end_column; }
+ set { end_column = value; }
}
public Document Document {
- get { return m_document; }
- set { m_document = value; }
+ get { return document; }
+ set { document = value; }
}
public SequencePoint (Document document)
{
- m_document = document;
- }
-
- public SequencePoint (Document doc, int startLine, int startCol, int endLine, int endCol) : this (doc)
- {
- m_startLine = startLine;
- m_startColumn = startCol;
- m_endLine = endLine;
- m_endColumn = endCol;
+ this.document = document;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/StackBehaviour.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/StackBehaviour.cs
deleted file mode 100644
index edab8aa..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/StackBehaviour.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-//
-// StackBehaviour.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- public enum StackBehaviour {
- Pop0,
- Pop1,
- Pop1_pop1,
- Popi,
- Popi_pop1,
- Popi_popi,
- Popi_popi8,
- Popi_popi_popi,
- Popi_popr4,
- Popi_popr8,
- Popref,
- Popref_pop1,
- Popref_popi,
- Popref_popi_popi,
- Popref_popi_popi8,
- Popref_popi_popr4,
- Popref_popi_popr8,
- Popref_popi_popref,
- PopAll,
- Push0,
- Push1,
- Push1_push1,
- Pushi,
- Pushi8,
- Pushr4,
- Pushr8,
- Pushref,
- Varpop,
- Varpush
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SymbolStoreHelper.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SymbolStoreHelper.cs
deleted file mode 100644
index c68d3c3..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/SymbolStoreHelper.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-//
-// SymbolStoreHelper.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- using System;
- using SR = System.Reflection;
-
- class SymbolStoreHelper {
-
- static readonly string MonoSymbolSupport = "Mono.Cecil.Mdb.MdbFactory, Mono.Cecil.Mdb";
- static readonly string DotNetSymbolSupport = "Mono.Cecil.Pdb.PdbFactory, Mono.Cecil.Pdb";
-
- static ISymbolStoreFactory s_factory;
-
- SymbolStoreHelper ()
- {
- }
-
- public static ISymbolReader GetReader (ModuleDefinition module)
- {
- InitFactory ();
-
- return s_factory.CreateReader (module, module.Image.FileInformation.FullName);
- }
-
- public static ISymbolWriter GetWriter (ModuleDefinition module, string assemblyFileName)
- {
- InitFactory ();
-
- return s_factory.CreateWriter (module, assemblyFileName);
- }
-
- static void InitFactory ()
- {
- if (s_factory != null)
- return;
-
- Type factoryType = Type.GetType (OnMono () ?
- MonoSymbolSupport :
- DotNetSymbolSupport,
- true);
-
- s_factory = (ISymbolStoreFactory) Activator.CreateInstance (factoryType);
- }
-
- static bool OnMono ()
- {
- return typeof (object).Assembly.GetType ("System.MonoType", false) != null;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Symbols.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Symbols.cs
new file mode 100644
index 0000000..ba2e694
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/Symbols.cs
@@ -0,0 +1,272 @@
+//
+// Symbols.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Runtime.InteropServices;
+using SR = System.Reflection;
+
+using Mono.Collections.Generic;
+
+namespace Mono.Cecil.Cil {
+
+ [StructLayout (LayoutKind.Sequential)]
+ public struct ImageDebugDirectory {
+ public int Characteristics;
+ public int TimeDateStamp;
+ public short MajorVersion;
+ public short MinorVersion;
+ public int Type;
+ public int SizeOfData;
+ public int AddressOfRawData;
+ public int PointerToRawData;
+ }
+
+ public sealed class Scope : IVariableDefinitionProvider {
+
+ Instruction start;
+ Instruction end;
+
+ Collection<Scope> scopes;
+ Collection<VariableDefinition> variables;
+
+ public Instruction Start {
+ get { return start; }
+ set { start = value; }
+ }
+
+ public Instruction End {
+ get { return end; }
+ set { end = value; }
+ }
+
+ public bool HasScopes {
+ get { return !scopes.IsNullOrEmpty (); }
+ }
+
+ public Collection<Scope> Scopes {
+ get {
+ if (scopes == null)
+ scopes = new Collection<Scope> ();
+
+ return scopes;
+ }
+ }
+
+ public bool HasVariables {
+ get { return !variables.IsNullOrEmpty (); }
+ }
+
+ public Collection<VariableDefinition> Variables {
+ get {
+ if (variables == null)
+ variables = new Collection<VariableDefinition> ();
+
+ return variables;
+ }
+ }
+ }
+
+ public struct InstructionSymbol {
+
+ public readonly int Offset;
+ public readonly SequencePoint SequencePoint;
+
+ public InstructionSymbol (int offset, SequencePoint sequencePoint)
+ {
+ this.Offset = offset;
+ this.SequencePoint = sequencePoint;
+ }
+ }
+
+ public sealed class MethodSymbols {
+
+ internal int code_size;
+ internal string method_name;
+ internal MetadataToken method_token;
+ internal MetadataToken local_var_token;
+ internal Collection<VariableDefinition> variables;
+ internal Collection<InstructionSymbol> instructions;
+
+ public bool HasVariables {
+ get { return !variables.IsNullOrEmpty (); }
+ }
+
+ public Collection<VariableDefinition> Variables {
+ get {
+ if (variables == null)
+ variables = new Collection<VariableDefinition> ();
+
+ return variables;
+ }
+ }
+
+ public Collection<InstructionSymbol> Instructions {
+ get {
+ if (instructions == null)
+ instructions = new Collection<InstructionSymbol> ();
+
+ return instructions;
+ }
+ }
+
+ public int CodeSize {
+ get { return code_size; }
+ }
+
+ public string MethodName {
+ get { return method_name; }
+ }
+
+ public MetadataToken MethodToken {
+ get { return method_token; }
+ }
+
+ public MetadataToken LocalVarToken {
+ get { return local_var_token; }
+ }
+
+ public MethodSymbols (string methodName)
+ {
+ this.method_name = methodName;
+ }
+ }
+
+ public delegate Instruction InstructionMapper (int offset);
+
+ public interface ISymbolReader : IDisposable {
+
+ bool ProcessDebugHeader (ImageDebugDirectory directory, byte [] header);
+ void Read (MethodBody body, InstructionMapper mapper);
+ void Read (MethodSymbols symbols);
+ }
+
+ public interface ISymbolReaderProvider {
+
+ ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName);
+ ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream);
+ }
+
+ static class SymbolProvider {
+
+ static readonly string symbol_kind = Type.GetType ("Mono.Runtime") != null ? "Mdb" : "Pdb";
+
+ static SR.AssemblyName GetPlatformSymbolAssemblyName ()
+ {
+ var cecil_name = typeof (SymbolProvider).Assembly.GetName ();
+
+ var name = new SR.AssemblyName {
+ Name = "Mono.Cecil." + symbol_kind,
+ Version = cecil_name.Version,
+ };
+
+ name.SetPublicKeyToken (cecil_name.GetPublicKeyToken ());
+
+ return name;
+ }
+
+ static Type GetPlatformType (string fullname)
+ {
+ var type = Type.GetType (fullname);
+ if (type != null)
+ return type;
+
+ var assembly_name = GetPlatformSymbolAssemblyName ();
+
+ type = Type.GetType (fullname + ", " + assembly_name.FullName);
+ if (type != null)
+ return type;
+
+ try {
+ var assembly = SR.Assembly.Load (assembly_name);
+ if (assembly != null)
+ return assembly.GetType (fullname);
+ } catch (FileNotFoundException) {
+#if !CF
+ } catch (FileLoadException) {
+#endif
+ }
+
+ return null;
+ }
+
+ static ISymbolReaderProvider reader_provider;
+
+ public static ISymbolReaderProvider GetPlatformReaderProvider ()
+ {
+ if (reader_provider != null)
+ return reader_provider;
+
+ var type = GetPlatformType (GetProviderTypeName ("ReaderProvider"));
+ if (type == null)
+ return null;
+
+ return reader_provider = (ISymbolReaderProvider) Activator.CreateInstance (type);
+ }
+
+ static string GetProviderTypeName (string name)
+ {
+ return "Mono.Cecil." + symbol_kind + "." + symbol_kind + name;
+ }
+
+#if !READ_ONLY
+
+ static ISymbolWriterProvider writer_provider;
+
+ public static ISymbolWriterProvider GetPlatformWriterProvider ()
+ {
+ if (writer_provider != null)
+ return writer_provider;
+
+ var type = GetPlatformType (GetProviderTypeName ("WriterProvider"));
+ if (type == null)
+ return null;
+
+ return writer_provider = (ISymbolWriterProvider) Activator.CreateInstance (type);
+ }
+
+#endif
+ }
+
+#if !READ_ONLY
+
+ public interface ISymbolWriter : IDisposable {
+
+ bool GetDebugHeader (out ImageDebugDirectory directory, out byte [] header);
+ void Write (MethodBody body);
+ void Write (MethodSymbols symbols);
+ }
+
+ public interface ISymbolWriterProvider {
+
+ ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName);
+ ISymbolWriter GetSymbolWriter (ModuleDefinition module, Stream symbolStream);
+ }
+
+#endif
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinition.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinition.cs
index 6518f5b..690543e 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinition.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinition.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -30,26 +30,23 @@ namespace Mono.Cecil.Cil {
public sealed class VariableDefinition : VariableReference {
- MethodDefinition m_method;
-
- public MethodDefinition Method {
- get { return m_method; }
- set { m_method = value; }
+ public bool IsPinned {
+ get { return variable_type.IsPinned; }
}
- public VariableDefinition (TypeReference variableType) : base (variableType)
+ public VariableDefinition (TypeReference variableType)
+ : base (variableType)
{
}
- public VariableDefinition (string name, int index, MethodDefinition method, TypeReference variableType) :
- base (name, index, variableType)
+ public VariableDefinition (string name, TypeReference variableType)
+ : base (name, variableType)
{
- m_method = method;
}
- public override void Accept (ICodeVisitor visitor)
+ public override VariableDefinition Resolve ()
{
- visitor.VisitVariableDefinition (this);
+ return this;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinitionCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinitionCollection.cs
deleted file mode 100644
index 3bd8446..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableDefinitionCollection.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// VariableDefinitionCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:53 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Cil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class VariableDefinitionCollection : CollectionBase, ICodeVisitable {
-
- IVariableDefinitionProvider m_container;
-
- public VariableDefinition this [int index] {
- get { return List [index] as VariableDefinition; }
- set { List [index] = value; }
- }
-
- public IVariableDefinitionProvider Container {
- get { return m_container; }
- }
-
- public VariableDefinitionCollection (IVariableDefinitionProvider container)
- {
- m_container = container;
- }
-
- public void Add (VariableDefinition value)
- {
- List.Add (value);
- }
-
- public bool Contains (VariableDefinition value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (VariableDefinition value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, VariableDefinition value)
- {
- List.Insert (index, value);
- }
-
- public void Remove (VariableDefinition value)
- {
- List.Remove (value);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is VariableDefinition))
- throw new ArgumentException ("Must be of type " + typeof (VariableDefinition).FullName);
- }
-
- public void Accept (ICodeVisitor visitor)
- {
- visitor.VisitVariableDefinitionCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableReference.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableReference.cs
index 7100730..5453845 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableReference.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableReference.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,46 +28,48 @@
namespace Mono.Cecil.Cil {
- public abstract class VariableReference : ICodeVisitable {
+ public abstract class VariableReference {
- string m_name;
- int m_index;
- TypeReference m_variableType;
+ string name;
+ internal int index = -1;
+ protected TypeReference variable_type;
public string Name {
- get { return m_name; }
- set { m_name = value; }
+ get { return name; }
+ set { name = value; }
}
- public int Index {
- get { return m_index; }
- set { m_index = value; }
+ public TypeReference VariableType {
+ get { return variable_type; }
+ set { variable_type = value; }
}
- public TypeReference VariableType {
- get { return m_variableType; }
- set { m_variableType = value; }
+ public int Index {
+ get { return index; }
}
- public VariableReference (TypeReference variableType)
+ internal VariableReference (TypeReference variable_type)
+ : this (string.Empty, variable_type)
{
- m_variableType = variableType;
}
- public VariableReference (string name, int index, TypeReference variableType) : this (variableType)
+ internal VariableReference (string name, TypeReference variable_type)
{
- m_name = name;
- m_index = index;
+ this.name = name;
+ this.variable_type = variable_type;
}
+ public abstract VariableDefinition Resolve ();
+
public override string ToString ()
{
- if (m_name != null && m_name.Length > 0)
- return m_name;
+ if (!string.IsNullOrEmpty (name))
+ return name;
- return string.Concat ("V_", m_index);
- }
+ if (index >= 0)
+ return "V_" + index;
- public abstract void Accept (ICodeVisitor visitor);
+ return string.Empty;
+ }
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Assembly.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Assembly.cs
deleted file mode 100644
index 72da5c2..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Assembly.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-//
-// AssemblyTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:25 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil;
-
- public sealed class AssemblyTable : IMetadataTable {
-
- public const int RId = 0x20;
-
- RowCollection m_rows;
-
- public AssemblyRow this [int index] {
- get { return m_rows [index] as AssemblyRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal AssemblyTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitAssemblyTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class AssemblyRow : IMetadataRow {
-
- public AssemblyHashAlgorithm HashAlgId;
- public ushort MajorVersion;
- public ushort MinorVersion;
- public ushort BuildNumber;
- public ushort RevisionNumber;
- public AssemblyFlags Flags;
- public uint PublicKey;
- public uint Name;
- public uint Culture;
-
- internal AssemblyRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitAssemblyRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyOS.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyOS.cs
deleted file mode 100644
index b6b193b..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyOS.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-//
-// AssemblyOSTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:25 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class AssemblyOSTable : IMetadataTable {
-
- public const int RId = 0x22;
-
- RowCollection m_rows;
-
- public AssemblyOSRow this [int index] {
- get { return m_rows [index] as AssemblyOSRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal AssemblyOSTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitAssemblyOSTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class AssemblyOSRow : IMetadataRow {
-
- public uint OSPlatformID;
- public uint OSMajorVersion;
- public uint OSMinorVersion;
-
- internal AssemblyOSRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitAssemblyOSRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyProcessor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyProcessor.cs
deleted file mode 100644
index ca7c7a9..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyProcessor.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// AssemblyProcessorTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:25 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class AssemblyProcessorTable : IMetadataTable {
-
- public const int RId = 0x21;
-
- RowCollection m_rows;
-
- public AssemblyProcessorRow this [int index] {
- get { return m_rows [index] as AssemblyProcessorRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal AssemblyProcessorTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitAssemblyProcessorTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class AssemblyProcessorRow : IMetadataRow {
-
- public uint Processor;
-
- internal AssemblyProcessorRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitAssemblyProcessorRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRef.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRef.cs
deleted file mode 100644
index 06b5006..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRef.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-//
-// AssemblyRefTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:25 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil;
-
- public sealed class AssemblyRefTable : IMetadataTable {
-
- public const int RId = 0x23;
-
- RowCollection m_rows;
-
- public AssemblyRefRow this [int index] {
- get { return m_rows [index] as AssemblyRefRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal AssemblyRefTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitAssemblyRefTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class AssemblyRefRow : IMetadataRow {
-
- public ushort MajorVersion;
- public ushort MinorVersion;
- public ushort BuildNumber;
- public ushort RevisionNumber;
- public AssemblyFlags Flags;
- public uint PublicKeyOrToken;
- public uint Name;
- public uint Culture;
- public uint HashValue;
-
- internal AssemblyRefRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitAssemblyRefRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefOS.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefOS.cs
deleted file mode 100644
index db794e9..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefOS.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-//
-// AssemblyRefOSTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:25 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class AssemblyRefOSTable : IMetadataTable {
-
- public const int RId = 0x25;
-
- RowCollection m_rows;
-
- public AssemblyRefOSRow this [int index] {
- get { return m_rows [index] as AssemblyRefOSRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal AssemblyRefOSTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitAssemblyRefOSTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class AssemblyRefOSRow : IMetadataRow {
-
- public uint OSPlatformID;
- public uint OSMajorVersion;
- public uint OSMinorVersion;
- public uint AssemblyRef;
-
- internal AssemblyRefOSRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitAssemblyRefOSRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefProcessor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefProcessor.cs
deleted file mode 100644
index 80cef8b..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/AssemblyRefProcessor.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// AssemblyRefProcessorTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:25 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class AssemblyRefProcessorTable : IMetadataTable {
-
- public const int RId = 0x24;
-
- RowCollection m_rows;
-
- public AssemblyRefProcessorRow this [int index] {
- get { return m_rows [index] as AssemblyRefProcessorRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal AssemblyRefProcessorTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitAssemblyRefProcessorTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class AssemblyRefProcessorRow : IMetadataRow {
-
- public uint Processor;
- public uint AssemblyRef;
-
- internal AssemblyRefProcessorRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitAssemblyRefProcessorRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BaseMetadataVisitor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BaseMetadataVisitor.cs
deleted file mode 100644
index fd6ac0f..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BaseMetadataVisitor.cs
+++ /dev/null
@@ -1,448 +0,0 @@
-//
-// BaseMetadataVisitor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Thu Feb 22 14:39:38 CET 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public abstract class BaseMetadataVisitor : IMetadataVisitor {
-
- public virtual void VisitMetadataRoot (MetadataRoot root)
- {
- }
-
- public virtual void VisitMetadataRootHeader (MetadataRoot.MetadataRootHeader header)
- {
- }
-
- public virtual void VisitMetadataStreamCollection (MetadataStreamCollection streams)
- {
- }
-
- public virtual void VisitMetadataStream (MetadataStream stream)
- {
- }
-
- public virtual void VisitMetadataStreamHeader (MetadataStream.MetadataStreamHeader header)
- {
- }
-
- public virtual void VisitGuidHeap (GuidHeap heap)
- {
- }
-
- public virtual void VisitStringsHeap (StringsHeap heap)
- {
- }
-
- public virtual void VisitTablesHeap (TablesHeap heap)
- {
- }
-
- public virtual void VisitBlobHeap (BlobHeap heap)
- {
- }
-
- public virtual void VisitUserStringsHeap (UserStringsHeap heap)
- {
- }
-
- public virtual void TerminateMetadataRoot (MetadataRoot root)
- {
- }
- }
-
- public abstract class BaseMetadataTableVisitor : IMetadataTableVisitor {
-
- public virtual void VisitTableCollection (TableCollection coll)
- {
- }
-
- public virtual void VisitAssemblyTable (AssemblyTable table)
- {
- }
-
- public virtual void VisitAssemblyOSTable (AssemblyOSTable table)
- {
- }
-
- public virtual void VisitAssemblyProcessorTable (AssemblyProcessorTable table)
- {
- }
-
- public virtual void VisitAssemblyRefTable (AssemblyRefTable table)
- {
- }
-
- public virtual void VisitAssemblyRefOSTable (AssemblyRefOSTable table)
- {
- }
-
- public virtual void VisitAssemblyRefProcessorTable (AssemblyRefProcessorTable table)
- {
- }
-
- public virtual void VisitClassLayoutTable (ClassLayoutTable table)
- {
- }
-
- public virtual void VisitConstantTable (ConstantTable table)
- {
- }
-
- public virtual void VisitCustomAttributeTable (CustomAttributeTable table)
- {
- }
-
- public virtual void VisitDeclSecurityTable (DeclSecurityTable table)
- {
- }
-
- public virtual void VisitEventTable (EventTable table)
- {
- }
-
- public virtual void VisitEventMapTable (EventMapTable table)
- {
- }
-
- public virtual void VisitEventPtrTable (EventPtrTable table)
- {
- }
-
- public virtual void VisitExportedTypeTable (ExportedTypeTable table)
- {
- }
-
- public virtual void VisitFieldTable (FieldTable table)
- {
- }
-
- public virtual void VisitFieldLayoutTable (FieldLayoutTable table)
- {
- }
-
- public virtual void VisitFieldMarshalTable (FieldMarshalTable table)
- {
- }
-
- public virtual void VisitFieldPtrTable (FieldPtrTable table)
- {
- }
-
- public virtual void VisitFieldRVATable (FieldRVATable table)
- {
- }
-
- public virtual void VisitFileTable (FileTable table)
- {
- }
-
- public virtual void VisitGenericParamTable (GenericParamTable table)
- {
- }
-
- public virtual void VisitGenericParamConstraintTable (GenericParamConstraintTable table)
- {
- }
-
- public virtual void VisitImplMapTable (ImplMapTable table)
- {
- }
-
- public virtual void VisitInterfaceImplTable (InterfaceImplTable table)
- {
- }
-
- public virtual void VisitManifestResourceTable (ManifestResourceTable table)
- {
- }
-
- public virtual void VisitMemberRefTable (MemberRefTable table)
- {
- }
-
- public virtual void VisitMethodTable (MethodTable table)
- {
- }
-
- public virtual void VisitMethodImplTable (MethodImplTable table)
- {
- }
-
- public virtual void VisitMethodPtrTable (MethodPtrTable table)
- {
- }
-
- public virtual void VisitMethodSemanticsTable (MethodSemanticsTable table)
- {
- }
-
- public virtual void VisitMethodSpecTable (MethodSpecTable table)
- {
- }
-
- public virtual void VisitModuleTable (ModuleTable table)
- {
- }
-
- public virtual void VisitModuleRefTable (ModuleRefTable table)
- {
- }
-
- public virtual void VisitNestedClassTable (NestedClassTable table)
- {
- }
-
- public virtual void VisitParamTable (ParamTable table)
- {
- }
-
- public virtual void VisitParamPtrTable (ParamPtrTable table)
- {
- }
-
- public virtual void VisitPropertyTable (PropertyTable table)
- {
- }
-
- public virtual void VisitPropertyMapTable (PropertyMapTable table)
- {
- }
-
- public virtual void VisitPropertyPtrTable (PropertyPtrTable table)
- {
- }
-
- public virtual void VisitStandAloneSigTable (StandAloneSigTable table)
- {
- }
-
- public virtual void VisitTypeDefTable (TypeDefTable table)
- {
- }
-
- public virtual void VisitTypeRefTable (TypeRefTable table)
- {
- }
-
- public virtual void VisitTypeSpecTable (TypeSpecTable table)
- {
- }
-
- public virtual void TerminateTableCollection (TableCollection coll)
- {
- }
-
- public abstract IMetadataRowVisitor GetRowVisitor();
- }
-
- public abstract class BaseMetadataRowVisitor : IMetadataRowVisitor {
-
- public virtual void VisitRowCollection (RowCollection coll)
- {
- }
-
- public virtual void VisitAssemblyRow (AssemblyRow row)
- {
- }
-
- public virtual void VisitAssemblyOSRow (AssemblyOSRow row)
- {
- }
-
- public virtual void VisitAssemblyProcessorRow (AssemblyProcessorRow row)
- {
- }
-
- public virtual void VisitAssemblyRefRow (AssemblyRefRow row)
- {
- }
-
- public virtual void VisitAssemblyRefOSRow (AssemblyRefOSRow row)
- {
- }
-
- public virtual void VisitAssemblyRefProcessorRow (AssemblyRefProcessorRow row)
- {
- }
-
- public virtual void VisitClassLayoutRow (ClassLayoutRow row)
- {
- }
-
- public virtual void VisitConstantRow (ConstantRow row)
- {
- }
-
- public virtual void VisitCustomAttributeRow (CustomAttributeRow row)
- {
- }
-
- public virtual void VisitDeclSecurityRow (DeclSecurityRow row)
- {
- }
-
- public virtual void VisitEventRow (EventRow row)
- {
- }
-
- public virtual void VisitEventMapRow (EventMapRow row)
- {
- }
-
- public virtual void VisitEventPtrRow (EventPtrRow row)
- {
- }
-
- public virtual void VisitExportedTypeRow (ExportedTypeRow row)
- {
- }
-
- public virtual void VisitFieldRow (FieldRow row)
- {
- }
-
- public virtual void VisitFieldLayoutRow (FieldLayoutRow row)
- {
- }
-
- public virtual void VisitFieldMarshalRow (FieldMarshalRow row)
- {
- }
-
- public virtual void VisitFieldPtrRow (FieldPtrRow row)
- {
- }
-
- public virtual void VisitFieldRVARow (FieldRVARow row)
- {
- }
-
- public virtual void VisitFileRow (FileRow row)
- {
- }
-
- public virtual void VisitGenericParamRow (GenericParamRow row)
- {
- }
-
- public virtual void VisitGenericParamConstraintRow (GenericParamConstraintRow row)
- {
- }
-
- public virtual void VisitImplMapRow (ImplMapRow row)
- {
- }
-
- public virtual void VisitInterfaceImplRow (InterfaceImplRow row)
- {
- }
-
- public virtual void VisitManifestResourceRow (ManifestResourceRow row)
- {
- }
-
- public virtual void VisitMemberRefRow (MemberRefRow row)
- {
- }
-
- public virtual void VisitMethodRow (MethodRow row)
- {
- }
-
- public virtual void VisitMethodImplRow (MethodImplRow row)
- {
- }
-
- public virtual void VisitMethodPtrRow (MethodPtrRow row)
- {
- }
-
- public virtual void VisitMethodSemanticsRow (MethodSemanticsRow row)
- {
- }
-
- public virtual void VisitMethodSpecRow (MethodSpecRow row)
- {
- }
-
- public virtual void VisitModuleRow (ModuleRow row)
- {
- }
-
- public virtual void VisitModuleRefRow (ModuleRefRow row)
- {
- }
-
- public virtual void VisitNestedClassRow (NestedClassRow row)
- {
- }
-
- public virtual void VisitParamRow (ParamRow row)
- {
- }
-
- public virtual void VisitParamPtrRow (ParamPtrRow row)
- {
- }
-
- public virtual void VisitPropertyRow (PropertyRow row)
- {
- }
-
- public virtual void VisitPropertyMapRow (PropertyMapRow row)
- {
- }
-
- public virtual void VisitPropertyPtrRow (PropertyPtrRow row)
- {
- }
-
- public virtual void VisitStandAloneSigRow (StandAloneSigRow row)
- {
- }
-
- public virtual void VisitTypeDefRow (TypeDefRow row)
- {
- }
-
- public virtual void VisitTypeRefRow (TypeRefRow row)
- {
- }
-
- public virtual void VisitTypeSpecRow (TypeSpecRow row)
- {
- }
-
- public virtual void TerminateRowCollection (RowCollection coll)
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BlobHeap.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BlobHeap.cs
index 57dd2e1..81c775e 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BlobHeap.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/BlobHeap.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,29 +26,34 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil.Metadata {
+using System;
+
+using Mono.Cecil.PE;
- using System.IO;
+namespace Mono.Cecil.Metadata {
- public class BlobHeap : MetadataHeap {
+ sealed class BlobHeap : Heap {
- internal BlobHeap (MetadataStream stream) : base (stream, MetadataStream.Blob)
+ public BlobHeap (Section section, uint start, uint size)
+ : base (section, start, size)
{
}
public byte [] Read (uint index)
{
- return ReadBytesFromStream (index);
- }
+ if (index == 0 || index > Size - 1)
+ return Empty<byte>.Array;
- public BinaryReader GetReader (uint index)
- {
- return new BinaryReader (new MemoryStream (Read (index)));
- }
+ var data = Section.Data;
- public override void Accept (IMetadataVisitor visitor)
- {
- visitor.VisitBlobHeap (this);
+ int position = (int) (index + Offset);
+ int length = (int) data.ReadCompressedUInt32 (ref position);
+
+ var buffer = new byte [length];
+
+ Buffer.BlockCopy (data, position, buffer, 0, length);
+
+ return buffer;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Buffers.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Buffers.cs
new file mode 100644
index 0000000..e8759d7
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Buffers.cs
@@ -0,0 +1,373 @@
+//
+// TableHeapBuffer.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using Mono.Cecil.PE;
+
+using RVA = System.UInt32;
+
+#if !READ_ONLY
+
+namespace Mono.Cecil.Metadata {
+
+ sealed class TableHeapBuffer : HeapBuffer {
+
+ readonly ModuleDefinition module;
+ readonly MetadataBuilder metadata;
+
+ internal MetadataTable [] tables = new MetadataTable [45];
+
+ bool large_string;
+ bool large_blob;
+ readonly int [] coded_index_sizes = new int [13];
+ readonly Func<Table, int> counter;
+
+ public override bool IsEmpty {
+ get { return false; }
+ }
+
+ public TableHeapBuffer (ModuleDefinition module, MetadataBuilder metadata)
+ : base (24)
+ {
+ this.module = module;
+ this.metadata = metadata;
+ this.counter = GetTableLength;
+ }
+
+ int GetTableLength (Table table)
+ {
+ var md_table = tables [(int) table];
+ return md_table != null ? md_table.Length : 0;
+ }
+
+ public TTable GetTable<TTable> (Table table) where TTable : MetadataTable, new ()
+ {
+ var md_table = (TTable) tables [(int) table];
+ if (md_table != null)
+ return md_table;
+
+ md_table = new TTable ();
+ tables [(int) table] = md_table;
+ return md_table;
+ }
+
+ public void WriteBySize (uint value, int size)
+ {
+ if (size == 4)
+ WriteUInt32 (value);
+ else
+ WriteUInt16 ((ushort) value);
+ }
+
+ public void WriteBySize (uint value, bool large)
+ {
+ if (large)
+ WriteUInt32 (value);
+ else
+ WriteUInt16 ((ushort) value);
+ }
+
+ public void WriteString (uint @string)
+ {
+ WriteBySize (@string, large_string);
+ }
+
+ public void WriteBlob (uint blob)
+ {
+ WriteBySize (blob, large_blob);
+ }
+
+ public void WriteRID (uint rid, Table table)
+ {
+ var md_table = tables [(int) table];
+ WriteBySize (rid, md_table == null ? false : md_table.IsLarge);
+ }
+
+ int GetCodedIndexSize (CodedIndex coded_index)
+ {
+ var index = (int) coded_index;
+ var size = coded_index_sizes [index];
+ if (size != 0)
+ return size;
+
+ return coded_index_sizes [index] = coded_index.GetSize (counter);
+ }
+
+ public void WriteCodedRID (uint rid, CodedIndex coded_index)
+ {
+ WriteBySize (rid, GetCodedIndexSize (coded_index));
+ }
+
+ public void WriteTableHeap ()
+ {
+ WriteUInt32 (0); // Reserved
+ WriteByte (GetTableHeapVersion ()); // MajorVersion
+ WriteByte (0); // MinorVersion
+ WriteByte (GetHeapSizes ()); // HeapSizes
+ WriteByte (10); // Reserved2
+ WriteUInt64 (GetValid ()); // Valid
+ WriteUInt64 (0x0016003301fa00); // Sorted
+
+ WriteRowCount ();
+ WriteTables ();
+ }
+
+ void WriteRowCount ()
+ {
+ for (int i = 0; i < tables.Length; i++) {
+ var table = tables [i];
+ if (table == null || table.Length == 0)
+ continue;
+
+ WriteUInt32 ((uint) table.Length);
+ }
+ }
+
+ void WriteTables ()
+ {
+ for (int i = 0; i < tables.Length; i++) {
+ var table = tables [i];
+ if (table == null || table.Length == 0)
+ continue;
+
+ table.Write (this);
+ }
+ }
+
+ ulong GetValid ()
+ {
+ ulong valid = 0;
+
+ for (int i = 0; i < tables.Length; i++) {
+ var table = tables [i];
+ if (table == null || table.Length == 0)
+ continue;
+
+ table.Sort ();
+ valid |= (1UL << i);
+ }
+
+ return valid;
+ }
+
+ byte GetHeapSizes ()
+ {
+ byte heap_sizes = 0;
+
+ if (metadata.string_heap.IsLarge) {
+ large_string = true;
+ heap_sizes |= 0x01;
+ }
+
+ if (metadata.blob_heap.IsLarge) {
+ large_blob = true;
+ heap_sizes |= 0x04;
+ }
+
+ return heap_sizes;
+ }
+
+ byte GetTableHeapVersion ()
+ {
+ switch (module.Runtime) {
+ case TargetRuntime.Net_1_0:
+ case TargetRuntime.Net_1_1:
+ return 1;
+ default:
+ return 2;
+ }
+ }
+
+ public void FixupData (RVA data_rva)
+ {
+ var table = GetTable<FieldRVATable> (Table.FieldRVA);
+ if (table.length == 0)
+ return;
+
+ var field_idx_size = GetTable<FieldTable> (Table.Field).IsLarge ? 4 : 2;
+ var previous = this.position;
+
+ base.position = table.position;
+ for (int i = 0; i < table.length; i++) {
+ var rva = ReadUInt32 ();
+ base.position -= 4;
+ WriteUInt32 (rva + data_rva);
+ base.position += field_idx_size;
+ }
+
+ base.position = previous;
+ }
+ }
+
+ sealed class ResourceBuffer : ByteBuffer {
+
+ public ResourceBuffer ()
+ : base (0)
+ {
+ }
+
+ public uint AddResource (byte [] resource)
+ {
+ var offset = (uint) this.position;
+ WriteInt32 (resource.Length);
+ WriteBytes (resource);
+ return offset;
+ }
+ }
+
+ sealed class DataBuffer : ByteBuffer {
+
+ public DataBuffer ()
+ : base (0)
+ {
+ }
+
+ public RVA AddData (byte [] data)
+ {
+ var rva = (RVA) position;
+ WriteBytes (data);
+ return rva;
+ }
+ }
+
+ abstract class HeapBuffer : ByteBuffer {
+
+ public bool IsLarge {
+ get { return base.length > 65536; }
+ }
+
+ public abstract bool IsEmpty { get; }
+
+ protected HeapBuffer (int length)
+ : base (length)
+ {
+ }
+ }
+
+ class StringHeapBuffer : HeapBuffer {
+
+ readonly Dictionary<string, uint> strings = new Dictionary<string, uint> ();
+
+ public sealed override bool IsEmpty {
+ get { return length <= 1; }
+ }
+
+ public StringHeapBuffer ()
+ : base (1)
+ {
+ WriteByte (0);
+ }
+
+ public uint GetStringIndex (string @string)
+ {
+ uint index;
+ if (strings.TryGetValue (@string, out index))
+ return index;
+
+ index = (uint) base.position;
+ WriteString (@string);
+ strings.Add (@string, index);
+ return index;
+ }
+
+ protected virtual void WriteString (string @string)
+ {
+ WriteBytes (Encoding.UTF8.GetBytes (@string));
+ WriteByte (0);
+ }
+ }
+
+ sealed class BlobHeapBuffer : HeapBuffer {
+
+ readonly Dictionary<ByteBuffer, uint> blobs = new Dictionary<ByteBuffer, uint> (new ByteBufferEqualityComparer ());
+
+ public override bool IsEmpty {
+ get { return length <= 1; }
+ }
+
+ public BlobHeapBuffer ()
+ : base (1)
+ {
+ WriteByte (0);
+ }
+
+ public uint GetBlobIndex (ByteBuffer blob)
+ {
+ uint index;
+ if (blobs.TryGetValue (blob, out index))
+ return index;
+
+ index = (uint) base.position;
+ WriteBlob (blob);
+ blobs.Add (blob, index);
+ return index;
+ }
+
+ void WriteBlob (ByteBuffer blob)
+ {
+ WriteCompressedUInt32 ((uint) blob.length);
+ WriteBytes (blob);
+ }
+ }
+
+ sealed class UserStringHeapBuffer : StringHeapBuffer {
+
+ protected override void WriteString (string @string)
+ {
+ WriteCompressedUInt32 ((uint) @string.Length * 2 + 1);
+
+ byte special = 0;
+
+ for (int i = 0; i < @string.Length; i++) {
+ var @char = @string [i];
+ WriteUInt16 (@char);
+
+ if (special == 1)
+ continue;
+
+ if (@char < 0x20 || @char > 0x7e) {
+ if (@char > 0x7e
+ || (@char >= 0x01 && @char <= 0x08)
+ || (@char >= 0x0e && @char <= 0x1f)
+ || @char == 0x27
+ || @char == 0x2d) {
+
+ special = 1;
+ }
+ }
+ }
+
+ WriteByte (special);
+ }
+ }
+}
+
+#endif
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ClassLayout.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ClassLayout.cs
deleted file mode 100644
index cb83be4..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ClassLayout.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-//
-// ClassLayoutTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:25 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class ClassLayoutTable : IMetadataTable {
-
- public const int RId = 0x0f;
-
- RowCollection m_rows;
-
- public ClassLayoutRow this [int index] {
- get { return m_rows [index] as ClassLayoutRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal ClassLayoutTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitClassLayoutTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class ClassLayoutRow : IMetadataRow {
-
- public ushort PackingSize;
- public uint ClassSize;
- public uint Parent;
-
- internal ClassLayoutRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitClassLayoutRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CodedIndex.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CodedIndex.cs
index 2cf5578..6267726 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CodedIndex.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CodedIndex.cs
@@ -4,10 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Mar 20 16:02:16 +0100 2007
-//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -31,7 +28,7 @@
namespace Mono.Cecil.Metadata {
- public enum CodedIndex {
+ enum CodedIndex {
TypeDefOrRef,
HasConstant,
HasCustomAttribute,
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Constant.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Constant.cs
deleted file mode 100644
index 3ca867d..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Constant.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-//
-// ConstantTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:25 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class ConstantTable : IMetadataTable {
-
- public const int RId = 0x0b;
-
- RowCollection m_rows;
-
- public ConstantRow this [int index] {
- get { return m_rows [index] as ConstantRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal ConstantTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitConstantTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class ConstantRow : IMetadataRow {
-
- public ElementType Type;
- public MetadataToken Parent;
- public uint Value;
-
- internal ConstantRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitConstantRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CultureUtils.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CultureUtils.cs
deleted file mode 100644
index 426f92b..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CultureUtils.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-//
-// CultureUtils.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.Collections;
- using System.Globalization;
-
- class CultureUtils {
-
- static IDictionary m_cultures;
-
- CultureUtils ()
- {
- }
-
- static void LoadCultures ()
- {
- if (m_cultures != null)
- return;
-
-#if CF_1_0 || CF_2_0
- CultureInfo [] cultures = new CultureInfo [0];
-#else
- CultureInfo [] cultures = CultureInfo.GetCultures (CultureTypes.AllCultures);
-#endif
- m_cultures = new Hashtable (cultures.Length + 2);
-
- foreach (CultureInfo ci in cultures)
- if (!m_cultures.Contains (ci.Name))
- m_cultures.Add (ci.Name, ci);
-
- if (!m_cultures.Contains (string.Empty))
- m_cultures.Add (string.Empty, CultureInfo.InvariantCulture);
-
- m_cultures.Add ("neutral", CultureInfo.InvariantCulture);
- }
-
- public static bool IsValid (string culture)
- {
- if (culture == null)
- throw new ArgumentNullException ("culture");
-
- LoadCultures ();
-
- return m_cultures.Contains (culture);
- }
-
- public static CultureInfo GetCultureInfo (string culture)
- {
- if (IsValid (culture))
- return m_cultures [culture] as CultureInfo;
-
- return CultureInfo.InvariantCulture;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CustomAttribute.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CustomAttribute.cs
deleted file mode 100644
index 21a0d0c..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/CustomAttribute.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-//
-// CustomAttributeTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:25 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class CustomAttributeTable : IMetadataTable {
-
- public const int RId = 0x0c;
-
- RowCollection m_rows;
-
- public CustomAttributeRow this [int index] {
- get { return m_rows [index] as CustomAttributeRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal CustomAttributeTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitCustomAttributeTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class CustomAttributeRow : IMetadataRow {
-
- public MetadataToken Parent;
- public MetadataToken Type;
- public uint Value;
-
- internal CustomAttributeRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitCustomAttributeRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/DeclSecurity.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/DeclSecurity.cs
deleted file mode 100644
index 1b2fbdc..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/DeclSecurity.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-//
-// DeclSecurityTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil;
-
- public sealed class DeclSecurityTable : IMetadataTable {
-
- public const int RId = 0x0e;
-
- RowCollection m_rows;
-
- public DeclSecurityRow this [int index] {
- get { return m_rows [index] as DeclSecurityRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal DeclSecurityTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitDeclSecurityTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class DeclSecurityRow : IMetadataRow {
-
- public SecurityAction Action;
- public MetadataToken Parent;
- public uint PermissionSet;
-
- internal DeclSecurityRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitDeclSecurityRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ElementType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ElementType.cs
index 4d78f43..f3c482b 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ElementType.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ElementType.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,46 +28,80 @@
namespace Mono.Cecil.Metadata {
- public enum ElementType {
- End = 0x00, // Marks end of a list
- Void = 0x01,
- Boolean = 0x02,
- Char = 0x03,
- I1 = 0x04,
- U1 = 0x05,
- I2 = 0x06,
- U2 = 0x07,
- I4 = 0x08,
- U4 = 0x09,
- I8 = 0x0a,
- U8 = 0x0b,
- R4 = 0x0c,
- R8 = 0x0d,
- String = 0x0e,
- Ptr = 0x0f, // Followed by <type> token
- ByRef = 0x10, // Followed by <type> token
- ValueType = 0x11, // Followed by <type> token
- Class = 0x12, // Followed by <type> token
- Var = 0x13, // Followed by generic parameter number
- Array = 0x14, // <type> <rank> <boundsCount> <bound1> <loCount> <lo1>
+ public enum MetadataType : byte {
+ Void = 0x01,
+ Boolean = 0x02,
+ Char = 0x03,
+ SByte = 0x04,
+ Byte = 0x05,
+ Int16 = 0x06,
+ UInt16 = 0x07,
+ Int32 = 0x08,
+ UInt32 = 0x09,
+ Int64 = 0x0a,
+ UInt64 = 0x0b,
+ Single = 0x0c,
+ Double = 0x0d,
+ String = 0x0e,
+ Pointer = 0x0f,
+ ByReference = 0x10,
+ ValueType = 0x11,
+ Class = 0x12,
+ Var = 0x13,
+ Array = 0x14,
+ GenericInstance = 0x15,
+ TypedByReference = 0x16,
+ IntPtr = 0x18,
+ UIntPtr = 0x19,
+ FunctionPointer = 0x1b,
+ Object = 0x1c,
+ MVar = 0x1e,
+ RequiredModifier = 0x1f,
+ OptionalModifier = 0x20,
+ Sentinel = 0x41,
+ Pinned = 0x45,
+ }
+
+ enum ElementType : byte {
+ None = 0x00,
+ Void = 0x01,
+ Boolean = 0x02,
+ Char = 0x03,
+ I1 = 0x04,
+ U1 = 0x05,
+ I2 = 0x06,
+ U2 = 0x07,
+ I4 = 0x08,
+ U4 = 0x09,
+ I8 = 0x0a,
+ U8 = 0x0b,
+ R4 = 0x0c,
+ R8 = 0x0d,
+ String = 0x0e,
+ Ptr = 0x0f, // Followed by <type> token
+ ByRef = 0x10, // Followed by <type> token
+ ValueType = 0x11, // Followed by <type> token
+ Class = 0x12, // Followed by <type> token
+ Var = 0x13, // Followed by generic parameter number
+ Array = 0x14, // <type> <rank> <boundsCount> <bound1> <loCount> <lo1>
GenericInst = 0x15, // <type> <type-arg-count> <type-1> ... <type-n> */
- TypedByRef = 0x16,
- I = 0x18, // System.IntPtr
- U = 0x19, // System.UIntPtr
- FnPtr = 0x1b, // Followed by full method signature
- Object = 0x1c, // System.Object
- SzArray = 0x1d, // Single-dim array with 0 lower bound
- MVar = 0x1e, // Followed by generic parameter number
- CModReqD = 0x1f, // Required modifier : followed by a TypeDef or TypeRef token
- CModOpt = 0x20, // Optional modifier : followed by a TypeDef or TypeRef token
- Internal = 0x21, // Implemented within the CLI
- Modifier = 0x40, // Or'd with following element types
- Sentinel = 0x41, // Sentinel for varargs method signature
- Pinned = 0x45, // Denotes a local variable that points at a pinned object
+ TypedByRef = 0x16,
+ I = 0x18, // System.IntPtr
+ U = 0x19, // System.UIntPtr
+ FnPtr = 0x1b, // Followed by full method signature
+ Object = 0x1c, // System.Object
+ SzArray = 0x1d, // Single-dim array with 0 lower bound
+ MVar = 0x1e, // Followed by generic parameter number
+ CModReqD = 0x1f, // Required modifier : followed by a TypeDef or TypeRef token
+ CModOpt = 0x20, // Optional modifier : followed by a TypeDef or TypeRef token
+ Internal = 0x21, // Implemented within the CLI
+ Modifier = 0x40, // Or'd with following element types
+ Sentinel = 0x41, // Sentinel for varargs method signature
+ Pinned = 0x45, // Denotes a local variable that points at a pinned object
// special undocumented constants
- Type = 0x50,
- Boxed = 0x51,
- Enum = 0x55
+ Type = 0x50,
+ Boxed = 0x51,
+ Enum = 0x55
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Event.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Event.cs
deleted file mode 100644
index a60fedb..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Event.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-//
-// EventTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil;
-
- public sealed class EventTable : IMetadataTable {
-
- public const int RId = 0x14;
-
- RowCollection m_rows;
-
- public EventRow this [int index] {
- get { return m_rows [index] as EventRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal EventTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitEventTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class EventRow : IMetadataRow {
-
- public EventAttributes EventFlags;
- public uint Name;
- public MetadataToken EventType;
-
- internal EventRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitEventRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventMap.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventMap.cs
deleted file mode 100644
index c3be845..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventMap.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// EventMapTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class EventMapTable : IMetadataTable {
-
- public const int RId = 0x12;
-
- RowCollection m_rows;
-
- public EventMapRow this [int index] {
- get { return m_rows [index] as EventMapRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal EventMapTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitEventMapTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class EventMapRow : IMetadataRow {
-
- public uint Parent;
- public uint EventList;
-
- internal EventMapRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitEventMapRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventPtr.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventPtr.cs
deleted file mode 100644
index 094fe5c..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/EventPtr.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// EventPtrTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Thu Feb 22 14:39:38 CET 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class EventPtrTable : IMetadataTable {
-
- public const int RId = 0x13;
-
- RowCollection m_rows;
-
- public EventPtrRow this [int index] {
- get { return m_rows [index] as EventPtrRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal EventPtrTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitEventPtrTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class EventPtrRow : IMetadataRow {
-
- public uint Event;
-
- internal EventPtrRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitEventPtrRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ExportedType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ExportedType.cs
deleted file mode 100644
index bca827f..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ExportedType.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-//
-// ExportedTypeTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil;
-
- public sealed class ExportedTypeTable : IMetadataTable {
-
- public const int RId = 0x27;
-
- RowCollection m_rows;
-
- public ExportedTypeRow this [int index] {
- get { return m_rows [index] as ExportedTypeRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal ExportedTypeTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitExportedTypeTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class ExportedTypeRow : IMetadataRow {
-
- public TypeAttributes Flags;
- public uint TypeDefId;
- public uint TypeName;
- public uint TypeNamespace;
- public MetadataToken Implementation;
-
- internal ExportedTypeRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitExportedTypeRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Field.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Field.cs
deleted file mode 100644
index 65b7998..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Field.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-//
-// FieldTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil;
-
- public sealed class FieldTable : IMetadataTable {
-
- public const int RId = 0x04;
-
- RowCollection m_rows;
-
- public FieldRow this [int index] {
- get { return m_rows [index] as FieldRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal FieldTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitFieldTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class FieldRow : IMetadataRow {
-
- public FieldAttributes Flags;
- public uint Name;
- public uint Signature;
-
- internal FieldRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitFieldRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldLayout.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldLayout.cs
deleted file mode 100644
index 5cf1563..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldLayout.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// FieldLayoutTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class FieldLayoutTable : IMetadataTable {
-
- public const int RId = 0x10;
-
- RowCollection m_rows;
-
- public FieldLayoutRow this [int index] {
- get { return m_rows [index] as FieldLayoutRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal FieldLayoutTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitFieldLayoutTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class FieldLayoutRow : IMetadataRow {
-
- public uint Offset;
- public uint Field;
-
- internal FieldLayoutRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitFieldLayoutRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldMarshal.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldMarshal.cs
deleted file mode 100644
index f5c6936..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldMarshal.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// FieldMarshalTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class FieldMarshalTable : IMetadataTable {
-
- public const int RId = 0x0d;
-
- RowCollection m_rows;
-
- public FieldMarshalRow this [int index] {
- get { return m_rows [index] as FieldMarshalRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal FieldMarshalTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitFieldMarshalTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class FieldMarshalRow : IMetadataRow {
-
- public MetadataToken Parent;
- public uint NativeType;
-
- internal FieldMarshalRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitFieldMarshalRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldPtr.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldPtr.cs
deleted file mode 100644
index b0d0c8a..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldPtr.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// FieldPtrTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Thu Feb 22 14:39:38 CET 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class FieldPtrTable : IMetadataTable {
-
- public const int RId = 0x03;
-
- RowCollection m_rows;
-
- public FieldPtrRow this [int index] {
- get { return m_rows [index] as FieldPtrRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal FieldPtrTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitFieldPtrTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class FieldPtrRow : IMetadataRow {
-
- public uint Field;
-
- internal FieldPtrRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitFieldPtrRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldRVA.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldRVA.cs
deleted file mode 100644
index e4e9fce..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/FieldRVA.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-//
-// FieldRVATable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil.Binary;
-
- public sealed class FieldRVATable : IMetadataTable {
-
- public const int RId = 0x1d;
-
- RowCollection m_rows;
-
- public FieldRVARow this [int index] {
- get { return m_rows [index] as FieldRVARow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal FieldRVATable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitFieldRVATable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class FieldRVARow : IMetadataRow {
-
- public RVA RVA;
- public uint Field;
-
- internal FieldRVARow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitFieldRVARow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/File.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/File.cs
deleted file mode 100644
index de10919..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/File.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-//
-// FileTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil;
-
- public sealed class FileTable : IMetadataTable {
-
- public const int RId = 0x26;
-
- RowCollection m_rows;
-
- public FileRow this [int index] {
- get { return m_rows [index] as FileRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal FileTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitFileTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class FileRow : IMetadataRow {
-
- public FileAttributes Flags;
- public uint Name;
- public uint HashValue;
-
- internal FileRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitFileRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParam.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParam.cs
deleted file mode 100644
index 219ca60..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParam.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-//
-// GenericParamTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil;
-
- public sealed class GenericParamTable : IMetadataTable {
-
- public const int RId = 0x2a;
-
- RowCollection m_rows;
-
- public GenericParamRow this [int index] {
- get { return m_rows [index] as GenericParamRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal GenericParamTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitGenericParamTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class GenericParamRow : IMetadataRow {
-
- public ushort Number;
- public GenericParameterAttributes Flags;
- public MetadataToken Owner;
- public uint Name;
-
- internal GenericParamRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitGenericParamRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParamConstraint.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParamConstraint.cs
deleted file mode 100644
index f6aa328..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GenericParamConstraint.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// GenericParamConstraintTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class GenericParamConstraintTable : IMetadataTable {
-
- public const int RId = 0x2c;
-
- RowCollection m_rows;
-
- public GenericParamConstraintRow this [int index] {
- get { return m_rows [index] as GenericParamConstraintRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal GenericParamConstraintTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitGenericParamConstraintTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class GenericParamConstraintRow : IMetadataRow {
-
- public uint Owner;
- public MetadataToken Constraint;
-
- internal GenericParamConstraintRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitGenericParamConstraintRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GuidHeap.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GuidHeap.cs
index 6ab60aa..19acdab 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GuidHeap.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/GuidHeap.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,49 +26,34 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil.Metadata {
+using System;
- using System;
- using System.Collections;
+using Mono.Cecil.PE;
- public class GuidHeap : MetadataHeap {
+namespace Mono.Cecil.Metadata {
- readonly IDictionary m_guids;
+ sealed class GuidHeap : Heap {
- public IDictionary Guids {
- get { return m_guids; }
+ public GuidHeap (Section section, uint start, uint size)
+ : base (section, start, size)
+ {
}
- public GuidHeap (MetadataStream stream) : base (stream, MetadataStream.GUID)
+ public Guid Read (uint index)
{
- m_guids = new Hashtable ();
- }
+ if (index == 0)
+ return new Guid ();
- public Guid this [uint index] {
- get {
- if (index == 0)
- return new Guid (new byte [16]);
+ const int guid_size = 16;
- int idx = (int) index - 1;
+ var buffer = new byte [guid_size];
- if (m_guids.Contains (idx))
- return (Guid) m_guids [idx];
+ index--;
- if (idx + 16 > this.Data.Length)
- throw new IndexOutOfRangeException ();
+ Buffer.BlockCopy (Section.Data, (int) (Offset + index), buffer, 0, guid_size);
- byte[] buffer = new byte [16];
- Buffer.BlockCopy (this.Data, idx, buffer, 0, 16);
- Guid res = new Guid (buffer);
- m_guids [idx] = res;
- return res;
- }
- set { m_guids [index] = value; }
- }
+ return new Guid (buffer);
- public override void Accept (IMetadataVisitor visitor)
- {
- visitor.VisitGuidHeap (this);
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitable.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Heap.cs
index 09ce018..e7ff720 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitable.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Heap.cs
@@ -1,10 +1,10 @@
//
-// IMetadataVisitable.cs
+// Heap.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,17 +26,23 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using Mono.Cecil.PE;
+
namespace Mono.Cecil.Metadata {
- public interface IMetadataVisitable {
- void Accept (IMetadataVisitor visitor);
- }
+ abstract class Heap {
- public interface IMetadataTableVisitable {
- void Accept (IMetadataTableVisitor visitor);
- }
+ public int IndexSize;
+
+ public readonly Section Section;
+ public readonly uint Offset;
+ public readonly uint Size;
- public interface IMetadataRowVisitable {
- void Accept (IMetadataRowVisitor visitor);
+ protected Heap (Section section, uint offset, uint size)
+ {
+ this.Section = section;
+ this.Offset = offset;
+ this.Size = size;
+ }
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataRow.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataRow.cs
deleted file mode 100644
index 012d5bf..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataRow.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// IMetadataRow.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public interface IMetadataRow : IMetadataRowVisitable {
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataTable.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataTable.cs
deleted file mode 100644
index 2fdf849..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataTable.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// IMetadataTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public interface IMetadataTable : IMetadataTableVisitable {
- int Id { get; }
- RowCollection Rows { get; set; }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitor.cs
deleted file mode 100644
index 3bbea3a..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/IMetadataVisitor.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-//
-// IMetadataVisitor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Thu Feb 22 14:39:38 CET 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public interface IMetadataVisitor {
- void VisitMetadataRoot (MetadataRoot root);
- void VisitMetadataRootHeader (MetadataRoot.MetadataRootHeader header);
- void VisitMetadataStreamCollection (MetadataStreamCollection streams);
- void VisitMetadataStream (MetadataStream stream);
- void VisitMetadataStreamHeader (MetadataStream.MetadataStreamHeader header);
- void VisitGuidHeap (GuidHeap heap);
- void VisitStringsHeap (StringsHeap heap);
- void VisitTablesHeap (TablesHeap heap);
- void VisitBlobHeap (BlobHeap heap);
- void VisitUserStringsHeap (UserStringsHeap heap);
-
- void TerminateMetadataRoot (MetadataRoot root);
- }
-
- public interface IMetadataTableVisitor {
- void VisitTableCollection (TableCollection coll);
-
- void VisitAssemblyTable (AssemblyTable table);
- void VisitAssemblyOSTable (AssemblyOSTable table);
- void VisitAssemblyProcessorTable (AssemblyProcessorTable table);
- void VisitAssemblyRefTable (AssemblyRefTable table);
- void VisitAssemblyRefOSTable (AssemblyRefOSTable table);
- void VisitAssemblyRefProcessorTable (AssemblyRefProcessorTable table);
- void VisitClassLayoutTable (ClassLayoutTable table);
- void VisitConstantTable (ConstantTable table);
- void VisitCustomAttributeTable (CustomAttributeTable table);
- void VisitDeclSecurityTable (DeclSecurityTable table);
- void VisitEventTable (EventTable table);
- void VisitEventMapTable (EventMapTable table);
- void VisitEventPtrTable (EventPtrTable table);
- void VisitExportedTypeTable (ExportedTypeTable table);
- void VisitFieldTable (FieldTable table);
- void VisitFieldLayoutTable (FieldLayoutTable table);
- void VisitFieldMarshalTable (FieldMarshalTable table);
- void VisitFieldPtrTable (FieldPtrTable table);
- void VisitFieldRVATable (FieldRVATable table);
- void VisitFileTable (FileTable table);
- void VisitGenericParamTable (GenericParamTable table);
- void VisitGenericParamConstraintTable (GenericParamConstraintTable table);
- void VisitImplMapTable (ImplMapTable table);
- void VisitInterfaceImplTable (InterfaceImplTable table);
- void VisitManifestResourceTable (ManifestResourceTable table);
- void VisitMemberRefTable (MemberRefTable table);
- void VisitMethodTable (MethodTable table);
- void VisitMethodImplTable (MethodImplTable table);
- void VisitMethodPtrTable (MethodPtrTable table);
- void VisitMethodSemanticsTable (MethodSemanticsTable table);
- void VisitMethodSpecTable (MethodSpecTable table);
- void VisitModuleTable (ModuleTable table);
- void VisitModuleRefTable (ModuleRefTable table);
- void VisitNestedClassTable (NestedClassTable table);
- void VisitParamTable (ParamTable table);
- void VisitParamPtrTable (ParamPtrTable table);
- void VisitPropertyTable (PropertyTable table);
- void VisitPropertyMapTable (PropertyMapTable table);
- void VisitPropertyPtrTable (PropertyPtrTable table);
- void VisitStandAloneSigTable (StandAloneSigTable table);
- void VisitTypeDefTable (TypeDefTable table);
- void VisitTypeRefTable (TypeRefTable table);
- void VisitTypeSpecTable (TypeSpecTable table);
-
- void TerminateTableCollection (TableCollection coll);
- IMetadataRowVisitor GetRowVisitor();
-}
-
- public interface IMetadataRowVisitor {
- void VisitRowCollection (RowCollection coll);
-
- void VisitAssemblyRow (AssemblyRow row);
- void VisitAssemblyOSRow (AssemblyOSRow row);
- void VisitAssemblyProcessorRow (AssemblyProcessorRow row);
- void VisitAssemblyRefRow (AssemblyRefRow row);
- void VisitAssemblyRefOSRow (AssemblyRefOSRow row);
- void VisitAssemblyRefProcessorRow (AssemblyRefProcessorRow row);
- void VisitClassLayoutRow (ClassLayoutRow row);
- void VisitConstantRow (ConstantRow row);
- void VisitCustomAttributeRow (CustomAttributeRow row);
- void VisitDeclSecurityRow (DeclSecurityRow row);
- void VisitEventRow (EventRow row);
- void VisitEventMapRow (EventMapRow row);
- void VisitEventPtrRow (EventPtrRow row);
- void VisitExportedTypeRow (ExportedTypeRow row);
- void VisitFieldRow (FieldRow row);
- void VisitFieldLayoutRow (FieldLayoutRow row);
- void VisitFieldMarshalRow (FieldMarshalRow row);
- void VisitFieldPtrRow (FieldPtrRow row);
- void VisitFieldRVARow (FieldRVARow row);
- void VisitFileRow (FileRow row);
- void VisitGenericParamRow (GenericParamRow row);
- void VisitGenericParamConstraintRow (GenericParamConstraintRow row);
- void VisitImplMapRow (ImplMapRow row);
- void VisitInterfaceImplRow (InterfaceImplRow row);
- void VisitManifestResourceRow (ManifestResourceRow row);
- void VisitMemberRefRow (MemberRefRow row);
- void VisitMethodRow (MethodRow row);
- void VisitMethodImplRow (MethodImplRow row);
- void VisitMethodPtrRow (MethodPtrRow row);
- void VisitMethodSemanticsRow (MethodSemanticsRow row);
- void VisitMethodSpecRow (MethodSpecRow row);
- void VisitModuleRow (ModuleRow row);
- void VisitModuleRefRow (ModuleRefRow row);
- void VisitNestedClassRow (NestedClassRow row);
- void VisitParamRow (ParamRow row);
- void VisitParamPtrRow (ParamPtrRow row);
- void VisitPropertyRow (PropertyRow row);
- void VisitPropertyMapRow (PropertyMapRow row);
- void VisitPropertyPtrRow (PropertyPtrRow row);
- void VisitStandAloneSigRow (StandAloneSigRow row);
- void VisitTypeDefRow (TypeDefRow row);
- void VisitTypeRefRow (TypeRefRow row);
- void VisitTypeSpecRow (TypeSpecRow row);
-
- void TerminateRowCollection (RowCollection coll);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ImplMap.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ImplMap.cs
deleted file mode 100644
index 3548312..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ImplMap.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-//
-// ImplMapTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil;
-
- public sealed class ImplMapTable : IMetadataTable {
-
- public const int RId = 0x1c;
-
- RowCollection m_rows;
-
- public ImplMapRow this [int index] {
- get { return m_rows [index] as ImplMapRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal ImplMapTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitImplMapTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class ImplMapRow : IMetadataRow {
-
- public PInvokeAttributes MappingFlags;
- public MetadataToken MemberForwarded;
- public uint ImportName;
- public uint ImportScope;
-
- internal ImplMapRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitImplMapRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/InterfaceImpl.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/InterfaceImpl.cs
deleted file mode 100644
index fc527c5..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/InterfaceImpl.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// InterfaceImplTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class InterfaceImplTable : IMetadataTable {
-
- public const int RId = 0x09;
-
- RowCollection m_rows;
-
- public InterfaceImplRow this [int index] {
- get { return m_rows [index] as InterfaceImplRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal InterfaceImplTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitInterfaceImplTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class InterfaceImplRow : IMetadataRow {
-
- public uint Class;
- public MetadataToken Interface;
-
- internal InterfaceImplRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitInterfaceImplRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ManifestResource.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ManifestResource.cs
deleted file mode 100644
index 07caf51..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ManifestResource.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-//
-// ManifestResourceTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil;
-
- public sealed class ManifestResourceTable : IMetadataTable {
-
- public const int RId = 0x28;
-
- RowCollection m_rows;
-
- public ManifestResourceRow this [int index] {
- get { return m_rows [index] as ManifestResourceRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal ManifestResourceTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitManifestResourceTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class ManifestResourceRow : IMetadataRow {
-
- public uint Offset;
- public ManifestResourceAttributes Flags;
- public uint Name;
- public MetadataToken Implementation;
-
- internal ManifestResourceRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitManifestResourceRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MemberRef.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MemberRef.cs
deleted file mode 100644
index 7a51aaa..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MemberRef.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-//
-// MemberRefTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class MemberRefTable : IMetadataTable {
-
- public const int RId = 0x0a;
-
- RowCollection m_rows;
-
- public MemberRefRow this [int index] {
- get { return m_rows [index] as MemberRefRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal MemberRefTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitMemberRefTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class MemberRefRow : IMetadataRow {
-
- public MetadataToken Class;
- public uint Name;
- public uint Signature;
-
- internal MemberRefRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitMemberRefRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataHeap.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataHeap.cs
deleted file mode 100644
index 7ce2d28..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataHeap.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-//
-// MetadataHeap.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
-
- using Mono.Cecil;
-
- public abstract class MetadataHeap : IMetadataVisitable {
-
- MetadataStream m_stream;
- string m_name;
- byte [] m_data;
-
- public string Name {
- get { return m_name; }
- }
-
- public byte [] Data {
- get { return m_data; }
- set { m_data = value; }
- }
-
- public int IndexSize;
-
- internal MetadataHeap (MetadataStream stream, string name)
- {
- m_name = name;
- m_stream = stream;
- }
-
- public static MetadataHeap HeapFactory (MetadataStream stream)
- {
- switch (stream.Header.Name) {
- case MetadataStream.Tables :
- case MetadataStream.IncrementalTables :
- return new TablesHeap (stream);
- case MetadataStream.GUID :
- return new GuidHeap (stream);
- case MetadataStream.Strings :
- return new StringsHeap (stream);
- case MetadataStream.UserStrings :
- return new UserStringsHeap (stream);
- case MetadataStream.Blob :
- return new BlobHeap (stream);
- default :
- return null;
- }
- }
-
- public MetadataStream GetStream ()
- {
- return m_stream;
- }
-
- protected virtual byte [] ReadBytesFromStream (uint pos)
- {
- int start, length = Utilities.ReadCompressedInteger (m_data, (int) pos, out start);
- byte [] buffer = new byte [length];
- Buffer.BlockCopy (m_data, start, buffer, 0, length);
- return buffer;
- }
-
- public abstract void Accept (IMetadataVisitor visitor);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataInitializer.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataInitializer.cs
deleted file mode 100644
index 3087d9d..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataInitializer.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-//
-// MetadataInitializer.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.IO;
- using System.Text;
-
- using Mono.Cecil;
- using Mono.Cecil.Binary;
-
- class MetadataInitializer : BaseMetadataVisitor {
-
- MetadataRoot m_root;
-
- public MetadataInitializer (ImageInitializer init)
- {
- m_root = init.Image.MetadataRoot;
- }
-
- public override void VisitMetadataRoot (MetadataRoot root)
- {
- root.Header = new MetadataRoot.MetadataRootHeader ();
- root.Streams = new MetadataStreamCollection ();
- }
-
- public override void VisitMetadataRootHeader (MetadataRoot.MetadataRootHeader header)
- {
- header.SetDefaultValues ();
- }
-
- public override void VisitMetadataStreamCollection (MetadataStreamCollection coll)
- {
- MetadataStream tables = new MetadataStream ();
- tables.Header.Name = MetadataStream.Tables;
- tables.Heap = MetadataHeap.HeapFactory (tables);
- TablesHeap th = tables.Heap as TablesHeap;
- th.Tables = new TableCollection (th);
- m_root.Streams.Add (tables);
- }
-
- public override void VisitTablesHeap (TablesHeap th)
- {
- th.Reserved = 0;
- th.MajorVersion = 1;
- th.MinorVersion = 0;
- th.Reserved2 = 1;
- th.Sorted = 0x2003301fa00;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataReader.cs
deleted file mode 100644
index a32c2e2..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataReader.cs
+++ /dev/null
@@ -1,229 +0,0 @@
-//
-// MetadataReader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.IO;
- using System.Text;
-
- using Mono.Cecil.Binary;
-
- class MetadataReader : BaseMetadataVisitor {
-
- ImageReader m_ir;
- BinaryReader m_binaryReader;
- MetadataTableReader m_tableReader;
- MetadataRoot m_root;
-
- public MetadataTableReader TableReader {
- get { return m_tableReader; }
- }
-
- public MetadataReader (ImageReader brv)
- {
- m_ir = brv;
- m_binaryReader = brv.GetReader ();
- }
-
- public MetadataRoot GetMetadataRoot ()
- {
- return m_root;
- }
-
- public BinaryReader GetDataReader (RVA rva)
- {
- return m_ir.Image.GetReaderAtVirtualAddress (rva);
- }
-
- public override void VisitMetadataRoot (MetadataRoot root)
- {
- m_root = root;
- root.Header = new MetadataRoot.MetadataRootHeader ();
- root.Streams = new MetadataStreamCollection ();
- }
-
- public override void VisitMetadataRootHeader (MetadataRoot.MetadataRootHeader header)
- {
- long headpos = m_binaryReader.BaseStream.Position;
-
- header.Signature = m_binaryReader.ReadUInt32 ();
-
- if (header.Signature != MetadataRoot.MetadataRootHeader.StandardSignature)
- throw new MetadataFormatException ("Wrong magic number");
-
- header.MajorVersion = m_binaryReader.ReadUInt16 ();
- header.MinorVersion = m_binaryReader.ReadUInt16 ();
- header.Reserved = m_binaryReader.ReadUInt32 ();
-
- // read version
- uint length = m_binaryReader.ReadUInt32 ();
- if (length != 0) {
- long pos = m_binaryReader.BaseStream.Position;
-
- byte [] version, buffer = new byte [length];
- int read = 0;
- while (read < length) {
- byte cur = (byte)m_binaryReader.ReadSByte ();
- if (cur == 0)
- break;
- buffer [read++] = cur;
- }
- version = new byte [read];
- Buffer.BlockCopy (buffer, 0, version, 0, read);
- header.Version = Encoding.UTF8.GetString (version, 0, version.Length);
-
- pos += length - headpos + 3;
- pos &= ~3;
- pos += headpos;
-
- m_binaryReader.BaseStream.Position = pos;
- } else
- header.Version = string.Empty;
-
- header.Flags = m_binaryReader.ReadUInt16 ();
- header.Streams = m_binaryReader.ReadUInt16 ();
- }
-
- public override void VisitMetadataStreamCollection (MetadataStreamCollection coll)
- {
- for (int i = 0; i < m_root.Header.Streams; i++)
- coll.Add (new MetadataStream ());
- }
-
- public override void VisitMetadataStreamHeader (MetadataStream.MetadataStreamHeader header)
- {
- header.Offset = m_binaryReader.ReadUInt32 ();
- header.Size = m_binaryReader.ReadUInt32 ();
-
- StringBuilder buffer = new StringBuilder ();
- while (true) {
- char cur = (char) m_binaryReader.ReadSByte ();
- if (cur == '\0')
- break;
- buffer.Append (cur);
- }
- header.Name = buffer.ToString ();
- if (header.Name.Length == 0)
- throw new MetadataFormatException ("Invalid stream name");
-
- long rootpos = m_root.GetImage ().ResolveVirtualAddress (
- m_root.GetImage ().CLIHeader.Metadata.VirtualAddress);
-
- long curpos = m_binaryReader.BaseStream.Position;
-
- if (header.Size != 0)
- curpos -= rootpos;
-
- curpos += 3;
- curpos &= ~3;
-
- if (header.Size != 0)
- curpos += rootpos;
-
- m_binaryReader.BaseStream.Position = curpos;
-
- header.Stream.Heap = MetadataHeap.HeapFactory (header.Stream);
- }
-
- public override void VisitGuidHeap (GuidHeap heap)
- {
- VisitHeap (heap);
- }
-
- public override void VisitStringsHeap (StringsHeap heap)
- {
- VisitHeap (heap);
-
- if (heap.Data.Length < 1 && heap.Data [0] != 0)
- throw new MetadataFormatException ("Malformed #Strings heap");
-
- heap [(uint) 0] = string.Empty;
- }
-
- public override void VisitTablesHeap (TablesHeap heap)
- {
- VisitHeap (heap);
- heap.Tables = new TableCollection (heap);
-
- BinaryReader br = new BinaryReader (new MemoryStream (heap.Data));
- try {
- heap.Reserved = br.ReadUInt32 ();
- heap.MajorVersion = br.ReadByte ();
- heap.MinorVersion = br.ReadByte ();
- heap.HeapSizes = br.ReadByte ();
- heap.Reserved2 = br.ReadByte ();
- heap.Valid = br.ReadInt64 ();
- heap.Sorted = br.ReadInt64 ();
- } finally {
- // COMPACT FRAMEWORK NOTE: BinaryReader is not IDisposable
- br.Close ();
- }
- }
-
- public override void VisitBlobHeap (BlobHeap heap)
- {
- VisitHeap (heap);
- }
-
- public override void VisitUserStringsHeap (UserStringsHeap heap)
- {
- VisitHeap (heap);
- }
-
- void VisitHeap (MetadataHeap heap)
- {
- long cursor = m_binaryReader.BaseStream.Position;
-
- m_binaryReader.BaseStream.Position = m_root.GetImage ().ResolveVirtualAddress (
- m_root.GetImage ().CLIHeader.Metadata.VirtualAddress)
- + heap.GetStream ().Header.Offset;
-
- heap.Data = m_binaryReader.ReadBytes ((int) heap.GetStream ().Header.Size);
-
- m_binaryReader.BaseStream.Position = cursor;
- }
-
- void SetHeapIndexSize (MetadataHeap heap, byte flag)
- {
- if (heap == null)
- return;
- TablesHeap th = m_root.Streams.TablesHeap;
- heap.IndexSize = ((th.HeapSizes & flag) > 0) ? 4 : 2;
- }
-
- public override void TerminateMetadataRoot (MetadataRoot root)
- {
- SetHeapIndexSize (root.Streams.StringsHeap, 0x01);
- SetHeapIndexSize (root.Streams.GuidHeap, 0x02);
- SetHeapIndexSize (root.Streams.BlobHeap, 0x04);
- m_tableReader = new MetadataTableReader (this);
- root.Streams.TablesHeap.Tables.Accept (m_tableReader);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRoot.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRoot.cs
deleted file mode 100644
index 9305149..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRoot.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-//
-// MetadataRoot.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil.Binary;
-
- public sealed class MetadataRoot : IMetadataVisitable {
-
- MetadataRootHeader m_header;
- Image m_image;
-
- MetadataStreamCollection m_streams;
-
- public MetadataRootHeader Header {
- get { return m_header; }
- set { m_header = value; }
- }
-
- public MetadataStreamCollection Streams {
- get { return m_streams; }
- set { m_streams = value; }
- }
-
- internal MetadataRoot (Image img)
- {
- m_image = img;
- }
-
- public Image GetImage ()
- {
- return m_image;
- }
-
- public void Accept (IMetadataVisitor visitor)
- {
- visitor.VisitMetadataRoot (this);
-
- m_header.Accept (visitor);
- m_streams.Accept (visitor);
-
- visitor.TerminateMetadataRoot (this);
- }
-
- public sealed class MetadataRootHeader : IHeader, IMetadataVisitable {
-
- public const uint StandardSignature = 0x424a5342;
-
- public uint Signature;
- public ushort MinorVersion;
- public ushort MajorVersion;
- public uint Reserved;
- public string Version;
- public ushort Flags;
- public ushort Streams;
-
- internal MetadataRootHeader ()
- {
- }
-
- public void SetDefaultValues ()
- {
- Signature = StandardSignature;
- Reserved = 0;
- Flags = 0;
- }
-
- public void Accept (IMetadataVisitor visitor)
- {
- visitor.VisitMetadataRootHeader (this);
- }
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowReader.cs
deleted file mode 100644
index a071b3c..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowReader.cs
+++ /dev/null
@@ -1,367 +0,0 @@
-//
-// MetadataRowReader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Jul 17 00:22:32 +0200 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.Collections;
- using System.IO;
-
- using Mono.Cecil.Binary;
-
- class MetadataRowReader : BaseMetadataRowVisitor {
-
- MetadataTableReader m_mtrv;
- BinaryReader m_binaryReader;
- MetadataRoot m_metadataRoot;
- IDictionary m_ciCache;
-
- int m_blobHeapIdxSz;
- int m_stringsHeapIdxSz;
- int m_guidHeapIdxSz;
-
- public MetadataRowReader (MetadataTableReader mtrv)
- {
- m_mtrv = mtrv;
- m_binaryReader = mtrv.GetReader ();
- m_metadataRoot = mtrv.GetMetadataRoot ();
- m_ciCache = new Hashtable ();
- }
-
- int GetIndexSize (int rid)
- {
- return m_mtrv.GetNumberOfRows (rid) < (1 << 16) ? 2 : 4;
- }
-
- int GetCodedIndexSize (CodedIndex ci)
- {
- return Utilities.GetCodedIndexSize (ci,
- new Utilities.TableRowCounter (m_mtrv.GetNumberOfRows), m_ciCache);
- }
-
- uint ReadByIndexSize (int size)
- {
- if (size == 2) {
- return (uint) m_binaryReader.ReadUInt16 ();
- } else if (size == 4) {
- return m_binaryReader.ReadUInt32 ();
- } else {
- throw new MetadataFormatException ("Non valid size for indexing");
- }
- }
-
- public override void VisitRowCollection (RowCollection coll)
- {
- m_blobHeapIdxSz = m_metadataRoot.Streams.BlobHeap != null ?
- m_metadataRoot.Streams.BlobHeap.IndexSize : 2;
- m_stringsHeapIdxSz = m_metadataRoot.Streams.StringsHeap != null ?
- m_metadataRoot.Streams.StringsHeap.IndexSize : 2;
- m_guidHeapIdxSz = m_metadataRoot.Streams.GuidHeap != null ?
- m_metadataRoot.Streams.GuidHeap.IndexSize : 2;
- }
-
- public override void VisitAssemblyRow (AssemblyRow row)
- {
- row.HashAlgId = (Mono.Cecil.AssemblyHashAlgorithm) m_binaryReader.ReadUInt32 ();
- row.MajorVersion = m_binaryReader.ReadUInt16 ();
- row.MinorVersion = m_binaryReader.ReadUInt16 ();
- row.BuildNumber = m_binaryReader.ReadUInt16 ();
- row.RevisionNumber = m_binaryReader.ReadUInt16 ();
- row.Flags = (Mono.Cecil.AssemblyFlags) m_binaryReader.ReadUInt32 ();
- row.PublicKey = ReadByIndexSize (m_blobHeapIdxSz);
- row.Name = ReadByIndexSize (m_stringsHeapIdxSz);
- row.Culture = ReadByIndexSize (m_stringsHeapIdxSz);
- }
- public override void VisitAssemblyOSRow (AssemblyOSRow row)
- {
- row.OSPlatformID = m_binaryReader.ReadUInt32 ();
- row.OSMajorVersion = m_binaryReader.ReadUInt32 ();
- row.OSMinorVersion = m_binaryReader.ReadUInt32 ();
- }
- public override void VisitAssemblyProcessorRow (AssemblyProcessorRow row)
- {
- row.Processor = m_binaryReader.ReadUInt32 ();
- }
- public override void VisitAssemblyRefRow (AssemblyRefRow row)
- {
- row.MajorVersion = m_binaryReader.ReadUInt16 ();
- row.MinorVersion = m_binaryReader.ReadUInt16 ();
- row.BuildNumber = m_binaryReader.ReadUInt16 ();
- row.RevisionNumber = m_binaryReader.ReadUInt16 ();
- row.Flags = (Mono.Cecil.AssemblyFlags) m_binaryReader.ReadUInt32 ();
- row.PublicKeyOrToken = ReadByIndexSize (m_blobHeapIdxSz);
- row.Name = ReadByIndexSize (m_stringsHeapIdxSz);
- row.Culture = ReadByIndexSize (m_stringsHeapIdxSz);
- row.HashValue = ReadByIndexSize (m_blobHeapIdxSz);
- }
- public override void VisitAssemblyRefOSRow (AssemblyRefOSRow row)
- {
- row.OSPlatformID = m_binaryReader.ReadUInt32 ();
- row.OSMajorVersion = m_binaryReader.ReadUInt32 ();
- row.OSMinorVersion = m_binaryReader.ReadUInt32 ();
- row.AssemblyRef = ReadByIndexSize (GetIndexSize (AssemblyRefTable.RId));
- }
- public override void VisitAssemblyRefProcessorRow (AssemblyRefProcessorRow row)
- {
- row.Processor = m_binaryReader.ReadUInt32 ();
- row.AssemblyRef = ReadByIndexSize (GetIndexSize (AssemblyRefTable.RId));
- }
- public override void VisitClassLayoutRow (ClassLayoutRow row)
- {
- row.PackingSize = m_binaryReader.ReadUInt16 ();
- row.ClassSize = m_binaryReader.ReadUInt32 ();
- row.Parent = ReadByIndexSize (GetIndexSize (TypeDefTable.RId));
- }
- public override void VisitConstantRow (ConstantRow row)
- {
- row.Type = (Mono.Cecil.Metadata.ElementType) m_binaryReader.ReadUInt16 ();
- row.Parent = Utilities.GetMetadataToken (CodedIndex.HasConstant,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.HasConstant)));
- row.Value = ReadByIndexSize (m_blobHeapIdxSz);
- }
- public override void VisitCustomAttributeRow (CustomAttributeRow row)
- {
- row.Parent = Utilities.GetMetadataToken (CodedIndex.HasCustomAttribute,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.HasCustomAttribute)));
- row.Type = Utilities.GetMetadataToken (CodedIndex.CustomAttributeType,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.CustomAttributeType)));
- row.Value = ReadByIndexSize (m_blobHeapIdxSz);
- }
- public override void VisitDeclSecurityRow (DeclSecurityRow row)
- {
- row.Action = (Mono.Cecil.SecurityAction) m_binaryReader.ReadInt16 ();
- row.Parent = Utilities.GetMetadataToken (CodedIndex.HasDeclSecurity,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.HasDeclSecurity)));
- row.PermissionSet = ReadByIndexSize (m_blobHeapIdxSz);
- }
- public override void VisitEventRow (EventRow row)
- {
- row.EventFlags = (Mono.Cecil.EventAttributes) m_binaryReader.ReadUInt16 ();
- row.Name = ReadByIndexSize (m_stringsHeapIdxSz);
- row.EventType = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.TypeDefOrRef)));
- }
- public override void VisitEventMapRow (EventMapRow row)
- {
- row.Parent = ReadByIndexSize (GetIndexSize (TypeDefTable.RId));
- row.EventList = ReadByIndexSize (GetIndexSize (EventTable.RId));
- }
- public override void VisitEventPtrRow (EventPtrRow row)
- {
- row.Event = ReadByIndexSize (GetIndexSize (EventTable.RId));
- }
- public override void VisitExportedTypeRow (ExportedTypeRow row)
- {
- row.Flags = (Mono.Cecil.TypeAttributes) m_binaryReader.ReadUInt32 ();
- row.TypeDefId = m_binaryReader.ReadUInt32 ();
- row.TypeName = ReadByIndexSize (m_stringsHeapIdxSz);
- row.TypeNamespace = ReadByIndexSize (m_stringsHeapIdxSz);
- row.Implementation = Utilities.GetMetadataToken (CodedIndex.Implementation,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.Implementation)));
- }
- public override void VisitFieldRow (FieldRow row)
- {
- row.Flags = (Mono.Cecil.FieldAttributes) m_binaryReader.ReadUInt16 ();
- row.Name = ReadByIndexSize (m_stringsHeapIdxSz);
- row.Signature = ReadByIndexSize (m_blobHeapIdxSz);
- }
- public override void VisitFieldLayoutRow (FieldLayoutRow row)
- {
- row.Offset = m_binaryReader.ReadUInt32 ();
- row.Field = ReadByIndexSize (GetIndexSize (FieldTable.RId));
- }
- public override void VisitFieldMarshalRow (FieldMarshalRow row)
- {
- row.Parent = Utilities.GetMetadataToken (CodedIndex.HasFieldMarshal,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.HasFieldMarshal)));
- row.NativeType = ReadByIndexSize (m_blobHeapIdxSz);
- }
- public override void VisitFieldPtrRow (FieldPtrRow row)
- {
- row.Field = ReadByIndexSize (GetIndexSize (FieldTable.RId));
- }
- public override void VisitFieldRVARow (FieldRVARow row)
- {
- row.RVA = new RVA (m_binaryReader.ReadUInt32 ());
- row.Field = ReadByIndexSize (GetIndexSize (FieldTable.RId));
- }
- public override void VisitFileRow (FileRow row)
- {
- row.Flags = (Mono.Cecil.FileAttributes) m_binaryReader.ReadUInt32 ();
- row.Name = ReadByIndexSize (m_stringsHeapIdxSz);
- row.HashValue = ReadByIndexSize (m_blobHeapIdxSz);
- }
- public override void VisitGenericParamRow (GenericParamRow row)
- {
- row.Number = m_binaryReader.ReadUInt16 ();
- row.Flags = (Mono.Cecil.GenericParameterAttributes) m_binaryReader.ReadUInt16 ();
- row.Owner = Utilities.GetMetadataToken (CodedIndex.TypeOrMethodDef,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.TypeOrMethodDef)));
- row.Name = ReadByIndexSize (m_stringsHeapIdxSz);
- }
- public override void VisitGenericParamConstraintRow (GenericParamConstraintRow row)
- {
- row.Owner = ReadByIndexSize (GetIndexSize (GenericParamTable.RId));
- row.Constraint = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.TypeDefOrRef)));
- }
- public override void VisitImplMapRow (ImplMapRow row)
- {
- row.MappingFlags = (Mono.Cecil.PInvokeAttributes) m_binaryReader.ReadUInt16 ();
- row.MemberForwarded = Utilities.GetMetadataToken (CodedIndex.MemberForwarded,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.MemberForwarded)));
- row.ImportName = ReadByIndexSize (m_stringsHeapIdxSz);
- row.ImportScope = ReadByIndexSize (GetIndexSize (ModuleRefTable.RId));
- }
- public override void VisitInterfaceImplRow (InterfaceImplRow row)
- {
- row.Class = ReadByIndexSize (GetIndexSize (TypeDefTable.RId));
- row.Interface = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.TypeDefOrRef)));
- }
- public override void VisitManifestResourceRow (ManifestResourceRow row)
- {
- row.Offset = m_binaryReader.ReadUInt32 ();
- row.Flags = (Mono.Cecil.ManifestResourceAttributes) m_binaryReader.ReadUInt32 ();
- row.Name = ReadByIndexSize (m_stringsHeapIdxSz);
- row.Implementation = Utilities.GetMetadataToken (CodedIndex.Implementation,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.Implementation)));
- }
- public override void VisitMemberRefRow (MemberRefRow row)
- {
- row.Class = Utilities.GetMetadataToken (CodedIndex.MemberRefParent,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.MemberRefParent)));
- row.Name = ReadByIndexSize (m_stringsHeapIdxSz);
- row.Signature = ReadByIndexSize (m_blobHeapIdxSz);
- }
- public override void VisitMethodRow (MethodRow row)
- {
- row.RVA = new RVA (m_binaryReader.ReadUInt32 ());
- row.ImplFlags = (Mono.Cecil.MethodImplAttributes) m_binaryReader.ReadUInt16 ();
- row.Flags = (Mono.Cecil.MethodAttributes) m_binaryReader.ReadUInt16 ();
- row.Name = ReadByIndexSize (m_stringsHeapIdxSz);
- row.Signature = ReadByIndexSize (m_blobHeapIdxSz);
- row.ParamList = ReadByIndexSize (GetIndexSize (ParamTable.RId));
- }
- public override void VisitMethodImplRow (MethodImplRow row)
- {
- row.Class = ReadByIndexSize (GetIndexSize (TypeDefTable.RId));
- row.MethodBody = Utilities.GetMetadataToken (CodedIndex.MethodDefOrRef,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.MethodDefOrRef)));
- row.MethodDeclaration = Utilities.GetMetadataToken (CodedIndex.MethodDefOrRef,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.MethodDefOrRef)));
- }
- public override void VisitMethodPtrRow (MethodPtrRow row)
- {
- row.Method = ReadByIndexSize (GetIndexSize (MethodTable.RId));
- }
- public override void VisitMethodSemanticsRow (MethodSemanticsRow row)
- {
- row.Semantics = (Mono.Cecil.MethodSemanticsAttributes) m_binaryReader.ReadUInt16 ();
- row.Method = ReadByIndexSize (GetIndexSize (MethodTable.RId));
- row.Association = Utilities.GetMetadataToken (CodedIndex.HasSemantics,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.HasSemantics)));
- }
- public override void VisitMethodSpecRow (MethodSpecRow row)
- {
- row.Method = Utilities.GetMetadataToken (CodedIndex.MethodDefOrRef,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.MethodDefOrRef)));
- row.Instantiation = ReadByIndexSize (m_blobHeapIdxSz);
- }
- public override void VisitModuleRow (ModuleRow row)
- {
- row.Generation = m_binaryReader.ReadUInt16 ();
- row.Name = ReadByIndexSize (m_stringsHeapIdxSz);
- row.Mvid = ReadByIndexSize (m_guidHeapIdxSz);
- row.EncId = ReadByIndexSize (m_guidHeapIdxSz);
- row.EncBaseId = ReadByIndexSize (m_guidHeapIdxSz);
- }
- public override void VisitModuleRefRow (ModuleRefRow row)
- {
- row.Name = ReadByIndexSize (m_stringsHeapIdxSz);
- }
- public override void VisitNestedClassRow (NestedClassRow row)
- {
- row.NestedClass = ReadByIndexSize (GetIndexSize (TypeDefTable.RId));
- row.EnclosingClass = ReadByIndexSize (GetIndexSize (TypeDefTable.RId));
- }
- public override void VisitParamRow (ParamRow row)
- {
- row.Flags = (Mono.Cecil.ParameterAttributes) m_binaryReader.ReadUInt16 ();
- row.Sequence = m_binaryReader.ReadUInt16 ();
- row.Name = ReadByIndexSize (m_stringsHeapIdxSz);
- }
- public override void VisitParamPtrRow (ParamPtrRow row)
- {
- row.Param = ReadByIndexSize (GetIndexSize (ParamTable.RId));
- }
- public override void VisitPropertyRow (PropertyRow row)
- {
- row.Flags = (Mono.Cecil.PropertyAttributes) m_binaryReader.ReadUInt16 ();
- row.Name = ReadByIndexSize (m_stringsHeapIdxSz);
- row.Type = ReadByIndexSize (m_blobHeapIdxSz);
- }
- public override void VisitPropertyMapRow (PropertyMapRow row)
- {
- row.Parent = ReadByIndexSize (GetIndexSize (TypeDefTable.RId));
- row.PropertyList = ReadByIndexSize (GetIndexSize (PropertyTable.RId));
- }
- public override void VisitPropertyPtrRow (PropertyPtrRow row)
- {
- row.Property = ReadByIndexSize (GetIndexSize (PropertyTable.RId));
- }
- public override void VisitStandAloneSigRow (StandAloneSigRow row)
- {
- row.Signature = ReadByIndexSize (m_blobHeapIdxSz);
- }
- public override void VisitTypeDefRow (TypeDefRow row)
- {
- row.Flags = (Mono.Cecil.TypeAttributes) m_binaryReader.ReadUInt32 ();
- row.Name = ReadByIndexSize (m_stringsHeapIdxSz);
- row.Namespace = ReadByIndexSize (m_stringsHeapIdxSz);
- row.Extends = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.TypeDefOrRef)));
- row.FieldList = ReadByIndexSize (GetIndexSize (FieldTable.RId));
- row.MethodList = ReadByIndexSize (GetIndexSize (MethodTable.RId));
- }
- public override void VisitTypeRefRow (TypeRefRow row)
- {
- row.ResolutionScope = Utilities.GetMetadataToken (CodedIndex.ResolutionScope,
- ReadByIndexSize (GetCodedIndexSize (CodedIndex.ResolutionScope)));
- row.Name = ReadByIndexSize (m_stringsHeapIdxSz);
- row.Namespace = ReadByIndexSize (m_stringsHeapIdxSz);
- }
- public override void VisitTypeSpecRow (TypeSpecRow row)
- {
- row.Signature = ReadByIndexSize (m_blobHeapIdxSz);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowWriter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowWriter.cs
deleted file mode 100644
index baddfc0..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataRowWriter.cs
+++ /dev/null
@@ -1,796 +0,0 @@
-//
-// MetadataRowWriter.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Thu Feb 22 14:39:38 CET 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Binary;
-
- class MetadataRowWriter : BaseMetadataRowVisitor {
-
- MetadataRoot m_root;
- MemoryBinaryWriter m_binaryWriter;
- IDictionary m_ciCache;
-
- int m_blobHeapIdxSz;
- int m_stringsHeapIdxSz;
- int m_guidHeapIdxSz;
-
- public MetadataRowWriter (MetadataTableWriter mtwv)
- {
- m_binaryWriter = mtwv.GetWriter ();
- m_root = mtwv.GetMetadataRoot ();
- m_ciCache = new Hashtable ();
- }
-
- void WriteBlobPointer (uint pointer)
- {
- WriteByIndexSize (pointer, m_blobHeapIdxSz);
- }
-
- void WriteStringPointer (uint pointer)
- {
- WriteByIndexSize (pointer, m_stringsHeapIdxSz);
- }
-
- void WriteGuidPointer (uint pointer)
- {
- WriteByIndexSize (pointer, m_guidHeapIdxSz);
- }
-
- void WriteTablePointer (uint pointer, int rid)
- {
- WriteByIndexSize (pointer, GetNumberOfRows (rid) < (1 << 16) ? 2 : 4);
- }
-
- void WriteMetadataToken (MetadataToken token, CodedIndex ci)
- {
- WriteByIndexSize (Utilities.CompressMetadataToken (ci, token),
- Utilities.GetCodedIndexSize (
- ci, new Utilities.TableRowCounter (GetNumberOfRows), m_ciCache));
- }
-
- int GetNumberOfRows (int rid)
- {
- IMetadataTable t = m_root.Streams.TablesHeap [rid];
- if (t == null || t.Rows == null)
- return 0;
- return t.Rows.Count;
- }
-
- void WriteByIndexSize (uint value, int size)
- {
- if (size == 4)
- m_binaryWriter.Write (value);
- else if (size == 2)
- m_binaryWriter.Write ((ushort) value);
- else
- throw new MetadataFormatException ("Non valid size for indexing");
- }
-
- public AssemblyRow CreateAssemblyRow (AssemblyHashAlgorithm _hashAlgId, ushort _majorVersion, ushort _minorVersion, ushort _buildNumber, ushort _revisionNumber, AssemblyFlags _flags, uint _publicKey, uint _name, uint _culture)
- {
- AssemblyRow row = new AssemblyRow ();
- row.HashAlgId = _hashAlgId;
- row.MajorVersion = _majorVersion;
- row.MinorVersion = _minorVersion;
- row.BuildNumber = _buildNumber;
- row.RevisionNumber = _revisionNumber;
- row.Flags = _flags;
- row.PublicKey = _publicKey;
- row.Name = _name;
- row.Culture = _culture;
- return row;
- }
-
- public AssemblyOSRow CreateAssemblyOSRow (uint _oSPlatformID, uint _oSMajorVersion, uint _oSMinorVersion)
- {
- AssemblyOSRow row = new AssemblyOSRow ();
- row.OSPlatformID = _oSPlatformID;
- row.OSMajorVersion = _oSMajorVersion;
- row.OSMinorVersion = _oSMinorVersion;
- return row;
- }
-
- public AssemblyProcessorRow CreateAssemblyProcessorRow (uint _processor)
- {
- AssemblyProcessorRow row = new AssemblyProcessorRow ();
- row.Processor = _processor;
- return row;
- }
-
- public AssemblyRefRow CreateAssemblyRefRow (ushort _majorVersion, ushort _minorVersion, ushort _buildNumber, ushort _revisionNumber, AssemblyFlags _flags, uint _publicKeyOrToken, uint _name, uint _culture, uint _hashValue)
- {
- AssemblyRefRow row = new AssemblyRefRow ();
- row.MajorVersion = _majorVersion;
- row.MinorVersion = _minorVersion;
- row.BuildNumber = _buildNumber;
- row.RevisionNumber = _revisionNumber;
- row.Flags = _flags;
- row.PublicKeyOrToken = _publicKeyOrToken;
- row.Name = _name;
- row.Culture = _culture;
- row.HashValue = _hashValue;
- return row;
- }
-
- public AssemblyRefOSRow CreateAssemblyRefOSRow (uint _oSPlatformID, uint _oSMajorVersion, uint _oSMinorVersion, uint _assemblyRef)
- {
- AssemblyRefOSRow row = new AssemblyRefOSRow ();
- row.OSPlatformID = _oSPlatformID;
- row.OSMajorVersion = _oSMajorVersion;
- row.OSMinorVersion = _oSMinorVersion;
- row.AssemblyRef = _assemblyRef;
- return row;
- }
-
- public AssemblyRefProcessorRow CreateAssemblyRefProcessorRow (uint _processor, uint _assemblyRef)
- {
- AssemblyRefProcessorRow row = new AssemblyRefProcessorRow ();
- row.Processor = _processor;
- row.AssemblyRef = _assemblyRef;
- return row;
- }
-
- public ClassLayoutRow CreateClassLayoutRow (ushort _packingSize, uint _classSize, uint _parent)
- {
- ClassLayoutRow row = new ClassLayoutRow ();
- row.PackingSize = _packingSize;
- row.ClassSize = _classSize;
- row.Parent = _parent;
- return row;
- }
-
- public ConstantRow CreateConstantRow (ElementType _type, MetadataToken _parent, uint _value)
- {
- ConstantRow row = new ConstantRow ();
- row.Type = _type;
- row.Parent = _parent;
- row.Value = _value;
- return row;
- }
-
- public CustomAttributeRow CreateCustomAttributeRow (MetadataToken _parent, MetadataToken _type, uint _value)
- {
- CustomAttributeRow row = new CustomAttributeRow ();
- row.Parent = _parent;
- row.Type = _type;
- row.Value = _value;
- return row;
- }
-
- public DeclSecurityRow CreateDeclSecurityRow (SecurityAction _action, MetadataToken _parent, uint _permissionSet)
- {
- DeclSecurityRow row = new DeclSecurityRow ();
- row.Action = _action;
- row.Parent = _parent;
- row.PermissionSet = _permissionSet;
- return row;
- }
-
- public EventRow CreateEventRow (EventAttributes _eventFlags, uint _name, MetadataToken _eventType)
- {
- EventRow row = new EventRow ();
- row.EventFlags = _eventFlags;
- row.Name = _name;
- row.EventType = _eventType;
- return row;
- }
-
- public EventMapRow CreateEventMapRow (uint _parent, uint _eventList)
- {
- EventMapRow row = new EventMapRow ();
- row.Parent = _parent;
- row.EventList = _eventList;
- return row;
- }
-
- public EventPtrRow CreateEventPtrRow (uint _event)
- {
- EventPtrRow row = new EventPtrRow ();
- row.Event = _event;
- return row;
- }
-
- public ExportedTypeRow CreateExportedTypeRow (TypeAttributes _flags, uint _typeDefId, uint _typeName, uint _typeNamespace, MetadataToken _implementation)
- {
- ExportedTypeRow row = new ExportedTypeRow ();
- row.Flags = _flags;
- row.TypeDefId = _typeDefId;
- row.TypeName = _typeName;
- row.TypeNamespace = _typeNamespace;
- row.Implementation = _implementation;
- return row;
- }
-
- public FieldRow CreateFieldRow (FieldAttributes _flags, uint _name, uint _signature)
- {
- FieldRow row = new FieldRow ();
- row.Flags = _flags;
- row.Name = _name;
- row.Signature = _signature;
- return row;
- }
-
- public FieldLayoutRow CreateFieldLayoutRow (uint _offset, uint _field)
- {
- FieldLayoutRow row = new FieldLayoutRow ();
- row.Offset = _offset;
- row.Field = _field;
- return row;
- }
-
- public FieldMarshalRow CreateFieldMarshalRow (MetadataToken _parent, uint _nativeType)
- {
- FieldMarshalRow row = new FieldMarshalRow ();
- row.Parent = _parent;
- row.NativeType = _nativeType;
- return row;
- }
-
- public FieldPtrRow CreateFieldPtrRow (uint _field)
- {
- FieldPtrRow row = new FieldPtrRow ();
- row.Field = _field;
- return row;
- }
-
- public FieldRVARow CreateFieldRVARow (RVA _rVA, uint _field)
- {
- FieldRVARow row = new FieldRVARow ();
- row.RVA = _rVA;
- row.Field = _field;
- return row;
- }
-
- public FileRow CreateFileRow (FileAttributes _flags, uint _name, uint _hashValue)
- {
- FileRow row = new FileRow ();
- row.Flags = _flags;
- row.Name = _name;
- row.HashValue = _hashValue;
- return row;
- }
-
- public GenericParamRow CreateGenericParamRow (ushort _number, GenericParameterAttributes _flags, MetadataToken _owner, uint _name)
- {
- GenericParamRow row = new GenericParamRow ();
- row.Number = _number;
- row.Flags = _flags;
- row.Owner = _owner;
- row.Name = _name;
- return row;
- }
-
- public GenericParamConstraintRow CreateGenericParamConstraintRow (uint _owner, MetadataToken _constraint)
- {
- GenericParamConstraintRow row = new GenericParamConstraintRow ();
- row.Owner = _owner;
- row.Constraint = _constraint;
- return row;
- }
-
- public ImplMapRow CreateImplMapRow (PInvokeAttributes _mappingFlags, MetadataToken _memberForwarded, uint _importName, uint _importScope)
- {
- ImplMapRow row = new ImplMapRow ();
- row.MappingFlags = _mappingFlags;
- row.MemberForwarded = _memberForwarded;
- row.ImportName = _importName;
- row.ImportScope = _importScope;
- return row;
- }
-
- public InterfaceImplRow CreateInterfaceImplRow (uint _class, MetadataToken _interface)
- {
- InterfaceImplRow row = new InterfaceImplRow ();
- row.Class = _class;
- row.Interface = _interface;
- return row;
- }
-
- public ManifestResourceRow CreateManifestResourceRow (uint _offset, ManifestResourceAttributes _flags, uint _name, MetadataToken _implementation)
- {
- ManifestResourceRow row = new ManifestResourceRow ();
- row.Offset = _offset;
- row.Flags = _flags;
- row.Name = _name;
- row.Implementation = _implementation;
- return row;
- }
-
- public MemberRefRow CreateMemberRefRow (MetadataToken _class, uint _name, uint _signature)
- {
- MemberRefRow row = new MemberRefRow ();
- row.Class = _class;
- row.Name = _name;
- row.Signature = _signature;
- return row;
- }
-
- public MethodRow CreateMethodRow (RVA _rVA, MethodImplAttributes _implFlags, MethodAttributes _flags, uint _name, uint _signature, uint _paramList)
- {
- MethodRow row = new MethodRow ();
- row.RVA = _rVA;
- row.ImplFlags = _implFlags;
- row.Flags = _flags;
- row.Name = _name;
- row.Signature = _signature;
- row.ParamList = _paramList;
- return row;
- }
-
- public MethodImplRow CreateMethodImplRow (uint _class, MetadataToken _methodBody, MetadataToken _methodDeclaration)
- {
- MethodImplRow row = new MethodImplRow ();
- row.Class = _class;
- row.MethodBody = _methodBody;
- row.MethodDeclaration = _methodDeclaration;
- return row;
- }
-
- public MethodPtrRow CreateMethodPtrRow (uint _method)
- {
- MethodPtrRow row = new MethodPtrRow ();
- row.Method = _method;
- return row;
- }
-
- public MethodSemanticsRow CreateMethodSemanticsRow (MethodSemanticsAttributes _semantics, uint _method, MetadataToken _association)
- {
- MethodSemanticsRow row = new MethodSemanticsRow ();
- row.Semantics = _semantics;
- row.Method = _method;
- row.Association = _association;
- return row;
- }
-
- public MethodSpecRow CreateMethodSpecRow (MetadataToken _method, uint _instantiation)
- {
- MethodSpecRow row = new MethodSpecRow ();
- row.Method = _method;
- row.Instantiation = _instantiation;
- return row;
- }
-
- public ModuleRow CreateModuleRow (ushort _generation, uint _name, uint _mvid, uint _encId, uint _encBaseId)
- {
- ModuleRow row = new ModuleRow ();
- row.Generation = _generation;
- row.Name = _name;
- row.Mvid = _mvid;
- row.EncId = _encId;
- row.EncBaseId = _encBaseId;
- return row;
- }
-
- public ModuleRefRow CreateModuleRefRow (uint _name)
- {
- ModuleRefRow row = new ModuleRefRow ();
- row.Name = _name;
- return row;
- }
-
- public NestedClassRow CreateNestedClassRow (uint _nestedClass, uint _enclosingClass)
- {
- NestedClassRow row = new NestedClassRow ();
- row.NestedClass = _nestedClass;
- row.EnclosingClass = _enclosingClass;
- return row;
- }
-
- public ParamRow CreateParamRow (ParameterAttributes _flags, ushort _sequence, uint _name)
- {
- ParamRow row = new ParamRow ();
- row.Flags = _flags;
- row.Sequence = _sequence;
- row.Name = _name;
- return row;
- }
-
- public ParamPtrRow CreateParamPtrRow (uint _param)
- {
- ParamPtrRow row = new ParamPtrRow ();
- row.Param = _param;
- return row;
- }
-
- public PropertyRow CreatePropertyRow (PropertyAttributes _flags, uint _name, uint _type)
- {
- PropertyRow row = new PropertyRow ();
- row.Flags = _flags;
- row.Name = _name;
- row.Type = _type;
- return row;
- }
-
- public PropertyMapRow CreatePropertyMapRow (uint _parent, uint _propertyList)
- {
- PropertyMapRow row = new PropertyMapRow ();
- row.Parent = _parent;
- row.PropertyList = _propertyList;
- return row;
- }
-
- public PropertyPtrRow CreatePropertyPtrRow (uint _property)
- {
- PropertyPtrRow row = new PropertyPtrRow ();
- row.Property = _property;
- return row;
- }
-
- public StandAloneSigRow CreateStandAloneSigRow (uint _signature)
- {
- StandAloneSigRow row = new StandAloneSigRow ();
- row.Signature = _signature;
- return row;
- }
-
- public TypeDefRow CreateTypeDefRow (TypeAttributes _flags, uint _name, uint _namespace, MetadataToken _extends, uint _fieldList, uint _methodList)
- {
- TypeDefRow row = new TypeDefRow ();
- row.Flags = _flags;
- row.Name = _name;
- row.Namespace = _namespace;
- row.Extends = _extends;
- row.FieldList = _fieldList;
- row.MethodList = _methodList;
- return row;
- }
-
- public TypeRefRow CreateTypeRefRow (MetadataToken _resolutionScope, uint _name, uint _namespace)
- {
- TypeRefRow row = new TypeRefRow ();
- row.ResolutionScope = _resolutionScope;
- row.Name = _name;
- row.Namespace = _namespace;
- return row;
- }
-
- public TypeSpecRow CreateTypeSpecRow (uint _signature)
- {
- TypeSpecRow row = new TypeSpecRow ();
- row.Signature = _signature;
- return row;
- }
-
- public override void VisitRowCollection (RowCollection coll)
- {
- m_blobHeapIdxSz = m_root.Streams.BlobHeap != null ?
- m_root.Streams.BlobHeap.IndexSize : 2;
- m_stringsHeapIdxSz = m_root.Streams.StringsHeap != null ?
- m_root.Streams.StringsHeap.IndexSize : 2;
- m_guidHeapIdxSz = m_root.Streams.GuidHeap != null ?
- m_root.Streams.GuidHeap.IndexSize : 2;
- }
-
- public override void VisitAssemblyRow (AssemblyRow row)
- {
- m_binaryWriter.Write ((uint) row.HashAlgId);
- m_binaryWriter.Write (row.MajorVersion);
- m_binaryWriter.Write (row.MinorVersion);
- m_binaryWriter.Write (row.BuildNumber);
- m_binaryWriter.Write (row.RevisionNumber);
- m_binaryWriter.Write ((uint) row.Flags);
- WriteBlobPointer (row.PublicKey);
- WriteStringPointer (row.Name);
- WriteStringPointer (row.Culture);
- }
-
- public override void VisitAssemblyOSRow (AssemblyOSRow row)
- {
- m_binaryWriter.Write (row.OSPlatformID);
- m_binaryWriter.Write (row.OSMajorVersion);
- m_binaryWriter.Write (row.OSMinorVersion);
- }
-
- public override void VisitAssemblyProcessorRow (AssemblyProcessorRow row)
- {
- m_binaryWriter.Write (row.Processor);
- }
-
- public override void VisitAssemblyRefRow (AssemblyRefRow row)
- {
- m_binaryWriter.Write (row.MajorVersion);
- m_binaryWriter.Write (row.MinorVersion);
- m_binaryWriter.Write (row.BuildNumber);
- m_binaryWriter.Write (row.RevisionNumber);
- m_binaryWriter.Write ((uint) row.Flags);
- WriteBlobPointer (row.PublicKeyOrToken);
- WriteStringPointer (row.Name);
- WriteStringPointer (row.Culture);
- WriteBlobPointer (row.HashValue);
- }
-
- public override void VisitAssemblyRefOSRow (AssemblyRefOSRow row)
- {
- m_binaryWriter.Write (row.OSPlatformID);
- m_binaryWriter.Write (row.OSMajorVersion);
- m_binaryWriter.Write (row.OSMinorVersion);
- WriteTablePointer (row.AssemblyRef, AssemblyRefTable.RId);
- }
-
- public override void VisitAssemblyRefProcessorRow (AssemblyRefProcessorRow row)
- {
- m_binaryWriter.Write (row.Processor);
- WriteTablePointer (row.AssemblyRef, AssemblyRefTable.RId);
- }
-
- public override void VisitClassLayoutRow (ClassLayoutRow row)
- {
- m_binaryWriter.Write (row.PackingSize);
- m_binaryWriter.Write (row.ClassSize);
- WriteTablePointer (row.Parent, TypeDefTable.RId);
- }
-
- public override void VisitConstantRow (ConstantRow row)
- {
- m_binaryWriter.Write ((ushort) row.Type);
- WriteMetadataToken (row.Parent, CodedIndex.HasConstant);
- WriteBlobPointer (row.Value);
- }
-
- public override void VisitCustomAttributeRow (CustomAttributeRow row)
- {
- WriteMetadataToken (row.Parent, CodedIndex.HasCustomAttribute);
- WriteMetadataToken (row.Type, CodedIndex.CustomAttributeType);
- WriteBlobPointer (row.Value);
- }
-
- public override void VisitDeclSecurityRow (DeclSecurityRow row)
- {
- m_binaryWriter.Write ((short) row.Action);
- WriteMetadataToken (row.Parent, CodedIndex.HasDeclSecurity);
- WriteBlobPointer (row.PermissionSet);
- }
-
- public override void VisitEventRow (EventRow row)
- {
- m_binaryWriter.Write ((ushort) row.EventFlags);
- WriteStringPointer (row.Name);
- WriteMetadataToken (row.EventType, CodedIndex.TypeDefOrRef);
- }
-
- public override void VisitEventMapRow (EventMapRow row)
- {
- WriteTablePointer (row.Parent, TypeDefTable.RId);
- WriteTablePointer (row.EventList, EventTable.RId);
- }
-
- public override void VisitEventPtrRow (EventPtrRow row)
- {
- WriteTablePointer (row.Event, EventTable.RId);
- }
-
- public override void VisitExportedTypeRow (ExportedTypeRow row)
- {
- m_binaryWriter.Write ((uint) row.Flags);
- m_binaryWriter.Write (row.TypeDefId);
- WriteStringPointer (row.TypeName);
- WriteStringPointer (row.TypeNamespace);
- WriteMetadataToken (row.Implementation, CodedIndex.Implementation);
- }
-
- public override void VisitFieldRow (FieldRow row)
- {
- m_binaryWriter.Write ((ushort) row.Flags);
- WriteStringPointer (row.Name);
- WriteBlobPointer (row.Signature);
- }
-
- public override void VisitFieldLayoutRow (FieldLayoutRow row)
- {
- m_binaryWriter.Write (row.Offset);
- WriteTablePointer (row.Field, FieldTable.RId);
- }
-
- public override void VisitFieldMarshalRow (FieldMarshalRow row)
- {
- WriteMetadataToken (row.Parent, CodedIndex.HasFieldMarshal);
- WriteBlobPointer (row.NativeType);
- }
-
- public override void VisitFieldPtrRow (FieldPtrRow row)
- {
- WriteTablePointer (row.Field, FieldTable.RId);
- }
-
- public override void VisitFieldRVARow (FieldRVARow row)
- {
- m_binaryWriter.Write (row.RVA.Value);
- WriteTablePointer (row.Field, FieldTable.RId);
- }
-
- public override void VisitFileRow (FileRow row)
- {
- m_binaryWriter.Write ((uint) row.Flags);
- WriteStringPointer (row.Name);
- WriteBlobPointer (row.HashValue);
- }
-
- public override void VisitGenericParamRow (GenericParamRow row)
- {
- m_binaryWriter.Write (row.Number);
- m_binaryWriter.Write ((ushort) row.Flags);
- WriteMetadataToken (row.Owner, CodedIndex.TypeOrMethodDef);
- WriteStringPointer (row.Name);
- }
-
- public override void VisitGenericParamConstraintRow (GenericParamConstraintRow row)
- {
- WriteTablePointer (row.Owner, GenericParamTable.RId);
- WriteMetadataToken (row.Constraint, CodedIndex.TypeDefOrRef);
- }
-
- public override void VisitImplMapRow (ImplMapRow row)
- {
- m_binaryWriter.Write ((ushort) row.MappingFlags);
- WriteMetadataToken (row.MemberForwarded, CodedIndex.MemberForwarded);
- WriteStringPointer (row.ImportName);
- WriteTablePointer (row.ImportScope, ModuleRefTable.RId);
- }
-
- public override void VisitInterfaceImplRow (InterfaceImplRow row)
- {
- WriteTablePointer (row.Class, TypeDefTable.RId);
- WriteMetadataToken (row.Interface, CodedIndex.TypeDefOrRef);
- }
-
- public override void VisitManifestResourceRow (ManifestResourceRow row)
- {
- m_binaryWriter.Write (row.Offset);
- m_binaryWriter.Write ((uint) row.Flags);
- WriteStringPointer (row.Name);
- WriteMetadataToken (row.Implementation, CodedIndex.Implementation);
- }
-
- public override void VisitMemberRefRow (MemberRefRow row)
- {
- WriteMetadataToken (row.Class, CodedIndex.MemberRefParent);
- WriteStringPointer (row.Name);
- WriteBlobPointer (row.Signature);
- }
-
- public override void VisitMethodRow (MethodRow row)
- {
- m_binaryWriter.Write (row.RVA.Value);
- m_binaryWriter.Write ((ushort) row.ImplFlags);
- m_binaryWriter.Write ((ushort) row.Flags);
- WriteStringPointer (row.Name);
- WriteBlobPointer (row.Signature);
- WriteTablePointer (row.ParamList, ParamTable.RId);
- }
-
- public override void VisitMethodImplRow (MethodImplRow row)
- {
- WriteTablePointer (row.Class, TypeDefTable.RId);
- WriteMetadataToken (row.MethodBody, CodedIndex.MethodDefOrRef);
- WriteMetadataToken (row.MethodDeclaration, CodedIndex.MethodDefOrRef);
- }
-
- public override void VisitMethodPtrRow (MethodPtrRow row)
- {
- WriteTablePointer (row.Method, MethodTable.RId);
- }
-
- public override void VisitMethodSemanticsRow (MethodSemanticsRow row)
- {
- m_binaryWriter.Write ((ushort) row.Semantics);
- WriteTablePointer (row.Method, MethodTable.RId);
- WriteMetadataToken (row.Association, CodedIndex.HasSemantics);
- }
-
- public override void VisitMethodSpecRow (MethodSpecRow row)
- {
- WriteMetadataToken (row.Method, CodedIndex.MethodDefOrRef);
- WriteBlobPointer (row.Instantiation);
- }
-
- public override void VisitModuleRow (ModuleRow row)
- {
- m_binaryWriter.Write (row.Generation);
- WriteStringPointer (row.Name);
- WriteGuidPointer (row.Mvid);
- WriteGuidPointer (row.EncId);
- WriteGuidPointer (row.EncBaseId);
- }
-
- public override void VisitModuleRefRow (ModuleRefRow row)
- {
- WriteStringPointer (row.Name);
- }
-
- public override void VisitNestedClassRow (NestedClassRow row)
- {
- WriteTablePointer (row.NestedClass, TypeDefTable.RId);
- WriteTablePointer (row.EnclosingClass, TypeDefTable.RId);
- }
-
- public override void VisitParamRow (ParamRow row)
- {
- m_binaryWriter.Write ((ushort) row.Flags);
- m_binaryWriter.Write (row.Sequence);
- WriteStringPointer (row.Name);
- }
-
- public override void VisitParamPtrRow (ParamPtrRow row)
- {
- WriteTablePointer (row.Param, ParamTable.RId);
- }
-
- public override void VisitPropertyRow (PropertyRow row)
- {
- m_binaryWriter.Write ((ushort) row.Flags);
- WriteStringPointer (row.Name);
- WriteBlobPointer (row.Type);
- }
-
- public override void VisitPropertyMapRow (PropertyMapRow row)
- {
- WriteTablePointer (row.Parent, TypeDefTable.RId);
- WriteTablePointer (row.PropertyList, PropertyTable.RId);
- }
-
- public override void VisitPropertyPtrRow (PropertyPtrRow row)
- {
- WriteTablePointer (row.Property, PropertyTable.RId);
- }
-
- public override void VisitStandAloneSigRow (StandAloneSigRow row)
- {
- WriteBlobPointer (row.Signature);
- }
-
- public override void VisitTypeDefRow (TypeDefRow row)
- {
- m_binaryWriter.Write ((uint) row.Flags);
- WriteStringPointer (row.Name);
- WriteStringPointer (row.Namespace);
- WriteMetadataToken (row.Extends, CodedIndex.TypeDefOrRef);
- WriteTablePointer (row.FieldList, FieldTable.RId);
- WriteTablePointer (row.MethodList, MethodTable.RId);
- }
-
- public override void VisitTypeRefRow (TypeRefRow row)
- {
- WriteMetadataToken (row.ResolutionScope, CodedIndex.ResolutionScope);
- WriteStringPointer (row.Name);
- WriteStringPointer (row.Namespace);
- }
-
- public override void VisitTypeSpecRow (TypeSpecRow row)
- {
- WriteBlobPointer (row.Signature);
- }
-
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStream.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStream.cs
deleted file mode 100644
index 96ba0b4..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStream.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-//
-// MetadataStream.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public class MetadataStream : IMetadataVisitable {
-
- public const string Strings = "#Strings";
- public const string Tables = "#~";
- public const string IncrementalTables = "#-";
- public const string Blob = "#Blob";
- public const string GUID = "#GUID";
- public const string UserStrings = "#US";
-
- MetadataStreamHeader m_header;
- MetadataHeap m_heap;
-
- public MetadataStreamHeader Header {
- get { return m_header; }
- set { m_header = value; }
- }
-
- public MetadataHeap Heap {
- get { return m_heap; }
- set { m_heap = value; }
- }
-
- internal MetadataStream ()
- {
- m_header = new MetadataStreamHeader (this);
- }
-
- public void Accept (IMetadataVisitor visitor)
- {
- visitor.VisitMetadataStream (this);
-
- m_header.Accept (visitor);
- if (m_heap != null)
- m_heap.Accept (visitor);
- }
-
- public class MetadataStreamHeader : IMetadataVisitable {
-
- public uint Offset;
- public uint Size;
- public string Name;
-
- private MetadataStream m_stream;
-
- public MetadataStream Stream {
- get { return m_stream; }
- }
-
- internal MetadataStreamHeader (MetadataStream stream)
- {
- m_stream = stream;
- }
-
- public void Accept (IMetadataVisitor visitor)
- {
- visitor.VisitMetadataStreamHeader (this);
- }
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStreamCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStreamCollection.cs
deleted file mode 100644
index b602f17..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataStreamCollection.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-//
-// MetadataStreamCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.Collections;
-
- public class MetadataStreamCollection : ICollection, IMetadataVisitable {
-
- IList m_items;
-
- BlobHeap m_blobHeap;
- GuidHeap m_guidHeap;
- StringsHeap m_stringsHeap;
- UserStringsHeap m_usHeap;
- TablesHeap m_tablesHeap;
-
- public MetadataStream this [int index] {
- get { return m_items [index] as MetadataStream; }
- set { m_items [index] = value; }
- }
-
- public int Count {
- get { return m_items.Count; }
- }
-
- public bool IsSynchronized {
- get { return false; }
- }
-
- public object SyncRoot {
- get { return this; }
- }
-
- public BlobHeap BlobHeap {
- get {
- if (m_blobHeap == null)
- m_blobHeap = GetHeap (MetadataStream.Blob) as BlobHeap;
- return m_blobHeap;
- }
- }
-
- public GuidHeap GuidHeap {
- get {
- if (m_guidHeap == null)
- m_guidHeap = GetHeap (MetadataStream.GUID) as GuidHeap;
- return m_guidHeap;
- }
- }
-
- public StringsHeap StringsHeap {
- get {
- if (m_stringsHeap == null)
- m_stringsHeap = GetHeap (MetadataStream.Strings) as StringsHeap;
- return m_stringsHeap;
- }
- }
-
- public TablesHeap TablesHeap {
- get {
- if (m_tablesHeap == null)
- m_tablesHeap = GetHeap (MetadataStream.Tables) as TablesHeap;
- return m_tablesHeap;
- }
- }
-
- public UserStringsHeap UserStringsHeap {
- get {
- if (m_usHeap == null)
- m_usHeap = GetHeap (MetadataStream.UserStrings) as UserStringsHeap;
- return m_usHeap;
- }
- }
-
- public MetadataStreamCollection ()
- {
- m_items = new ArrayList (5);
- }
-
- private MetadataHeap GetHeap (string name)
- {
- for (int i = 0; i < m_items.Count; i++) {
- MetadataStream stream = m_items [i] as MetadataStream;
- if (stream.Heap.Name == name)
- return stream.Heap;
- }
-
- return null;
- }
-
- internal void Add (MetadataStream value)
- {
- m_items.Add (value);
- }
-
- internal void Remove (MetadataStream value)
- {
- m_items.Remove (value);
- }
-
- public void CopyTo (Array ary, int index)
- {
- m_items.CopyTo (ary, index);
- }
-
- public IEnumerator GetEnumerator ()
- {
- return m_items.GetEnumerator ();
- }
-
- public void Accept (IMetadataVisitor visitor)
- {
- visitor.VisitMetadataStreamCollection (this);
-
- for (int i = 0; i < m_items.Count; i++)
- this [i].Accept (visitor);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableReader.cs
deleted file mode 100644
index f24362f..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableReader.cs
+++ /dev/null
@@ -1,769 +0,0 @@
-//
-// MetadataTableReader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Jul 17 00:22:32 +0200 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.Collections;
- using System.IO;
-
- class MetadataTableReader : BaseMetadataTableVisitor {
-
- MetadataRoot m_metadataRoot;
- TablesHeap m_heap;
- MetadataRowReader m_mrrv;
- BinaryReader m_binaryReader;
-
- int [] m_rows = new int [TablesHeap.MaxTableCount];
-
- public MetadataTableReader (MetadataReader mrv)
- {
- m_metadataRoot = mrv.GetMetadataRoot ();
- m_heap = m_metadataRoot.Streams.TablesHeap;
- m_binaryReader = new BinaryReader (new MemoryStream (m_heap.Data));
- m_binaryReader.BaseStream.Position = 24;
- m_mrrv = new MetadataRowReader (this);
- }
-
- public MetadataRoot GetMetadataRoot ()
- {
- return m_metadataRoot;
- }
-
- public BinaryReader GetReader ()
- {
- return m_binaryReader;
- }
-
- public override IMetadataRowVisitor GetRowVisitor ()
- {
- return m_mrrv;
- }
-
- public int GetNumberOfRows (int rid)
- {
- return m_rows [rid];
- }
-
- public AssemblyTable GetAssemblyTable ()
- {
- return (AssemblyTable) m_heap [AssemblyTable.RId];
- }
-
- public AssemblyOSTable GetAssemblyOSTable ()
- {
- return (AssemblyOSTable) m_heap [AssemblyOSTable.RId];
- }
-
- public AssemblyProcessorTable GetAssemblyProcessorTable ()
- {
- return (AssemblyProcessorTable) m_heap [AssemblyProcessorTable.RId];
- }
-
- public AssemblyRefTable GetAssemblyRefTable ()
- {
- return (AssemblyRefTable) m_heap [AssemblyRefTable.RId];
- }
-
- public AssemblyRefOSTable GetAssemblyRefOSTable ()
- {
- return (AssemblyRefOSTable) m_heap [AssemblyRefOSTable.RId];
- }
-
- public AssemblyRefProcessorTable GetAssemblyRefProcessorTable ()
- {
- return (AssemblyRefProcessorTable) m_heap [AssemblyRefProcessorTable.RId];
- }
-
- public ClassLayoutTable GetClassLayoutTable ()
- {
- return (ClassLayoutTable) m_heap [ClassLayoutTable.RId];
- }
-
- public ConstantTable GetConstantTable ()
- {
- return (ConstantTable) m_heap [ConstantTable.RId];
- }
-
- public CustomAttributeTable GetCustomAttributeTable ()
- {
- return (CustomAttributeTable) m_heap [CustomAttributeTable.RId];
- }
-
- public DeclSecurityTable GetDeclSecurityTable ()
- {
- return (DeclSecurityTable) m_heap [DeclSecurityTable.RId];
- }
-
- public EventTable GetEventTable ()
- {
- return (EventTable) m_heap [EventTable.RId];
- }
-
- public EventMapTable GetEventMapTable ()
- {
- return (EventMapTable) m_heap [EventMapTable.RId];
- }
-
- public EventPtrTable GetEventPtrTable ()
- {
- return (EventPtrTable) m_heap [EventPtrTable.RId];
- }
-
- public ExportedTypeTable GetExportedTypeTable ()
- {
- return (ExportedTypeTable) m_heap [ExportedTypeTable.RId];
- }
-
- public FieldTable GetFieldTable ()
- {
- return (FieldTable) m_heap [FieldTable.RId];
- }
-
- public FieldLayoutTable GetFieldLayoutTable ()
- {
- return (FieldLayoutTable) m_heap [FieldLayoutTable.RId];
- }
-
- public FieldMarshalTable GetFieldMarshalTable ()
- {
- return (FieldMarshalTable) m_heap [FieldMarshalTable.RId];
- }
-
- public FieldPtrTable GetFieldPtrTable ()
- {
- return (FieldPtrTable) m_heap [FieldPtrTable.RId];
- }
-
- public FieldRVATable GetFieldRVATable ()
- {
- return (FieldRVATable) m_heap [FieldRVATable.RId];
- }
-
- public FileTable GetFileTable ()
- {
- return (FileTable) m_heap [FileTable.RId];
- }
-
- public GenericParamTable GetGenericParamTable ()
- {
- return (GenericParamTable) m_heap [GenericParamTable.RId];
- }
-
- public GenericParamConstraintTable GetGenericParamConstraintTable ()
- {
- return (GenericParamConstraintTable) m_heap [GenericParamConstraintTable.RId];
- }
-
- public ImplMapTable GetImplMapTable ()
- {
- return (ImplMapTable) m_heap [ImplMapTable.RId];
- }
-
- public InterfaceImplTable GetInterfaceImplTable ()
- {
- return (InterfaceImplTable) m_heap [InterfaceImplTable.RId];
- }
-
- public ManifestResourceTable GetManifestResourceTable ()
- {
- return (ManifestResourceTable) m_heap [ManifestResourceTable.RId];
- }
-
- public MemberRefTable GetMemberRefTable ()
- {
- return (MemberRefTable) m_heap [MemberRefTable.RId];
- }
-
- public MethodTable GetMethodTable ()
- {
- return (MethodTable) m_heap [MethodTable.RId];
- }
-
- public MethodImplTable GetMethodImplTable ()
- {
- return (MethodImplTable) m_heap [MethodImplTable.RId];
- }
-
- public MethodPtrTable GetMethodPtrTable ()
- {
- return (MethodPtrTable) m_heap [MethodPtrTable.RId];
- }
-
- public MethodSemanticsTable GetMethodSemanticsTable ()
- {
- return (MethodSemanticsTable) m_heap [MethodSemanticsTable.RId];
- }
-
- public MethodSpecTable GetMethodSpecTable ()
- {
- return (MethodSpecTable) m_heap [MethodSpecTable.RId];
- }
-
- public ModuleTable GetModuleTable ()
- {
- return (ModuleTable) m_heap [ModuleTable.RId];
- }
-
- public ModuleRefTable GetModuleRefTable ()
- {
- return (ModuleRefTable) m_heap [ModuleRefTable.RId];
- }
-
- public NestedClassTable GetNestedClassTable ()
- {
- return (NestedClassTable) m_heap [NestedClassTable.RId];
- }
-
- public ParamTable GetParamTable ()
- {
- return (ParamTable) m_heap [ParamTable.RId];
- }
-
- public ParamPtrTable GetParamPtrTable ()
- {
- return (ParamPtrTable) m_heap [ParamPtrTable.RId];
- }
-
- public PropertyTable GetPropertyTable ()
- {
- return (PropertyTable) m_heap [PropertyTable.RId];
- }
-
- public PropertyMapTable GetPropertyMapTable ()
- {
- return (PropertyMapTable) m_heap [PropertyMapTable.RId];
- }
-
- public PropertyPtrTable GetPropertyPtrTable ()
- {
- return (PropertyPtrTable) m_heap [PropertyPtrTable.RId];
- }
-
- public StandAloneSigTable GetStandAloneSigTable ()
- {
- return (StandAloneSigTable) m_heap [StandAloneSigTable.RId];
- }
-
- public TypeDefTable GetTypeDefTable ()
- {
- return (TypeDefTable) m_heap [TypeDefTable.RId];
- }
-
- public TypeRefTable GetTypeRefTable ()
- {
- return (TypeRefTable) m_heap [TypeRefTable.RId];
- }
-
- public TypeSpecTable GetTypeSpecTable ()
- {
- return (TypeSpecTable) m_heap [TypeSpecTable.RId];
- }
-
- public override void VisitTableCollection (TableCollection coll)
- {
- if (m_heap.HasTable (ModuleTable.RId)) {
- coll.Add (new ModuleTable ());
- m_rows [ModuleTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (TypeRefTable.RId)) {
- coll.Add (new TypeRefTable ());
- m_rows [TypeRefTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (TypeDefTable.RId)) {
- coll.Add (new TypeDefTable ());
- m_rows [TypeDefTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (FieldPtrTable.RId)) {
- coll.Add (new FieldPtrTable ());
- m_rows [FieldPtrTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (FieldTable.RId)) {
- coll.Add (new FieldTable ());
- m_rows [FieldTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (MethodPtrTable.RId)) {
- coll.Add (new MethodPtrTable ());
- m_rows [MethodPtrTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (MethodTable.RId)) {
- coll.Add (new MethodTable ());
- m_rows [MethodTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (ParamPtrTable.RId)) {
- coll.Add (new ParamPtrTable ());
- m_rows [ParamPtrTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (ParamTable.RId)) {
- coll.Add (new ParamTable ());
- m_rows [ParamTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (InterfaceImplTable.RId)) {
- coll.Add (new InterfaceImplTable ());
- m_rows [InterfaceImplTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (MemberRefTable.RId)) {
- coll.Add (new MemberRefTable ());
- m_rows [MemberRefTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (ConstantTable.RId)) {
- coll.Add (new ConstantTable ());
- m_rows [ConstantTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (CustomAttributeTable.RId)) {
- coll.Add (new CustomAttributeTable ());
- m_rows [CustomAttributeTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (FieldMarshalTable.RId)) {
- coll.Add (new FieldMarshalTable ());
- m_rows [FieldMarshalTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (DeclSecurityTable.RId)) {
- coll.Add (new DeclSecurityTable ());
- m_rows [DeclSecurityTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (ClassLayoutTable.RId)) {
- coll.Add (new ClassLayoutTable ());
- m_rows [ClassLayoutTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (FieldLayoutTable.RId)) {
- coll.Add (new FieldLayoutTable ());
- m_rows [FieldLayoutTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (StandAloneSigTable.RId)) {
- coll.Add (new StandAloneSigTable ());
- m_rows [StandAloneSigTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (EventMapTable.RId)) {
- coll.Add (new EventMapTable ());
- m_rows [EventMapTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (EventPtrTable.RId)) {
- coll.Add (new EventPtrTable ());
- m_rows [EventPtrTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (EventTable.RId)) {
- coll.Add (new EventTable ());
- m_rows [EventTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (PropertyMapTable.RId)) {
- coll.Add (new PropertyMapTable ());
- m_rows [PropertyMapTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (PropertyPtrTable.RId)) {
- coll.Add (new PropertyPtrTable ());
- m_rows [PropertyPtrTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (PropertyTable.RId)) {
- coll.Add (new PropertyTable ());
- m_rows [PropertyTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (MethodSemanticsTable.RId)) {
- coll.Add (new MethodSemanticsTable ());
- m_rows [MethodSemanticsTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (MethodImplTable.RId)) {
- coll.Add (new MethodImplTable ());
- m_rows [MethodImplTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (ModuleRefTable.RId)) {
- coll.Add (new ModuleRefTable ());
- m_rows [ModuleRefTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (TypeSpecTable.RId)) {
- coll.Add (new TypeSpecTable ());
- m_rows [TypeSpecTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (ImplMapTable.RId)) {
- coll.Add (new ImplMapTable ());
- m_rows [ImplMapTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (FieldRVATable.RId)) {
- coll.Add (new FieldRVATable ());
- m_rows [FieldRVATable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (AssemblyTable.RId)) {
- coll.Add (new AssemblyTable ());
- m_rows [AssemblyTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (AssemblyProcessorTable.RId)) {
- coll.Add (new AssemblyProcessorTable ());
- m_rows [AssemblyProcessorTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (AssemblyOSTable.RId)) {
- coll.Add (new AssemblyOSTable ());
- m_rows [AssemblyOSTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (AssemblyRefTable.RId)) {
- coll.Add (new AssemblyRefTable ());
- m_rows [AssemblyRefTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (AssemblyRefProcessorTable.RId)) {
- coll.Add (new AssemblyRefProcessorTable ());
- m_rows [AssemblyRefProcessorTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (AssemblyRefOSTable.RId)) {
- coll.Add (new AssemblyRefOSTable ());
- m_rows [AssemblyRefOSTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (FileTable.RId)) {
- coll.Add (new FileTable ());
- m_rows [FileTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (ExportedTypeTable.RId)) {
- coll.Add (new ExportedTypeTable ());
- m_rows [ExportedTypeTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (ManifestResourceTable.RId)) {
- coll.Add (new ManifestResourceTable ());
- m_rows [ManifestResourceTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (NestedClassTable.RId)) {
- coll.Add (new NestedClassTable ());
- m_rows [NestedClassTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (GenericParamTable.RId)) {
- coll.Add (new GenericParamTable ());
- m_rows [GenericParamTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (MethodSpecTable.RId)) {
- coll.Add (new MethodSpecTable ());
- m_rows [MethodSpecTable.RId] = m_binaryReader.ReadInt32 ();
- }
- if (m_heap.HasTable (GenericParamConstraintTable.RId)) {
- coll.Add (new GenericParamConstraintTable ());
- m_rows [GenericParamConstraintTable.RId] = m_binaryReader.ReadInt32 ();
- }
- }
-
- public override void VisitAssemblyTable (AssemblyTable table)
- {
- int number = m_rows [AssemblyTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new AssemblyRow ());
- }
- public override void VisitAssemblyOSTable (AssemblyOSTable table)
- {
- int number = m_rows [AssemblyOSTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new AssemblyOSRow ());
- }
- public override void VisitAssemblyProcessorTable (AssemblyProcessorTable table)
- {
- int number = m_rows [AssemblyProcessorTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new AssemblyProcessorRow ());
- }
- public override void VisitAssemblyRefTable (AssemblyRefTable table)
- {
- int number = m_rows [AssemblyRefTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new AssemblyRefRow ());
- }
- public override void VisitAssemblyRefOSTable (AssemblyRefOSTable table)
- {
- int number = m_rows [AssemblyRefOSTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new AssemblyRefOSRow ());
- }
- public override void VisitAssemblyRefProcessorTable (AssemblyRefProcessorTable table)
- {
- int number = m_rows [AssemblyRefProcessorTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new AssemblyRefProcessorRow ());
- }
- public override void VisitClassLayoutTable (ClassLayoutTable table)
- {
- int number = m_rows [ClassLayoutTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new ClassLayoutRow ());
- }
- public override void VisitConstantTable (ConstantTable table)
- {
- int number = m_rows [ConstantTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new ConstantRow ());
- }
- public override void VisitCustomAttributeTable (CustomAttributeTable table)
- {
- int number = m_rows [CustomAttributeTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new CustomAttributeRow ());
- }
- public override void VisitDeclSecurityTable (DeclSecurityTable table)
- {
- int number = m_rows [DeclSecurityTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new DeclSecurityRow ());
- }
- public override void VisitEventTable (EventTable table)
- {
- int number = m_rows [EventTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new EventRow ());
- }
- public override void VisitEventMapTable (EventMapTable table)
- {
- int number = m_rows [EventMapTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new EventMapRow ());
- }
- public override void VisitEventPtrTable (EventPtrTable table)
- {
- int number = m_rows [EventPtrTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new EventPtrRow ());
- }
- public override void VisitExportedTypeTable (ExportedTypeTable table)
- {
- int number = m_rows [ExportedTypeTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new ExportedTypeRow ());
- }
- public override void VisitFieldTable (FieldTable table)
- {
- int number = m_rows [FieldTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new FieldRow ());
- }
- public override void VisitFieldLayoutTable (FieldLayoutTable table)
- {
- int number = m_rows [FieldLayoutTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new FieldLayoutRow ());
- }
- public override void VisitFieldMarshalTable (FieldMarshalTable table)
- {
- int number = m_rows [FieldMarshalTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new FieldMarshalRow ());
- }
- public override void VisitFieldPtrTable (FieldPtrTable table)
- {
- int number = m_rows [FieldPtrTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new FieldPtrRow ());
- }
- public override void VisitFieldRVATable (FieldRVATable table)
- {
- int number = m_rows [FieldRVATable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new FieldRVARow ());
- }
- public override void VisitFileTable (FileTable table)
- {
- int number = m_rows [FileTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new FileRow ());
- }
- public override void VisitGenericParamTable (GenericParamTable table)
- {
- int number = m_rows [GenericParamTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new GenericParamRow ());
- }
- public override void VisitGenericParamConstraintTable (GenericParamConstraintTable table)
- {
- int number = m_rows [GenericParamConstraintTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new GenericParamConstraintRow ());
- }
- public override void VisitImplMapTable (ImplMapTable table)
- {
- int number = m_rows [ImplMapTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new ImplMapRow ());
- }
- public override void VisitInterfaceImplTable (InterfaceImplTable table)
- {
- int number = m_rows [InterfaceImplTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new InterfaceImplRow ());
- }
- public override void VisitManifestResourceTable (ManifestResourceTable table)
- {
- int number = m_rows [ManifestResourceTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new ManifestResourceRow ());
- }
- public override void VisitMemberRefTable (MemberRefTable table)
- {
- int number = m_rows [MemberRefTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new MemberRefRow ());
- }
- public override void VisitMethodTable (MethodTable table)
- {
- int number = m_rows [MethodTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new MethodRow ());
- }
- public override void VisitMethodImplTable (MethodImplTable table)
- {
- int number = m_rows [MethodImplTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new MethodImplRow ());
- }
- public override void VisitMethodPtrTable (MethodPtrTable table)
- {
- int number = m_rows [MethodPtrTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new MethodPtrRow ());
- }
- public override void VisitMethodSemanticsTable (MethodSemanticsTable table)
- {
- int number = m_rows [MethodSemanticsTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new MethodSemanticsRow ());
- }
- public override void VisitMethodSpecTable (MethodSpecTable table)
- {
- int number = m_rows [MethodSpecTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new MethodSpecRow ());
- }
- public override void VisitModuleTable (ModuleTable table)
- {
- int number = m_rows [ModuleTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new ModuleRow ());
- }
- public override void VisitModuleRefTable (ModuleRefTable table)
- {
- int number = m_rows [ModuleRefTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new ModuleRefRow ());
- }
- public override void VisitNestedClassTable (NestedClassTable table)
- {
- int number = m_rows [NestedClassTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new NestedClassRow ());
- }
- public override void VisitParamTable (ParamTable table)
- {
- int number = m_rows [ParamTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new ParamRow ());
- }
- public override void VisitParamPtrTable (ParamPtrTable table)
- {
- int number = m_rows [ParamPtrTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new ParamPtrRow ());
- }
- public override void VisitPropertyTable (PropertyTable table)
- {
- int number = m_rows [PropertyTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new PropertyRow ());
- }
- public override void VisitPropertyMapTable (PropertyMapTable table)
- {
- int number = m_rows [PropertyMapTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new PropertyMapRow ());
- }
- public override void VisitPropertyPtrTable (PropertyPtrTable table)
- {
- int number = m_rows [PropertyPtrTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new PropertyPtrRow ());
- }
- public override void VisitStandAloneSigTable (StandAloneSigTable table)
- {
- int number = m_rows [StandAloneSigTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new StandAloneSigRow ());
- }
- public override void VisitTypeDefTable (TypeDefTable table)
- {
- int number = m_rows [TypeDefTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new TypeDefRow ());
- }
- public override void VisitTypeRefTable (TypeRefTable table)
- {
- int number = m_rows [TypeRefTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new TypeRefRow ());
- }
- public override void VisitTypeSpecTable (TypeSpecTable table)
- {
- int number = m_rows [TypeSpecTable.RId];
- table.Rows = new RowCollection (number);
- for (int i = 0; i < number; i++)
- table.Rows.Add (new TypeSpecRow ());
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableWriter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableWriter.cs
deleted file mode 100644
index 6c7fab4..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataTableWriter.cs
+++ /dev/null
@@ -1,602 +0,0 @@
-//
-// MetadataTableWriter.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Thu Feb 22 14:39:38 CET 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Binary;
-
- internal sealed class MetadataTableWriter : BaseMetadataTableVisitor {
-
- MetadataRoot m_root;
- TablesHeap m_heap;
- MetadataRowWriter m_mrrw;
- MemoryBinaryWriter m_binaryWriter;
-
- public MetadataTableWriter (MetadataWriter mrv, MemoryBinaryWriter writer)
- {
- m_root = mrv.GetMetadataRoot ();
- m_heap = m_root.Streams.TablesHeap;
- m_binaryWriter = writer;
- m_mrrw = new MetadataRowWriter (this);
- }
-
- public MetadataRoot GetMetadataRoot ()
- {
- return m_root;
- }
-
- public override IMetadataRowVisitor GetRowVisitor ()
- {
- return m_mrrw;
- }
-
- public MemoryBinaryWriter GetWriter ()
- {
- return m_binaryWriter;
- }
-
- void InitializeTable (IMetadataTable table)
- {
- table.Rows = new RowCollection ();
- m_heap.Valid |= 1L << table.Id;
- m_heap.Tables.Add (table);
- }
-
- void WriteCount (int rid)
- {
- if (m_heap.HasTable (rid))
- m_binaryWriter.Write (m_heap [rid].Rows.Count);
- }
-
- public AssemblyTable GetAssemblyTable ()
- {
- AssemblyTable table = m_heap [AssemblyTable.RId] as AssemblyTable;
- if (table != null)
- return table;
-
- table = new AssemblyTable ();
- InitializeTable (table);
- return table;
- }
-
- public AssemblyOSTable GetAssemblyOSTable ()
- {
- AssemblyOSTable table = m_heap [AssemblyOSTable.RId] as AssemblyOSTable;
- if (table != null)
- return table;
-
- table = new AssemblyOSTable ();
- InitializeTable (table);
- return table;
- }
-
- public AssemblyProcessorTable GetAssemblyProcessorTable ()
- {
- AssemblyProcessorTable table = m_heap [AssemblyProcessorTable.RId] as AssemblyProcessorTable;
- if (table != null)
- return table;
-
- table = new AssemblyProcessorTable ();
- InitializeTable (table);
- return table;
- }
-
- public AssemblyRefTable GetAssemblyRefTable ()
- {
- AssemblyRefTable table = m_heap [AssemblyRefTable.RId] as AssemblyRefTable;
- if (table != null)
- return table;
-
- table = new AssemblyRefTable ();
- InitializeTable (table);
- return table;
- }
-
- public AssemblyRefOSTable GetAssemblyRefOSTable ()
- {
- AssemblyRefOSTable table = m_heap [AssemblyRefOSTable.RId] as AssemblyRefOSTable;
- if (table != null)
- return table;
-
- table = new AssemblyRefOSTable ();
- InitializeTable (table);
- return table;
- }
-
- public AssemblyRefProcessorTable GetAssemblyRefProcessorTable ()
- {
- AssemblyRefProcessorTable table = m_heap [AssemblyRefProcessorTable.RId] as AssemblyRefProcessorTable;
- if (table != null)
- return table;
-
- table = new AssemblyRefProcessorTable ();
- InitializeTable (table);
- return table;
- }
-
- public ClassLayoutTable GetClassLayoutTable ()
- {
- ClassLayoutTable table = m_heap [ClassLayoutTable.RId] as ClassLayoutTable;
- if (table != null)
- return table;
-
- table = new ClassLayoutTable ();
- InitializeTable (table);
- return table;
- }
-
- public ConstantTable GetConstantTable ()
- {
- ConstantTable table = m_heap [ConstantTable.RId] as ConstantTable;
- if (table != null)
- return table;
-
- table = new ConstantTable ();
- InitializeTable (table);
- return table;
- }
-
- public CustomAttributeTable GetCustomAttributeTable ()
- {
- CustomAttributeTable table = m_heap [CustomAttributeTable.RId] as CustomAttributeTable;
- if (table != null)
- return table;
-
- table = new CustomAttributeTable ();
- InitializeTable (table);
- return table;
- }
-
- public DeclSecurityTable GetDeclSecurityTable ()
- {
- DeclSecurityTable table = m_heap [DeclSecurityTable.RId] as DeclSecurityTable;
- if (table != null)
- return table;
-
- table = new DeclSecurityTable ();
- InitializeTable (table);
- return table;
- }
-
- public EventTable GetEventTable ()
- {
- EventTable table = m_heap [EventTable.RId] as EventTable;
- if (table != null)
- return table;
-
- table = new EventTable ();
- InitializeTable (table);
- return table;
- }
-
- public EventMapTable GetEventMapTable ()
- {
- EventMapTable table = m_heap [EventMapTable.RId] as EventMapTable;
- if (table != null)
- return table;
-
- table = new EventMapTable ();
- InitializeTable (table);
- return table;
- }
-
- public EventPtrTable GetEventPtrTable ()
- {
- EventPtrTable table = m_heap [EventPtrTable.RId] as EventPtrTable;
- if (table != null)
- return table;
-
- table = new EventPtrTable ();
- InitializeTable (table);
- return table;
- }
-
- public ExportedTypeTable GetExportedTypeTable ()
- {
- ExportedTypeTable table = m_heap [ExportedTypeTable.RId] as ExportedTypeTable;
- if (table != null)
- return table;
-
- table = new ExportedTypeTable ();
- InitializeTable (table);
- return table;
- }
-
- public FieldTable GetFieldTable ()
- {
- FieldTable table = m_heap [FieldTable.RId] as FieldTable;
- if (table != null)
- return table;
-
- table = new FieldTable ();
- InitializeTable (table);
- return table;
- }
-
- public FieldLayoutTable GetFieldLayoutTable ()
- {
- FieldLayoutTable table = m_heap [FieldLayoutTable.RId] as FieldLayoutTable;
- if (table != null)
- return table;
-
- table = new FieldLayoutTable ();
- InitializeTable (table);
- return table;
- }
-
- public FieldMarshalTable GetFieldMarshalTable ()
- {
- FieldMarshalTable table = m_heap [FieldMarshalTable.RId] as FieldMarshalTable;
- if (table != null)
- return table;
-
- table = new FieldMarshalTable ();
- InitializeTable (table);
- return table;
- }
-
- public FieldPtrTable GetFieldPtrTable ()
- {
- FieldPtrTable table = m_heap [FieldPtrTable.RId] as FieldPtrTable;
- if (table != null)
- return table;
-
- table = new FieldPtrTable ();
- InitializeTable (table);
- return table;
- }
-
- public FieldRVATable GetFieldRVATable ()
- {
- FieldRVATable table = m_heap [FieldRVATable.RId] as FieldRVATable;
- if (table != null)
- return table;
-
- table = new FieldRVATable ();
- InitializeTable (table);
- return table;
- }
-
- public FileTable GetFileTable ()
- {
- FileTable table = m_heap [FileTable.RId] as FileTable;
- if (table != null)
- return table;
-
- table = new FileTable ();
- InitializeTable (table);
- return table;
- }
-
- public GenericParamTable GetGenericParamTable ()
- {
- GenericParamTable table = m_heap [GenericParamTable.RId] as GenericParamTable;
- if (table != null)
- return table;
-
- table = new GenericParamTable ();
- InitializeTable (table);
- return table;
- }
-
- public GenericParamConstraintTable GetGenericParamConstraintTable ()
- {
- GenericParamConstraintTable table = m_heap [GenericParamConstraintTable.RId] as GenericParamConstraintTable;
- if (table != null)
- return table;
-
- table = new GenericParamConstraintTable ();
- InitializeTable (table);
- return table;
- }
-
- public ImplMapTable GetImplMapTable ()
- {
- ImplMapTable table = m_heap [ImplMapTable.RId] as ImplMapTable;
- if (table != null)
- return table;
-
- table = new ImplMapTable ();
- InitializeTable (table);
- return table;
- }
-
- public InterfaceImplTable GetInterfaceImplTable ()
- {
- InterfaceImplTable table = m_heap [InterfaceImplTable.RId] as InterfaceImplTable;
- if (table != null)
- return table;
-
- table = new InterfaceImplTable ();
- InitializeTable (table);
- return table;
- }
-
- public ManifestResourceTable GetManifestResourceTable ()
- {
- ManifestResourceTable table = m_heap [ManifestResourceTable.RId] as ManifestResourceTable;
- if (table != null)
- return table;
-
- table = new ManifestResourceTable ();
- InitializeTable (table);
- return table;
- }
-
- public MemberRefTable GetMemberRefTable ()
- {
- MemberRefTable table = m_heap [MemberRefTable.RId] as MemberRefTable;
- if (table != null)
- return table;
-
- table = new MemberRefTable ();
- InitializeTable (table);
- return table;
- }
-
- public MethodTable GetMethodTable ()
- {
- MethodTable table = m_heap [MethodTable.RId] as MethodTable;
- if (table != null)
- return table;
-
- table = new MethodTable ();
- InitializeTable (table);
- return table;
- }
-
- public MethodImplTable GetMethodImplTable ()
- {
- MethodImplTable table = m_heap [MethodImplTable.RId] as MethodImplTable;
- if (table != null)
- return table;
-
- table = new MethodImplTable ();
- InitializeTable (table);
- return table;
- }
-
- public MethodPtrTable GetMethodPtrTable ()
- {
- MethodPtrTable table = m_heap [MethodPtrTable.RId] as MethodPtrTable;
- if (table != null)
- return table;
-
- table = new MethodPtrTable ();
- InitializeTable (table);
- return table;
- }
-
- public MethodSemanticsTable GetMethodSemanticsTable ()
- {
- MethodSemanticsTable table = m_heap [MethodSemanticsTable.RId] as MethodSemanticsTable;
- if (table != null)
- return table;
-
- table = new MethodSemanticsTable ();
- InitializeTable (table);
- return table;
- }
-
- public MethodSpecTable GetMethodSpecTable ()
- {
- MethodSpecTable table = m_heap [MethodSpecTable.RId] as MethodSpecTable;
- if (table != null)
- return table;
-
- table = new MethodSpecTable ();
- InitializeTable (table);
- return table;
- }
-
- public ModuleTable GetModuleTable ()
- {
- ModuleTable table = m_heap [ModuleTable.RId] as ModuleTable;
- if (table != null)
- return table;
-
- table = new ModuleTable ();
- InitializeTable (table);
- return table;
- }
-
- public ModuleRefTable GetModuleRefTable ()
- {
- ModuleRefTable table = m_heap [ModuleRefTable.RId] as ModuleRefTable;
- if (table != null)
- return table;
-
- table = new ModuleRefTable ();
- InitializeTable (table);
- return table;
- }
-
- public NestedClassTable GetNestedClassTable ()
- {
- NestedClassTable table = m_heap [NestedClassTable.RId] as NestedClassTable;
- if (table != null)
- return table;
-
- table = new NestedClassTable ();
- InitializeTable (table);
- return table;
- }
-
- public ParamTable GetParamTable ()
- {
- ParamTable table = m_heap [ParamTable.RId] as ParamTable;
- if (table != null)
- return table;
-
- table = new ParamTable ();
- InitializeTable (table);
- return table;
- }
-
- public ParamPtrTable GetParamPtrTable ()
- {
- ParamPtrTable table = m_heap [ParamPtrTable.RId] as ParamPtrTable;
- if (table != null)
- return table;
-
- table = new ParamPtrTable ();
- InitializeTable (table);
- return table;
- }
-
- public PropertyTable GetPropertyTable ()
- {
- PropertyTable table = m_heap [PropertyTable.RId] as PropertyTable;
- if (table != null)
- return table;
-
- table = new PropertyTable ();
- InitializeTable (table);
- return table;
- }
-
- public PropertyMapTable GetPropertyMapTable ()
- {
- PropertyMapTable table = m_heap [PropertyMapTable.RId] as PropertyMapTable;
- if (table != null)
- return table;
-
- table = new PropertyMapTable ();
- InitializeTable (table);
- return table;
- }
-
- public PropertyPtrTable GetPropertyPtrTable ()
- {
- PropertyPtrTable table = m_heap [PropertyPtrTable.RId] as PropertyPtrTable;
- if (table != null)
- return table;
-
- table = new PropertyPtrTable ();
- InitializeTable (table);
- return table;
- }
-
- public StandAloneSigTable GetStandAloneSigTable ()
- {
- StandAloneSigTable table = m_heap [StandAloneSigTable.RId] as StandAloneSigTable;
- if (table != null)
- return table;
-
- table = new StandAloneSigTable ();
- InitializeTable (table);
- return table;
- }
-
- public TypeDefTable GetTypeDefTable ()
- {
- TypeDefTable table = m_heap [TypeDefTable.RId] as TypeDefTable;
- if (table != null)
- return table;
-
- table = new TypeDefTable ();
- InitializeTable (table);
- return table;
- }
-
- public TypeRefTable GetTypeRefTable ()
- {
- TypeRefTable table = m_heap [TypeRefTable.RId] as TypeRefTable;
- if (table != null)
- return table;
-
- table = new TypeRefTable ();
- InitializeTable (table);
- return table;
- }
-
- public TypeSpecTable GetTypeSpecTable ()
- {
- TypeSpecTable table = m_heap [TypeSpecTable.RId] as TypeSpecTable;
- if (table != null)
- return table;
-
- table = new TypeSpecTable ();
- InitializeTable (table);
- return table;
- }
-
- public override void VisitTableCollection (TableCollection coll)
- {
- WriteCount (ModuleTable.RId);
- WriteCount (TypeRefTable.RId);
- WriteCount (TypeDefTable.RId);
- WriteCount (FieldPtrTable.RId);
- WriteCount (FieldTable.RId);
- WriteCount (MethodPtrTable.RId);
- WriteCount (MethodTable.RId);
- WriteCount (ParamPtrTable.RId);
- WriteCount (ParamTable.RId);
- WriteCount (InterfaceImplTable.RId);
- WriteCount (MemberRefTable.RId);
- WriteCount (ConstantTable.RId);
- WriteCount (CustomAttributeTable.RId);
- WriteCount (FieldMarshalTable.RId);
- WriteCount (DeclSecurityTable.RId);
- WriteCount (ClassLayoutTable.RId);
- WriteCount (FieldLayoutTable.RId);
- WriteCount (StandAloneSigTable.RId);
- WriteCount (EventMapTable.RId);
- WriteCount (EventPtrTable.RId);
- WriteCount (EventTable.RId);
- WriteCount (PropertyMapTable.RId);
- WriteCount (PropertyPtrTable.RId);
- WriteCount (PropertyTable.RId);
- WriteCount (MethodSemanticsTable.RId);
- WriteCount (MethodImplTable.RId);
- WriteCount (ModuleRefTable.RId);
- WriteCount (TypeSpecTable.RId);
- WriteCount (ImplMapTable.RId);
- WriteCount (FieldRVATable.RId);
- WriteCount (AssemblyTable.RId);
- WriteCount (AssemblyProcessorTable.RId);
- WriteCount (AssemblyOSTable.RId);
- WriteCount (AssemblyRefTable.RId);
- WriteCount (AssemblyRefProcessorTable.RId);
- WriteCount (AssemblyRefOSTable.RId);
- WriteCount (FileTable.RId);
- WriteCount (ExportedTypeTable.RId);
- WriteCount (ManifestResourceTable.RId);
- WriteCount (NestedClassTable.RId);
- WriteCount (GenericParamTable.RId);
- WriteCount (MethodSpecTable.RId);
- WriteCount (GenericParamConstraintTable.RId);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataToken.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataToken.cs
index d584fed..8c1338e 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataToken.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataToken.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,55 +26,62 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil.Metadata {
+namespace Mono.Cecil {
public struct MetadataToken {
- uint m_rid;
- TokenType m_type;
+ readonly uint token;
- public uint RID {
- get { return m_rid; }
+ public uint RID {
+ get { return token & 0x00ffffff; }
}
public TokenType TokenType {
- get { return m_type; }
+ get { return (TokenType) (token & 0xff000000); }
}
- public static readonly MetadataToken Zero = new MetadataToken ((TokenType) 0, 0);
+ public static readonly MetadataToken Zero = new MetadataToken ((uint) 0);
- public MetadataToken (int token)
+ public MetadataToken (uint token)
{
- m_type = (TokenType) (token & 0xff000000);
- m_rid = (uint) token & 0x00ffffff;
+ this.token = token;
}
- public MetadataToken (TokenType table, uint rid)
+ public MetadataToken (TokenType type)
+ : this (type, 0)
{
- m_type = table;
- m_rid = rid;
}
- internal static MetadataToken FromMetadataRow (TokenType table, int rowIndex)
+ public MetadataToken (TokenType type, uint rid)
{
- return new MetadataToken (table, (uint) rowIndex + 1);
+ token = (uint) type | rid;
}
- public uint ToUInt ()
+ public MetadataToken (TokenType type, int rid)
{
- return (uint) m_type | m_rid;
+ token = (uint) type | (uint) rid;
+ }
+
+ public int ToInt32 ()
+ {
+ return (int) token;
+ }
+
+ public uint ToUInt32 ()
+ {
+ return token;
}
public override int GetHashCode ()
{
- return (int) ToUInt ();
+ return (int) token;
}
- public override bool Equals (object other)
+ public override bool Equals (object obj)
{
- if (other is MetadataToken) {
- MetadataToken o = (MetadataToken) other;
- return o.m_rid == m_rid && o.m_type == m_type;
+ if (obj is MetadataToken) {
+ var other = (MetadataToken) obj;
+ return other.token == token;
}
return false;
@@ -82,18 +89,17 @@ namespace Mono.Cecil.Metadata {
public static bool operator == (MetadataToken one, MetadataToken other)
{
- return one.Equals (other);
+ return one.token == other.token;
}
public static bool operator != (MetadataToken one, MetadataToken other)
{
- return !one.Equals (other);
+ return one.token != other.token;
}
public override string ToString ()
{
- return string.Format ("{0} [0x{1}]",
- m_type, m_rid.ToString ("x4"));
+ return string.Format ("[{0}:0x{1}]", TokenType, RID.ToString ("x4"));
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataWriter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataWriter.cs
deleted file mode 100644
index e872af2..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataWriter.cs
+++ /dev/null
@@ -1,506 +0,0 @@
-//
-// MetadataWriter.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.Collections;
- using System.IO;
- using System.Text;
-
- using Mono.Cecil;
- using Mono.Cecil.Binary;
-
- internal sealed class MetadataWriter : BaseMetadataVisitor {
-
- AssemblyDefinition m_assembly;
- MetadataRoot m_root;
- TargetRuntime m_runtime;
- ImageWriter m_imgWriter;
- MetadataTableWriter m_tableWriter;
- MemoryBinaryWriter m_binaryWriter;
-
- IDictionary m_stringCache;
- MemoryBinaryWriter m_stringWriter;
-
- IDictionary m_guidCache;
- MemoryBinaryWriter m_guidWriter;
-
- IDictionary m_usCache;
- MemoryBinaryWriter m_usWriter;
-
- IDictionary m_blobCache;
- MemoryBinaryWriter m_blobWriter;
-
- MemoryBinaryWriter m_tWriter;
-
- MemoryBinaryWriter m_cilWriter;
-
- MemoryBinaryWriter m_fieldDataWriter;
- MemoryBinaryWriter m_resWriter;
-
- uint m_mdStart, m_mdSize;
- uint m_resStart, m_resSize;
- uint m_snsStart, m_snsSize;
- uint m_debugHeaderStart;
- uint m_imporTableStart;
-
- uint m_entryPointToken;
-
- RVA m_cursor = new RVA (0x2050);
-
- public MemoryBinaryWriter CilWriter {
- get { return m_cilWriter; }
- }
-
- public uint DebugHeaderPosition {
- get { return m_debugHeaderStart; }
- }
-
- public uint ImportTablePosition {
- get { return m_imporTableStart; }
- }
-
- public uint EntryPointToken {
- get { return m_entryPointToken; }
- set { m_entryPointToken = value; }
- }
-
- public MetadataWriter (AssemblyDefinition asm, MetadataRoot root,
- AssemblyKind kind, TargetRuntime rt, BinaryWriter writer)
- {
- m_assembly = asm;
- m_root = root;
- m_runtime = rt;
- m_imgWriter = new ImageWriter (this, kind, writer);
- m_binaryWriter = m_imgWriter.GetTextWriter ();
-
- m_stringCache = new Hashtable ();
- m_stringWriter = new MemoryBinaryWriter (Encoding.UTF8);
- m_stringWriter.Write ((byte) 0);
-
- m_guidCache = new Hashtable ();
- m_guidWriter = new MemoryBinaryWriter ();
-
- m_usCache = new Hashtable ();
- m_usWriter = new MemoryBinaryWriter (Encoding.Unicode);
- m_usWriter.Write ((byte) 0);
-
- m_blobCache = new Hashtable ();
- m_blobWriter = new MemoryBinaryWriter ();
- m_blobWriter.Write ((byte) 0);
-
- m_tWriter = new MemoryBinaryWriter ();
- m_tableWriter = new MetadataTableWriter (this, m_tWriter);
-
- m_cilWriter = new MemoryBinaryWriter ();
-
- m_fieldDataWriter = new MemoryBinaryWriter ();
- m_resWriter = new MemoryBinaryWriter ();
- }
-
- public MetadataRoot GetMetadataRoot ()
- {
- return m_root;
- }
-
- public ImageWriter GetImageWriter ()
- {
- return m_imgWriter;
- }
-
- public MemoryBinaryWriter GetWriter ()
- {
- return m_binaryWriter;
- }
-
- public MetadataTableWriter GetTableVisitor ()
- {
- return m_tableWriter;
- }
-
- public void AddData (int length)
- {
- m_cursor += new RVA ((uint) length);
- }
-
- public RVA GetDataCursor ()
- {
- return m_cursor;
- }
-
- public uint AddString (string str)
- {
- if (str == null || str.Length == 0)
- return 0;
-
- if (m_stringCache.Contains (str))
- return (uint) m_stringCache [str];
-
- uint pointer = (uint) m_stringWriter.BaseStream.Position;
- m_stringCache [str] = pointer;
- m_stringWriter.Write (Encoding.UTF8.GetBytes (str));
- m_stringWriter.Write ('\0');
- return pointer;
- }
-
- public uint AddBlob (byte [] data)
- {
- if (data == null || data.Length == 0)
- return 0;
-
- // using CompactFramework compatible version of
- // Convert.ToBase64String
- string key = Convert.ToBase64String (data, 0, data.Length);
- if (m_blobCache.Contains (key))
- return (uint) m_blobCache [key];
-
- uint pointer = (uint) m_blobWriter.BaseStream.Position;
- m_blobCache [key] = pointer;
- Utilities.WriteCompressedInteger (m_blobWriter, data.Length);
- m_blobWriter.Write (data);
- return pointer;
- }
-
- public uint AddGuid (Guid g)
- {
- if (m_guidCache.Contains (g))
- return (uint) m_guidCache [g];
-
- uint pointer = (uint) m_guidWriter.BaseStream.Position;
- m_guidCache [g] = pointer;
- m_guidWriter.Write (g.ToByteArray ());
- return pointer + 1;
- }
-
- public uint AddUserString (string str)
- {
- if (str == null)
- return 0;
-
- if (m_usCache.Contains (str))
- return (uint) m_usCache [str];
-
- uint pointer = (uint) m_usWriter.BaseStream.Position;
- m_usCache [str] = pointer;
- byte [] us = Encoding.Unicode.GetBytes (str);
- Utilities.WriteCompressedInteger (m_usWriter, us.Length + 1);
- m_usWriter.Write (us);
- m_usWriter.Write ((byte) (RequiresSpecialHandling (us) ? 1 : 0));
- return pointer;
- }
-
- static bool RequiresSpecialHandling (byte [] chars)
- {
- for (int i = 0; i < chars.Length; i++) {
- byte c = chars [i];
- if ((i % 2) == 1)
- if (c != 0)
- return true;
-
- if (InRange (0x01, 0x08, c) ||
- InRange (0x0e, 0x1f, c) ||
- c == 0x27 ||
- c == 0x2d ||
- c == 0x7f) {
-
- return true;
- }
- }
-
- return false;
- }
-
- static bool InRange (int left, int right, int value)
- {
- return left <= value && value <= right;
- }
-
- void CreateStream (string name)
- {
- MetadataStream stream = new MetadataStream ();
- stream.Header.Name = name;
- stream.Heap = MetadataHeap.HeapFactory (stream);
- m_root.Streams.Add (stream);
- }
-
- void SetHeapSize (MetadataHeap heap, MemoryBinaryWriter data, byte flag)
- {
- if (data.BaseStream.Length > 65536) {
- m_root.Streams.TablesHeap.HeapSizes |= flag;
- heap.IndexSize = 4;
- } else
- heap.IndexSize = 2;
- }
-
- public uint AddResource (byte [] data)
- {
- uint offset = (uint) m_resWriter.BaseStream.Position;
- m_resWriter.Write (data.Length);
- m_resWriter.Write (data);
- m_resWriter.QuadAlign ();
- return offset;
- }
-
- public void AddFieldInitData (byte [] data)
- {
- m_fieldDataWriter.Write (data);
- m_fieldDataWriter.QuadAlign ();
- }
-
- uint GetStrongNameSignatureSize ()
- {
- if (m_assembly.Name.PublicKey != null) {
- // in fx 2.0 the key may be from 384 to 16384 bits
- // so we must calculate the signature size based on
- // the size of the public key (minus the 32 byte header)
- int size = m_assembly.Name.PublicKey.Length;
- if (size > 32)
- return (uint) (size - 32);
- // note: size == 16 for the ECMA "key" which is replaced
- // by the runtime with a 1024 bits key (128 bytes)
- }
- return 128; // default strongname signature size
- }
-
- public override void VisitMetadataRoot (MetadataRoot root)
- {
- WriteMemStream (m_cilWriter);
- WriteMemStream (m_fieldDataWriter);
- m_resStart = (uint) m_binaryWriter.BaseStream.Position;
- WriteMemStream (m_resWriter);
- m_resSize = (uint) (m_binaryWriter.BaseStream.Position - m_resStart);
-
- // for now, we only reserve the place for the strong name signature
- if ((m_assembly.Name.Flags & AssemblyFlags.PublicKey) > 0) {
- m_snsStart = (uint) m_binaryWriter.BaseStream.Position;
- m_snsSize = GetStrongNameSignatureSize ();
- m_binaryWriter.Write (new byte [m_snsSize]);
- m_binaryWriter.QuadAlign ();
- }
-
- // save place for debug header
- if (m_imgWriter.GetImage ().DebugHeader != null) {
- m_debugHeaderStart = (uint) m_binaryWriter.BaseStream.Position;
- m_binaryWriter.Write (new byte [m_imgWriter.GetImage ().DebugHeader.GetSize ()]);
- m_binaryWriter.QuadAlign ();
- }
-
- m_mdStart = (uint) m_binaryWriter.BaseStream.Position;
-
- if (m_stringWriter.BaseStream.Length > 1) {
- CreateStream (MetadataStream.Strings);
- SetHeapSize (root.Streams.StringsHeap, m_stringWriter, 0x01);
- m_stringWriter.QuadAlign ();
- }
-
- if (m_guidWriter.BaseStream.Length > 0) {
- CreateStream (MetadataStream.GUID);
- SetHeapSize (root.Streams.GuidHeap, m_guidWriter, 0x02);
- }
-
- if (m_blobWriter.BaseStream.Length > 1) {
- CreateStream (MetadataStream.Blob);
- SetHeapSize (root.Streams.BlobHeap, m_blobWriter, 0x04);
- m_blobWriter.QuadAlign ();
- }
-
- if (m_usWriter.BaseStream.Length > 2) {
- CreateStream (MetadataStream.UserStrings);
- m_usWriter.QuadAlign ();
- }
-
- m_root.Header.MajorVersion = 1;
- m_root.Header.MinorVersion = 1;
-
- switch (m_runtime) {
- case TargetRuntime.NET_1_0 :
- m_root.Header.Version = "v1.0.3705";
- break;
- case TargetRuntime.NET_1_1 :
- m_root.Header.Version = "v1.1.4322";
- break;
- case TargetRuntime.NET_2_0 :
- m_root.Header.Version = "v2.0.50727";
- break;
- }
-
- m_root.Streams.TablesHeap.Tables.Accept (m_tableWriter);
-
- if (m_tWriter.BaseStream.Length == 0)
- m_root.Streams.Remove (m_root.Streams.TablesHeap.GetStream ());
- }
-
- public override void VisitMetadataRootHeader (MetadataRoot.MetadataRootHeader header)
- {
- m_binaryWriter.Write (header.Signature);
- m_binaryWriter.Write (header.MajorVersion);
- m_binaryWriter.Write (header.MinorVersion);
- m_binaryWriter.Write (header.Reserved);
- m_binaryWriter.Write (header.Version.Length + 3 & (~3));
- m_binaryWriter.Write (Encoding.ASCII.GetBytes (header.Version));
- m_binaryWriter.QuadAlign ();
- m_binaryWriter.Write (header.Flags);
- m_binaryWriter.Write ((ushort) m_root.Streams.Count);
- }
-
- public override void VisitMetadataStreamCollection (MetadataStreamCollection streams)
- {
- foreach (MetadataStream stream in streams) {
- MetadataStream.MetadataStreamHeader header = stream.Header;
-
- header.Offset = (uint) (m_binaryWriter.BaseStream.Position);
- m_binaryWriter.Write (header.Offset);
- MemoryBinaryWriter container;
- string name = header.Name;
- uint size = 0;
- switch (header.Name) {
- case MetadataStream.Tables :
- container = m_tWriter;
- size += 24; // header
- break;
- case MetadataStream.Strings :
- name += "\0\0\0\0";
- container = m_stringWriter;
- break;
- case MetadataStream.GUID :
- container = m_guidWriter;
- break;
- case MetadataStream.Blob :
- container = m_blobWriter;
- break;
- case MetadataStream.UserStrings :
- container = m_usWriter;
- break;
- default :
- throw new MetadataFormatException ("Unknown stream kind");
- }
-
- size += (uint) (container.BaseStream.Length + 3 & (~3));
- m_binaryWriter.Write (size);
- m_binaryWriter.Write (Encoding.ASCII.GetBytes (name));
- m_binaryWriter.QuadAlign ();
- }
- }
-
- void WriteMemStream (MemoryBinaryWriter writer)
- {
- m_binaryWriter.Write (writer);
- m_binaryWriter.QuadAlign ();
- }
-
- void PatchStreamHeaderOffset (MetadataHeap heap)
- {
- long pos = m_binaryWriter.BaseStream.Position;
- m_binaryWriter.BaseStream.Position = heap.GetStream ().Header.Offset;
- m_binaryWriter.Write ((uint) (pos - m_mdStart));
- m_binaryWriter.BaseStream.Position = pos;
- }
-
- public override void VisitGuidHeap (GuidHeap heap)
- {
- PatchStreamHeaderOffset (heap);
- WriteMemStream (m_guidWriter);
- }
-
- public override void VisitStringsHeap (StringsHeap heap)
- {
- PatchStreamHeaderOffset (heap);
- WriteMemStream (m_stringWriter);
- }
-
- public override void VisitTablesHeap (TablesHeap heap)
- {
- PatchStreamHeaderOffset (heap);
- m_binaryWriter.Write (heap.Reserved);
- switch (m_runtime) {
- case TargetRuntime.NET_1_0 :
- case TargetRuntime.NET_1_1 :
- heap.MajorVersion = 1;
- heap.MinorVersion = 0;
- break;
- case TargetRuntime.NET_2_0 :
- heap.MajorVersion = 2;
- heap.MinorVersion = 0;
- break;
- }
- m_binaryWriter.Write (heap.MajorVersion);
- m_binaryWriter.Write (heap.MinorVersion);
- m_binaryWriter.Write (heap.HeapSizes);
- m_binaryWriter.Write (heap.Reserved2);
- m_binaryWriter.Write (heap.Valid);
- m_binaryWriter.Write (heap.Sorted);
- WriteMemStream (m_tWriter);
- }
-
- public override void VisitBlobHeap (BlobHeap heap)
- {
- PatchStreamHeaderOffset (heap);
- WriteMemStream (m_blobWriter);
- }
-
- public override void VisitUserStringsHeap (UserStringsHeap heap)
- {
- PatchStreamHeaderOffset (heap);
- WriteMemStream (m_usWriter);
- }
-
- void PatchHeader ()
- {
- Image img = m_imgWriter.GetImage ();
-
- img.CLIHeader.EntryPointToken = m_entryPointToken;
-
- if (m_mdSize > 0)
- img.CLIHeader.Metadata = new DataDirectory (
- img.TextSection.VirtualAddress + m_mdStart, m_imporTableStart - m_mdStart);
-
- if (m_resSize > 0)
- img.CLIHeader.Resources = new DataDirectory (
- img.TextSection.VirtualAddress + m_resStart, m_resSize);
-
- if (m_snsStart > 0)
- img.CLIHeader.StrongNameSignature = new DataDirectory (
- img.TextSection.VirtualAddress + m_snsStart, m_snsSize);
-
- if (m_debugHeaderStart > 0)
- img.PEOptionalHeader.DataDirectories.Debug = new DataDirectory (
- img.TextSection.VirtualAddress + m_debugHeaderStart, 0x1c);
- }
-
- public override void TerminateMetadataRoot (MetadataRoot root)
- {
- m_mdSize = (uint) (m_binaryWriter.BaseStream.Position - m_mdStart);
- m_imporTableStart = (uint) m_binaryWriter.BaseStream.Position;
- m_binaryWriter.Write (new byte [0x60]); // imports
- m_imgWriter.Initialize ();
- PatchHeader ();
- root.GetImage ().Accept (m_imgWriter);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Method.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Method.cs
deleted file mode 100644
index 3d195bc..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Method.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-//
-// MethodTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil;
-
- using Mono.Cecil.Binary;
-
- public sealed class MethodTable : IMetadataTable {
-
- public const int RId = 0x06;
-
- RowCollection m_rows;
-
- public MethodRow this [int index] {
- get { return m_rows [index] as MethodRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal MethodTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitMethodTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class MethodRow : IMetadataRow {
-
- public RVA RVA;
- public MethodImplAttributes ImplFlags;
- public MethodAttributes Flags;
- public uint Name;
- public uint Signature;
- public uint ParamList;
-
- internal MethodRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitMethodRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodImpl.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodImpl.cs
deleted file mode 100644
index fa9a9d2..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodImpl.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-//
-// MethodImplTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class MethodImplTable : IMetadataTable {
-
- public const int RId = 0x19;
-
- RowCollection m_rows;
-
- public MethodImplRow this [int index] {
- get { return m_rows [index] as MethodImplRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal MethodImplTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitMethodImplTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class MethodImplRow : IMetadataRow {
-
- public uint Class;
- public MetadataToken MethodBody;
- public MetadataToken MethodDeclaration;
-
- internal MethodImplRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitMethodImplRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodPtr.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodPtr.cs
deleted file mode 100644
index 7a81b88..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodPtr.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// MethodPtrTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Thu Feb 22 14:39:38 CET 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class MethodPtrTable : IMetadataTable {
-
- public const int RId = 0x05;
-
- RowCollection m_rows;
-
- public MethodPtrRow this [int index] {
- get { return m_rows [index] as MethodPtrRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal MethodPtrTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitMethodPtrTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class MethodPtrRow : IMetadataRow {
-
- public uint Method;
-
- internal MethodPtrRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitMethodPtrRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSemantics.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSemantics.cs
deleted file mode 100644
index c1dd175..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSemantics.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-//
-// MethodSemanticsTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil;
-
- public sealed class MethodSemanticsTable : IMetadataTable {
-
- public const int RId = 0x18;
-
- RowCollection m_rows;
-
- public MethodSemanticsRow this [int index] {
- get { return m_rows [index] as MethodSemanticsRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal MethodSemanticsTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitMethodSemanticsTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class MethodSemanticsRow : IMetadataRow {
-
- public MethodSemanticsAttributes Semantics;
- public uint Method;
- public MetadataToken Association;
-
- internal MethodSemanticsRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitMethodSemanticsRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSpec.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSpec.cs
deleted file mode 100644
index dc5a61d..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MethodSpec.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// MethodSpecTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class MethodSpecTable : IMetadataTable {
-
- public const int RId = 0x2b;
-
- RowCollection m_rows;
-
- public MethodSpecRow this [int index] {
- get { return m_rows [index] as MethodSpecRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal MethodSpecTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitMethodSpecTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class MethodSpecRow : IMetadataRow {
-
- public MetadataToken Method;
- public uint Instantiation;
-
- internal MethodSpecRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitMethodSpecRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Module.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Module.cs
deleted file mode 100644
index be06b96..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Module.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-//
-// ModuleTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class ModuleTable : IMetadataTable {
-
- public const int RId = 0x00;
-
- RowCollection m_rows;
-
- public ModuleRow this [int index] {
- get { return m_rows [index] as ModuleRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal ModuleTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitModuleTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class ModuleRow : IMetadataRow {
-
- public ushort Generation;
- public uint Name;
- public uint Mvid;
- public uint EncId;
- public uint EncBaseId;
-
- internal ModuleRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitModuleRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ModuleRef.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ModuleRef.cs
deleted file mode 100644
index fd88991..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ModuleRef.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// ModuleRefTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class ModuleRefTable : IMetadataTable {
-
- public const int RId = 0x1a;
-
- RowCollection m_rows;
-
- public ModuleRefRow this [int index] {
- get { return m_rows [index] as ModuleRefRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal ModuleRefTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitModuleRefTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class ModuleRefRow : IMetadataRow {
-
- public uint Name;
-
- internal ModuleRefRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitModuleRefRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/NestedClass.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/NestedClass.cs
deleted file mode 100644
index 9920a64..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/NestedClass.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// NestedClassTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class NestedClassTable : IMetadataTable {
-
- public const int RId = 0x29;
-
- RowCollection m_rows;
-
- public NestedClassRow this [int index] {
- get { return m_rows [index] as NestedClassRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal NestedClassTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitNestedClassTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class NestedClassRow : IMetadataRow {
-
- public uint NestedClass;
- public uint EnclosingClass;
-
- internal NestedClassRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitNestedClassRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Param.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Param.cs
deleted file mode 100644
index 5704ce6..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Param.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-//
-// ParamTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil;
-
- public sealed class ParamTable : IMetadataTable {
-
- public const int RId = 0x08;
-
- RowCollection m_rows;
-
- public ParamRow this [int index] {
- get { return m_rows [index] as ParamRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal ParamTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitParamTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class ParamRow : IMetadataRow {
-
- public ParameterAttributes Flags;
- public ushort Sequence;
- public uint Name;
-
- internal ParamRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitParamRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ParamPtr.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ParamPtr.cs
deleted file mode 100644
index ffba322..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/ParamPtr.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// ParamPtrTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Thu Feb 22 14:39:38 CET 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class ParamPtrTable : IMetadataTable {
-
- public const int RId = 0x07;
-
- RowCollection m_rows;
-
- public ParamPtrRow this [int index] {
- get { return m_rows [index] as ParamPtrRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal ParamPtrTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitParamPtrTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class ParamPtrRow : IMetadataRow {
-
- public uint Param;
-
- internal ParamPtrRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitParamPtrRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Property.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Property.cs
deleted file mode 100644
index 5f3bcc9..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Property.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-//
-// PropertyTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil;
-
- public sealed class PropertyTable : IMetadataTable {
-
- public const int RId = 0x17;
-
- RowCollection m_rows;
-
- public PropertyRow this [int index] {
- get { return m_rows [index] as PropertyRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal PropertyTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitPropertyTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class PropertyRow : IMetadataRow {
-
- public PropertyAttributes Flags;
- public uint Name;
- public uint Type;
-
- internal PropertyRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitPropertyRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyMap.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyMap.cs
deleted file mode 100644
index 5a3b13c..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyMap.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// PropertyMapTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class PropertyMapTable : IMetadataTable {
-
- public const int RId = 0x15;
-
- RowCollection m_rows;
-
- public PropertyMapRow this [int index] {
- get { return m_rows [index] as PropertyMapRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal PropertyMapTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitPropertyMapTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class PropertyMapRow : IMetadataRow {
-
- public uint Parent;
- public uint PropertyList;
-
- internal PropertyMapRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitPropertyMapRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyPtr.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyPtr.cs
deleted file mode 100644
index f767757..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/PropertyPtr.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// PropertyPtrTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Thu Feb 22 14:39:38 CET 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class PropertyPtrTable : IMetadataTable {
-
- public const int RId = 0x16;
-
- RowCollection m_rows;
-
- public PropertyPtrRow this [int index] {
- get { return m_rows [index] as PropertyPtrRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal PropertyPtrTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitPropertyPtrTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class PropertyPtrRow : IMetadataRow {
-
- public uint Property;
-
- internal PropertyPtrRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitPropertyPtrRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Row.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Row.cs
new file mode 100644
index 0000000..ab491a6
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Row.cs
@@ -0,0 +1,170 @@
+//
+// Row.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections.Generic;
+
+namespace Mono.Cecil.Metadata {
+
+ struct Row<T1, T2> {
+ internal T1 Col1;
+ internal T2 Col2;
+
+ public Row (T1 col1, T2 col2)
+ {
+ Col1 = col1;
+ Col2 = col2;
+ }
+ }
+
+ struct Row<T1, T2, T3> {
+ internal T1 Col1;
+ internal T2 Col2;
+ internal T3 Col3;
+
+ public Row (T1 col1, T2 col2, T3 col3)
+ {
+ Col1 = col1;
+ Col2 = col2;
+ Col3 = col3;
+ }
+ }
+
+ struct Row<T1, T2, T3, T4> {
+ internal T1 Col1;
+ internal T2 Col2;
+ internal T3 Col3;
+ internal T4 Col4;
+
+ public Row (T1 col1, T2 col2, T3 col3, T4 col4)
+ {
+ Col1 = col1;
+ Col2 = col2;
+ Col3 = col3;
+ Col4 = col4;
+ }
+ }
+
+ struct Row<T1, T2, T3, T4, T5> {
+ internal T1 Col1;
+ internal T2 Col2;
+ internal T3 Col3;
+ internal T4 Col4;
+ internal T5 Col5;
+
+ public Row (T1 col1, T2 col2, T3 col3, T4 col4, T5 col5)
+ {
+ Col1 = col1;
+ Col2 = col2;
+ Col3 = col3;
+ Col4 = col4;
+ Col5 = col5;
+ }
+ }
+
+ struct Row<T1, T2, T3, T4, T5, T6> {
+ internal T1 Col1;
+ internal T2 Col2;
+ internal T3 Col3;
+ internal T4 Col4;
+ internal T5 Col5;
+ internal T6 Col6;
+
+ public Row (T1 col1, T2 col2, T3 col3, T4 col4, T5 col5, T6 col6)
+ {
+ Col1 = col1;
+ Col2 = col2;
+ Col3 = col3;
+ Col4 = col4;
+ Col5 = col5;
+ Col6 = col6;
+ }
+ }
+
+ struct Row<T1, T2, T3, T4, T5, T6, T7, T8, T9> {
+ internal T1 Col1;
+ internal T2 Col2;
+ internal T3 Col3;
+ internal T4 Col4;
+ internal T5 Col5;
+ internal T6 Col6;
+ internal T7 Col7;
+ internal T8 Col8;
+ internal T9 Col9;
+
+ public Row (T1 col1, T2 col2, T3 col3, T4 col4, T5 col5, T6 col6, T7 col7, T8 col8, T9 col9)
+ {
+ Col1 = col1;
+ Col2 = col2;
+ Col3 = col3;
+ Col4 = col4;
+ Col5 = col5;
+ Col6 = col6;
+ Col7 = col7;
+ Col8 = col8;
+ Col9 = col9;
+ }
+ }
+
+ sealed class RowEqualityComparer : IEqualityComparer<Row<string, string>>, IEqualityComparer<Row<uint, uint>>, IEqualityComparer<Row<uint, uint, uint>> {
+
+ public bool Equals (Row<string, string> x, Row<string, string> y)
+ {
+ return x.Col1 == y.Col1
+ && x.Col2 == y.Col2;
+ }
+
+ public int GetHashCode (Row<string, string> obj)
+ {
+ string x = obj.Col1, y = obj.Col2;
+ return (x != null ? x.GetHashCode () : 0) ^ (y != null ? y.GetHashCode () : 0);
+ }
+
+ public bool Equals (Row<uint, uint> x, Row<uint, uint> y)
+ {
+ return x.Col1 == y.Col1
+ && x.Col2 == y.Col2;
+ }
+
+ public int GetHashCode (Row<uint, uint> obj)
+ {
+ return (int) (obj.Col1 ^ obj.Col2);
+ }
+
+ public bool Equals (Row<uint, uint, uint> x, Row<uint, uint, uint> y)
+ {
+ return x.Col1 == y.Col1
+ && x.Col2 == y.Col2
+ && x.Col3 == y.Col3;
+ }
+
+ public int GetHashCode (Row<uint, uint, uint> obj)
+ {
+ return (int) (obj.Col1 ^ obj.Col2 ^ obj.Col3);
+ }
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/RowCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/RowCollection.cs
deleted file mode 100644
index 4da8c4e..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/RowCollection.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-//
-// RowCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.Collections;
-
- public class RowCollection : ICollection, IMetadataRowVisitable {
-
- ArrayList m_items;
-
- public IMetadataRow this [int index] {
- get { return m_items [index] as IMetadataRow; }
- set { m_items [index] = value; }
- }
-
- public int Count {
- get { return m_items.Count; }
- }
-
- public bool IsSynchronized {
- get { return false; }
- }
-
- public object SyncRoot {
- get { return this; }
- }
-
- internal RowCollection (int size)
- {
- m_items = new ArrayList (size);
- }
-
- internal RowCollection ()
- {
- m_items = new ArrayList ();
- }
-
- internal void Add (IMetadataRow value)
- {
- m_items.Add (value);
- }
-
- public void Clear ()
- {
- m_items.Clear ();
- }
-
- public bool Contains (IMetadataRow value)
- {
- return m_items.Contains (value);
- }
-
- public int IndexOf (IMetadataRow value)
- {
- return m_items.IndexOf (value);
- }
-
- public void Insert (int index, IMetadataRow value)
- {
- m_items.Insert (index, value);
- }
-
- public void Remove (IMetadataRow value)
- {
- m_items.Remove (value);
- }
-
- public void RemoveAt (int index)
- {
- m_items.Remove (index);
- }
-
- public void CopyTo (Array ary, int index)
- {
- m_items.CopyTo (ary, index);
- }
-
- public void Sort (IComparer comp)
- {
- m_items.Sort (comp);
- }
-
- public IEnumerator GetEnumerator ()
- {
- return m_items.GetEnumerator ();
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitRowCollection (this);
-
- for (int i = 0; i < m_items.Count; i++)
- this [i].Accept (visitor);
-
- visitor.TerminateRowCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StandAloneSig.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StandAloneSig.cs
deleted file mode 100644
index cb3c7f9..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StandAloneSig.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// StandAloneSigTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class StandAloneSigTable : IMetadataTable {
-
- public const int RId = 0x11;
-
- RowCollection m_rows;
-
- public StandAloneSigRow this [int index] {
- get { return m_rows [index] as StandAloneSigRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal StandAloneSigTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitStandAloneSigTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class StandAloneSigRow : IMetadataRow {
-
- public uint Signature;
-
- internal StandAloneSigRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitStandAloneSigRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StringsHeap.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StringHeap.cs
index 6121cf8..85a2892 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StringsHeap.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/StringHeap.cs
@@ -1,10 +1,10 @@
//
-// StringsHeap.cs
+// StringHeap.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,51 +26,56 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil.Metadata {
+using System;
+using System.Collections.Generic;
+using System.Text;
- using System.Collections;
- using System.Text;
+using Mono.Cecil.PE;
- public class StringsHeap : MetadataHeap {
+namespace Mono.Cecil.Metadata {
- IDictionary m_strings;
+ class StringHeap : Heap {
- public string this [uint index] {
- get {
- string str = m_strings [index] as string;
- if (str == null) {
- str = ReadStringAt (index);
- m_strings [index] = str;
- }
- return str;
- }
- set { m_strings [index] = value; }
- }
+ readonly Dictionary<uint, string> strings = new Dictionary<uint, string> ();
- internal StringsHeap (MetadataStream stream) : base (stream, MetadataStream.Strings)
+ public StringHeap (Section section, uint start, uint size)
+ : base (section, start, size)
{
- m_strings = new Hashtable ();
}
- string ReadStringAt (uint index)
+ public string Read (uint index)
{
- if (index > Data.Length - 1)
+ if (index == 0)
return string.Empty;
+ string @string;
+ if (strings.TryGetValue (index, out @string))
+ return @string;
+
+ if (index > Size - 1)
+ return string.Empty;
+
+ @string = ReadStringAt (index);
+ if (@string.Length != 0)
+ strings.Add (index, @string);
+
+ return @string;
+ }
+
+ protected virtual string ReadStringAt (uint index)
+ {
int length = 0;
- for (int i = (int) index; i < Data.Length; i++) {
- if (Data [i] == 0)
+ byte [] data = Section.Data;
+ int start = (int) (index + Offset);
+
+ for (int i = start; ; i++) {
+ if (data [i] == 0)
break;
length++;
}
- return Encoding.UTF8.GetString (Data, (int) index, length);
- }
-
- public override void Accept (IMetadataVisitor visitor)
- {
- visitor.VisitStringsHeap (this);
+ return Encoding.UTF8.GetString (data, start, length);
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableCollection.cs
deleted file mode 100644
index 817ccb0..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableCollection.cs
+++ /dev/null
@@ -1,115 +0,0 @@
-//
-// TableCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.Collections;
-
- public class TableCollection : ICollection, IMetadataTableVisitable {
-
- IMetadataTable [] m_tables = new IMetadataTable [TablesHeap.MaxTableCount];
-
- TablesHeap m_heap;
-
- public IMetadataTable this [int index] {
- get { return m_tables [index]; }
- set { m_tables [index] = value; }
- }
-
- public int Count {
- get {
- return GetList ().Count;
- }
- }
-
- public bool IsSynchronized {
- get { return false; }
- }
-
- public object SyncRoot {
- get { return this; }
- }
-
- public TablesHeap Heap {
- get { return m_heap; }
- }
-
- internal TableCollection (TablesHeap heap)
- {
- m_heap = heap;
- }
-
- internal void Add (IMetadataTable value)
- {
- m_tables [value.Id] = value;
- }
-
- public bool Contains (IMetadataTable value)
- {
- return m_tables [value.Id] != null;
- }
-
- internal void Remove (IMetadataTable value)
- {
- m_tables [value.Id] = null;
- }
-
- public void CopyTo (Array array, int index)
- {
- GetList ().CopyTo (array, index);
- }
-
- internal IList GetList ()
- {
- IList tables = new ArrayList ();
- for (int i = 0; i < m_tables.Length; i++) {
- IMetadataTable table = m_tables [i];
- if (table != null)
- tables.Add (table);
- }
-
- return tables;
- }
-
- public IEnumerator GetEnumerator ()
- {
- return GetList ().GetEnumerator ();
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitTableCollection (this);
-
- foreach (IMetadataTable table in GetList ())
- table.Accept (visitor);
-
- visitor.TerminateTableCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableHeap.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableHeap.cs
new file mode 100644
index 0000000..cc441db
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TableHeap.cs
@@ -0,0 +1,153 @@
+//
+// TableHeap.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using Mono.Cecil.PE;
+
+namespace Mono.Cecil.Metadata {
+
+ enum Table : byte {
+ Module = 0x00,
+ TypeRef = 0x01,
+ TypeDef = 0x02,
+ FieldPtr = 0x03,
+ Field = 0x04,
+ MethodPtr = 0x05,
+ Method = 0x06,
+ ParamPtr = 0x07,
+ Param = 0x08,
+ InterfaceImpl = 0x09,
+ MemberRef = 0x0a,
+ Constant = 0x0b,
+ CustomAttribute = 0x0c,
+ FieldMarshal = 0x0d,
+ DeclSecurity = 0x0e,
+ ClassLayout = 0x0f,
+ FieldLayout = 0x10,
+ StandAloneSig = 0x11,
+ EventMap = 0x12,
+ EventPtr = 0x13,
+ Event = 0x14,
+ PropertyMap = 0x15,
+ PropertyPtr = 0x16,
+ Property = 0x17,
+ MethodSemantics = 0x18,
+ MethodImpl = 0x19,
+ ModuleRef = 0x1a,
+ TypeSpec = 0x1b,
+ ImplMap = 0x1c,
+ FieldRVA = 0x1d,
+ Assembly = 0x20,
+ AssemblyProcessor = 0x21,
+ AssemblyOS = 0x22,
+ AssemblyRef = 0x23,
+ AssemblyRefProcessor = 0x24,
+ AssemblyRefOS = 0x25,
+ File = 0x26,
+ ExportedType = 0x27,
+ ManifestResource = 0x28,
+ NestedClass = 0x29,
+ GenericParam = 0x2a,
+ MethodSpec = 0x2b,
+ GenericParamConstraint = 0x2c,
+ }
+
+ struct TableInformation {
+ public uint Offset;
+ public uint Length;
+ public uint RowSize;
+ }
+
+ sealed class TableHeap : Heap {
+
+ 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 readonly TableInformation [] Tables = new TableInformation [45];
+
+ public TableInformation this [Table table] {
+ get { return Tables [(int) table]; }
+ }
+
+ public TableHeap (Section section, uint start, uint size)
+ : base (section, start, size)
+ {
+ }
+
+ public bool HasTable (Table table)
+ {
+ return (Valid & (1L << (int) table)) != 0;
+ }
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TablesHeap.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TablesHeap.cs
deleted file mode 100644
index 583ac7e..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TablesHeap.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-// TablesHeap.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System;
- using System.Collections;
-
- public class TablesHeap : MetadataHeap {
-
- public uint Reserved;
- public byte MajorVersion;
- public byte MinorVersion;
- public byte HeapSizes;
- public byte Reserved2;
- public long Valid;
- public long Sorted;
-
- TableCollection m_tables;
-
- public const int MaxTableCount = 45;
-
- public TableCollection Tables {
- get { return m_tables; }
- set { m_tables = value; }
- }
-
- public IMetadataTable this [int id]
- {
- get { return m_tables [id]; }
- set { m_tables [id] = value; }
- }
-
- internal TablesHeap (MetadataStream stream) : base(stream, MetadataStream.Tables)
- {
- }
-
- public bool HasTable (int id)
- {
- return (Valid & (1L << id)) != 0;
- }
-
- public override void Accept (IMetadataVisitor visitor)
- {
- visitor.VisitTablesHeap (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TokenType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TokenType.cs
index 44de804..f822b6d 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TokenType.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TokenType.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,33 +26,31 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil.Metadata {
+namespace Mono.Cecil {
public enum TokenType : uint {
- Module = 0x00000000,
- TypeRef = 0x01000000,
- TypeDef = 0x02000000,
- Field = 0x04000000,
- Method = 0x06000000,
- Param = 0x08000000,
- InterfaceImpl = 0x09000000,
- MemberRef = 0x0a000000,
- CustomAttribute = 0x0c000000,
- Permission = 0x0e000000,
- Signature = 0x11000000,
- Event = 0x14000000,
- Property = 0x17000000,
- ModuleRef = 0x1a000000,
- TypeSpec = 0x1b000000,
- Assembly = 0x20000000,
- AssemblyRef = 0x23000000,
- File = 0x26000000,
- ExportedType = 0x27000000,
- ManifestResource = 0x28000000,
- GenericParam = 0x2a000000,
- MethodSpec = 0x2b000000,
- String = 0x70000000,
- Name = 0x71000000,
- BaseType = 0x72000000
+ Module = 0x00000000,
+ TypeRef = 0x01000000,
+ TypeDef = 0x02000000,
+ Field = 0x04000000,
+ Method = 0x06000000,
+ Param = 0x08000000,
+ InterfaceImpl = 0x09000000,
+ MemberRef = 0x0a000000,
+ CustomAttribute = 0x0c000000,
+ Permission = 0x0e000000,
+ Signature = 0x11000000,
+ Event = 0x14000000,
+ Property = 0x17000000,
+ ModuleRef = 0x1a000000,
+ TypeSpec = 0x1b000000,
+ Assembly = 0x20000000,
+ AssemblyRef = 0x23000000,
+ File = 0x26000000,
+ ExportedType = 0x27000000,
+ ManifestResource = 0x28000000,
+ GenericParam = 0x2a000000,
+ MethodSpec = 0x2b000000,
+ String = 0x70000000,
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeDef.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeDef.cs
deleted file mode 100644
index d611ac9..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeDef.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-//
-// TypeDefTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using Mono.Cecil;
-
- public sealed class TypeDefTable : IMetadataTable {
-
- public const int RId = 0x02;
-
- RowCollection m_rows;
-
- public TypeDefRow this [int index] {
- get { return m_rows [index] as TypeDefRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal TypeDefTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitTypeDefTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class TypeDefRow : IMetadataRow {
-
- public TypeAttributes Flags;
- public uint Name;
- public uint Namespace;
- public MetadataToken Extends;
- public uint FieldList;
- public uint MethodList;
-
- internal TypeDefRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitTypeDefRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeRef.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeRef.cs
deleted file mode 100644
index d27d72e..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeRef.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-//
-// TypeRefTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class TypeRefTable : IMetadataTable {
-
- public const int RId = 0x01;
-
- RowCollection m_rows;
-
- public TypeRefRow this [int index] {
- get { return m_rows [index] as TypeRefRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal TypeRefTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitTypeRefTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class TypeRefRow : IMetadataRow {
-
- public MetadataToken ResolutionScope;
- public uint Name;
- public uint Namespace;
-
- internal TypeRefRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitTypeRefRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeSpec.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeSpec.cs
deleted file mode 100644
index 5c20402..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/TypeSpec.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// TypeSpecTable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Oct 10 23:08:26 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- public sealed class TypeSpecTable : IMetadataTable {
-
- public const int RId = 0x1b;
-
- RowCollection m_rows;
-
- public TypeSpecRow this [int index] {
- get { return m_rows [index] as TypeSpecRow; }
- set { m_rows [index] = value; }
- }
-
- public RowCollection Rows {
- get { return m_rows; }
- set { m_rows = value; }
- }
-
- public int Id {
- get { return RId; }
- }
-
- internal TypeSpecTable ()
- {
- }
-
- public void Accept (IMetadataTableVisitor visitor)
- {
- visitor.VisitTypeSpecTable (this);
- this.Rows.Accept (visitor.GetRowVisitor ());
- }
- }
-
- public sealed class TypeSpecRow : IMetadataRow {
-
- public uint Signature;
-
- internal TypeSpecRow ()
- {
- }
-
- public void Accept (IMetadataRowVisitor visitor)
- {
- visitor.VisitTypeSpecRow (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataFormatException.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/UserStringHeap.cs
index dd91790..7353cb7 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/MetadataFormatException.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/UserStringHeap.cs
@@ -1,10 +1,10 @@
//
-// MetadataFormatException.cs
+// UserStringHeap.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,30 +26,34 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil.Metadata {
+using System;
- using System;
+using Mono.Cecil.PE;
- using Mono.Cecil.Binary;
+namespace Mono.Cecil.Metadata {
- public class MetadataFormatException : ImageFormatException {
+ sealed class UserStringHeap : StringHeap {
- internal MetadataFormatException () : base ()
+ public UserStringHeap (Section section, uint start, uint size)
+ : base (section, start, size)
{
}
- internal MetadataFormatException (string message) : base (message)
+ protected override string ReadStringAt (uint index)
{
- }
+ byte [] data = Section.Data;
+ int start = (int) (index + Offset);
- internal MetadataFormatException (string message, params string [] parameters) :
- base (string.Format (message, parameters))
- {
- }
+ uint length = (uint) (data.ReadCompressedUInt32 (ref start) & ~1);
+ if (length < 1)
+ return string.Empty;
- internal MetadataFormatException (string message, Exception inner) :
- base (message, inner)
- {
+ var chars = new char [length / 2];
+
+ for (int i = start, j = 0; i < start + length; i += 2)
+ chars [j++] = (char) (data [i] | (data [i + 1] << 8));
+
+ return new string (chars);
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/UserStringsHeap.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/UserStringsHeap.cs
deleted file mode 100644
index fb5302f..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/UserStringsHeap.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-//
-// UserStringsHeap.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Metadata {
-
- using System.Collections;
- using System.Text;
-
- public class UserStringsHeap : MetadataHeap {
-
- readonly IDictionary m_strings;
-
- public string this [uint offset] {
- get {
- string us = m_strings [offset] as string;
- if (us != null)
- return us;
-
- us = ReadStringAt ((int) offset);
- if (us != null && us.Length != 0)
- m_strings [offset] = us;
-
- return us;
- }
- set { m_strings [offset] = value; }
- }
-
- internal UserStringsHeap (MetadataStream stream) : base (stream, MetadataStream.UserStrings)
- {
- m_strings = new Hashtable ();
- }
-
- string ReadStringAt (int offset)
- {
- int length = Utilities.ReadCompressedInteger (this.Data, offset, out offset) - 1;
- if (length < 1)
- return string.Empty;
-
- return Encoding.Unicode.GetString (this.Data, offset, length);
- }
-
- public override void Accept (IMetadataVisitor visitor)
- {
- visitor.VisitUserStringsHeap (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Utilities.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Utilities.cs
index cc6353a..496c61b 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Utilities.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Metadata/Utilities.cs
@@ -4,10 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Tue Jul 17 00:22:33 +0200 2007
-//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -29,617 +26,504 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil.Metadata {
+using System;
- using System;
- using System.Collections;
- using System.IO;
+using Mono.Cecil.Metadata;
- class Utilities {
+namespace Mono.Cecil {
- Utilities ()
- {
- }
+ static partial class Mixin {
- public static int ReadCompressedInteger (byte [] data, int pos, out int start)
+ public static uint ReadCompressedUInt32 (this byte [] data, ref int position)
{
- int integer = 0;
- start = pos;
- if ((data [pos] & 0x80) == 0) {
- integer = data [pos];
- start++;
- } else if ((data [pos] & 0x40) == 0) {
- integer = (data [start] & ~0x80) << 8;
- integer |= data [pos + 1];
- start += 2;
+ uint integer;
+ if ((data [position] & 0x80) == 0) {
+ integer = data [position];
+ position++;
+ } else if ((data [position] & 0x40) == 0) {
+ integer = (uint) (data [position] & ~0x80) << 8;
+ integer |= data [position + 1];
+ position += 2;
} else {
- integer = (data [start] & ~0xc0) << 24;
- integer |= data [pos + 1] << 16;
- integer |= data [pos + 2] << 8;
- integer |= data [pos + 3];
- start += 4;
+ integer = (uint) (data [position] & ~0xc0) << 24;
+ integer |= (uint) data [position + 1] << 16;
+ integer |= (uint) data [position + 2] << 8;
+ integer |= (uint) data [position + 3];
+ position += 4;
}
return integer;
}
- public static int WriteCompressedInteger (BinaryWriter writer, int value)
- {
- if (value < 0x80)
- writer.Write ((byte) value);
- else if (value < 0x4000) {
- writer.Write ((byte) (0x80 | (value >> 8)));
- writer.Write ((byte) (value & 0xff));
- } else {
- writer.Write ((byte) ((value >> 24) | 0xc0));
- writer.Write ((byte) ((value >> 16) & 0xff));
- writer.Write ((byte) ((value >> 8) & 0xff));
- writer.Write ((byte) (value & 0xff));
- }
- return (int) writer.BaseStream.Position;
- }
-
- public static MetadataToken GetMetadataToken (CodedIndex cidx, uint data)
+ public static MetadataToken GetMetadataToken (this CodedIndex self, uint data)
{
- uint rid = 0;
- switch (cidx) {
- case CodedIndex.TypeDefOrRef :
+ uint rid;
+ TokenType token_type;
+ switch (self) {
+ case CodedIndex.TypeDefOrRef:
rid = data >> 2;
switch (data & 3) {
- case 0 :
- return new MetadataToken (TokenType.TypeDef, rid);
- case 1 :
- return new MetadataToken (TokenType.TypeRef, rid);
- case 2 :
- return new MetadataToken (TokenType.TypeSpec, rid);
- default :
- return MetadataToken.Zero;
+ case 0:
+ token_type = TokenType.TypeDef; goto ret;
+ case 1:
+ token_type = TokenType.TypeRef; goto ret;
+ case 2:
+ token_type = TokenType.TypeSpec; goto ret;
+ default:
+ goto exit;
}
- case CodedIndex.HasConstant :
+ case CodedIndex.HasConstant:
rid = data >> 2;
switch (data & 3) {
- case 0 :
- return new MetadataToken (TokenType.Field, rid);
- case 1 :
- return new MetadataToken (TokenType.Param, rid);
- case 2 :
- return new MetadataToken (TokenType.Property, rid);
- default :
- return MetadataToken.Zero;
+ case 0:
+ token_type = TokenType.Field; goto ret;
+ case 1:
+ token_type = TokenType.Param; goto ret;
+ case 2:
+ token_type = TokenType.Property; goto ret;
+ default:
+ goto exit;
}
- case CodedIndex.HasCustomAttribute :
+ case CodedIndex.HasCustomAttribute:
rid = data >> 5;
switch (data & 31) {
- case 0 :
- return new MetadataToken (TokenType.Method, rid);
- case 1 :
- return new MetadataToken (TokenType.Field, rid);
- case 2 :
- return new MetadataToken (TokenType.TypeRef, rid);
- case 3 :
- return new MetadataToken (TokenType.TypeDef, rid);
- case 4 :
- return new MetadataToken (TokenType.Param, rid);
- case 5 :
- return new MetadataToken (TokenType.InterfaceImpl, rid);
- case 6 :
- return new MetadataToken (TokenType.MemberRef, rid);
- case 7 :
- return new MetadataToken (TokenType.Module, rid);
- case 8 :
- return new MetadataToken (TokenType.Permission, rid);
- case 9 :
- return new MetadataToken (TokenType.Property, rid);
- case 10 :
- return new MetadataToken (TokenType.Event, rid);
- case 11 :
- return new MetadataToken (TokenType.Signature, rid);
- case 12 :
- return new MetadataToken (TokenType.ModuleRef, rid);
- case 13 :
- return new MetadataToken (TokenType.TypeSpec, rid);
- case 14 :
- return new MetadataToken (TokenType.Assembly, rid);
- case 15 :
- return new MetadataToken (TokenType.AssemblyRef, rid);
- case 16 :
- return new MetadataToken (TokenType.File, rid);
- case 17 :
- return new MetadataToken (TokenType.ExportedType, rid);
- case 18 :
- return new MetadataToken (TokenType.ManifestResource, rid);
- case 19 :
- return new MetadataToken (TokenType.GenericParam, rid);
- default :
- return MetadataToken.Zero;
+ case 0:
+ token_type = TokenType.Method; goto ret;
+ case 1:
+ token_type = TokenType.Field; goto ret;
+ case 2:
+ token_type = TokenType.TypeRef; goto ret;
+ case 3:
+ token_type = TokenType.TypeDef; goto ret;
+ case 4:
+ token_type = TokenType.Param; goto ret;
+ case 5:
+ token_type = TokenType.InterfaceImpl; goto ret;
+ case 6:
+ token_type = TokenType.MemberRef; goto ret;
+ case 7:
+ token_type = TokenType.Module; goto ret;
+ case 8:
+ token_type = TokenType.Permission; goto ret;
+ case 9:
+ token_type = TokenType.Property; goto ret;
+ case 10:
+ token_type = TokenType.Event; goto ret;
+ case 11:
+ token_type = TokenType.Signature; goto ret;
+ case 12:
+ token_type = TokenType.ModuleRef; goto ret;
+ case 13:
+ token_type = TokenType.TypeSpec; goto ret;
+ case 14:
+ token_type = TokenType.Assembly; goto ret;
+ case 15:
+ token_type = TokenType.AssemblyRef; goto ret;
+ case 16:
+ token_type = TokenType.File; goto ret;
+ case 17:
+ token_type = TokenType.ExportedType; goto ret;
+ case 18:
+ token_type = TokenType.ManifestResource; goto ret;
+ case 19:
+ token_type = TokenType.GenericParam; goto ret;
+ default:
+ goto exit;
}
- case CodedIndex.HasFieldMarshal :
+ case CodedIndex.HasFieldMarshal:
rid = data >> 1;
switch (data & 1) {
- case 0 :
- return new MetadataToken (TokenType.Field, rid);
- case 1 :
- return new MetadataToken (TokenType.Param, rid);
- default :
- return MetadataToken.Zero;
+ case 0:
+ token_type = TokenType.Field; goto ret;
+ case 1:
+ token_type = TokenType.Param; goto ret;
+ default:
+ goto exit;
}
- case CodedIndex.HasDeclSecurity :
+ case CodedIndex.HasDeclSecurity:
rid = data >> 2;
switch (data & 3) {
- case 0 :
- return new MetadataToken (TokenType.TypeDef, rid);
- case 1 :
- return new MetadataToken (TokenType.Method, rid);
- case 2 :
- return new MetadataToken (TokenType.Assembly, rid);
- default :
- return MetadataToken.Zero;
+ case 0:
+ token_type = TokenType.TypeDef; goto ret;
+ case 1:
+ token_type = TokenType.Method; goto ret;
+ case 2:
+ token_type = TokenType.Assembly; goto ret;
+ default:
+ goto exit;
}
- case CodedIndex.MemberRefParent :
+ case CodedIndex.MemberRefParent:
rid = data >> 3;
switch (data & 7) {
- case 0 :
- return new MetadataToken (TokenType.TypeDef, rid);
- case 1 :
- return new MetadataToken (TokenType.TypeRef, rid);
- case 2 :
- return new MetadataToken (TokenType.ModuleRef, rid);
- case 3 :
- return new MetadataToken (TokenType.Method, rid);
- case 4 :
- return new MetadataToken (TokenType.TypeSpec, rid);
- default :
- return MetadataToken.Zero;
+ case 0:
+ token_type = TokenType.TypeDef; goto ret;
+ case 1:
+ token_type = TokenType.TypeRef; goto ret;
+ case 2:
+ token_type = TokenType.ModuleRef; goto ret;
+ case 3:
+ token_type = TokenType.Method; goto ret;
+ case 4:
+ token_type = TokenType.TypeSpec; goto ret;
+ default:
+ goto exit;
}
- case CodedIndex.HasSemantics :
+ case CodedIndex.HasSemantics:
rid = data >> 1;
switch (data & 1) {
- case 0 :
- return new MetadataToken (TokenType.Event, rid);
- case 1 :
- return new MetadataToken (TokenType.Property, rid);
- default :
- return MetadataToken.Zero;
+ case 0:
+ token_type = TokenType.Event; goto ret;
+ case 1:
+ token_type = TokenType.Property; goto ret;
+ default:
+ goto exit;
}
- case CodedIndex.MethodDefOrRef :
+ case CodedIndex.MethodDefOrRef:
rid = data >> 1;
switch (data & 1) {
- case 0 :
- return new MetadataToken (TokenType.Method, rid);
- case 1 :
- return new MetadataToken (TokenType.MemberRef, rid);
- default :
- return MetadataToken.Zero;
+ case 0:
+ token_type = TokenType.Method; goto ret;
+ case 1:
+ token_type = TokenType.MemberRef; goto ret;
+ default:
+ goto exit;
}
- case CodedIndex.MemberForwarded :
+ case CodedIndex.MemberForwarded:
rid = data >> 1;
switch (data & 1) {
- case 0 :
- return new MetadataToken (TokenType.Field, rid);
- case 1 :
- return new MetadataToken (TokenType.Method, rid);
- default :
- return MetadataToken.Zero;
+ case 0:
+ token_type = TokenType.Field; goto ret;
+ case 1:
+ token_type = TokenType.Method; goto ret;
+ default:
+ goto exit;
}
- case CodedIndex.Implementation :
+ case CodedIndex.Implementation:
rid = data >> 2;
switch (data & 3) {
- case 0 :
- return new MetadataToken (TokenType.File, rid);
- case 1 :
- return new MetadataToken (TokenType.AssemblyRef, rid);
- case 2 :
- return new MetadataToken (TokenType.ExportedType, rid);
- default :
- return MetadataToken.Zero;
+ case 0:
+ token_type = TokenType.File; goto ret;
+ case 1:
+ token_type = TokenType.AssemblyRef; goto ret;
+ case 2:
+ token_type = TokenType.ExportedType; goto ret;
+ default:
+ goto exit;
}
- case CodedIndex.CustomAttributeType :
+ case CodedIndex.CustomAttributeType:
rid = data >> 3;
switch (data & 7) {
- case 2 :
- return new MetadataToken (TokenType.Method, rid);
- case 3 :
- return new MetadataToken (TokenType.MemberRef, rid);
- default :
- return MetadataToken.Zero;
+ case 2:
+ token_type = TokenType.Method; goto ret;
+ case 3:
+ token_type = TokenType.MemberRef; goto ret;
+ default:
+ goto exit;
}
- case CodedIndex.ResolutionScope :
+ case CodedIndex.ResolutionScope:
rid = data >> 2;
switch (data & 3) {
- case 0 :
- return new MetadataToken (TokenType.Module, rid);
- case 1 :
- return new MetadataToken (TokenType.ModuleRef, rid);
- case 2 :
- return new MetadataToken (TokenType.AssemblyRef, rid);
- case 3 :
- return new MetadataToken (TokenType.TypeRef, rid);
- default :
- return MetadataToken.Zero;
+ case 0:
+ token_type = TokenType.Module; goto ret;
+ case 1:
+ token_type = TokenType.ModuleRef; goto ret;
+ case 2:
+ token_type = TokenType.AssemblyRef; goto ret;
+ case 3:
+ token_type = TokenType.TypeRef; goto ret;
+ default:
+ goto exit;
}
- case CodedIndex.TypeOrMethodDef :
+ case CodedIndex.TypeOrMethodDef:
rid = data >> 1;
switch (data & 1) {
- case 0 :
- return new MetadataToken (TokenType.TypeDef, rid);
- case 1 :
- return new MetadataToken (TokenType.Method, rid);
- default :
- return MetadataToken.Zero;
+ case 0:
+ token_type = TokenType.TypeDef; goto ret;
+ case 1:
+ token_type = TokenType.Method; goto ret;
+ default: goto exit;
}
- default :
- return MetadataToken.Zero;
+ default:
+ goto exit;
}
+ ret:
+ return new MetadataToken (token_type, rid);
+ exit:
+ return MetadataToken.Zero;
}
- public static uint CompressMetadataToken (CodedIndex cidx, MetadataToken token)
+#if !READ_ONLY
+ public static uint CompressMetadataToken (this CodedIndex self, MetadataToken token)
{
uint ret = 0;
if (token.RID == 0)
return ret;
- switch (cidx) {
- case CodedIndex.TypeDefOrRef :
+ switch (self) {
+ case CodedIndex.TypeDefOrRef:
ret = token.RID << 2;
switch (token.TokenType) {
- case TokenType.TypeDef :
+ case TokenType.TypeDef:
return ret | 0;
- case TokenType.TypeRef :
+ case TokenType.TypeRef:
return ret | 1;
- case TokenType.TypeSpec :
+ case TokenType.TypeSpec:
return ret | 2;
- default :
- throw new MetadataFormatException("Non valid Token for TypeDefOrRef");
+ default:
+ goto exit;
}
- case CodedIndex.HasConstant :
+ case CodedIndex.HasConstant:
ret = token.RID << 2;
switch (token.TokenType) {
- case TokenType.Field :
+ case TokenType.Field:
return ret | 0;
- case TokenType.Param :
+ case TokenType.Param:
return ret | 1;
- case TokenType.Property :
+ case TokenType.Property:
return ret | 2;
- default :
- throw new MetadataFormatException("Non valid Token for HasConstant");
+ default:
+ goto exit;
}
- case CodedIndex.HasCustomAttribute :
+ case CodedIndex.HasCustomAttribute:
ret = token.RID << 5;
switch (token.TokenType) {
- case TokenType.Method :
+ case TokenType.Method:
return ret | 0;
- case TokenType.Field :
+ case TokenType.Field:
return ret | 1;
- case TokenType.TypeRef :
+ case TokenType.TypeRef:
return ret | 2;
- case TokenType.TypeDef :
+ case TokenType.TypeDef:
return ret | 3;
- case TokenType.Param :
+ case TokenType.Param:
return ret | 4;
- case TokenType.InterfaceImpl :
+ case TokenType.InterfaceImpl:
return ret | 5;
- case TokenType.MemberRef :
+ case TokenType.MemberRef:
return ret | 6;
- case TokenType.Module :
+ case TokenType.Module:
return ret | 7;
- case TokenType.Permission :
+ case TokenType.Permission:
return ret | 8;
- case TokenType.Property :
+ case TokenType.Property:
return ret | 9;
- case TokenType.Event :
+ case TokenType.Event:
return ret | 10;
- case TokenType.Signature :
+ case TokenType.Signature:
return ret | 11;
- case TokenType.ModuleRef :
+ case TokenType.ModuleRef:
return ret | 12;
- case TokenType.TypeSpec :
+ case TokenType.TypeSpec:
return ret | 13;
- case TokenType.Assembly :
+ case TokenType.Assembly:
return ret | 14;
- case TokenType.AssemblyRef :
+ case TokenType.AssemblyRef:
return ret | 15;
- case TokenType.File :
+ case TokenType.File:
return ret | 16;
- case TokenType.ExportedType :
+ case TokenType.ExportedType:
return ret | 17;
- case TokenType.ManifestResource :
+ case TokenType.ManifestResource:
return ret | 18;
- case TokenType.GenericParam :
+ case TokenType.GenericParam:
return ret | 19;
- default :
- throw new MetadataFormatException("Non valid Token for HasCustomAttribute");
+ default:
+ goto exit;
}
- case CodedIndex.HasFieldMarshal :
+ case CodedIndex.HasFieldMarshal:
ret = token.RID << 1;
switch (token.TokenType) {
- case TokenType.Field :
+ case TokenType.Field:
return ret | 0;
- case TokenType.Param :
+ case TokenType.Param:
return ret | 1;
- default :
- throw new MetadataFormatException("Non valid Token for HasFieldMarshal");
+ default:
+ goto exit;
}
- case CodedIndex.HasDeclSecurity :
+ case CodedIndex.HasDeclSecurity:
ret = token.RID << 2;
switch (token.TokenType) {
- case TokenType.TypeDef :
+ case TokenType.TypeDef:
return ret | 0;
- case TokenType.Method :
+ case TokenType.Method:
return ret | 1;
- case TokenType.Assembly :
+ case TokenType.Assembly:
return ret | 2;
- default :
- throw new MetadataFormatException("Non valid Token for HasDeclSecurity");
+ default:
+ goto exit;
}
- case CodedIndex.MemberRefParent :
+ case CodedIndex.MemberRefParent:
ret = token.RID << 3;
switch (token.TokenType) {
- case TokenType.TypeDef :
+ case TokenType.TypeDef:
return ret | 0;
- case TokenType.TypeRef :
+ case TokenType.TypeRef:
return ret | 1;
- case TokenType.ModuleRef :
+ case TokenType.ModuleRef:
return ret | 2;
- case TokenType.Method :
+ case TokenType.Method:
return ret | 3;
- case TokenType.TypeSpec :
+ case TokenType.TypeSpec:
return ret | 4;
- default :
- throw new MetadataFormatException("Non valid Token for MemberRefParent");
+ default:
+ goto exit;
}
- case CodedIndex.HasSemantics :
+ case CodedIndex.HasSemantics:
ret = token.RID << 1;
switch (token.TokenType) {
- case TokenType.Event :
+ case TokenType.Event:
return ret | 0;
- case TokenType.Property :
+ case TokenType.Property:
return ret | 1;
- default :
- throw new MetadataFormatException("Non valid Token for HasSemantics");
+ default:
+ goto exit;
}
- case CodedIndex.MethodDefOrRef :
+ case CodedIndex.MethodDefOrRef:
ret = token.RID << 1;
switch (token.TokenType) {
- case TokenType.Method :
+ case TokenType.Method:
return ret | 0;
- case TokenType.MemberRef :
+ case TokenType.MemberRef:
return ret | 1;
- default :
- throw new MetadataFormatException("Non valid Token for MethodDefOrRef");
+ default:
+ goto exit;
}
- case CodedIndex.MemberForwarded :
+ case CodedIndex.MemberForwarded:
ret = token.RID << 1;
switch (token.TokenType) {
- case TokenType.Field :
+ case TokenType.Field:
return ret | 0;
- case TokenType.Method :
+ case TokenType.Method:
return ret | 1;
- default :
- throw new MetadataFormatException("Non valid Token for MemberForwarded");
+ default:
+ goto exit;
}
- case CodedIndex.Implementation :
+ case CodedIndex.Implementation:
ret = token.RID << 2;
switch (token.TokenType) {
- case TokenType.File :
+ case TokenType.File:
return ret | 0;
- case TokenType.AssemblyRef :
+ case TokenType.AssemblyRef:
return ret | 1;
- case TokenType.ExportedType :
+ case TokenType.ExportedType:
return ret | 2;
- default :
- throw new MetadataFormatException("Non valid Token for Implementation");
+ default:
+ goto exit;
}
- case CodedIndex.CustomAttributeType :
+ case CodedIndex.CustomAttributeType:
ret = token.RID << 3;
switch (token.TokenType) {
- case TokenType.Method :
+ case TokenType.Method:
return ret | 2;
- case TokenType.MemberRef :
+ case TokenType.MemberRef:
return ret | 3;
- default :
- throw new MetadataFormatException("Non valid Token for CustomAttributeType");
+ default:
+ goto exit;
}
- case CodedIndex.ResolutionScope :
+ case CodedIndex.ResolutionScope:
ret = token.RID << 2;
switch (token.TokenType) {
- case TokenType.Module :
+ case TokenType.Module:
return ret | 0;
- case TokenType.ModuleRef :
+ case TokenType.ModuleRef:
return ret | 1;
- case TokenType.AssemblyRef :
+ case TokenType.AssemblyRef:
return ret | 2;
- case TokenType.TypeRef :
+ case TokenType.TypeRef:
return ret | 3;
- default :
- throw new MetadataFormatException("Non valid Token for ResolutionScope");
+ default:
+ goto exit;
}
- case CodedIndex.TypeOrMethodDef :
+ case CodedIndex.TypeOrMethodDef:
ret = token.RID << 1;
switch (token.TokenType) {
- case TokenType.TypeDef :
+ case TokenType.TypeDef:
return ret | 0;
- case TokenType.Method :
+ case TokenType.Method:
return ret | 1;
- default :
- throw new MetadataFormatException("Non valid Token for TypeOrMethodDef");
+ default:
+ goto exit;
}
- default :
- throw new MetadataFormatException ("Non valid CodedIndex");
+ default:
+ goto exit;
}
+ exit:
+ throw new ArgumentException ();
}
+#endif
- internal static Type GetCorrespondingTable (TokenType t)
+ public static int GetSize (this CodedIndex self, Func<Table, int> counter)
{
- switch (t) {
- case TokenType.Assembly :
- return typeof (AssemblyTable);
- case TokenType.AssemblyRef :
- return typeof (AssemblyRefTable);
- case TokenType.CustomAttribute :
- return typeof (CustomAttributeTable);
- case TokenType.Event :
- return typeof (EventTable);
- case TokenType.ExportedType :
- return typeof (ExportedTypeTable);
- case TokenType.Field :
- return typeof (FieldTable);
- case TokenType.File :
- return typeof (FileTable);
- case TokenType.InterfaceImpl :
- return typeof (InterfaceImplTable);
- case TokenType.MemberRef :
- return typeof (MemberRefTable);
- case TokenType.Method :
- return typeof (MethodTable);
- case TokenType.Module :
- return typeof (ModuleTable);
- case TokenType.ModuleRef :
- return typeof (ModuleRefTable);
- case TokenType.Param :
- return typeof (ParamTable);
- case TokenType.Permission :
- return typeof (DeclSecurityTable);
- case TokenType.Property :
- return typeof (PropertyTable);
- case TokenType.Signature :
- return typeof (StandAloneSigTable);
- case TokenType.TypeDef :
- return typeof (TypeDefTable);
- case TokenType.TypeRef :
- return typeof (TypeRefTable);
- case TokenType.TypeSpec :
- return typeof (TypeSpecTable);
- default :
- return null;
- }
- }
-
- internal delegate int TableRowCounter (int rid);
+ int bits;
+ Table [] tables;
- internal static int GetCodedIndexSize (CodedIndex ci, TableRowCounter rowCounter, IDictionary codedIndexCache)
- {
- int bits = 0, max = 0;
- if (codedIndexCache [ci] != null)
- return (int) codedIndexCache [ci];
-
- int res = 0;
- int [] rids;
- switch (ci) {
- case CodedIndex.TypeDefOrRef :
+ switch (self) {
+ case CodedIndex.TypeDefOrRef:
bits = 2;
- rids = new int [3];
- rids [0] = TypeDefTable.RId;
- rids [1] = TypeRefTable.RId;
- rids [2] = TypeSpecTable.RId;
+ tables = new [] { Table.TypeDef, Table.TypeRef, Table.TypeSpec };
break;
- case CodedIndex.HasConstant :
+ case CodedIndex.HasConstant:
bits = 2;
- rids = new int [3];
- rids [0] = FieldTable.RId;
- rids [1] = ParamTable.RId;
- rids [2] = PropertyTable.RId;
+ tables = new [] { Table.Field, Table.Param, Table.Property };
break;
- case CodedIndex.HasCustomAttribute :
+ case CodedIndex.HasCustomAttribute:
bits = 5;
- rids = new int [20];
- rids [0] = MethodTable.RId;
- rids [1] = FieldTable.RId;
- rids [2] = TypeRefTable.RId;
- rids [3] = TypeDefTable.RId;
- rids [4] = ParamTable.RId;
- rids [5] = InterfaceImplTable.RId;
- rids [6] = MemberRefTable.RId;
- rids [7] = ModuleTable.RId;
- rids [8] = DeclSecurityTable.RId;
- rids [9] = PropertyTable.RId;
- rids [10] = EventTable.RId;
- rids [11] = StandAloneSigTable.RId;
- rids [12] = ModuleRefTable.RId;
- rids [13] = TypeSpecTable.RId;
- rids [14] = AssemblyTable.RId;
- rids [15] = AssemblyRefTable.RId;
- rids [16] = FileTable.RId;
- rids [17] = ExportedTypeTable.RId;
- rids [18] = ManifestResourceTable.RId;
- rids [19] = GenericParamTable.RId;
+ tables = new [] {
+ Table.Method, Table.Field, Table.TypeRef, Table.TypeDef, Table.Param, Table.InterfaceImpl, Table.MemberRef,
+ Table.Module, Table.DeclSecurity, Table.Property, Table.Event, Table.StandAloneSig, Table.ModuleRef,
+ Table.TypeSpec, Table.Assembly, Table.AssemblyRef, Table.File, Table.ExportedType,
+ Table.ManifestResource, Table.GenericParam
+ };
break;
- case CodedIndex.HasFieldMarshal :
+ case CodedIndex.HasFieldMarshal:
bits = 1;
- rids = new int [2];
- rids [0] = FieldTable.RId;
- rids [1] = ParamTable.RId;
+ tables = new [] { Table.Field, Table.Param };
break;
- case CodedIndex.HasDeclSecurity :
+ case CodedIndex.HasDeclSecurity:
bits = 2;
- rids = new int [3];
- rids [0] = TypeDefTable.RId;
- rids [1] = MethodTable.RId;
- rids [2] = AssemblyTable.RId;
+ tables = new [] { Table.TypeDef, Table.Method, Table.Assembly };
break;
- case CodedIndex.MemberRefParent :
+ case CodedIndex.MemberRefParent:
bits = 3;
- rids = new int [5];
- rids [0] = TypeDefTable.RId;
- rids [1] = TypeRefTable.RId;
- rids [2] = ModuleRefTable.RId;
- rids [3] = MethodTable.RId;
- rids [4] = TypeSpecTable.RId;
+ tables = new [] { Table.TypeDef, Table.TypeRef, Table.ModuleRef, Table.Method, Table.TypeSpec };
break;
- case CodedIndex.HasSemantics :
+ case CodedIndex.HasSemantics:
bits = 1;
- rids = new int [2];
- rids [0] = EventTable.RId;
- rids [1] = PropertyTable.RId;
+ tables = new [] { Table.Event, Table.Property };
break;
- case CodedIndex.MethodDefOrRef :
+ case CodedIndex.MethodDefOrRef:
bits = 1;
- rids = new int [2];
- rids [0] = MethodTable.RId;
- rids [1] = MemberRefTable.RId;
+ tables = new [] { Table.Method, Table.MemberRef };
break;
- case CodedIndex.MemberForwarded :
+ case CodedIndex.MemberForwarded:
bits = 1;
- rids = new int [2];
- rids [0] = FieldTable.RId;
- rids [1] = MethodTable.RId;
+ tables = new [] { Table.Field, Table.Method };
break;
- case CodedIndex.Implementation :
+ case CodedIndex.Implementation:
bits = 2;
- rids = new int [3];
- rids [0] = FileTable.RId;
- rids [1] = AssemblyRefTable.RId;
- rids [2] = ExportedTypeTable.RId;
+ tables = new [] { Table.File, Table.AssemblyRef, Table.ExportedType };
break;
- case CodedIndex.CustomAttributeType :
+ case CodedIndex.CustomAttributeType:
bits = 3;
- rids = new int [2];
- rids [0] = MethodTable.RId;
- rids [1] = MemberRefTable.RId;
+ tables = new [] { Table.Method, Table.MemberRef };
break;
- case CodedIndex.ResolutionScope :
+ case CodedIndex.ResolutionScope:
bits = 2;
- rids = new int [4];
- rids [0] = ModuleTable.RId;
- rids [1] = ModuleRefTable.RId;
- rids [2] = AssemblyRefTable.RId;
- rids [3] = TypeRefTable.RId;
+ tables = new [] { Table.Module, Table.ModuleRef, Table.AssemblyRef, Table.TypeRef };
break;
- case CodedIndex.TypeOrMethodDef :
+ case CodedIndex.TypeOrMethodDef:
bits = 1;
- rids = new int [2];
- rids [0] = TypeDefTable.RId;
- rids [1] = MethodTable.RId;
+ tables = new [] { Table.TypeDef, Table.Method };
break;
- default :
- throw new MetadataFormatException ("Non valid CodedIndex");
+ default:
+ throw new ArgumentException ();
}
- for (int i = 0; i < rids.Length; i++) {
- int rows = rowCounter (rids [i]);
- if (rows > max) max = rows;
+ int max = 0;
+
+ for (int i = 0; i < tables.Length; i++) {
+ max = System.Math.Max (counter (tables [i]), max);
}
- res = max < (1 << (16 - bits)) ? 2 : 4;
- codedIndexCache [ci] = res;
- return res;
+ return max < (1 << (16 - bits)) ? 2 : 4;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodDefSig.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/BinaryStreamReader.cs
index b7e2e58..8f5b38e 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodDefSig.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/BinaryStreamReader.cs
@@ -1,10 +1,10 @@
//
-// MethodDefSig.cs
+// BinaryStreamReader.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,23 +26,26 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil.Signatures {
+using System;
+using System.IO;
- internal sealed class MethodDefSig : MethodRefSig {
+namespace Mono.Cecil.PE {
- public int GenericParameterCount;
+ class BinaryStreamReader : BinaryReader {
- public MethodDefSig () : this (0)
+ public BinaryStreamReader (Stream stream)
+ : base (stream)
{
}
- public MethodDefSig (uint blobIndex) : base (blobIndex)
+ protected void Advance (int bytes)
{
+ BaseStream.Seek (bytes, SeekOrigin.Current);
}
- public override void Accept (ISignatureVisitor visitor)
+ protected DataDirectory ReadDataDirectory ()
{
- visitor.VisitMethodDefSig (this);
+ return new DataDirectory (ReadUInt32 (), ReadUInt32 ());
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseReflectionReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/BinaryStreamWriter.cs
index ceeec17..37189cb 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseReflectionReader.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/BinaryStreamWriter.cs
@@ -1,10 +1,10 @@
//
-// BaseReflectionReader.cs
+// BinaryStreamWriter.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,48 +26,71 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
+using System.IO;
- internal abstract class BaseReflectionReader : BaseReflectionVisitor, IDetailReader {
+#if !READ_ONLY
- public virtual void ReadSemantic (EventDefinition evt)
+namespace Mono.Cecil.PE {
+
+ class BinaryStreamWriter : BinaryWriter {
+
+ public BinaryStreamWriter (Stream stream)
+ : base (stream)
+ {
+ }
+
+ public void WriteByte (byte value)
{
+ Write (value);
}
- public virtual void ReadSemantic (PropertyDefinition prop)
+ public void WriteUInt16 (ushort value)
{
+ Write (value);
}
- public virtual void ReadMarshalSpec (ParameterDefinition param)
+ public void WriteInt16 (short value)
{
+ Write (value);
}
- public virtual void ReadMarshalSpec (FieldDefinition field)
+ public void WriteUInt32 (uint value)
{
+ Write (value);
}
- public virtual void ReadLayout (TypeDefinition type)
+ public void WriteInt32 (int value)
{
+ Write (value);
}
- public virtual void ReadLayout (FieldDefinition field)
+ public void WriteUInt64 (ulong value)
{
+ Write (value);
}
- public virtual void ReadConstant (FieldDefinition field)
+ public void WriteBytes (byte [] bytes)
{
+ Write (bytes);
}
- public virtual void ReadConstant (PropertyDefinition prop)
+ public void WriteDataDirectory (DataDirectory directory)
{
+ Write (directory.VirtualAddress);
+ Write (directory.Size);
}
- public virtual void ReadConstant (ParameterDefinition param)
+ public void WriteBuffer (ByteBuffer buffer)
{
+ Write (buffer.buffer, 0, buffer.length);
}
- public virtual void ReadInitialValue (FieldDefinition field)
+ protected void Advance (int bytes)
{
+ BaseStream.Seek (bytes, SeekOrigin.Current);
}
}
}
+
+#endif
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ByteBuffer.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ByteBuffer.cs
new file mode 100644
index 0000000..4303b6d
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ByteBuffer.cs
@@ -0,0 +1,342 @@
+//
+// ByteBuffer.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Cecil.PE {
+
+ class ByteBuffer {
+
+ internal byte [] buffer;
+ internal int length;
+ internal int position;
+
+ public ByteBuffer ()
+ {
+ this.buffer = Empty<byte>.Array;
+ }
+
+ public ByteBuffer (int length)
+ {
+ this.buffer = new byte [length];
+ }
+
+ public ByteBuffer (byte [] buffer)
+ {
+ this.buffer = buffer ?? Empty<byte>.Array;
+ this.length = this.buffer.Length;
+ }
+
+ public void Reset (byte [] buffer)
+ {
+ this.buffer = buffer ?? Empty<byte>.Array;
+ this.length = this.buffer.Length;
+ }
+
+ public void Advance (int length)
+ {
+ position += length;
+ }
+
+ public byte ReadByte ()
+ {
+ return buffer [position++];
+ }
+
+ public sbyte ReadSByte ()
+ {
+ return (sbyte) ReadByte ();
+ }
+
+ public byte [] ReadBytes (int length)
+ {
+ var bytes = new byte [length];
+ Buffer.BlockCopy (buffer, position, bytes, 0, length);
+ position += length;
+ return bytes;
+ }
+
+ public ushort ReadUInt16 ()
+ {
+ ushort value = (ushort) (buffer [position]
+ | (buffer [position + 1] << 8));
+ position += 2;
+ return value;
+ }
+
+ public short ReadInt16 ()
+ {
+ return (short) ReadUInt16 ();
+ }
+
+ public uint ReadUInt32 ()
+ {
+ uint value = (uint) (buffer [position]
+ | (buffer [position + 1] << 8)
+ | (buffer [position + 2] << 16)
+ | (buffer [position + 3] << 24));
+ position += 4;
+ return value;
+ }
+
+ public int ReadInt32 ()
+ {
+ return (int) ReadUInt32 ();
+ }
+
+ public ulong ReadUInt64 ()
+ {
+ uint low = ReadUInt32 ();
+ uint high = ReadUInt32 ();
+
+ return (((ulong) high) << 32) | low;
+ }
+
+ public long ReadInt64 ()
+ {
+ return (long) ReadUInt64 ();
+ }
+
+ public uint ReadCompressedUInt32 ()
+ {
+ byte first = ReadByte ();
+ if ((first & 0x80) == 0)
+ return first;
+
+ if ((first & 0x40) == 0)
+ return ((uint) (first & ~0x80) << 8)
+ | ReadByte ();
+
+ return ((uint) (first & ~0xc0) << 24)
+ | (uint) ReadByte () << 16
+ | (uint) ReadByte () << 8
+ | ReadByte ();
+ }
+
+ public int ReadCompressedInt32 ()
+ {
+ var value = (int) ReadCompressedUInt32 ();
+
+ return (value & 1) != 0
+ ? -(value >> 1)
+ : value >> 1;
+ }
+
+ public float ReadSingle ()
+ {
+ if (!BitConverter.IsLittleEndian) {
+ var bytes = ReadBytes (4);
+ Array.Reverse (bytes);
+ return BitConverter.ToSingle (bytes, 0);
+ }
+
+ float value = BitConverter.ToSingle (buffer, position);
+ position += 4;
+ return value;
+ }
+
+ public double ReadDouble ()
+ {
+ if (!BitConverter.IsLittleEndian) {
+ var bytes = ReadBytes (8);
+ Array.Reverse (bytes);
+ return BitConverter.ToDouble (bytes, 0);
+ }
+
+ double value = BitConverter.ToDouble (buffer, position);
+ position += 8;
+ return value;
+ }
+
+#if !READ_ONLY
+
+ public void WriteByte (byte value)
+ {
+ if (position == buffer.Length)
+ Grow (1);
+
+ buffer [position++] = value;
+
+ if (position > length)
+ length = position;
+ }
+
+ public void WriteSByte (sbyte value)
+ {
+ WriteByte ((byte) value);
+ }
+
+ public void WriteUInt16 (ushort value)
+ {
+ if (position + 2 > buffer.Length)
+ Grow (2);
+
+ buffer [position++] = (byte) value;
+ buffer [position++] = (byte) (value >> 8);
+
+ if (position > length)
+ length = position;
+ }
+
+ public void WriteInt16 (short value)
+ {
+ WriteUInt16 ((ushort) value);
+ }
+
+ public void WriteUInt32 (uint value)
+ {
+ if (position + 4 > buffer.Length)
+ Grow (4);
+
+ buffer [position++] = (byte) value;
+ buffer [position++] = (byte) (value >> 8);
+ buffer [position++] = (byte) (value >> 16);
+ buffer [position++] = (byte) (value >> 24);
+
+ if (position > length)
+ length = position;
+ }
+
+ public void WriteInt32 (int value)
+ {
+ WriteUInt32 ((uint) value);
+ }
+
+ public void WriteUInt64 (ulong value)
+ {
+ if (position + 8 > buffer.Length)
+ Grow (8);
+
+ buffer [position++] = (byte) value;
+ buffer [position++] = (byte) (value >> 8);
+ buffer [position++] = (byte) (value >> 16);
+ buffer [position++] = (byte) (value >> 24);
+ buffer [position++] = (byte) (value >> 32);
+ buffer [position++] = (byte) (value >> 40);
+ buffer [position++] = (byte) (value >> 48);
+ buffer [position++] = (byte) (value >> 56);
+
+ if (position > length)
+ length = position;
+ }
+
+ public void WriteInt64 (long value)
+ {
+ WriteUInt64 ((ulong) value);
+ }
+
+ public void WriteCompressedUInt32 (uint value)
+ {
+ if (value < 0x80)
+ WriteByte ((byte) value);
+ else if (value < 0x4000) {
+ WriteByte ((byte) (0x80 | (value >> 8)));
+ WriteByte ((byte) (value & 0xff));
+ } else {
+ WriteByte ((byte) ((value >> 24) | 0xc0));
+ WriteByte ((byte) ((value >> 16) & 0xff));
+ WriteByte ((byte) ((value >> 8) & 0xff));
+ WriteByte ((byte) (value & 0xff));
+ }
+ }
+
+ public void WriteCompressedInt32 (int value)
+ {
+ WriteCompressedUInt32 ((uint) ((value < 0) ? ((-value) << 1) | 1 : value << 1));
+ }
+
+ public void WriteBytes (byte [] bytes)
+ {
+ var length = bytes.Length;
+ if (position + length > buffer.Length)
+ Grow (length);
+
+ Buffer.BlockCopy (bytes, 0, buffer, position, length);
+ position += length;
+
+ if (position > this.length)
+ this.length = position;
+ }
+
+ public void WriteBytes (int length)
+ {
+ if (position + length > buffer.Length)
+ Grow (length);
+
+ position += length;
+
+ if (position > this.length)
+ this.length = position;
+ }
+
+ public void WriteBytes (ByteBuffer buffer)
+ {
+ if (position + buffer.length > this.buffer.Length)
+ Grow (buffer.length);
+
+ Buffer.BlockCopy (buffer.buffer, 0, this.buffer, position, buffer.length);
+ position += buffer.length;
+
+ if (position > this.length)
+ this.length = position;
+ }
+
+ public void WriteSingle (float value)
+ {
+ var bytes = BitConverter.GetBytes (value);
+
+ if (!BitConverter.IsLittleEndian)
+ Array.Reverse (bytes);
+
+ WriteBytes (bytes);
+ }
+
+ public void WriteDouble (double value)
+ {
+ var bytes = BitConverter.GetBytes (value);
+
+ if (!BitConverter.IsLittleEndian)
+ Array.Reverse (bytes);
+
+ WriteBytes (bytes);
+ }
+
+ void Grow (int desired)
+ {
+ var current = this.buffer;
+ var current_length = current.Length;
+
+ var buffer = new byte [System.Math.Max (current_length + desired, current_length * 2)];
+ Buffer.BlockCopy (current, 0, buffer, 0, current_length);
+ this.buffer = buffer;
+ }
+
+#endif
+
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionException.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs
index 4027313..fd78025 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionException.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs
@@ -1,10 +1,10 @@
//
-// ReflectionException.cs
+// ByteBufferEqualityComparer.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,30 +26,36 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
+using System.Collections.Generic;
- using System;
+namespace Mono.Cecil.PE {
- using Mono.Cecil.Metadata;
+ sealed class ByteBufferEqualityComparer : IEqualityComparer<ByteBuffer> {
- public sealed class ReflectionException : MetadataFormatException {
-
- internal ReflectionException () : base ()
+ public bool Equals (ByteBuffer x, ByteBuffer y)
{
- }
+ if (x.length != y.length)
+ return false;
- internal ReflectionException (string message) : base (message)
- {
- }
+ var x_buffer = x.buffer;
+ var y_buffer = y.buffer;
- internal ReflectionException (string message, params string [] parameters) :
- base (string.Format (message, parameters))
- {
+ for (int i = 0; i < x.length; i++)
+ if (x_buffer [i] != y_buffer [i])
+ return false;
+
+ return true;
}
- internal ReflectionException (string message, Exception inner) :
- base (message, inner)
+ public int GetHashCode (ByteBuffer buffer)
{
+ var hash = 0;
+ var bytes = buffer.buffer;
+ for (int i = 0; i < buffer.length; i++)
+ hash = (hash * 37) ^ bytes [i];
+
+ return hash;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Signature.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/DataDirectory.cs
index 5d9e254..5ba2d2d 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Signature.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/DataDirectory.cs
@@ -1,10 +1,10 @@
//
-// Signature.cs
+// DataDirectory.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,25 +26,25 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil.Signatures {
+using System;
- using System;
+using RVA = System.UInt32;
- internal abstract class Signature : ISignatureVisitable {
+namespace Mono.Cecil.PE {
- public byte CallingConvention;
- public uint BlobIndex;
+ struct DataDirectory {
- public Signature (uint blobIndex)
- {
- BlobIndex = blobIndex;
+ public readonly RVA VirtualAddress;
+ public readonly uint Size;
+
+ public bool IsZero {
+ get { return VirtualAddress == 0 && Size == 0; }
}
- public Signature ()
+ public DataDirectory (RVA rva, uint size)
{
- BlobIndex = 0;
+ this.VirtualAddress = rva;
+ this.Size = size;
}
-
- public abstract void Accept (ISignatureVisitor visitor);
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/Image.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/Image.cs
new file mode 100644
index 0000000..11aba8f
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/Image.cs
@@ -0,0 +1,159 @@
+//
+// Image.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+using Mono;
+using Mono.Cecil.Cil;
+using Mono.Cecil.Metadata;
+
+using RVA = System.UInt32;
+
+namespace Mono.Cecil.PE {
+
+ sealed class Image {
+
+ public ModuleKind Kind;
+ public TargetRuntime Runtime;
+ public TargetArchitecture Architecture;
+ public string FileName;
+
+ public Section [] Sections;
+
+ public Section MetadataSection;
+
+ public uint EntryPointToken;
+ public ModuleAttributes Attributes;
+
+ public DataDirectory Debug;
+ public DataDirectory Resources;
+
+ public StringHeap StringHeap;
+ public BlobHeap BlobHeap;
+ public UserStringHeap UserStringHeap;
+ public GuidHeap GuidHeap;
+ public TableHeap TableHeap;
+
+ readonly int [] coded_index_sizes = new int [13];
+
+ readonly Func<Table, int> counter;
+
+ public Image ()
+ {
+ counter = GetTableLength;
+ }
+
+ public bool HasTable (Table table)
+ {
+ return GetTableLength (table) > 0;
+ }
+
+ public int GetTableLength (Table table)
+ {
+ return (int) TableHeap [table].Length;
+ }
+
+ public int GetTableIndexSize (Table table)
+ {
+ return GetTableLength (table) < 65536 ? 2 : 4;
+ }
+
+ public int GetCodedIndexSize (CodedIndex coded_index)
+ {
+ var index = (int) coded_index;
+ var size = coded_index_sizes [index];
+ if (size != 0)
+ return size;
+
+ return coded_index_sizes [index] = coded_index.GetSize (counter);
+ }
+
+ public uint ResolveVirtualAddress (RVA rva)
+ {
+ var section = GetSectionAtVirtualAddress (rva);
+ if (section == null)
+ throw new ArgumentOutOfRangeException ();
+
+ return ResolveVirtualAddressInSection (rva, section);
+ }
+
+ public uint ResolveVirtualAddressInSection (RVA rva, Section section)
+ {
+ return rva + section.PointerToRawData - section.VirtualAddress;
+ }
+
+ public Section GetSection (string name)
+ {
+ var sections = this.Sections;
+ for (int i = 0; i < sections.Length; i++) {
+ var section = sections [i];
+ if (section.Name == name)
+ return section;
+ }
+
+ return null;
+ }
+
+ public Section GetSectionAtVirtualAddress (RVA rva)
+ {
+ var sections = this.Sections;
+ for (int i = 0; i < sections.Length; i++) {
+ var section = sections [i];
+ if (rva >= section.VirtualAddress && rva < section.VirtualAddress + section.SizeOfRawData)
+ return section;
+ }
+
+ return null;
+ }
+
+ public ImageDebugDirectory GetDebugHeader (out byte [] header)
+ {
+ var section = GetSectionAtVirtualAddress (Debug.VirtualAddress);
+ var buffer = new ByteBuffer (section.Data);
+ buffer.position = (int) (Debug.VirtualAddress - section.VirtualAddress);
+
+ var directory = new ImageDebugDirectory {
+ Characteristics = buffer.ReadInt32 (),
+ TimeDateStamp = buffer.ReadInt32 (),
+ MajorVersion = buffer.ReadInt16 (),
+ MinorVersion = buffer.ReadInt16 (),
+ Type = buffer.ReadInt32 (),
+ SizeOfData = buffer.ReadInt32 (),
+ AddressOfRawData = buffer.ReadInt32 (),
+ PointerToRawData = buffer.ReadInt32 (),
+ };
+
+ buffer.position = (int) (directory.PointerToRawData - section.PointerToRawData);
+
+ header = new byte [directory.SizeOfData];
+ Buffer.BlockCopy (buffer.buffer, buffer.position, header, 0, header.Length);
+
+ return directory;
+ }
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageReader.cs
new file mode 100644
index 0000000..a228c1f
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageReader.cs
@@ -0,0 +1,678 @@
+//
+// ImageReader.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+
+using Mono.Cecil.Metadata;
+
+using RVA = System.UInt32;
+
+namespace Mono.Cecil.PE {
+
+ sealed class ImageReader : BinaryStreamReader {
+
+ readonly Image image;
+
+ DataDirectory cli;
+ DataDirectory metadata;
+
+ public ImageReader (Stream stream)
+ : base (stream)
+ {
+ image = new Image ();
+
+ image.FileName = stream.GetFullyQualifiedName ();
+ }
+
+ void MoveTo (DataDirectory directory)
+ {
+ BaseStream.Position = image.ResolveVirtualAddress (directory.VirtualAddress);
+ }
+
+ void MoveTo (uint position)
+ {
+ BaseStream.Position = position;
+ }
+
+ void ReadImage ()
+ {
+ if (BaseStream.Length < 128)
+ throw new BadImageFormatException ();
+
+ // - DOSHeader
+
+ // PE 2
+ // Start 58
+ // Lfanew 4
+ // End 64
+
+ if (ReadUInt16 () != 0x5a4d)
+ throw new BadImageFormatException ();
+
+ Advance (58);
+
+ MoveTo (ReadUInt32 ());
+
+ if (ReadUInt32 () != 0x00004550)
+ throw new BadImageFormatException ();
+
+ // - PEFileHeader
+
+ // Machine 2
+ image.Architecture = ReadArchitecture ();
+
+ // NumberOfSections 2
+ ushort sections = ReadUInt16 ();
+
+ // TimeDateStamp 4
+ // PointerToSymbolTable 4
+ // NumberOfSymbols 4
+ // OptionalHeaderSize 2
+ Advance (14);
+
+ // Characteristics 2
+ ushort characteristics = ReadUInt16 ();
+
+ ushort subsystem;
+ ReadOptionalHeaders (out subsystem);
+ ReadSections (sections);
+ ReadCLIHeader ();
+ ReadMetadata ();
+
+ image.Kind = GetModuleKind (characteristics, subsystem);
+ }
+
+ TargetArchitecture ReadArchitecture ()
+ {
+ var machine = ReadUInt16 ();
+ switch (machine) {
+ case 0x014c:
+ return TargetArchitecture.I386;
+ case 0x8664:
+ return TargetArchitecture.AMD64;
+ case 0x0200:
+ return TargetArchitecture.IA64;
+ }
+
+ throw new NotSupportedException ();
+ }
+
+ static ModuleKind GetModuleKind (ushort characteristics, ushort subsystem)
+ {
+ if ((characteristics & 0x2000) != 0) // ImageCharacteristics.Dll
+ return ModuleKind.Dll;
+
+ if (subsystem == 0x2 || subsystem == 0x9) // SubSystem.WindowsGui || SubSystem.WindowsCeGui
+ return ModuleKind.Windows;
+
+ return ModuleKind.Console;
+ }
+
+ void ReadOptionalHeaders (out ushort subsystem)
+ {
+ // - PEOptionalHeader
+ // - StandardFieldsHeader
+
+ // Magic 2
+ bool pe64 = ReadUInt16 () == 0x20b;
+
+ // pe32 || pe64
+
+ // LMajor 1
+ // LMinor 1
+ // CodeSize 4
+ // InitializedDataSize 4
+ // UninitializedDataSize4
+ // EntryPointRVA 4
+ // BaseOfCode 4
+ // BaseOfData 4 || 0
+
+ // - NTSpecificFieldsHeader
+
+ // ImageBase 4 || 8
+ // SectionAlignment 4
+ // FileAlignement 4
+ // OSMajor 2
+ // OSMinor 2
+ // UserMajor 2
+ // UserMinor 2
+ // SubSysMajor 2
+ // SubSysMinor 2
+ // Reserved 4
+ // ImageSize 4
+ // HeaderSize 4
+ // FileChecksum 4
+ Advance (66);
+
+ // SubSystem 2
+ subsystem = ReadUInt16 ();
+
+ // DLLFlags 2
+ // StackReserveSize 4 || 8
+ // StackCommitSize 4 || 8
+ // HeapReserveSize 4 || 8
+ // HeapCommitSize 4 || 8
+ // LoaderFlags 4
+ // NumberOfDataDir 4
+
+ // - DataDirectoriesHeader
+
+ // ExportTable 8
+ // ImportTable 8
+ // ResourceTable 8
+ // ExceptionTable 8
+ // CertificateTable 8
+ // BaseRelocationTable 8
+
+ Advance (pe64 ? 90 : 74);
+
+ // Debug 8
+ image.Debug = ReadDataDirectory ();
+
+ // Copyright 8
+ // GlobalPtr 8
+ // TLSTable 8
+ // LoadConfigTable 8
+ // BoundImport 8
+ // IAT 8
+ // DelayImportDescriptor8
+ Advance (56);
+
+ // CLIHeader 8
+ cli = ReadDataDirectory ();
+
+ if (cli.IsZero)
+ throw new BadImageFormatException ();
+
+ // Reserved 8
+ Advance (8);
+ }
+
+ string ReadAlignedString (int length)
+ {
+ int read = 0;
+ var buffer = new char [length];
+ while (read < length) {
+ var current = ReadByte ();
+ if (current == 0)
+ break;
+
+ buffer [read++] = (char) current;
+ }
+
+ Advance (-1 + ((read + 4) & ~3) - read);
+
+ return new string (buffer, 0, read);
+ }
+
+ string ReadZeroTerminatedString (int length)
+ {
+ int read = 0;
+ var buffer = new char [length];
+ var bytes = ReadBytes (length);
+ while (read < length) {
+ var current = bytes [read];
+ if (current == 0)
+ break;
+
+ buffer [read++] = (char) current;
+ }
+
+ return new string (buffer, 0, read);
+ }
+
+ void ReadSections (ushort count)
+ {
+ var sections = new Section [count];
+
+ for (int i = 0; i < count; i++) {
+ var section = new Section ();
+
+ // Name
+ section.Name = ReadZeroTerminatedString (8);
+
+ // VirtualSize 4
+ Advance (4);
+
+ // VirtualAddress 4
+ section.VirtualAddress = ReadUInt32 ();
+ // SizeOfRawData 4
+ section.SizeOfRawData = ReadUInt32 ();
+ // PointerToRawData 4
+ section.PointerToRawData = ReadUInt32 ();
+
+ // PointerToRelocations 4
+ // PointerToLineNumbers 4
+ // NumberOfRelocations 2
+ // NumberOfLineNumbers 2
+ // Characteristics 4
+ Advance (16);
+
+ sections [i] = section;
+
+ if (section.Name == ".reloc")
+ continue;
+
+ ReadSectionData (section);
+ }
+
+ image.Sections = sections;
+ }
+
+ void ReadSectionData (Section section)
+ {
+ var position = BaseStream.Position;
+
+ MoveTo (section.PointerToRawData);
+
+ var length = (int) section.SizeOfRawData;
+ var data = new byte [length];
+ int offset = 0, read;
+
+ while ((read = Read (data, offset, length - offset)) > 0)
+ offset += read;
+
+ section.Data = data;
+
+ BaseStream.Position = position;
+ }
+
+ void ReadCLIHeader ()
+ {
+ MoveTo (cli);
+
+ // - CLIHeader
+
+ // Cb 4
+ // MajorRuntimeVersion 2
+ // MinorRuntimeVersion 2
+ Advance (8);
+
+ // Metadata 8
+ metadata = ReadDataDirectory ();
+ // Flags 4
+ image.Attributes = (ModuleAttributes) ReadUInt32 ();
+ // EntryPointToken 4
+ image.EntryPointToken = ReadUInt32 ();
+ // Resources 8
+ image.Resources = ReadDataDirectory ();
+ // StrongNameSignature 8
+ // CodeManagerTable 8
+ // VTableFixups 8
+ // ExportAddressTableJumps 8
+ // ManagedNativeHeader 8
+ }
+
+ void ReadMetadata ()
+ {
+ MoveTo (metadata);
+
+ if (ReadUInt32 () != 0x424a5342)
+ throw new BadImageFormatException ();
+
+ // MajorVersion 2
+ // MinorVersion 2
+ // Reserved 4
+ Advance (8);
+
+ var version = ReadZeroTerminatedString (ReadInt32 ());
+ image.Runtime = version.ParseRuntime ();
+
+ // Flags 2
+ Advance (2);
+
+ var streams = ReadUInt16 ();
+
+ var section = image.GetSectionAtVirtualAddress (metadata.VirtualAddress);
+ if (section == null)
+ throw new BadImageFormatException ();
+
+ image.MetadataSection = section;
+
+ for (int i = 0; i < streams; i++)
+ ReadMetadataStream (section);
+
+ if (image.TableHeap != null)
+ ReadTableHeap ();
+ }
+
+ void ReadMetadataStream (Section section)
+ {
+ // Offset 4
+ uint start = metadata.VirtualAddress - section.VirtualAddress + ReadUInt32 (); // relative to the section start
+
+ // Size 4
+ uint size = ReadUInt32 ();
+
+ var name = ReadAlignedString (16);
+ switch (name) {
+ case "#~":
+ case "#-":
+ image.TableHeap = new TableHeap (section, start, size);
+ break;
+ case "#Strings":
+ image.StringHeap = new StringHeap (section, start, size);
+ break;
+ case "#Blob":
+ image.BlobHeap = new BlobHeap (section, start, size);
+ break;
+ case "#GUID":
+ image.GuidHeap = new GuidHeap (section, start, size);
+ break;
+ case "#US":
+ image.UserStringHeap = new UserStringHeap (section, start, size);
+ break;
+ }
+ }
+
+ void ReadTableHeap ()
+ {
+ var heap = image.TableHeap;
+
+ uint start = heap.Section.PointerToRawData;
+
+ MoveTo (heap.Offset + start);
+
+ // Reserved 4
+ // MajorVersion 1
+ // MinorVersion 1
+ Advance (6);
+
+ // HeapSizes 1
+ var sizes = ReadByte ();
+
+ // Reserved2 1
+ Advance (1);
+
+ // Valid 8
+ heap.Valid = ReadInt64 ();
+
+ // Sorted 8
+ heap.Sorted = ReadInt64 ();
+
+ for (int i = 0; i < TableHeap.TableIdentifiers.Length; i++) {
+ var table = TableHeap.TableIdentifiers [i];
+ if (!heap.HasTable (table))
+ continue;
+
+ heap.Tables [(int) table].Length = ReadUInt32 ();
+ }
+
+ SetIndexSize (image.StringHeap, sizes, 0x1);
+ SetIndexSize (image.GuidHeap, sizes, 0x2);
+ SetIndexSize (image.BlobHeap, sizes, 0x4);
+
+ ComputeTableInformations ();
+ }
+
+ static void SetIndexSize (Heap heap, uint sizes, byte flag)
+ {
+ if (heap == null)
+ return;
+
+ heap.IndexSize = (sizes & flag) > 0 ? 4 : 2;
+ }
+
+ int GetTableIndexSize (Table table)
+ {
+ return image.GetTableIndexSize (table);
+ }
+
+ int GetCodedIndexSize (CodedIndex index)
+ {
+ return image.GetCodedIndexSize (index);
+ }
+
+ void ComputeTableInformations ()
+ {
+ uint offset = (uint) BaseStream.Position - image.MetadataSection.PointerToRawData; // header
+
+ int stridx_size = image.StringHeap.IndexSize;
+ int blobidx_size = image.BlobHeap != null ? image.BlobHeap.IndexSize : 2;
+
+ var heap = image.TableHeap;
+ var tables = heap.Tables;
+
+ for (int i = 0; i < TableHeap.TableIdentifiers.Length; i++) {
+ var table = TableHeap.TableIdentifiers [i];
+ if (!heap.HasTable (table))
+ continue;
+
+ int size;
+ switch (table) {
+ case Table.Module:
+ size = 2 // Generation
+ + stridx_size // Name
+ + (image.GuidHeap.IndexSize * 3); // Mvid, EncId, EncBaseId
+ break;
+ case Table.TypeRef:
+ size = GetCodedIndexSize (CodedIndex.ResolutionScope) // ResolutionScope
+ + (stridx_size * 2); // Name, Namespace
+ break;
+ case Table.TypeDef:
+ size = 4 // Flags
+ + (stridx_size * 2) // Name, Namespace
+ + GetCodedIndexSize (CodedIndex.TypeDefOrRef) // BaseType
+ + GetTableIndexSize (Table.Field) // FieldList
+ + GetTableIndexSize (Table.Method); // MethodList
+ break;
+ case Table.FieldPtr:
+ size = GetTableIndexSize (Table.Field); // Field
+ break;
+ case Table.Field:
+ size = 2 // Flags
+ + stridx_size // Name
+ + blobidx_size; // Signature
+ break;
+ case Table.MethodPtr:
+ size = GetTableIndexSize (Table.Method); // Method
+ break;
+ case Table.Method:
+ size = 8 // Rva 4, ImplFlags 2, Flags 2
+ + stridx_size // Name
+ + blobidx_size // Signature
+ + GetTableIndexSize (Table.Param); // ParamList
+ break;
+ case Table.ParamPtr:
+ size = GetTableIndexSize (Table.Param); // Param
+ break;
+ case Table.Param:
+ size = 4 // Flags 2, Sequence 2
+ + stridx_size; // Name
+ break;
+ case Table.InterfaceImpl:
+ size = GetTableIndexSize (Table.TypeDef) // Class
+ + GetCodedIndexSize (CodedIndex.TypeDefOrRef); // Interface
+ break;
+ case Table.MemberRef:
+ size = GetCodedIndexSize (CodedIndex.MemberRefParent) // Class
+ + stridx_size // Name
+ + blobidx_size; // Signature
+ break;
+ case Table.Constant:
+ size = 2 // Type
+ + GetCodedIndexSize (CodedIndex.HasConstant) // Parent
+ + blobidx_size; // Value
+ break;
+ case Table.CustomAttribute:
+ size = GetCodedIndexSize (CodedIndex.HasCustomAttribute) // Parent
+ + GetCodedIndexSize (CodedIndex.CustomAttributeType) // Type
+ + blobidx_size; // Value
+ break;
+ case Table.FieldMarshal:
+ size = GetCodedIndexSize (CodedIndex.HasFieldMarshal) // Parent
+ + blobidx_size; // NativeType
+ break;
+ case Table.DeclSecurity:
+ size = 2 // Action
+ + GetCodedIndexSize (CodedIndex.HasDeclSecurity) // Parent
+ + blobidx_size; // PermissionSet
+ break;
+ case Table.ClassLayout:
+ size = 6 // PackingSize 2, ClassSize 4
+ + GetTableIndexSize (Table.TypeDef); // Parent
+ break;
+ case Table.FieldLayout:
+ size = 4 // Offset
+ + GetTableIndexSize (Table.Field); // Field
+ break;
+ case Table.StandAloneSig:
+ size = blobidx_size; // Signature
+ break;
+ case Table.EventMap:
+ size = GetTableIndexSize (Table.TypeDef) // Parent
+ + GetTableIndexSize (Table.Event); // EventList
+ break;
+ case Table.EventPtr:
+ size = GetTableIndexSize (Table.Event); // Event
+ break;
+ case Table.Event:
+ size = 2 // Flags
+ + stridx_size // Name
+ + GetCodedIndexSize (CodedIndex.TypeDefOrRef); // EventType
+ break;
+ case Table.PropertyMap:
+ size = GetTableIndexSize (Table.TypeDef) // Parent
+ + GetTableIndexSize (Table.Property); // PropertyList
+ break;
+ case Table.PropertyPtr:
+ size = GetTableIndexSize (Table.Property); // Property
+ break;
+ case Table.Property:
+ size = 2 // Flags
+ + stridx_size // Name
+ + blobidx_size; // Type
+ break;
+ case Table.MethodSemantics:
+ size = 2 // Semantics
+ + GetTableIndexSize (Table.Method) // Method
+ + GetCodedIndexSize (CodedIndex.HasSemantics); // Association
+ break;
+ case Table.MethodImpl:
+ size = GetTableIndexSize (Table.TypeDef) // Class
+ + GetCodedIndexSize (CodedIndex.MethodDefOrRef) // MethodBody
+ + GetCodedIndexSize (CodedIndex.MethodDefOrRef); // MethodDeclaration
+ break;
+ case Table.ModuleRef:
+ size = stridx_size; // Name
+ break;
+ case Table.TypeSpec:
+ size = blobidx_size; // Signature
+ break;
+ case Table.ImplMap:
+ size = 2 // MappingFlags
+ + GetCodedIndexSize (CodedIndex.MemberForwarded) // MemberForwarded
+ + stridx_size // ImportName
+ + GetTableIndexSize (Table.ModuleRef); // ImportScope
+ break;
+ case Table.FieldRVA:
+ size = 4 // RVA
+ + GetTableIndexSize (Table.Field); // Field
+ break;
+ case Table.Assembly:
+ size = 16 // HashAlgId 4, Version 4 * 2, Flags 4
+ + blobidx_size // PublicKey
+ + (stridx_size * 2); // Name, Culture
+ break;
+ case Table.AssemblyProcessor:
+ size = 4; // Processor
+ break;
+ case Table.AssemblyOS:
+ size = 12; // Platform 4, Version 2 * 4
+ break;
+ case Table.AssemblyRef:
+ size = 12 // Version 2 * 4 + Flags 4
+ + (blobidx_size * 2) // PublicKeyOrToken, HashValue
+ + (stridx_size * 2); // Name, Culture
+ break;
+ case Table.AssemblyRefProcessor:
+ size = 4 // Processor
+ + GetTableIndexSize (Table.AssemblyRef); // AssemblyRef
+ break;
+ case Table.AssemblyRefOS:
+ size = 12 // Platform 4, Version 2 * 4
+ + GetTableIndexSize (Table.AssemblyRef); // AssemblyRef
+ break;
+ case Table.File:
+ size = 4 // Flags
+ + stridx_size // Name
+ + blobidx_size; // HashValue
+ break;
+ case Table.ExportedType:
+ size = 8 // Flags 4, TypeDefId 4
+ + (stridx_size * 2) // Name, Namespace
+ + GetCodedIndexSize (CodedIndex.Implementation); // Implementation
+ break;
+ case Table.ManifestResource:
+ size = 8 // Offset, Flags
+ + stridx_size // Name
+ + GetCodedIndexSize (CodedIndex.Implementation); // Implementation
+ break;
+ case Table.NestedClass:
+ size = GetTableIndexSize (Table.TypeDef) // NestedClass
+ + GetTableIndexSize (Table.TypeDef); // EnclosingClass
+ break;
+ case Table.GenericParam:
+ size = 4 // Number, Flags
+ + GetCodedIndexSize (CodedIndex.TypeOrMethodDef) // Owner
+ + stridx_size; // Name
+ break;
+ case Table.MethodSpec:
+ size = GetCodedIndexSize (CodedIndex.MethodDefOrRef) // Method
+ + blobidx_size; // Instantiation
+ break;
+ case Table.GenericParamConstraint:
+ size = GetTableIndexSize (Table.GenericParam) // Owner
+ + GetCodedIndexSize (CodedIndex.TypeDefOrRef); // Constraint
+ break;
+ default:
+ throw new NotSupportedException ();
+ }
+
+ int index = (int) table;
+
+ tables [index].RowSize = (uint) size;
+ tables [index].Offset = offset;
+
+ offset += (uint) size * tables [index].Length;
+ }
+ }
+
+ public static Image ReadImageFrom (Stream stream)
+ {
+ try {
+ var reader = new ImageReader (stream);
+ reader.ReadImage ();
+ return reader.image;
+ } catch (EndOfStreamException e) {
+ throw new BadImageFormatException (stream.GetFullyQualifiedName (), e);
+ }
+ }
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs
new file mode 100644
index 0000000..939de6b
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs
@@ -0,0 +1,820 @@
+//
+// ImageWriter.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+
+#if !READ_ONLY
+
+using Mono.Cecil.Cil;
+using Mono.Cecil.Metadata;
+
+using RVA = System.UInt32;
+
+namespace Mono.Cecil.PE {
+
+ sealed class ImageWriter : BinaryStreamWriter {
+
+ readonly ModuleDefinition module;
+ readonly MetadataBuilder metadata;
+ readonly TextMap text_map;
+
+ ImageDebugDirectory debug_directory;
+ byte [] debug_data;
+
+ ByteBuffer win32_resources;
+
+ const uint pe_header_size = 0x178u;
+ const uint section_header_size = 0x28u;
+ const uint file_alignment = 0x200;
+ const uint section_alignment = 0x2000;
+ const ulong image_base = 0x00400000;
+
+ internal const RVA text_rva = 0x2000;
+
+ readonly bool pe64;
+ readonly uint time_stamp;
+
+ internal Section text;
+ internal Section rsrc;
+ internal Section reloc;
+
+ ushort sections;
+
+ ImageWriter (ModuleDefinition module, MetadataBuilder metadata, Stream stream)
+ : base (stream)
+ {
+ this.module = module;
+ this.metadata = metadata;
+ this.GetDebugHeader ();
+ this.GetWin32Resources ();
+ this.text_map = BuildTextMap ();
+ this.sections = 2; // text + reloc
+ this.pe64 = module.Architecture != TargetArchitecture.I386;
+ this.time_stamp = (uint) DateTime.UtcNow.Subtract (new DateTime (1970, 1, 1)).TotalSeconds;
+ }
+
+ void GetDebugHeader ()
+ {
+ var symbol_writer = metadata.symbol_writer;
+ if (symbol_writer == null)
+ return;
+
+ if (!symbol_writer.GetDebugHeader (out debug_directory, out debug_data))
+ debug_data = Empty<byte>.Array;
+ }
+
+ void GetWin32Resources ()
+ {
+ var rsrc = GetImageResourceSection ();
+ if (rsrc == null)
+ return;
+
+ var raw_resources = new byte [rsrc.Data.Length];
+ Buffer.BlockCopy (rsrc.Data, 0, raw_resources, 0, rsrc.Data.Length);
+ win32_resources = new ByteBuffer (raw_resources);
+ }
+
+ Section GetImageResourceSection ()
+ {
+ if (!module.HasImage)
+ return null;
+
+ const string rsrc_section = ".rsrc";
+
+ return module.Image.GetSection (rsrc_section);
+ }
+
+ public static ImageWriter CreateWriter (ModuleDefinition module, MetadataBuilder metadata, Stream stream)
+ {
+ var writer = new ImageWriter (module, metadata, stream);
+ writer.BuildSections ();
+ return writer;
+ }
+
+ void BuildSections ()
+ {
+ var has_win32_resources = win32_resources != null;
+ if (has_win32_resources)
+ sections++;
+
+ text = CreateSection (".text", text_map.GetLength (), null);
+ var previous = text;
+
+ if (has_win32_resources) {
+ rsrc = CreateSection (".rsrc", (uint) win32_resources.length, previous);
+
+ PatchWin32Resources (win32_resources);
+ previous = rsrc;
+ }
+
+ reloc = CreateSection (".reloc", 12u, previous);
+ }
+
+ Section CreateSection (string name, uint size, Section previous)
+ {
+ return new Section {
+ Name = name,
+ VirtualAddress = previous != null
+ ? previous.VirtualAddress + Align (previous.VirtualSize, section_alignment)
+ : text_rva,
+ VirtualSize = size,
+ PointerToRawData = previous != null
+ ? previous.PointerToRawData + previous.SizeOfRawData
+ : Align (GetHeaderSize (), file_alignment),
+ SizeOfRawData = Align (size, file_alignment)
+ };
+ }
+
+ static uint Align (uint value, uint align)
+ {
+ align--;
+ return (value + align) & ~align;
+ }
+
+ void WriteDOSHeader ()
+ {
+ Write (new byte [] {
+ // dos header start
+ 0x4d, 0x5a, 0x90, 0x00, 0x03, 0x00, 0x00,
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff,
+ 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ // lfanew
+ 0x80, 0x00, 0x00, 0x00,
+ // dos header end
+ 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09,
+ 0xcd, 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21,
+ 0x54, 0x68, 0x69, 0x73, 0x20, 0x70, 0x72,
+ 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x20, 0x63,
+ 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x20, 0x62,
+ 0x65, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x69,
+ 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, 0x6d,
+ 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a,
+ 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00
+ });
+ }
+
+ void WritePEFileHeader ()
+ {
+ WriteUInt32 (0x00004550); // Magic
+ WriteUInt16 (GetMachine ()); // Machine
+ WriteUInt16 (sections); // NumberOfSections
+ WriteUInt32 (time_stamp);
+ WriteUInt32 (0); // PointerToSymbolTable
+ WriteUInt32 (0); // NumberOfSymbols
+ WriteUInt16 ((ushort) (!pe64 ? 0xe0 : 0xf0)); // SizeOfOptionalHeader
+
+ // ExecutableImage | (pe64 ? 32BitsMachine : LargeAddressAware)
+ var characteristics = (ushort) (0x0002 | (!pe64 ? 0x0100 : 0x0020));
+ if (module.Kind == ModuleKind.Dll || module.Kind == ModuleKind.NetModule)
+ characteristics |= 0x2000;
+ WriteUInt16 (characteristics); // Characteristics
+ }
+
+ ushort GetMachine ()
+ {
+ switch (module.Architecture) {
+ case TargetArchitecture.I386:
+ return 0x014c;
+ case TargetArchitecture.AMD64:
+ return 0x8664;
+ case TargetArchitecture.IA64:
+ return 0x0200;
+ }
+
+ throw new NotSupportedException ();
+ }
+
+ void WriteOptionalHeaders ()
+ {
+ WriteUInt16 ((ushort) (!pe64 ? 0x10b : 0x20b)); // Magic
+ WriteByte (8); // LMajor
+ WriteByte (0); // LMinor
+ WriteUInt32 (text.SizeOfRawData); // CodeSize
+ WriteUInt32 (reloc.SizeOfRawData
+ + (rsrc != null ? rsrc.SizeOfRawData : 0)); // InitializedDataSize
+ WriteUInt32 (0); // UninitializedDataSize
+
+ var entry_point_rva = text_map.GetRVA (TextSegment.StartupStub);
+ if (module.Architecture == TargetArchitecture.IA64)
+ entry_point_rva += 0x20;
+ WriteUInt32 (entry_point_rva); // EntryPointRVA
+ WriteUInt32 (text_rva); // BaseOfCode
+
+ if (!pe64) {
+ WriteUInt32 (0); // BaseOfData
+ WriteUInt32 ((uint) image_base); // ImageBase
+ } else {
+ WriteUInt64 (image_base); // ImageBase
+ }
+
+ WriteUInt32 (section_alignment); // SectionAlignment
+ WriteUInt32 (file_alignment); // FileAlignment
+
+ WriteUInt16 (4); // OSMajor
+ WriteUInt16 (0); // OSMinor
+ WriteUInt16 (0); // UserMajor
+ WriteUInt16 (0); // UserMinor
+ WriteUInt16 (4); // SubSysMajor
+ WriteUInt16 (0); // SubSysMinor
+ WriteUInt32 (0); // Reserved
+
+ WriteUInt32 (reloc.VirtualAddress + Align (reloc.VirtualSize, section_alignment)); // ImageSize
+ WriteUInt32 (text.PointerToRawData); // HeaderSize
+
+ WriteUInt32 (0); // Checksum
+ WriteUInt16 (GetSubSystem ()); // SubSystem
+ WriteUInt16 (0x8540); // DLLFlags
+
+ const ulong stack_reserve = 0x100000;
+ const ulong stack_commit = 0x1000;
+ const ulong heap_reserve = 0x100000;
+ const ulong heap_commit = 0x1000;
+
+ if (!pe64) {
+ WriteUInt32 ((uint) stack_reserve);
+ WriteUInt32 ((uint) stack_commit);
+ WriteUInt32 ((uint) heap_reserve);
+ WriteUInt32 ((uint) heap_commit);
+ } else {
+ WriteUInt64 (stack_reserve);
+ WriteUInt64 (stack_commit);
+ WriteUInt64 (heap_reserve);
+ WriteUInt64 (heap_commit);
+ }
+
+ WriteUInt32 (0); // LoaderFlags
+ WriteUInt32 (16); // NumberOfDataDir
+
+ WriteZeroDataDirectory (); // ExportTable
+ WriteDataDirectory (text_map.GetDataDirectory (TextSegment.ImportDirectory)); // ImportTable
+ if (rsrc != null) { // ResourceTable
+ WriteUInt32 (rsrc.VirtualAddress);
+ WriteUInt32 (rsrc.VirtualSize);
+ } else
+ WriteZeroDataDirectory ();
+
+ WriteZeroDataDirectory (); // ExceptionTable
+ WriteZeroDataDirectory (); // CertificateTable
+ WriteUInt32 (reloc.VirtualAddress); // BaseRelocationTable
+ WriteUInt32 (reloc.VirtualSize);
+
+ if (text_map.GetLength (TextSegment.DebugDirectory) > 0) {
+ WriteUInt32 (text_map.GetRVA (TextSegment.DebugDirectory));
+ WriteUInt32 (28u);
+ } else
+ WriteZeroDataDirectory ();
+
+ WriteZeroDataDirectory (); // Copyright
+ WriteZeroDataDirectory (); // GlobalPtr
+ WriteZeroDataDirectory (); // TLSTable
+ WriteZeroDataDirectory (); // LoadConfigTable
+ WriteZeroDataDirectory (); // BoundImport
+ WriteDataDirectory (text_map.GetDataDirectory (TextSegment.ImportAddressTable)); // IAT
+ WriteZeroDataDirectory (); // DelayImportDesc
+ WriteDataDirectory (text_map.GetDataDirectory (TextSegment.CLIHeader)); // CLIHeader
+ WriteZeroDataDirectory (); // Reserved
+ }
+
+ void WriteZeroDataDirectory ()
+ {
+ WriteUInt32 (0);
+ WriteUInt32 (0);
+ }
+
+ ushort GetSubSystem ()
+ {
+ switch (module.Kind) {
+ case ModuleKind.Console:
+ case ModuleKind.Dll:
+ case ModuleKind.NetModule:
+ return 0x3;
+ case ModuleKind.Windows:
+ return 0x2;
+ default:
+ throw new ArgumentOutOfRangeException ();
+ }
+ }
+
+ void WriteSectionHeaders ()
+ {
+ WriteSection (text, 0x60000020);
+
+ if (rsrc != null)
+ WriteSection (rsrc, 0x40000040);
+
+ WriteSection (reloc, 0x42000040);
+ }
+
+ void WriteSection (Section section, uint characteristics)
+ {
+ var name = new byte [8];
+ var sect_name = section.Name;
+ for (int i = 0; i < sect_name.Length; i++)
+ name [i] = (byte) sect_name [i];
+
+ WriteBytes (name);
+ WriteUInt32 (section.VirtualSize);
+ WriteUInt32 (section.VirtualAddress);
+ WriteUInt32 (section.SizeOfRawData);
+ WriteUInt32 (section.PointerToRawData);
+ WriteUInt32 (0); // PointerToRelocations
+ WriteUInt32 (0); // PointerToLineNumbers
+ WriteUInt16 (0); // NumberOfRelocations
+ WriteUInt16 (0); // NumberOfLineNumbers
+ WriteUInt32 (characteristics);
+ }
+
+ void MoveTo (uint pointer)
+ {
+ BaseStream.Seek (pointer, SeekOrigin.Begin);
+ }
+
+ void MoveToRVA (Section section, RVA rva)
+ {
+ BaseStream.Seek (section.PointerToRawData + rva - section.VirtualAddress, SeekOrigin.Begin);
+ }
+
+ void MoveToRVA (TextSegment segment)
+ {
+ MoveToRVA (text, text_map.GetRVA (segment));
+ }
+
+ void WriteRVA (RVA rva)
+ {
+ if (!pe64)
+ WriteUInt32 (rva);
+ else
+ WriteUInt64 (rva);
+ }
+
+ void WriteText ()
+ {
+ MoveTo (text.PointerToRawData);
+
+ // ImportAddressTable
+
+ WriteRVA (text_map.GetRVA (TextSegment.ImportHintNameTable));
+ WriteRVA (0);
+
+ // CLIHeader
+
+ WriteUInt32 (0x48);
+ WriteUInt16 (2);
+ WriteUInt16 ((ushort) ((module.Runtime <= TargetRuntime.Net_1_1) ? 0 : 5));
+
+ WriteUInt32 (text_map.GetRVA (TextSegment.MetadataHeader));
+ WriteUInt32 (GetMetadataLength ());
+ WriteUInt32 ((uint) module.Attributes);
+ WriteUInt32 (metadata.entry_point.ToUInt32 ());
+ WriteDataDirectory (text_map.GetDataDirectory (TextSegment.Resources));
+ WriteDataDirectory (text_map.GetDataDirectory (TextSegment.StrongNameSignature));
+ WriteZeroDataDirectory (); // CodeManagerTable
+ WriteZeroDataDirectory (); // VTableFixups
+ WriteZeroDataDirectory (); // ExportAddressTableJumps
+ WriteZeroDataDirectory (); // ManagedNativeHeader
+
+ // Code
+
+ MoveToRVA (TextSegment.Code);
+ WriteBuffer (metadata.code);
+
+ // Resources
+
+ MoveToRVA (TextSegment.Resources);
+ WriteBuffer (metadata.resources);
+
+ // Data
+
+ if (metadata.data.length > 0) {
+ MoveToRVA (TextSegment.Data);
+ WriteBuffer (metadata.data);
+ }
+
+ // StrongNameSignature
+ // stays blank
+
+ // MetadataHeader
+
+ MoveToRVA (TextSegment.MetadataHeader);
+ WriteMetadataHeader ();
+
+ WriteMetadata ();
+
+ // DebugDirectory
+ if (text_map.GetLength (TextSegment.DebugDirectory) > 0) {
+ MoveToRVA (TextSegment.DebugDirectory);
+ WriteDebugDirectory ();
+ }
+
+ // ImportDirectory
+ MoveToRVA (TextSegment.ImportDirectory);
+ WriteImportDirectory ();
+
+ // StartupStub
+ MoveToRVA (TextSegment.StartupStub);
+ WriteStartupStub ();
+ }
+
+ uint GetMetadataLength ()
+ {
+ return text_map.GetRVA (TextSegment.DebugDirectory) - text_map.GetRVA (TextSegment.MetadataHeader);
+ }
+
+ void WriteMetadataHeader ()
+ {
+ WriteUInt32 (0x424a5342); // Signature
+ WriteUInt16 (1); // MajorVersion
+ WriteUInt16 (1); // MinorVersion
+ WriteUInt32 (0); // Reserved
+
+ var version = GetZeroTerminatedString (GetVersion ());
+ WriteUInt32 ((uint) version.Length);
+ WriteBytes (version);
+ WriteUInt16 (0); // Flags
+ WriteUInt16 (GetStreamCount ());
+
+ uint offset = text_map.GetRVA (TextSegment.TableHeap) - text_map.GetRVA (TextSegment.MetadataHeader);
+
+ WriteStreamHeader (ref offset, TextSegment.TableHeap, "#~");
+ WriteStreamHeader (ref offset, TextSegment.StringHeap, "#Strings");
+ WriteStreamHeader (ref offset, TextSegment.UserStringHeap, "#US");
+ WriteStreamHeader (ref offset, TextSegment.GuidHeap, "#GUID");
+ WriteStreamHeader (ref offset, TextSegment.BlobHeap, "#Blob");
+ }
+
+ string GetVersion ()
+ {
+ switch (module.Runtime) {
+ case TargetRuntime.Net_1_0:
+ return "v1.0.3705";
+ case TargetRuntime.Net_1_1:
+ return "v1.1.4322";
+ case TargetRuntime.Net_2_0:
+ return "v2.0.50727";
+ case TargetRuntime.Net_4_0:
+ default:
+ return "v4.0.30319";
+ }
+ }
+
+ ushort GetStreamCount ()
+ {
+ return (ushort) (
+ 1 // #~
+ + 1 // #Strings
+ + (metadata.user_string_heap.IsEmpty ? 0 : 1) // #US
+ + 1 // GUID
+ + (metadata.blob_heap.IsEmpty ? 0 : 1)); // #Blob
+ }
+
+ void WriteStreamHeader (ref uint offset, TextSegment heap, string name)
+ {
+ var length = (uint) text_map.GetLength (heap);
+ if (length == 0)
+ return;
+
+ WriteUInt32 (offset);
+ WriteUInt32 (length);
+ WriteBytes (GetZeroTerminatedString (name));
+ offset += length;
+ }
+
+ static byte [] GetZeroTerminatedString (string @string)
+ {
+ return GetString (@string, (@string.Length + 1 + 3) & ~3);
+ }
+
+ static byte [] GetSimpleString (string @string)
+ {
+ return GetString (@string, @string.Length);
+ }
+
+ static byte [] GetString (string @string, int length)
+ {
+ var bytes = new byte [length];
+ for (int i = 0; i < @string.Length; i++)
+ bytes [i] = (byte) @string [i];
+
+ return bytes;
+ }
+
+ void WriteMetadata ()
+ {
+ WriteHeap (TextSegment.TableHeap, metadata.table_heap);
+ WriteHeap (TextSegment.StringHeap, metadata.string_heap);
+ WriteHeap (TextSegment.UserStringHeap, metadata.user_string_heap);
+ WriteGuidHeap ();
+ WriteHeap (TextSegment.BlobHeap, metadata.blob_heap);
+ }
+
+ void WriteHeap (TextSegment heap, HeapBuffer buffer)
+ {
+ if (buffer.IsEmpty)
+ return;
+
+ MoveToRVA (heap);
+ WriteBuffer (buffer);
+ }
+
+ void WriteGuidHeap ()
+ {
+ MoveToRVA (TextSegment.GuidHeap);
+ WriteBytes (module.Mvid.ToByteArray ());
+ }
+
+ void WriteDebugDirectory ()
+ {
+ WriteInt32 (debug_directory.Characteristics);
+ WriteUInt32 (time_stamp);
+ WriteInt16 (debug_directory.MajorVersion);
+ WriteInt16 (debug_directory.MinorVersion);
+ WriteInt32 (debug_directory.Type);
+ WriteInt32 (debug_directory.SizeOfData);
+ WriteInt32 (debug_directory.AddressOfRawData);
+ WriteInt32 ((int) BaseStream.Position + 4);
+
+ WriteBytes (debug_data);
+ }
+
+ void WriteImportDirectory ()
+ {
+ WriteUInt32 (text_map.GetRVA (TextSegment.ImportDirectory) + 40); // ImportLookupTable
+ WriteUInt32 (0); // DateTimeStamp
+ WriteUInt32 (0); // ForwarderChain
+ WriteUInt32 (text_map.GetRVA (TextSegment.ImportHintNameTable) + 14);
+ WriteUInt32 (text_map.GetRVA (TextSegment.ImportAddressTable));
+ Advance (20);
+
+ // ImportLookupTable
+ WriteUInt32 (text_map.GetRVA (TextSegment.ImportHintNameTable));
+
+ // ImportHintNameTable
+ MoveToRVA (TextSegment.ImportHintNameTable);
+
+ WriteUInt16 (0); // Hint
+ WriteBytes (GetRuntimeMain ());
+ WriteByte (0);
+ WriteBytes (GetSimpleString ("mscoree.dll"));
+ WriteUInt16 (0);
+ }
+
+ byte [] GetRuntimeMain ()
+ {
+ return module.Kind == ModuleKind.Dll || module.Kind == ModuleKind.NetModule
+ ? GetSimpleString ("_CorDllMain")
+ : GetSimpleString ("_CorExeMain");
+ }
+
+ void WriteStartupStub ()
+ {
+ switch (module.Architecture) {
+ case TargetArchitecture.I386:
+ WriteUInt16 (0x25ff);
+ WriteUInt32 ((uint) image_base + text_map.GetRVA (TextSegment.ImportAddressTable));
+ return;
+ case TargetArchitecture.AMD64:
+ WriteUInt16 (0xa148);
+ WriteUInt32 ((uint) image_base + text_map.GetRVA (TextSegment.ImportAddressTable));
+ WriteUInt16 (0xe0ff);
+ return;
+ case TargetArchitecture.IA64:
+ WriteBytes (new byte [] {
+ 0x0b, 0x48, 0x00, 0x02, 0x18, 0x10, 0xa0, 0x40, 0x24, 0x30, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00,
+ 0x10, 0x08, 0x00, 0x12, 0x18, 0x10, 0x60, 0x50, 0x04, 0x80, 0x03, 0x00, 0x60, 0x00, 0x80, 0x00
+ });
+ WriteUInt32 ((uint) image_base + text_map.GetRVA (TextSegment.StartupStub));
+ WriteUInt32 ((uint) image_base + text_rva);
+ return;
+ }
+ }
+
+ void WriteRsrc ()
+ {
+ MoveTo (rsrc.PointerToRawData);
+ WriteBuffer (win32_resources);
+ }
+
+ void WriteReloc ()
+ {
+ MoveTo (reloc.PointerToRawData);
+
+ var reloc_rva = text_map.GetRVA (TextSegment.StartupStub);
+ reloc_rva += module.Architecture == TargetArchitecture.IA64 ? 0x20u : 2;
+ var page_rva = reloc_rva & ~0xfffu;
+
+ WriteUInt32 (page_rva); // PageRVA
+ WriteUInt32 (0x000c); // Block Size
+
+ switch (module.Architecture) {
+ case TargetArchitecture.I386:
+ WriteUInt32 (0x3000 + reloc_rva - page_rva);
+ break;
+ case TargetArchitecture.AMD64:
+ WriteUInt32 (0xa000 + reloc_rva - page_rva);
+ break;
+ case TargetArchitecture.IA64:
+ WriteUInt16 ((ushort) (0xa000 + reloc_rva - page_rva));
+ WriteUInt16 ((ushort) (0xa000 + reloc_rva - page_rva + 8));
+ break;
+ }
+
+ WriteBytes (new byte [file_alignment - reloc.VirtualSize]);
+ }
+
+ public void WriteImage ()
+ {
+ WriteDOSHeader ();
+ WritePEFileHeader ();
+ WriteOptionalHeaders ();
+ WriteSectionHeaders ();
+ WriteText ();
+ if (rsrc != null)
+ WriteRsrc ();
+ WriteReloc ();
+ }
+
+ TextMap BuildTextMap ()
+ {
+ var map = metadata.text_map;
+
+ map.AddMap (TextSegment.Code, metadata.code.length, !pe64 ? 4 : 16);
+ map.AddMap (TextSegment.Resources, metadata.resources.length, 8);
+ map.AddMap (TextSegment.Data, metadata.data.length, 4);
+ if (metadata.data.length > 0)
+ metadata.table_heap.FixupData (map.GetRVA (TextSegment.Data));
+ map.AddMap (TextSegment.StrongNameSignature, GetStrongNameLength (), 4);
+
+ map.AddMap (TextSegment.MetadataHeader, GetMetadataHeaderLength ());
+ map.AddMap (TextSegment.TableHeap, metadata.table_heap.length, 4);
+ map.AddMap (TextSegment.StringHeap, metadata.string_heap.length, 4);
+ map.AddMap (TextSegment.UserStringHeap, metadata.user_string_heap.IsEmpty ? 0 : metadata.user_string_heap.length, 4);
+ map.AddMap (TextSegment.GuidHeap, 16);
+ map.AddMap (TextSegment.BlobHeap, metadata.blob_heap.IsEmpty ? 0 : metadata.blob_heap.length, 4);
+
+ int debug_dir_len = 0;
+ if (!debug_data.IsNullOrEmpty ()) {
+ const int debug_dir_header_len = 28;
+
+ debug_directory.AddressOfRawData = (int) map.GetNextRVA (TextSegment.BlobHeap) + debug_dir_header_len;
+ debug_dir_len = debug_data.Length + debug_dir_header_len;
+ }
+
+ map.AddMap (TextSegment.DebugDirectory, debug_dir_len, 4);
+
+ RVA import_dir_rva = map.GetNextRVA (TextSegment.DebugDirectory);
+ RVA import_hnt_rva = import_dir_rva + (!pe64 ? 48u : 52u);
+ import_hnt_rva = (import_hnt_rva + 15u) & ~15u;
+ uint import_dir_len = (import_hnt_rva - import_dir_rva) + 27u;
+
+ RVA startup_stub_rva = import_dir_rva + import_dir_len;
+ startup_stub_rva = module.Architecture == TargetArchitecture.IA64
+ ? (startup_stub_rva + 15u) & ~15u
+ : 2 + ((startup_stub_rva + 3u) & ~3u);
+
+ map.AddMap (TextSegment.ImportDirectory, new Range (import_dir_rva, import_dir_len));
+ map.AddMap (TextSegment.ImportHintNameTable, new Range (import_hnt_rva, 0));
+ map.AddMap (TextSegment.StartupStub, new Range (startup_stub_rva, GetStartupStubLength ()));
+
+ return map;
+ }
+
+ uint GetStartupStubLength ()
+ {
+ switch (module.Architecture) {
+ case TargetArchitecture.I386:
+ return 6;
+ case TargetArchitecture.AMD64:
+ return 12;
+ case TargetArchitecture.IA64:
+ return 48;
+ default:
+ throw new InvalidOperationException ();
+ }
+ }
+
+ int GetMetadataHeaderLength ()
+ {
+ return
+ // MetadataHeader
+ 40
+ // #~ header
+ + 12
+ // #Strings header
+ + 20
+ // #US header
+ + (metadata.user_string_heap.IsEmpty ? 0 : 12)
+ // #GUID header
+ + 16
+ // #Blob header
+ + (metadata.blob_heap.IsEmpty ? 0 : 16);
+ }
+
+ int GetStrongNameLength ()
+ {
+ if ((module.Attributes & ModuleAttributes.StrongNameSigned) == 0)
+ return 0;
+
+ if (module.Assembly == null)
+ throw new InvalidOperationException ();
+
+ var public_key = module.Assembly.Name.PublicKey;
+
+ if (public_key != null) {
+ // in fx 2.0 the key may be from 384 to 16384 bits
+ // so we must calculate the signature size based on
+ // the size of the public key (minus the 32 byte header)
+ int size = public_key.Length;
+ if (size > 32)
+ return size - 32;
+ // note: size == 16 for the ECMA "key" which is replaced
+ // by the runtime with a 1024 bits key (128 bytes)
+ }
+
+ return 128; // default strongname signature size
+ }
+
+ public DataDirectory GetStrongNameSignatureDirectory ()
+ {
+ return text_map.GetDataDirectory (TextSegment.StrongNameSignature);
+ }
+
+ public uint GetHeaderSize ()
+ {
+ return pe_header_size + (sections * section_header_size);
+ }
+
+ void PatchWin32Resources (ByteBuffer resources)
+ {
+ PatchResourceDirectoryTable (resources);
+ }
+
+ void PatchResourceDirectoryTable (ByteBuffer resources)
+ {
+ resources.Advance (12);
+
+ var entries = resources.ReadUInt16 () + resources.ReadUInt16 ();
+
+ for (int i = 0; i < entries; i++)
+ PatchResourceDirectoryEntry (resources);
+ }
+
+ void PatchResourceDirectoryEntry (ByteBuffer resources)
+ {
+ resources.Advance (4);
+ var child = resources.ReadUInt32 ();
+
+ var position = resources.position;
+ resources.position = (int) child & 0x7fffffff;
+
+ if ((child & 0x80000000) != 0)
+ PatchResourceDirectoryTable (resources);
+ else
+ PatchResourceDataEntry (resources);
+
+ resources.position = position;
+ }
+
+ void PatchResourceDataEntry (ByteBuffer resources)
+ {
+ var old_rsrc = GetImageResourceSection ();
+ var rva = resources.ReadUInt32 ();
+ resources.position -= 4;
+ resources.WriteUInt32 (rva - old_rsrc.VirtualAddress + rsrc.VirtualAddress);
+ }
+ }
+}
+
+#endif
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/FlowControl.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/Section.cs
index e08104d..54935f9 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/FlowControl.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/Section.cs
@@ -1,10 +1,10 @@
//
-// FlowControl.cs
+// Section.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,17 +26,18 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil.Cil {
+using System;
- public enum FlowControl {
- Branch,
- Break,
- Call,
- Cond_Branch,
- Meta,
- Next,
- Phi,
- Return,
- Throw
+using RVA = System.UInt32;
+
+namespace Mono.Cecil.PE {
+
+ sealed class Section {
+ public string Name;
+ public RVA VirtualAddress;
+ public uint VirtualSize;
+ public uint SizeOfRawData;
+ public uint PointerToRawData;
+ public byte [] Data;
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/TextMap.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/TextMap.cs
new file mode 100644
index 0000000..daeda0c
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.PE/TextMap.cs
@@ -0,0 +1,129 @@
+//
+// TextMap.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+#if !READ_ONLY
+
+using RVA = System.UInt32;
+
+namespace Mono.Cecil.PE {
+
+ enum TextSegment {
+ ImportAddressTable,
+ CLIHeader,
+ Code,
+ Resources,
+ Data,
+ StrongNameSignature,
+
+ // Metadata
+ MetadataHeader,
+ TableHeap,
+ StringHeap,
+ UserStringHeap,
+ GuidHeap,
+ BlobHeap,
+ // End Metadata
+
+ DebugDirectory,
+ ImportDirectory,
+ ImportHintNameTable,
+ StartupStub,
+ }
+
+ sealed class TextMap {
+
+ readonly Range [] map = new Range [16 /*Enum.GetValues (typeof (TextSegment)).Length*/];
+
+ public void AddMap (TextSegment segment, int length)
+ {
+ map [(int) segment] = new Range (GetStart (segment), (uint) length);
+ }
+
+ public void AddMap (TextSegment segment, int length, int align)
+ {
+ align--;
+
+ AddMap (segment, (length + align) & ~align);
+ }
+
+ public void AddMap (TextSegment segment, Range range)
+ {
+ map [(int) segment] = range;
+ }
+
+ public Range GetRange (TextSegment segment)
+ {
+ return map [(int) segment];
+ }
+
+ public DataDirectory GetDataDirectory (TextSegment segment)
+ {
+ var range = map [(int) segment];
+
+ return new DataDirectory (range.Length == 0 ? 0 : range.Start, range.Length);
+ }
+
+ public RVA GetRVA (TextSegment segment)
+ {
+ return map [(int) segment].Start;
+ }
+
+ public RVA GetNextRVA (TextSegment segment)
+ {
+ var i = (int) segment;
+ return map [i].Start + map [i].Length;
+ }
+
+ public int GetLength (TextSegment segment)
+ {
+ return (int) map [(int) segment].Length;
+ }
+
+ RVA GetStart (TextSegment segment)
+ {
+ var index = (int) segment;
+ return index == 0 ? ImageWriter.text_rva : ComputeStart (index);
+ }
+
+ RVA ComputeStart (int index)
+ {
+ index--;
+ return map [index].Start + map [index].Length;
+ }
+
+ public uint GetLength ()
+ {
+ var range = map [(int) TextSegment.StartupStub];
+ return range.Start - ImageWriter.text_rva + range.Length;
+ }
+ }
+}
+
+#endif
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Array.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Array.cs
deleted file mode 100644
index c708963..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Array.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Array.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 - 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- using Mono.Cecil.Metadata;
-
- internal sealed class ARRAY : SigType {
-
- public CustomMod [] CustomMods;
- public SigType Type;
- public ArrayShape Shape;
-
- public ARRAY () : base (ElementType.Array)
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ArrayShape.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ArrayShape.cs
deleted file mode 100644
index 7cf3940..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ArrayShape.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// ArrayShape.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- internal sealed class ArrayShape {
-
- public int Rank;
- public int NumSizes;
- public int [] Sizes;
- public int NumLoBounds;
- public int [] LoBounds;
-
- public ArrayShape ()
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/BaseSignatureVisitor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/BaseSignatureVisitor.cs
deleted file mode 100644
index 0a37a5b..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/BaseSignatureVisitor.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// BaseSignatureVisitor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- internal abstract class BaseSignatureVisitor : ISignatureVisitor {
-
- public virtual void VisitMethodDefSig (MethodDefSig methodDef)
- {
- }
-
- public virtual void VisitMethodRefSig (MethodRefSig methodRef)
- {
- }
-
- public virtual void VisitFieldSig (FieldSig field)
- {
- }
-
- public virtual void VisitPropertySig (PropertySig property)
- {
- }
-
- public virtual void VisitLocalVarSig (LocalVarSig localvar)
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Constraint.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Constraint.cs
deleted file mode 100644
index 416707b..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Constraint.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// Constraints.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- using Mono.Cecil.Metadata;
-
- internal enum Constraint : byte {
- None = 0x0,
- Pinned = (byte) ElementType.Pinned
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomAttrib.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomAttrib.cs
deleted file mode 100644
index aca30e2..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomAttrib.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-//
-// CustomAttrib.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- using Mono.Cecil.Metadata;
-
- internal sealed class CustomAttrib {
-
- public const ushort StdProlog = 0x0001;
-
- public MethodReference Constructor;
-
- public ushort Prolog;
- public FixedArg [] FixedArgs;
- public ushort NumNamed;
- public NamedArg [] NamedArgs;
- public bool Read;
-
- public CustomAttrib (MethodReference ctor)
- {
- Constructor = ctor;
- }
-
- public struct FixedArg {
-
- public bool SzArray;
- public uint NumElem;
- public Elem [] Elems;
- }
-
- public struct Elem {
-
- public bool Simple;
- public bool String;
- public bool Type;
- public bool BoxedValueType;
-
- public ElementType FieldOrPropType;
- public object Value;
-
- public TypeReference ElemType;
- }
-
- public struct NamedArg {
-
- public bool Field;
- public bool Property;
-
- public ElementType FieldOrPropType;
- public string FieldOrPropName;
- public FixedArg FixedArg;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomMod.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomMod.cs
deleted file mode 100644
index 242f4d2..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/CustomMod.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// CustomMod.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- using Mono.Cecil.Metadata;
-
- internal sealed class CustomMod {
-
- public enum CMODType : byte {
- None = 0x0,
- OPT = (byte) ElementType.CModOpt,
- REQD = (byte) ElementType.CModReqD
- }
-
- public CMODType CMOD;
- public MetadataToken TypeDefOrRef;
-
- public CustomMod ()
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FieldSig.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FieldSig.cs
deleted file mode 100644
index a01c058..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FieldSig.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// FieldSig.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- internal sealed class FieldSig : Signature {
-
- public bool Field;
- public CustomMod [] CustomMods;
- public SigType Type;
-
- public FieldSig () : base ()
- {
- }
-
- public FieldSig (uint blobIndex) : base (blobIndex)
- {
- }
-
- public override void Accept (ISignatureVisitor visitor)
- {
- visitor.VisitFieldSig (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FnPtr.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FnPtr.cs
deleted file mode 100644
index 02fc330..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/FnPtr.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// FnPtr.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- using Mono.Cecil.Metadata;
-
- internal sealed class FNPTR : SigType {
-
- public MethodSig Method;
-
- public FNPTR () : base (ElementType.FnPtr)
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericArg.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericArg.cs
deleted file mode 100644
index 74edb4a..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericArg.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// GenericArg.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- class GenericArg {
-
- public CustomMod [] CustomMods;
- public SigType Type;
-
- public GenericArg (SigType type)
- {
- Type = type;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInst.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInst.cs
deleted file mode 100644
index 02bd111..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInst.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// GenericInst.cs
-//
-// Author:
-// Martin Baulig <baulig@ximian.com>
-// Jb Evain <jbevain@gmail.com>
-//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- using Mono.Cecil;
- using Mono.Cecil.Metadata;
-
- internal sealed class GENERICINST : SigType {
-
- public bool ValueType;
- public MetadataToken Type;
-
- public GenericInstSignature Signature;
-
- public GENERICINST () : base (ElementType.GenericInst)
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInstSignature.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInstSignature.cs
deleted file mode 100644
index 94d41c4..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/GenericInstSignature.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// GenericInstSignature.cs
-//
-// Author:
-// Martin Baulig <martin@ximian.com>
-//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- internal sealed class GenericInstSignature {
-
- public int Arity;
- public GenericArg [] Types;
-
- public GenericInstSignature ()
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitable.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitable.cs
deleted file mode 100644
index 81374f0..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitable.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// ISignatureVisitable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- internal interface ISignatureVisitable {
-
- void Accept (ISignatureVisitor visitor);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitor.cs
deleted file mode 100644
index e473e87..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ISignatureVisitor.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// ISignatureVisitor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- internal interface ISignatureVisitor {
-
- void VisitMethodDefSig (MethodDefSig methodDef);
- void VisitMethodRefSig (MethodRefSig methodRef);
- void VisitFieldSig (FieldSig field);
- void VisitPropertySig (PropertySig property);
- void VisitLocalVarSig (LocalVarSig localvar);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/InputOutputItem.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/InputOutputItem.cs
deleted file mode 100644
index 5240a81..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/InputOutputItem.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// InputOutputItem.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- internal abstract class InputOutputItem {
-
- public CustomMod [] CustomMods;
- public bool ByRef;
- public SigType Type;
- public bool TypedByRef;
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/LocalVarSig.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/LocalVarSig.cs
deleted file mode 100644
index 071c90c..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/LocalVarSig.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// LocalVarSig.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- internal sealed class LocalVarSig : Signature {
-
- public bool Local;
- public int Count;
- public LocalVariable [] LocalVariables;
-
- public LocalVarSig () : base ()
- {
- }
-
- public LocalVarSig (uint blobIndex) : base (blobIndex)
- {
- }
-
- public override void Accept (ISignatureVisitor visitor)
- {
- visitor.VisitLocalVarSig (this);
- }
-
- public struct LocalVariable {
-
- public CustomMod [] CustomMods;
- public Constraint Constraint;
- public bool ByRef;
- public SigType Type;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MVar.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MVar.cs
deleted file mode 100644
index 3fca4a4..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MVar.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// MVar.cs
-//
-// Author:
-// Martin Baulig <martin@ximian.com>
-//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- using Mono.Cecil.Metadata;
-
- internal sealed class MVAR : SigType {
-
- public int Index;
-
- public MVAR (int index) : base (ElementType.MVar)
- {
- this.Index = index;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MarshalSig.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MarshalSig.cs
deleted file mode 100644
index 4b99c57..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MarshalSig.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// MarshalSig.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- using System;
-
- using Mono.Cecil;
-
- internal sealed class MarshalSig {
-
- public NativeType NativeInstrinsic;
- public IMarshalSigSpec Spec;
-
- public MarshalSig (NativeType nt)
- {
- this.NativeInstrinsic = nt;
- }
-
- public interface IMarshalSigSpec {
- }
-
- public sealed class Array : IMarshalSigSpec {
-
- public NativeType ArrayElemType;
- public int ParamNum;
- public int ElemMult;
- public int NumElem;
-
- public Array ()
- {
- this.ParamNum = 0;
- this.ElemMult = 0;
- this.NumElem = 0;
- }
- }
-
- public sealed class CustomMarshaler : IMarshalSigSpec {
-
- public string Guid;
- public string UnmanagedType;
- public string ManagedType;
- public string Cookie;
- }
-
- public sealed class FixedArray : IMarshalSigSpec {
-
- public int NumElem;
- public NativeType ArrayElemType;
-
- public FixedArray ()
- {
- this.NumElem = 0;
- this.ArrayElemType = NativeType.NONE;
- }
- }
-
- public sealed class SafeArray : IMarshalSigSpec {
-
- public VariantType ArrayElemType;
- }
-
- public sealed class FixedSysString : IMarshalSigSpec {
-
- public int Size;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodRefSig.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodRefSig.cs
deleted file mode 100644
index 63cc35b..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodRefSig.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// MethodRefSig.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- internal class MethodRefSig : MethodSig {
-
- public int Sentinel;
-
- public MethodRefSig () : this (0)
- {
- }
-
- public MethodRefSig (uint blobIndex) : base (blobIndex)
- {
- Sentinel = -1;
- }
-
- public override void Accept (ISignatureVisitor visitor)
- {
- visitor.VisitMethodRefSig (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSig.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSig.cs
deleted file mode 100644
index 3b65809..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSig.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// MethodSig.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using Mono.Cecil;
-
-namespace Mono.Cecil.Signatures {
-
- internal abstract class MethodSig : Signature {
-
- public bool HasThis;
- public bool ExplicitThis;
- public MethodCallingConvention MethCallConv;
- public int ParamCount;
- public RetType RetType;
- public Param [] Parameters;
-
- public MethodSig () : base ()
- {
- }
-
- public MethodSig (uint blobIndex) : base (blobIndex)
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSpec.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSpec.cs
deleted file mode 100644
index 0ad0f8b..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/MethodSpec.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// TypeSpec.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- internal sealed class MethodSpec {
-
- public GenericInstSignature Signature;
-
- public MethodSpec (GenericInstSignature sig)
- {
- this.Signature = sig;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Param.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Param.cs
deleted file mode 100644
index 0bd7a0d..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Param.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// Param.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- internal sealed class Param : InputOutputItem {
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/PropertySig.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/PropertySig.cs
deleted file mode 100644
index 5db0820..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/PropertySig.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// PropertySig.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- internal sealed class PropertySig : Signature {
-
- public bool Property;
- public int ParamCount;
- public CustomMod [] CustomMods;
- public SigType Type;
- public Param [] Parameters;
-
- public PropertySig () : base ()
- {
- }
-
- public PropertySig (uint blobIndex) : base (blobIndex)
- {
- }
-
- public override void Accept (ISignatureVisitor visitor)
- {
- visitor.VisitPropertySig (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Ptr.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Ptr.cs
deleted file mode 100644
index e95394d..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Ptr.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Ptr.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- using Mono.Cecil.Metadata;
-
- internal sealed class PTR : SigType {
-
- public CustomMod [] CustomMods;
- public SigType PtrType;
- public bool Void;
-
- public PTR () : base (ElementType.Ptr)
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/RetType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/RetType.cs
deleted file mode 100644
index 6541211..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/RetType.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// RetType.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- internal sealed class RetType : InputOutputItem {
-
- public bool Void;
-
- public RetType ()
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SigType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SigType.cs
deleted file mode 100644
index 6e2d19b..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SigType.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// SigType.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- using Mono.Cecil.Metadata;
-
- internal class SigType {
-
- public ElementType ElementType;
-
- public SigType (ElementType elem)
- {
- ElementType = elem;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureReader.cs
deleted file mode 100644
index 97f8761..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureReader.cs
+++ /dev/null
@@ -1,961 +0,0 @@
-//
-// SignatureReader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 - 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- using System;
- using System.Collections;
- using System.IO;
- using System.Text;
-
- using Mono.Cecil;
- using Mono.Cecil.Metadata;
-
- internal sealed class SignatureReader : BaseSignatureVisitor {
-
- MetadataRoot m_root;
- ReflectionReader m_reflectReader;
- byte [] m_blobData;
-
- IDictionary m_signatures;
-
- IAssemblyResolver AssemblyResolver {
- get { return m_reflectReader.Module.Assembly.Resolver; }
- }
-
- public SignatureReader (MetadataRoot root, ReflectionReader reflectReader)
- {
- m_root = root;
- m_reflectReader = reflectReader;
-
- m_blobData = m_root.Streams.BlobHeap != null ? m_root.Streams.BlobHeap.Data : new byte [0];
-
- m_signatures = new Hashtable ();
- }
-
- public FieldSig GetFieldSig (uint index)
- {
- FieldSig f = m_signatures [index] as FieldSig;
- if (f == null) {
- f = new FieldSig (index);
- f.Accept (this);
- m_signatures [index] = f;
- }
- return f;
- }
-
- public PropertySig GetPropSig (uint index)
- {
- PropertySig p = m_signatures [index] as PropertySig;
- if (p == null) {
- p = new PropertySig (index);
- p.Accept (this);
- m_signatures [index] = p;
- }
- return p;
- }
-
- public MethodDefSig GetMethodDefSig (uint index)
- {
- MethodDefSig m = m_signatures [index] as MethodDefSig;
- if (m == null) {
- m = new MethodDefSig (index);
- m.Accept (this);
- m_signatures [index] = m;
- }
- return m;
- }
-
- public MethodRefSig GetMethodRefSig (uint index)
- {
- MethodRefSig m = m_signatures [index] as MethodRefSig;
- if (m == null) {
- m = new MethodRefSig (index);
- m.Accept (this);
- m_signatures [index] = m;
- }
- return m;
- }
-
- public TypeSpec GetTypeSpec (uint index)
- {
- TypeSpec ts = m_signatures [index] as TypeSpec;
-
- if (ts == null) {
- ts = ReadTypeSpec (m_blobData, (int) index);
- m_signatures [index] = ts;
- }
-
- return ts;
- }
-
- public MethodSpec GetMethodSpec (uint index)
- {
- MethodSpec ms = m_signatures [index] as MethodSpec;
-
- if (ms == null) {
- ms = ReadMethodSpec (m_blobData, (int) index);
- m_signatures [index] = ms;
- }
-
- return ms;
- }
-
- public LocalVarSig GetLocalVarSig (uint index)
- {
- LocalVarSig lv = m_signatures [index] as LocalVarSig;
- if (lv == null) {
- lv = new LocalVarSig (index);
- lv.Accept (this);
- m_signatures [index] = lv;
- }
- return lv;
- }
-
- public CustomAttrib GetCustomAttrib (uint index, MethodReference ctor)
- {
- return GetCustomAttrib (index, ctor, false);
- }
-
- public CustomAttrib GetCustomAttrib (uint index, MethodReference ctor, bool resolve)
- {
- return ReadCustomAttrib ((int) index, ctor, resolve);
- }
-
- public CustomAttrib GetCustomAttrib (byte [] data, MethodReference ctor)
- {
- return GetCustomAttrib (data, ctor, false);
- }
-
- public CustomAttrib GetCustomAttrib (byte [] data, MethodReference ctor, bool resolve)
- {
- BinaryReader br = new BinaryReader (new MemoryStream (data));
- return ReadCustomAttrib (br, data, ctor, resolve);
- }
-
- public Signature GetMemberRefSig (TokenType tt, uint index)
- {
- int start, callconv;
- Utilities.ReadCompressedInteger (m_blobData, (int) index, out start);
- callconv = m_blobData [start];
- if ((callconv & 0x5) == 0x5 || (callconv & 0x10) == 0x10) // vararg || generic?
- return GetMethodDefSig (index);
- if ((callconv & 0x6) != 0) // field ?
- return GetFieldSig (index);
-
- switch (tt) {
- case TokenType.TypeDef :
- case TokenType.TypeRef :
- case TokenType.TypeSpec :
- return GetMethodRefSig (index);
- case TokenType.ModuleRef :
- case TokenType.Method :
- return GetMethodDefSig (index);
- }
- return null;
- }
-
- public MarshalSig GetMarshalSig (uint index)
- {
- MarshalSig ms = m_signatures [index] as MarshalSig;
- if (ms == null) {
- byte [] data = m_root.Streams.BlobHeap.Read (index);
- ms = ReadMarshalSig (data);
- m_signatures [index] = ms;
- }
- return ms;
- }
-
- public MethodSig GetStandAloneMethodSig (uint index)
- {
- byte [] data = m_root.Streams.BlobHeap.Read (index);
- int start;
- if ((data [0] & 0x5) > 0) {
- MethodRefSig mrs = new MethodRefSig (index);
- ReadMethodRefSig (mrs, data, 0, out start);
- return mrs;
- } else {
- MethodDefSig mds = new MethodDefSig (index);
- ReadMethodDefSig (mds, data, 0, out start);
- return mds;
- }
- }
-
- public override void VisitMethodDefSig (MethodDefSig methodDef)
- {
- int start;
- ReadMethodDefSig (methodDef, m_root.Streams.BlobHeap.Read (methodDef.BlobIndex), 0, out start);
- }
-
- public override void VisitMethodRefSig (MethodRefSig methodRef)
- {
- int start;
- ReadMethodRefSig (methodRef, m_root.Streams.BlobHeap.Read (methodRef.BlobIndex), 0, out start);
- }
-
- public override void VisitFieldSig (FieldSig field)
- {
- int start;
- Utilities.ReadCompressedInteger (m_blobData, (int) field.BlobIndex, out start);
- field.CallingConvention = m_blobData [start];
- field.Field = (field.CallingConvention & 0x6) != 0;
- field.CustomMods = ReadCustomMods (m_blobData, start + 1, out start);
- field.Type = ReadType (m_blobData, start, out start);
- }
-
- public override void VisitPropertySig (PropertySig property)
- {
- int start;
- Utilities.ReadCompressedInteger (m_blobData, (int) property.BlobIndex, out start);
- property.CallingConvention = m_blobData [start];
- property.Property = (property.CallingConvention & 0x8) != 0;
- property.ParamCount = Utilities.ReadCompressedInteger (m_blobData, start + 1, out start);
- property.CustomMods = ReadCustomMods (m_blobData, start, out start);
- property.Type = ReadType (m_blobData, start, out start);
- property.Parameters = ReadParameters (property.ParamCount, m_blobData, start);
- }
-
- public override void VisitLocalVarSig (LocalVarSig localvar)
- {
- int start;
- Utilities.ReadCompressedInteger (m_blobData, (int) localvar.BlobIndex, out start);
- localvar.CallingConvention = m_blobData [start];
- localvar.Local = (localvar.CallingConvention & 0x7) != 0;
- localvar.Count = Utilities.ReadCompressedInteger (m_blobData, start + 1, out start);
- localvar.LocalVariables = ReadLocalVariables (localvar.Count, m_blobData, start);
- }
-
- void ReadMethodDefSig (MethodDefSig methodDef, byte [] data, int pos, out int start)
- {
- methodDef.CallingConvention = data [pos];
- start = pos + 1;
- methodDef.HasThis = (methodDef.CallingConvention & 0x20) != 0;
- methodDef.ExplicitThis = (methodDef.CallingConvention & 0x40) != 0;
- if ((methodDef.CallingConvention & 0x5) != 0)
- methodDef.MethCallConv |= MethodCallingConvention.VarArg;
- else if ((methodDef.CallingConvention & 0x10) != 0) {
- methodDef.MethCallConv |= MethodCallingConvention.Generic;
- methodDef.GenericParameterCount = Utilities.ReadCompressedInteger (data, start, out start);
- } else
- methodDef.MethCallConv |= MethodCallingConvention.Default;
-
- methodDef.ParamCount = Utilities.ReadCompressedInteger (data, start, out start);
- methodDef.RetType = ReadRetType (data, start, out start);
- int sentpos;
- methodDef.Parameters = ReadParameters (methodDef.ParamCount, data, start, out sentpos);
- methodDef.Sentinel = sentpos;
- }
-
- void ReadMethodRefSig (MethodRefSig methodRef, byte [] data, int pos, out int start)
- {
- methodRef.CallingConvention = data [pos];
- start = pos + 1;
- methodRef.HasThis = (methodRef.CallingConvention & 0x20) != 0;
- methodRef.ExplicitThis = (methodRef.CallingConvention & 0x40) != 0;
- if ((methodRef.CallingConvention & 0x1) != 0)
- methodRef.MethCallConv |= MethodCallingConvention.C;
- else if ((methodRef.CallingConvention & 0x2) != 0)
- methodRef.MethCallConv |= MethodCallingConvention.StdCall;
- else if ((methodRef.CallingConvention & 0x3) != 0)
- methodRef.MethCallConv |= MethodCallingConvention.ThisCall;
- else if ((methodRef.CallingConvention & 0x4) != 0)
- methodRef.MethCallConv |= MethodCallingConvention.FastCall;
- else if ((methodRef.CallingConvention & 0x5) != 0)
- methodRef.MethCallConv |= MethodCallingConvention.VarArg;
- else
- methodRef.MethCallConv |= MethodCallingConvention.Default;
- methodRef.ParamCount = Utilities.ReadCompressedInteger (data, start, out start);
- methodRef.RetType = ReadRetType (data, start, out start);
- int sentpos;
- methodRef.Parameters = ReadParameters (methodRef.ParamCount, data, start, out sentpos);
- methodRef.Sentinel = sentpos;
- }
-
- LocalVarSig.LocalVariable [] ReadLocalVariables (int length, byte [] data, int pos)
- {
- int start = pos;
- LocalVarSig.LocalVariable [] types = new LocalVarSig.LocalVariable [length];
- for (int i = 0; i < length; i++)
- types [i] = ReadLocalVariable (data, start, out start);
- return types;
- }
-
- LocalVarSig.LocalVariable ReadLocalVariable (byte [] data, int pos, out int start)
- {
- start = pos;
- LocalVarSig.LocalVariable lv = new LocalVarSig.LocalVariable ();
- lv.ByRef = false;
- int cursor;
- while (true) {
- lv.CustomMods = ReadCustomMods (data, start, out start);
- cursor = start;
- int current = Utilities.ReadCompressedInteger (data, start, out start);
- if (current == (int) ElementType.Pinned) // the only possible constraint
- lv.Constraint |= Constraint.Pinned;
- else if (current == (int) ElementType.ByRef) {
- lv.ByRef = true;
-
- if (lv.CustomMods == null || lv.CustomMods.Length == 0)
- lv.CustomMods = ReadCustomMods (data, start, out start);
- } else {
- lv.Type = ReadType (data, cursor, out start);
- break;
- }
- }
- return lv;
- }
-
- TypeSpec ReadTypeSpec (byte [] data, int pos)
- {
- int start = pos;
- Utilities.ReadCompressedInteger (data, start, out start);
- TypeSpec ts = new TypeSpec ();
- ts.CustomMods = ReadCustomMods (data, start, out start);
- ts.Type = ReadType (data, start, out start);
- return ts;
- }
-
- MethodSpec ReadMethodSpec (byte [] data, int pos)
- {
- int start = pos;
-
- Utilities.ReadCompressedInteger (data, start, out start);
- if (Utilities.ReadCompressedInteger (data, start, out start) != 0x0a)
- throw new ReflectionException ("Invalid MethodSpec signature");
-
- return new MethodSpec (ReadGenericInstSignature (data, start, out start));
- }
-
- RetType ReadRetType (byte [] data, int pos, out int start)
- {
- RetType rt = new RetType ();
- start = pos;
- rt.CustomMods = ReadCustomMods (data, start, out start);
- int curs = start;
- ElementType flag = (ElementType) Utilities.ReadCompressedInteger (data, start, out start);
- switch (flag) {
- case ElementType.Void :
- rt.ByRef = rt.TypedByRef = false;
- rt.Void = true;
- break;
- case ElementType.TypedByRef :
- rt.ByRef = rt.Void = false;
- rt.TypedByRef = true;
- break;
- case ElementType.ByRef :
- rt.TypedByRef = rt.Void = false;
- rt.ByRef = true;
-
- if (rt.CustomMods == null || rt.CustomMods.Length == 0)
- rt.CustomMods = ReadCustomMods (data, start, out start);
-
- rt.Type = ReadType (data, start, out start);
- break;
- default :
- rt.TypedByRef = rt.Void = rt.ByRef = false;
- rt.Type = ReadType (data, curs, out start);
- break;
- }
- return rt;
- }
-
- Param [] ReadParameters (int length, byte [] data, int pos)
- {
- Param [] ret = new Param [length];
- int start = pos;
- for (int i = 0; i < length; i++)
- ret [i] = ReadParameter (data, start, out start);
- return ret;
- }
-
- Param [] ReadParameters (int length, byte [] data, int pos, out int sentinelpos)
- {
- Param [] ret = new Param [length];
- int start = pos;
- sentinelpos = -1;
-
- for (int i = 0; i < length; i++) {
- int curs = start;
- int flag = Utilities.ReadCompressedInteger (data, start, out start);
-
- if (flag == (int) ElementType.Sentinel) {
- sentinelpos = i;
- curs = start;
- }
-
- ret [i] = ReadParameter (data, curs, out start);
- }
-
- return ret;
- }
-
- Param ReadParameter (byte [] data, int pos, out int start)
- {
- Param p = new Param ();
- start = pos;
-
- p.CustomMods = ReadCustomMods (data, start, out start);
- int curs = start;
- ElementType flag = (ElementType) Utilities.ReadCompressedInteger (data, start, out start);
- switch (flag) {
- case ElementType.TypedByRef :
- p.TypedByRef = true;
- p.ByRef = false;
- break;
- case ElementType.ByRef :
- p.TypedByRef = false;
- p.ByRef = true;
-
- if (p.CustomMods == null || p.CustomMods.Length == 0)
- p.CustomMods = ReadCustomMods (data, start, out start);
-
- p.Type = ReadType (data, start, out start);
- break;
- default :
- p.TypedByRef = false;
- p.ByRef = false;
- p.Type = ReadType (data, curs, out start);
- break;
- }
- return p;
- }
-
- SigType ReadType (byte [] data, int pos, out int start)
- {
- start = pos;
- ElementType element = (ElementType) Utilities.ReadCompressedInteger (data, start, out start);
- switch (element) {
- case ElementType.ValueType :
- VALUETYPE vt = new VALUETYPE ();
- vt.Type = Utilities.GetMetadataToken(CodedIndex.TypeDefOrRef,
- (uint) Utilities.ReadCompressedInteger (data, start, out start));
- return vt;
- case ElementType.Class :
- CLASS c = new CLASS ();
- c.Type = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef,
- (uint) Utilities.ReadCompressedInteger (data, start, out start));
- return c;
- case ElementType.Ptr :
- PTR p = new PTR ();
- int buf = start;
- int flag = Utilities.ReadCompressedInteger (data, start, out start);
- p.Void = flag == (int) ElementType.Void;
- if (p.Void)
- return p;
- start = buf;
- p.CustomMods = ReadCustomMods (data, start, out start);
- p.PtrType = ReadType (data, start, out start);
- return p;
- case ElementType.FnPtr :
- FNPTR fp = new FNPTR ();
- if ((data [start] & 0x5) != 0) {
- MethodRefSig mr = new MethodRefSig ((uint) start);
- ReadMethodRefSig (mr, data, start, out start);
- fp.Method = mr;
- } else {
- MethodDefSig md = new MethodDefSig ((uint) start);
- ReadMethodDefSig (md, data, start, out start);
- fp.Method = md;
- }
- return fp;
- case ElementType.Array :
- ARRAY ary = new ARRAY ();
- ary.CustomMods = ReadCustomMods (data, start, out start);
- ArrayShape shape = new ArrayShape ();
- ary.Type = ReadType (data, start, out start);
- shape.Rank = Utilities.ReadCompressedInteger (data, start, out start);
- shape.NumSizes = Utilities.ReadCompressedInteger (data, start, out start);
- shape.Sizes = new int [shape.NumSizes];
- for (int i = 0; i < shape.NumSizes; i++)
- shape.Sizes [i] = Utilities.ReadCompressedInteger (data, start, out start);
- shape.NumLoBounds = Utilities.ReadCompressedInteger (data, start, out start);
- shape.LoBounds = new int [shape.NumLoBounds];
- for (int i = 0; i < shape.NumLoBounds; i++)
- shape.LoBounds [i] = Utilities.ReadCompressedInteger (data, start, out start);
- ary.Shape = shape;
- return ary;
- case ElementType.SzArray :
- SZARRAY sa = new SZARRAY ();
- sa.CustomMods = ReadCustomMods (data, start, out start);
- sa.Type = ReadType (data, start, out start);
- return sa;
- case ElementType.Var:
- return new VAR (Utilities.ReadCompressedInteger (data, start, out start));
- case ElementType.MVar:
- return new MVAR (Utilities.ReadCompressedInteger (data, start, out start));
- case ElementType.GenericInst:
- GENERICINST ginst = new GENERICINST ();
-
- ginst.ValueType = ((ElementType) Utilities.ReadCompressedInteger (
- data, start, out start)) == ElementType.ValueType;
-
- ginst.Type = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef,
- (uint) Utilities.ReadCompressedInteger (data, start, out start));
-
- ginst.Signature = ReadGenericInstSignature (data, start, out start);
-
- return ginst;
- default :
- return new SigType (element);
- }
- }
-
- GenericInstSignature ReadGenericInstSignature (byte [] data, int pos, out int start)
- {
- start = pos;
- GenericInstSignature gis = new GenericInstSignature ();
- gis.Arity = Utilities.ReadCompressedInteger (data, start, out start);
- gis.Types = new GenericArg [gis.Arity];
- for (int i = 0; i < gis.Arity; i++)
- gis.Types [i] = ReadGenericArg (data, start, out start);
-
- return gis;
- }
-
- GenericArg ReadGenericArg (byte[] data, int pos, out int start)
- {
- start = pos;
- CustomMod [] mods = ReadCustomMods (data, start, out start);
- GenericArg arg = new GenericArg (ReadType (data, start, out start));
- arg.CustomMods = mods;
- return arg;
- }
-
- CustomMod [] ReadCustomMods (byte [] data, int pos, out int start)
- {
- ArrayList cmods = new ArrayList ();
- start = pos;
- while (true) {
- int buf = start;
- ElementType flag = (ElementType) Utilities.ReadCompressedInteger (data, start, out start);
- start = buf;
- if (!((flag == ElementType.CModOpt) || (flag == ElementType.CModReqD)))
- break;
- cmods.Add (ReadCustomMod (data, start, out start));
- }
- return cmods.ToArray (typeof (CustomMod)) as CustomMod [];
- }
-
- CustomMod ReadCustomMod (byte [] data, int pos, out int start)
- {
- CustomMod cm = new CustomMod ();
- start = pos;
- ElementType cmod = (ElementType) Utilities.ReadCompressedInteger (data, start, out start);
- if (cmod == ElementType.CModOpt)
- cm.CMOD = CustomMod.CMODType.OPT;
- else if (cmod == ElementType.CModReqD)
- cm.CMOD = CustomMod.CMODType.REQD;
- else
- cm.CMOD = CustomMod.CMODType.None;
- cm.TypeDefOrRef = Utilities.GetMetadataToken (CodedIndex.TypeDefOrRef,
- (uint) Utilities.ReadCompressedInteger (data, start, out start));
- return cm;
- }
-
- CustomAttrib ReadCustomAttrib (int pos, MethodReference ctor, bool resolve)
- {
- int start, length = Utilities.ReadCompressedInteger (m_blobData, pos, out start);
- byte [] data = new byte [length];
- Buffer.BlockCopy (m_blobData, start, data, 0, length);
- try {
- return ReadCustomAttrib (new BinaryReader (
- new MemoryStream (data)), data, ctor, resolve);
- } catch {
- CustomAttrib ca = new CustomAttrib (ctor);
- ca.Read = false;
- return ca;
- }
- }
-
- CustomAttrib ReadCustomAttrib (BinaryReader br, byte [] data, MethodReference ctor, bool resolve)
- {
- CustomAttrib ca = new CustomAttrib (ctor);
- if (data.Length == 0) {
- ca.FixedArgs = new CustomAttrib.FixedArg [0];
- ca.NamedArgs = new CustomAttrib.NamedArg [0];
- return ca;
- }
-
- bool read = true;
-
- ca.Prolog = br.ReadUInt16 ();
- if (ca.Prolog != CustomAttrib.StdProlog)
- throw new MetadataFormatException ("Non standard prolog for custom attribute");
-
- ca.FixedArgs = new CustomAttrib.FixedArg [ctor.Parameters.Count];
- for (int i = 0; i < ca.FixedArgs.Length && read; i++)
- ca.FixedArgs [i] = ReadFixedArg (data, br,
- ctor.Parameters [i].ParameterType, ref read, resolve);
-
- if (br.BaseStream.Position == br.BaseStream.Length)
- read = false;
-
- if (!read) {
- ca.Read = read;
- return ca;
- }
-
- ca.NumNamed = br.ReadUInt16 ();
- ca.NamedArgs = new CustomAttrib.NamedArg [ca.NumNamed];
- for (int i = 0; i < ca.NumNamed && read; i++)
- ca.NamedArgs [i] = ReadNamedArg (data, br, ref read, resolve);
-
- ca.Read = read;
- return ca;
- }
-
- CustomAttrib.FixedArg ReadFixedArg (byte [] data, BinaryReader br,
- TypeReference param, ref bool read, bool resolve)
- {
- CustomAttrib.FixedArg fa = new CustomAttrib.FixedArg ();
- if (param is ArrayType) {
- param = ((ArrayType) param).ElementType;
- fa.SzArray = true;
- fa.NumElem = br.ReadUInt32 ();
-
- if (fa.NumElem == 0 || fa.NumElem == 0xffffffff) {
- fa.Elems = new CustomAttrib.Elem [0];
- fa.NumElem = 0;
- return fa;
- }
-
- fa.Elems = new CustomAttrib.Elem [fa.NumElem];
- for (int i = 0; i < fa.NumElem; i++)
- fa.Elems [i] = ReadElem (data, br, param, ref read, resolve);
- } else
- fa.Elems = new CustomAttrib.Elem [] { ReadElem (data, br, param, ref read, resolve) };
-
- return fa;
- }
-
- TypeReference CreateEnumTypeReference (string enumName)
- {
- string asmName = null;
- int asmStart = enumName.IndexOf (',');
- if (asmStart != -1) {
- asmName = enumName.Substring (asmStart + 1);
- enumName = enumName.Substring (0, asmStart);
- }
- // Inner class style is reflection style.
- enumName = enumName.Replace ('+', '/');
- AssemblyNameReference asm;
- if (asmName == null) {
- // If no assembly is given then the ECMA standard says the
- // assembly is either the current one or mscorlib.
- if (m_reflectReader.Module.Types.Contains (enumName))
- return m_reflectReader.Module.Types [enumName];
-
- asm = m_reflectReader.Corlib;
- } else
- asm = AssemblyNameReference.Parse (asmName);
-
- string [] outers = enumName.Split ('/');
- string outerfullname = outers [0];
- string ns = null;
- int nsIndex = outerfullname.LastIndexOf ('.');
- if (nsIndex != -1)
- ns = outerfullname.Substring (0, nsIndex);
- string name = outerfullname.Substring (nsIndex + 1);
- TypeReference decType = new TypeReference (name, ns, asm);
- for (int i = 1; i < outers.Length; i++) {
- TypeReference t = new TypeReference (outers [i], null, asm);
- t.DeclaringType = decType;
- decType = t;
- }
- decType.IsValueType = true;
-
- return decType;
- }
-
- TypeReference ReadTypeReference (byte [] data, BinaryReader br, out ElementType elemType)
- {
- bool array = false;
- elemType = (ElementType) br.ReadByte ();
- if (elemType == ElementType.SzArray) {
- elemType = (ElementType) br.ReadByte ();
- array = true;
- }
-
- TypeReference res;
- if (elemType == ElementType.Enum)
- res = CreateEnumTypeReference (ReadUTF8String (data, br));
- else
- res = TypeReferenceFromElemType (elemType);
-
- if (array)
- res = new ArrayType (res);
-
- return res;
- }
-
- TypeReference TypeReferenceFromElemType (ElementType elemType)
- {
- switch (elemType) {
- case ElementType.Boxed :
- return m_reflectReader.SearchCoreType (Constants.Object);
- case ElementType.String :
- return m_reflectReader.SearchCoreType (Constants.String);
- case ElementType.Type :
- return m_reflectReader.SearchCoreType (Constants.Type);
- case ElementType.Boolean :
- return m_reflectReader.SearchCoreType (Constants.Boolean);
- case ElementType.Char :
- return m_reflectReader.SearchCoreType (Constants.Char);
- case ElementType.R4 :
- return m_reflectReader.SearchCoreType (Constants.Single);
- case ElementType.R8 :
- return m_reflectReader.SearchCoreType (Constants.Double);
- case ElementType.I1 :
- return m_reflectReader.SearchCoreType (Constants.SByte);
- case ElementType.I2 :
- return m_reflectReader.SearchCoreType (Constants.Int16);
- case ElementType.I4 :
- return m_reflectReader.SearchCoreType (Constants.Int32);
- case ElementType.I8 :
- return m_reflectReader.SearchCoreType (Constants.Int64);
- case ElementType.U1 :
- return m_reflectReader.SearchCoreType (Constants.Byte);
- case ElementType.U2 :
- return m_reflectReader.SearchCoreType (Constants.UInt16);
- case ElementType.U4 :
- return m_reflectReader.SearchCoreType (Constants.UInt32);
- case ElementType.U8 :
- return m_reflectReader.SearchCoreType (Constants.UInt64);
- default :
- throw new MetadataFormatException ("Non valid type in CustomAttrib.Elem: 0x{0}",
- ((byte) elemType).ToString("x2"));
- }
- }
-
- internal CustomAttrib.NamedArg ReadNamedArg (byte [] data, BinaryReader br, ref bool read, bool resolve)
- {
- CustomAttrib.NamedArg na = new CustomAttrib.NamedArg ();
- byte kind = br.ReadByte ();
- if (kind == 0x53) { // field
- na.Field = true;
- na.Property = false;
- } else if (kind == 0x54) { // property
- na.Field = false;
- na.Property = true;
- } else
- throw new MetadataFormatException ("Wrong kind of namedarg found: 0x" + kind.ToString("x2"));
-
- TypeReference elemType = ReadTypeReference (data, br, out na.FieldOrPropType);
- na.FieldOrPropName = ReadUTF8String (data, br);
- na.FixedArg = ReadFixedArg (data, br, elemType, ref read, resolve);
-
- return na;
- }
-
- CustomAttrib.Elem ReadElem (byte [] data, BinaryReader br, TypeReference elemType, ref bool read, bool resolve)
- {
- CustomAttrib.Elem elem = new CustomAttrib.Elem ();
-
- string elemName = elemType.FullName;
-
- if (elemName == Constants.Object) {
- elemType = ReadTypeReference (data, br, out elem.FieldOrPropType);
- if (elemType is ArrayType) {
- read = false; // Don't know how to represent arrays as an object value.
- return elem;
- } else if (elemType.FullName == Constants.Object)
- throw new MetadataFormatException ("Non valid type in CustomAttrib.Elem after boxed prefix: 0x{0}",
- ((byte) elem.FieldOrPropType).ToString("x2"));
-
- elem = ReadElem (data, br, elemType, ref read, resolve);
- elem.String = elem.Simple = elem.Type = false;
- elem.BoxedValueType = true;
- return elem;
- }
-
- elem.ElemType = elemType;
-
- if (elemName == Constants.Type || elemName == Constants.String) {
- switch (elemType.FullName) {
- case Constants.String:
- elem.String = true;
- elem.BoxedValueType = elem.Simple = elem.Type = false;
- break;
- case Constants.Type:
- elem.Type = true;
- elem.BoxedValueType = elem.Simple = elem.String = false;
- break;
- }
-
- if (data [br.BaseStream.Position] == 0xff) { // null
- elem.Value = null;
- br.BaseStream.Position++;
- } else {
- elem.Value = ReadUTF8String (data, br);
- }
- return elem;
- }
-
- elem.String = elem.Type = elem.BoxedValueType = false;
- if (!ReadSimpleValue (br, ref elem, elem.ElemType)) {
- if (!resolve) { // until enums writing is implemented
- read = false;
- return elem;
- }
- TypeReference typeRef = GetEnumUnderlyingType (elem.ElemType, resolve);
- if (typeRef == null || !ReadSimpleValue (br, ref elem, typeRef))
- read = false;
- }
-
- return elem;
- }
-
- TypeReference GetEnumUnderlyingType (TypeReference enumType, bool resolve)
- {
- TypeDefinition type = enumType as TypeDefinition;
- if (type == null && resolve && AssemblyResolver != null) {
- if (enumType.Scope is ModuleDefinition)
- throw new NotSupportedException ();
-
- AssemblyDefinition asm = AssemblyResolver.Resolve (
- ((AssemblyNameReference) enumType.Scope).FullName);
- type = asm.MainModule.Types [enumType.FullName];
- }
-
- if (type != null && type.IsEnum)
- return type.Fields.GetField ("value__").FieldType;
-
- return null;
- }
-
- bool ReadSimpleValue (BinaryReader br, ref CustomAttrib.Elem elem, TypeReference type)
- {
- switch (type.FullName) {
- case Constants.Boolean :
- elem.Value = br.ReadByte () == 1;
- break;
- case Constants.Char :
- elem.Value = (char) br.ReadUInt16 ();
- break;
- case Constants.Single :
- elem.Value = br.ReadSingle ();
- break;
- case Constants.Double :
- elem.Value = br.ReadDouble ();
- break;
- case Constants.Byte :
- elem.Value = br.ReadByte ();
- break;
- case Constants.Int16 :
- elem.Value = br.ReadInt16 ();
- break;
- case Constants.Int32 :
- elem.Value = br.ReadInt32 ();
- break;
- case Constants.Int64 :
- elem.Value = br.ReadInt64 ();
- break;
- case Constants.SByte :
- elem.Value = br.ReadSByte ();
- break;
- case Constants.UInt16 :
- elem.Value = br.ReadUInt16 ();
- break;
- case Constants.UInt32 :
- elem.Value = br.ReadUInt32 ();
- break;
- case Constants.UInt64 :
- elem.Value = br.ReadUInt64 ();
- break;
- default : // enum
- return false;
- }
- elem.Simple = true;
- return true;
- }
-
- MarshalSig ReadMarshalSig (byte [] data)
- {
- int start;
- MarshalSig ms = new MarshalSig ((NativeType) Utilities.ReadCompressedInteger (data, 0, out start));
- switch (ms.NativeInstrinsic) {
- case NativeType.ARRAY:
- MarshalSig.Array ar = new MarshalSig.Array ();
- ar.ArrayElemType = (NativeType) Utilities.ReadCompressedInteger (data, start, out start);
- if (start < data.Length)
- ar.ParamNum = Utilities.ReadCompressedInteger (data, start, out start);
- if (start < data.Length)
- ar.NumElem = Utilities.ReadCompressedInteger (data, start, out start);
- if (start < data.Length)
- ar.ElemMult = Utilities.ReadCompressedInteger (data, start, out start);
- ms.Spec = ar;
- break;
- case NativeType.CUSTOMMARSHALER:
- MarshalSig.CustomMarshaler cm = new MarshalSig.CustomMarshaler ();
- cm.Guid = ReadUTF8String (data, start, out start);
- cm.UnmanagedType = ReadUTF8String (data, start, out start);
- cm.ManagedType = ReadUTF8String (data, start, out start);
- cm.Cookie = ReadUTF8String (data, start, out start);
- ms.Spec = cm;
- break;
- case NativeType.FIXEDARRAY:
- MarshalSig.FixedArray fa = new MarshalSig.FixedArray ();
- fa.NumElem = Utilities.ReadCompressedInteger (data, start, out start);
- if (start < data.Length)
- fa.ArrayElemType = (NativeType) Utilities.ReadCompressedInteger (data, start, out start);
- ms.Spec = fa;
- break;
- case NativeType.SAFEARRAY:
- MarshalSig.SafeArray sa = new MarshalSig.SafeArray ();
- if (start < data.Length)
- sa.ArrayElemType = (VariantType) Utilities.ReadCompressedInteger (data, start, out start);
- ms.Spec = sa;
- break;
- case NativeType.FIXEDSYSSTRING:
- MarshalSig.FixedSysString fss = new MarshalSig.FixedSysString ();
- if (start < data.Length)
- fss.Size = Utilities.ReadCompressedInteger (data, start, out start);
- ms.Spec = fss;
- break;
- }
- return ms;
- }
-
- static internal string ReadUTF8String (byte [] data, BinaryReader br)
- {
- int start = (int)br.BaseStream.Position;
- string val = ReadUTF8String (data, start, out start);
- br.BaseStream.Position = start;
- return val;
- }
-
- static internal string ReadUTF8String (byte [] data, int pos, out int start)
- {
- int length = Utilities.ReadCompressedInteger (data, pos, out start);
- pos = start;
- start += length;
- // COMPACT FRAMEWORK NOTE: Encoding.GetString (byte[]) is not supported.
- return Encoding.UTF8.GetString (data, pos, length);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureWriter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureWriter.cs
deleted file mode 100644
index dfe92d7..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SignatureWriter.cs
+++ /dev/null
@@ -1,564 +0,0 @@
-//
-// SignatureWriter.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 - 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- using System;
- using System.Text;
-
- using Mono.Cecil;
- using Mono.Cecil.Binary;
- using Mono.Cecil.Metadata;
-
- internal sealed class SignatureWriter : BaseSignatureVisitor {
-
- MetadataWriter m_mdWriter;
- MemoryBinaryWriter m_sigWriter;
-
- public SignatureWriter (MetadataWriter mdWriter)
- {
- m_mdWriter = mdWriter;
- m_sigWriter = new MemoryBinaryWriter ();
- }
-
- uint GetPointer ()
- {
- return m_mdWriter.AddBlob (m_sigWriter.ToArray ());
- }
-
- public uint AddMethodDefSig (MethodDefSig methSig)
- {
- return AddSignature (methSig);
- }
-
- public uint AddMethodRefSig (MethodRefSig methSig)
- {
- return AddSignature (methSig);
- }
-
- public uint AddPropertySig (PropertySig ps)
- {
- return AddSignature (ps);
- }
-
- public uint AddFieldSig (FieldSig fSig)
- {
- return AddSignature (fSig);
- }
-
- public uint AddLocalVarSig (LocalVarSig lvs)
- {
- return AddSignature (lvs);
- }
-
- uint AddSignature (Signature s)
- {
- m_sigWriter.Empty ();
- s.Accept (this);
- return GetPointer ();
- }
-
- public uint AddTypeSpec (TypeSpec ts)
- {
- m_sigWriter.Empty ();
- Write (ts);
- return GetPointer ();
- }
-
- public uint AddMethodSpec (MethodSpec ms)
- {
- m_sigWriter.Empty ();
- Write (ms);
- return GetPointer ();
- }
-
- public uint AddMarshalSig (MarshalSig ms)
- {
- m_sigWriter.Empty ();
- Write (ms);
- return GetPointer ();
- }
-
- public uint AddCustomAttribute (CustomAttrib ca, MethodReference ctor)
- {
- CompressCustomAttribute (ca, ctor, m_sigWriter);
- return GetPointer ();
- }
-
- public byte [] CompressCustomAttribute (CustomAttrib ca, MethodReference ctor)
- {
- MemoryBinaryWriter writer = new MemoryBinaryWriter ();
- CompressCustomAttribute (ca, ctor, writer);
- return writer.ToArray ();
- }
-
- public byte [] CompressFieldSig (FieldSig field)
- {
- m_sigWriter.Empty ();
- VisitFieldSig (field);
- return m_sigWriter.ToArray ();
- }
-
- public byte [] CompressLocalVar (LocalVarSig.LocalVariable var)
- {
- m_sigWriter.Empty ();
- Write (var);
- return m_sigWriter.ToArray ();
- }
-
- void CompressCustomAttribute (CustomAttrib ca, MethodReference ctor, MemoryBinaryWriter writer)
- {
- m_sigWriter.Empty ();
- Write (ca, ctor, writer);
- }
-
- public override void VisitMethodDefSig (MethodDefSig methodDef)
- {
- m_sigWriter.Write (methodDef.CallingConvention);
- if (methodDef.GenericParameterCount > 0)
- Write (methodDef.GenericParameterCount);
- Write (methodDef.ParamCount);
- Write (methodDef.RetType);
- Write (methodDef.Parameters, methodDef.Sentinel);
- }
-
- public override void VisitMethodRefSig (MethodRefSig methodRef)
- {
- m_sigWriter.Write (methodRef.CallingConvention);
- Write (methodRef.ParamCount);
- Write (methodRef.RetType);
- Write (methodRef.Parameters, methodRef.Sentinel);
- }
-
- public override void VisitFieldSig (FieldSig field)
- {
- m_sigWriter.Write (field.CallingConvention);
- Write (field.CustomMods);
- Write (field.Type);
- }
-
- public override void VisitPropertySig (PropertySig property)
- {
- m_sigWriter.Write (property.CallingConvention);
- Write (property.ParamCount);
- Write (property.CustomMods);
- Write (property.Type);
- Write (property.Parameters);
- }
-
- public override void VisitLocalVarSig (LocalVarSig localvar)
- {
- m_sigWriter.Write (localvar.CallingConvention);
- Write (localvar.Count);
- Write (localvar.LocalVariables);
- }
-
- void Write (LocalVarSig.LocalVariable [] vars)
- {
- foreach (LocalVarSig.LocalVariable var in vars)
- Write (var);
- }
-
- void Write (LocalVarSig.LocalVariable var)
- {
- Write (var.CustomMods);
- if ((var.Constraint & Constraint.Pinned) != 0)
- Write (ElementType.Pinned);
- if (var.ByRef)
- Write (ElementType.ByRef);
- Write (var.Type);
- }
-
- void Write (RetType retType)
- {
- Write (retType.CustomMods);
- if (retType.Void)
- Write (ElementType.Void);
- else if (retType.TypedByRef)
- Write (ElementType.TypedByRef);
- else if (retType.ByRef) {
- Write (ElementType.ByRef);
- Write (retType.Type);
- } else
- Write (retType.Type);
- }
-
- void Write (Param [] parameters, int sentinel)
- {
- for (int i = 0; i < parameters.Length; i++) {
- if (i == sentinel)
- Write (ElementType.Sentinel);
-
- Write (parameters [i]);
- }
- }
-
- void Write (Param [] parameters)
- {
- foreach (Param p in parameters)
- Write (p);
- }
-
- void Write (ElementType et)
- {
- Write ((int) et);
- }
-
- void Write (SigType t)
- {
- Write ((int) t.ElementType);
-
- switch (t.ElementType) {
- case ElementType.ValueType :
- Write ((int) Utilities.CompressMetadataToken (
- CodedIndex.TypeDefOrRef, ((VALUETYPE) t).Type));
- break;
- case ElementType.Class :
- Write ((int) Utilities.CompressMetadataToken (
- CodedIndex.TypeDefOrRef, ((CLASS) t).Type));
- break;
- case ElementType.Ptr :
- PTR p = (PTR) t;
- if (p.Void)
- Write (ElementType.Void);
- else {
- Write (p.CustomMods);
- Write (p.PtrType);
- }
- break;
- case ElementType.FnPtr :
- FNPTR fp = (FNPTR) t;
- if (fp.Method is MethodRefSig)
- (fp.Method as MethodRefSig).Accept (this);
- else
- (fp.Method as MethodDefSig).Accept (this);
- break;
- case ElementType.Array :
- ARRAY ary = (ARRAY) t;
- Write (ary.CustomMods);
- ArrayShape shape = ary.Shape;
- Write (ary.Type);
- Write (shape.Rank);
- Write (shape.NumSizes);
- foreach (int size in shape.Sizes)
- Write (size);
- Write (shape.NumLoBounds);
- foreach (int loBound in shape.LoBounds)
- Write (loBound);
- break;
- case ElementType.SzArray :
- SZARRAY sa = (SZARRAY) t;
- Write (sa.CustomMods);
- Write (sa.Type);
- break;
- case ElementType.Var :
- Write (((VAR) t).Index);
- break;
- case ElementType.MVar :
- Write (((MVAR) t).Index);
- break;
- case ElementType.GenericInst :
- GENERICINST gi = t as GENERICINST;
- Write (gi.ValueType ? ElementType.ValueType : ElementType.Class);
- Write ((int) Utilities.CompressMetadataToken (
- CodedIndex.TypeDefOrRef, gi.Type));
- Write (gi.Signature);
- break;
- }
- }
-
- void Write (TypeSpec ts)
- {
- Write (ts.CustomMods);
- Write (ts.Type);
- }
-
- void Write (MethodSpec ms)
- {
- Write (0x0a);
- Write (ms.Signature);
- }
-
- void Write (GenericInstSignature gis)
- {
- Write (gis.Arity);
- for (int i = 0; i < gis.Arity; i++)
- Write (gis.Types [i]);
- }
-
- void Write (GenericArg arg)
- {
- Write (arg.CustomMods);
- Write (arg.Type);
- }
-
- void Write (Param p)
- {
- Write (p.CustomMods);
- if (p.TypedByRef)
- Write (ElementType.TypedByRef);
- else if (p.ByRef) {
- Write (ElementType.ByRef);
- Write (p.Type);
- } else
- Write (p.Type);
- }
-
- void Write (CustomMod [] customMods)
- {
- foreach (CustomMod cm in customMods)
- Write (cm);
- }
-
- void Write (CustomMod cm)
- {
- switch (cm.CMOD) {
- case CustomMod.CMODType.OPT :
- Write (ElementType.CModOpt);
- break;
- case CustomMod.CMODType.REQD :
- Write (ElementType.CModReqD);
- break;
- }
-
- Write ((int) Utilities.CompressMetadataToken (
- CodedIndex.TypeDefOrRef, cm.TypeDefOrRef));
- }
-
- void Write (MarshalSig ms)
- {
- Write ((int) ms.NativeInstrinsic);
- switch (ms.NativeInstrinsic) {
- case NativeType.ARRAY :
- MarshalSig.Array ar = (MarshalSig.Array) ms.Spec;
- Write ((int) ar.ArrayElemType);
- if (ar.ParamNum != -1)
- Write (ar.ParamNum);
- if (ar.NumElem != -1)
- Write (ar.NumElem);
- if (ar.ElemMult != -1)
- Write (ar.ElemMult);
- break;
- case NativeType.CUSTOMMARSHALER :
- MarshalSig.CustomMarshaler cm = (MarshalSig.CustomMarshaler) ms.Spec;
- Write (cm.Guid);
- Write (cm.UnmanagedType);
- Write (cm.ManagedType);
- Write (cm.Cookie);
- break;
- case NativeType.FIXEDARRAY :
- MarshalSig.FixedArray fa = (MarshalSig.FixedArray) ms.Spec;
- Write (fa.NumElem);
- if (fa.ArrayElemType != NativeType.NONE)
- Write ((int) fa.ArrayElemType);
- break;
- case NativeType.SAFEARRAY :
- Write ((int) ((MarshalSig.SafeArray) ms.Spec).ArrayElemType);
- break;
- case NativeType.FIXEDSYSSTRING :
- Write (((MarshalSig.FixedSysString) ms.Spec).Size);
- break;
- }
- }
-
- void Write (CustomAttrib ca, MethodReference ctor, MemoryBinaryWriter writer)
- {
- if (ca == null)
- return;
-
- if (ca.Prolog != CustomAttrib.StdProlog)
- return;
-
- writer.Write (ca.Prolog);
-
- for (int i = 0; i < ctor.Parameters.Count; i++)
- Write (ca.FixedArgs [i], writer);
-
- writer.Write (ca.NumNamed);
-
- for (int i = 0; i < ca.NumNamed; i++)
- Write (ca.NamedArgs [i], writer);
- }
-
- void Write (CustomAttrib.FixedArg fa, MemoryBinaryWriter writer)
- {
- if (fa.SzArray)
- writer.Write (fa.NumElem);
-
- foreach (CustomAttrib.Elem elem in fa.Elems)
- Write (elem, writer);
- }
-
- static string GetEnumFullName (TypeReference type)
- {
- string fullname = type.FullName;
-
- if (type.IsNested)
- fullname = fullname.Replace ('/', '+');
-
- if (type is TypeDefinition)
- return fullname;
-
- return string.Concat (fullname, ", ", type.Module.Assembly.Name.FullName);
- }
-
- void Write (CustomAttrib.NamedArg na, MemoryBinaryWriter writer)
- {
- if (na.Field)
- writer.Write ((byte) 0x53);
- else if (na.Property)
- writer.Write ((byte) 0x54);
- else
- throw new MetadataFormatException ("Unknown kind of namedarg");
-
- if (na.FieldOrPropType == ElementType.Class)
- na.FieldOrPropType = ElementType.Enum;
-
- if (na.FixedArg.SzArray)
- writer.Write ((byte) ElementType.SzArray);
-
- if (na.FieldOrPropType == ElementType.Object)
- writer.Write ((byte) ElementType.Boxed);
- else
- writer.Write ((byte) na.FieldOrPropType);
-
- if (na.FieldOrPropType == ElementType.Enum)
- Write (GetEnumFullName (na.FixedArg.Elems [0].ElemType));
-
- Write (na.FieldOrPropName);
-
- Write (na.FixedArg, writer);
- }
-
- static ElementType GetElementTypeFromTypeCode (TypeCode tc)
- {
- switch (tc) {
- case TypeCode.Byte:
- return ElementType.U1;
- case TypeCode.SByte:
- return ElementType.I1;
- case TypeCode.Int16:
- return ElementType.I2;
- case TypeCode.UInt16:
- return ElementType.U2;
- case TypeCode.Int32:
- return ElementType.I4;
- case TypeCode.UInt32:
- return ElementType.U4;
- case TypeCode.Int64:
- return ElementType.I8;
- case TypeCode.UInt64:
- return ElementType.U8;
- default:
- throw new ArgumentException ("tc");
- }
- }
-
- void Write (CustomAttrib.Elem elem, MemoryBinaryWriter writer)
- {
- if (elem.String)
- elem.FieldOrPropType = ElementType.String;
- else if (elem.Type)
- elem.FieldOrPropType = ElementType.Type;
-
- if (elem.FieldOrPropType == ElementType.Class) // an enum in fact
- elem.FieldOrPropType = GetElementTypeFromTypeCode (Type.GetTypeCode (elem.Value.GetType ()));
-
- if (elem.BoxedValueType)
- Write (elem.FieldOrPropType);
-
- switch (elem.FieldOrPropType) {
- case ElementType.Boolean :
- writer.Write ((byte) ((bool) elem.Value ? 1 : 0));
- break;
- case ElementType.Char :
- writer.Write ((ushort) (char) elem.Value);
- break;
- case ElementType.R4 :
- writer.Write ((float) elem.Value);
- break;
- case ElementType.R8 :
- writer.Write ((double) elem.Value);
- break;
- case ElementType.I1 :
- writer.Write ((sbyte) elem.Value);
- break;
- case ElementType.I2 :
- writer.Write ((short) elem.Value);
- break;
- case ElementType.I4 :
- writer.Write ((int) elem.Value);
- break;
- case ElementType.I8 :
- writer.Write ((long) elem.Value);
- break;
- case ElementType.U1 :
- writer.Write ((byte) elem.Value);
- break;
- case ElementType.U2 :
- writer.Write ((ushort) elem.Value);
- break;
- case ElementType.U4 :
- writer.Write ((uint) elem.Value);
- break;
- case ElementType.U8 :
- writer.Write ((long) elem.Value);
- break;
- case ElementType.String :
- case ElementType.Type :
- string s = elem.Value as string;
- if (s == null)
- writer.Write ((byte) 0xff);
- else if (s.Length == 0)
- writer.Write ((byte) 0x00);
- else
- Write (s);
- break;
- case ElementType.Object :
- if (elem.Value != null)
- throw new NotSupportedException ("Unknown state");
- writer.Write ((byte) 0xff);
- break;
- default :
- throw new NotImplementedException ("WriteElem " + elem.FieldOrPropType.ToString ());
- }
- }
-
- void Write (string s)
- {
- byte [] str = Encoding.UTF8.GetBytes (s);
- Write (str.Length);
- m_sigWriter.Write (str);
- }
-
- void Write (int i)
- {
- Utilities.WriteCompressedInteger (m_sigWriter, i);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SzArray.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SzArray.cs
deleted file mode 100644
index 08ad8f1..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/SzArray.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// SzArray.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 - 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- using Mono.Cecil.Metadata;
-
- internal sealed class SZARRAY : SigType {
-
- public CustomMod [] CustomMods;
- public SigType Type;
-
- public SZARRAY () : base (ElementType.SzArray)
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/TypeSpec.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/TypeSpec.cs
deleted file mode 100644
index 7664df3..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/TypeSpec.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// TypeSpec.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 - 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- internal sealed class TypeSpec {
-
- public CustomMod [] CustomMods;
- public SigType Type;
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ValueType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ValueType.cs
deleted file mode 100644
index 36b2661..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/ValueType.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// ValueType.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- using Mono.Cecil.Metadata;
-
- internal sealed class VALUETYPE : SigType {
-
- public MetadataToken Type;
-
- public VALUETYPE () : base (ElementType.ValueType)
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Var.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Var.cs
deleted file mode 100644
index 97b35b6..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Var.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// Var.cs
-//
-// Author:
-// Martin Baulig <martin@ximian.com>
-//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil.Signatures {
-
- using Mono.Cecil.Metadata;
-
- internal sealed class VAR : SigType {
-
- public int Index;
-
- public VAR (int index) : base (ElementType.Var)
- {
- this.Index = index;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.csproj b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.csproj
index c6c6d93..fb0cab1 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.csproj
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.csproj
@@ -1,19 +1,19 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>8.0.50727</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{D8F63DFF-5230-43E4-9AB2-DA6E721A1FAE}</ProjectGuid>
+ <ProjectGuid>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Mono.Cecil</RootNamespace>
<AssemblyName>Mono.Cecil</AssemblyName>
- <StartupObject>
- </StartupObject>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
<SignAssembly>true</SignAssembly>
- <AssemblyOriginatorKeyFile>..\mono.snk</AssemblyOriginatorKeyFile>
+ <AssemblyOriginatorKeyFile>mono.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -23,6 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -31,335 +32,149 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
- <Compile Include="Mono.Cecil.Binary\BaseImageVisitor.cs" />
- <Compile Include="Mono.Cecil.Binary\CLIHeader.cs" />
- <Compile Include="Mono.Cecil.Binary\CopyImageVisitor.cs" />
- <Compile Include="Mono.Cecil.Binary\DataDirectory.cs" />
- <Compile Include="Mono.Cecil.Binary\DebugHeader.cs" />
- <Compile Include="Mono.Cecil.Binary\DebugStoreType.cs" />
- <Compile Include="Mono.Cecil.Binary\DOSHeader.cs" />
- <Compile Include="Mono.Cecil.Binary\ExportTable.cs" />
- <Compile Include="Mono.Cecil.Binary\IBinaryVisitable.cs" />
- <Compile Include="Mono.Cecil.Binary\IBinaryVisitor.cs" />
- <Compile Include="Mono.Cecil.Binary\IHeader.cs" />
- <Compile Include="Mono.Cecil.Binary\Image.cs" />
- <Compile Include="Mono.Cecil.Binary\ImageCharacteristics.cs" />
- <Compile Include="Mono.Cecil.Binary\ImageFormatException.cs" />
- <Compile Include="Mono.Cecil.Binary\ImageInitializer.cs" />
- <Compile Include="Mono.Cecil.Binary\ImageReader.cs" />
- <Compile Include="Mono.Cecil.Binary\ImageWriter.cs" />
- <Compile Include="Mono.Cecil.Binary\Imports.cs" />
- <Compile Include="Mono.Cecil.Binary\MemoryBinaryWriter.cs" />
- <Compile Include="Mono.Cecil.Binary\PEFileHeader.cs" />
- <Compile Include="Mono.Cecil.Binary\PEOptionalHeader.cs" />
- <Compile Include="Mono.Cecil.Binary\ResourceDataEntry.cs" />
- <Compile Include="Mono.Cecil.Binary\ResourceDirectoryEntry.cs" />
- <Compile Include="Mono.Cecil.Binary\ResourceDirectoryString.cs" />
- <Compile Include="Mono.Cecil.Binary\ResourceDirectoryTable.cs" />
- <Compile Include="Mono.Cecil.Binary\ResourceNode.cs" />
- <Compile Include="Mono.Cecil.Binary\ResourceReader.cs" />
- <Compile Include="Mono.Cecil.Binary\ResourceWriter.cs" />
- <Compile Include="Mono.Cecil.Binary\RuntimeImage.cs" />
- <Compile Include="Mono.Cecil.Binary\RVA.cs" />
- <Compile Include="Mono.Cecil.Binary\Section.cs" />
- <Compile Include="Mono.Cecil.Binary\SectionCharacteristics.cs" />
- <Compile Include="Mono.Cecil.Binary\SectionCollection.cs" />
- <Compile Include="Mono.Cecil.Binary\SubSystem.cs" />
- <Compile Include="Mono.Cecil.Cil\BaseCodeVisitor.cs" />
- <Compile Include="Mono.Cecil.Cil\CilWorker.cs" />
<Compile Include="Mono.Cecil.Cil\Code.cs" />
- <Compile Include="Mono.Cecil.Cil\CodeReader.cs" />
<Compile Include="Mono.Cecil.Cil\CodeWriter.cs" />
- <Compile Include="Mono.Cecil.Cil\DocumentType.cs" />
+ <Compile Include="Mono.Cecil.Cil\CodeReader.cs" />
<Compile Include="Mono.Cecil.Cil\Document.cs" />
- <Compile Include="Mono.Cecil.Cil\DocumentHashAlgorithm.cs" />
- <Compile Include="Mono.Cecil.Cil\DocumentLanguage.cs" />
- <Compile Include="Mono.Cecil.Cil\DocumentLanguageVendor.cs" />
<Compile Include="Mono.Cecil.Cil\ExceptionHandler.cs" />
- <Compile Include="Mono.Cecil.Cil\ExceptionHandlerCollection.cs" />
- <Compile Include="Mono.Cecil.Cil\ExceptionHandlerType.cs" />
- <Compile Include="Mono.Cecil.Cil\FlowControl.cs" />
- <Compile Include="Mono.Cecil.Cil\GuidAttribute.cs" />
- <Compile Include="Mono.Cecil.Cil\ICodeVisitable.cs" />
- <Compile Include="Mono.Cecil.Cil\ICodeVisitor.cs" />
+ <Compile Include="Mono.Cecil.Cil\ILProcessor.cs" />
<Compile Include="Mono.Cecil.Cil\Instruction.cs" />
- <Compile Include="Mono.Cecil.Cil\InstructionCollection.cs" />
- <Compile Include="Mono.Cecil.Cil\IScopeProvider.cs" />
- <Compile Include="Mono.Cecil.Cil\ISymbolReader.cs" />
- <Compile Include="Mono.Cecil.Cil\ISymbolStoreFactory.cs" />
- <Compile Include="Mono.Cecil.Cil\ISymbolWriter.cs" />
- <Compile Include="Mono.Cecil.Cil\IVariableDefinitionProvider.cs" />
<Compile Include="Mono.Cecil.Cil\MethodBody.cs" />
- <Compile Include="Mono.Cecil.Cil\MethodDataSection.cs" />
- <Compile Include="Mono.Cecil.Cil\MethodHeader.cs" />
<Compile Include="Mono.Cecil.Cil\OpCode.cs" />
<Compile Include="Mono.Cecil.Cil\OpCodes.cs" />
- <Compile Include="Mono.Cecil.Cil\OpCodeType.cs" />
- <Compile Include="Mono.Cecil.Cil\OperandType.cs" />
- <Compile Include="Mono.Cecil.Cil\Scope.cs" />
- <Compile Include="Mono.Cecil.Cil\ScopeCollection.cs" />
<Compile Include="Mono.Cecil.Cil\SequencePoint.cs" />
- <Compile Include="Mono.Cecil.Cil\StackBehaviour.cs" />
- <Compile Include="Mono.Cecil.Cil\SymbolStoreHelper.cs" />
+ <Compile Include="Mono.Cecil.Cil\Symbols.cs" />
<Compile Include="Mono.Cecil.Cil\VariableDefinition.cs" />
- <Compile Include="Mono.Cecil.Cil\VariableDefinitionCollection.cs" />
<Compile Include="Mono.Cecil.Cil\VariableReference.cs" />
- <Compile Include="Mono.Cecil.Metadata\Assembly.cs" />
- <Compile Include="Mono.Cecil.Metadata\AssemblyOS.cs" />
- <Compile Include="Mono.Cecil.Metadata\AssemblyProcessor.cs" />
- <Compile Include="Mono.Cecil.Metadata\AssemblyRef.cs" />
- <Compile Include="Mono.Cecil.Metadata\AssemblyRefOS.cs" />
- <Compile Include="Mono.Cecil.Metadata\AssemblyRefProcessor.cs" />
- <Compile Include="Mono.Cecil.Metadata\BaseMetadataVisitor.cs" />
<Compile Include="Mono.Cecil.Metadata\BlobHeap.cs" />
- <Compile Include="Mono.Cecil.Metadata\ClassLayout.cs" />
+ <Compile Include="Mono.Cecil.Metadata\Buffers.cs" />
<Compile Include="Mono.Cecil.Metadata\CodedIndex.cs" />
- <Compile Include="Mono.Cecil.Metadata\Constant.cs" />
- <Compile Include="Mono.Cecil.Metadata\CultureUtils.cs" />
- <Compile Include="Mono.Cecil.Metadata\CustomAttribute.cs" />
- <Compile Include="Mono.Cecil.Metadata\DeclSecurity.cs" />
<Compile Include="Mono.Cecil.Metadata\ElementType.cs" />
- <Compile Include="Mono.Cecil.Metadata\Event.cs" />
- <Compile Include="Mono.Cecil.Metadata\EventMap.cs" />
- <Compile Include="Mono.Cecil.Metadata\EventPtr.cs" />
- <Compile Include="Mono.Cecil.Metadata\ExportedType.cs" />
- <Compile Include="Mono.Cecil.Metadata\Field.cs" />
- <Compile Include="Mono.Cecil.Metadata\FieldLayout.cs" />
- <Compile Include="Mono.Cecil.Metadata\FieldMarshal.cs" />
- <Compile Include="Mono.Cecil.Metadata\FieldPtr.cs" />
- <Compile Include="Mono.Cecil.Metadata\FieldRVA.cs" />
- <Compile Include="Mono.Cecil.Metadata\File.cs" />
- <Compile Include="Mono.Cecil.Metadata\GenericParam.cs" />
- <Compile Include="Mono.Cecil.Metadata\GenericParamConstraint.cs" />
<Compile Include="Mono.Cecil.Metadata\GuidHeap.cs" />
- <Compile Include="Mono.Cecil.Metadata\IMetadataRow.cs" />
- <Compile Include="Mono.Cecil.Metadata\IMetadataTable.cs" />
- <Compile Include="Mono.Cecil.Metadata\IMetadataVisitable.cs" />
- <Compile Include="Mono.Cecil.Metadata\IMetadataVisitor.cs" />
- <Compile Include="Mono.Cecil.Metadata\ImplMap.cs" />
- <Compile Include="Mono.Cecil.Metadata\InterfaceImpl.cs" />
- <Compile Include="Mono.Cecil.Metadata\ManifestResource.cs" />
- <Compile Include="Mono.Cecil.Metadata\MemberRef.cs" />
- <Compile Include="Mono.Cecil.Metadata\MetadataFormatException.cs" />
- <Compile Include="Mono.Cecil.Metadata\MetadataHeap.cs" />
- <Compile Include="Mono.Cecil.Metadata\MetadataInitializer.cs" />
- <Compile Include="Mono.Cecil.Metadata\MetadataReader.cs" />
- <Compile Include="Mono.Cecil.Metadata\MetadataRoot.cs" />
- <Compile Include="Mono.Cecil.Metadata\MetadataRowReader.cs" />
- <Compile Include="Mono.Cecil.Metadata\MetadataRowWriter.cs" />
- <Compile Include="Mono.Cecil.Metadata\MetadataStream.cs" />
- <Compile Include="Mono.Cecil.Metadata\MetadataStreamCollection.cs" />
- <Compile Include="Mono.Cecil.Metadata\MetadataTableReader.cs" />
- <Compile Include="Mono.Cecil.Metadata\MetadataTableWriter.cs" />
+ <Compile Include="Mono.Cecil.Metadata\Heap.cs" />
<Compile Include="Mono.Cecil.Metadata\MetadataToken.cs" />
- <Compile Include="Mono.Cecil.Metadata\MetadataWriter.cs" />
- <Compile Include="Mono.Cecil.Metadata\Method.cs" />
- <Compile Include="Mono.Cecil.Metadata\MethodImpl.cs" />
- <Compile Include="Mono.Cecil.Metadata\MethodPtr.cs" />
- <Compile Include="Mono.Cecil.Metadata\MethodSemantics.cs" />
- <Compile Include="Mono.Cecil.Metadata\MethodSpec.cs" />
- <Compile Include="Mono.Cecil.Metadata\Module.cs" />
- <Compile Include="Mono.Cecil.Metadata\ModuleRef.cs" />
- <Compile Include="Mono.Cecil.Metadata\NestedClass.cs" />
- <Compile Include="Mono.Cecil.Metadata\Param.cs" />
- <Compile Include="Mono.Cecil.Metadata\ParamPtr.cs" />
- <Compile Include="Mono.Cecil.Metadata\Property.cs" />
- <Compile Include="Mono.Cecil.Metadata\PropertyMap.cs" />
- <Compile Include="Mono.Cecil.Metadata\PropertyPtr.cs" />
- <Compile Include="Mono.Cecil.Metadata\RowCollection.cs" />
- <Compile Include="Mono.Cecil.Metadata\StandAloneSig.cs" />
- <Compile Include="Mono.Cecil.Metadata\StringsHeap.cs" />
- <Compile Include="Mono.Cecil.Metadata\TableCollection.cs" />
- <Compile Include="Mono.Cecil.Metadata\TablesHeap.cs" />
+ <Compile Include="Mono.Cecil.Metadata\Row.cs" />
+ <Compile Include="Mono.Cecil.Metadata\StringHeap.cs" />
+ <Compile Include="Mono.Cecil.Metadata\TableHeap.cs" />
<Compile Include="Mono.Cecil.Metadata\TokenType.cs" />
- <Compile Include="Mono.Cecil.Metadata\TypeDef.cs" />
- <Compile Include="Mono.Cecil.Metadata\TypeRef.cs" />
- <Compile Include="Mono.Cecil.Metadata\TypeSpec.cs" />
- <Compile Include="Mono.Cecil.Metadata\UserStringsHeap.cs" />
+ <Compile Include="Mono.Cecil.Metadata\UserStringHeap.cs" />
<Compile Include="Mono.Cecil.Metadata\Utilities.cs" />
- <Compile Include="Mono.Cecil.Signatures\Array.cs" />
- <Compile Include="Mono.Cecil.Signatures\ArrayShape.cs" />
- <Compile Include="Mono.Cecil.Signatures\BaseSignatureVisitor.cs" />
- <Compile Include="Mono.Cecil.Signatures\Class.cs" />
- <Compile Include="Mono.Cecil.Signatures\Constraint.cs" />
- <Compile Include="Mono.Cecil.Signatures\CustomAttrib.cs" />
- <Compile Include="Mono.Cecil.Signatures\CustomMod.cs" />
- <Compile Include="Mono.Cecil.Signatures\FieldSig.cs" />
- <Compile Include="Mono.Cecil.Signatures\FnPtr.cs" />
- <Compile Include="Mono.Cecil.Signatures\GenericArg.cs" />
- <Compile Include="Mono.Cecil.Signatures\GenericInst.cs" />
- <Compile Include="Mono.Cecil.Signatures\GenericInstSignature.cs" />
- <Compile Include="Mono.Cecil.Signatures\InputOutputItem.cs" />
- <Compile Include="Mono.Cecil.Signatures\ISignatureVisitable.cs" />
- <Compile Include="Mono.Cecil.Signatures\ISignatureVisitor.cs" />
- <Compile Include="Mono.Cecil.Signatures\LocalVarSig.cs" />
- <Compile Include="Mono.Cecil.Signatures\MarshalSig.cs" />
- <Compile Include="Mono.Cecil.Signatures\MethodDefSig.cs" />
- <Compile Include="Mono.Cecil.Signatures\MethodRefSig.cs" />
- <Compile Include="Mono.Cecil.Signatures\MethodSig.cs" />
- <Compile Include="Mono.Cecil.Signatures\MethodSpec.cs" />
- <Compile Include="Mono.Cecil.Signatures\MVar.cs" />
- <Compile Include="Mono.Cecil.Signatures\Param.cs" />
- <Compile Include="Mono.Cecil.Signatures\PropertySig.cs" />
- <Compile Include="Mono.Cecil.Signatures\Ptr.cs" />
- <Compile Include="Mono.Cecil.Signatures\RetType.cs" />
- <Compile Include="Mono.Cecil.Signatures\Signature.cs" />
- <Compile Include="Mono.Cecil.Signatures\SignatureReader.cs" />
- <Compile Include="Mono.Cecil.Signatures\SignatureWriter.cs" />
- <Compile Include="Mono.Cecil.Signatures\SigType.cs" />
- <Compile Include="Mono.Cecil.Signatures\SzArray.cs" />
- <Compile Include="Mono.Cecil.Signatures\TypeSpec.cs" />
- <Compile Include="Mono.Cecil.Signatures\ValueType.cs" />
- <Compile Include="Mono.Cecil.Signatures\Var.cs" />
- <Compile Include="Mono.Cecil\AggressiveReflectionReader.cs" />
- <Compile Include="Mono.Cecil\ArrayDimension.cs" />
- <Compile Include="Mono.Cecil\ArrayDimensionCollection.cs" />
+ <Compile Include="Mono.Cecil.PE\BinaryStreamReader.cs" />
+ <Compile Include="Mono.Cecil.PE\BinaryStreamWriter.cs" />
+ <Compile Include="Mono.Cecil.PE\ByteBufferEqualityComparer.cs" />
+ <Compile Include="Mono.Cecil.PE\ByteBuffer.cs" />
+ <Compile Include="Mono.Cecil.PE\DataDirectory.cs" />
+ <Compile Include="Mono.Cecil.PE\Image.cs" />
+ <Compile Include="Mono.Cecil.PE\ImageReader.cs" />
+ <Compile Include="Mono.Cecil.PE\ImageWriter.cs" />
+ <Compile Include="Mono.Cecil.PE\Section.cs" />
+ <Compile Include="Mono.Cecil.PE\TextMap.cs" />
<Compile Include="Mono.Cecil\ArrayType.cs" />
<Compile Include="Mono.Cecil\AssemblyDefinition.cs" />
- <Compile Include="Mono.Cecil\AssemblyFactory.cs" />
<Compile Include="Mono.Cecil\AssemblyFlags.cs" />
<Compile Include="Mono.Cecil\AssemblyHashAlgorithm.cs" />
<Compile Include="Mono.Cecil\AssemblyInfo.cs" />
- <Compile Include="Mono.Cecil\AssemblyKind.cs" />
<Compile Include="Mono.Cecil\AssemblyLinkedResource.cs" />
<Compile Include="Mono.Cecil\AssemblyNameDefinition.cs" />
<Compile Include="Mono.Cecil\AssemblyNameReference.cs" />
- <Compile Include="Mono.Cecil\AssemblyNameReferenceCollection.cs" />
+ <Compile Include="Mono.Cecil\AssemblyReader.cs" />
+ <Compile Include="Mono.Cecil\AssemblyWriter.cs" />
<Compile Include="Mono.Cecil\BaseAssemblyResolver.cs" />
- <Compile Include="Mono.Cecil\BaseReflectionReader.cs" />
- <Compile Include="Mono.Cecil\BaseReflectionVisitor.cs" />
- <Compile Include="Mono.Cecil\BaseStructureVisitor.cs" />
<Compile Include="Mono.Cecil\CallSite.cs" />
- <Compile Include="Mono.Cecil\CompactFrameworkCompatibility.cs" />
- <Compile Include="Mono.Cecil\Constants.cs" />
- <Compile Include="Mono.Cecil\ConstraintCollection.cs" />
- <Compile Include="Mono.Cecil\ConstructorCollection.cs" />
+ <Compile Include="Mono.Cecil\TypeParser.cs" />
+ <Compile Include="Mono.Cecil\Import.cs" />
+ <Compile Include="Mono.Collections.Generic\Collection.cs" />
+ <Compile Include="Mono.Cecil\ExportedType.cs" />
+ <Compile Include="Mono.Cecil\SecurityDeclaration.cs" />
<Compile Include="Mono.Cecil\CustomAttribute.cs" />
- <Compile Include="Mono.Cecil\CustomAttributeCollection.cs" />
<Compile Include="Mono.Cecil\DefaultAssemblyResolver.cs" />
- <Compile Include="Mono.Cecil\DefaultImporter.cs" />
- <Compile Include="Mono.Cecil\EmbeddedResource.cs" />
- <Compile Include="Mono.Cecil\EventAttributes.cs" />
- <Compile Include="Mono.Cecil\EventDefinition.cs" />
- <Compile Include="Mono.Cecil\EventDefinitionCollection.cs" />
- <Compile Include="Mono.Cecil\EventReference.cs" />
- <Compile Include="Mono.Cecil\ExternTypeCollection.cs" />
- <Compile Include="Mono.Cecil\FieldAttributes.cs" />
- <Compile Include="Mono.Cecil\FieldDefinition.cs" />
- <Compile Include="Mono.Cecil\FieldDefinitionCollection.cs" />
- <Compile Include="Mono.Cecil\FieldReference.cs" />
<Compile Include="Mono.Cecil\FileAttributes.cs" />
<Compile Include="Mono.Cecil\FunctionPointerType.cs" />
- <Compile Include="Mono.Cecil\GenericArgumentCollection.cs" />
- <Compile Include="Mono.Cecil\GenericContext.cs" />
<Compile Include="Mono.Cecil\GenericInstanceMethod.cs" />
<Compile Include="Mono.Cecil\GenericInstanceType.cs" />
<Compile Include="Mono.Cecil\GenericParameter.cs" />
<Compile Include="Mono.Cecil\GenericParameterAttributes.cs" />
- <Compile Include="Mono.Cecil\GenericParameterCollection.cs" />
- <Compile Include="Mono.Cecil\HashCodeProvider.cs" />
- <Compile Include="Mono.Cecil\IAnnotationProvider.cs" />
- <Compile Include="Mono.Cecil\IAssemblyResolver.cs" />
+ <Compile Include="Mono.Cecil\IConstantProvider.cs" />
<Compile Include="Mono.Cecil\ICustomAttributeProvider.cs" />
- <Compile Include="Mono.Cecil\IDetailReader.cs" />
<Compile Include="Mono.Cecil\IGenericInstance.cs" />
<Compile Include="Mono.Cecil\IGenericParameterProvider.cs" />
- <Compile Include="Mono.Cecil\IHasConstant.cs" />
- <Compile Include="Mono.Cecil\IHasMarshalSpec.cs" />
- <Compile Include="Mono.Cecil\IHasSecurity.cs" />
- <Compile Include="Mono.Cecil\IImporter.cs" />
- <Compile Include="Mono.Cecil\IMemberDefinition.cs" />
- <Compile Include="Mono.Cecil\IMemberReference.cs" />
- <Compile Include="Mono.Cecil\IMetadataScope.cs" />
- <Compile Include="Mono.Cecil\IMetadataTokenProvider.cs" />
+ <Compile Include="Mono.Cecil\IMarshalInfoProvider.cs" />
+ <Compile Include="Mono.Cecil\MarshalInfo.cs" />
+ <Compile Include="Mono.Cecil\MetadataResolver.cs" />
+ <Compile Include="Mono.Cecil\Modifiers.cs" />
+ <Compile Include="Mono.Cecil\NativeType.cs" />
+ <Compile Include="Mono.Cecil\PinnedType.cs" />
+ <Compile Include="Mono.Cecil\MetadataSystem.cs" />
<Compile Include="Mono.Cecil\IMethodSignature.cs" />
- <Compile Include="Mono.Cecil\ImportContext.cs" />
- <Compile Include="Mono.Cecil\InterfaceCollection.cs" />
- <Compile Include="Mono.Cecil\IReflectionStructureVisitable.cs" />
- <Compile Include="Mono.Cecil\IReflectionStructureVisitor.cs" />
- <Compile Include="Mono.Cecil\IReflectionVisitable.cs" />
- <Compile Include="Mono.Cecil\IReflectionVisitor.cs" />
- <Compile Include="Mono.Cecil\IRequireResolving.cs" />
+ <Compile Include="Mono.Cecil\ParameterDefinitionCollection.cs" />
+ <Compile Include="Mono.Cecil\EmbeddedResource.cs" />
+ <Compile Include="Mono.Cecil\EventAttributes.cs" />
+ <Compile Include="Mono.Cecil\EventDefinition.cs" />
+ <Compile Include="Mono.Cecil\EventReference.cs" />
+ <Compile Include="Mono.Cecil\FieldAttributes.cs" />
+ <Compile Include="Mono.Cecil\FieldDefinition.cs" />
+ <Compile Include="Mono.Cecil\FieldReference.cs" />
+ <Compile Include="Mono.Cecil\IMemberDefinition.cs" />
<Compile Include="Mono.Cecil\LinkedResource.cs" />
- <Compile Include="Mono.Cecil\ManifestResourceAttributes.cs" />
- <Compile Include="Mono.Cecil\MarshalSpec.cs" />
<Compile Include="Mono.Cecil\MemberReference.cs" />
- <Compile Include="Mono.Cecil\MemberReferenceCollection.cs" />
<Compile Include="Mono.Cecil\MethodAttributes.cs" />
<Compile Include="Mono.Cecil\MethodCallingConvention.cs" />
<Compile Include="Mono.Cecil\MethodDefinition.cs" />
- <Compile Include="Mono.Cecil\MethodDefinitionCollection.cs" />
<Compile Include="Mono.Cecil\MethodImplAttributes.cs" />
<Compile Include="Mono.Cecil\MethodReference.cs" />
<Compile Include="Mono.Cecil\MethodReturnType.cs" />
<Compile Include="Mono.Cecil\MethodSemanticsAttributes.cs" />
<Compile Include="Mono.Cecil\MethodSpecification.cs" />
- <Compile Include="Mono.Cecil\Modifiers.cs" />
- <Compile Include="Mono.Cecil\ModuleDefinition.cs" />
- <Compile Include="Mono.Cecil\ModuleDefinitionCollection.cs" />
- <Compile Include="Mono.Cecil\ModuleReference.cs" />
- <Compile Include="Mono.Cecil\ModuleReferenceCollection.cs" />
- <Compile Include="Mono.Cecil\NativeType.cs" />
- <Compile Include="Mono.Cecil\NestedTypeCollection.cs" />
- <Compile Include="Mono.Cecil\NullReferenceImporter.cs" />
- <Compile Include="Mono.Cecil\OverrideCollection.cs" />
<Compile Include="Mono.Cecil\ParameterAttributes.cs" />
<Compile Include="Mono.Cecil\ParameterDefinition.cs" />
- <Compile Include="Mono.Cecil\ParameterDefinitionCollection.cs" />
<Compile Include="Mono.Cecil\ParameterReference.cs" />
- <Compile Include="Mono.Cecil\PinnedType.cs" />
<Compile Include="Mono.Cecil\PInvokeAttributes.cs" />
<Compile Include="Mono.Cecil\PInvokeInfo.cs" />
<Compile Include="Mono.Cecil\PointerType.cs" />
<Compile Include="Mono.Cecil\PropertyAttributes.cs" />
<Compile Include="Mono.Cecil\PropertyDefinition.cs" />
- <Compile Include="Mono.Cecil\PropertyDefinitionCollection.cs" />
<Compile Include="Mono.Cecil\PropertyReference.cs" />
<Compile Include="Mono.Cecil\ReferenceType.cs" />
- <Compile Include="Mono.Cecil\ReflectionController.cs" />
- <Compile Include="Mono.Cecil\ReflectionException.cs" />
- <Compile Include="Mono.Cecil\ReflectionHelper.cs" />
- <Compile Include="Mono.Cecil\ReflectionReader.cs" />
- <Compile Include="Mono.Cecil\ReflectionWriter.cs" />
+ <Compile Include="Mono.Cecil\IMetadataScope.cs" />
+ <Compile Include="Mono.Cecil\IMetadataTokenProvider.cs" />
+ <Compile Include="Mono.Cecil\ManifestResourceAttributes.cs" />
+ <Compile Include="Mono.Cecil\ModuleReference.cs" />
+ <Compile Include="Mono.Cecil\MemberDefinitionCollection.cs" />
+ <Compile Include="Mono.Cecil\ModuleDefinition.cs" />
+ <Compile Include="Mono.Cecil\ModuleKind.cs" />
<Compile Include="Mono.Cecil\Resource.cs" />
- <Compile Include="Mono.Cecil\ResourceCollection.cs" />
- <Compile Include="Mono.Cecil\SecurityAction.cs" />
- <Compile Include="Mono.Cecil\SecurityDeclaration.cs" />
- <Compile Include="Mono.Cecil\SecurityDeclarationCollection.cs" />
- <Compile Include="Mono.Cecil\SecurityDeclarationReader.cs" />
<Compile Include="Mono.Cecil\SentinelType.cs" />
- <Compile Include="Mono.Cecil\StructureReader.cs" />
- <Compile Include="Mono.Cecil\StructureWriter.cs" />
- <Compile Include="Mono.Cecil\TableComparers.cs" />
<Compile Include="Mono.Cecil\TargetRuntime.cs" />
<Compile Include="Mono.Cecil\TypeAttributes.cs" />
<Compile Include="Mono.Cecil\TypeDefinition.cs" />
<Compile Include="Mono.Cecil\TypeDefinitionCollection.cs" />
<Compile Include="Mono.Cecil\TypeReference.cs" />
- <Compile Include="Mono.Cecil\TypeReferenceCollection.cs" />
<Compile Include="Mono.Cecil\TypeSpecification.cs" />
+ <Compile Include="Mono.Cecil\TypeSystem.cs" />
<Compile Include="Mono.Cecil\VariantType.cs" />
- <Compile Include="Mono.Xml\MiniParser.cs" />
- <Compile Include="Mono.Xml\SecurityParser.cs" />
- <Compile Include="Mono.Xml\SmallXmlParser.cs" />
+ <Compile Include="Mono.Collections.Generic\ReadOnlyCollection.cs" />
+ <Compile Include="Mono.Security.Cryptography\CryptoConvert.cs" />
+ <Compile Include="Mono.Security.Cryptography\CryptoService.cs" />
+ <Compile Include="System.Runtime.CompilerServices\ExtensionAttribute.cs" />
+ <Compile Include="Mono\Actions.cs" />
+ <Compile Include="Mono\Empty.cs" />
+ <Compile Include="Mono\Funcs.cs" />
</ItemGroup>
<ItemGroup>
- <None Include="AUTHORS" />
- <None Include="ChangeLog" />
- <None Include="configure" />
- <None Include="default.build" />
- <None Include="Makefile" />
- <None Include="mono-cecil.pc.in" />
- <None Include="Mono.Cecil.dll.sources" />
- <None Include="Mono.Xml\ChangeLog" />
- <None Include="NEWS" />
- <None Include="README" />
- <None Include="TODO" />
+ <Content Include="NOTES.txt" />
</ItemGroup>
<ItemGroup>
- <Reference Include="System" />
+ <None Include="mono.snk" />
</ItemGroup>
-</Project>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.dll.sources b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.dll.sources
deleted file mode 100644
index d3568bf..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.dll.sources
+++ /dev/null
@@ -1,311 +0,0 @@
-./Mono.Cecil/AggressiveReflectionReader.cs
-./Mono.Cecil/ArrayDimension.cs
-./Mono.Cecil/ArrayDimensionCollection.cs
-./Mono.Cecil/ArrayType.cs
-./Mono.Cecil/AssemblyDefinition.cs
-./Mono.Cecil/AssemblyFactory.cs
-./Mono.Cecil/AssemblyFlags.cs
-./Mono.Cecil/AssemblyHashAlgorithm.cs
-./Mono.Cecil/AssemblyInfo.cs
-./Mono.Cecil/AssemblyKind.cs
-./Mono.Cecil/AssemblyLinkedResource.cs
-./Mono.Cecil/AssemblyNameDefinition.cs
-./Mono.Cecil/AssemblyNameReference.cs
-./Mono.Cecil/AssemblyNameReferenceCollection.cs
-./Mono.Cecil/BaseAssemblyResolver.cs
-./Mono.Cecil/BaseReflectionReader.cs
-./Mono.Cecil/BaseReflectionVisitor.cs
-./Mono.Cecil/BaseStructureVisitor.cs
-./Mono.Cecil/CallSite.cs
-./Mono.Cecil/CompactFrameworkCompatibility.cs
-./Mono.Cecil/Constants.cs
-./Mono.Cecil/ConstraintCollection.cs
-./Mono.Cecil/ConstructorCollection.cs
-./Mono.Cecil/CustomAttribute.cs
-./Mono.Cecil/CustomAttributeCollection.cs
-./Mono.Cecil/DefaultAssemblyResolver.cs
-./Mono.Cecil/DefaultImporter.cs
-./Mono.Cecil/EmbeddedResource.cs
-./Mono.Cecil/EventAttributes.cs
-./Mono.Cecil/EventDefinition.cs
-./Mono.Cecil/EventDefinitionCollection.cs
-./Mono.Cecil/EventReference.cs
-./Mono.Cecil/ExternTypeCollection.cs
-./Mono.Cecil/FieldAttributes.cs
-./Mono.Cecil/FieldDefinition.cs
-./Mono.Cecil/FieldDefinitionCollection.cs
-./Mono.Cecil/FieldReference.cs
-./Mono.Cecil/FileAttributes.cs
-./Mono.Cecil/FunctionPointerType.cs
-./Mono.Cecil/GenericArgumentCollection.cs
-./Mono.Cecil/GenericContext.cs
-./Mono.Cecil/GenericInstanceMethod.cs
-./Mono.Cecil/GenericInstanceType.cs
-./Mono.Cecil/GenericParameter.cs
-./Mono.Cecil/GenericParameterAttributes.cs
-./Mono.Cecil/GenericParameterCollection.cs
-./Mono.Cecil/HashCodeProvider.cs
-./Mono.Cecil/IAnnotationProvider.cs
-./Mono.Cecil/IAssemblyResolver.cs
-./Mono.Cecil/ICustomAttributeProvider.cs
-./Mono.Cecil/IDetailReader.cs
-./Mono.Cecil/IGenericInstance.cs
-./Mono.Cecil/IGenericParameterProvider.cs
-./Mono.Cecil/IHasConstant.cs
-./Mono.Cecil/IHasMarshalSpec.cs
-./Mono.Cecil/IHasSecurity.cs
-./Mono.Cecil/IImporter.cs
-./Mono.Cecil/IMemberDefinition.cs
-./Mono.Cecil/IMemberReference.cs
-./Mono.Cecil/IMetadataScope.cs
-./Mono.Cecil/IMetadataTokenProvider.cs
-./Mono.Cecil/IMethodSignature.cs
-./Mono.Cecil/ImportContext.cs
-./Mono.Cecil/InterfaceCollection.cs
-./Mono.Cecil/IReflectionStructureVisitable.cs
-./Mono.Cecil/IReflectionStructureVisitor.cs
-./Mono.Cecil/IReflectionVisitable.cs
-./Mono.Cecil/IReflectionVisitor.cs
-./Mono.Cecil/IRequireResolving.cs
-./Mono.Cecil/LinkedResource.cs
-./Mono.Cecil/ManifestResourceAttributes.cs
-./Mono.Cecil/MarshalSpec.cs
-./Mono.Cecil/MemberReference.cs
-./Mono.Cecil/MemberReferenceCollection.cs
-./Mono.Cecil/MethodAttributes.cs
-./Mono.Cecil/MethodCallingConvention.cs
-./Mono.Cecil/MethodDefinition.cs
-./Mono.Cecil/MethodDefinitionCollection.cs
-./Mono.Cecil/MethodImplAttributes.cs
-./Mono.Cecil/MethodReference.cs
-./Mono.Cecil/MethodReturnType.cs
-./Mono.Cecil/MethodSemanticsAttributes.cs
-./Mono.Cecil/MethodSpecification.cs
-./Mono.Cecil/Modifiers.cs
-./Mono.Cecil/ModuleDefinition.cs
-./Mono.Cecil/ModuleDefinitionCollection.cs
-./Mono.Cecil/ModuleReference.cs
-./Mono.Cecil/ModuleReferenceCollection.cs
-./Mono.Cecil/NativeType.cs
-./Mono.Cecil/NestedTypeCollection.cs
-./Mono.Cecil/NullReferenceImporter.cs
-./Mono.Cecil/OverrideCollection.cs
-./Mono.Cecil/ParameterAttributes.cs
-./Mono.Cecil/ParameterDefinition.cs
-./Mono.Cecil/ParameterDefinitionCollection.cs
-./Mono.Cecil/ParameterReference.cs
-./Mono.Cecil/PinnedType.cs
-./Mono.Cecil/PInvokeAttributes.cs
-./Mono.Cecil/PInvokeInfo.cs
-./Mono.Cecil/PointerType.cs
-./Mono.Cecil/PropertyAttributes.cs
-./Mono.Cecil/PropertyDefinition.cs
-./Mono.Cecil/PropertyDefinitionCollection.cs
-./Mono.Cecil/PropertyReference.cs
-./Mono.Cecil/ReferenceType.cs
-./Mono.Cecil/ReflectionController.cs
-./Mono.Cecil/ReflectionException.cs
-./Mono.Cecil/ReflectionHelper.cs
-./Mono.Cecil/ReflectionReader.cs
-./Mono.Cecil/ReflectionWriter.cs
-./Mono.Cecil/Resource.cs
-./Mono.Cecil/ResourceCollection.cs
-./Mono.Cecil/SecurityAction.cs
-./Mono.Cecil/SecurityDeclaration.cs
-./Mono.Cecil/SecurityDeclarationCollection.cs
-./Mono.Cecil/SecurityDeclarationReader.cs
-./Mono.Cecil/SentinelType.cs
-./Mono.Cecil/StructureReader.cs
-./Mono.Cecil/StructureWriter.cs
-./Mono.Cecil/TableComparers.cs
-./Mono.Cecil/TargetRuntime.cs
-./Mono.Cecil/TypeAttributes.cs
-./Mono.Cecil/TypeDefinition.cs
-./Mono.Cecil/TypeDefinitionCollection.cs
-./Mono.Cecil/TypeReference.cs
-./Mono.Cecil/TypeReferenceCollection.cs
-./Mono.Cecil/TypeSpecification.cs
-./Mono.Cecil/VariantType.cs
-./Mono.Cecil.Binary/BaseImageVisitor.cs
-./Mono.Cecil.Binary/CLIHeader.cs
-./Mono.Cecil.Binary/CopyImageVisitor.cs
-./Mono.Cecil.Binary/DataDirectory.cs
-./Mono.Cecil.Binary/DebugHeader.cs
-./Mono.Cecil.Binary/DebugStoreType.cs
-./Mono.Cecil.Binary/DOSHeader.cs
-./Mono.Cecil.Binary/ExportTable.cs
-./Mono.Cecil.Binary/IBinaryVisitable.cs
-./Mono.Cecil.Binary/IBinaryVisitor.cs
-./Mono.Cecil.Binary/IHeader.cs
-./Mono.Cecil.Binary/Image.cs
-./Mono.Cecil.Binary/ImageCharacteristics.cs
-./Mono.Cecil.Binary/ImageFormatException.cs
-./Mono.Cecil.Binary/ImageInitializer.cs
-./Mono.Cecil.Binary/ImageReader.cs
-./Mono.Cecil.Binary/ImageWriter.cs
-./Mono.Cecil.Binary/Imports.cs
-./Mono.Cecil.Binary/MemoryBinaryWriter.cs
-./Mono.Cecil.Binary/PEFileHeader.cs
-./Mono.Cecil.Binary/PEOptionalHeader.cs
-./Mono.Cecil.Binary/ResourceDataEntry.cs
-./Mono.Cecil.Binary/ResourceDirectoryEntry.cs
-./Mono.Cecil.Binary/ResourceDirectoryString.cs
-./Mono.Cecil.Binary/ResourceDirectoryTable.cs
-./Mono.Cecil.Binary/ResourceNode.cs
-./Mono.Cecil.Binary/ResourceReader.cs
-./Mono.Cecil.Binary/ResourceWriter.cs
-./Mono.Cecil.Binary/RuntimeImage.cs
-./Mono.Cecil.Binary/RVA.cs
-./Mono.Cecil.Binary/Section.cs
-./Mono.Cecil.Binary/SectionCharacteristics.cs
-./Mono.Cecil.Binary/SectionCollection.cs
-./Mono.Cecil.Binary/SubSystem.cs
-./Mono.Cecil.Metadata/Assembly.cs
-./Mono.Cecil.Metadata/AssemblyOS.cs
-./Mono.Cecil.Metadata/AssemblyProcessor.cs
-./Mono.Cecil.Metadata/AssemblyRef.cs
-./Mono.Cecil.Metadata/AssemblyRefOS.cs
-./Mono.Cecil.Metadata/AssemblyRefProcessor.cs
-./Mono.Cecil.Metadata/BaseMetadataVisitor.cs
-./Mono.Cecil.Metadata/BlobHeap.cs
-./Mono.Cecil.Metadata/ClassLayout.cs
-./Mono.Cecil.Metadata/CodedIndex.cs
-./Mono.Cecil.Metadata/Constant.cs
-./Mono.Cecil.Metadata/CultureUtils.cs
-./Mono.Cecil.Metadata/CustomAttribute.cs
-./Mono.Cecil.Metadata/DeclSecurity.cs
-./Mono.Cecil.Metadata/ElementType.cs
-./Mono.Cecil.Metadata/Event.cs
-./Mono.Cecil.Metadata/EventMap.cs
-./Mono.Cecil.Metadata/EventPtr.cs
-./Mono.Cecil.Metadata/ExportedType.cs
-./Mono.Cecil.Metadata/Field.cs
-./Mono.Cecil.Metadata/FieldLayout.cs
-./Mono.Cecil.Metadata/FieldMarshal.cs
-./Mono.Cecil.Metadata/FieldPtr.cs
-./Mono.Cecil.Metadata/FieldRVA.cs
-./Mono.Cecil.Metadata/File.cs
-./Mono.Cecil.Metadata/GenericParam.cs
-./Mono.Cecil.Metadata/GenericParamConstraint.cs
-./Mono.Cecil.Metadata/GuidHeap.cs
-./Mono.Cecil.Metadata/IMetadataRow.cs
-./Mono.Cecil.Metadata/IMetadataTable.cs
-./Mono.Cecil.Metadata/IMetadataVisitable.cs
-./Mono.Cecil.Metadata/IMetadataVisitor.cs
-./Mono.Cecil.Metadata/ImplMap.cs
-./Mono.Cecil.Metadata/InterfaceImpl.cs
-./Mono.Cecil.Metadata/ManifestResource.cs
-./Mono.Cecil.Metadata/MemberRef.cs
-./Mono.Cecil.Metadata/MetadataFormatException.cs
-./Mono.Cecil.Metadata/MetadataHeap.cs
-./Mono.Cecil.Metadata/MetadataInitializer.cs
-./Mono.Cecil.Metadata/MetadataReader.cs
-./Mono.Cecil.Metadata/MetadataRoot.cs
-./Mono.Cecil.Metadata/MetadataRowReader.cs
-./Mono.Cecil.Metadata/MetadataRowWriter.cs
-./Mono.Cecil.Metadata/MetadataStream.cs
-./Mono.Cecil.Metadata/MetadataStreamCollection.cs
-./Mono.Cecil.Metadata/MetadataTableReader.cs
-./Mono.Cecil.Metadata/MetadataTableWriter.cs
-./Mono.Cecil.Metadata/MetadataToken.cs
-./Mono.Cecil.Metadata/MetadataWriter.cs
-./Mono.Cecil.Metadata/Method.cs
-./Mono.Cecil.Metadata/MethodImpl.cs
-./Mono.Cecil.Metadata/MethodPtr.cs
-./Mono.Cecil.Metadata/MethodSemantics.cs
-./Mono.Cecil.Metadata/MethodSpec.cs
-./Mono.Cecil.Metadata/Module.cs
-./Mono.Cecil.Metadata/ModuleRef.cs
-./Mono.Cecil.Metadata/NestedClass.cs
-./Mono.Cecil.Metadata/Param.cs
-./Mono.Cecil.Metadata/ParamPtr.cs
-./Mono.Cecil.Metadata/Property.cs
-./Mono.Cecil.Metadata/PropertyMap.cs
-./Mono.Cecil.Metadata/PropertyPtr.cs
-./Mono.Cecil.Metadata/RowCollection.cs
-./Mono.Cecil.Metadata/StandAloneSig.cs
-./Mono.Cecil.Metadata/StringsHeap.cs
-./Mono.Cecil.Metadata/TableCollection.cs
-./Mono.Cecil.Metadata/TablesHeap.cs
-./Mono.Cecil.Metadata/TokenType.cs
-./Mono.Cecil.Metadata/TypeDef.cs
-./Mono.Cecil.Metadata/TypeRef.cs
-./Mono.Cecil.Metadata/TypeSpec.cs
-./Mono.Cecil.Metadata/UserStringsHeap.cs
-./Mono.Cecil.Metadata/Utilities.cs
-./Mono.Cecil.Cil/BaseCodeVisitor.cs
-./Mono.Cecil.Cil/CilWorker.cs
-./Mono.Cecil.Cil/Code.cs
-./Mono.Cecil.Cil/CodeReader.cs
-./Mono.Cecil.Cil/CodeWriter.cs
-./Mono.Cecil.Cil/Document.cs
-./Mono.Cecil.Cil/DocumentHashAlgorithm.cs
-./Mono.Cecil.Cil/DocumentLanguage.cs
-./Mono.Cecil.Cil/DocumentLanguageVendor.cs
-./Mono.Cecil.Cil/DocumentType.cs
-./Mono.Cecil.Cil/ExceptionHandler.cs
-./Mono.Cecil.Cil/ExceptionHandlerCollection.cs
-./Mono.Cecil.Cil/ExceptionHandlerType.cs
-./Mono.Cecil.Cil/FlowControl.cs
-./Mono.Cecil.Cil/GuidAttribute.cs
-./Mono.Cecil.Cil/ICodeVisitable.cs
-./Mono.Cecil.Cil/ICodeVisitor.cs
-./Mono.Cecil.Cil/Instruction.cs
-./Mono.Cecil.Cil/InstructionCollection.cs
-./Mono.Cecil.Cil/IScopeProvider.cs
-./Mono.Cecil.Cil/ISymbolReader.cs
-./Mono.Cecil.Cil/ISymbolStoreFactory.cs
-./Mono.Cecil.Cil/ISymbolWriter.cs
-./Mono.Cecil.Cil/IVariableDefinitionProvider.cs
-./Mono.Cecil.Cil/MethodBody.cs
-./Mono.Cecil.Cil/MethodDataSection.cs
-./Mono.Cecil.Cil/MethodHeader.cs
-./Mono.Cecil.Cil/OpCode.cs
-./Mono.Cecil.Cil/OpCodes.cs
-./Mono.Cecil.Cil/OpCodeType.cs
-./Mono.Cecil.Cil/OperandType.cs
-./Mono.Cecil.Cil/Scope.cs
-./Mono.Cecil.Cil/ScopeCollection.cs
-./Mono.Cecil.Cil/SequencePoint.cs
-./Mono.Cecil.Cil/StackBehaviour.cs
-./Mono.Cecil.Cil/SymbolStoreHelper.cs
-./Mono.Cecil.Cil/VariableDefinition.cs
-./Mono.Cecil.Cil/VariableDefinitionCollection.cs
-./Mono.Cecil.Cil/VariableReference.cs
-./Mono.Cecil.Signatures/Array.cs
-./Mono.Cecil.Signatures/ArrayShape.cs
-./Mono.Cecil.Signatures/BaseSignatureVisitor.cs
-./Mono.Cecil.Signatures/Class.cs
-./Mono.Cecil.Signatures/Constraint.cs
-./Mono.Cecil.Signatures/CustomAttrib.cs
-./Mono.Cecil.Signatures/CustomMod.cs
-./Mono.Cecil.Signatures/FieldSig.cs
-./Mono.Cecil.Signatures/FnPtr.cs
-./Mono.Cecil.Signatures/GenericArg.cs
-./Mono.Cecil.Signatures/GenericInst.cs
-./Mono.Cecil.Signatures/GenericInstSignature.cs
-./Mono.Cecil.Signatures/InputOutputItem.cs
-./Mono.Cecil.Signatures/ISignatureVisitable.cs
-./Mono.Cecil.Signatures/ISignatureVisitor.cs
-./Mono.Cecil.Signatures/LocalVarSig.cs
-./Mono.Cecil.Signatures/MarshalSig.cs
-./Mono.Cecil.Signatures/MethodDefSig.cs
-./Mono.Cecil.Signatures/MethodRefSig.cs
-./Mono.Cecil.Signatures/MethodSig.cs
-./Mono.Cecil.Signatures/MethodSpec.cs
-./Mono.Cecil.Signatures/MVar.cs
-./Mono.Cecil.Signatures/Param.cs
-./Mono.Cecil.Signatures/PropertySig.cs
-./Mono.Cecil.Signatures/Ptr.cs
-./Mono.Cecil.Signatures/RetType.cs
-./Mono.Cecil.Signatures/Signature.cs
-./Mono.Cecil.Signatures/SignatureReader.cs
-./Mono.Cecil.Signatures/SignatureWriter.cs
-./Mono.Cecil.Signatures/SigType.cs
-./Mono.Cecil.Signatures/SzArray.cs
-./Mono.Cecil.Signatures/TypeSpec.cs
-./Mono.Cecil.Signatures/ValueType.cs
-./Mono.Cecil.Signatures/Var.cs
-./Mono.Xml/MiniParser.cs
-./Mono.Xml/SecurityParser.cs
-./Mono.Xml/SmallXmlParser.cs
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.nunit b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.nunit
new file mode 100755
index 0000000..36e6808
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.nunit
@@ -0,0 +1,9 @@
+<NUnitProject>
+ <Settings activeconfig="Default" />
+ <Config name="Default" binpathtype="Auto">
+ <assembly path="Test\bin\Debug\Mono.Cecil.Tests.dll" />
+ <assembly path="rocks\Test\bin\Debug\Mono.Cecil.Rocks.Tests.dll" />
+ <assembly path="symbols\mdb\Test\bin\Debug\Mono.Cecil.Mdb.Tests.dll" />
+ <assembly path="symbols\pdb\Test\bin\Debug\Mono.Cecil.Pdb.Tests.dll" />
+ </Config>
+</NUnitProject>
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.sln b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.sln
new file mode 100644
index 0000000..4afe99a
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.sln
@@ -0,0 +1,85 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{74E5ECE0-06B4-401C-AEBA-E8DD53E17943}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Symbols", "Symbols", "{929D5B3B-E29A-40CC-93D8-0FF43A6F9FA1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil", "Mono.Cecil.csproj", "{D68133BD-1E63-496E-9EDE-4FBDBF77B486}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Tests", "Test\Mono.Cecil.Tests.csproj", "{A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dbg", "dbg\dbg.csproj", "{89A775F3-64AB-485E-B958-60C25254B732}"
+EndProject
+Project("{00000000-0000-0000-0000-000000000000}") = "Mono.Cecil-SL", "Mono.Cecil-SL.csproj", "{59019979-D337-441B-851F-2133452191A8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Mdb", "symbols\mdb\Mono.Cecil.Mdb.csproj", "{8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Mdb.Tests", "symbols\mdb\Test\Mono.Cecil.Mdb.Tests.csproj", "{AC71DF9C-99FA-4A63-990A-66C8010355A6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Pdb", "symbols\pdb\Mono.Cecil.Pdb.csproj", "{63E6915C-7EA4-4D76-AB28-0D7191EEA626}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Pdb.Tests", "symbols\pdb\Test\Mono.Cecil.Pdb.Tests.csproj", "{29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Rocks.Tests", "rocks\Test\Mono.Cecil.Rocks.Tests.csproj", "{C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Rocks", "rocks\Mono.Cecil.Rocks.csproj", "{FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.Release|Any CPU.Build.0 = Release|Any CPU
+ {89A775F3-64AB-485E-B958-60C25254B732}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {89A775F3-64AB-485E-B958-60C25254B732}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {89A775F3-64AB-485E-B958-60C25254B732}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {89A775F3-64AB-485E-B958-60C25254B732}.Release|Any CPU.Build.0 = Release|Any CPU
+ {59019979-D337-441B-851F-2133452191A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {59019979-D337-441B-851F-2133452191A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {59019979-D337-441B-851F-2133452191A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {59019979-D337-441B-851F-2133452191A8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AC71DF9C-99FA-4A63-990A-66C8010355A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AC71DF9C-99FA-4A63-990A-66C8010355A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AC71DF9C-99FA-4A63-990A-66C8010355A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AC71DF9C-99FA-4A63-990A-66C8010355A6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.Release|Any CPU.Build.0 = Release|Any CPU
+ {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055} = {74E5ECE0-06B4-401C-AEBA-E8DD53E17943}
+ {AC71DF9C-99FA-4A63-990A-66C8010355A6} = {74E5ECE0-06B4-401C-AEBA-E8DD53E17943}
+ {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA} = {74E5ECE0-06B4-401C-AEBA-E8DD53E17943}
+ {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52} = {74E5ECE0-06B4-401C-AEBA-E8DD53E17943}
+ {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD} = {929D5B3B-E29A-40CC-93D8-0FF43A6F9FA1}
+ {63E6915C-7EA4-4D76-AB28-0D7191EEA626} = {929D5B3B-E29A-40CC-93D8-0FF43A6F9FA1}
+ EndGlobalSection
+EndGlobal
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs
deleted file mode 100644
index 3979db7..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs
+++ /dev/null
@@ -1,452 +0,0 @@
-//
-// AggressiveRefletionReader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
-
- using Mono.Cecil.Metadata;
- using Mono.Cecil.Signatures;
-
- internal sealed class AggressiveReflectionReader : ReflectionReader {
-
- public AggressiveReflectionReader (ModuleDefinition module) : base (module)
- {
- }
-
- public override void VisitTypeDefinitionCollection (TypeDefinitionCollection types)
- {
- base.VisitTypeDefinitionCollection (types);
-
- ReadGenericParameterConstraints ();
- ReadClassLayoutInfos ();
- ReadFieldLayoutInfos ();
- ReadPInvokeInfos ();
- ReadProperties ();
- ReadEvents ();
- ReadSemantics ();
- ReadInterfaces ();
- ReadOverrides ();
- ReadSecurityDeclarations ();
- ReadCustomAttributes ();
- ReadConstants ();
- ReadExternTypes ();
- ReadMarshalSpecs ();
- ReadInitialValues ();
-
- m_events = null;
- m_properties = null;
- m_parameters = null;
- }
-
- void ReadGenericParameterConstraints ()
- {
- if (!m_tHeap.HasTable (GenericParamConstraintTable.RId))
- return;
-
- GenericParamConstraintTable gpcTable = m_tableReader.GetGenericParamConstraintTable ();
- for (int i = 0; i < gpcTable.Rows.Count; i++) {
- GenericParamConstraintRow gpcRow = gpcTable [i];
- GenericParameter gp = GetGenericParameterAt (gpcRow.Owner);
-
- gp.Constraints.Add (GetTypeDefOrRef (gpcRow.Constraint, new GenericContext (gp.Owner)));
- }
- }
-
- void ReadClassLayoutInfos ()
- {
- if (!m_tHeap.HasTable (ClassLayoutTable.RId))
- return;
-
- ClassLayoutTable clTable = m_tableReader.GetClassLayoutTable ();
- for (int i = 0; i < clTable.Rows.Count; i++) {
- ClassLayoutRow clRow = clTable [i];
- TypeDefinition type = GetTypeDefAt (clRow.Parent);
- type.PackingSize = clRow.PackingSize;
- type.ClassSize = clRow.ClassSize;
- }
- }
-
- void ReadFieldLayoutInfos ()
- {
- if (!m_tHeap.HasTable (FieldLayoutTable.RId))
- return;
-
- FieldLayoutTable flTable = m_tableReader.GetFieldLayoutTable ();
- for (int i = 0; i < flTable.Rows.Count; i++) {
- FieldLayoutRow flRow = flTable [i];
- FieldDefinition field = GetFieldDefAt (flRow.Field);
- field.Offset = flRow.Offset;
- }
- }
-
- void ReadPInvokeInfos ()
- {
- if (!m_tHeap.HasTable (ImplMapTable.RId))
- return;
-
- ImplMapTable imTable = m_tableReader.GetImplMapTable ();
- for (int i = 0; i < imTable.Rows.Count; i++) {
- ImplMapRow imRow = imTable [i];
- if (imRow.MemberForwarded.TokenType == TokenType.Method) { // should always be true
- MethodDefinition meth = GetMethodDefAt (imRow.MemberForwarded.RID);
- meth.PInvokeInfo = new PInvokeInfo (
- meth, imRow.MappingFlags, MetadataRoot.Streams.StringsHeap [imRow.ImportName],
- Module.ModuleReferences [(int) imRow.ImportScope - 1]);
- }
- }
- }
-
- void ReadProperties ()
- {
- if (!m_tHeap.HasTable (PropertyTable.RId))
- return;
-
- PropertyTable propsTable = m_tableReader.GetPropertyTable ();
- PropertyMapTable pmapTable = m_tableReader.GetPropertyMapTable ();
- m_properties = new PropertyDefinition [propsTable.Rows.Count];
- for (int i = 0; i < pmapTable.Rows.Count; i++) {
- PropertyMapRow pmapRow = pmapTable [i];
- if (pmapRow.Parent == 0)
- continue;
-
- TypeDefinition owner = GetTypeDefAt (pmapRow.Parent);
-
- GenericContext context = new GenericContext (owner);
-
- int start = (int) pmapRow.PropertyList, last = propsTable.Rows.Count + 1, end;
- if (i < pmapTable.Rows.Count - 1)
- end = (int) pmapTable [i + 1].PropertyList;
- else
- end = last;
-
- if (end > last)
- end = last;
-
- for (int j = start; j < end; j++) {
- PropertyRow prow = propsTable [j - 1];
- PropertySig psig = m_sigReader.GetPropSig (prow.Type);
- PropertyDefinition pdef = new PropertyDefinition (
- m_root.Streams.StringsHeap [prow.Name],
- GetTypeRefFromSig (psig.Type, context),
- prow.Flags);
- pdef.MetadataToken = MetadataToken.FromMetadataRow (TokenType.Property, j - 1);
-
- pdef.PropertyType = GetModifierType (psig.CustomMods, pdef.PropertyType);
-
- if (!IsDeleted (pdef))
- owner.Properties.Add (pdef);
-
- m_properties [j - 1] = pdef;
- }
- }
- }
-
- void ReadEvents ()
- {
- if (!m_tHeap.HasTable (EventTable.RId))
- return;
-
- EventTable evtTable = m_tableReader.GetEventTable ();
- EventMapTable emapTable = m_tableReader.GetEventMapTable ();
- m_events = new EventDefinition [evtTable.Rows.Count];
- for (int i = 0; i < emapTable.Rows.Count; i++) {
- EventMapRow emapRow = emapTable [i];
- if (emapRow.Parent == 0)
- continue;
-
- TypeDefinition owner = GetTypeDefAt (emapRow.Parent);
- GenericContext context = new GenericContext (owner);
-
- int start = (int) emapRow.EventList, last = evtTable.Rows.Count + 1, end;
- if (i < (emapTable.Rows.Count - 1))
- end = (int) emapTable [i + 1].EventList;
- else
- end = last;
-
- if (end > last)
- end = last;
-
- for (int j = start; j < end; j++) {
- EventRow erow = evtTable [j - 1];
- EventDefinition edef = new EventDefinition (
- m_root.Streams.StringsHeap [erow.Name],
- GetTypeDefOrRef (erow.EventType, context), erow.EventFlags);
- edef.MetadataToken = MetadataToken.FromMetadataRow (TokenType.Event, j - 1);
-
- if (!IsDeleted (edef))
- owner.Events.Add (edef);
-
- m_events [j - 1] = edef;
- }
- }
- }
-
- void ReadSemantics ()
- {
- if (!m_tHeap.HasTable (MethodSemanticsTable.RId))
- return;
-
- MethodSemanticsTable semTable = m_tableReader.GetMethodSemanticsTable ();
- for (int i = 0; i < semTable.Rows.Count; i++) {
- MethodSemanticsRow semRow = semTable [i];
- MethodDefinition semMeth = GetMethodDefAt (semRow.Method);
- semMeth.SemanticsAttributes = semRow.Semantics;
- switch (semRow.Association.TokenType) {
- case TokenType.Event :
- EventDefinition evt = GetEventDefAt (semRow.Association.RID);
- if ((semRow.Semantics & MethodSemanticsAttributes.AddOn) != 0)
- evt.AddMethod = semMeth;
- else if ((semRow.Semantics & MethodSemanticsAttributes.Fire) != 0)
- evt.InvokeMethod = semMeth;
- else if ((semRow.Semantics & MethodSemanticsAttributes.RemoveOn) != 0)
- evt.RemoveMethod = semMeth;
- break;
- case TokenType.Property :
- PropertyDefinition prop = GetPropertyDefAt (semRow.Association.RID);
- if ((semRow.Semantics & MethodSemanticsAttributes.Getter) != 0)
- prop.GetMethod = semMeth;
- else if ((semRow.Semantics & MethodSemanticsAttributes.Setter) != 0)
- prop.SetMethod = semMeth;
- break;
- }
- }
- }
-
- void ReadInterfaces ()
- {
- if (!m_tHeap.HasTable (InterfaceImplTable.RId))
- return;
-
- InterfaceImplTable intfsTable = m_tableReader.GetInterfaceImplTable ();
- for (int i = 0; i < intfsTable.Rows.Count; i++) {
- InterfaceImplRow intfsRow = intfsTable [i];
- TypeDefinition owner = GetTypeDefAt (intfsRow.Class);
- owner.Interfaces.Add (GetTypeDefOrRef (intfsRow.Interface, new GenericContext (owner)));
- }
- }
-
- void ReadOverrides ()
- {
- if (!m_tHeap.HasTable (MethodImplTable.RId))
- return;
-
- MethodImplTable implTable = m_tableReader.GetMethodImplTable ();
- for (int i = 0; i < implTable.Rows.Count; i++) {
- MethodImplRow implRow = implTable [i];
- if (implRow.MethodBody.TokenType == TokenType.Method) {
- MethodDefinition owner = GetMethodDefAt (implRow.MethodBody.RID);
- switch (implRow.MethodDeclaration.TokenType) {
- case TokenType.Method :
- owner.Overrides.Add (
- GetMethodDefAt (implRow.MethodDeclaration.RID));
- break;
- case TokenType.MemberRef :
- owner.Overrides.Add (
- (MethodReference) GetMemberRefAt (
- implRow.MethodDeclaration.RID, new GenericContext (owner)));
- break;
- }
- }
- }
- }
-
- void ReadSecurityDeclarations ()
- {
- if (!m_tHeap.HasTable (DeclSecurityTable.RId))
- return;
-
- DeclSecurityTable dsTable = m_tableReader.GetDeclSecurityTable ();
- for (int i = 0; i < dsTable.Rows.Count; i++) {
- DeclSecurityRow dsRow = dsTable [i];
- SecurityDeclaration dec = BuildSecurityDeclaration (dsRow);
-
- if (dsRow.Parent.RID == 0)
- continue;
-
- IHasSecurity owner = null;
- switch (dsRow.Parent.TokenType) {
- case TokenType.Assembly :
- owner = this.Module.Assembly;
- break;
- case TokenType.TypeDef :
- owner = GetTypeDefAt (dsRow.Parent.RID);
- break;
- case TokenType.Method :
- owner = GetMethodDefAt (dsRow.Parent.RID);
- break;
- }
-
- owner.SecurityDeclarations.Add (dec);
- }
- }
-
- void ReadCustomAttributes ()
- {
- if (!m_tHeap.HasTable (CustomAttributeTable.RId))
- return;
-
- CustomAttributeTable caTable = m_tableReader.GetCustomAttributeTable ();
- for (int i = 0; i < caTable.Rows.Count; i++) {
- CustomAttributeRow caRow = caTable [i];
- MethodReference ctor;
-
- if (caRow.Type.RID == 0)
- continue;
-
- if (caRow.Type.TokenType == TokenType.Method)
- ctor = GetMethodDefAt (caRow.Type.RID);
- else
- ctor = GetMemberRefAt (caRow.Type.RID, new GenericContext ()) as MethodReference;
-
- CustomAttrib ca = m_sigReader.GetCustomAttrib (caRow.Value, ctor);
- CustomAttribute cattr;
- if (!ca.Read) {
- cattr = new CustomAttribute (ctor);
- cattr.Resolved = false;
- cattr.Blob = m_root.Streams.BlobHeap.Read (caRow.Value);
- } else
- cattr = BuildCustomAttribute (ctor, ca);
-
- if (caRow.Parent.RID == 0)
- continue;
-
- ICustomAttributeProvider owner = null;
- switch (caRow.Parent.TokenType) {
- case TokenType.Assembly :
- owner = this.Module.Assembly;
- break;
- case TokenType.Module :
- owner = this.Module;
- break;
- case TokenType.TypeDef :
- owner = GetTypeDefAt (caRow.Parent.RID);
- break;
- case TokenType.TypeRef :
- owner = GetTypeRefAt (caRow.Parent.RID);
- break;
- case TokenType.Field :
- owner = GetFieldDefAt (caRow.Parent.RID);
- break;
- case TokenType.Method :
- owner = GetMethodDefAt (caRow.Parent.RID);
- break;
- case TokenType.Property :
- owner = GetPropertyDefAt (caRow.Parent.RID);
- break;
- case TokenType.Event :
- owner = GetEventDefAt (caRow.Parent.RID);
- break;
- case TokenType.Param :
- owner = GetParamDefAt (caRow.Parent.RID);
- break;
- case TokenType.GenericParam :
- owner = GetGenericParameterAt (caRow.Parent.RID);
- break;
- default :
- //TODO: support other ?
- break;
- }
-
- if (owner != null)
- owner.CustomAttributes.Add (cattr);
- }
- }
-
- void ReadConstants ()
- {
- if (!m_tHeap.HasTable (ConstantTable.RId))
- return;
-
- ConstantTable csTable = m_tableReader.GetConstantTable ();
- for (int i = 0; i < csTable.Rows.Count; i++) {
- ConstantRow csRow = csTable [i];
-
- object constant = GetConstant (csRow.Value, csRow.Type);
-
- IHasConstant owner = null;
- switch (csRow.Parent.TokenType) {
- case TokenType.Field :
- owner = GetFieldDefAt (csRow.Parent.RID);
- break;
- case TokenType.Property :
- owner = GetPropertyDefAt (csRow.Parent.RID);
- break;
- case TokenType.Param :
- owner = GetParamDefAt (csRow.Parent.RID);
- break;
- }
-
- owner.Constant = constant;
- }
- }
-
- void ReadExternTypes ()
- {
- base.VisitExternTypeCollection (Module.ExternTypes);
- }
-
- void ReadMarshalSpecs ()
- {
- if (!m_tHeap.HasTable (FieldMarshalTable.RId))
- return;
-
- FieldMarshalTable fmTable = m_tableReader.GetFieldMarshalTable ();
- for (int i = 0; i < fmTable.Rows.Count; i++) {
- FieldMarshalRow fmRow = fmTable [i];
-
- IHasMarshalSpec owner = null;
- switch (fmRow.Parent.TokenType) {
- case TokenType.Field:
- owner = GetFieldDefAt (fmRow.Parent.RID);
- break;
- case TokenType.Param:
- owner = GetParamDefAt (fmRow.Parent.RID);
- break;
- }
-
- owner.MarshalSpec = BuildMarshalDesc (
- m_sigReader.GetMarshalSig (fmRow.NativeType), owner);
- }
- }
-
- void ReadInitialValues ()
- {
- if (!m_tHeap.HasTable (FieldRVATable.RId))
- return;
-
- FieldRVATable frTable = m_tableReader.GetFieldRVATable ();
- for (int i = 0; i < frTable.Rows.Count; i++) {
- FieldRVARow frRow = frTable [i];
- FieldDefinition field = GetFieldDefAt (frRow.Field);
- field.RVA = frRow.RVA;
- SetInitialValue (field);
- }
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayType.cs
index 097738c..e3a060f 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayType.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayType.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,80 +26,134 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+using System.Text;
+using Mono.Collections.Generic;
+using MD = Mono.Cecil.Metadata;
+
namespace Mono.Cecil {
- using System;
- using System.Text;
+ public struct ArrayDimension {
+
+ int? lower_bound;
+ int? upper_bound;
+
+ public int? LowerBound {
+ get { return lower_bound; }
+ set { lower_bound = value; }
+ }
+
+ public int? UpperBound {
+ get { return upper_bound; }
+ set { upper_bound = value; }
+ }
+
+ public bool IsSized {
+ get { return lower_bound.HasValue || upper_bound.HasValue; }
+ }
+
+ public ArrayDimension (int? lowerBound, int? upperBound)
+ {
+ this.lower_bound = lowerBound;
+ this.upper_bound = upperBound;
+ }
- using Mono.Cecil.Signatures;
+ public override string ToString ()
+ {
+ return !IsSized
+ ? string.Empty
+ : lower_bound + "..." + upper_bound;
+ }
+ }
public sealed class ArrayType : TypeSpecification {
- private ArrayDimensionCollection m_dimensions;
+ Collection<ArrayDimension> dimensions;
+
+ public Collection<ArrayDimension> Dimensions {
+ get {
+ if (dimensions != null)
+ return dimensions;
- public ArrayDimensionCollection Dimensions {
- get { return m_dimensions; }
+ dimensions = new Collection<ArrayDimension> ();
+ dimensions.Add (new ArrayDimension ());
+ return dimensions;
+ }
}
public int Rank {
- get { return m_dimensions.Count; }
+ get { return dimensions == null ? 1 : dimensions.Count; }
}
- public bool IsSizedArray {
+ public bool IsVector {
get {
- if (this.Rank != 1)
+ if (dimensions == null)
+ return true;
+
+ if (dimensions.Count > 1)
return false;
- ArrayDimension dim = m_dimensions [0];
- return dim.UpperBound == 0;
+
+ var dimension = dimensions [0];
+
+ return !dimension.IsSized;
}
}
+ public override bool IsValueType {
+ get { return false; }
+ set { throw new InvalidOperationException (); }
+ }
+
public override string Name {
- get { return string.Concat (base.Name, Suffix ()); }
+ get { return base.Name + Suffix; }
}
public override string FullName {
- get { return string.Concat (base.FullName, Suffix ()); }
+ get { return base.FullName + Suffix; }
}
- string Suffix ()
- {
- StringBuilder sb = new StringBuilder ();
- sb.Append ("[");
- for (int i = 0; i < m_dimensions.Count; i++) {
- ArrayDimension dim = m_dimensions [i];
- string rank = dim.ToString ();
- if (i < m_dimensions.Count - 1)
- sb.Append (",");
- if (rank.Length > 0) {
- sb.Append (" ");
- sb.Append (rank);
+ string Suffix {
+ get {
+ if (IsVector)
+ return "[]";
+
+ var suffix = new StringBuilder ();
+ suffix.Append ("[");
+ for (int i = 0; i < dimensions.Count; i++) {
+ if (i > 0)
+ suffix.Append (",");
+
+ suffix.Append (dimensions [i].ToString ());
}
+ suffix.Append ("]");
+
+ return suffix.ToString ();
}
- sb.Append ("]");
- return sb.ToString ();
}
- internal ArrayType (TypeReference elementsType, ArrayShape shape) : base (elementsType)
+ public override bool IsArray {
+ get { return true; }
+ }
+
+ public ArrayType (TypeReference type)
+ : base (type)
{
- m_dimensions = new ArrayDimensionCollection (this);
- for (int i = 0; i < shape.Rank; i++) {
- int lower = 0, upper = 0;
- if (i < shape.NumSizes)
- if (i < shape.NumLoBounds) {
- lower = shape.LoBounds [i];
- upper = shape.LoBounds [i] + shape.Sizes [i] - 1;
- } else
- upper = shape.Sizes [i] - 1;
-
- m_dimensions.Add (new ArrayDimension (lower, upper));
- }
+ Mixin.CheckType (type);
+ this.etype = MD.ElementType.Array;
}
- public ArrayType (TypeReference elementsType) : base (elementsType)
+ public ArrayType (TypeReference type, int rank)
+ : this (type)
{
- m_dimensions = new ArrayDimensionCollection (this);
- m_dimensions.Add (new ArrayDimension (0, 0));
+ Mixin.CheckType (type);
+
+ if (rank == 1)
+ return;
+
+ dimensions = new Collection<ArrayDimension> (rank);
+ for (int i = 0; i < rank; i++)
+ dimensions.Add (new ArrayDimension ());
+ this.etype = MD.ElementType.Array;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyDefinition.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyDefinition.cs
index 1187433..bb757d3 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyDefinition.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyDefinition.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,133 +26,164 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
+using System.IO;
+
+using Mono.Collections.Generic;
- using System;
- using System.Collections;
+namespace Mono.Cecil {
- using Mono.Cecil.Metadata;
+ public sealed class AssemblyDefinition : ICustomAttributeProvider, ISecurityDeclarationProvider {
- public class AssemblyDefinition : ICustomAttributeProvider,
- IHasSecurity, IAnnotationProvider, IReflectionStructureVisitable {
+ AssemblyNameDefinition name;
- MetadataToken m_token;
- AssemblyNameDefinition m_asmName;
- ModuleDefinitionCollection m_modules;
- SecurityDeclarationCollection m_secDecls;
- CustomAttributeCollection m_customAttrs;
- MethodDefinition m_ep;
- TargetRuntime m_runtime;
- AssemblyKind m_kind;
+ internal ModuleDefinition main_module;
+ Collection<ModuleDefinition> modules;
+ Collection<CustomAttribute> custom_attributes;
+ Collection<SecurityDeclaration> security_declarations;
- ModuleDefinition m_mainModule;
- StructureReader m_reader;
+ public AssemblyNameDefinition Name {
+ get { return name; }
+ set { name = value; }
+ }
- IAssemblyResolver m_resolver;
- IDictionary m_annotations;
+ public string FullName {
+ get { return name != null ? name.FullName : string.Empty; }
+ }
public MetadataToken MetadataToken {
- get { return m_token; }
- set { m_token = value; }
+ get { return new MetadataToken (TokenType.Assembly, 1); }
+ set { }
}
- public AssemblyNameDefinition Name {
- get { return m_asmName; }
+ public Collection<ModuleDefinition> Modules {
+ get {
+ if (modules != null)
+ return modules;
+
+ if (main_module.HasImage)
+ return modules = main_module.Read (this, (_, reader) => reader.ReadModules ());
+
+ return modules = new Collection<ModuleDefinition> { main_module };
+ }
}
- public ModuleDefinitionCollection Modules {
- get { return m_modules; }
+ public ModuleDefinition MainModule {
+ get { return main_module; }
+ }
+
+ public MethodDefinition EntryPoint {
+ get { return main_module.EntryPoint; }
+ set { main_module.EntryPoint = value; }
}
- public SecurityDeclarationCollection SecurityDeclarations {
+ public bool HasCustomAttributes {
get {
- if (m_secDecls == null)
- m_secDecls = new SecurityDeclarationCollection (this);
+ if (custom_attributes != null)
+ return custom_attributes.Count > 0;
- return m_secDecls;
+ return this.GetHasCustomAttributes (main_module);
}
}
- public CustomAttributeCollection CustomAttributes {
+ public Collection<CustomAttribute> CustomAttributes {
+ get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (main_module)); }
+ }
+
+ public bool HasSecurityDeclarations {
get {
- if (m_customAttrs == null)
- m_customAttrs = new CustomAttributeCollection (this);
+ if (security_declarations != null)
+ return security_declarations.Count > 0;
- return m_customAttrs;
+ return this.GetHasSecurityDeclarations (main_module);
}
}
- public MethodDefinition EntryPoint {
- get { return m_ep; }
- set { m_ep = value; }
+ public Collection<SecurityDeclaration> SecurityDeclarations {
+ get { return security_declarations ?? (security_declarations = this.GetSecurityDeclarations (main_module)); }
}
- public TargetRuntime Runtime {
- get { return m_runtime; }
- set { m_runtime = value; }
+ internal AssemblyDefinition ()
+ {
}
- public AssemblyKind Kind {
- get { return m_kind; }
- set { m_kind = value; }
+#if !READ_ONLY
+ public static AssemblyDefinition CreateAssembly (AssemblyNameDefinition assemblyName, string moduleName, ModuleKind kind)
+ {
+ return CreateAssembly (assemblyName, moduleName, new ModuleParameters { Kind = kind });
}
- public ModuleDefinition MainModule {
- get {
- if (m_mainModule == null)
- foreach (ModuleDefinition module in m_modules)
- if (module.Main)
- m_mainModule = module;
+ public static AssemblyDefinition CreateAssembly (AssemblyNameDefinition assemblyName, string moduleName, ModuleParameters parameters)
+ {
+ if (assemblyName == null)
+ throw new ArgumentNullException ("assemblyName");
+ if (moduleName == null)
+ throw new ArgumentNullException ("moduleName");
+ Mixin.CheckParameters (parameters);
+ if (parameters.Kind == ModuleKind.NetModule)
+ throw new ArgumentException ("kind");
- return m_mainModule;
- }
+ var assembly = ModuleDefinition.CreateModule (moduleName, parameters).Assembly;
+ assembly.Name = assemblyName;
+
+ return assembly;
}
+#endif
- internal StructureReader Reader {
- get { return m_reader; }
+ public static AssemblyDefinition ReadAssembly (string fileName)
+ {
+ return ReadAssembly (ModuleDefinition.ReadModule (fileName));
}
- public IAssemblyResolver Resolver {
- get { return m_resolver; }
- set { m_resolver = value; }
+ public static AssemblyDefinition ReadAssembly (string fileName, ReaderParameters parameters)
+ {
+ return ReadAssembly (ModuleDefinition.ReadModule (fileName, parameters));
}
- IDictionary IAnnotationProvider.Annotations {
- get {
- if (m_annotations == null)
- m_annotations = new Hashtable ();
- return m_annotations;
- }
+ public static AssemblyDefinition ReadAssembly (Stream stream)
+ {
+ return ReadAssembly (ModuleDefinition.ReadModule (stream));
+ }
+
+ public static AssemblyDefinition ReadAssembly (Stream stream, ReaderParameters parameters)
+ {
+ return ReadAssembly (ModuleDefinition.ReadModule (stream, parameters));
}
- internal AssemblyDefinition (AssemblyNameDefinition name)
+ static AssemblyDefinition ReadAssembly (ModuleDefinition module)
{
- if (name == null)
- throw new ArgumentNullException ("name");
+ var assembly = module.Assembly;
+ if (assembly == null)
+ throw new ArgumentException ();
- m_asmName = name;
- m_modules = new ModuleDefinitionCollection (this);
- m_resolver = new DefaultAssemblyResolver ();
+ return assembly;
}
- internal AssemblyDefinition (AssemblyNameDefinition name, StructureReader reader) : this (name)
+#if !READ_ONLY
+ public void Write (string fileName)
{
- m_reader = reader;
+ Write (fileName, new WriterParameters ());
}
- public void Accept (IReflectionStructureVisitor visitor)
+ public void Write (Stream stream)
{
- visitor.VisitAssemblyDefinition (this);
+ Write (stream, new WriterParameters ());
+ }
- m_asmName.Accept (visitor);
- m_modules.Accept (visitor);
+ public void Write (string fileName, WriterParameters parameters)
+ {
+ main_module.Write (fileName, parameters);
+ }
- visitor.TerminateAssemblyDefinition (this);
+ public void Write (Stream stream, WriterParameters parameters)
+ {
+ main_module.Write (stream, parameters);
}
+#endif
public override string ToString ()
{
- return m_asmName.FullName;
+ return this.FullName;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFactory.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFactory.cs
deleted file mode 100644
index fb0c689..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFactory.cs
+++ /dev/null
@@ -1,176 +0,0 @@
-//
-// AssemblyFactory.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.IO;
- using SR = System.Reflection;
-
- using Mono.Cecil.Binary;
-
- public sealed class AssemblyFactory {
-
- AssemblyFactory ()
- {
- }
-
- static AssemblyDefinition GetAssembly (ImageReader irv, bool manifestOnly)
- {
- StructureReader srv = new StructureReader (irv, manifestOnly);
- AssemblyDefinition asm = new AssemblyDefinition (
- new AssemblyNameDefinition (), srv);
-
- asm.Accept (srv);
- return asm;
- }
-
- static AssemblyDefinition GetAssembly (ImageReader reader)
- {
- return GetAssembly (reader, false);
- }
-
- static AssemblyDefinition GetAssemblyManifest (ImageReader reader)
- {
- return GetAssembly (reader, true);
- }
-
- public static AssemblyDefinition GetAssembly (string file)
- {
- return GetAssembly (ImageReader.Read (file));
- }
-
- public static AssemblyDefinition GetAssembly (byte [] assembly)
- {
- return GetAssembly (ImageReader.Read (assembly));
- }
-
- public static AssemblyDefinition GetAssembly (Stream stream)
- {
- return GetAssembly (ImageReader.Read (stream));
- }
-
- public static AssemblyDefinition GetAssemblyManifest (string file)
- {
- return GetAssemblyManifest (ImageReader.Read (file));
- }
-
- public static AssemblyDefinition GetAssemblyManifest (byte [] assembly)
- {
- return GetAssemblyManifest (ImageReader.Read (assembly));
- }
-
- public static AssemblyDefinition GetAssemblyManifest (Stream stream)
- {
- return GetAssemblyManifest (ImageReader.Read (stream));
- }
-
- static TargetRuntime CurrentRuntime ()
- {
- Version corlib = typeof (object).Assembly.GetName ().Version;
- if (corlib.Major == 1)
- return corlib.Minor == 0 ? TargetRuntime.NET_1_0 : TargetRuntime.NET_1_1;
- else // if (corlib.Major == 2)
- return TargetRuntime.NET_2_0;
- }
-
- public static AssemblyDefinition DefineAssembly (string name, AssemblyKind kind)
- {
- return DefineAssembly (name, name, CurrentRuntime (), kind);
- }
-
- public static AssemblyDefinition DefineAssembly (string name, TargetRuntime rt, AssemblyKind kind)
- {
- return DefineAssembly (name, name, rt, kind);
- }
-
- public static AssemblyDefinition DefineAssembly (string assemblyName, string moduleName, TargetRuntime rt, AssemblyKind kind)
- {
- AssemblyNameDefinition asmName = new AssemblyNameDefinition ();
- asmName.Name = assemblyName;
- AssemblyDefinition asm = new AssemblyDefinition (asmName);
- asm.Runtime = rt;
- asm.Kind = kind;
- ModuleDefinition main = new ModuleDefinition (moduleName, asm, true);
- asm.Modules.Add (main);
- return asm;
- }
-
- static void WriteAssembly (AssemblyDefinition asm, BinaryWriter bw)
- {
- asm.Accept (new StructureWriter (asm, bw));
- }
-
- public static void SaveAssembly (AssemblyDefinition asm, string file)
- {
- using (FileStream fs = new FileStream (
- file, FileMode.Create, FileAccess.Write, FileShare.None)) {
-
- SaveAssembly (asm, fs);
- asm.MainModule.Image.SetFileInfo (new FileInfo (file));
- }
- }
-
- public static void SaveAssembly (AssemblyDefinition asm, out byte [] assembly)
- {
- MemoryBinaryWriter bw = new MemoryBinaryWriter ();
- SaveAssembly (asm, bw.BaseStream);
- assembly = bw.ToArray ();
- }
-
- public static void SaveAssembly (AssemblyDefinition asm, Stream stream)
- {
- BinaryWriter bw = new BinaryWriter (stream);
- try {
- WriteAssembly (asm, bw);
- } finally {
- bw.Close ();
- }
-
- foreach (ModuleDefinition module in asm.Modules)
- if (module.Controller.Writer.SaveSymbols)
- module.Controller.Writer.WriteSymbols (module);
- }
-
-#if !CF_1_0 && !CF_2_0
- public static SR.Assembly CreateReflectionAssembly (AssemblyDefinition asm, AppDomain domain)
- {
- using (MemoryBinaryWriter writer = new MemoryBinaryWriter ()) {
-
- WriteAssembly (asm, writer);
- return domain.Load (writer.ToArray ());
- }
- }
-
- public static SR.Assembly CreateReflectionAssembly (AssemblyDefinition asm)
- {
- return CreateReflectionAssembly (asm, AppDomain.CurrentDomain);
- }
-#endif
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFlags.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFlags.cs
index 9231fc8..6d04c59 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFlags.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyFlags.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,16 +26,16 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
- using System;
+namespace Mono.Cecil {
[Flags]
- public enum AssemblyFlags : uint {
+ public enum AssemblyAttributes : uint {
PublicKey = 0x0001,
SideBySideCompatible = 0x0000,
Retargetable = 0x0100,
- EnableJITcompileTracking = 0x8000,
- DisableJITcompileOptimizer = 0x4000
+ DisableJITCompileOptimizer = 0x4000,
+ EnableJITCompileTracking = 0x8000,
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyHashAlgorithm.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyHashAlgorithm.cs
index e32c2ec..0e7bf83 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyHashAlgorithm.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyHashAlgorithm.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -34,4 +34,3 @@ namespace Mono.Cecil {
SHA1 = 0x8004
}
}
-
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyInfo.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyInfo.cs
index 6092924..b701981 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyInfo.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyInfo.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,30 +26,24 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-#if !EMBEDDED
-
[assembly: AssemblyTitle ("Mono.Cecil")]
-[assembly: AssemblyDescription ("Library for reading and writing CIL images")]
-[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyProduct ("Mono.Cecil")]
-[assembly: AssemblyCopyright ("(C) 2005 - 2007, Jb Evain")]
-[assembly: AssemblyCulture ("")]
+[assembly: AssemblyCopyright ("Copyright © 2008 - 2010 Jb Evain")]
-[assembly: CLSCompliant (false)]
[assembly: ComVisible (false)]
-[assembly: AssemblyVersion ("0.6.8.8607")]
-
-#if KEYFILE
-[assembly: AssemblyKeyFile("../../mono.snk")]
-#endif
+[assembly: Guid ("fd225bb4-fa53-44b2-a6db-85f5e48dcb54")]
+[assembly: AssemblyVersion ("0.9.4.0")]
+#if !CF
+[assembly: AssemblyFileVersion ("0.9.4.0")]
#endif
-
-
+[assembly: InternalsVisibleTo ("Mono.Cecil.Pdb, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
+[assembly: InternalsVisibleTo ("Mono.Cecil.Mdb, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
+[assembly: InternalsVisibleTo ("Mono.Cecil.Rocks, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
+[assembly: InternalsVisibleTo ("Mono.Cecil.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyLinkedResource.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyLinkedResource.cs
index 0ff9ff1..68e44f8 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyLinkedResource.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyLinkedResource.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,26 +26,32 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
namespace Mono.Cecil {
public sealed class AssemblyLinkedResource : Resource {
- private AssemblyNameReference m_asmRef;
+ AssemblyNameReference reference;
public AssemblyNameReference Assembly {
- get { return m_asmRef; }
- set { m_asmRef = value; }
+ get { return reference; }
+ set { reference = value; }
+ }
+
+ public override ResourceType ResourceType {
+ get { return ResourceType.AssemblyLinked; }
}
- public AssemblyLinkedResource (string name, ManifestResourceAttributes flags,
- AssemblyNameReference asmRef) : base (name, flags)
+ public AssemblyLinkedResource (string name, ManifestResourceAttributes flags)
+ : base (name, flags)
{
- m_asmRef = asmRef;
}
- public override void Accept (IReflectionStructureVisitor visitor)
+ public AssemblyLinkedResource (string name, ManifestResourceAttributes flags, AssemblyNameReference reference)
+ : base (name, flags)
{
- visitor.VisitAssemblyLinkedResource (this);
+ this.reference = reference;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameDefinition.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameDefinition.cs
index bf54fb5..4756cb8 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameDefinition.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameDefinition.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,27 +26,25 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
- using System;
+namespace Mono.Cecil {
public sealed class AssemblyNameDefinition : AssemblyNameReference {
public override byte [] Hash {
- get { return new byte [0]; }
- }
-
- public AssemblyNameDefinition () : base()
- {
+ get { return Empty<byte>.Array; }
}
- public AssemblyNameDefinition (string name, string culture, Version version) : base (name, culture, version)
+ internal AssemblyNameDefinition ()
{
+ this.token = new MetadataToken (TokenType.Assembly, 1);
}
- public override void Accept (IReflectionStructureVisitor visitor)
+ public AssemblyNameDefinition (string name, Version version)
+ : base (name, version)
{
- visitor.VisitAssemblyNameDefinition (this);
+ this.token = new MetadataToken (TokenType.Assembly, 1);
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs
index bb1f55c..2798082 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,155 +26,158 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
+using System.Globalization;
+using System.Security.Cryptography;
+using System.Text;
- using System;
- using System.Collections;
- using System.Globalization;
- using System.Security.Cryptography;
- using System.Text;
+namespace Mono.Cecil {
- using Mono.Cecil.Metadata;
+ public class AssemblyNameReference : IMetadataScope {
- public class AssemblyNameReference : IMetadataScope, IAnnotationProvider, IReflectionStructureVisitable {
+ string name;
+ string culture;
+ Version version;
+ uint attributes;
+ byte [] public_key;
+ byte [] public_key_token;
+ AssemblyHashAlgorithm hash_algorithm;
+ byte [] hash;
- string m_name;
- string m_culture;
- Version m_version;
- AssemblyFlags m_flags;
- byte [] m_publicKey;
- byte [] m_publicKeyToken;
- AssemblyHashAlgorithm m_hashAlgo;
- byte [] m_hash;
- MetadataToken m_token;
- IDictionary m_annotations;
+ internal MetadataToken token;
- bool m_fullNameDiscarded = true;
- string m_fullName;
+ string full_name;
public string Name {
- get { return m_name; }
+ get { return name; }
set {
- m_name = value;
- m_fullNameDiscarded = true;
+ name = value;
+ full_name = null;
}
}
public string Culture {
- get { return m_culture; }
+ get { return culture; }
set {
- m_culture = value;
- m_fullNameDiscarded = true;
+ culture = value;
+ full_name = null;
}
}
public Version Version {
- get { return m_version; }
+ get { return version; }
set {
- m_version = value;
- m_fullNameDiscarded = true;
+ version = value;
+ full_name = null;
}
}
- public AssemblyFlags Flags {
- get { return m_flags; }
- set { m_flags = value; }
+ public AssemblyAttributes Attributes {
+ get { return (AssemblyAttributes) attributes; }
+ set { attributes = (uint) value; }
}
public bool HasPublicKey {
- get { return (m_flags & AssemblyFlags.PublicKey) != 0; }
- set {
- if (value)
- m_flags |= AssemblyFlags.PublicKey;
- else
- m_flags &= ~AssemblyFlags.PublicKey;
- }
+ get { return attributes.GetAttributes ((uint) AssemblyAttributes.PublicKey); }
+ set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.PublicKey, value); }
}
public bool IsSideBySideCompatible {
- get { return (m_flags & AssemblyFlags.SideBySideCompatible) != 0; }
- set {
- if (value)
- m_flags |= AssemblyFlags.SideBySideCompatible;
- else
- m_flags &= ~AssemblyFlags.SideBySideCompatible;
- }
+ get { return attributes.GetAttributes ((uint) AssemblyAttributes.SideBySideCompatible); }
+ set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.SideBySideCompatible, value); }
}
public bool IsRetargetable {
- get { return (m_flags & AssemblyFlags.Retargetable) != 0; }
- set {
- if (value)
- m_flags |= AssemblyFlags.Retargetable;
- else
- m_flags &= ~AssemblyFlags.Retargetable;
- }
+ get { return attributes.GetAttributes ((uint) AssemblyAttributes.Retargetable); }
+ set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.Retargetable, value); }
}
public byte [] PublicKey {
- get { return m_publicKey; }
+ get { return public_key; }
set {
- m_publicKey = value;
- m_publicKeyToken = null;
- m_fullNameDiscarded = true;
+ public_key = value;
+ HasPublicKey = !public_key.IsNullOrEmpty ();
+ public_key_token = Empty<byte>.Array;
+ full_name = null;
}
}
public byte [] PublicKeyToken {
get {
-#if !CF_1_0
- if ((m_publicKeyToken == null || m_publicKeyToken.Length == 0) && (m_publicKey != null && m_publicKey.Length > 0)) {
- HashAlgorithm ha;
- switch (m_hashAlgo) {
- case AssemblyHashAlgorithm.Reserved:
- ha = MD5.Create (); break;
- default:
- // None default to SHA1
- ha = SHA1.Create (); break;
- }
- byte [] hash = ha.ComputeHash (m_publicKey);
+ if (public_key_token.IsNullOrEmpty () && !public_key.IsNullOrEmpty ()) {
+ var hash = HashPublicKey ();
// we need the last 8 bytes in reverse order
- m_publicKeyToken = new byte [8];
- Array.Copy (hash, (hash.Length - 8), m_publicKeyToken, 0, 8);
- Array.Reverse (m_publicKeyToken, 0, 8);
+ public_key_token = new byte [8];
+ Array.Copy (hash, (hash.Length - 8), public_key_token, 0, 8);
+ Array.Reverse (public_key_token, 0, 8);
}
-#endif
- return m_publicKeyToken;
+ return public_key_token;
}
set {
- m_publicKeyToken = value;
- m_fullNameDiscarded = true;
+ public_key_token = value;
+ full_name = null;
+ }
+ }
+
+ byte [] HashPublicKey ()
+ {
+ HashAlgorithm algorithm;
+
+ switch (hash_algorithm) {
+ case AssemblyHashAlgorithm.Reserved:
+#if SILVERLIGHT
+ throw new NotSupportedException ();
+#else
+ algorithm = MD5.Create ();
+ break;
+#endif
+ default:
+ // None default to SHA1
+#if SILVERLIGHT
+ algorithm = new SHA1Managed ();
+ break;
+#else
+ algorithm = SHA1.Create ();
+ break;
+#endif
}
+
+ using (algorithm)
+ return algorithm.ComputeHash (public_key);
+ }
+
+ public virtual MetadataScopeType MetadataScopeType {
+ get { return MetadataScopeType.AssemblyNameReference; }
}
public string FullName {
get {
- if (m_fullName != null && !m_fullNameDiscarded)
- return m_fullName;
-
- StringBuilder sb = new StringBuilder ();
- string sep = ", ";
- sb.Append (m_name);
- if (m_version != null) {
- sb.Append (sep);
- sb.Append ("Version=");
- sb.Append (m_version.ToString ());
+ if (full_name != null)
+ return full_name;
+
+ const string sep = ", ";
+
+ var builder = new StringBuilder ();
+ builder.Append (name);
+ if (version != null) {
+ builder.Append (sep);
+ builder.Append ("Version=");
+ builder.Append (version.ToString ());
}
- sb.Append (sep);
- sb.Append ("Culture=");
- sb.Append (m_culture == null || m_culture == string.Empty ? "neutral" : m_culture);
- sb.Append (sep);
- sb.Append ("PublicKeyToken=");
- if (this.PublicKeyToken != null && m_publicKeyToken.Length > 0) {
- for (int i = 0 ; i < m_publicKeyToken.Length ; i++) {
- sb.Append (m_publicKeyToken [i].ToString ("x2"));
+ builder.Append (sep);
+ builder.Append ("Culture=");
+ builder.Append (string.IsNullOrEmpty (culture) ? "neutral" : culture);
+ builder.Append (sep);
+ builder.Append ("PublicKeyToken=");
+
+ if (this.PublicKeyToken != null && public_key_token.Length > 0) {
+ for (int i = 0 ; i < public_key_token.Length ; i++) {
+ builder.Append (public_key_token [i].ToString ("x2"));
}
- } else {
- sb.Append ("null");
- }
- m_fullName = sb.ToString ();
- m_fullNameDiscarded = false;
- return m_fullName;
+ } else
+ builder.Append ("null");
+
+ return full_name = builder.ToString ();
}
}
@@ -185,17 +188,17 @@ namespace Mono.Cecil {
if (fullName.Length == 0)
throw new ArgumentException ("Name can not be empty");
- AssemblyNameReference name = new AssemblyNameReference ();
- string [] tokens = fullName.Split (',');
+ var name = new AssemblyNameReference ();
+ var tokens = fullName.Split (',');
for (int i = 0; i < tokens.Length; i++) {
- string token = tokens [i].Trim ();
+ var token = tokens [i].Trim ();
if (i == 0) {
name.Name = token;
continue;
}
- string [] parts = token.Split ('=');
+ var parts = token.Split ('=');
if (parts.Length != 2)
throw new ArgumentException ("Malformed name");
@@ -207,13 +210,13 @@ namespace Mono.Cecil {
name.Culture = parts [1];
break;
case "PublicKeyToken":
- string pkToken = parts [1];
- if (pkToken == "null")
+ string pk_token = parts [1];
+ if (pk_token == "null")
break;
- name.PublicKeyToken = new byte [pkToken.Length / 2];
+ name.PublicKeyToken = new byte [pk_token.Length / 2];
for (int j = 0; j < name.PublicKeyToken.Length; j++) {
- name.PublicKeyToken [j] = Byte.Parse (pkToken.Substring (j * 2, 2), NumberStyles.HexNumber);
+ name.PublicKeyToken [j] = Byte.Parse (pk_token.Substring (j * 2, 2), NumberStyles.HexNumber);
}
break;
}
@@ -222,54 +225,39 @@ namespace Mono.Cecil {
return name;
}
- public AssemblyHashAlgorithm HashAlgorithm
- {
- get { return m_hashAlgo; }
- set { m_hashAlgo = value; }
+ public AssemblyHashAlgorithm HashAlgorithm {
+ get { return hash_algorithm; }
+ set { hash_algorithm = value; }
}
public virtual byte [] Hash {
- get { return m_hash; }
- set { m_hash = value; }
+ get { return hash; }
+ set { hash = value; }
}
public MetadataToken MetadataToken {
- get { return m_token; }
- set { m_token = value; }
+ get { return token; }
+ set { token = value; }
}
- IDictionary IAnnotationProvider.Annotations {
- get {
- if (m_annotations == null)
- m_annotations = new Hashtable ();
- return m_annotations;
- }
- }
-
- public AssemblyNameReference () : this (string.Empty, string.Empty, new Version (0, 0, 0, 0))
+ internal AssemblyNameReference ()
{
}
- public AssemblyNameReference (string name, string culture, Version version)
+ public AssemblyNameReference (string name, Version version)
{
if (name == null)
throw new ArgumentNullException ("name");
- if (culture == null)
- throw new ArgumentNullException ("culture");
- m_name = name;
- m_culture = culture;
- m_version = version;
- m_hashAlgo = AssemblyHashAlgorithm.None;
+
+ this.name = name;
+ this.version = version;
+ this.hash_algorithm = AssemblyHashAlgorithm.None;
+ this.token = new MetadataToken (TokenType.AssemblyRef);
}
public override string ToString ()
{
return this.FullName;
}
-
- public virtual void Accept (IReflectionStructureVisitor visitor)
- {
- visitor.VisitAssemblyNameReference (this);
- }
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReferenceCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReferenceCollection.cs
deleted file mode 100644
index be2b3b9..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyNameReferenceCollection.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// AssemblyNameReferenceCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:52 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class AssemblyNameReferenceCollection : CollectionBase, IReflectionStructureVisitable {
-
- ModuleDefinition m_container;
-
- public AssemblyNameReference this [int index] {
- get { return List [index] as AssemblyNameReference; }
- set { List [index] = value; }
- }
-
- public ModuleDefinition Container {
- get { return m_container; }
- }
-
- public AssemblyNameReferenceCollection (ModuleDefinition container)
- {
- m_container = container;
- }
-
- public void Add (AssemblyNameReference value)
- {
- List.Add (value);
- }
-
- public bool Contains (AssemblyNameReference value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (AssemblyNameReference value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, AssemblyNameReference value)
- {
- List.Insert (index, value);
- }
-
- public void Remove (AssemblyNameReference value)
- {
- List.Remove (value);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is AssemblyNameReference))
- throw new ArgumentException ("Must be of type " + typeof (AssemblyNameReference).FullName);
- }
-
- public void Accept (IReflectionStructureVisitor visitor)
- {
- visitor.VisitAssemblyNameReferenceCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyReader.cs
new file mode 100644
index 0000000..edbc957
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyReader.cs
@@ -0,0 +1,3007 @@
+//
+// AssemblyReader.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+using Mono.Collections.Generic;
+using Mono.Cecil.Cil;
+using Mono.Cecil.Metadata;
+using Mono.Cecil.PE;
+
+using RVA = System.UInt32;
+
+namespace Mono.Cecil {
+
+ abstract class ModuleReader {
+
+ readonly protected Image image;
+ readonly protected ModuleDefinition module;
+
+ protected ModuleReader (Image image, ReadingMode mode)
+ {
+ this.image = image;
+ this.module = new ModuleDefinition (image);
+ this.module.ReadingMode = mode;
+ }
+
+ protected abstract void ReadModule ();
+
+ protected void ReadModuleManifest (MetadataReader reader)
+ {
+ reader.Populate (module);
+
+ ReadAssembly (reader);
+ }
+
+ void ReadAssembly (MetadataReader reader)
+ {
+ var name = reader.ReadAssemblyNameDefinition ();
+ if (name == null) {
+ module.kind = ModuleKind.NetModule;
+ return;
+ }
+
+ var assembly = new AssemblyDefinition ();
+ assembly.Name = name;
+
+ module.assembly = assembly;
+ assembly.main_module = module;
+ }
+
+ public static ModuleDefinition CreateModuleFrom (Image image, ReaderParameters parameters)
+ {
+ var module = ReadModule (image, parameters);
+
+ ReadSymbols (module, parameters);
+
+ if (parameters.AssemblyResolver != null)
+ module.AssemblyResolver = parameters.AssemblyResolver;
+
+ return module;
+ }
+
+ static void ReadSymbols (ModuleDefinition module, ReaderParameters parameters)
+ {
+ var symbol_reader_provider = parameters.SymbolReaderProvider;
+
+ if (symbol_reader_provider == null && parameters.ReadSymbols)
+ symbol_reader_provider = SymbolProvider.GetPlatformReaderProvider ();
+
+ if (symbol_reader_provider != null) {
+ module.SymbolReaderProvider = symbol_reader_provider;
+
+ var reader = parameters.SymbolStream != null
+ ? symbol_reader_provider.GetSymbolReader (module, parameters.SymbolStream)
+ : symbol_reader_provider.GetSymbolReader (module, module.FullyQualifiedName);
+
+ module.ReadSymbols (reader);
+ }
+ }
+
+ static ModuleDefinition ReadModule (Image image, ReaderParameters parameters)
+ {
+ var reader = CreateModuleReader (image, parameters.ReadingMode);
+ reader.ReadModule ();
+ return reader.module;
+ }
+
+ static ModuleReader CreateModuleReader (Image image, ReadingMode mode)
+ {
+ switch (mode) {
+ case ReadingMode.Immediate:
+ return new ImmediateModuleReader (image);
+ case ReadingMode.Deferred:
+ return new DeferredModuleReader (image);
+ default:
+ throw new ArgumentException ();
+ }
+ }
+ }
+
+ sealed class ImmediateModuleReader : ModuleReader {
+
+ public ImmediateModuleReader (Image image)
+ : base (image, ReadingMode.Immediate)
+ {
+ }
+
+ protected override void ReadModule ()
+ {
+ this.module.Read (this.module, (module, reader) => {
+ ReadModuleManifest (reader);
+ ReadModule (module);
+ return module;
+ });
+ }
+
+ public static void ReadModule (ModuleDefinition module)
+ {
+ if (module.HasAssemblyReferences)
+ Read (module.AssemblyReferences);
+ if (module.HasResources)
+ Read (module.Resources);
+ if (module.HasModuleReferences)
+ Read (module.ModuleReferences);
+ if (module.HasTypes)
+ ReadTypes (module.Types);
+ if (module.HasExportedTypes)
+ Read (module.ExportedTypes);
+ if (module.HasCustomAttributes)
+ Read (module.CustomAttributes);
+
+ var assembly = module.Assembly;
+ if (assembly == null)
+ return;
+
+ if (assembly.HasCustomAttributes)
+ Read (assembly.CustomAttributes);
+ if (assembly.HasSecurityDeclarations)
+ Read (assembly.SecurityDeclarations);
+ }
+
+ static void ReadTypes (Collection<TypeDefinition> types)
+ {
+ for (int i = 0; i < types.Count; i++)
+ ReadType (types [i]);
+ }
+
+ static void ReadType (TypeDefinition type)
+ {
+ ReadGenericParameters (type);
+
+ if (type.HasInterfaces)
+ Read (type.Interfaces);
+
+ if (type.HasNestedTypes)
+ ReadTypes (type.NestedTypes);
+
+ if (type.HasLayoutInfo)
+ Read (type.ClassSize);
+
+ if (type.HasFields)
+ ReadFields (type);
+
+ if (type.HasMethods)
+ ReadMethods (type);
+
+ if (type.HasProperties)
+ ReadProperties (type);
+
+ if (type.HasEvents)
+ ReadEvents (type);
+
+ ReadSecurityDeclarations (type);
+ ReadCustomAttributes (type);
+ }
+
+ static void ReadGenericParameters (IGenericParameterProvider provider)
+ {
+ if (!provider.HasGenericParameters)
+ return;
+
+ var parameters = provider.GenericParameters;
+
+ for (int i = 0; i < parameters.Count; i++) {
+ var parameter = parameters [i];
+
+ if (parameter.HasConstraints)
+ Read (parameter.Constraints);
+
+ if (parameter.HasCustomAttributes)
+ Read (parameter.CustomAttributes);
+ }
+ }
+
+ static void ReadSecurityDeclarations (ISecurityDeclarationProvider provider)
+ {
+ if (provider.HasSecurityDeclarations)
+ Read (provider.SecurityDeclarations);
+ }
+
+ static void ReadCustomAttributes (ICustomAttributeProvider provider)
+ {
+ if (provider.HasCustomAttributes)
+ Read (provider.CustomAttributes);
+ }
+
+ static void ReadFields (TypeDefinition type)
+ {
+ var fields = type.Fields;
+
+ for (int i = 0; i < fields.Count; i++) {
+ var field = fields [i];
+
+ if (field.HasConstant)
+ Read (field.Constant);
+
+ if (field.HasLayoutInfo)
+ Read (field.Offset);
+
+ if (field.RVA > 0)
+ Read (field.InitialValue);
+
+ if (field.HasMarshalInfo)
+ Read (field.MarshalInfo);
+
+ ReadCustomAttributes (field);
+ }
+ }
+
+ static void ReadMethods (TypeDefinition type)
+ {
+ var methods = type.Methods;
+
+ for (int i = 0; i < methods.Count; i++) {
+ var method = methods [i];
+
+ ReadGenericParameters (method);
+
+ if (method.HasParameters)
+ ReadParameters (method);
+
+ if (method.HasOverrides)
+ Read (method.Overrides);
+
+ if (method.IsPInvokeImpl)
+ Read (method.PInvokeInfo);
+
+ ReadSecurityDeclarations (method);
+ ReadCustomAttributes (method);
+
+ var return_type = method.MethodReturnType;
+ if (return_type.HasConstant)
+ Read (return_type.Constant);
+
+ if (return_type.HasMarshalInfo)
+ Read (return_type.MarshalInfo);
+
+ ReadCustomAttributes (return_type);
+ }
+ }
+
+ static void ReadParameters (MethodDefinition method)
+ {
+ var parameters = method.Parameters;
+
+ for (int i = 0; i < parameters.Count; i++) {
+ var parameter = parameters [i];
+
+ if (parameter.HasConstant)
+ Read (parameter.Constant);
+
+ if (parameter.HasMarshalInfo)
+ Read (parameter.MarshalInfo);
+
+ ReadCustomAttributes (parameter);
+ }
+ }
+
+ static void ReadProperties (TypeDefinition type)
+ {
+ var properties = type.Properties;
+
+ for (int i = 0; i < properties.Count; i++) {
+ var property = properties [i];
+
+ Read (property.GetMethod);
+
+ if (property.HasConstant)
+ Read (property.Constant);
+
+ ReadCustomAttributes (property);
+ }
+ }
+
+ static void ReadEvents (TypeDefinition type)
+ {
+ var events = type.Events;
+
+ for (int i = 0; i < events.Count; i++) {
+ var @event = events [i];
+
+ Read (@event.AddMethod);
+
+ ReadCustomAttributes (@event);
+ }
+ }
+
+ static void Read (object collection)
+ {
+ }
+ }
+
+ sealed class DeferredModuleReader : ModuleReader {
+
+ public DeferredModuleReader (Image image)
+ : base (image, ReadingMode.Deferred)
+ {
+ }
+
+ protected override void ReadModule ()
+ {
+ this.module.Read (this.module, (module, reader) => {
+ ReadModuleManifest (reader);
+ return module;
+ });
+ }
+ }
+
+ sealed class MetadataReader : ByteBuffer {
+
+ readonly internal Image image;
+ readonly internal ModuleDefinition module;
+ readonly internal MetadataSystem metadata;
+
+ internal IGenericContext context;
+ internal CodeReader code;
+
+ uint Position {
+ get { return (uint) base.position; }
+ set { base.position = (int) value; }
+ }
+
+ public MetadataReader (ModuleDefinition module)
+ : base (module.Image.MetadataSection.Data)
+ {
+ this.image = module.Image;
+ this.module = module;
+ this.metadata = module.MetadataSystem;
+ this.code = CodeReader.CreateCodeReader (this);
+ }
+
+ int GetCodedIndexSize (CodedIndex index)
+ {
+ return image.GetCodedIndexSize (index);
+ }
+
+ uint ReadByIndexSize (int size)
+ {
+ if (size == 4)
+ return ReadUInt32 ();
+ else
+ return ReadUInt16 ();
+ }
+
+ byte [] ReadBlob ()
+ {
+ var blob_heap = image.BlobHeap;
+ if (blob_heap == null) {
+ position += 2;
+ return Empty<byte>.Array;
+ }
+
+ return blob_heap.Read (ReadBlobIndex ());
+ }
+
+ byte [] ReadBlob (uint signature)
+ {
+ var blob_heap = image.BlobHeap;
+ if (blob_heap == null)
+ return Empty<byte>.Array;
+
+ return blob_heap.Read (signature);
+ }
+
+ uint ReadBlobIndex ()
+ {
+ var blob_heap = image.BlobHeap;
+ return ReadByIndexSize (blob_heap != null ? blob_heap.IndexSize : 2);
+ }
+
+ string ReadString ()
+ {
+ return image.StringHeap.Read (ReadByIndexSize (image.StringHeap.IndexSize));
+ }
+
+ uint ReadStringIndex ()
+ {
+ return ReadByIndexSize (image.StringHeap.IndexSize);
+ }
+
+ uint ReadTableIndex (Table table)
+ {
+ return ReadByIndexSize (image.GetTableIndexSize (table));
+ }
+
+ MetadataToken ReadMetadataToken (CodedIndex index)
+ {
+ return index.GetMetadataToken (ReadByIndexSize (GetCodedIndexSize (index)));
+ }
+
+ int MoveTo (Table table)
+ {
+ var info = image.TableHeap [table];
+ if (info.Length != 0)
+ Position = info.Offset;
+
+ return (int) info.Length;
+ }
+
+ bool MoveTo (Table table, uint row)
+ {
+ var info = image.TableHeap [table];
+ var length = info.Length;
+ if (length == 0 || row > length)
+ return false;
+
+ Position = info.Offset + (info.RowSize * (row - 1));
+ return true;
+ }
+
+ public AssemblyNameDefinition ReadAssemblyNameDefinition ()
+ {
+ if (MoveTo (Table.Assembly) == 0)
+ return null;
+
+ var name = new AssemblyNameDefinition ();
+
+ name.HashAlgorithm = (AssemblyHashAlgorithm) ReadUInt32 ();
+
+ PopulateVersionAndFlags (name);
+
+ name.PublicKey = ReadBlob ();
+
+ PopulateNameAndCulture (name);
+
+ return name;
+ }
+
+ public ModuleDefinition Populate (ModuleDefinition module)
+ {
+ if (MoveTo (Table.Module) == 0)
+ return module;
+
+ Advance (2); // Generation
+
+ module.Name = ReadString ();
+ module.Mvid = image.GuidHeap.Read (ReadByIndexSize (image.GuidHeap.IndexSize));
+
+ return module;
+ }
+
+ public Collection<AssemblyNameReference> ReadAssemblyReferences ()
+ {
+ int length = MoveTo (Table.AssemblyRef);
+ var references = new Collection<AssemblyNameReference> (length);
+
+ for (uint i = 1; i <= length; i++) {
+ var reference = new AssemblyNameReference ();
+ reference.token = new MetadataToken (TokenType.AssemblyRef, i);
+
+ PopulateVersionAndFlags (reference);
+
+ reference.PublicKeyToken = ReadBlob ();
+
+ PopulateNameAndCulture (reference);
+
+ reference.Hash = ReadBlob ();
+
+ references.Add (reference);
+ }
+
+ return references;
+ }
+
+ public MethodDefinition ReadEntryPoint ()
+ {
+ if (module.Kind != ModuleKind.Console && module.Kind != ModuleKind.Windows)
+ return null;
+
+ var token = new MetadataToken (module.Image.EntryPointToken);
+
+ return GetMethodDefinition (token.RID);
+ }
+
+ public Collection<ModuleDefinition> ReadModules ()
+ {
+ var modules = new Collection<ModuleDefinition> (1);
+ modules.Add (this.module);
+
+ int length = MoveTo (Table.File);
+ for (uint i = 1; i <= length; i++) {
+ var attributes = (FileAttributes) ReadUInt32 ();
+ var name = ReadString ();
+ ReadBlobIndex ();
+
+ if (attributes != FileAttributes.ContainsMetaData)
+ continue;
+
+ var parameters = new ReaderParameters {
+ ReadingMode = module.ReadingMode,
+ SymbolReaderProvider = module.SymbolReaderProvider,
+ };
+
+ modules.Add (ModuleDefinition.ReadModule (
+ GetModuleFileName (name), parameters));
+ }
+
+ return modules;
+ }
+
+ string GetModuleFileName (string name)
+ {
+ if (module.FullyQualifiedName == null)
+ throw new NotSupportedException ();
+
+ var path = Path.GetDirectoryName (module.FullyQualifiedName);
+ return Path.Combine (path, name);
+ }
+
+ public Collection<ModuleReference> ReadModuleReferences ()
+ {
+ int length = MoveTo (Table.ModuleRef);
+ var references = new Collection<ModuleReference> (length);
+
+ for (uint i = 1; i <= length; i++) {
+ var reference = new ModuleReference (ReadString ());
+ reference.token = new MetadataToken (TokenType.ModuleRef, i);
+
+ references.Add (reference);
+ }
+
+ return references;
+ }
+
+ public bool HasFileResource ()
+ {
+ int length = MoveTo (Table.File);
+ if (length == 0)
+ return false;
+
+ for (uint i = 1; i <= length; i++)
+ if (ReadFileRecord (i).Col1 == FileAttributes.ContainsNoMetaData)
+ return true;
+
+ return false;
+ }
+
+ public Collection<Resource> ReadResources ()
+ {
+ int length = MoveTo (Table.ManifestResource);
+ var resources = new Collection<Resource> (length);
+
+ for (int i = 1; i <= length; i++) {
+ var offset = ReadUInt32 ();
+ var flags = (ManifestResourceAttributes) ReadUInt32 ();
+ var name = ReadString ();
+ var implementation = ReadMetadataToken (CodedIndex.Implementation);
+
+ Resource resource;
+
+ if (implementation.RID == 0) {
+ resource = new EmbeddedResource (name, flags, offset, this);
+ } else if (implementation.TokenType == TokenType.AssemblyRef) {
+ resource = new AssemblyLinkedResource (name, flags) {
+ Assembly = (AssemblyNameReference) GetTypeReferenceScope (implementation),
+ };
+ } else if (implementation.TokenType == TokenType.File) {
+ var file_record = ReadFileRecord (implementation.RID);
+
+ resource = new LinkedResource (name, flags) {
+ File = file_record.Col2,
+ hash = ReadBlob (file_record.Col3)
+ };
+ } else
+ throw new NotSupportedException ();
+
+ resources.Add (resource);
+ }
+
+ return resources;
+ }
+
+ Row<FileAttributes, string, uint> ReadFileRecord (uint rid)
+ {
+ var position = this.position;
+
+ if (!MoveTo (Table.File, rid))
+ throw new ArgumentException ();
+
+ var record = new Row<FileAttributes, string, uint> (
+ (FileAttributes) ReadUInt32 (),
+ ReadString (),
+ ReadBlobIndex ());
+
+ this.position = position;
+
+ return record;
+ }
+
+ public MemoryStream GetManagedResourceStream (uint offset)
+ {
+ var rva = image.Resources.VirtualAddress;
+ var section = image.GetSectionAtVirtualAddress (rva);
+ var position = (rva - section.VirtualAddress) + offset;
+ var buffer = section.Data;
+
+ var length = buffer [position]
+ | (buffer [position + 1] << 8)
+ | (buffer [position + 2] << 16)
+ | (buffer [position + 3] << 24);
+
+ return new MemoryStream (buffer, (int) position + 4, length);
+ }
+
+ void PopulateVersionAndFlags (AssemblyNameReference name)
+ {
+ name.Version = new Version (
+ ReadUInt16 (),
+ ReadUInt16 (),
+ ReadUInt16 (),
+ ReadUInt16 ());
+
+ name.Attributes = (AssemblyAttributes) ReadUInt32 ();
+ }
+
+ void PopulateNameAndCulture (AssemblyNameReference name)
+ {
+ name.Name = ReadString ();
+ name.Culture = ReadString ();
+ }
+
+ public TypeDefinitionCollection ReadTypes ()
+ {
+ InitializeTypeDefinitions ();
+ var mtypes = metadata.Types;
+ var type_count = mtypes.Length - metadata.NestedTypes.Count;
+ var types = new TypeDefinitionCollection (module, type_count);
+
+ for (int i = 0; i < mtypes.Length; i++) {
+ var type = mtypes [i];
+ if (IsNested (type.Attributes))
+ continue;
+
+ types.Add (type);
+ }
+
+ return types;
+ }
+
+ void InitializeTypeDefinitions ()
+ {
+ if (metadata.Types != null)
+ return;
+
+ InitializeNestedTypes ();
+ InitializeFields ();
+ InitializeMethods ();
+
+ int length = MoveTo (Table.TypeDef);
+ var types = metadata.Types = new TypeDefinition [length];
+
+ for (uint i = 0; i < length; i++) {
+ if (types [i] != null)
+ continue;
+
+ types [i] = ReadType (i + 1);
+ }
+ }
+
+ static bool IsNested (TypeAttributes attributes)
+ {
+ switch (attributes & TypeAttributes.VisibilityMask) {
+ case TypeAttributes.NestedAssembly:
+ case TypeAttributes.NestedFamANDAssem:
+ case TypeAttributes.NestedFamily:
+ case TypeAttributes.NestedFamORAssem:
+ case TypeAttributes.NestedPrivate:
+ case TypeAttributes.NestedPublic:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ public bool HasNestedTypes (TypeDefinition type)
+ {
+ uint [] mapping;
+ InitializeNestedTypes ();
+
+ if (!metadata.TryGetNestedTypeMapping (type, out mapping))
+ return false;
+
+ return mapping.Length > 0;
+ }
+
+ public Collection<TypeDefinition> ReadNestedTypes (TypeDefinition type)
+ {
+ InitializeNestedTypes ();
+ uint [] mapping;
+ if (!metadata.TryGetNestedTypeMapping (type, out mapping))
+ return new MemberDefinitionCollection<TypeDefinition> (type);
+
+ var nested_types = new MemberDefinitionCollection<TypeDefinition> (type, mapping.Length);
+
+ for (int i = 0; i < mapping.Length; i++)
+ nested_types.Add (GetTypeDefinition (mapping [i]));
+
+ metadata.RemoveNestedTypeMapping (type);
+
+ return nested_types;
+ }
+
+ void InitializeNestedTypes ()
+ {
+ if (metadata.NestedTypes != null)
+ return;
+
+ var length = MoveTo (Table.NestedClass);
+
+ metadata.NestedTypes = new Dictionary<uint, uint []> (length);
+ metadata.ReverseNestedTypes = new Dictionary<uint, uint> (length);
+
+ if (length == 0)
+ return;
+
+ for (int i = 1; i <= length; i++) {
+ var nested = ReadTableIndex (Table.TypeDef);
+ var declaring = ReadTableIndex (Table.TypeDef);
+
+ AddNestedMapping (declaring, nested);
+ }
+ }
+
+ void AddNestedMapping (uint declaring, uint nested)
+ {
+ metadata.SetNestedTypeMapping (declaring, AddMapping (metadata.NestedTypes, declaring, nested));
+ metadata.SetReverseNestedTypeMapping (nested, declaring);
+ }
+
+ static TValue [] AddMapping<TKey, TValue> (Dictionary<TKey, TValue []> cache, TKey key, TValue value)
+ {
+ TValue [] mapped;
+ if (!cache.TryGetValue (key, out mapped)) {
+ mapped = new [] { value };
+ return mapped;
+ }
+
+ var new_mapped = new TValue [mapped.Length + 1];
+ Array.Copy (mapped, new_mapped, mapped.Length);
+ new_mapped [mapped.Length] = value;
+ return new_mapped;
+ }
+
+ TypeDefinition ReadType (uint rid)
+ {
+ if (!MoveTo (Table.TypeDef, rid))
+ return null;
+
+ var attributes = (TypeAttributes) ReadUInt32 ();
+ var name = ReadString ();
+ var @namespace = ReadString ();
+ var type = new TypeDefinition (@namespace, name, attributes);
+ type.token = new MetadataToken (TokenType.TypeDef, rid);
+ type.scope = module;
+ type.module = module;
+
+ metadata.AddTypeDefinition (type);
+
+ this.context = type;
+
+ type.BaseType = GetTypeDefOrRef (ReadMetadataToken (CodedIndex.TypeDefOrRef));
+
+ type.fields_range = ReadFieldsRange (rid);
+ type.methods_range = ReadMethodsRange (rid);
+
+ if (IsNested (attributes))
+ type.DeclaringType = GetNestedTypeDeclaringType (type);
+
+ return type;
+ }
+
+ TypeDefinition GetNestedTypeDeclaringType (TypeDefinition type)
+ {
+ uint declaring_rid;
+ if (!metadata.TryGetReverseNestedTypeMapping (type, out declaring_rid))
+ return null;
+
+ metadata.RemoveReverseNestedTypeMapping (type);
+ return GetTypeDefinition (declaring_rid);
+ }
+
+ Range ReadFieldsRange (uint type_index)
+ {
+ return ReadListRange (type_index, Table.TypeDef, Table.Field);
+ }
+
+ Range ReadMethodsRange (uint type_index)
+ {
+ return ReadListRange (type_index, Table.TypeDef, Table.Method);
+ }
+
+ Range ReadListRange (uint current_index, Table current, Table target)
+ {
+ var list = new Range ();
+
+ list.Start = ReadTableIndex (target);
+
+ uint next_index;
+ var current_table = image.TableHeap [current];
+
+ if (current_index == current_table.Length)
+ next_index = image.TableHeap [target].Length + 1;
+ else {
+ var position = Position;
+ Position += (uint) (current_table.RowSize - image.GetTableIndexSize (target));
+ next_index = ReadTableIndex (target);
+ Position = position;
+ }
+
+ list.Length = next_index - list.Start;
+
+ return list;
+ }
+
+ public Row<short, int> ReadTypeLayout (TypeDefinition type)
+ {
+ InitializeTypeLayouts ();
+ Row<ushort, uint> class_layout;
+ var rid = type.token.RID;
+ if (!metadata.ClassLayouts.TryGetValue (rid, out class_layout))
+ return new Row<short, int> (Mixin.NoDataMarker, Mixin.NoDataMarker);
+
+ type.PackingSize = (short) class_layout.Col1;
+ type.ClassSize = (int) class_layout.Col2;
+
+ metadata.ClassLayouts.Remove (rid);
+
+ return new Row<short, int> ((short) class_layout.Col1, (int) class_layout.Col2);
+ }
+
+ void InitializeTypeLayouts ()
+ {
+ if (metadata.ClassLayouts != null)
+ return;
+
+ int length = MoveTo (Table.ClassLayout);
+
+ var class_layouts = metadata.ClassLayouts = new Dictionary<uint, Row<ushort, uint>> (length);
+
+ for (uint i = 0; i < length; i++) {
+ var packing_size = ReadUInt16 ();
+ var class_size = ReadUInt32 ();
+
+ var parent = ReadTableIndex (Table.TypeDef);
+
+ class_layouts.Add (parent, new Row<ushort, uint> (packing_size, class_size));
+ }
+ }
+
+ public TypeReference GetTypeDefOrRef (MetadataToken token)
+ {
+ return (TypeReference) LookupToken (token);
+ }
+
+ TypeDefinition GetTypeDefinition (uint rid)
+ {
+ InitializeTypeDefinitions ();
+
+ var type = metadata.GetTypeDefinition (rid);
+ if (type != null)
+ return type;
+
+ return ReadTypeDefinition (rid);
+ }
+
+ TypeDefinition ReadTypeDefinition (uint rid)
+ {
+ if (!MoveTo (Table.TypeDef, rid))
+ return null;
+
+ return ReadType (rid);
+ }
+
+ void InitializeTypeReferences ()
+ {
+ if (metadata.TypeReferences != null)
+ return;
+
+ metadata.TypeReferences = new TypeReference [image.GetTableLength (Table.TypeRef)];
+ }
+
+ public TypeReference GetTypeReference (string scope, string full_name)
+ {
+ InitializeTypeReferences ();
+
+ var length = metadata.TypeReferences.Length;
+
+ for (uint i = 1; i <= length; i++) {
+ var type = GetTypeReference (i);
+
+ if (type.FullName != full_name)
+ continue;
+
+ if (string.IsNullOrEmpty (scope))
+ return type;
+
+ if (type.Scope.Name == scope)
+ return type;
+ }
+
+ return null;
+ }
+
+ TypeReference GetTypeReference (uint rid)
+ {
+ InitializeTypeReferences ();
+
+ var type = metadata.GetTypeReference (rid);
+ if (type != null)
+ return type;
+
+ type = ReadTypeReference (rid);
+ if (type != null)
+ metadata.AddTypeReference (type);
+
+ return type;
+ }
+
+ TypeReference ReadTypeReference (uint rid)
+ {
+ if (!MoveTo (Table.TypeRef, rid))
+ return null;
+
+ TypeReference declaring_type = null;
+ IMetadataScope scope;
+
+ var scope_token = ReadMetadataToken (CodedIndex.ResolutionScope);
+
+ if (scope_token.TokenType == TokenType.TypeRef) {
+ declaring_type = GetTypeDefOrRef (scope_token);
+
+ scope = declaring_type != null
+ ? declaring_type.Scope
+ : module;
+ } else
+ scope = GetTypeReferenceScope (scope_token);
+
+ var name = ReadString ();
+ var @namespace = ReadString ();
+
+ var type = new TypeReference (
+ @namespace,
+ name,
+ scope);
+
+ type.DeclaringType = declaring_type;
+ type.token = new MetadataToken (TokenType.TypeRef, rid);
+ type.module = module;
+
+ MetadataSystem.TryProcessPrimitiveType (type);
+
+ return type;
+ }
+
+ 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];
+ case TokenType.ModuleRef:
+ return module.ModuleReferences [(int) scope.RID - 1];
+ case TokenType.Module:
+ return module;
+ default:
+ throw new NotSupportedException ();
+ }
+ }
+
+ public IEnumerable<TypeReference> GetTypeReferences ()
+ {
+ InitializeTypeReferences ();
+
+ var length = image.GetTableLength (Table.TypeRef);
+
+ var type_references = new TypeReference [length];
+
+ for (uint i = 1; i <= length; i++)
+ type_references [i - 1] = GetTypeReference (i);
+
+ return type_references;
+ }
+
+ TypeReference GetTypeSpecification (uint rid)
+ {
+ if (!MoveTo (Table.TypeSpec, rid))
+ return null;
+
+ var reader = ReadSignature (ReadBlobIndex ());
+ return reader.ReadTypeSignature ();
+ }
+
+ SignatureReader ReadSignature (uint signature)
+ {
+ return new SignatureReader (signature, this);
+ }
+
+ public bool HasInterfaces (TypeDefinition type)
+ {
+ InitializeInterfaces ();
+ MetadataToken [] mapping;
+
+ return metadata.TryGetInterfaceMapping (type, out mapping);
+ }
+
+ public Collection<TypeReference> ReadInterfaces (TypeDefinition type)
+ {
+ InitializeInterfaces ();
+ MetadataToken [] mapping;
+
+ if (!metadata.TryGetInterfaceMapping (type, out mapping))
+ return new Collection<TypeReference> ();
+
+ var interfaces = new Collection<TypeReference> (mapping.Length);
+
+ this.context = type;
+
+ for (int i = 0; i < mapping.Length; i++)
+ interfaces.Add (GetTypeDefOrRef (mapping [i]));
+
+ metadata.RemoveInterfaceMapping (type);
+
+ return interfaces;
+ }
+
+ void InitializeInterfaces ()
+ {
+ if (metadata.Interfaces != null)
+ return;
+
+ int length = MoveTo (Table.InterfaceImpl);
+
+ metadata.Interfaces = new Dictionary<uint, MetadataToken []> (length);
+
+ for (int i = 0; i < length; i++) {
+ var type = ReadTableIndex (Table.TypeDef);
+ var @interface = ReadMetadataToken (CodedIndex.TypeDefOrRef);
+
+ AddInterfaceMapping (type, @interface);
+ }
+ }
+
+ void AddInterfaceMapping (uint type, MetadataToken @interface)
+ {
+ metadata.SetInterfaceMapping (type, AddMapping (metadata.Interfaces, type, @interface));
+ }
+
+ public Collection<FieldDefinition> ReadFields (TypeDefinition type)
+ {
+ var fields_range = type.fields_range;
+ if (fields_range.Length == 0)
+ return new MemberDefinitionCollection<FieldDefinition> (type);
+
+ 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));
+
+ return fields;
+ }
+
+ FieldDefinition ReadField (uint field_rid)
+ {
+ var attributes = (FieldAttributes) ReadUInt16 ();
+ var name = ReadString ();
+ var signature = ReadBlobIndex ();
+
+ var field = new FieldDefinition (name, attributes, ReadFieldType (signature));
+ field.token = new MetadataToken (TokenType.Field, field_rid);
+ metadata.AddFieldDefinition (field);
+
+ return field;
+ }
+
+ void InitializeFields ()
+ {
+ if (metadata.Fields != null)
+ return;
+
+ metadata.Fields = new FieldDefinition [image.GetTableLength (Table.Field)];
+ }
+
+ TypeReference ReadFieldType (uint signature)
+ {
+ var reader = ReadSignature (signature);
+
+ const byte field_sig = 0x6;
+
+ if (reader.ReadByte () != field_sig)
+ throw new NotSupportedException ();
+
+ return reader.ReadTypeSignature ();
+ }
+
+ public int ReadFieldRVA (FieldDefinition field)
+ {
+ InitializeFieldRVAs ();
+ var rid = field.token.RID;
+
+ RVA rva;
+ if (!metadata.FieldRVAs.TryGetValue (rid, out rva))
+ return 0;
+
+ var size = GetFieldTypeSize (field.FieldType);
+
+ if (size == 0 || rva == 0)
+ return 0;
+
+ metadata.FieldRVAs.Remove (rid);
+
+ field.InitialValue = GetFieldInitializeValue (size, rva);
+
+ return (int) rva;
+ }
+
+ byte [] GetFieldInitializeValue (int size, RVA rva)
+ {
+ var section = image.GetSectionAtVirtualAddress (rva);
+ if (section == null)
+ return Empty<byte>.Array;
+
+ var value = new byte [size];
+ Buffer.BlockCopy (section.Data, (int) (rva - section.VirtualAddress), value, 0, size);
+ return value;
+ }
+
+ static int GetFieldTypeSize (TypeReference type)
+ {
+ int size = 0;
+
+ switch (type.etype) {
+ case ElementType.Boolean:
+ case ElementType.U1:
+ case ElementType.I1:
+ size = 1;
+ break;
+ case ElementType.U2:
+ case ElementType.I2:
+ case ElementType.Char:
+ size = 2;
+ break;
+ case ElementType.U4:
+ case ElementType.I4:
+ case ElementType.R4:
+ size = 4;
+ break;
+ case ElementType.U8:
+ case ElementType.I8:
+ case ElementType.R8:
+ size = 8;
+ break;
+ case ElementType.Ptr:
+ case ElementType.FnPtr:
+ size = IntPtr.Size;
+ break;
+ case ElementType.CModOpt:
+ case ElementType.CModReqD:
+ return GetFieldTypeSize (((IModifierType) type).ElementType);
+ default:
+ var field_type = type.CheckedResolve ();
+ if (field_type.HasLayoutInfo)
+ size = field_type.ClassSize;
+
+ break;
+ }
+
+ return size;
+ }
+
+ void InitializeFieldRVAs ()
+ {
+ if (metadata.FieldRVAs != null)
+ return;
+
+ int length = MoveTo (Table.FieldRVA);
+
+ var field_rvas = metadata.FieldRVAs = new Dictionary<uint, uint> (length);
+
+ for (int i = 0; i < length; i++) {
+ var rva = ReadUInt32 ();
+ var field = ReadTableIndex (Table.Field);
+
+ field_rvas.Add (field, rva);
+ }
+ }
+
+ public int ReadFieldLayout (FieldDefinition field)
+ {
+ InitializeFieldLayouts ();
+ var rid = field.token.RID;
+ uint offset;
+ if (!metadata.FieldLayouts.TryGetValue (rid, out offset))
+ return Mixin.NoDataMarker;
+
+ metadata.FieldLayouts.Remove (rid);
+
+ return (int) offset;
+ }
+
+ void InitializeFieldLayouts ()
+ {
+ if (metadata.FieldLayouts != null)
+ return;
+
+ int length = MoveTo (Table.FieldLayout);
+
+ var field_layouts = metadata.FieldLayouts = new Dictionary<uint, uint> (length);
+
+ for (int i = 0; i < length; i++) {
+ var offset = ReadUInt32 ();
+ var field = ReadTableIndex (Table.Field);
+
+ field_layouts.Add (field, offset);
+ }
+ }
+
+ public bool HasEvents (TypeDefinition type)
+ {
+ InitializeEvents ();
+
+ Range range;
+ if (!metadata.TryGetEventsRange (type, out range))
+ return false;
+
+ return range.Length > 0;
+ }
+
+ public Collection<EventDefinition> ReadEvents (TypeDefinition type)
+ {
+ InitializeEvents ();
+ Range range;
+
+ if (!metadata.TryGetEventsRange (type, out range))
+ return new MemberDefinitionCollection<EventDefinition> (type);
+
+ var events = new MemberDefinitionCollection<EventDefinition> (type, (int) range.Length);
+
+ metadata.RemoveEventsRange (type);
+
+ if (range.Length == 0 || !MoveTo (Table.Event, range.Start))
+ return events;
+
+ this.context = type;
+
+ for (uint i = 0; i < range.Length; i++)
+ events.Add (ReadEvent (range.Start + i));
+
+ return events;
+ }
+
+ EventDefinition ReadEvent (uint event_rid)
+ {
+ var attributes = (EventAttributes) ReadUInt16 ();
+ var name = ReadString ();
+ var event_type = GetTypeDefOrRef (ReadMetadataToken (CodedIndex.TypeDefOrRef));
+
+ var @event = new EventDefinition (name, attributes, event_type);
+ @event.token = new MetadataToken (TokenType.Event, event_rid);
+ return @event;
+ }
+
+ void InitializeEvents ()
+ {
+ if (metadata.Events != null)
+ return;
+
+ int length = MoveTo (Table.EventMap);
+
+ metadata.Events = new Dictionary<uint, Range> (length);
+
+ for (uint i = 1; i <= length; i++) {
+ var type_rid = ReadTableIndex (Table.TypeDef);
+ Range events_range = ReadEventsRange (i);
+ metadata.AddEventsRange (type_rid, events_range);
+ }
+ }
+
+ Range ReadEventsRange (uint rid)
+ {
+ return ReadListRange (rid, Table.EventMap, Table.Event);
+ }
+
+ public bool HasProperties (TypeDefinition type)
+ {
+ InitializeProperties ();
+
+ Range range;
+ if (!metadata.TryGetPropertiesRange (type, out range))
+ return false;
+
+ return range.Length > 0;
+ }
+
+ public Collection<PropertyDefinition> ReadProperties (TypeDefinition type)
+ {
+ InitializeProperties ();
+
+ Range range;
+
+ if (!metadata.TryGetPropertiesRange (type, out range))
+ return new MemberDefinitionCollection<PropertyDefinition> (type);
+
+ metadata.RemovePropertiesRange (type);
+
+ var properties = new MemberDefinitionCollection<PropertyDefinition> (type, (int) range.Length);
+
+ if (range.Length == 0 || !MoveTo (Table.Property, range.Start))
+ return properties;
+
+ this.context = type;
+
+ for (uint i = 0; i < range.Length; i++)
+ properties.Add (ReadProperty (range.Start + i));
+
+ return properties;
+ }
+
+ PropertyDefinition ReadProperty (uint property_rid)
+ {
+ var attributes = (PropertyAttributes) ReadUInt16 ();
+ var name = ReadString ();
+ var signature = ReadBlobIndex ();
+
+ var reader = ReadSignature (signature);
+ const byte property_signature = 0x8;
+
+ var calling_convention = reader.ReadByte ();
+
+ if ((calling_convention & property_signature) == 0)
+ throw new NotSupportedException ();
+
+ var has_this = (calling_convention & 0x20) != 0;
+
+ reader.ReadCompressedUInt32 (); // count
+
+ var property = new PropertyDefinition (name, attributes, reader.ReadTypeSignature ());
+ property.HasThis = has_this;
+ property.token = new MetadataToken (TokenType.Property, property_rid);
+
+ return property;
+ }
+
+ void InitializeProperties ()
+ {
+ if (metadata.Properties != null)
+ return;
+
+ int length = MoveTo (Table.PropertyMap);
+
+ metadata.Properties = new Dictionary<uint, Range> (length);
+
+ for (uint i = 1; i <= length; i++) {
+ var type_rid = ReadTableIndex (Table.TypeDef);
+ var properties_range = ReadPropertiesRange (i);
+ metadata.AddPropertiesRange (type_rid, properties_range);
+ }
+ }
+
+ Range ReadPropertiesRange (uint rid)
+ {
+ return ReadListRange (rid, Table.PropertyMap, Table.Property);
+ }
+
+ public MethodSemanticsAttributes ReadMethodSemantics (MethodDefinition method)
+ {
+ InitializeMethodSemantics ();
+ Row<MethodSemanticsAttributes, MetadataToken> row;
+ if (!metadata.Semantics.TryGetValue (method.token.RID, out row))
+ return MethodSemanticsAttributes.None;
+
+ method.SemanticsAttributes = row.Col1;
+ var type = method.DeclaringType;
+
+ switch (row.Col1) {
+ case MethodSemanticsAttributes.AddOn:
+ GetEvent (type, row.Col2).add_method = method;
+ break;
+ case MethodSemanticsAttributes.Fire:
+ GetEvent (type, row.Col2).invoke_method = method;
+ break;
+ case MethodSemanticsAttributes.RemoveOn:
+ GetEvent (type, row.Col2).remove_method = method;
+ break;
+ case MethodSemanticsAttributes.Getter:
+ GetProperty (type, row.Col2).get_method = method;
+ break;
+ case MethodSemanticsAttributes.Setter:
+ GetProperty (type, row.Col2).set_method = method;
+ break;
+ case MethodSemanticsAttributes.Other:
+ switch (row.Col2.TokenType) {
+ case TokenType.Event: {
+ var @event = GetEvent (type, row.Col2);
+ if (@event.other_methods == null)
+ @event.other_methods = new Collection<MethodDefinition> ();
+
+ @event.other_methods.Add (method);
+ break;
+ }
+ case TokenType.Property: {
+ var property = GetProperty (type, row.Col2);
+ if (property.other_methods == null)
+ property.other_methods = new Collection<MethodDefinition> ();
+
+ property.other_methods.Add (method);
+
+ break;
+ }
+ default:
+ throw new NotSupportedException ();
+ }
+ break;
+ default:
+ throw new NotSupportedException ();
+ }
+
+ metadata.Semantics.Remove (method.token.RID);
+
+ return row.Col1;
+ }
+
+ static EventDefinition GetEvent (TypeDefinition type, MetadataToken token)
+ {
+ if (token.TokenType != TokenType.Event)
+ throw new ArgumentException ();
+
+ return GetMember (type.Events, token);
+ }
+
+ static PropertyDefinition GetProperty (TypeDefinition type, MetadataToken token)
+ {
+ if (token.TokenType != TokenType.Property)
+ throw new ArgumentException ();
+
+ return GetMember (type.Properties, token);
+ }
+
+ static TMember GetMember<TMember> (Collection<TMember> members, MetadataToken token) where TMember : IMemberDefinition
+ {
+ for (int i = 0; i < members.Count; i++) {
+ var member = members [i];
+ if (member.MetadataToken == token)
+ return member;
+ }
+
+ throw new ArgumentException ();
+ }
+
+ void InitializeMethodSemantics ()
+ {
+ if (metadata.Semantics != null)
+ return;
+
+ int length = MoveTo (Table.MethodSemantics);
+
+ var semantics = metadata.Semantics = new Dictionary<uint, Row<MethodSemanticsAttributes, MetadataToken>> (0);
+
+ for (uint i = 0; i < length; i++) {
+ var attributes = (MethodSemanticsAttributes) ReadUInt16 ();
+ var method_rid = ReadTableIndex (Table.Method);
+ var association = ReadMetadataToken (CodedIndex.HasSemantics);
+
+ semantics [method_rid] = new Row<MethodSemanticsAttributes, MetadataToken> (attributes, association);
+ }
+ }
+
+ public PropertyDefinition ReadMethods (PropertyDefinition property)
+ {
+ ReadAllSemantics (property.DeclaringType);
+ return property;
+ }
+
+ public EventDefinition ReadMethods (EventDefinition @event)
+ {
+ ReadAllSemantics (@event.DeclaringType);
+ return @event;
+ }
+
+ static void ReadAllSemantics (TypeDefinition type)
+ {
+ var methods = type.Methods;
+ for (int i = 0; i < methods.Count; i++)
+ methods [i].ReadSemantics ();
+ }
+
+ Range ReadParametersRange (uint method_rid)
+ {
+ return ReadListRange (method_rid, Table.Method, Table.Param);
+ }
+
+ public Collection<MethodDefinition> ReadMethods (TypeDefinition type)
+ {
+ var methods_range = type.methods_range;
+ if (methods_range.Length == 0)
+ return new MemberDefinitionCollection<MethodDefinition> (type);
+
+ var methods = new MemberDefinitionCollection<MethodDefinition> (type, (int) methods_range.Length);
+
+ MoveTo (Table.Method, methods_range.Start);
+ for (uint i = 0; i < methods_range.Length; i++)
+ ReadMethod (methods_range.Start + i, methods);
+
+ return methods;
+ }
+
+ void InitializeMethods ()
+ {
+ if (metadata.Methods != null)
+ return;
+
+ metadata.Methods = new MethodDefinition [image.GetTableLength (Table.Method)];
+ }
+
+ void ReadMethod (uint method_rid, Collection<MethodDefinition> methods)
+ {
+ var method = new MethodDefinition ();
+ method.rva = ReadUInt32 ();
+ method.ImplAttributes = (MethodImplAttributes) ReadUInt16 ();
+ method.Attributes = (MethodAttributes) ReadUInt16 ();
+ method.Name = ReadString ();
+ method.token = new MetadataToken (TokenType.Method, method_rid);
+
+ methods.Add (method); // attach method
+
+ var signature = ReadBlobIndex ();
+ var param_range = ReadParametersRange (method_rid);
+
+ this.context = method;
+
+ ReadMethodSignature (signature, method);
+ metadata.AddMethodDefinition (method);
+
+ if (param_range.Length == 0)
+ return;
+
+ var position = base.position;
+ ReadParameters (method, param_range);
+ base.position = position;
+ }
+
+ 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 ();
+
+ var parameter = sequence == 0
+ ? method.MethodReturnType.Parameter
+ : method.Parameters [sequence - 1];
+
+ parameter.token = new MetadataToken (TokenType.Param, param_range.Start + i);
+ parameter.Name = name;
+ parameter.Attributes = attributes;
+ }
+ }
+
+ void ReadMethodSignature (uint signature, IMethodSignature method)
+ {
+ var reader = ReadSignature (signature);
+ reader.ReadMethodSignature (method);
+ }
+
+ public PInvokeInfo ReadPInvokeInfo (MethodDefinition method)
+ {
+ InitializePInvokes ();
+ Row<PInvokeAttributes, uint, uint> row;
+
+ var rid = method.token.RID;
+
+ if (!metadata.PInvokes.TryGetValue (rid, out row))
+ return null;
+
+ metadata.PInvokes.Remove (rid);
+
+ return new PInvokeInfo (
+ row.Col1,
+ image.StringHeap.Read (row.Col2),
+ module.ModuleReferences [(int) row.Col3 - 1]);
+ }
+
+ void InitializePInvokes ()
+ {
+ if (metadata.PInvokes != null)
+ return;
+
+ int length = MoveTo (Table.ImplMap);
+
+ var pinvokes = metadata.PInvokes = new Dictionary<uint, Row<PInvokeAttributes, uint, uint>> (length);
+
+ for (int i = 1; i <= length; i++) {
+ var attributes = (PInvokeAttributes) ReadUInt16 ();
+ var method = ReadMetadataToken (CodedIndex.MemberForwarded);
+ var name = ReadStringIndex ();
+ var scope = ReadTableIndex (Table.File);
+
+ if (method.TokenType != TokenType.Method)
+ continue;
+
+ pinvokes.Add (method.RID, new Row<PInvokeAttributes, uint, uint> (attributes, name, scope));
+ }
+ }
+
+ public bool HasGenericParameters (IGenericParameterProvider provider)
+ {
+ InitializeGenericParameters ();
+
+ Range range;
+ if (!metadata.TryGetGenericParameterRange (provider, out range))
+ return false;
+
+ return range.Length > 0;
+ }
+
+ public Collection<GenericParameter> ReadGenericParameters (IGenericParameterProvider provider)
+ {
+ InitializeGenericParameters ();
+
+ Range range;
+ if (!metadata.TryGetGenericParameterRange (provider, out range)
+ || !MoveTo (Table.GenericParam, range.Start))
+ return new Collection<GenericParameter> ();
+
+ metadata.RemoveGenericParameterRange (provider);
+
+ var generic_parameters = new Collection<GenericParameter> ((int) range.Length);
+
+ for (uint i = 0; i < range.Length; i++) {
+ ReadUInt16 (); // index
+ var flags = (GenericParameterAttributes) ReadUInt16 ();
+ ReadMetadataToken (CodedIndex.TypeOrMethodDef);
+ var name = ReadString ();
+
+ var parameter = new GenericParameter (name, provider);
+ parameter.token = new MetadataToken (TokenType.GenericParam, range.Start + i);
+ parameter.Attributes = flags;
+
+ generic_parameters.Add (parameter);
+ }
+
+ return generic_parameters;
+ }
+
+ void InitializeGenericParameters ()
+ {
+ if (metadata.GenericParameters != null)
+ return;
+
+ metadata.GenericParameters = InitializeRanges (
+ Table.GenericParam, () => {
+ Advance (4);
+ var next = ReadMetadataToken (CodedIndex.TypeOrMethodDef);
+ ReadStringIndex ();
+ return next;
+ });
+ }
+
+ Dictionary<MetadataToken, Range> InitializeRanges (Table table, Func<MetadataToken> get_next)
+ {
+ int length = MoveTo (table);
+ var ranges = new Dictionary<MetadataToken, Range> (length);
+
+ if (length == 0)
+ return ranges;
+
+ MetadataToken owner = MetadataToken.Zero;
+ Range range = new Range (1, 0);
+
+ for (uint i = 1; i <= length; i++) {
+ var next = get_next ();
+
+ if (i == 1) {
+ owner = next;
+ range.Length++;
+ } else if (next != owner) {
+ if (owner.RID != 0)
+ ranges.Add (owner, range);
+ range = new Range (i, 1);
+ owner = next;
+ } else
+ range.Length++;
+ }
+
+ if (owner != MetadataToken.Zero)
+ ranges.Add (owner, range);
+
+ return ranges;
+ }
+
+ public bool HasGenericConstraints (GenericParameter generic_parameter)
+ {
+ InitializeGenericConstraints ();
+
+ MetadataToken [] mapping;
+ if (!metadata.TryGetGenericConstraintMapping (generic_parameter, out mapping))
+ return false;
+
+ return mapping.Length > 0;
+ }
+
+ public Collection<TypeReference> ReadGenericConstraints (GenericParameter generic_parameter)
+ {
+ InitializeGenericConstraints ();
+
+ MetadataToken [] mapping;
+ if (!metadata.TryGetGenericConstraintMapping (generic_parameter, out mapping))
+ return new Collection<TypeReference> ();
+
+ var constraints = new Collection<TypeReference> (mapping.Length);
+
+ this.context = (IGenericContext) generic_parameter.Owner;
+
+ for (int i = 0; i < mapping.Length; i++)
+ constraints.Add (GetTypeDefOrRef (mapping [i]));
+
+ metadata.RemoveGenericConstraintMapping (generic_parameter);
+
+ return constraints;
+ }
+
+ void InitializeGenericConstraints ()
+ {
+ if (metadata.GenericConstraints != null)
+ return;
+
+ var length = MoveTo (Table.GenericParamConstraint);
+
+ metadata.GenericConstraints = new Dictionary<uint, MetadataToken []> (length);
+
+ for (int i = 1; i <= length; i++)
+ AddGenericConstraintMapping (
+ ReadTableIndex (Table.GenericParam),
+ ReadMetadataToken (CodedIndex.TypeDefOrRef));
+ }
+
+ void AddGenericConstraintMapping (uint generic_parameter, MetadataToken constraint)
+ {
+ metadata.SetGenericConstraintMapping (
+ generic_parameter,
+ AddMapping (metadata.GenericConstraints, generic_parameter, constraint));
+ }
+
+ public bool HasOverrides (MethodDefinition method)
+ {
+ InitializeOverrides ();
+ MetadataToken [] mapping;
+
+ if (!metadata.TryGetOverrideMapping (method, out mapping))
+ return false;
+
+ return mapping.Length > 0;
+ }
+
+ public Collection<MethodReference> ReadOverrides (MethodDefinition method)
+ {
+ InitializeOverrides ();
+
+ MetadataToken [] mapping;
+ if (!metadata.TryGetOverrideMapping (method, out mapping))
+ return new Collection<MethodReference> ();
+
+ var overrides = new Collection<MethodReference> (mapping.Length);
+
+ this.context = method;
+
+ for (int i = 0; i < mapping.Length; i++)
+ overrides.Add ((MethodReference) LookupToken (mapping [i]));
+
+ metadata.RemoveOverrideMapping (method);
+
+ return overrides;
+ }
+
+ void InitializeOverrides ()
+ {
+ if (metadata.Overrides != null)
+ return;
+
+ var length = MoveTo (Table.MethodImpl);
+
+ metadata.Overrides = new Dictionary<uint, MetadataToken []> (length);
+
+ for (int i = 1; i <= length; i++) {
+ ReadTableIndex (Table.TypeDef);
+
+ var method = ReadMetadataToken (CodedIndex.MethodDefOrRef);
+ if (method.TokenType != TokenType.Method)
+ throw new NotSupportedException ();
+
+ var @override = ReadMetadataToken (CodedIndex.MethodDefOrRef);
+
+ AddOverrideMapping (method.RID, @override);
+ }
+ }
+
+ void AddOverrideMapping (uint method_rid, MetadataToken @override)
+ {
+ metadata.SetOverrideMapping (
+ method_rid,
+ AddMapping (metadata.Overrides, method_rid, @override));
+ }
+
+ public MethodBody ReadMethodBody (MethodDefinition method)
+ {
+ return code.ReadMethodBody (method);
+ }
+
+ public CallSite ReadCallSite (MetadataToken token)
+ {
+ if (!MoveTo (Table.StandAloneSig, token.RID))
+ return null;
+
+ var signature = ReadBlobIndex ();
+
+ var call_site = new CallSite ();
+
+ ReadMethodSignature (signature, call_site);
+
+ return call_site;
+ }
+
+ public VariableDefinitionCollection ReadVariables (MetadataToken local_var_token)
+ {
+ if (!MoveTo (Table.StandAloneSig, local_var_token.RID))
+ return null;
+
+ var reader = ReadSignature (ReadBlobIndex ());
+ const byte local_sig = 0x7;
+
+ if (reader.ReadByte () != local_sig)
+ throw new NotSupportedException ();
+
+ var count = reader.ReadCompressedUInt32 ();
+ if (count == 0)
+ return null;
+
+ var variables = new VariableDefinitionCollection ((int) count);
+
+ for (int i = 0; i < count; i++)
+ variables.Add (new VariableDefinition (reader.ReadTypeSignature ()));
+
+ return variables;
+ }
+
+ public IMetadataTokenProvider LookupToken (MetadataToken token)
+ {
+ var rid = token.RID;
+
+ if (rid == 0)
+ return null;
+
+ IMetadataTokenProvider element;
+ var position = this.position;
+ var context = this.context;
+
+ switch (token.TokenType) {
+ case TokenType.TypeDef:
+ element = GetTypeDefinition (rid);
+ break;
+ case TokenType.TypeRef:
+ element = GetTypeReference (rid);
+ break;
+ case TokenType.TypeSpec:
+ element = GetTypeSpecification (rid);
+ break;
+ case TokenType.Field:
+ element = GetFieldDefinition (rid);
+ break;
+ case TokenType.Method:
+ element = GetMethodDefinition (rid);
+ break;
+ case TokenType.MemberRef:
+ element = GetMemberReference (rid);
+ break;
+ case TokenType.MethodSpec:
+ element = GetMethodSpecification (rid);
+ break;
+ default:
+ throw new NotSupportedException ();
+ }
+
+ this.position = position;
+ this.context = context;
+
+ return element;
+ }
+
+ public FieldDefinition GetFieldDefinition (uint rid)
+ {
+ InitializeTypeDefinitions ();
+
+ var field = metadata.GetFieldDefinition (rid);
+ if (field != null)
+ return field;
+
+ return LookupField (rid);
+ }
+
+ FieldDefinition LookupField (uint rid)
+ {
+ var type = metadata.GetFieldDeclaringType (rid);
+ if (type == null)
+ throw new NotSupportedException ();
+
+ InitializeCollection (type.Fields);
+
+ return metadata.GetFieldDefinition (rid);
+ }
+
+ public MethodDefinition GetMethodDefinition (uint rid)
+ {
+ InitializeTypeDefinitions ();
+
+ var method = metadata.GetMethodDefinition (rid);
+ if (method != null)
+ return method;
+
+ return LookupMethod (rid);
+ }
+
+ MethodDefinition LookupMethod (uint rid)
+ {
+ var type = metadata.GetMethodDeclaringType (rid);
+ if (type == null)
+ throw new NotSupportedException ();
+
+ InitializeCollection (type.Methods);
+
+ return metadata.GetMethodDefinition (rid);
+ }
+
+ MethodSpecification GetMethodSpecification (uint rid)
+ {
+ if (!MoveTo (Table.MethodSpec, rid))
+ return null;
+
+ var method = (MethodReference) LookupToken (
+ ReadMetadataToken (CodedIndex.MethodDefOrRef));
+ var signature = ReadBlobIndex ();
+
+ return ReadMethodSpecSignature (signature, method);
+ }
+
+ MethodSpecification ReadMethodSpecSignature (uint signature, MethodReference method)
+ {
+ var reader = ReadSignature (signature);
+ const byte methodspec_sig = 0x0a;
+
+ var call_conv = reader.ReadByte ();
+
+ if (call_conv != methodspec_sig)
+ throw new NotSupportedException ();
+
+ var instance = new GenericInstanceMethod (method);
+
+ reader.ReadGenericInstanceSignature (method, instance);
+
+ return instance;
+ }
+
+ MemberReference GetMemberReference (uint rid)
+ {
+ InitializeMemberReferences ();
+
+ var member = metadata.GetMemberReference (rid);
+ if (member != null)
+ return member;
+
+ member = ReadMemberReference (rid);
+ if (!member.ContainsGenericParameter)
+ metadata.AddMemberReference (member);
+ return member;
+ }
+
+ MemberReference ReadMemberReference (uint rid)
+ {
+ if (!MoveTo (Table.MemberRef, rid))
+ return null;
+
+ var token = ReadMetadataToken (CodedIndex.MemberRefParent);
+ var name = ReadString ();
+ var signature = ReadBlobIndex ();
+
+ MemberReference member;
+
+ switch (token.TokenType) {
+ case TokenType.TypeDef:
+ case TokenType.TypeRef:
+ case TokenType.TypeSpec:
+ member = ReadTypeMemberReference (token, name, signature);
+ break;
+ case TokenType.Method:
+ member = ReadMethodMemberReference (token, name, signature);
+ break;
+ default:
+ throw new NotSupportedException ();
+ }
+
+ member.token = new MetadataToken (TokenType.MemberRef, rid);
+
+ return member;
+ }
+
+ MemberReference ReadTypeMemberReference (MetadataToken type, string name, uint signature)
+ {
+ var declaring_type = GetTypeDefOrRef (type);
+
+ this.context = declaring_type;
+
+ var member = ReadMemberReferenceSignature (signature, declaring_type);
+ member.Name = name;
+
+ return member;
+ }
+
+ MemberReference ReadMemberReferenceSignature (uint signature, TypeReference declaring_type)
+ {
+ var reader = ReadSignature (signature);
+ const byte field_sig = 0x6;
+
+ if (reader.buffer [reader.position] == field_sig) {
+ reader.position++;
+ var field = new FieldReference ();
+ field.DeclaringType = declaring_type;
+ field.FieldType = reader.ReadTypeSignature ();
+ return field;
+ } else {
+ var method = new MethodReference ();
+ method.DeclaringType = declaring_type;
+ reader.ReadMethodSignature (method);
+ return method;
+ }
+ }
+
+ MemberReference ReadMethodMemberReference (MetadataToken token, string name, uint signature)
+ {
+ var method = GetMethodDefinition (token.RID);
+
+ this.context = method;
+
+ var member = ReadMemberReferenceSignature (signature, method.DeclaringType);
+ member.Name = name;
+
+ return member;
+ }
+
+ void InitializeMemberReferences ()
+ {
+ if (metadata.MemberReferences != null)
+ return;
+
+ metadata.MemberReferences = new MemberReference [image.GetTableLength (Table.MemberRef)];
+ }
+
+ public IEnumerable<MemberReference> GetMemberReferences ()
+ {
+ InitializeMemberReferences ();
+
+ var length = image.GetTableLength (Table.MemberRef);
+
+ var type_system = module.TypeSystem;
+
+ var context = new MethodReference (string.Empty, type_system.Void);
+ context.DeclaringType = new TypeReference (string.Empty, string.Empty, type_system.Corlib);
+
+ var member_references = new MemberReference [length];
+
+ for (uint i = 1; i <= length; i++) {
+ this.context = context;
+ member_references [i - 1] = GetMemberReference (i);
+ }
+
+ return member_references;
+ }
+
+ void InitializeConstants ()
+ {
+ if (metadata.Constants != null)
+ return;
+
+ var length = MoveTo (Table.Constant);
+
+ var constants = metadata.Constants = new Dictionary<MetadataToken, Row<ElementType, uint>> (length);
+
+ for (uint i = 1; i <= length; i++) {
+ var type = (ElementType) ReadUInt16 ();
+ var owner = ReadMetadataToken (CodedIndex.HasConstant);
+ var signature = ReadBlobIndex ();
+
+ constants.Add (owner, new Row<ElementType, uint> (type, signature));
+ }
+ }
+
+ public object ReadConstant (IConstantProvider owner)
+ {
+ InitializeConstants ();
+
+ Row<ElementType, uint> row;
+ if (!metadata.Constants.TryGetValue (owner.MetadataToken, out row))
+ return Mixin.NoValue;
+
+ metadata.Constants.Remove (owner.MetadataToken);
+
+ switch (row.Col1) {
+ case ElementType.Class:
+ case ElementType.Object:
+ return null;
+ case ElementType.String:
+ return ReadConstantString (ReadBlob (row.Col2));
+ default:
+ return ReadConstantPrimitive (row.Col1, row.Col2);
+ }
+ }
+
+ static string ReadConstantString (byte [] blob)
+ {
+ var length = blob.Length;
+ if ((length & 1) == 1)
+ length--;
+
+ return Encoding.Unicode.GetString (blob, 0, length);
+ }
+
+ object ReadConstantPrimitive (ElementType type, uint signature)
+ {
+ var reader = ReadSignature (signature);
+ return reader.ReadConstantSignature (type);
+ }
+
+ void InitializeCustomAttributes ()
+ {
+ if (metadata.CustomAttributes != null)
+ return;
+
+ metadata.CustomAttributes = InitializeRanges (
+ Table.CustomAttribute, () => {
+ var next = ReadMetadataToken (CodedIndex.HasCustomAttribute);
+ ReadMetadataToken (CodedIndex.CustomAttributeType);
+ ReadBlobIndex ();
+ return next;
+ });
+ }
+
+ public bool HasCustomAttributes (ICustomAttributeProvider owner)
+ {
+ InitializeCustomAttributes ();
+
+ Range range;
+ if (!metadata.TryGetCustomAttributeRange (owner, out range))
+ return false;
+
+ return range.Length > 0;
+ }
+
+ public Collection<CustomAttribute> ReadCustomAttributes (ICustomAttributeProvider owner)
+ {
+ InitializeCustomAttributes ();
+
+ Range range;
+ if (!metadata.TryGetCustomAttributeRange (owner, out range)
+ || !MoveTo (Table.CustomAttribute, range.Start))
+ return new Collection<CustomAttribute> ();
+
+ var custom_attributes = new Collection<CustomAttribute> ((int) range.Length);
+
+ for (int i = 0; i < range.Length; i++) {
+ ReadMetadataToken (CodedIndex.HasCustomAttribute);
+
+ var constructor = (MethodReference) LookupToken (
+ ReadMetadataToken (CodedIndex.CustomAttributeType));
+
+ var signature = ReadBlobIndex ();
+
+ custom_attributes.Add (new CustomAttribute (signature, constructor));
+ }
+
+ metadata.RemoveCustomAttributeRange (owner);
+
+ return custom_attributes;
+ }
+
+ public byte [] ReadCustomAttributeBlob (uint signature)
+ {
+ return ReadBlob (signature);
+ }
+
+ public void ReadCustomAttributeSignature (CustomAttribute attribute)
+ {
+ var reader = ReadSignature (attribute.signature);
+ if (reader.ReadUInt16 () != 0x0001)
+ throw new InvalidOperationException ();
+
+ var constructor = attribute.Constructor;
+ if (constructor.HasParameters)
+ reader.ReadCustomAttributeConstructorArguments (attribute, constructor.Parameters);
+
+ if (!reader.CanReadMore ())
+ return;
+
+ var named = reader.ReadUInt16 ();
+
+ if (named == 0)
+ return;
+
+ reader.ReadCustomAttributeNamedArguments (named, ref attribute.fields, ref attribute.properties);
+ }
+
+ void InitializeMarshalInfos ()
+ {
+ if (metadata.FieldMarshals != null)
+ return;
+
+ var length = MoveTo (Table.FieldMarshal);
+
+ var marshals = metadata.FieldMarshals = new Dictionary<MetadataToken, uint> (length);
+
+ for (int i = 0; i < length; i++) {
+ var token = ReadMetadataToken (CodedIndex.HasFieldMarshal);
+ var signature = ReadBlobIndex ();
+ if (token.RID == 0)
+ continue;
+
+ marshals.Add (token, signature);
+ }
+ }
+
+ public bool HasMarshalInfo (IMarshalInfoProvider owner)
+ {
+ InitializeMarshalInfos ();
+
+ return metadata.FieldMarshals.ContainsKey (owner.MetadataToken);
+ }
+
+ public MarshalInfo ReadMarshalInfo (IMarshalInfoProvider owner)
+ {
+ InitializeMarshalInfos ();
+
+ uint signature;
+ if (!metadata.FieldMarshals.TryGetValue (owner.MetadataToken, out signature))
+ return null;
+
+ var reader = ReadSignature (signature);
+
+ metadata.FieldMarshals.Remove (owner.MetadataToken);
+
+ return reader.ReadMarshalInfo ();
+ }
+
+ void InitializeSecurityDeclarations ()
+ {
+ if (metadata.SecurityDeclarations != null)
+ return;
+
+ metadata.SecurityDeclarations = InitializeRanges (
+ Table.DeclSecurity, () => {
+ ReadUInt16 ();
+ var next = ReadMetadataToken (CodedIndex.HasDeclSecurity);
+ ReadBlobIndex ();
+ return next;
+ });
+ }
+
+ public bool HasSecurityDeclarations (ISecurityDeclarationProvider owner)
+ {
+ InitializeSecurityDeclarations ();
+
+ Range range;
+ if (!metadata.TryGetSecurityDeclarationRange (owner, out range))
+ return false;
+
+ return range.Length > 0;
+ }
+
+ public Collection<SecurityDeclaration> ReadSecurityDeclarations (ISecurityDeclarationProvider owner)
+ {
+ InitializeSecurityDeclarations ();
+
+ Range range;
+ if (!metadata.TryGetSecurityDeclarationRange (owner, out range)
+ || !MoveTo (Table.DeclSecurity, range.Start))
+ return new Collection<SecurityDeclaration> ();
+
+ var security_declarations = new Collection<SecurityDeclaration> ((int) range.Length);
+
+ for (int i = 0; i < range.Length; i++) {
+ var action = (SecurityAction) ReadUInt16 ();
+ ReadMetadataToken (CodedIndex.HasDeclSecurity);
+ var signature = ReadBlobIndex ();
+
+ security_declarations.Add (new SecurityDeclaration (action, signature, module));
+ }
+
+ metadata.RemoveSecurityDeclarationRange (owner);
+
+ return security_declarations;
+ }
+
+ public byte [] ReadSecurityDeclarationBlob (uint signature)
+ {
+ return ReadBlob (signature);
+ }
+
+ public void ReadSecurityDeclarationSignature (SecurityDeclaration declaration)
+ {
+ var signature = declaration.signature;
+ var reader = ReadSignature (signature);
+
+ if (reader.buffer [reader.position] != '.') {
+ ReadXmlSecurityDeclaration (signature, declaration);
+ return;
+ }
+
+ reader.ReadByte ();
+ var count = reader.ReadCompressedUInt32 ();
+ var attributes = new Collection<SecurityAttribute> ((int) count);
+
+ for (int i = 0; i < count; i++)
+ attributes.Add (reader.ReadSecurityAttribute ());
+
+ declaration.security_attributes = attributes;
+ }
+
+ void ReadXmlSecurityDeclaration (uint signature, SecurityDeclaration declaration)
+ {
+ var blob = ReadBlob (signature);
+ var attributes = new Collection<SecurityAttribute> (1);
+
+ var attribute = new SecurityAttribute (
+ module.TypeSystem.LookupType ("System.Security.Permissions", "PermissionSetAttribute"));
+
+ attribute.properties = new Collection<CustomAttributeNamedArgument> (1);
+ attribute.properties.Add (
+ new CustomAttributeNamedArgument (
+ "XML",
+ new CustomAttributeArgument (
+ module.TypeSystem.String,
+ Encoding.Unicode.GetString (blob, 0, blob.Length))));
+
+ attributes.Add (attribute);
+
+ declaration.security_attributes = attributes;
+ }
+
+ public Collection<ExportedType> ReadExportedTypes ()
+ {
+ var length = MoveTo (Table.ExportedType);
+ if (length == 0)
+ return new Collection<ExportedType> ();
+
+ var exported_types = new Collection<ExportedType> (length);
+
+ for (int i = 1; i <= length; i++) {
+ var attributes = (TypeAttributes) ReadUInt32 ();
+ var identifier = ReadUInt32 ();
+ var name = ReadString ();
+ var @namespace = ReadString ();
+ var implementation = ReadMetadataToken (CodedIndex.Implementation);
+
+ ExportedType declaring_type = null;
+ IMetadataScope scope = null;
+
+ switch (implementation.TokenType) {
+ case TokenType.AssemblyRef:
+ case TokenType.File:
+ scope = GetExportedTypeScope (implementation);
+ break;
+ case TokenType.ExportedType:
+ // FIXME: if the table is not properly sorted
+ declaring_type = exported_types [(int) implementation.RID - 1];
+ break;
+ }
+
+ var exported_type = new ExportedType (@namespace, name, scope) {
+ Attributes = attributes,
+ Identifier = (int) identifier,
+ DeclaringType = declaring_type,
+ };
+ exported_type.token = new MetadataToken (TokenType.ExportedType, i);
+
+ exported_types.Add (exported_type);
+ }
+
+ return exported_types;
+ }
+
+ IMetadataScope GetExportedTypeScope (MetadataToken token)
+ {
+ switch (token.TokenType) {
+ case TokenType.AssemblyRef:
+ return module.AssemblyReferences [(int) token.RID - 1];
+ case TokenType.File:
+ var position = this.position;
+ var reference = GetModuleReferenceFromFile (token);
+ this.position = position;
+
+ if (reference == null)
+ throw new NotSupportedException ();
+
+ return reference;
+ default:
+ throw new NotSupportedException ();
+ }
+ }
+
+ ModuleReference GetModuleReferenceFromFile (MetadataToken token)
+ {
+ if (!MoveTo (Table.File, token.RID))
+ return null;
+
+ ReadUInt32 ();
+ var file_name = ReadString ();
+ var modules = module.ModuleReferences;
+
+ ModuleReference reference = null;
+ for (int i = 0; i < modules.Count; i++) {
+ var module_reference = modules [i];
+ if (module_reference.Name != file_name)
+ continue;
+
+ reference = module_reference;
+ break;
+ }
+
+ return reference;
+ }
+
+ static void InitializeCollection (object o)
+ {
+ }
+ }
+
+ sealed class SignatureReader : ByteBuffer {
+
+ readonly MetadataReader reader;
+ readonly uint start, sig_length;
+
+ TypeSystem TypeSystem {
+ get { return reader.module.TypeSystem; }
+ }
+
+ public SignatureReader (uint blob, MetadataReader reader)
+ : base (reader.buffer)
+ {
+ this.reader = reader;
+
+ MoveToBlob (blob);
+
+ this.sig_length = ReadCompressedUInt32 ();
+ this.start = (uint) position;
+ }
+
+ void MoveToBlob (uint blob)
+ {
+ position = (int) (reader.image.BlobHeap.Offset + blob);
+ }
+
+ MetadataToken ReadTypeTokenSignature ()
+ {
+ return CodedIndex.TypeDefOrRef.GetMetadataToken (ReadCompressedUInt32 ());
+ }
+
+ GenericParameter GetGenericParameter (GenericParameterType type, uint var)
+ {
+ var context = reader.context;
+
+ if (context == null)
+ throw new NotSupportedException ();
+
+ IGenericParameterProvider provider;
+
+ switch (type) {
+ case GenericParameterType.Type:
+ provider = context.Type;
+ break;
+ case GenericParameterType.Method:
+ provider = context.Method;
+ break;
+ default:
+ throw new NotSupportedException ();
+ }
+
+ int index = (int) var;
+
+ if (!context.IsDefinition)
+ CheckGenericContext (provider, index);
+
+ return provider.GenericParameters [index];
+ }
+
+ static void CheckGenericContext (IGenericParameterProvider owner, int index)
+ {
+ var owner_parameters = owner.GenericParameters;
+
+ for (int i = owner_parameters.Count; i <= index; i++)
+ owner_parameters.Add (new GenericParameter (owner));
+ }
+
+ public void ReadGenericInstanceSignature (IGenericParameterProvider provider, IGenericInstance instance)
+ {
+ var arity = ReadCompressedUInt32 ();
+
+ if (!provider.IsDefinition)
+ CheckGenericContext (provider, (int) arity - 1);
+
+ var instance_arguments = instance.GenericArguments;
+
+ for (int i = 0; i < arity; i++)
+ instance_arguments.Add (ReadTypeSignature ());
+ }
+
+ ArrayType ReadArrayTypeSignature ()
+ {
+ var array = new ArrayType (ReadTypeSignature ());
+
+ var rank = ReadCompressedUInt32 ();
+
+ var sizes = new uint [ReadCompressedUInt32 ()];
+ for (int i = 0; i < sizes.Length; i++)
+ sizes [i] = ReadCompressedUInt32 ();
+
+ var low_bounds = new int [ReadCompressedUInt32 ()];
+ for (int i = 0; i < low_bounds.Length; i++)
+ low_bounds [i] = ReadCompressedInt32 ();
+
+ array.Dimensions.Clear ();
+
+ for (int i = 0; i < rank; i++) {
+ int? lower = null, upper = null;
+
+ if (i < low_bounds.Length)
+ lower = low_bounds [i];
+
+ if (i < sizes.Length)
+ upper = lower + (int) sizes [i] - 1;
+
+ array.Dimensions.Add (new ArrayDimension (lower, upper));
+ }
+
+ return array;
+ }
+
+ TypeReference GetTypeDefOrRef (MetadataToken token)
+ {
+ return reader.GetTypeDefOrRef (token);
+ }
+
+ public TypeReference ReadTypeSignature ()
+ {
+ return ReadTypeSignature ((ElementType) ReadByte ());
+ }
+
+ TypeReference ReadTypeSignature (ElementType etype)
+ {
+ switch (etype) {
+ case ElementType.ValueType: {
+ var value_type = GetTypeDefOrRef (ReadTypeTokenSignature ());
+ value_type.IsValueType = true;
+ return value_type;
+ }
+ case ElementType.Class:
+ return GetTypeDefOrRef (ReadTypeTokenSignature ());
+ case ElementType.Ptr:
+ return new PointerType (ReadTypeSignature ());
+ case ElementType.FnPtr: {
+ var fptr = new FunctionPointerType ();
+ ReadMethodSignature (fptr);
+ return fptr;
+ }
+ case ElementType.ByRef:
+ return new ByReferenceType (ReadTypeSignature ());
+ case ElementType.Pinned:
+ return new PinnedType (ReadTypeSignature ());
+ case ElementType.SzArray:
+ return new ArrayType (ReadTypeSignature ());
+ case ElementType.Array:
+ return ReadArrayTypeSignature ();
+ case ElementType.CModOpt:
+ return new OptionalModifierType (
+ GetTypeDefOrRef (ReadTypeTokenSignature ()), ReadTypeSignature ());
+ case ElementType.CModReqD:
+ return new RequiredModifierType (
+ GetTypeDefOrRef (ReadTypeTokenSignature ()), ReadTypeSignature ());
+ case ElementType.Sentinel:
+ return new SentinelType (ReadTypeSignature ());
+ case ElementType.Var:
+ return GetGenericParameter (GenericParameterType.Type, ReadCompressedUInt32 ());
+ case ElementType.MVar:
+ return GetGenericParameter (GenericParameterType.Method, ReadCompressedUInt32 ());
+ case ElementType.GenericInst: {
+ var is_value_type = ReadByte () == (byte) ElementType.ValueType;
+ var element_type = GetTypeDefOrRef (ReadTypeTokenSignature ());
+ var generic_instance = new GenericInstanceType (element_type);
+
+ ReadGenericInstanceSignature (element_type, generic_instance);
+
+ if (is_value_type) {
+ generic_instance.IsValueType = true;
+ element_type.GetElementType ().IsValueType = true;
+ }
+
+ return generic_instance;
+ }
+ case ElementType.Object: return TypeSystem.Object;
+ case ElementType.Void: return TypeSystem.Void;
+ case ElementType.TypedByRef: return TypeSystem.TypedReference;
+ case ElementType.I: return TypeSystem.IntPtr;
+ case ElementType.U: return TypeSystem.UIntPtr;
+ default: return GetPrimitiveType (etype);
+ }
+ }
+
+ public void ReadMethodSignature (IMethodSignature method)
+ {
+ var calling_convention = ReadByte ();
+ 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)
+ reader.context = generic_context;
+
+ if ((calling_convention & 0x10) != 0) {
+ var arity = ReadCompressedUInt32 ();
+
+ if (generic_context != null && !generic_context.IsDefinition)
+ CheckGenericContext (generic_context, (int) arity -1 );
+ }
+
+ // TODO: more call_conv
+
+ var param_count = ReadCompressedUInt32 ();
+
+ method.MethodReturnType.ReturnType = ReadTypeSignature ();
+
+ if (param_count == 0)
+ return;
+
+ Collection<ParameterDefinition> parameters;
+
+ var method_ref = method as MethodReference;
+ if (method_ref != null)
+ parameters = method_ref.parameters = new ParameterDefinitionCollection (method, (int) param_count);
+ else
+ parameters = method.Parameters;
+
+ for (int i = 0; i < param_count; i++)
+ parameters.Add (new ParameterDefinition (ReadTypeSignature ()));
+ }
+
+ public object ReadConstantSignature (ElementType type)
+ {
+ return ReadPrimitiveValue (type);
+ }
+
+ public void ReadCustomAttributeConstructorArguments (CustomAttribute attribute, Collection<ParameterDefinition> parameters)
+ {
+ var count = parameters.Count;
+ if (count == 0)
+ return;
+
+ attribute.arguments = new Collection<CustomAttributeArgument> (count);
+
+ for (int i = 0; i < count; i++)
+ attribute.arguments.Add (
+ ReadCustomAttributeFixedArgument (parameters [i].ParameterType));
+ }
+
+ CustomAttributeArgument ReadCustomAttributeFixedArgument (TypeReference type)
+ {
+ if (type.IsArray)
+ return ReadCustomAttributeFixedArrayArgument ((ArrayType) type);
+
+ return ReadCustomAttributeElement (type);
+ }
+
+ public void ReadCustomAttributeNamedArguments (ushort count, ref Collection<CustomAttributeNamedArgument> fields, ref Collection<CustomAttributeNamedArgument> properties)
+ {
+ for (int i = 0; i < count; i++)
+ ReadCustomAttributeNamedArgument (ref fields, ref properties);
+ }
+
+ void ReadCustomAttributeNamedArgument (ref Collection<CustomAttributeNamedArgument> fields, ref Collection<CustomAttributeNamedArgument> properties)
+ {
+ var kind = ReadByte ();
+ var type = ReadCustomAttributeFieldOrPropType ();
+ var name = ReadUTF8String ();
+
+ Collection<CustomAttributeNamedArgument> container;
+ switch (kind) {
+ case 0x53:
+ container = GetCustomAttributeNamedArgumentCollection (ref fields);
+ break;
+ case 0x54:
+ container = GetCustomAttributeNamedArgumentCollection (ref properties);
+ break;
+ default:
+ throw new NotSupportedException ();
+ }
+
+ container.Add (new CustomAttributeNamedArgument (name, ReadCustomAttributeFixedArgument (type)));
+ }
+
+ static Collection<CustomAttributeNamedArgument> GetCustomAttributeNamedArgumentCollection (ref Collection<CustomAttributeNamedArgument> collection)
+ {
+ if (collection != null)
+ return collection;
+
+ return collection = new Collection<CustomAttributeNamedArgument> ();
+ }
+
+ CustomAttributeArgument ReadCustomAttributeFixedArrayArgument (ArrayType type)
+ {
+ var length = ReadUInt32 ();
+
+ if (length == 0xffffffff)
+ return new CustomAttributeArgument (type, null);
+
+ if (length == 0)
+ return new CustomAttributeArgument (type, Empty<CustomAttributeArgument>.Array);
+
+ var arguments = new CustomAttributeArgument [length];
+ var element_type = type.ElementType;
+
+ for (int i = 0; i < length; i++)
+ arguments [i] = ReadCustomAttributeElement (element_type);
+
+ return new CustomAttributeArgument (type, arguments);
+ }
+
+ CustomAttributeArgument ReadCustomAttributeElement (TypeReference type)
+ {
+ if (type.IsArray)
+ return ReadCustomAttributeFixedArrayArgument ((ArrayType) type);
+
+ if (type.etype == ElementType.Object)
+ return ReadCustomAttributeElement (ReadCustomAttributeFieldOrPropType ());
+
+ return new CustomAttributeArgument (type, ReadCustomAttributeElementValue (type));
+ }
+
+ object ReadCustomAttributeElementValue (TypeReference type)
+ {
+ var etype = type.etype;
+
+ switch (etype) {
+ case ElementType.String:
+ return ReadUTF8String ();
+ case ElementType.None:
+ if (type.IsTypeOf ("System", "Type"))
+ return ReadTypeReference ();
+
+ return ReadCustomAttributeEnum (type);
+ default:
+ return ReadPrimitiveValue (etype);
+ }
+ }
+
+ object ReadPrimitiveValue (ElementType type)
+ {
+ switch (type) {
+ case ElementType.Boolean:
+ return ReadByte () == 1;
+ case ElementType.I1:
+ return (sbyte) ReadByte ();
+ case ElementType.U1:
+ return ReadByte ();
+ case ElementType.Char:
+ return (char) ReadUInt16 ();
+ case ElementType.I2:
+ return ReadInt16 ();
+ case ElementType.U2:
+ return ReadUInt16 ();
+ case ElementType.I4:
+ return ReadInt32 ();
+ case ElementType.U4:
+ return ReadUInt32 ();
+ case ElementType.I8:
+ return ReadInt64 ();
+ case ElementType.U8:
+ return ReadUInt64 ();
+ case ElementType.R4:
+ return ReadSingle ();
+ case ElementType.R8:
+ return ReadDouble ();
+ default:
+ throw new NotImplementedException (type.ToString ());
+ }
+ }
+
+ TypeReference GetPrimitiveType (ElementType etype)
+ {
+ switch (etype) {
+ case ElementType.Boolean:
+ return TypeSystem.Boolean;
+ case ElementType.Char:
+ return TypeSystem.Char;
+ case ElementType.I1:
+ return TypeSystem.SByte;
+ case ElementType.U1:
+ return TypeSystem.Byte;
+ case ElementType.I2:
+ return TypeSystem.Int16;
+ case ElementType.U2:
+ return TypeSystem.UInt16;
+ case ElementType.I4:
+ return TypeSystem.Int32;
+ case ElementType.U4:
+ return TypeSystem.UInt32;
+ case ElementType.I8:
+ return TypeSystem.Int64;
+ case ElementType.U8:
+ return TypeSystem.UInt64;
+ case ElementType.R4:
+ return TypeSystem.Single;
+ case ElementType.R8:
+ return TypeSystem.Double;
+ case ElementType.String:
+ return TypeSystem.String;
+ default:
+ throw new NotImplementedException (etype.ToString ());
+ }
+ }
+
+ TypeReference ReadCustomAttributeFieldOrPropType ()
+ {
+ var etype = (ElementType) ReadByte ();
+
+ switch (etype) {
+ case ElementType.Boxed:
+ return TypeSystem.Object;
+ case ElementType.SzArray:
+ return new ArrayType (ReadCustomAttributeFieldOrPropType ());
+ case ElementType.Enum:
+ return ReadTypeReference ();
+ case ElementType.Type:
+ return TypeSystem.LookupType ("System", "Type");
+ default:
+ return GetPrimitiveType (etype);
+ }
+ }
+
+ public TypeReference ReadTypeReference ()
+ {
+ return TypeParser.ParseType (reader.module, ReadUTF8String ());
+ }
+
+ object ReadCustomAttributeEnum (TypeReference enum_type)
+ {
+ var type = enum_type.CheckedResolve ();
+ if (!type.IsEnum)
+ throw new ArgumentException ();
+
+ return ReadCustomAttributeElementValue (type.GetEnumUnderlyingType ());
+ }
+
+ public SecurityAttribute ReadSecurityAttribute ()
+ {
+ var attribute = new SecurityAttribute (ReadTypeReference ());
+
+ ReadCompressedUInt32 ();
+
+ ReadCustomAttributeNamedArguments (
+ (ushort) ReadCompressedUInt32 (),
+ ref attribute.fields,
+ ref attribute.properties);
+
+ return attribute;
+ }
+
+ public MarshalInfo ReadMarshalInfo ()
+ {
+ var native = ReadNativeType ();
+ switch (native) {
+ case NativeType.Array: {
+ var array = new ArrayMarshalInfo ();
+ if (CanReadMore ())
+ array.element_type = ReadNativeType ();
+ if (CanReadMore ())
+ array.size_parameter_index = (int) ReadCompressedUInt32 ();
+ if (CanReadMore ())
+ array.size = (int) ReadCompressedUInt32 ();
+ if (CanReadMore ())
+ array.size_parameter_multiplier = (int) ReadCompressedUInt32 ();
+ return array;
+ }
+ case NativeType.SafeArray: {
+ var array = new SafeArrayMarshalInfo ();
+ if (CanReadMore ())
+ array.element_type = ReadVariantType ();
+ return array;
+ }
+ case NativeType.FixedArray: {
+ var array = new FixedArrayMarshalInfo ();
+ if (CanReadMore ())
+ array.size = (int) ReadCompressedUInt32 ();
+ if (CanReadMore ())
+ array.element_type = ReadNativeType ();
+ return array;
+ }
+ case NativeType.FixedSysString: {
+ var sys_string = new FixedSysStringMarshalInfo ();
+ if (CanReadMore ())
+ sys_string.size = (int) ReadCompressedUInt32 ();
+ return sys_string;
+ }
+ case NativeType.CustomMarshaler: {
+ var marshaler = new CustomMarshalInfo ();
+ var guid_value = ReadUTF8String ();
+ marshaler.guid = !string.IsNullOrEmpty (guid_value) ? new Guid (guid_value) : Guid.Empty;
+ marshaler.unmanaged_type = ReadUTF8String ();
+ marshaler.managed_type = ReadTypeReference ();
+ marshaler.cookie = ReadUTF8String ();
+ return marshaler;
+ }
+ default:
+ return new MarshalInfo (native);
+ }
+ }
+
+ NativeType ReadNativeType ()
+ {
+ return (NativeType) ReadByte ();
+ }
+
+ VariantType ReadVariantType ()
+ {
+ return (VariantType) ReadByte ();
+ }
+
+ string ReadUTF8String ()
+ {
+ if (buffer [position] == 0xff) {
+ position++;
+ return null;
+ }
+
+ var length = (int) ReadCompressedUInt32 ();
+ if (length == 0)
+ return string.Empty;
+
+ var @string = Encoding.UTF8.GetString (buffer, position,
+ buffer [position + length - 1] == 0 ? length - 1 : length);
+
+ position += length;
+ return @string;
+ }
+
+ public bool CanReadMore ()
+ {
+ return position - start < sig_length;
+ }
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyWriter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyWriter.cs
new file mode 100644
index 0000000..a60004b
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyWriter.cs
@@ -0,0 +1,2522 @@
+//
+// AssemblyWriter.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+using Mono.Collections.Generic;
+using Mono.Cecil.Cil;
+using Mono.Cecil.Metadata;
+using Mono.Cecil.PE;
+
+using RVA = System.UInt32;
+using RID = System.UInt32;
+using CodedRID = System.UInt32;
+using StringIndex = System.UInt32;
+using BlobIndex = System.UInt32;
+
+namespace Mono.Cecil {
+
+#if !READ_ONLY
+
+ using TypeRefRow = Row<CodedRID, StringIndex, StringIndex>;
+ using TypeDefRow = Row<TypeAttributes, StringIndex, StringIndex, CodedRID, RID, RID>;
+ using FieldRow = Row<FieldAttributes, StringIndex, BlobIndex>;
+ using MethodRow = Row<RVA, MethodImplAttributes, MethodAttributes, StringIndex, BlobIndex, RID>;
+ using ParamRow = Row<ParameterAttributes, ushort, StringIndex>;
+ using InterfaceImplRow = Row<uint, CodedRID>;
+ using MemberRefRow = Row<CodedRID, StringIndex, BlobIndex>;
+ using ConstantRow = Row<ElementType, CodedRID, BlobIndex>;
+ using CustomAttributeRow = Row<CodedRID, CodedRID, BlobIndex>;
+ using FieldMarshalRow = Row<CodedRID, BlobIndex>;
+ using DeclSecurityRow = Row<SecurityAction, CodedRID, BlobIndex>;
+ using ClassLayoutRow = Row<ushort, uint, RID>;
+ using FieldLayoutRow = Row<uint, RID>;
+ using EventMapRow = Row<RID, RID>;
+ using EventRow = Row<EventAttributes, StringIndex, CodedRID>;
+ using PropertyMapRow = Row<RID, RID>;
+ using PropertyRow = Row<PropertyAttributes, StringIndex, BlobIndex>;
+ using MethodSemanticsRow = Row<MethodSemanticsAttributes, RID, CodedRID>;
+ using MethodImplRow = Row<RID, CodedRID, CodedRID>;
+ using ImplMapRow = Row<PInvokeAttributes, CodedRID, StringIndex, RID>;
+ using FieldRVARow = Row<RVA, RID>;
+ using AssemblyRow = Row<AssemblyHashAlgorithm, ushort, ushort, ushort, ushort, AssemblyAttributes, uint, uint, uint>;
+ using AssemblyRefRow = Row<ushort, ushort, ushort, ushort, AssemblyAttributes, uint, uint, uint, uint>;
+ using FileRow = Row<FileAttributes, StringIndex, BlobIndex>;
+ using ExportedTypeRow = Row<TypeAttributes, uint, StringIndex, StringIndex, CodedRID>;
+ using ManifestResourceRow = Row<uint, ManifestResourceAttributes, StringIndex, CodedRID>;
+ using NestedClassRow = Row<RID, RID>;
+ using GenericParamRow = Row<ushort, GenericParameterAttributes, CodedRID, StringIndex>;
+ using MethodSpecRow = Row<CodedRID, BlobIndex>;
+ using GenericParamConstraintRow = Row<RID, CodedRID>;
+
+ static class ModuleWriter {
+
+ public static void WriteModuleTo (ModuleDefinition module, Stream stream, WriterParameters parameters)
+ {
+ if ((module.Attributes & ModuleAttributes.ILOnly) == 0)
+ throw new ArgumentException ();
+
+ if (module.HasImage && module.ReadingMode == ReadingMode.Deferred)
+ ImmediateModuleReader.ReadModule (module);
+
+ module.MetadataSystem.Clear ();
+
+ var name = module.assembly != null ? module.assembly.Name : null;
+ var fq_name = stream.GetFullyQualifiedName ();
+ var symbol_writer_provider = parameters.SymbolWriterProvider;
+ if (symbol_writer_provider == null && parameters.WriteSymbols)
+ symbol_writer_provider = SymbolProvider.GetPlatformWriterProvider ();
+ var symbol_writer = GetSymbolWriter (module, fq_name, symbol_writer_provider);
+
+#if !SILVERLIGHT && !CF
+ if (parameters.StrongNameKeyPair != null && name != null)
+ name.PublicKey = parameters.StrongNameKeyPair.PublicKey;
+#endif
+
+ if (name != null && name.HasPublicKey)
+ module.Attributes |= ModuleAttributes.StrongNameSigned;
+
+ var metadata = new MetadataBuilder (module, fq_name,
+ symbol_writer_provider, symbol_writer);
+
+ BuildMetadata (module, metadata);
+
+ if (module.SymbolReader != null)
+ module.SymbolReader.Dispose ();
+
+ var writer = ImageWriter.CreateWriter (module, metadata, stream);
+
+ writer.WriteImage ();
+
+#if !SILVERLIGHT && !CF
+ if (parameters.StrongNameKeyPair != null)
+ CryptoService.StrongName (stream, writer, parameters.StrongNameKeyPair);
+#endif
+ if (symbol_writer != null)
+ symbol_writer.Dispose ();
+ }
+
+ static void BuildMetadata (ModuleDefinition module, MetadataBuilder metadata)
+ {
+ if (!module.HasImage) {
+ metadata.BuildMetadata ();
+ return;
+ }
+
+ module.Read (metadata, (builder, _) => {
+ builder.BuildMetadata ();
+ return builder;
+ });
+ }
+
+ static ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fq_name, ISymbolWriterProvider symbol_writer_provider)
+ {
+ if (symbol_writer_provider == null)
+ return null;
+
+ return symbol_writer_provider.GetSymbolWriter (module, fq_name);
+ }
+ }
+
+ abstract class MetadataTable {
+
+ public abstract int Length { get; }
+
+ public bool IsLarge {
+ get { return Length > 65535; }
+ }
+
+ public abstract void Write (TableHeapBuffer buffer);
+ public abstract void Sort ();
+ }
+
+ abstract class OneRowTable<TRow> : MetadataTable where TRow : struct {
+
+ internal TRow row;
+
+ public sealed override int Length {
+ get { return 1; }
+ }
+
+ public sealed override void Sort ()
+ {
+ }
+ }
+
+ abstract class MetadataTable<TRow> : MetadataTable where TRow : struct {
+
+ internal TRow [] rows = new TRow [2];
+ internal int length;
+
+ public sealed override int Length {
+ get { return length; }
+ }
+
+ public int AddRow (TRow row)
+ {
+ if (rows.Length == length)
+ Grow ();
+
+ rows [length++] = row;
+ return length;
+ }
+
+ void Grow ()
+ {
+ var rows = new TRow [this.rows.Length * 2];
+ Array.Copy (this.rows, rows, this.rows.Length);
+ this.rows = rows;
+ }
+
+ public override void Sort ()
+ {
+ }
+ }
+
+ abstract class SortedTable<TRow> : MetadataTable<TRow>, IComparer<TRow> where TRow : struct {
+
+ public sealed override void Sort ()
+ {
+ Array.Sort (rows, 0, length, this);
+ }
+
+ protected int Compare (uint x, uint y)
+ {
+ return x == y ? 0 : x > y ? 1 : -1;
+ }
+
+ public abstract int Compare (TRow x, TRow y);
+ }
+
+ sealed class ModuleTable : OneRowTable<uint> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ buffer.WriteUInt16 (0); // Generation
+ buffer.WriteString (row); // Name
+ buffer.WriteUInt16 (1); // Mvid
+ buffer.WriteUInt16 (0); // EncId
+ buffer.WriteUInt16 (0); // EncBaseId
+ }
+ }
+
+ sealed class TypeRefTable : MetadataTable<TypeRefRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteCodedRID (
+ rows [i].Col1, CodedIndex.ResolutionScope); // Scope
+ buffer.WriteString (rows [i].Col2); // Name
+ buffer.WriteString (rows [i].Col3); // Namespace
+ }
+ }
+ }
+
+ sealed class TypeDefTable : MetadataTable<TypeDefRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt32 ((uint) rows [i].Col1); // Attributes
+ buffer.WriteString (rows [i].Col2); // Name
+ buffer.WriteString (rows [i].Col3); // Namespace
+ buffer.WriteCodedRID (
+ rows [i].Col4, CodedIndex.TypeDefOrRef); // Extends
+ buffer.WriteRID (rows [i].Col5, Table.Field); // FieldList
+ buffer.WriteRID (rows [i].Col6, Table.Method); // MethodList
+ }
+ }
+ }
+
+ sealed class FieldTable : MetadataTable<FieldRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt16 ((ushort) rows [i].Col1); // Attributes
+ buffer.WriteString (rows [i].Col2); // Name
+ buffer.WriteBlob (rows [i].Col3); // Signature
+ }
+ }
+ }
+
+ sealed class MethodTable : MetadataTable<MethodRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt32 (rows [i].Col1); // RVA
+ buffer.WriteUInt16 ((ushort) rows [i].Col2); // ImplFlags
+ buffer.WriteUInt16 ((ushort) rows [i].Col3); // Flags
+ buffer.WriteString (rows [i].Col4); // Name
+ buffer.WriteBlob (rows [i].Col5); // Signature
+ buffer.WriteRID (rows [i].Col6, Table.Param); // ParamList
+ }
+ }
+ }
+
+ sealed class ParamTable : MetadataTable<ParamRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt16 ((ushort) rows [i].Col1); // Attributes
+ buffer.WriteUInt16 (rows [i].Col2); // Sequence
+ buffer.WriteString (rows [i].Col3); // Name
+ }
+ }
+ }
+
+ sealed class InterfaceImplTable : MetadataTable<InterfaceImplRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteRID (rows [i].Col1, Table.TypeDef); // Class
+ buffer.WriteCodedRID (rows [i].Col2, CodedIndex.TypeDefOrRef); // Interface
+ }
+ }
+
+ /*public override int Compare (InterfaceImplRow x, InterfaceImplRow y)
+ {
+ return (int) (x.Col1 == y.Col1 ? y.Col2 - x.Col2 : x.Col1 - y.Col1);
+ }*/
+ }
+
+ sealed class MemberRefTable : MetadataTable<MemberRefRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteCodedRID (rows [i].Col1, CodedIndex.MemberRefParent);
+ buffer.WriteString (rows [i].Col2);
+ buffer.WriteBlob (rows [i].Col3);
+ }
+ }
+ }
+
+ sealed class ConstantTable : SortedTable<ConstantRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt16 ((ushort) rows [i].Col1);
+ buffer.WriteCodedRID (rows [i].Col2, CodedIndex.HasConstant);
+ buffer.WriteBlob (rows [i].Col3);
+ }
+ }
+
+ public override int Compare (ConstantRow x, ConstantRow y)
+ {
+ return Compare (x.Col2, y.Col2);
+ }
+ }
+
+ sealed class CustomAttributeTable : SortedTable<CustomAttributeRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteCodedRID (rows [i].Col1, CodedIndex.HasCustomAttribute); // Parent
+ buffer.WriteCodedRID (rows [i].Col2, CodedIndex.CustomAttributeType); // Type
+ buffer.WriteBlob (rows [i].Col3);
+ }
+ }
+
+ public override int Compare (CustomAttributeRow x, CustomAttributeRow y)
+ {
+ return Compare (x.Col1, y.Col1);
+ }
+ }
+
+ sealed class FieldMarshalTable : SortedTable<FieldMarshalRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteCodedRID (rows [i].Col1, CodedIndex.HasFieldMarshal);
+ buffer.WriteBlob (rows [i].Col2);
+ }
+ }
+
+ public override int Compare (FieldMarshalRow x, FieldMarshalRow y)
+ {
+ return Compare (x.Col1, y.Col1);
+ }
+ }
+
+ sealed class DeclSecurityTable : SortedTable<DeclSecurityRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt16 ((ushort) rows [i].Col1);
+ buffer.WriteCodedRID (rows [i].Col2, CodedIndex.HasDeclSecurity);
+ buffer.WriteBlob (rows [i].Col3);
+ }
+ }
+
+ public override int Compare (DeclSecurityRow x, DeclSecurityRow y)
+ {
+ return Compare (x.Col2, y.Col2);
+ }
+ }
+
+ sealed class ClassLayoutTable : SortedTable<ClassLayoutRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt16 (rows [i].Col1); // PackingSize
+ buffer.WriteUInt32 (rows [i].Col2); // ClassSize
+ buffer.WriteRID (rows [i].Col3, Table.TypeDef); // Parent
+ }
+ }
+
+ public override int Compare (ClassLayoutRow x, ClassLayoutRow y)
+ {
+ return Compare (x.Col3, y.Col3);
+ }
+ }
+
+ sealed class FieldLayoutTable : SortedTable<FieldLayoutRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt32 (rows [i].Col1); // Offset
+ buffer.WriteRID (rows [i].Col2, Table.Field); // Parent
+ }
+ }
+
+ public override int Compare (FieldLayoutRow x, FieldLayoutRow y)
+ {
+ return Compare (x.Col2, y.Col2);
+ }
+ }
+
+ sealed class StandAloneSigTable : MetadataTable<uint> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++)
+ buffer.WriteBlob (rows [i]);
+ }
+ }
+
+ sealed class EventMapTable : MetadataTable<EventMapRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteRID (rows [i].Col1, Table.TypeDef); // Parent
+ buffer.WriteRID (rows [i].Col2, Table.Event); // EventList
+ }
+ }
+ }
+
+ sealed class EventTable : MetadataTable<EventRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt16 ((ushort) rows [i].Col1); // Flags
+ buffer.WriteString (rows [i].Col2); // Name
+ buffer.WriteCodedRID (rows [i].Col3, CodedIndex.TypeDefOrRef); // EventType
+ }
+ }
+ }
+
+ sealed class PropertyMapTable : MetadataTable<PropertyMapRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteRID (rows [i].Col1, Table.TypeDef); // Parent
+ buffer.WriteRID (rows [i].Col2, Table.Property); // PropertyList
+ }
+ }
+ }
+
+ sealed class PropertyTable : MetadataTable<PropertyRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt16 ((ushort) rows [i].Col1); // Flags
+ buffer.WriteString (rows [i].Col2); // Name
+ buffer.WriteBlob (rows [i].Col3); // Type
+ }
+ }
+ }
+
+ sealed class MethodSemanticsTable : SortedTable<MethodSemanticsRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt16 ((ushort) rows [i].Col1); // Flags
+ buffer.WriteRID (rows [i].Col2, Table.Method); // Method
+ buffer.WriteCodedRID (rows [i].Col3, CodedIndex.HasSemantics); // Association
+ }
+ }
+
+ public override int Compare (MethodSemanticsRow x, MethodSemanticsRow y)
+ {
+ return Compare (x.Col3, y.Col3);
+ }
+ }
+
+ sealed class MethodImplTable : MetadataTable<MethodImplRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteRID (rows [i].Col1, Table.TypeDef); // Class
+ buffer.WriteCodedRID (rows [i].Col2, CodedIndex.MethodDefOrRef); // MethodBody
+ buffer.WriteCodedRID (rows [i].Col3, CodedIndex.MethodDefOrRef); // MethodDeclaration
+ }
+ }
+ }
+
+ sealed class ModuleRefTable : MetadataTable<uint> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++)
+ buffer.WriteString (rows [i]); // Name
+ }
+ }
+
+ sealed class TypeSpecTable : MetadataTable<uint> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++)
+ buffer.WriteBlob (rows [i]); // Signature
+ }
+ }
+
+ sealed class ImplMapTable : SortedTable<ImplMapRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt16 ((ushort) rows [i].Col1); // Flags
+ buffer.WriteCodedRID (rows [i].Col2, CodedIndex.MemberForwarded); // MemberForwarded
+ buffer.WriteString (rows [i].Col3); // ImportName
+ buffer.WriteRID (rows [i].Col4, Table.ModuleRef); // ImportScope
+ }
+ }
+
+ public override int Compare (ImplMapRow x, ImplMapRow y)
+ {
+ return Compare (x.Col2, y.Col2);
+ }
+ }
+
+ sealed class FieldRVATable : SortedTable<FieldRVARow> {
+
+ internal int position;
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ position = buffer.position;
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt32 (rows [i].Col1); // RVA
+ buffer.WriteRID (rows [i].Col2, Table.Field); // Field
+ }
+ }
+
+ public override int Compare (FieldRVARow x, FieldRVARow y)
+ {
+ return Compare (x.Col2, y.Col2);
+ }
+ }
+
+ sealed class AssemblyTable : OneRowTable<AssemblyRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ buffer.WriteUInt32 ((uint) row.Col1); // AssemblyHashAlgorithm
+ buffer.WriteUInt16 (row.Col2); // MajorVersion
+ buffer.WriteUInt16 (row.Col3); // MinorVersion
+ buffer.WriteUInt16 (row.Col4); // Build
+ buffer.WriteUInt16 (row.Col5); // Revision
+ buffer.WriteUInt32 ((uint) row.Col6); // Flags
+ buffer.WriteBlob (row.Col7); // PublicKey
+ buffer.WriteString (row.Col8); // Name
+ buffer.WriteString (row.Col9); // Culture
+ }
+ }
+
+ sealed class AssemblyRefTable : MetadataTable<AssemblyRefRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt16 (rows [i].Col1); // MajorVersion
+ buffer.WriteUInt16 (rows [i].Col2); // MinorVersion
+ buffer.WriteUInt16 (rows [i].Col3); // Build
+ buffer.WriteUInt16 (rows [i].Col4); // Revision
+ buffer.WriteUInt32 ((uint) rows [i].Col5); // Flags
+ buffer.WriteBlob (rows [i].Col6); // PublicKeyOrToken
+ buffer.WriteString (rows [i].Col7); // Name
+ buffer.WriteString (rows [i].Col8); // Culture
+ buffer.WriteBlob (rows [i].Col9); // Hash
+ }
+ }
+ }
+
+ sealed class FileTable : MetadataTable<FileRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt32 ((uint) rows [i].Col1);
+ buffer.WriteString (rows [i].Col2);
+ buffer.WriteBlob (rows [i].Col3);
+ }
+ }
+ }
+
+ sealed class ExportedTypeTable : MetadataTable<ExportedTypeRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt32 ((uint) rows [i].Col1);
+ buffer.WriteUInt32 (rows [i].Col2);
+ buffer.WriteString (rows [i].Col3);
+ buffer.WriteString (rows [i].Col4);
+ buffer.WriteCodedRID (rows [i].Col5, CodedIndex.Implementation);
+ }
+ }
+ }
+
+ sealed class ManifestResourceTable : MetadataTable<ManifestResourceRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt32 (rows [i].Col1);
+ buffer.WriteUInt32 ((uint) rows [i].Col2);
+ buffer.WriteString (rows [i].Col3);
+ buffer.WriteCodedRID (rows [i].Col4, CodedIndex.Implementation);
+ }
+ }
+ }
+
+ sealed class NestedClassTable : SortedTable<NestedClassRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteRID (rows [i].Col1, Table.TypeDef); // NestedClass
+ buffer.WriteRID (rows [i].Col2, Table.TypeDef); // EnclosingClass
+ }
+ }
+
+ public override int Compare (NestedClassRow x, NestedClassRow y)
+ {
+ return Compare (x.Col1, y.Col1);
+ }
+ }
+
+ sealed class GenericParamTable : MetadataTable<GenericParamRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteUInt16 (rows [i].Col1); // Number
+ buffer.WriteUInt16 ((ushort) rows [i].Col2); // Flags
+ buffer.WriteCodedRID (rows [i].Col3, CodedIndex.TypeOrMethodDef); // Owner
+ buffer.WriteString (rows [i].Col4); // Name
+ }
+ }
+ }
+
+ sealed class MethodSpecTable : MetadataTable<MethodSpecRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteCodedRID (rows [i].Col1, CodedIndex.MethodDefOrRef); // Method
+ buffer.WriteBlob (rows [i].Col2); // Instantiation
+ }
+ }
+ }
+
+ sealed class GenericParamConstraintTable : MetadataTable<GenericParamConstraintRow> {
+
+ public override void Write (TableHeapBuffer buffer)
+ {
+ for (int i = 0; i < length; i++) {
+ buffer.WriteRID (rows [i].Col1, Table.GenericParam); // Owner
+ buffer.WriteCodedRID (rows [i].Col2, CodedIndex.TypeDefOrRef); // Constraint
+ }
+ }
+ }
+
+ sealed class MetadataBuilder {
+
+ readonly internal ModuleDefinition module;
+ readonly internal ISymbolWriterProvider symbol_writer_provider;
+ readonly internal ISymbolWriter symbol_writer;
+ readonly internal TextMap text_map;
+ readonly internal string fq_name;
+
+ readonly Dictionary<TypeRefRow, MetadataToken> type_ref_map;
+ readonly Dictionary<uint, MetadataToken> type_spec_map;
+ readonly Dictionary<MemberRefRow, MetadataToken> member_ref_map;
+ readonly Dictionary<MethodSpecRow, MetadataToken> method_spec_map;
+ readonly Collection<GenericParameter> generic_parameters;
+ readonly Dictionary<MetadataToken, MetadataToken> method_def_map;
+
+ readonly internal CodeWriter code;
+ readonly internal DataBuffer data;
+ readonly internal ResourceBuffer resources;
+ readonly internal StringHeapBuffer string_heap;
+ readonly internal UserStringHeapBuffer user_string_heap;
+ readonly internal BlobHeapBuffer blob_heap;
+ readonly internal TableHeapBuffer table_heap;
+
+ internal MetadataToken entry_point;
+
+ RID type_rid = 1;
+ RID field_rid = 1;
+ RID method_rid = 1;
+ RID param_rid = 1;
+ RID property_rid = 1;
+ RID event_rid = 1;
+
+ readonly TypeRefTable type_ref_table;
+ readonly TypeDefTable type_def_table;
+ readonly FieldTable field_table;
+ readonly MethodTable method_table;
+ readonly ParamTable param_table;
+ readonly InterfaceImplTable iface_impl_table;
+ readonly MemberRefTable member_ref_table;
+ readonly ConstantTable constant_table;
+ readonly CustomAttributeTable custom_attribute_table;
+ readonly DeclSecurityTable declsec_table;
+ readonly StandAloneSigTable standalone_sig_table;
+ readonly EventMapTable event_map_table;
+ readonly EventTable event_table;
+ readonly PropertyMapTable property_map_table;
+ readonly PropertyTable property_table;
+ readonly TypeSpecTable typespec_table;
+ readonly MethodSpecTable method_spec_table;
+
+ readonly internal bool write_symbols;
+
+ public MetadataBuilder (ModuleDefinition module, string fq_name, ISymbolWriterProvider symbol_writer_provider, ISymbolWriter symbol_writer)
+ {
+ this.module = module;
+ this.text_map = CreateTextMap ();
+ this.fq_name = fq_name;
+ this.symbol_writer_provider = symbol_writer_provider;
+ this.symbol_writer = symbol_writer;
+ this.write_symbols = symbol_writer != null;
+ this.code = new CodeWriter (this);
+ this.data = new DataBuffer ();
+ this.resources = new ResourceBuffer ();
+ this.string_heap = new StringHeapBuffer ();
+ this.user_string_heap = new UserStringHeapBuffer ();
+ this.blob_heap = new BlobHeapBuffer ();
+ this.table_heap = new TableHeapBuffer (module, this);
+
+ this.type_ref_table = GetTable<TypeRefTable> (Table.TypeRef);
+ this.type_def_table = GetTable<TypeDefTable> (Table.TypeDef);
+ this.field_table = GetTable<FieldTable> (Table.Field);
+ this.method_table = GetTable<MethodTable> (Table.Method);
+ this.param_table = GetTable<ParamTable> (Table.Param);
+ this.iface_impl_table = GetTable<InterfaceImplTable> (Table.InterfaceImpl);
+ this.member_ref_table = GetTable<MemberRefTable> (Table.MemberRef);
+ this.constant_table = GetTable<ConstantTable> (Table.Constant);
+ this.custom_attribute_table = GetTable<CustomAttributeTable> (Table.CustomAttribute);
+ this.declsec_table = GetTable<DeclSecurityTable> (Table.DeclSecurity);
+ this.standalone_sig_table = GetTable<StandAloneSigTable> (Table.StandAloneSig);
+ this.event_map_table = GetTable<EventMapTable> (Table.EventMap);
+ this.event_table = GetTable<EventTable> (Table.Event);
+ this.property_map_table = GetTable<PropertyMapTable> (Table.PropertyMap);
+ this.property_table = GetTable<PropertyTable> (Table.Property);
+ this.typespec_table = GetTable<TypeSpecTable> (Table.TypeSpec);
+ this.method_spec_table = GetTable<MethodSpecTable> (Table.MethodSpec);
+
+ var row_equality_comparer = new RowEqualityComparer ();
+ type_ref_map = new Dictionary<TypeRefRow, MetadataToken> (row_equality_comparer);
+ type_spec_map = new Dictionary<uint, MetadataToken> ();
+ member_ref_map = new Dictionary<MemberRefRow, MetadataToken> (row_equality_comparer);
+ method_spec_map = new Dictionary<MethodSpecRow, MetadataToken> (row_equality_comparer);
+ generic_parameters = new Collection<GenericParameter> ();
+ if (write_symbols)
+ method_def_map = new Dictionary<MetadataToken, MetadataToken> ();
+ }
+
+ TextMap CreateTextMap ()
+ {
+ var map = new TextMap ();
+ map.AddMap (TextSegment.ImportAddressTable, module.Architecture == TargetArchitecture.I386 ? 8 : 16);
+ map.AddMap (TextSegment.CLIHeader, 0x48, 8);
+ return map;
+ }
+
+ TTable GetTable<TTable> (Table table) where TTable : MetadataTable, new ()
+ {
+ return table_heap.GetTable<TTable> (table);
+ }
+
+ uint GetStringIndex (string @string)
+ {
+ if (string.IsNullOrEmpty (@string))
+ return 0;
+
+ return string_heap.GetStringIndex (@string);
+ }
+
+ uint GetBlobIndex (ByteBuffer blob)
+ {
+ if (blob.length == 0)
+ return 0;
+
+ return blob_heap.GetBlobIndex (blob);
+ }
+
+ uint GetBlobIndex (byte [] blob)
+ {
+ if (blob.IsNullOrEmpty ())
+ return 0;
+
+ return GetBlobIndex (new ByteBuffer (blob));
+ }
+
+ public void BuildMetadata ()
+ {
+ BuildModule ();
+
+ table_heap.WriteTableHeap ();
+ }
+
+ void BuildModule ()
+ {
+ var table = GetTable<ModuleTable> (Table.Module);
+ table.row = GetStringIndex (module.Name);
+
+ var assembly = module.Assembly;
+
+ if (assembly != null)
+ BuildAssembly ();
+
+ if (module.HasAssemblyReferences)
+ AddAssemblyReferences ();
+
+ if (module.HasModuleReferences)
+ AddModuleReferences ();
+
+ if (module.HasResources)
+ AddResources ();
+
+ if (module.HasExportedTypes)
+ AddExportedTypes ();
+
+ BuildTypes ();
+
+ if (assembly != null) {
+ if (assembly.HasCustomAttributes)
+ AddCustomAttributes (assembly);
+
+ if (assembly.HasSecurityDeclarations)
+ AddSecurityDeclarations (assembly);
+ }
+
+ if (module.HasCustomAttributes)
+ AddCustomAttributes (module);
+
+ if (module.EntryPoint != null)
+ entry_point = LookupToken (module.EntryPoint);
+ }
+
+ void BuildAssembly ()
+ {
+ var assembly = module.Assembly;
+ var name = assembly.Name;
+
+ var table = GetTable<AssemblyTable> (Table.Assembly);
+
+ table.row = new AssemblyRow (
+ name.HashAlgorithm,
+ (ushort) name.Version.Major,
+ (ushort) name.Version.Minor,
+ (ushort) name.Version.Build,
+ (ushort) name.Version.Revision,
+ name.Attributes,
+ GetBlobIndex (name.PublicKey),
+ GetStringIndex (name.Name),
+ GetStringIndex (name.Culture));
+
+ if (assembly.Modules.Count > 1)
+ BuildModules ();
+ }
+
+ void BuildModules ()
+ {
+ var modules = this.module.Assembly.Modules;
+ var table = GetTable<FileTable> (Table.File);
+
+ for (int i = 0; i < modules.Count; i++) {
+ var module = modules [i];
+ if (module.IsMain)
+ continue;
+
+ var parameters = new WriterParameters {
+ SymbolWriterProvider = symbol_writer_provider,
+ };
+
+ var file_name = GetModuleFileName (module.Name);
+ module.Write (file_name, parameters);
+
+ var hash = CryptoService.ComputeHash (file_name);
+
+ table.AddRow (new FileRow (
+ FileAttributes.ContainsMetaData,
+ GetStringIndex (module.Name),
+ GetBlobIndex (hash)));
+ }
+ }
+
+ string GetModuleFileName (string name)
+ {
+ if (string.IsNullOrEmpty (name))
+ throw new NotSupportedException ();
+
+ var path = Path.GetDirectoryName (fq_name);
+ return Path.Combine (path, name);
+ }
+
+ void AddAssemblyReferences ()
+ {
+ var references = module.AssemblyReferences;
+ var table = GetTable<AssemblyRefTable> (Table.AssemblyRef);
+
+ for (int i = 0; i < references.Count; i++) {
+ var reference = references [i];
+
+ var key_or_token = reference.PublicKey.IsNullOrEmpty ()
+ ? reference.PublicKeyToken
+ : reference.PublicKey;
+
+ var rid = table.AddRow (new AssemblyRefRow (
+ (ushort) reference.Version.Major,
+ (ushort) reference.Version.Minor,
+ (ushort) reference.Version.Build,
+ (ushort) reference.Version.Revision,
+ reference.Attributes,
+ GetBlobIndex (key_or_token),
+ GetStringIndex (reference.Name),
+ GetStringIndex (reference.Culture),
+ GetBlobIndex (reference.Hash)));
+
+ reference.token = new MetadataToken (TokenType.AssemblyRef, rid);
+ }
+ }
+
+ void AddModuleReferences ()
+ {
+ var references = module.ModuleReferences;
+ var table = GetTable<ModuleRefTable> (Table.ModuleRef);
+
+ for (int i = 0; i < references.Count; i++) {
+ var reference = references [i];
+
+ reference.token = new MetadataToken (
+ TokenType.ModuleRef,
+ table.AddRow (GetStringIndex (reference.Name)));
+ }
+ }
+
+ void AddResources ()
+ {
+ var resources = module.Resources;
+ var table = GetTable<ManifestResourceTable> (Table.ManifestResource);
+
+ for (int i = 0; i < resources.Count; i++) {
+ var resource = resources [i];
+
+ var row = new ManifestResourceRow (
+ 0,
+ resource.Attributes,
+ GetStringIndex (resource.Name),
+ 0);
+
+ switch (resource.ResourceType) {
+ case ResourceType.Embedded:
+ row.Col1 = AddEmbeddedResource ((EmbeddedResource) resource);
+ break;
+ case ResourceType.Linked:
+ row.Col4 = CodedIndex.Implementation.CompressMetadataToken (
+ new MetadataToken (
+ TokenType.File,
+ AddLinkedResource ((LinkedResource) resource)));
+ break;
+ case ResourceType.AssemblyLinked:
+ row.Col4 = CodedIndex.Implementation.CompressMetadataToken (
+ ((AssemblyLinkedResource) resource).Assembly.MetadataToken);
+ break;
+ default:
+ throw new NotSupportedException ();
+ }
+
+ table.AddRow (row);
+ }
+ }
+
+ uint AddLinkedResource (LinkedResource resource)
+ {
+ var table = GetTable<FileTable> (Table.File);
+
+ var hash = resource.Hash.IsNullOrEmpty ()
+ ? CryptoService.ComputeHash (resource.File)
+ : resource.Hash;
+
+ return (uint) table.AddRow (new FileRow (
+ FileAttributes.ContainsNoMetaData,
+ GetStringIndex (resource.File),
+ GetBlobIndex (hash)));
+ }
+
+ uint AddEmbeddedResource (EmbeddedResource resource)
+ {
+ return resources.AddResource (resource.GetResourceData ());
+ }
+
+ void AddExportedTypes ()
+ {
+ var exported_types = module.ExportedTypes;
+ var table = GetTable<ExportedTypeTable> (Table.ExportedType);
+
+ for (int i = 0; i < exported_types.Count; i++) {
+ var exported_type = exported_types [i];
+
+ var rid = table.AddRow (new ExportedTypeRow (
+ exported_type.Attributes,
+ (uint) exported_type.Identifier,
+ GetStringIndex (exported_type.Name),
+ GetStringIndex (exported_type.Namespace),
+ MakeCodedRID (GetExportedTypeScope (exported_type), CodedIndex.Implementation)));
+
+ exported_type.token = new MetadataToken (TokenType.ExportedType, rid);
+ }
+ }
+
+ MetadataToken GetExportedTypeScope (ExportedType exported_type)
+ {
+ if (exported_type.DeclaringType != null)
+ return exported_type.DeclaringType.MetadataToken;
+
+ var scope = exported_type.Scope;
+ switch (scope.MetadataToken.TokenType) {
+ case TokenType.AssemblyRef:
+ return scope.MetadataToken;
+ case TokenType.ModuleRef:
+ var file_table = GetTable<FileTable> (Table.File);
+ for (int i = 0; i < file_table.length; i++)
+ if (file_table.rows [i].Col2 == GetStringIndex (scope.Name))
+ return new MetadataToken (TokenType.File, i + 1);
+
+ break;
+ }
+
+ throw new NotSupportedException ();
+ }
+
+ void BuildTypes ()
+ {
+ if (!module.HasTypes)
+ return;
+
+ AttachTokens ();
+ AddTypeDefs ();
+ AddGenericParameters ();
+ }
+
+ void AttachTokens ()
+ {
+ var types = module.Types;
+
+ for (int i = 0; i < types.Count; i++)
+ AttachTypeDefToken (types [i]);
+ }
+
+ void AttachTypeDefToken (TypeDefinition type)
+ {
+ type.token = new MetadataToken (TokenType.TypeDef, type_rid++);
+ type.fields_range.Start = field_rid;
+ type.methods_range.Start = method_rid;
+
+ if (type.HasFields)
+ AttachFieldsDefToken (type);
+
+ if (type.HasMethods)
+ AttachMethodsDefToken (type);
+
+ if (type.HasNestedTypes)
+ AttachNestedTypesDefToken (type);
+ }
+
+ void AttachNestedTypesDefToken (TypeDefinition type)
+ {
+ var nested_types = type.NestedTypes;
+ for (int i = 0; i < nested_types.Count; i++)
+ AttachTypeDefToken (nested_types [i]);
+ }
+
+ void AttachFieldsDefToken (TypeDefinition type)
+ {
+ var fields = type.Fields;
+ type.fields_range.Length = (uint) fields.Count;
+ for (int i = 0; i < fields.Count; i++)
+ fields [i].token = new MetadataToken (TokenType.Field, field_rid++);
+ }
+
+ void AttachMethodsDefToken (TypeDefinition type)
+ {
+ var methods = type.Methods;
+ type.methods_range.Length = (uint) methods.Count;
+ for (int i = 0; i < methods.Count; i++) {
+ var method = methods [i];
+ var new_token = new MetadataToken (TokenType.Method, method_rid++);
+
+ if (write_symbols && method.token != MetadataToken.Zero)
+ method_def_map.Add (new_token, method.token);
+
+ method.token = new_token;
+ }
+ }
+
+ public bool TryGetOriginalMethodToken (MetadataToken new_token, out MetadataToken original)
+ {
+ return method_def_map.TryGetValue (new_token, out original);
+ }
+
+ MetadataToken GetTypeToken (TypeReference type)
+ {
+ if (type == null)
+ return MetadataToken.Zero;
+
+ if (type.IsDefinition)
+ return type.token;
+
+ if (type.IsTypeSpecification ())
+ return GetTypeSpecToken (type);
+
+ return GetTypeRefToken (type);
+ }
+
+ MetadataToken GetTypeSpecToken (TypeReference type)
+ {
+ var row = GetBlobIndex (GetTypeSpecSignature (type));
+
+ MetadataToken token;
+ if (type_spec_map.TryGetValue (row, out token))
+ return token;
+
+ return AddTypeSpecification (type, row);
+ }
+
+ MetadataToken AddTypeSpecification (TypeReference type, uint row)
+ {
+ type.token = new MetadataToken (TokenType.TypeSpec, typespec_table.AddRow (row));
+
+ var token = type.token;
+ type_spec_map.Add (row, token);
+ return token;
+ }
+
+ MetadataToken GetTypeRefToken (TypeReference type)
+ {
+ var row = CreateTypeRefRow (type);
+
+ MetadataToken token;
+ if (type_ref_map.TryGetValue (row, out token))
+ return token;
+
+ return AddTypeReference (type, row);
+ }
+
+ TypeRefRow CreateTypeRefRow (TypeReference type)
+ {
+ var scope_token = type.IsNested
+ ? GetTypeRefToken (type.DeclaringType)
+ : type.Scope.MetadataToken;
+
+ return new TypeRefRow (
+ MakeCodedRID (scope_token, CodedIndex.ResolutionScope),
+ GetStringIndex (type.Name),
+ GetStringIndex (type.Namespace));
+ }
+
+ static CodedRID MakeCodedRID (IMetadataTokenProvider provider, CodedIndex index)
+ {
+ return MakeCodedRID (provider.MetadataToken, index);
+ }
+
+ static CodedRID MakeCodedRID (MetadataToken token, CodedIndex index)
+ {
+ return index.CompressMetadataToken (token);
+ }
+
+ MetadataToken AddTypeReference (TypeReference type, TypeRefRow row)
+ {
+ type.token = new MetadataToken (TokenType.TypeRef, type_ref_table.AddRow (row));
+
+ var token = type.token;
+ type_ref_map.Add (row, token);
+ return token;
+ }
+
+ void AddTypeDefs ()
+ {
+ var types = module.Types;
+
+ for (int i = 0; i < types.Count; i++)
+ AddType (types [i]);
+ }
+
+ void AddType (TypeDefinition type)
+ {
+ type_def_table.AddRow (new TypeDefRow (
+ type.Attributes,
+ GetStringIndex (type.Name),
+ GetStringIndex (type.Namespace),
+ MakeCodedRID (GetTypeToken (type.BaseType), CodedIndex.TypeDefOrRef),
+ type.fields_range.Start,
+ type.methods_range.Start));
+
+ if (type.HasGenericParameters)
+ AddGenericParameters (type);
+
+ if (type.HasInterfaces)
+ AddInterfaces (type);
+
+ if (type.HasLayoutInfo)
+ AddLayoutInfo (type);
+
+ if (type.HasFields)
+ AddFields (type);
+
+ if (type.HasMethods)
+ AddMethods (type);
+
+ if (type.HasProperties)
+ AddProperties (type);
+
+ if (type.HasEvents)
+ AddEvents (type);
+
+ if (type.HasCustomAttributes)
+ AddCustomAttributes (type);
+
+ if (type.HasSecurityDeclarations)
+ AddSecurityDeclarations (type);
+
+ if (type.HasNestedTypes)
+ AddNestedTypes (type);
+ }
+
+ void AddGenericParameters (IGenericParameterProvider owner)
+ {
+ var parameters = owner.GenericParameters;
+
+ for (int i = 0; i < parameters.Count; i++)
+ generic_parameters.Add (parameters [i]);
+ }
+
+ sealed class GenericParameterComparer : IComparer<GenericParameter> {
+
+ public int Compare (GenericParameter a, GenericParameter b)
+ {
+ var a_owner = MakeCodedRID (a.Owner, CodedIndex.TypeOrMethodDef);
+ var b_owner = MakeCodedRID (b.Owner, CodedIndex.TypeOrMethodDef);
+ if (a_owner == b_owner) {
+ var a_pos = a.Position;
+ var b_pos = b.Position;
+ return a_pos == b_pos ? 0 : a_pos > b_pos ? 1 : -1;
+ }
+
+ return a_owner > b_owner ? 1 : -1;
+ }
+ }
+
+ void AddGenericParameters ()
+ {
+ var items = this.generic_parameters.items;
+ var size = this.generic_parameters.size;
+ Array.Sort (items, 0, size, new GenericParameterComparer ());
+
+ var generic_param_table = GetTable<GenericParamTable> (Table.GenericParam);
+ var generic_param_constraint_table = GetTable<GenericParamConstraintTable> (Table.GenericParamConstraint);
+
+ for (int i = 0; i < size; i++) {
+ var generic_parameter = items [i];
+
+ var rid = generic_param_table.AddRow (new GenericParamRow (
+ (ushort) generic_parameter.Position,
+ generic_parameter.Attributes,
+ MakeCodedRID (generic_parameter.Owner, CodedIndex.TypeOrMethodDef),
+ GetStringIndex (generic_parameter.Name)));
+
+ generic_parameter.token = new MetadataToken (TokenType.GenericParam, rid);
+
+ if (generic_parameter.HasConstraints)
+ AddConstraints (generic_parameter, generic_param_constraint_table);
+
+ if (generic_parameter.HasCustomAttributes)
+ AddCustomAttributes (generic_parameter);
+ }
+ }
+
+ void AddConstraints (GenericParameter generic_parameter, GenericParamConstraintTable table)
+ {
+ var constraints = generic_parameter.Constraints;
+
+ var rid = generic_parameter.token.RID;
+
+ for (int i = 0; i < constraints.Count; i++)
+ table.AddRow (new GenericParamConstraintRow (
+ rid,
+ MakeCodedRID (GetTypeToken (constraints [i]), CodedIndex.TypeDefOrRef)));
+ }
+
+ void AddInterfaces (TypeDefinition type)
+ {
+ var interfaces = type.Interfaces;
+ var type_rid = type.token.RID;
+
+ for (int i = 0; i < interfaces.Count; i++)
+ iface_impl_table.AddRow (new InterfaceImplRow (
+ type_rid,
+ MakeCodedRID (GetTypeToken (interfaces [i]), CodedIndex.TypeDefOrRef)));
+ }
+
+ void AddLayoutInfo (TypeDefinition type)
+ {
+ var table = GetTable<ClassLayoutTable> (Table.ClassLayout);
+
+ table.AddRow (new ClassLayoutRow (
+ (ushort) type.PackingSize,
+ (uint) type.ClassSize,
+ type.token.RID));
+ }
+
+ void AddNestedTypes (TypeDefinition type)
+ {
+ var nested_types = type.NestedTypes;
+ var nested_table = GetTable<NestedClassTable> (Table.NestedClass);
+
+ for (int i = 0; i < nested_types.Count; i++) {
+ var nested = nested_types [i];
+ AddType (nested);
+ nested_table.AddRow (new NestedClassRow (nested.token.RID, type.token.RID));
+ }
+ }
+
+ void AddFields (TypeDefinition type)
+ {
+ var fields = type.Fields;
+
+ for (int i = 0; i < fields.Count; i++)
+ AddField (fields [i]);
+ }
+
+ void AddField (FieldDefinition field)
+ {
+ field_table.AddRow (new FieldRow (
+ field.Attributes,
+ GetStringIndex (field.Name),
+ GetBlobIndex (GetFieldSignature (field))));
+
+ if (!field.InitialValue.IsNullOrEmpty ())
+ AddFieldRVA (field);
+
+ if (field.HasLayoutInfo)
+ AddFieldLayout (field);
+
+ if (field.HasCustomAttributes)
+ AddCustomAttributes (field);
+
+ if (field.HasConstant)
+ AddConstant (field, field.FieldType);
+
+ if (field.HasMarshalInfo)
+ AddMarshalInfo (field);
+ }
+
+ void AddFieldRVA (FieldDefinition field)
+ {
+ var table = GetTable<FieldRVATable> (Table.FieldRVA);
+ table.AddRow (new FieldRVARow (
+ data.AddData (field.InitialValue),
+ field.token.RID));
+ }
+
+ void AddFieldLayout (FieldDefinition field)
+ {
+ var table = GetTable<FieldLayoutTable> (Table.FieldLayout);
+ table.AddRow (new FieldLayoutRow ((uint) field.Offset, field.token.RID));
+ }
+
+ void AddMethods (TypeDefinition type)
+ {
+ var methods = type.Methods;
+
+ for (int i = 0; i < methods.Count; i++)
+ AddMethod (methods [i]);
+ }
+
+ void AddMethod (MethodDefinition method)
+ {
+ method_table.AddRow (new MethodRow (
+ method.HasBody ? code.WriteMethodBody (method) : 0,
+ method.ImplAttributes,
+ method.Attributes,
+ GetStringIndex (method.Name),
+ GetBlobIndex (GetMethodSignature (method)),
+ param_rid));
+
+ if (method.HasParameters)
+ AddParameters (method);
+
+ if (method.HasGenericParameters)
+ AddGenericParameters (method);
+
+ if (method.IsPInvokeImpl)
+ AddPInvokeInfo (method);
+
+ if (method.HasCustomAttributes)
+ AddCustomAttributes (method);
+
+ if (method.HasSecurityDeclarations)
+ AddSecurityDeclarations (method);
+
+ if (method.HasOverrides)
+ AddOverrides (method);
+ }
+
+ void AddParameters (MethodDefinition method)
+ {
+ var parameters = method.Parameters;
+
+ var return_parameter = method.MethodReturnType.parameter;
+
+ if (return_parameter != null && RequiresParameterRow (return_parameter))
+ AddParameter (0, return_parameter, param_table);
+
+ for (int i = 0; i < parameters.Count; i++) {
+ var parameter = parameters [i];
+ if (!RequiresParameterRow (parameter))
+ continue;
+
+ AddParameter ((ushort) (i + 1), parameter, param_table);
+ }
+ }
+
+ void AddPInvokeInfo (MethodDefinition method)
+ {
+ var pinvoke = method.PInvokeInfo;
+ if (pinvoke == null)
+ throw new ArgumentException ();
+
+ var table = GetTable<ImplMapTable> (Table.ImplMap);
+ table.AddRow (new ImplMapRow (
+ pinvoke.Attributes,
+ MakeCodedRID (method, CodedIndex.MemberForwarded),
+ GetStringIndex (pinvoke.EntryPoint),
+ pinvoke.Module.MetadataToken.RID));
+ }
+
+ void AddOverrides (MethodDefinition method)
+ {
+ var overrides = method.Overrides;
+ var table = GetTable<MethodImplTable> (Table.MethodImpl);
+
+ for (int i = 0; i < overrides.Count; i++) {
+ table.AddRow (new MethodImplRow (
+ method.DeclaringType.token.RID,
+ MakeCodedRID (method, CodedIndex.MethodDefOrRef),
+ MakeCodedRID (LookupToken (overrides [i]), CodedIndex.MethodDefOrRef)));
+ }
+ }
+
+ static bool RequiresParameterRow (ParameterDefinition parameter)
+ {
+ return !string.IsNullOrEmpty (parameter.Name)
+ || parameter.Attributes != ParameterAttributes.None
+ || parameter.HasMarshalInfo
+ || parameter.HasConstant
+ || parameter.HasCustomAttributes;
+ }
+
+ void AddParameter (ushort sequence, ParameterDefinition parameter, ParamTable table)
+ {
+ table.AddRow (new ParamRow (
+ parameter.Attributes,
+ sequence,
+ GetStringIndex (parameter.Name)));
+
+ parameter.token = new MetadataToken (TokenType.Param, param_rid++);
+
+ if (parameter.HasCustomAttributes)
+ AddCustomAttributes (parameter);
+
+ if (parameter.HasConstant)
+ AddConstant (parameter, parameter.ParameterType);
+
+ if (parameter.HasMarshalInfo)
+ AddMarshalInfo (parameter);
+ }
+
+ void AddMarshalInfo (IMarshalInfoProvider owner)
+ {
+ var table = GetTable<FieldMarshalTable> (Table.FieldMarshal);
+
+ table.AddRow (new FieldMarshalRow (
+ MakeCodedRID (owner, CodedIndex.HasFieldMarshal),
+ GetBlobIndex (GetMarshalInfoSignature (owner))));
+ }
+
+ void AddProperties (TypeDefinition type)
+ {
+ var properties = type.Properties;
+
+ property_map_table.AddRow (new PropertyMapRow (type.token.RID, property_rid));
+
+ for (int i = 0; i < properties.Count; i++)
+ AddProperty (properties [i]);
+ }
+
+ void AddProperty (PropertyDefinition property)
+ {
+ property_table.AddRow (new PropertyRow (
+ property.Attributes,
+ GetStringIndex (property.Name),
+ GetBlobIndex (GetPropertySignature (property))));
+ property.token = new MetadataToken (TokenType.Property, property_rid++);
+
+ var method = property.GetMethod;
+ if (method != null)
+ AddSemantic (MethodSemanticsAttributes.Getter, property, method);
+
+ method = property.SetMethod;
+ if (method != null)
+ AddSemantic (MethodSemanticsAttributes.Setter, property, method);
+
+ if (property.HasOtherMethods)
+ AddOtherSemantic (property, property.OtherMethods);
+
+ if (property.HasCustomAttributes)
+ AddCustomAttributes (property);
+
+ if (property.HasConstant)
+ AddConstant (property, property.PropertyType);
+ }
+
+ void AddOtherSemantic (IMetadataTokenProvider owner, Collection<MethodDefinition> others)
+ {
+ for (int i = 0; i < others.Count; i++)
+ AddSemantic (MethodSemanticsAttributes.Other, owner, others [i]);
+ }
+
+ void AddEvents (TypeDefinition type)
+ {
+ var events = type.Events;
+
+ event_map_table.AddRow (new EventMapRow (type.token.RID, event_rid));
+
+ for (int i = 0; i < events.Count; i++)
+ AddEvent (events [i]);
+ }
+
+ void AddEvent (EventDefinition @event)
+ {
+ event_table.AddRow (new EventRow (
+ @event.Attributes,
+ GetStringIndex (@event.Name),
+ MakeCodedRID (GetTypeToken (@event.EventType), CodedIndex.TypeDefOrRef)));
+ @event.token = new MetadataToken (TokenType.Event, event_rid++);
+
+ var method = @event.AddMethod;
+ if (method != null)
+ AddSemantic (MethodSemanticsAttributes.AddOn, @event, method);
+
+ method = @event.InvokeMethod;
+ if (method != null)
+ AddSemantic (MethodSemanticsAttributes.Fire, @event, method);
+
+ method = @event.RemoveMethod;
+ if (method != null)
+ AddSemantic (MethodSemanticsAttributes.RemoveOn, @event, method);
+
+ if (@event.HasOtherMethods)
+ AddOtherSemantic (@event, @event.OtherMethods);
+
+ if (@event.HasCustomAttributes)
+ AddCustomAttributes (@event);
+ }
+
+ void AddSemantic (MethodSemanticsAttributes semantics, IMetadataTokenProvider provider, MethodDefinition method)
+ {
+ method.SemanticsAttributes = semantics;
+ var table = GetTable<MethodSemanticsTable> (Table.MethodSemantics);
+
+ table.AddRow (new MethodSemanticsRow (
+ semantics,
+ method.token.RID,
+ MakeCodedRID (provider, CodedIndex.HasSemantics)));
+ }
+
+ void AddConstant (IConstantProvider owner, TypeReference type)
+ {
+ var constant = owner.Constant;
+ var etype = GetConstantType (type, constant);
+
+ constant_table.AddRow (new ConstantRow (
+ etype,
+ MakeCodedRID (owner.MetadataToken, CodedIndex.HasConstant),
+ GetBlobIndex (GetConstantSignature (etype, constant))));
+ }
+
+ static ElementType GetConstantType (TypeReference constant_type, object constant)
+ {
+ if (constant == null)
+ return ElementType.Class;
+
+ var etype = constant_type.etype;
+ switch (etype) {
+ case ElementType.None:
+ var type = constant_type.CheckedResolve ();
+ if (type.IsEnum)
+ return GetConstantType (type.GetEnumUnderlyingType (), constant);
+
+ return ElementType.Class;
+ case ElementType.String:
+ return ElementType.String;
+ case ElementType.Object:
+ return GetConstantType (constant.GetType ());
+ case ElementType.Array:
+ case ElementType.SzArray:
+ case ElementType.MVar:
+ case ElementType.Var:
+ return ElementType.Class;
+ case ElementType.GenericInst:
+ case ElementType.CModOpt:
+ case ElementType.CModReqD:
+ case ElementType.ByRef:
+ case ElementType.Sentinel:
+ return GetConstantType (((TypeSpecification) constant_type).ElementType, constant);
+ case ElementType.Boolean:
+ case ElementType.Char:
+ case ElementType.I:
+ case ElementType.I1:
+ case ElementType.I2:
+ case ElementType.I4:
+ case ElementType.I8:
+ case ElementType.U:
+ case ElementType.U1:
+ case ElementType.U2:
+ case ElementType.U4:
+ case ElementType.U8:
+ case ElementType.R4:
+ case ElementType.R8:
+ return GetConstantType (constant.GetType ());
+ default:
+ return etype;
+ }
+ }
+
+ static ElementType GetConstantType (Type type)
+ {
+ switch (Type.GetTypeCode (type)) {
+ case TypeCode.Boolean:
+ return ElementType.Boolean;
+ case TypeCode.Byte:
+ return ElementType.U1;
+ case TypeCode.SByte:
+ return ElementType.I1;
+ case TypeCode.Char:
+ return ElementType.Char;
+ case TypeCode.Int16:
+ return ElementType.I2;
+ case TypeCode.UInt16:
+ return ElementType.U2;
+ case TypeCode.Int32:
+ return ElementType.I4;
+ case TypeCode.UInt32:
+ return ElementType.U4;
+ case TypeCode.Int64:
+ return ElementType.I8;
+ case TypeCode.UInt64:
+ return ElementType.U8;
+ case TypeCode.Single:
+ return ElementType.R4;
+ case TypeCode.Double:
+ return ElementType.R8;
+ case TypeCode.String:
+ return ElementType.String;
+ default:
+ throw new NotSupportedException (type.FullName);
+ }
+ }
+
+ void AddCustomAttributes (ICustomAttributeProvider owner)
+ {
+ var custom_attributes = owner.CustomAttributes;
+
+ for (int i = 0; i < custom_attributes.Count; i++) {
+ var attribute = custom_attributes [i];
+
+ custom_attribute_table.AddRow (new CustomAttributeRow (
+ MakeCodedRID (owner, CodedIndex.HasCustomAttribute),
+ MakeCodedRID (LookupToken (attribute.Constructor), CodedIndex.CustomAttributeType),
+ GetBlobIndex (GetCustomAttributeSignature (attribute))));
+ }
+ }
+
+ void AddSecurityDeclarations (ISecurityDeclarationProvider owner)
+ {
+ var declarations = owner.SecurityDeclarations;
+
+ for (int i = 0; i < declarations.Count; i++) {
+ var declaration = declarations [i];
+
+ declsec_table.AddRow (new DeclSecurityRow (
+ declaration.Action,
+ MakeCodedRID (owner, CodedIndex.HasDeclSecurity),
+ GetBlobIndex (GetSecurityDeclarationSignature (declaration))));
+ }
+ }
+
+ MetadataToken GetMemberRefToken (MemberReference member)
+ {
+ var row = CreateMemberRefRow (member);
+
+ MetadataToken token;
+ if (member_ref_map.TryGetValue (row, out token))
+ return token;
+
+ AddMemberReference (member, row);
+
+ return member.token;
+ }
+
+ MemberRefRow CreateMemberRefRow (MemberReference member)
+ {
+ return new MemberRefRow (
+ MakeCodedRID (GetTypeToken (member.DeclaringType), CodedIndex.MemberRefParent),
+ GetStringIndex (member.Name),
+ GetBlobIndex (GetMemberRefSignature (member)));
+ }
+
+ void AddMemberReference (MemberReference member, MemberRefRow row)
+ {
+ member.token = new MetadataToken (TokenType.MemberRef, member_ref_table.AddRow (row));
+ member_ref_map.Add (row, member.token);
+ }
+
+ MetadataToken GetMethodSpecToken (MethodSpecification method_spec)
+ {
+ var row = CreateMethodSpecRow (method_spec);
+
+ MetadataToken token;
+ if (method_spec_map.TryGetValue (row, out token))
+ return token;
+
+ AddMethodSpecification (method_spec, row);
+
+ return method_spec.token;
+ }
+
+ void AddMethodSpecification (MethodSpecification method_spec, MethodSpecRow row)
+ {
+ method_spec.token = new MetadataToken (TokenType.MethodSpec, method_spec_table.AddRow (row));
+ method_spec_map.Add (row, method_spec.token);
+ }
+
+ MethodSpecRow CreateMethodSpecRow (MethodSpecification method_spec)
+ {
+ return new MethodSpecRow (
+ MakeCodedRID (LookupToken (method_spec.ElementMethod), CodedIndex.MethodDefOrRef),
+ GetBlobIndex (GetMethodSpecSignature (method_spec)));
+ }
+
+ SignatureWriter CreateSignatureWriter ()
+ {
+ return new SignatureWriter (this);
+ }
+
+ SignatureWriter GetMethodSpecSignature (MethodSpecification method_spec)
+ {
+ if (!method_spec.IsGenericInstance)
+ throw new NotSupportedException ();
+
+ var generic_instance = (GenericInstanceMethod) method_spec;
+
+ var signature = CreateSignatureWriter ();
+ signature.WriteByte (0x0a);
+
+ signature.WriteGenericInstanceSignature (generic_instance);
+
+ return signature;
+ }
+
+ public uint AddStandAloneSignature (uint signature)
+ {
+ return (uint) standalone_sig_table.AddRow (signature);
+ }
+
+ public uint GetLocalVariableBlobIndex (Collection<VariableDefinition> variables)
+ {
+ return GetBlobIndex (GetVariablesSignature (variables));
+ }
+
+ public uint GetCallSiteBlobIndex (CallSite call_site)
+ {
+ return GetBlobIndex (GetMethodSignature (call_site));
+ }
+
+ SignatureWriter GetVariablesSignature (Collection<VariableDefinition> variables)
+ {
+ var signature = CreateSignatureWriter ();
+ signature.WriteByte (0x7);
+ signature.WriteCompressedUInt32 ((uint) variables.Count);
+ for (int i = 0; i < variables.Count; i++)
+ signature.WriteTypeSignature (variables [i].VariableType);
+ return signature;
+ }
+
+ SignatureWriter GetFieldSignature (FieldReference field)
+ {
+ var signature = CreateSignatureWriter ();
+ signature.WriteByte (0x6);
+ signature.WriteTypeSignature (field.FieldType);
+ return signature;
+ }
+
+ SignatureWriter GetMethodSignature (IMethodSignature method)
+ {
+ var signature = CreateSignatureWriter ();
+ signature.WriteMethodSignature (method);
+ return signature;
+ }
+
+ SignatureWriter GetMemberRefSignature (MemberReference member)
+ {
+ var field = member as FieldReference;
+ if (field != null)
+ return GetFieldSignature (field);
+
+ var method = member as MethodReference;
+ if (method != null)
+ return GetMethodSignature (method);
+
+ throw new NotSupportedException ();
+ }
+
+ SignatureWriter GetPropertySignature (PropertyDefinition property)
+ {
+ var signature = CreateSignatureWriter ();
+ byte calling_convention = 0x8;
+ if (property.HasThis)
+ calling_convention |= 0x20;
+
+ uint param_count = 0;
+ Collection<ParameterDefinition> parameters = null;
+
+ if (property.HasParameters) {
+ parameters = property.Parameters;
+ param_count = (uint) parameters.Count;
+ }
+
+ signature.WriteByte (calling_convention);
+ signature.WriteCompressedUInt32 (param_count);
+ signature.WriteTypeSignature (property.PropertyType);
+
+ if (param_count == 0)
+ return signature;
+
+ for (int i = 0; i < param_count; i++)
+ signature.WriteTypeSignature (parameters [i].ParameterType);
+
+ return signature;
+ }
+
+ SignatureWriter GetTypeSpecSignature (TypeReference type)
+ {
+ var signature = CreateSignatureWriter ();
+ signature.WriteTypeSignature (type);
+ return signature;
+ }
+
+ SignatureWriter GetConstantSignature (ElementType type, object value)
+ {
+ var signature = CreateSignatureWriter ();
+
+ switch (type) {
+ case ElementType.Array:
+ case ElementType.SzArray:
+ case ElementType.Class:
+ case ElementType.Object:
+ case ElementType.Var:
+ case ElementType.MVar:
+ signature.WriteInt32 (0);
+ break;
+ case ElementType.String:
+ signature.WriteConstantString ((string) value);
+ break;
+ default:
+ signature.WriteConstantPrimitive (value);
+ break;
+ }
+
+ return signature;
+ }
+
+ SignatureWriter GetCustomAttributeSignature (CustomAttribute attribute)
+ {
+ var signature = CreateSignatureWriter ();
+ if (!attribute.resolved) {
+ signature.WriteBytes (attribute.GetBlob ());
+ return signature;
+ }
+
+ signature.WriteUInt16 (0x0001);
+
+ signature.WriteCustomAttributeConstructorArguments (attribute);
+
+ signature.WriteCustomAttributeNamedArguments (attribute);
+
+ return signature;
+ }
+
+ 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]);
+
+ return signature;
+ }
+
+ SignatureWriter GetMarshalInfoSignature (IMarshalInfoProvider owner)
+ {
+ var signature = CreateSignatureWriter ();
+
+ signature.WriteMarshalInfo (owner.MarshalInfo);
+
+ return signature;
+ }
+
+ public MetadataToken LookupToken (IMetadataTokenProvider provider)
+ {
+ if (provider == null)
+ throw new ArgumentNullException ();
+
+ var token = provider.MetadataToken;
+
+ switch (token.TokenType) {
+ case TokenType.TypeDef:
+ case TokenType.Method:
+ case TokenType.Field:
+ case TokenType.Event:
+ case TokenType.Property:
+ return token;
+ case TokenType.TypeRef:
+ case TokenType.TypeSpec:
+ case TokenType.GenericParam:
+ return GetTypeToken ((TypeReference) provider);
+ case TokenType.MethodSpec:
+ return GetMethodSpecToken ((MethodSpecification) provider);
+ case TokenType.MemberRef:
+ return GetMemberRefToken ((MemberReference) provider);
+ default:
+ throw new NotSupportedException ();
+ }
+ }
+ }
+
+ sealed class SignatureWriter : ByteBuffer {
+
+ readonly MetadataBuilder metadata;
+
+ public SignatureWriter (MetadataBuilder metadata)
+ : base (6)
+ {
+ this.metadata = metadata;
+ }
+
+ public void WriteElementType (ElementType element_type)
+ {
+ WriteByte ((byte) element_type);
+ }
+
+ public void WriteUTF8String (string @string)
+ {
+ if (@string == null) {
+ WriteByte (0xff);
+ return;
+ }
+
+ var bytes = Encoding.UTF8.GetBytes (@string);
+ WriteCompressedUInt32 ((uint) bytes.Length);
+ WriteBytes (bytes);
+ }
+
+ public void WriteMethodSignature (IMethodSignature method)
+ {
+ byte calling_convention = (byte) method.CallingConvention;
+ if (method.HasThis)
+ calling_convention |= 0x20;
+ if (method.ExplicitThis)
+ calling_convention |= 0x40;
+
+ var generic_provider = method as IGenericParameterProvider;
+ var generic_arity = generic_provider != null && generic_provider.HasGenericParameters
+ ? generic_provider.GenericParameters.Count
+ : 0;
+
+ if (generic_arity > 0)
+ calling_convention |= 0x10;
+
+ var param_count = method.HasParameters ? method.Parameters.Count : 0;
+
+ WriteByte (calling_convention);
+
+ if (generic_arity > 0)
+ WriteCompressedUInt32 ((uint) generic_arity);
+
+ WriteCompressedUInt32 ((uint) param_count);
+ WriteTypeSignature (method.ReturnType);
+
+ if (param_count == 0)
+ return;
+
+ var parameters = method.Parameters;
+
+ for (int i = 0; i < param_count; i++)
+ WriteTypeSignature (parameters [i].ParameterType);
+ }
+
+ uint MakeTypeDefOrRefCodedRID (TypeReference type)
+ {
+ return CodedIndex.TypeDefOrRef.CompressMetadataToken (metadata.LookupToken (type));
+ }
+
+ public void WriteTypeSignature (TypeReference type)
+ {
+ if (type == null)
+ throw new ArgumentNullException ();
+
+ var etype = type.etype;
+
+ switch (etype) {
+ case ElementType.MVar:
+ case ElementType.Var: {
+ var generic_parameter = (GenericParameter) type;
+
+ WriteElementType (etype);
+ var position = generic_parameter.Position;
+ if (position == -1)
+ throw new NotSupportedException ();
+
+ WriteCompressedUInt32 ((uint) position);
+ break;
+ }
+
+ case ElementType.GenericInst: {
+ var generic_instance = (GenericInstanceType) type;
+ WriteElementType (ElementType.GenericInst);
+ WriteElementType (generic_instance.IsValueType ? ElementType.ValueType : ElementType.Class);
+ WriteCompressedUInt32 (MakeTypeDefOrRefCodedRID (generic_instance.ElementType));
+
+ WriteGenericInstanceSignature (generic_instance);
+ break;
+ }
+
+ case ElementType.Ptr:
+ case ElementType.ByRef:
+ case ElementType.Pinned:
+ case ElementType.Sentinel: {
+ var type_spec = (TypeSpecification) type;
+ WriteElementType (etype);
+ WriteTypeSignature (type_spec.ElementType);
+ break;
+ }
+
+ case ElementType.FnPtr: {
+ var fptr = (FunctionPointerType) type;
+ WriteElementType (ElementType.FnPtr);
+ WriteMethodSignature (fptr);
+ break;
+ }
+
+ case ElementType.CModOpt:
+ case ElementType.CModReqD: {
+ var modifier = (IModifierType) type;
+ WriteModifierSignature (etype, modifier);
+ break;
+ }
+
+ case ElementType.Array: {
+ var array = (ArrayType) type;
+ if (!array.IsVector) {
+ WriteArrayTypeSignature (array);
+ break;
+ }
+
+ WriteElementType (ElementType.SzArray);
+ WriteTypeSignature (array.ElementType);
+ break;
+ }
+
+ case ElementType.None: {
+ WriteElementType (type.IsValueType ? ElementType.ValueType : ElementType.Class);
+ WriteCompressedUInt32 (MakeTypeDefOrRefCodedRID (type));
+ break;
+ }
+
+ default:
+ if (!TryWriteElementType (type))
+ throw new NotSupportedException ();
+
+ break;
+
+ }
+ }
+
+ void WriteArrayTypeSignature (ArrayType array)
+ {
+ WriteElementType (ElementType.Array);
+ WriteTypeSignature (array.ElementType);
+
+ var dimensions = array.Dimensions;
+ var rank = dimensions.Count;
+
+ WriteCompressedUInt32 ((uint) rank);
+
+ var sized = 0;
+ var lbounds = 0;
+
+ for (int i = 0; i < rank; i++) {
+ var dimension = dimensions [i];
+
+ if (dimension.UpperBound.HasValue) {
+ sized++;
+ lbounds++;
+ } else if (dimension.LowerBound.HasValue)
+ lbounds++;
+ }
+
+ var sizes = new int [sized];
+ var low_bounds = new int [lbounds];
+
+ for (int i = 0; i < lbounds; i++) {
+ var dimension = dimensions [i];
+ low_bounds [i] = dimension.LowerBound.GetValueOrDefault ();
+ if (dimension.UpperBound.HasValue)
+ sizes [i] = dimension.UpperBound.Value - low_bounds [i] + 1;
+ }
+
+ WriteCompressedUInt32 ((uint) sized);
+ for (int i = 0; i < sized; i++)
+ WriteCompressedUInt32 ((uint) sizes [i]);
+
+ WriteCompressedUInt32 ((uint) lbounds);
+ for (int i = 0; i < lbounds; i++)
+ WriteCompressedInt32 (low_bounds [i]);
+ }
+
+ public void WriteGenericInstanceSignature (IGenericInstance instance)
+ {
+ var generic_arguments = instance.GenericArguments;
+ var arity = generic_arguments.Count;
+
+ WriteCompressedUInt32 ((uint) arity);
+ for (int i = 0; i < arity; i++)
+ WriteTypeSignature (generic_arguments [i]);
+ }
+
+ void WriteModifierSignature (ElementType element_type, IModifierType type)
+ {
+ WriteElementType (element_type);
+ WriteCompressedUInt32 (MakeTypeDefOrRefCodedRID (type.ModifierType));
+ WriteTypeSignature (type.ElementType);
+ }
+
+ bool TryWriteElementType (TypeReference type)
+ {
+ var element = type.etype;
+
+ if (element == ElementType.None)
+ return false;
+
+ WriteElementType (element);
+ return true;
+ }
+
+ public void WriteConstantString (string value)
+ {
+ WriteBytes (Encoding.Unicode.GetBytes (value));
+ }
+
+ public void WriteConstantPrimitive (object value)
+ {
+ WritePrimitiveValue (value);
+ }
+
+ public void WriteCustomAttributeConstructorArguments (CustomAttribute attribute)
+ {
+ if (!attribute.HasConstructorArguments)
+ return;
+
+ var arguments = attribute.ConstructorArguments;
+ var parameters = attribute.Constructor.Parameters;
+
+ if (parameters.Count != arguments.Count)
+ throw new InvalidOperationException ();
+
+ for (int i = 0; i < arguments.Count; i++)
+ WriteCustomAttributeFixedArgument (parameters [i].ParameterType, arguments [i]);
+ }
+
+ void WriteCustomAttributeFixedArgument (TypeReference type, CustomAttributeArgument argument)
+ {
+ if (type.IsArray) {
+ WriteCustomAttributeFixedArrayArgument ((ArrayType) type, argument);
+ return;
+ }
+
+ WriteCustomAttributeElement (type, argument);
+ }
+
+ void WriteCustomAttributeFixedArrayArgument (ArrayType type, CustomAttributeArgument argument)
+ {
+ var values = argument.Value as CustomAttributeArgument [];
+
+ if (values == null) {
+ WriteUInt32 (0xffffffff);
+ return;
+ }
+
+ WriteInt32 (values.Length);
+
+ if (values.Length == 0)
+ return;
+
+ var element_type = type.ElementType;
+
+ for (int i = 0; i < values.Length; i++)
+ WriteCustomAttributeElement (element_type, values [i]);
+ }
+
+ void WriteCustomAttributeElement (TypeReference type, CustomAttributeArgument argument)
+ {
+ if (type.IsArray) {
+ WriteCustomAttributeFixedArrayArgument ((ArrayType) type, argument);
+ return;
+ }
+
+ if (type.etype == ElementType.Object) {
+ WriteCustomAttributeFieldOrPropType (argument.Type);
+ WriteCustomAttributeElement (argument.Type, argument);
+ return;
+ }
+
+ WriteCustomAttributeValue (type, argument.Value);
+ }
+
+ void WriteCustomAttributeValue (TypeReference type, object value)
+ {
+ var etype = type.etype;
+
+ switch (etype) {
+ case ElementType.String:
+ var @string = (string) value;
+ if (@string == null)
+ WriteByte (0xff);
+ else
+ WriteUTF8String (@string);
+ break;
+ case ElementType.None:
+ if (type.IsTypeOf ("System", "Type"))
+ WriteTypeReference ((TypeReference) value);
+ else
+ WriteCustomAttributeEnumValue (type, value);
+ break;
+ default:
+ WritePrimitiveValue (value);
+ break;
+ }
+ }
+
+ void WritePrimitiveValue (object value)
+ {
+ if (value == null)
+ throw new ArgumentNullException ();
+
+ switch (Type.GetTypeCode (value.GetType ())) {
+ case TypeCode.Boolean:
+ WriteByte ((byte) (((bool) value) ? 1 : 0));
+ break;
+ case TypeCode.Byte:
+ WriteByte ((byte) value);
+ break;
+ case TypeCode.SByte:
+ WriteSByte ((sbyte) value);
+ break;
+ case TypeCode.Int16:
+ WriteInt16 ((short) value);
+ break;
+ case TypeCode.UInt16:
+ WriteUInt16 ((ushort) value);
+ break;
+ case TypeCode.Char:
+ WriteInt16 ((short) (char) value);
+ break;
+ case TypeCode.Int32:
+ WriteInt32 ((int) value);
+ break;
+ case TypeCode.UInt32:
+ WriteUInt32 ((uint) value);
+ break;
+ case TypeCode.Single:
+ WriteSingle ((float) value);
+ break;
+ case TypeCode.Int64:
+ WriteInt64 ((long) value);
+ break;
+ case TypeCode.UInt64:
+ WriteUInt64 ((ulong) value);
+ break;
+ case TypeCode.Double:
+ WriteDouble ((double) value);
+ break;
+ default:
+ throw new NotSupportedException (value.GetType ().FullName);
+ }
+ }
+
+ void WriteCustomAttributeEnumValue (TypeReference enum_type, object value)
+ {
+ var type = enum_type.CheckedResolve ();
+ if (!type.IsEnum)
+ throw new ArgumentException ();
+
+ WriteCustomAttributeValue (type.GetEnumUnderlyingType (), value);
+ }
+
+ void WriteCustomAttributeFieldOrPropType (TypeReference type)
+ {
+ if (type.IsArray) {
+ var array = (ArrayType) type;
+ WriteElementType (ElementType.SzArray);
+ WriteCustomAttributeFieldOrPropType (array.ElementType);
+ return;
+ }
+
+ var etype = type.etype;
+
+ switch (etype) {
+ case ElementType.Object:
+ WriteElementType (ElementType.Boxed);
+ return;
+ case ElementType.None:
+ if (type.IsTypeOf ("System", "Type"))
+ WriteElementType (ElementType.Type);
+ else {
+ WriteElementType (ElementType.Enum);
+ WriteTypeReference (type);
+ }
+ return;
+ default:
+ WriteElementType (etype);
+ return;
+ }
+ }
+
+ public void WriteCustomAttributeNamedArguments (CustomAttribute attribute)
+ {
+ var count = GetNamedArgumentCount (attribute);
+
+ WriteUInt16 ((ushort) count);
+
+ if (count == 0)
+ return;
+
+ WriteICustomAttributeNamedArguments (attribute);
+ }
+
+ static int GetNamedArgumentCount (ICustomAttribute attribute)
+ {
+ int count = 0;
+
+ if (attribute.HasFields)
+ count += attribute.Fields.Count;
+
+ if (attribute.HasProperties)
+ count += attribute.Properties.Count;
+
+ return count;
+ }
+
+ void WriteICustomAttributeNamedArguments (ICustomAttribute attribute)
+ {
+ if (attribute.HasFields)
+ WriteCustomAttributeNamedArguments (0x53, attribute.Fields);
+
+ if (attribute.HasProperties)
+ WriteCustomAttributeNamedArguments (0x54, attribute.Properties);
+ }
+
+ void WriteCustomAttributeNamedArguments (byte kind, Collection<CustomAttributeNamedArgument> named_arguments)
+ {
+ for (int i = 0; i < named_arguments.Count; i++)
+ WriteCustomAttributeNamedArgument (kind, named_arguments [i]);
+ }
+
+ void WriteCustomAttributeNamedArgument (byte kind, CustomAttributeNamedArgument named_argument)
+ {
+ var argument = named_argument.Argument;
+
+ WriteByte (kind);
+ WriteCustomAttributeFieldOrPropType (argument.Type);
+ WriteUTF8String (named_argument.Name);
+ WriteCustomAttributeFixedArgument (argument.Type, argument);
+ }
+
+ public void WriteSecurityAttribute (SecurityAttribute attribute)
+ {
+ WriteTypeReference (attribute.AttributeType);
+
+ var count = GetNamedArgumentCount (attribute);
+
+ if (count == 0) {
+ WriteCompressedUInt32 (0); // length
+ WriteCompressedUInt32 (0); // count
+ return;
+ }
+
+ var buffer = new SignatureWriter (metadata);
+ buffer.WriteCompressedUInt32 ((uint) count);
+ buffer.WriteICustomAttributeNamedArguments (attribute);
+
+ WriteCompressedUInt32 ((uint) buffer.length);
+ WriteBytes (buffer);
+ }
+
+ void WriteTypeReference (TypeReference type)
+ {
+ WriteUTF8String (TypeParser.ToParseable (type));
+ }
+
+ public void WriteMarshalInfo (MarshalInfo marshal_info)
+ {
+ WriteNativeType (marshal_info.native);
+
+ switch (marshal_info.native) {
+ case NativeType.Array: {
+ var array = (ArrayMarshalInfo) marshal_info;
+ if (array.element_type != NativeType.None)
+ WriteNativeType (array.element_type);
+ if (array.size_parameter_index > -1)
+ WriteCompressedUInt32 ((uint) array.size_parameter_index);
+ if (array.size > -1)
+ WriteCompressedUInt32 ((uint) array.size);
+ if (array.size_parameter_multiplier > -1)
+ WriteCompressedUInt32 ((uint) array.size_parameter_multiplier);
+ return;
+ }
+ case NativeType.SafeArray: {
+ var array = (SafeArrayMarshalInfo) marshal_info;
+ if (array.element_type != VariantType.None)
+ WriteVariantType (array.element_type);
+ return;
+ }
+ case NativeType.FixedArray: {
+ var array = (FixedArrayMarshalInfo) marshal_info;
+ if (array.size > -1)
+ WriteCompressedUInt32 ((uint) array.size);
+ if (array.element_type != NativeType.None)
+ WriteNativeType (array.element_type);
+ return;
+ }
+ case NativeType.FixedSysString:
+ var sys_string = (FixedSysStringMarshalInfo) marshal_info;
+ if (sys_string.size > -1)
+ WriteCompressedUInt32 ((uint) sys_string.size);
+ return;
+ case NativeType.CustomMarshaler:
+ var marshaler = (CustomMarshalInfo) marshal_info;
+ WriteUTF8String (marshaler.guid != Guid.Empty ? marshaler.guid.ToString () : string.Empty);
+ WriteUTF8String (marshaler.unmanaged_type);
+ WriteTypeReference (marshaler.managed_type);
+ WriteUTF8String (marshaler.cookie);
+ return;
+ }
+ }
+
+ void WriteNativeType (NativeType native)
+ {
+ WriteByte ((byte) native);
+ }
+
+ void WriteVariantType (VariantType variant)
+ {
+ WriteByte ((byte) variant);
+ }
+ }
+
+#endif
+
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseAssemblyResolver.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseAssemblyResolver.cs
index 3d276cf..0b8f08f 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseAssemblyResolver.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseAssemblyResolver.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,31 +26,56 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+using Mono.Collections.Generic;
+
namespace Mono.Cecil {
- using System;
- using System.Collections;
- using System.IO;
- using SR = System.Reflection;
- using System.Text;
+ public delegate AssemblyDefinition AssemblyResolveEventHandler (object sender, AssemblyNameReference reference);
+
+ public sealed class AssemblyResolveEventArgs : EventArgs {
+
+ readonly AssemblyNameReference reference;
+
+ public AssemblyNameReference AssemblyReference {
+ get { return reference; }
+ }
+
+ public AssemblyResolveEventArgs (AssemblyNameReference reference)
+ {
+ this.reference = reference;
+ }
+ }
public abstract class BaseAssemblyResolver : IAssemblyResolver {
- ArrayList m_directories;
+ static readonly bool on_mono = Type.GetType ("Mono.Runtime") != null;
+
+ readonly Collection<string> directories;
+
+#if !SILVERLIGHT && !CF
+ Collection<string> gac_paths;
+#endif
public void AddSearchDirectory (string directory)
{
- m_directories.Add (directory);
+ directories.Add (directory);
}
public void RemoveSearchDirectory (string directory)
{
- m_directories.Remove (directory);
+ directories.Remove (directory);
}
public string [] GetSearchDirectories ()
{
- return (string []) m_directories.ToArray ();
+ var directories = new string [this.directories.size];
+ Array.Copy (this.directories.items, directories, directories.Length);
+ return directories;
}
public virtual AssemblyDefinition Resolve (string fullName)
@@ -58,29 +83,33 @@ namespace Mono.Cecil {
return Resolve (AssemblyNameReference.Parse (fullName));
}
- public BaseAssemblyResolver ()
+ public event AssemblyResolveEventHandler ResolveFailure;
+
+ protected BaseAssemblyResolver ()
+ {
+ directories = new Collection<string> (2) { ".", "bin" };
+ }
+
+ AssemblyDefinition GetAssembly (string file)
{
- m_directories = new ArrayList ();
- m_directories.Add (".");
- m_directories.Add ("bin");
+ return ModuleDefinition.ReadModule (file, new ReaderParameters { AssemblyResolver = this}).Assembly;
}
public virtual AssemblyDefinition Resolve (AssemblyNameReference name)
{
- AssemblyDefinition assembly;
- string frameworkdir = Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName);
-
- assembly = SearchDirectory (name, m_directories);
+ var assembly = SearchDirectory (name, directories);
if (assembly != null)
return assembly;
+#if !SILVERLIGHT && !CF
+ var framework_dir = Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName);
+
if (IsZero (name.Version)) {
- assembly = SearchDirectory (name, new string [] {frameworkdir});
+ assembly = SearchDirectory (name, new [] { framework_dir });
if (assembly != null)
return assembly;
}
-#if !CF_1_0 && !CF_2_0
if (name.Name == "mscorlib") {
assembly = GetCorlib (name);
if (assembly != null)
@@ -90,24 +119,29 @@ namespace Mono.Cecil {
assembly = GetAssemblyInGac (name);
if (assembly != null)
return assembly;
-#endif
- assembly = SearchDirectory (name, new string [] {frameworkdir});
+ assembly = SearchDirectory (name, new [] { framework_dir });
if (assembly != null)
return assembly;
+#endif
+
+ if (ResolveFailure != null) {
+ assembly = ResolveFailure (this, name);
+ if (assembly != null)
+ return assembly;
+ }
throw new FileNotFoundException ("Could not resolve: " + name);
}
- static readonly string [] _extentions = new string [] { ".dll", ".exe" };
-
- static AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable directories)
+ AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable<string> directories)
{
- foreach (string dir in directories) {
- foreach (string ext in _extentions) {
- string file = Path.Combine (dir, name.Name + ext);
+ var extensions = new [] { ".exe", ".dll" };
+ foreach (var directory in directories) {
+ foreach (var extension in extensions) {
+ string file = Path.Combine (directory, name.Name + extension);
if (File.Exists (file))
- return AssemblyFactory.GetAssembly (file);
+ return GetAssembly (file);
}
}
@@ -119,92 +153,158 @@ namespace Mono.Cecil {
return version.Major == 0 && version.Minor == 0 && version.Build == 0 && version.Revision == 0;
}
-#if !CF_1_0 && !CF_2_0
- static AssemblyDefinition GetCorlib (AssemblyNameReference reference)
+#if !SILVERLIGHT && !CF
+ AssemblyDefinition GetCorlib (AssemblyNameReference reference)
{
- SR.AssemblyName corlib = typeof (object).Assembly.GetName ();
- if (corlib.Version == reference.Version || IsZero (reference.Version))
- return AssemblyFactory.GetAssembly (typeof (object).Module.FullyQualifiedName);
+ var version = reference.Version;
+ var corlib = typeof (object).Assembly.GetName ();
+
+ if (corlib.Version == version || IsZero (version))
+ return GetAssembly (typeof (object).Module.FullyQualifiedName);
- string path = Directory.GetParent (
+ var path = Directory.GetParent (
Directory.GetParent (
typeof (object).Module.FullyQualifiedName).FullName
).FullName;
- if (OnMono ()) {
- if (reference.Version.Major == 1)
+ if (on_mono) {
+ if (version.Major == 1)
path = Path.Combine (path, "1.0");
- else if (reference.Version.Major == 2)
- path = Path.Combine (path, "2.0");
+ else if (version.Major == 2) {
+ if (version.MajorRevision == 5)
+ path = Path.Combine (path, "2.1");
+ else
+ path = Path.Combine (path, "2.0");
+ } else if (version.Major == 4)
+ path = Path.Combine (path, "4.0");
else
- throw new NotSupportedException ("Version not supported: " + reference.Version);
+ throw new NotSupportedException ("Version not supported: " + version);
} else {
- if (reference.Version.ToString () == "1.0.3300.0")
- path = Path.Combine (path, "v1.0.3705");
- else if (reference.Version.ToString () == "1.0.5000.0")
- path = Path.Combine (path, "v1.1.4322");
- else if (reference.Version.ToString () == "2.0.0.0")
+ switch (version.Major) {
+ case 1:
+ if (version.MajorRevision == 3300)
+ path = Path.Combine (path, "v1.0.3705");
+ else
+ path = Path.Combine (path, "v1.0.5000.0");
+ break;
+ case 2:
path = Path.Combine (path, "v2.0.50727");
- else
- throw new NotSupportedException ("Version not supported: " + reference.Version);
+ break;
+ case 4:
+ path = Path.Combine (path, "v4.0.30319");
+ break;
+ default:
+ throw new NotSupportedException ("Version not supported: " + version);
+ }
}
- if (File.Exists (Path.Combine (path, "mscorlib.dll")))
- return AssemblyFactory.GetAssembly (Path.Combine (path, "mscorlib.dll"));
+ var file = Path.Combine (path, "mscorlib.dll");
+ if (File.Exists (file))
+ return GetAssembly (file);
return null;
}
- public static bool OnMono ()
+ static Collection<string> GetGacPaths ()
+ {
+ if (on_mono)
+ return GetDefaultMonoGacPaths ();
+
+ var paths = new Collection<string> (2);
+ var windir = Environment.GetEnvironmentVariable ("WINDIR");
+ if (windir == null)
+ return paths;
+
+ paths.Add (Path.Combine (windir, "assembly"));
+ paths.Add (Path.Combine (windir, Path.Combine ("Microsoft.NET", "assembly")));
+ return paths;
+ }
+
+ static Collection<string> GetDefaultMonoGacPaths ()
+ {
+ var paths = new Collection<string> (1);
+ var gac = GetCurrentMonoGac ();
+ if (gac != null)
+ paths.Add (gac);
+
+ var gac_paths_env = Environment.GetEnvironmentVariable ("MONO_GAC_PREFIX");
+ if (string.IsNullOrEmpty (gac_paths_env))
+ return paths;
+
+ var prefixes = gac_paths_env.Split (Path.PathSeparator);
+ foreach (var prefix in prefixes) {
+ if (string.IsNullOrEmpty (prefix))
+ continue;
+
+ var gac_path = Path.Combine (Path.Combine (Path.Combine (prefix, "lib"), "mono"), "gac");
+ if (Directory.Exists (gac_path) && !paths.Contains (gac))
+ paths.Add (gac_path);
+ }
+
+ return paths;
+ }
+
+ static string GetCurrentMonoGac ()
{
- return typeof (object).Assembly.GetType ("System.MonoType", false) != null;
+ return Path.Combine (Directory.GetParent (typeof (object).Module.FullyQualifiedName).FullName, "gac");
}
- static AssemblyDefinition GetAssemblyInGac (AssemblyNameReference reference)
+ AssemblyDefinition GetAssemblyInGac (AssemblyNameReference reference)
{
if (reference.PublicKeyToken == null || reference.PublicKeyToken.Length == 0)
return null;
- string currentGac = GetCurrentGacPath ();
- if (OnMono ()) {
- string s = GetAssemblyFile (reference, currentGac);
- if (File.Exists (s))
- return AssemblyFactory.GetAssembly (s);
- } else {
- string [] gacs = new string [] {"GAC_MSIL", "GAC_32", "GAC"};
- for (int i = 0; i < gacs.Length; i++) {
- string gac = Path.Combine (Directory.GetParent (currentGac).FullName, gacs [i]);
- string asm = GetAssemblyFile (reference, gac);
- if (Directory.Exists (gac) && File.Exists (asm))
- return AssemblyFactory.GetAssembly (asm);
+ if (gac_paths == null)
+ gac_paths = GetGacPaths ();
+
+ if (on_mono)
+ return GetAssemblyInMonoGac (reference);
+
+ return GetAssemblyInNetGac (reference);
+ }
+
+ AssemblyDefinition GetAssemblyInMonoGac (AssemblyNameReference reference)
+ {
+ for (int i = 0; i < gac_paths.Count; i++) {
+ var gac_path = gac_paths [i];
+ var file = GetAssemblyFile (reference, string.Empty, gac_path);
+ if (File.Exists (file))
+ return GetAssembly (file);
+ }
+
+ return null;
+ }
+
+ AssemblyDefinition GetAssemblyInNetGac (AssemblyNameReference reference)
+ {
+ var gacs = new [] { "GAC_MSIL", "GAC_32", "GAC" };
+ var prefixes = new [] { string.Empty, "v4.0_" };
+
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < gacs.Length; j++) {
+ var gac = Path.Combine (gac_paths [i], gacs [j]);
+ var file = GetAssemblyFile (reference, prefixes [i], gac);
+ if (Directory.Exists (gac) && File.Exists (file))
+ return GetAssembly (file);
}
}
return null;
}
- static string GetAssemblyFile (AssemblyNameReference reference, string gac)
+ static string GetAssemblyFile (AssemblyNameReference reference, string prefix, string gac)
{
- StringBuilder sb = new StringBuilder ();
- sb.Append (reference.Version);
- sb.Append ("__");
+ var gac_folder = new StringBuilder ();
+ gac_folder.Append (prefix);
+ gac_folder.Append (reference.Version);
+ gac_folder.Append ("__");
for (int i = 0; i < reference.PublicKeyToken.Length; i++)
- sb.Append (reference.PublicKeyToken [i].ToString ("x2"));
+ gac_folder.Append (reference.PublicKeyToken [i].ToString ("x2"));
return Path.Combine (
Path.Combine (
- Path.Combine (gac, reference.Name), sb.ToString ()),
- string.Concat (reference.Name, ".dll"));
- }
-
- static string GetCurrentGacPath ()
- {
- return Directory.GetParent (
- Directory.GetParent (
- Path.GetDirectoryName (
- typeof (Uri).Module.FullyQualifiedName)
- ).FullName
- ).FullName;
+ Path.Combine (gac, reference.Name), gac_folder.ToString ()),
+ reference.Name + ".dll");
}
#endif
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseReflectionVisitor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseReflectionVisitor.cs
deleted file mode 100644
index 3d3a514..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseReflectionVisitor.cs
+++ /dev/null
@@ -1,188 +0,0 @@
-//
-// BaseReflectionVisitor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System.Collections;
-
- public abstract class BaseReflectionVisitor : IReflectionVisitor {
-
- public virtual void VisitModuleDefinition (ModuleDefinition module)
- {
- }
-
- public virtual void VisitTypeDefinitionCollection (TypeDefinitionCollection types)
- {
- }
-
- public virtual void VisitTypeDefinition (TypeDefinition type)
- {
- }
-
- public virtual void VisitTypeReferenceCollection (TypeReferenceCollection refs)
- {
- }
-
- public virtual void VisitTypeReference (TypeReference type)
- {
- }
-
- public virtual void VisitMemberReferenceCollection (MemberReferenceCollection members)
- {
- }
-
- public virtual void VisitMemberReference (MemberReference member)
- {
- }
-
- public virtual void VisitInterfaceCollection (InterfaceCollection interfaces)
- {
- }
-
- public virtual void VisitInterface (TypeReference interf)
- {
- }
-
- public virtual void VisitExternTypeCollection (ExternTypeCollection externs)
- {
- }
-
- public virtual void VisitExternType (TypeReference externType)
- {
- }
-
- public virtual void VisitOverrideCollection (OverrideCollection meth)
- {
- }
-
- public virtual void VisitOverride (MethodReference ov)
- {
- }
-
- public virtual void VisitNestedTypeCollection (NestedTypeCollection nestedTypes)
- {
- }
-
- public virtual void VisitNestedType (TypeDefinition nestedType)
- {
- }
-
- public virtual void VisitParameterDefinitionCollection (ParameterDefinitionCollection parameters)
- {
- }
-
- public virtual void VisitParameterDefinition (ParameterDefinition parameter)
- {
- }
-
- public virtual void VisitMethodDefinitionCollection (MethodDefinitionCollection methods)
- {
- }
-
- public virtual void VisitMethodDefinition (MethodDefinition method)
- {
- }
-
- public virtual void VisitConstructorCollection (ConstructorCollection ctors)
- {
- }
-
- public virtual void VisitConstructor (MethodDefinition ctor)
- {
- }
-
- public virtual void VisitPInvokeInfo (PInvokeInfo pinvk)
- {
- }
-
- public virtual void VisitEventDefinitionCollection (EventDefinitionCollection events)
- {
- }
-
- public virtual void VisitEventDefinition (EventDefinition evt)
- {
- }
-
- public virtual void VisitFieldDefinitionCollection (FieldDefinitionCollection fields)
- {
- }
-
- public virtual void VisitFieldDefinition (FieldDefinition field)
- {
- }
-
- public virtual void VisitPropertyDefinitionCollection (PropertyDefinitionCollection properties)
- {
- }
-
- public virtual void VisitPropertyDefinition (PropertyDefinition property)
- {
- }
-
- public virtual void VisitSecurityDeclarationCollection (SecurityDeclarationCollection secDecls)
- {
- }
-
- public virtual void VisitSecurityDeclaration (SecurityDeclaration secDecl)
- {
- }
-
- public virtual void VisitCustomAttributeCollection (CustomAttributeCollection customAttrs)
- {
- }
-
- public virtual void VisitCustomAttribute (CustomAttribute customAttr)
- {
- }
-
- public virtual void VisitGenericParameterCollection (GenericParameterCollection genparams)
- {
- }
-
- public virtual void VisitGenericParameter (GenericParameter genparam)
- {
- }
-
- public virtual void VisitMarshalSpec (MarshalSpec marshalSpec)
- {
- }
-
- public virtual void TerminateModuleDefinition (ModuleDefinition module)
- {
- }
-
- protected void VisitCollection (ICollection coll)
- {
- if (coll.Count == 0)
- return;
-
- foreach (IReflectionVisitable visitable in coll)
- visitable.Accept (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseStructureVisitor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseStructureVisitor.cs
deleted file mode 100644
index 1acec7d..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/BaseStructureVisitor.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-//
-// BaseStructureVisitor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System.Collections;
-
- public abstract class BaseStructureVisitor : IReflectionStructureVisitor {
-
- public virtual void VisitAssemblyDefinition (AssemblyDefinition asm)
- {
- }
-
- public virtual void VisitAssemblyNameDefinition (AssemblyNameDefinition name)
- {
- }
-
- public virtual void VisitAssemblyNameReferenceCollection (AssemblyNameReferenceCollection names)
- {
- }
-
- public virtual void VisitAssemblyNameReference (AssemblyNameReference name)
- {
- }
-
- public virtual void VisitResourceCollection (ResourceCollection resources)
- {
- }
-
- public virtual void VisitEmbeddedResource (EmbeddedResource res)
- {
- }
-
- public virtual void VisitLinkedResource (LinkedResource res)
- {
- }
-
- public virtual void VisitAssemblyLinkedResource (AssemblyLinkedResource res)
- {
- }
-
- public virtual void VisitModuleDefinition (ModuleDefinition module)
- {
- }
-
- public virtual void VisitModuleDefinitionCollection (ModuleDefinitionCollection modules)
- {
- }
-
- public virtual void VisitModuleReference (ModuleReference module)
- {
- }
-
- public virtual void VisitModuleReferenceCollection (ModuleReferenceCollection modules)
- {
- }
-
- public virtual void TerminateAssemblyDefinition (AssemblyDefinition asm)
- {
- }
-
- protected void VisitCollection (ICollection coll)
- {
- if (coll.Count == 0)
- return;
-
- foreach (IReflectionStructureVisitable visitable in coll)
- visitable.Accept (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CallSite.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CallSite.cs
index 586203c..e4880ec 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CallSite.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CallSite.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 - 2007 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,78 +26,20 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
-
- using System.Collections;
- using System.Text;
-
- using Mono.Cecil.Metadata;
-
- public sealed class CallSite : IMethodSignature, IAnnotationProvider, IMetadataTokenProvider {
-
- MethodReference m_function;
-
- public bool HasThis {
- get { return m_function.HasThis; }
- set { m_function.HasThis = value; }
- }
-
- public bool ExplicitThis {
- get { return m_function.ExplicitThis; }
- set { m_function.ExplicitThis = value; }
- }
-
- public MethodCallingConvention CallingConvention {
- get { return m_function.CallingConvention; }
- set { m_function.CallingConvention = value; }
- }
-
- public ParameterDefinitionCollection Parameters {
- get { return m_function.Parameters; }
- }
-
- public MethodReturnType ReturnType {
- get { return m_function.ReturnType; }
- set { m_function.ReturnType = value; }
- }
-
- public MetadataToken MetadataToken {
- get { return m_function.MetadataToken; }
- set { m_function.MetadataToken = value; }
- }
-
- IDictionary IAnnotationProvider.Annotations {
- get { return ((IAnnotationProvider) m_function).Annotations; }
- }
-
- public CallSite (bool hasThis, bool explicitThis, MethodCallingConvention callConv, MethodReturnType retType)
- {
- m_function = new MethodReference (string.Empty, hasThis, explicitThis, callConv);
- m_function.ReturnType = retType;
- }
+using System;
+using System.Text;
- public int GetSentinel ()
- {
- return m_function.GetSentinel ();
- }
-
- public override string ToString ()
- {
- int sentinel = GetSentinel ();
- StringBuilder sb = new StringBuilder ();
- sb.Append (m_function.ReturnType.ReturnType.FullName);
- sb.Append ("(");
- for (int i = 0; i < m_function.Parameters.Count; i++) {
- if (i > 0)
- sb.Append (",");
+namespace Mono.Cecil {
- if (i == sentinel)
- sb.Append ("...,");
+ public sealed class CallSite : MethodReference {
- sb.Append (m_function.Parameters [i].ParameterType.FullName);
+ public override string FullName {
+ get {
+ var signature = new StringBuilder ();
+ signature.Append (ReturnType.FullName);
+ this.MethodSignatureFullName (signature);
+ return signature.ToString ();
}
- sb.Append (")");
- return sb.ToString ();
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CompactFrameworkCompatibility.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CompactFrameworkCompatibility.cs
deleted file mode 100644
index 85fde6e..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CompactFrameworkCompatibility.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-//
-// FrameworkCompatibility.cs
-//
-// Author:
-// Rodrigo B. de Oliveira (rodrigobamboo@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-#if CF_1_0
-namespace System {
-
- internal class NotImplementedException : System.Exception {
-
- public NotImplementedException (string message) : base (message)
- {
- }
-
- public NotImplementedException ()
- {
- }
- }
-}
-#endif
-
-#if CF_1_0 || CF_2_0
-namespace System.Security {
-
- public class SecurityElement {
-
- public SecurityElement (string tag)
- {
- }
-
- public string Text
- {
- get { return string.Empty; }
- set {}
- }
-
- public void AddChild (SecurityElement child)
- {
- }
-
- public void AddAttribute (string name, string value)
- {
- }
- }
-}
-#endif
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Constants.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Constants.cs
deleted file mode 100644
index 32491e6..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Constants.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-//
-// Constants.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- public class Constants {
-
- Constants ()
- {
- }
-
- public const string Corlib = "mscorlib";
-
- public const string ModuleType = "<Module>";
- public const string PrivateImplDetails = "<PrivateImplementationDetails>";
- public const string Deleted = "_Deleted";
-
- public const string Void = "System.Void";
- public const string Object = "System.Object";
- public const string String = "System.String";
- public const string Boolean = "System.Boolean";
- public const string Char = "System.Char";
- public const string Single = "System.Single";
- public const string Double = "System.Double";
- public const string SByte = "System.SByte";
- public const string Byte = "System.Byte";
- public const string Int16 = "System.Int16";
- public const string UInt16 = "System.UInt16";
- public const string Int32 = "System.Int32";
- public const string UInt32 = "System.UInt32";
- public const string Int64 = "System.Int64";
- public const string UInt64 = "System.UInt64";
- public const string IntPtr = "System.IntPtr";
- public const string UIntPtr = "System.UIntPtr";
- public const string TypedReference = "System.TypedReference";
- public const string Type = "System.Type";
- public const string ValueType = "System.ValueType";
- public const string Enum = "System.Enum";
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstraintCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstraintCollection.cs
deleted file mode 100644
index 0c0f293..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstraintCollection.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-//
-// ConstraintCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:54 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class ConstraintCollection : CollectionBase {
-
- GenericParameter m_container;
-
- public TypeReference this [int index] {
- get { return List [index] as TypeReference; }
- set { List [index] = value; }
- }
-
- public GenericParameter Container {
- get { return m_container; }
- }
-
- public ConstraintCollection (GenericParameter container)
- {
- m_container = container;
- }
-
- public void Add (TypeReference value)
- {
- List.Add (value);
- }
-
- public bool Contains (TypeReference value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (TypeReference value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, TypeReference value)
- {
- List.Insert (index, value);
- }
-
- public void Remove (TypeReference value)
- {
- List.Remove (value);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is TypeReference))
- throw new ArgumentException ("Must be of type " + typeof (TypeReference).FullName);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstructorCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstructorCollection.cs
deleted file mode 100644
index d348f5b..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ConstructorCollection.cs
+++ /dev/null
@@ -1,175 +0,0 @@
-//
-// ConstructorCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Fri Mar 30 18:43:56 +0200 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class ConstructorCollection : CollectionBase, IReflectionVisitable {
-
- TypeDefinition m_container;
-
- public MethodDefinition this [int index] {
- get { return List [index] as MethodDefinition; }
- set { List [index] = value; }
- }
-
- public TypeDefinition Container {
- get { return m_container; }
- }
-
- public ConstructorCollection (TypeDefinition container)
- {
- m_container = container;
- }
-
- public void Add (MethodDefinition value)
- {
- Attach (value);
-
- List.Add (value);
- }
-
-
- public new void Clear ()
- {
- foreach (MethodDefinition item in this)
- Detach (item);
-
- base.Clear ();
- }
-
- public bool Contains (MethodDefinition value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (MethodDefinition value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, MethodDefinition value)
- {
- Attach (value);
-
- List.Insert (index, value);
- }
-
- public void Remove (MethodDefinition value)
- {
- List.Remove (value);
-
- Detach (value);
- }
-
-
- public new void RemoveAt (int index)
- {
- MethodDefinition item = this [index];
- Remove (item);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is MethodDefinition))
- throw new ArgumentException ("Must be of type " + typeof (MethodDefinition).FullName);
- }
-
- internal MethodDefinition GetConstructorInternal (bool isStatic, IList parameters)
- {
- foreach (MethodDefinition ctor in this) {
- if (ctor.IsStatic != isStatic || ctor.Parameters.Count != parameters.Count)
- continue;
-
- bool match = true;
- for (int i = 0; i < parameters.Count; i++) {
- string pname;
- object param = parameters [i];
- if (param is Type)
- pname = ReflectionHelper.GetTypeSignature (param as Type);
- else if (param is TypeReference)
- pname = (param as TypeReference).FullName;
- else if (param is ParameterDefinition)
- pname = (param as ParameterDefinition).ParameterType.FullName;
- else
- throw new NotSupportedException ();
-
- if (ctor.Parameters [i].ParameterType.FullName != pname) {
- match = false;
- break;
- }
- }
-
- if (match)
- return ctor;
- }
-
- return null;
- }
-
- public MethodDefinition GetConstructor (bool isStatic, Type [] parameters)
- {
- return GetConstructorInternal (isStatic, parameters);
- }
-
- public MethodDefinition GetConstructor (bool isStatic, TypeReference [] parameters)
- {
- return GetConstructorInternal (isStatic, parameters);
- }
-
- public MethodDefinition GetConstructor (bool isStatic, ParameterDefinitionCollection parameters)
- {
- return GetConstructorInternal (isStatic, parameters);
- }
-
- void Attach (MemberReference member)
- {
- if (member.DeclaringType != null)
- throw new ReflectionException ("Member already attached, clone it instead");
-
- member.DeclaringType = m_container;
- }
-
- void Detach (MemberReference member)
- {
- member.DeclaringType = null;
- }
-
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitConstructorCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttribute.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttribute.cs
index c98f933..af47d8b 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttribute.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttribute.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,168 +26,192 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
+using Mono.Collections.Generic;
+
namespace Mono.Cecil {
- using System.Collections;
+ public struct CustomAttributeArgument {
+
+ readonly TypeReference type;
+ readonly object value;
+
+ public TypeReference Type {
+ get { return type; }
+ }
+
+ public object Value {
+ get { return value; }
+ }
+
+ public CustomAttributeArgument (TypeReference type, object value)
+ {
+ Mixin.CheckType (type);
+ this.type = type;
+ this.value = value;
+ }
+ }
+
+ public struct CustomAttributeNamedArgument {
+
+ readonly string name;
+ readonly CustomAttributeArgument argument;
- public sealed class CustomAttribute : IRequireResolving, IAnnotationProvider, IReflectionVisitable {
+ public string Name {
+ get { return name; }
+ }
- MethodReference m_ctor;
- IList m_parameters;
- IDictionary m_fields;
- IDictionary m_properties;
- IDictionary m_fieldTypes;
- IDictionary m_propTypes;
- IDictionary m_annotations;
+ public CustomAttributeArgument Argument {
+ get { return argument; }
+ }
- bool m_resolved;
- byte [] m_blob;
+ public CustomAttributeNamedArgument (string name, CustomAttributeArgument argument)
+ {
+ Mixin.CheckName (name);
+ this.name = name;
+ this.argument = argument;
+ }
+ }
+
+ public interface ICustomAttribute {
+
+ TypeReference AttributeType { get; }
+
+ bool HasFields { get; }
+ bool HasProperties { get; }
+ Collection<CustomAttributeNamedArgument> Fields { get; }
+ Collection<CustomAttributeNamedArgument> Properties { get; }
+ }
+
+ public sealed class CustomAttribute : ICustomAttribute {
+
+ readonly internal uint signature;
+ internal bool resolved;
+ MethodReference constructor;
+ byte [] blob;
+ internal Collection<CustomAttributeArgument> arguments;
+ internal Collection<CustomAttributeNamedArgument> fields;
+ internal Collection<CustomAttributeNamedArgument> properties;
public MethodReference Constructor {
- get { return m_ctor; }
- set { m_ctor = value; }
+ get { return constructor; }
+ set { constructor = value; }
}
- public IList ConstructorParameters {
- get {
- if (m_parameters == null)
- m_parameters = new ArrayList ();
- return m_parameters;
- }
+ public TypeReference AttributeType {
+ get { return constructor.DeclaringType; }
}
- public IDictionary Fields {
+ public bool HasConstructorArguments {
get {
- if (m_fields == null)
- m_fields = new Hashtable ();
+ Resolve ();
- return m_fields;
+ return !arguments.IsNullOrEmpty ();
}
}
- public IDictionary Properties {
+ public Collection<CustomAttributeArgument> ConstructorArguments {
get {
- if (m_properties == null)
- m_properties = new Hashtable ();
+ Resolve ();
- return m_properties;
+ return arguments ?? (arguments = new Collection<CustomAttributeArgument> ());
}
}
- internal IDictionary FieldTypes {
+ public bool HasFields {
get {
- if (m_fieldTypes == null)
- m_fieldTypes = new Hashtable ();
+ Resolve ();
- return m_fieldTypes;
+ return !fields.IsNullOrEmpty ();
}
}
- internal IDictionary PropertyTypes {
+ public Collection<CustomAttributeNamedArgument> Fields {
get {
- if (m_propTypes == null)
- m_propTypes = new Hashtable ();
+ Resolve ();
- return m_propTypes;
+ return fields ?? (fields = new Collection<CustomAttributeNamedArgument> ());
}
}
- public bool Resolved {
- get { return m_resolved; }
- set { m_resolved = value; }
- }
+ public bool HasProperties {
+ get {
+ Resolve ();
- public byte [] Blob {
- get { return m_blob; }
- set { m_blob = value; }
+ return !properties.IsNullOrEmpty ();
+ }
}
- IDictionary IAnnotationProvider.Annotations {
+ public Collection<CustomAttributeNamedArgument> Properties {
get {
- if (m_annotations == null)
- m_annotations = new Hashtable ();
- return m_annotations;
+ Resolve ();
+
+ return properties ?? (properties = new Collection<CustomAttributeNamedArgument> ());
}
}
- public CustomAttribute (MethodReference ctor)
- {
- m_ctor = ctor;
- m_resolved = true;
+ internal bool HasImage {
+ get { return constructor != null && constructor.HasImage; }
}
- public TypeReference GetFieldType (string fieldName)
- {
- return (TypeReference) FieldTypes [fieldName];
+ internal ModuleDefinition Module {
+ get { return constructor.Module; }
}
- public TypeReference GetPropertyType (string propertyName)
+ internal CustomAttribute (uint signature, MethodReference constructor)
{
- return (TypeReference) PropertyTypes [propertyName];
+ this.signature = signature;
+ this.constructor = constructor;
+ this.resolved = false;
}
- public void SetFieldType (string fieldName, TypeReference type)
+ public CustomAttribute (MethodReference constructor)
{
- FieldTypes [fieldName] = type;
+ this.constructor = constructor;
+ this.resolved = true;
}
- public void SetPropertyType (string propertyName, TypeReference type)
+ public CustomAttribute (MethodReference constructor, byte [] blob)
{
- PropertyTypes [propertyName] = type;
+ this.constructor = constructor;
+ this.resolved = false;
+ this.blob = blob;
}
- public CustomAttribute Clone ()
+ public byte [] GetBlob ()
{
- return Clone (this, new ImportContext (NullReferenceImporter.Instance));
- }
+ if (blob != null)
+ return blob;
- static void Clone (IDictionary original, IDictionary target)
- {
- target.Clear ();
- foreach (DictionaryEntry entry in original)
- target.Add (entry.Key, entry.Value);
- }
+ if (!HasImage || signature == 0)
+ throw new NotSupportedException ();
- internal static CustomAttribute Clone (CustomAttribute custattr, ImportContext context)
- {
- CustomAttribute ca = new CustomAttribute (context.Import (custattr.Constructor));
- custattr.CopyTo (ca);
- return ca;
+ return blob = Module.Read (this, (attribute, reader) => reader.ReadCustomAttributeBlob (attribute.signature));
}
- void CopyTo (CustomAttribute target)
+ void Resolve ()
{
- target.Resolved = Resolved;
- if (!Resolved) {
- target.Blob = Blob;
+ if (resolved || !HasImage)
return;
- }
-
- foreach (object o in ConstructorParameters)
- target.ConstructorParameters.Add (o);
- Clone (Fields, target.Fields);
- Clone (FieldTypes, target.FieldTypes);
- Clone (Properties, target.Properties);
- Clone (PropertyTypes, target.PropertyTypes);
- }
-
- public bool Resolve ()
- {
- if (Resolved)
- return true;
- ReflectionReader r = m_ctor.DeclaringType.Module.Controller.Reader;
- CustomAttribute newCa = r.GetCustomAttribute (m_ctor, Blob, true);
- if (!newCa.Resolved)
- return false;
+ Module.Read (this, (attribute, reader) => {
+ reader.ReadCustomAttributeSignature (attribute);
+ return this;
+ });
- newCa.CopyTo (this);
- return true;
+ resolved = true;
}
+ }
+
+ static partial class Mixin {
- public void Accept (IReflectionVisitor visitor)
+ public static void CheckName (string name)
{
- visitor.VisitCustomAttribute (this);
+ if (name == null)
+ throw new ArgumentNullException ("name");
+ if (name.Length == 0)
+ throw new ArgumentException ("Empty name");
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttributeCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttributeCollection.cs
deleted file mode 100644
index 023b35a..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/CustomAttributeCollection.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// CustomAttributeCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:53 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class CustomAttributeCollection : CollectionBase, IReflectionVisitable {
-
- ICustomAttributeProvider m_container;
-
- public CustomAttribute this [int index] {
- get { return List [index] as CustomAttribute; }
- set { List [index] = value; }
- }
-
- public ICustomAttributeProvider Container {
- get { return m_container; }
- }
-
- public CustomAttributeCollection (ICustomAttributeProvider container)
- {
- m_container = container;
- }
-
- public void Add (CustomAttribute value)
- {
- List.Add (value);
- }
-
- public bool Contains (CustomAttribute value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (CustomAttribute value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, CustomAttribute value)
- {
- List.Insert (index, value);
- }
-
- public void Remove (CustomAttribute value)
- {
- List.Remove (value);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is CustomAttribute))
- throw new ArgumentException ("Must be of type " + typeof (CustomAttribute).FullName);
- }
-
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitCustomAttributeCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultAssemblyResolver.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultAssemblyResolver.cs
index 95b8789..cac7974 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultAssemblyResolver.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultAssemblyResolver.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,37 +26,50 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+using System.Collections.Generic;
+
namespace Mono.Cecil {
- using System.Collections;
+ public static class GlobalAssemblyResolver {
+
+ public static readonly IAssemblyResolver Instance = new DefaultAssemblyResolver ();
+ }
public class DefaultAssemblyResolver : BaseAssemblyResolver {
- IDictionary m_cache;
+ readonly IDictionary<string, AssemblyDefinition> cache;
public DefaultAssemblyResolver ()
{
- m_cache = new Hashtable ();
+ cache = new Dictionary<string, AssemblyDefinition> ();
}
public override AssemblyDefinition Resolve (AssemblyNameReference name)
{
- AssemblyDefinition asm = (AssemblyDefinition) m_cache [name.FullName];
- if (asm == null) {
- asm = base.Resolve (name);
- m_cache [name.FullName] = asm;
- }
+ if (name == null)
+ throw new ArgumentNullException ("name");
- return asm;
+ AssemblyDefinition assembly;
+ if (cache.TryGetValue (name.FullName, out assembly))
+ return assembly;
+
+ assembly = base.Resolve (name);
+ cache [name.FullName] = assembly;
+
+ return assembly;
}
protected void RegisterAssembly (AssemblyDefinition assembly)
{
- string key = assembly.Name.FullName;
- if (m_cache.Contains (key))
+ if (assembly == null)
+ throw new ArgumentNullException ("assembly");
+
+ var name = assembly.Name.FullName;
+ if (cache.ContainsKey (name))
return;
- m_cache [key] = assembly;
+ cache [name] = assembly;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultImporter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultImporter.cs
deleted file mode 100644
index f8d3011..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/DefaultImporter.cs
+++ /dev/null
@@ -1,230 +0,0 @@
-//
-// DefaultReferenceImporter.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- public class DefaultImporter : IImporter {
-
- ModuleDefinition m_module;
-
- public ModuleDefinition Module {
- get { return m_module; }
- }
-
- public DefaultImporter (ModuleDefinition module)
- {
- m_module = module;
- }
-
- public AssemblyNameReference ImportAssembly (AssemblyNameReference asm)
- {
- AssemblyNameReference asmRef = GetAssemblyNameReference (asm);
- if (asmRef != null)
- return asmRef;
-
- asmRef = new AssemblyNameReference (
- asm.Name, asm.Culture, asm.Version);
- asmRef.PublicKeyToken = asm.PublicKeyToken;
- asmRef.HashAlgorithm = asm.HashAlgorithm;
- m_module.AssemblyReferences.Add (asmRef);
- return asmRef;
- }
-
- AssemblyNameReference GetAssemblyNameReference (AssemblyNameReference asm)
- {
- foreach (AssemblyNameReference reference in m_module.AssemblyReferences)
- if (reference.FullName == asm.FullName)
- return reference;
-
- return null;
- }
-
- TypeReference GetTypeSpec (TypeReference t, ImportContext context)
- {
- Stack s = new Stack ();
- while (t is TypeSpecification) {
- s.Push (t);
- t = (t as TypeSpecification).ElementType;
- }
-
- TypeReference elementType = ImportTypeReference (t, context);
- while (s.Count > 0) {
- t = (TypeReference) s.Pop ();
- if (t is PointerType)
- elementType = new PointerType (elementType);
- else if (t is ArrayType) // deal with complex arrays
- elementType = new ArrayType (elementType);
- else if (t is ReferenceType)
- elementType = new ReferenceType (elementType);
- else if (t is GenericInstanceType) {
- GenericInstanceType git = t as GenericInstanceType;
- GenericInstanceType genElemType = new GenericInstanceType (elementType);
-
- context.GenericContext.CheckProvider (genElemType.GetOriginalType (), git.GenericArguments.Count);
- foreach (TypeReference arg in git.GenericArguments)
- genElemType.GenericArguments.Add (ImportTypeReference (arg, context));
-
- elementType = genElemType;
- } else
- throw new ReflectionException ("Unknown element type: {0}", t.GetType ().Name);
- }
-
- return elementType;
- }
-
- static GenericParameter GetGenericParameter (GenericParameter gp, ImportContext context)
- {
- GenericParameter p;
- if (gp.Owner is TypeReference)
- p = context.GenericContext.Type.GenericParameters [gp.Position];
- else if (gp.Owner is MethodReference)
- p = context.GenericContext.Method.GenericParameters [gp.Position];
- else
- throw new NotSupportedException ();
-
- return p;
- }
-
- public virtual TypeReference ImportTypeReference (TypeReference t, ImportContext context)
- {
- if (t.Module == m_module)
- return t;
-
- if (t is TypeSpecification)
- return GetTypeSpec (t, context);
-
- if (t is GenericParameter)
- return GetGenericParameter (t as GenericParameter, context);
-
- TypeReference type = m_module.TypeReferences [t.FullName];
- if (type != null)
- return type;
-
- AssemblyNameReference asm;
- if (t.Scope is AssemblyNameReference)
- asm = ImportAssembly ((AssemblyNameReference) t.Scope);
- else if (t.Scope is ModuleDefinition)
- asm = ImportAssembly (((ModuleDefinition) t.Scope).Assembly.Name);
- else
- throw new NotImplementedException ();
-
- type = new TypeReference (t.Name, t.Namespace, asm, t.IsValueType);
-
- context.GenericContext.Type = type;
-
- foreach (GenericParameter gp in t.GenericParameters)
- type.GenericParameters.Add (GenericParameter.Clone (gp, context));
-
- m_module.TypeReferences.Add (type);
- return type;
- }
-
- public virtual FieldReference ImportFieldReference (FieldReference fr, ImportContext context)
- {
- if (fr.DeclaringType.Module == m_module)
- return fr;
-
- FieldReference field = (FieldReference) GetMemberReference (fr);
- if (field != null)
- return field;
-
- field = new FieldReference (
- fr.Name,
- ImportTypeReference (fr.DeclaringType, context),
- ImportTypeReference (fr.FieldType, context));
-
- m_module.MemberReferences.Add (field);
- return field;
- }
-
- MethodReference GetMethodSpec (MethodReference meth, ImportContext context)
- {
- if (!(meth is GenericInstanceMethod))
- return null;
-
- GenericInstanceMethod gim = meth as GenericInstanceMethod;
- GenericInstanceMethod ngim = new GenericInstanceMethod (
- ImportMethodReference (gim.ElementMethod, context));
-
- context.GenericContext.CheckProvider (ngim.GetOriginalMethod (), gim.GenericArguments.Count);
- foreach (TypeReference arg in gim.GenericArguments)
- ngim.GenericArguments.Add (ImportTypeReference (arg, context));
-
- return ngim;
- }
-
- public virtual MethodReference ImportMethodReference (MethodReference mr, ImportContext context)
- {
- if (mr.DeclaringType.Module == m_module)
- return mr;
-
- if (mr is MethodSpecification)
- return GetMethodSpec (mr, context);
-
- MethodReference meth = (MethodReference) GetMemberReference (mr);
- if (meth != null)
- return meth;
-
- meth = new MethodReference (
- mr.Name,
- mr.HasThis,
- mr.ExplicitThis,
- mr.CallingConvention);
- meth.DeclaringType = ImportTypeReference (mr.DeclaringType, context);
-
- TypeReference contextType = meth.DeclaringType.GetOriginalType ();
-
- context.GenericContext.Method = meth;
- context.GenericContext.Type = contextType;
-
- foreach (GenericParameter gp in mr.GenericParameters)
- meth.GenericParameters.Add (GenericParameter.Clone (gp, context));
-
- meth.ReturnType.ReturnType = ImportTypeReference (mr.ReturnType.ReturnType, context);
-
- foreach (ParameterDefinition param in mr.Parameters)
- meth.Parameters.Add (new ParameterDefinition (
- ImportTypeReference (param.ParameterType, context)));
-
- m_module.MemberReferences.Add (meth);
- return meth;
- }
-
- MemberReference GetMemberReference (MemberReference member)
- {
- foreach (MemberReference reference in m_module.MemberReferences)
- if (reference.ToString () == member.ToString ())
- return reference;
-
- return null;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EmbeddedResource.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EmbeddedResource.cs
index 7bd67be..e0216da 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EmbeddedResource.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EmbeddedResource.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,31 +26,65 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+using System.IO;
+
namespace Mono.Cecil {
public sealed class EmbeddedResource : Resource {
- byte [] m_data;
+ readonly MetadataReader reader;
+
+ uint? offset;
+ byte [] data;
+ Stream stream;
- public byte [] Data {
- get { return m_data; }
- set { m_data = value; }
+ public override ResourceType ResourceType {
+ get { return ResourceType.Embedded; }
}
- public EmbeddedResource (string name, ManifestResourceAttributes flags) :
- base (name, flags)
+ public EmbeddedResource (string name, ManifestResourceAttributes attributes, byte [] data) :
+ base (name, attributes)
{
+ this.data = data;
}
- public EmbeddedResource (string name, ManifestResourceAttributes flags, byte [] data) :
- base (name, flags)
+ public EmbeddedResource (string name, ManifestResourceAttributes attributes, Stream stream) :
+ base (name, attributes)
{
- m_data = data;
+ this.stream = stream;
}
- public override void Accept (IReflectionStructureVisitor visitor)
+ internal EmbeddedResource (string name, ManifestResourceAttributes attributes, uint offset, MetadataReader reader)
+ : base (name, attributes)
{
- visitor.VisitEmbeddedResource (this);
+ this.offset = offset;
+ this.reader = reader;
+ }
+
+ public Stream GetResourceStream ()
+ {
+ if (stream != null)
+ return stream;
+
+ if (data != null)
+ return new MemoryStream (data);
+
+ if (offset.HasValue)
+ return reader.GetManagedResourceStream (offset.Value);
+
+ throw new InvalidOperationException ();
+ }
+
+ public byte [] GetResourceData ()
+ {
+ if (data != null)
+ return data;
+
+ if (offset.HasValue)
+ return reader.GetManagedResourceStream (offset.Value).ToArray ();
+
+ throw new InvalidOperationException ();
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventAttributes.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventAttributes.cs
index 2db3a3c..b5b097d 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventAttributes.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventAttributes.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,12 +26,13 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
- using System;
+namespace Mono.Cecil {
[Flags]
public enum EventAttributes : ushort {
+ None = 0x0000,
SpecialName = 0x0200, // Event is special
RTSpecialName = 0x0400 // CLI provides 'special' behavior, depending upon the name of the event
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinition.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinition.cs
index ff76cc3..7a80aa0 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinition.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinition.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,134 +26,138 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using Mono.Collections.Generic;
+
namespace Mono.Cecil {
- public sealed class EventDefinition : EventReference, IMemberDefinition, ICustomAttributeProvider {
+ public sealed class EventDefinition : EventReference, IMemberDefinition {
- EventAttributes m_attributes;
+ ushort attributes;
- CustomAttributeCollection m_customAttrs;
+ Collection<CustomAttribute> custom_attributes;
- MethodDefinition m_addMeth;
- MethodDefinition m_invMeth;
- MethodDefinition m_remMeth;
+ internal MethodDefinition add_method;
+ internal MethodDefinition invoke_method;
+ internal MethodDefinition remove_method;
+ internal Collection<MethodDefinition> other_methods;
public EventAttributes Attributes {
- get { return m_attributes; }
- set { m_attributes = value; }
+ get { return (EventAttributes) attributes; }
+ set { attributes = (ushort) value; }
}
public MethodDefinition AddMethod {
- get { return m_addMeth; }
- set { m_addMeth = value; }
+ get {
+ if (add_method != null)
+ return add_method;
+
+ InitializeMethods ();
+ return add_method;
+ }
+ set { add_method = value; }
}
public MethodDefinition InvokeMethod {
- get { return m_invMeth; }
- set { m_invMeth = value; }
+ get {
+ if (invoke_method != null)
+ return invoke_method;
+
+ InitializeMethods ();
+ return invoke_method;
+ }
+ set { invoke_method = value; }
}
public MethodDefinition RemoveMethod {
- get { return m_remMeth; }
- set { m_remMeth = value; }
+ get {
+ if (remove_method != null)
+ return remove_method;
+
+ InitializeMethods ();
+ return remove_method;
+ }
+ set { remove_method = value; }
}
- public CustomAttributeCollection CustomAttributes {
+ public bool HasOtherMethods {
get {
- if (m_customAttrs == null)
- m_customAttrs = new CustomAttributeCollection (this);
+ if (other_methods != null)
+ return other_methods.Count > 0;
- return m_customAttrs;
+ InitializeMethods ();
+ return !other_methods.IsNullOrEmpty ();
}
}
- #region EventAttributes
+ public Collection<MethodDefinition> OtherMethods {
+ get {
+ if (other_methods != null)
+ return other_methods;
- public bool IsSpecialName {
- get { return (m_attributes & EventAttributes.SpecialName) != 0; }
- set {
- if (value)
- m_attributes |= EventAttributes.SpecialName;
- else
- m_attributes &= ~EventAttributes.SpecialName;
+ InitializeMethods ();
+
+ if (other_methods != null)
+ return other_methods;
+
+ return other_methods = new Collection<MethodDefinition> ();
}
}
- public bool IsRuntimeSpecialName {
- get { return (m_attributes & EventAttributes.RTSpecialName) != 0; }
- set {
- if (value)
- m_attributes |= EventAttributes.RTSpecialName;
- else
- m_attributes &= ~EventAttributes.RTSpecialName;
+ public bool HasCustomAttributes {
+ get {
+ if (custom_attributes != null)
+ return custom_attributes.Count > 0;
+
+ return this.GetHasCustomAttributes (Module);
}
}
- #endregion
-
- public EventDefinition (string name, TypeReference eventType,
- EventAttributes attrs) : base (name, eventType)
- {
- m_attributes = attrs;
+ public Collection<CustomAttribute> CustomAttributes {
+ get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); }
}
- public static MethodDefinition CreateAddMethod (EventDefinition evt)
- {
- MethodDefinition add = new MethodDefinition (
- string.Concat ("add_", evt.Name), (MethodAttributes) 0, evt.EventType);
- evt.AddMethod = add;
- return add;
+ #region EventAttributes
+
+ public bool IsSpecialName {
+ get { return attributes.GetAttributes ((ushort) EventAttributes.SpecialName); }
+ set { attributes = attributes.SetAttributes ((ushort) EventAttributes.SpecialName, value); }
}
- public static MethodDefinition CreateRemoveMethod (EventDefinition evt)
- {
- MethodDefinition remove = new MethodDefinition (
- string.Concat ("remove_", evt.Name), (MethodAttributes) 0, evt.EventType);
- evt.RemoveMethod = remove;
- return remove;
+ public bool IsRuntimeSpecialName {
+ get { return attributes.GetAttributes ((ushort) FieldAttributes.RTSpecialName); }
+ set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.RTSpecialName, value); }
}
- public static MethodDefinition CreateInvokeMethod (EventDefinition evt)
- {
- MethodDefinition raise = new MethodDefinition (
- string.Concat ("raise_", evt.Name), (MethodAttributes) 0, evt.EventType);
- evt.InvokeMethod = raise;
- return raise;
+ #endregion
+
+ public new TypeDefinition DeclaringType {
+ get { return (TypeDefinition) base.DeclaringType; }
+ set { base.DeclaringType = value; }
}
- public EventDefinition Clone ()
- {
- return Clone (this, new ImportContext (NullReferenceImporter.Instance, this.DeclaringType));
+ public override bool IsDefinition {
+ get { return true; }
}
- internal static EventDefinition Clone (EventDefinition evt, ImportContext context)
+ public EventDefinition (string name, EventAttributes attributes, TypeReference eventType)
+ : base (name, eventType)
{
- EventDefinition ne = new EventDefinition (
- evt.Name,
- context.Import (evt.EventType),
- evt.Attributes);
-
- if (context.GenericContext.Type is TypeDefinition) {
- TypeDefinition type = context.GenericContext.Type as TypeDefinition;
- if (evt.AddMethod != null)
- ne.AddMethod = type.Methods.GetMethod (evt.AddMethod.Name) [0];
- if (evt.InvokeMethod != null)
- ne.InvokeMethod = type.Methods.GetMethod (evt.InvokeMethod.Name) [0];
- if (evt.RemoveMethod != null)
- ne.RemoveMethod = type.Methods.GetMethod (evt.RemoveMethod.Name) [0];
- }
-
- foreach (CustomAttribute ca in evt.CustomAttributes)
- ne.CustomAttributes.Add (CustomAttribute.Clone (ca, context));
-
- return ne;
+ this.attributes = (ushort) attributes;
+ this.token = new MetadataToken (TokenType.Event);
}
- public override void Accept (IReflectionVisitor visitor)
+ void InitializeMethods ()
{
- visitor.VisitEventDefinition (this);
+ if (add_method != null
+ || invoke_method != null
+ || remove_method != null)
+ return;
+
+ var module = this.Module;
+ if (!module.HasImage ())
+ return;
- this.CustomAttributes.Accept (visitor);
+ module.Read (this, (@event, reader) => reader.ReadMethods (@event));
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinitionCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinitionCollection.cs
deleted file mode 100644
index f646dfb..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventDefinitionCollection.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-//
-// EventDefinitionCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Fri Mar 30 18:43:57 +0200 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class EventDefinitionCollection : CollectionBase, IReflectionVisitable {
-
- TypeDefinition m_container;
-
- public EventDefinition this [int index] {
- get { return List [index] as EventDefinition; }
- set { List [index] = value; }
- }
-
- public TypeDefinition Container {
- get { return m_container; }
- }
-
- public EventDefinitionCollection (TypeDefinition container)
- {
- m_container = container;
- }
-
- public void Add (EventDefinition value)
- {
- Attach (value);
-
- List.Add (value);
- }
-
-
- public new void Clear ()
- {
- foreach (EventDefinition item in this)
- Detach (item);
-
- base.Clear ();
- }
-
- public bool Contains (EventDefinition value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (EventDefinition value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, EventDefinition value)
- {
- Attach (value);
-
- List.Insert (index, value);
- }
-
- public void Remove (EventDefinition value)
- {
- List.Remove (value);
-
- Detach (value);
- }
-
-
- public new void RemoveAt (int index)
- {
- EventDefinition item = this [index];
- Remove (item);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is EventDefinition))
- throw new ArgumentException ("Must be of type " + typeof (EventDefinition).FullName);
- }
-
- public EventDefinition GetEvent (string name)
- {
- foreach (EventDefinition evt in this)
- if (evt.Name == name)
- return evt;
-
- return null;
- }
-
- void Attach (MemberReference member)
- {
- if (member.DeclaringType != null)
- throw new ReflectionException ("Member already attached, clone it instead");
-
- member.DeclaringType = m_container;
- }
-
- void Detach (MemberReference member)
- {
- member.DeclaringType = null;
- }
-
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitEventDefinitionCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventReference.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventReference.cs
index 734452e..e1435da 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventReference.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/EventReference.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,25 +26,30 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
namespace Mono.Cecil {
public abstract class EventReference : MemberReference {
- TypeReference m_eventType;
+ TypeReference event_type;
public TypeReference EventType {
- get { return m_eventType; }
- set { m_eventType = value; }
+ get { return event_type; }
+ set { event_type = value; }
}
- public EventReference (string name, TypeReference eventType) : base (name)
- {
- m_eventType = eventType;
+ public override string FullName {
+ get { return event_type.FullName + " " + MemberFullName (); }
}
- public override string ToString ()
+ protected EventReference (string name, TypeReference eventType)
+ : base (name)
{
- return string.Concat (m_eventType.FullName, " ", base.ToString ());
+ if (eventType == null)
+ throw new ArgumentNullException ("eventType");
+
+ event_type = eventType;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExportedType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExportedType.cs
new file mode 100644
index 0000000..a1e793a
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExportedType.cs
@@ -0,0 +1,235 @@
+//
+// ExportedType.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Cecil {
+
+ public class ExportedType : IMetadataTokenProvider {
+
+ string @namespace;
+ string name;
+ uint attributes;
+ IMetadataScope scope;
+ int identifier;
+ ExportedType declaring_type;
+ internal MetadataToken token;
+
+ public string Namespace {
+ get { return @namespace; }
+ set { @namespace = value; }
+ }
+
+ public string Name {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public TypeAttributes Attributes {
+ get { return (TypeAttributes) attributes; }
+ set { attributes = (uint) value; }
+ }
+
+ public IMetadataScope Scope {
+ get {
+ if (declaring_type != null)
+ return declaring_type.Scope;
+
+ return scope;
+ }
+ }
+
+ public ExportedType DeclaringType {
+ get { return declaring_type; }
+ set { declaring_type = value; }
+ }
+
+ public MetadataToken MetadataToken {
+ get { return token; }
+ set { token = value; }
+ }
+
+ public int Identifier {
+ get { return identifier; }
+ set { identifier = value; }
+ }
+
+ #region TypeAttributes
+
+ public bool IsNotPublic {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NotPublic); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NotPublic, value); }
+ }
+
+ public bool IsPublic {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.Public); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.Public, value); }
+ }
+
+ public bool IsNestedPublic {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPublic); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPublic, value); }
+ }
+
+ public bool IsNestedPrivate {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPrivate); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPrivate, value); }
+ }
+
+ public bool IsNestedFamily {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamily); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamily, value); }
+ }
+
+ public bool IsNestedAssembly {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedAssembly); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedAssembly, value); }
+ }
+
+ public bool IsNestedFamilyAndAssembly {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamANDAssem); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamANDAssem, value); }
+ }
+
+ public bool IsNestedFamilyOrAssembly {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamORAssem); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamORAssem, value); }
+ }
+
+ public bool IsAutoLayout {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.AutoLayout); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.AutoLayout, value); }
+ }
+
+ public bool IsSequentialLayout {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.SequentialLayout); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.SequentialLayout, value); }
+ }
+
+ public bool IsExplicitLayout {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.ExplicitLayout); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.ExplicitLayout, value); }
+ }
+
+ public bool IsClass {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Class); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Class, value); }
+ }
+
+ public bool IsInterface {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Interface); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Interface, value); }
+ }
+
+ public bool IsAbstract {
+ get { return attributes.GetAttributes ((uint) TypeAttributes.Abstract); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Abstract, value); }
+ }
+
+ public bool IsSealed {
+ get { return attributes.GetAttributes ((uint) TypeAttributes.Sealed); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Sealed, value); }
+ }
+
+ public bool IsSpecialName {
+ get { return attributes.GetAttributes ((uint) TypeAttributes.SpecialName); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.SpecialName, value); }
+ }
+
+ public bool IsImport {
+ get { return attributes.GetAttributes ((uint) TypeAttributes.Import); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Import, value); }
+ }
+
+ public bool IsSerializable {
+ get { return attributes.GetAttributes ((uint) TypeAttributes.Serializable); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Serializable, value); }
+ }
+
+ public bool IsAnsiClass {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass, value); }
+ }
+
+ public bool IsUnicodeClass {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.UnicodeClass); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.UnicodeClass, value); }
+ }
+
+ public bool IsAutoClass {
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AutoClass); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AutoClass, value); }
+ }
+
+ public bool IsBeforeFieldInit {
+ get { return attributes.GetAttributes ((uint) TypeAttributes.BeforeFieldInit); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.BeforeFieldInit, value); }
+ }
+
+ public bool IsRuntimeSpecialName {
+ get { return attributes.GetAttributes ((uint) TypeAttributes.RTSpecialName); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.RTSpecialName, value); }
+ }
+
+ public bool HasSecurity {
+ get { return attributes.GetAttributes ((uint) TypeAttributes.HasSecurity); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.HasSecurity, value); }
+ }
+
+ #endregion
+
+ public bool IsForwarder {
+ get { return attributes.GetAttributes ((uint) TypeAttributes.Forwarder); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Forwarder, value); }
+ }
+
+ public string FullName {
+ get {
+ if (declaring_type != null)
+ return declaring_type.FullName + "/" + name;
+
+ if (string.IsNullOrEmpty (@namespace))
+ return name;
+
+ return @namespace + "." + name;
+ }
+ }
+
+ public ExportedType (string @namespace, string name, IMetadataScope scope)
+ {
+ this.@namespace = @namespace;
+ this.name = name;
+ this.scope = scope;
+ }
+
+ public override string ToString ()
+ {
+ return FullName;
+ }
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExternTypeCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExternTypeCollection.cs
deleted file mode 100644
index c40f68d..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ExternTypeCollection.cs
+++ /dev/null
@@ -1,214 +0,0 @@
-//
-// ExternTypeCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Fri Mar 30 18:43:57 +0200 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
- using System.Collections.Specialized;
-
- using Mono.Cecil.Cil;
-
- using Hcp = Mono.Cecil.HashCodeProvider;
- using Cmp = System.Collections.Comparer;
-
- public sealed class ExternTypeCollection : NameObjectCollectionBase, IList, IReflectionVisitable {
-
- ModuleDefinition m_container;
-
- public TypeReference this [int index] {
- get { return this.BaseGet (index) as TypeReference; }
- set { this.BaseSet (index, value); }
- }
-
- public TypeReference this [string fullName] {
- get { return this.BaseGet (fullName) as TypeReference; }
- set { this.BaseSet (fullName, value); }
- }
-
- public ModuleDefinition Container {
- get { return m_container; }
- }
-
- public bool IsSynchronized {
- get { return false; }
- }
-
- public object SyncRoot {
- get { return this; }
- }
-
- bool IList.IsReadOnly {
- get { return false; }
- }
-
- bool IList.IsFixedSize {
- get { return false; }
- }
-
- object IList.this [int index] {
- get { return BaseGet (index); }
- set {
- Check (value);
- BaseSet (index, value);
- }
- }
-
- public ExternTypeCollection (ModuleDefinition container) :
- base (Hcp.Instance, Cmp.Default)
- {
- m_container = container;
- }
-
- public void Add (TypeReference value)
- {
- if (value == null)
- throw new ArgumentNullException ("value");
-
- Attach (value);
-
- this.BaseAdd (value.FullName, value);
- }
-
- public void Clear ()
- {
- foreach (TypeReference item in this)
- Detach (item);
-
- this.BaseClear ();
- }
-
- public bool Contains (TypeReference value)
- {
- return Contains (value.FullName);
- }
-
- public bool Contains (string fullName)
- {
- return this.BaseGet (fullName) != null;
- }
-
- public int IndexOf (TypeReference value)
- {
- string [] keys = this.BaseGetAllKeys ();
- return Array.IndexOf (keys, value.FullName, 0, keys.Length);
- }
-
- public void Remove (TypeReference value)
- {
- this.BaseRemove (value.FullName);
-
- Detach (value);
- }
-
- public void RemoveAt (int index)
- {
- TypeReference item = this [index];
- Remove (item);
-
- Detach (item);
- }
-
- public void CopyTo (Array ary, int index)
- {
- this.BaseGetAllValues ().CopyTo (ary, index);
- }
-
- public new IEnumerator GetEnumerator ()
- {
- return this.BaseGetAllValues ().GetEnumerator ();
- }
-
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitExternTypeCollection (this);
- }
-
-#if CF_1_0 || CF_2_0
- internal object [] BaseGetAllValues ()
- {
- object [] values = new object [this.Count];
- for (int i=0; i < values.Length; ++i) {
- values [i] = this.BaseGet (i);
- }
- return values;
- }
-#endif
-
- void Check (object value)
- {
- if (!(value is TypeReference))
- throw new ArgumentException ();
- }
-
- int IList.Add (object value)
- {
- Check (value);
- Add (value as TypeReference);
- return 0;
- }
-
- bool IList.Contains (object value)
- {
- Check (value);
- return Contains (value as TypeReference);
- }
-
- int IList.IndexOf (object value)
- {
- throw new NotSupportedException ();
- }
-
- void IList.Insert (int index, object value)
- {
- throw new NotSupportedException ();
- }
-
- void IList.Remove (object value)
- {
- Check (value);
- Remove (value as TypeReference);
- }
-
- void Detach (TypeReference type)
- {
- type.Module = null;
- }
-
- void Attach (TypeReference type)
- {
- if (type.Module != null)
- throw new ReflectionException ("Type is already attached, clone it instead");
-
- type.Module = m_container;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldAttributes.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldAttributes.cs
index b7e90f0..947a877 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldAttributes.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldAttributes.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,14 +26,14 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
- using System;
+namespace Mono.Cecil {
[Flags]
public enum FieldAttributes : ushort {
FieldAccessMask = 0x0007,
- Compilercontrolled = 0x0000, // Member not referenceable
+ CompilerControlled = 0x0000, // Member not referenceable
Private = 0x0001, // Accessible only by the parent type
FamANDAssem = 0x0002, // Accessible by sub-types only in this assembly
Assembly = 0x0003, // Accessible by anyone in the Assembly
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinition.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinition.cs
index 9e3154a..c60a940 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinition.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinition.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,292 +26,254 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using Mono.Collections.Generic;
+
namespace Mono.Cecil {
- using Mono.Cecil;
- using Mono.Cecil.Binary;
+ public sealed class FieldDefinition : FieldReference, IMemberDefinition, IConstantProvider, IMarshalInfoProvider {
+
+ ushort attributes;
+ Collection<CustomAttribute> custom_attributes;
- public sealed class FieldDefinition : FieldReference, IMemberDefinition,
- ICustomAttributeProvider, IHasMarshalSpec, IHasConstant {
+ int offset = Mixin.NotResolvedMarker;
- FieldAttributes m_attributes;
+ internal int rva = Mixin.NotResolvedMarker;
+ byte [] initial_value;
- CustomAttributeCollection m_customAttrs;
+ object constant = Mixin.NotResolved;
- bool m_hasInfo;
- uint m_offset;
+ MarshalInfo marshal_info;
- RVA m_rva;
- byte [] m_initVal;
+ void ResolveLayout ()
+ {
+ if (offset != Mixin.NotResolvedMarker)
+ return;
- bool m_hasConstant;
- object m_const;
+ if (!HasImage) {
+ offset = Mixin.NoDataMarker;
+ return;
+ }
- MarshalSpec m_marshalDesc;
+ offset = Module.Read (this, (field, reader) => reader.ReadFieldLayout (field));
+ }
public bool HasLayoutInfo {
- get { return m_hasInfo; }
+ get {
+ if (offset >= 0)
+ return true;
+
+ ResolveLayout ();
+
+ return offset >= 0;
+ }
}
- public uint Offset {
- get { return m_offset; }
- set {
- m_hasInfo = true;
- m_offset = value;
+ public int Offset {
+ get {
+ if (offset >= 0)
+ return offset;
+
+ ResolveLayout ();
+
+ return offset >= 0 ? offset : -1;
}
+ set { offset = value; }
+ }
+
+ void ResolveRVA ()
+ {
+ if (rva != Mixin.NotResolvedMarker)
+ return;
+
+ if (!HasImage)
+ return;
+
+ rva = Module.Read (this, (field, reader) => reader.ReadFieldRVA (field));
}
- public RVA RVA {
- get { return m_rva; }
- set { m_rva = value; }
+ public int RVA {
+ get {
+ if (rva > 0)
+ return rva;
+
+ ResolveRVA ();
+
+ return rva > 0 ? rva : 0;
+ }
}
public byte [] InitialValue {
- get { return m_initVal; }
- set { m_initVal = value; }
+ get {
+ if (initial_value != null)
+ return initial_value;
+
+ ResolveRVA ();
+
+ if (initial_value == null)
+ initial_value = Empty<byte>.Array;
+
+ return initial_value;
+ }
+ set { initial_value = value; }
}
public FieldAttributes Attributes {
- get { return m_attributes; }
- set { m_attributes = value; }
+ get { return (FieldAttributes) attributes; }
+ set { attributes = (ushort) value; }
}
public bool HasConstant {
- get { return m_hasConstant; }
+ get {
+ ResolveConstant ();
+
+ return constant != Mixin.NoValue;
+ }
+ set { if (!value) constant = Mixin.NoValue; }
}
public object Constant {
- get { return m_const; }
- set {
- m_hasConstant = true;
- m_const = value;
- }
+ get { return HasConstant ? constant : null; }
+ set { constant = value; }
}
- public CustomAttributeCollection CustomAttributes {
+ void ResolveConstant ()
+ {
+ if (constant != Mixin.NotResolved)
+ return;
+
+ this.ResolveConstant (ref constant, Module);
+ }
+
+ public bool HasCustomAttributes {
get {
- if (m_customAttrs == null)
- m_customAttrs = new CustomAttributeCollection (this);
+ if (custom_attributes != null)
+ return custom_attributes.Count > 0;
- return m_customAttrs;
+ return this.GetHasCustomAttributes (Module);
}
}
- public MarshalSpec MarshalSpec {
- get { return m_marshalDesc; }
- set {
- m_marshalDesc = value;
- if (value != null)
- m_attributes |= FieldAttributes.HasFieldMarshal;
- else
- m_attributes &= FieldAttributes.HasFieldMarshal;
+ public Collection<CustomAttribute> CustomAttributes {
+ get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); }
+ }
+
+ public bool HasMarshalInfo {
+ get {
+ if (marshal_info != null)
+ return true;
+
+ return this.GetHasMarshalInfo (Module);
}
}
+ public MarshalInfo MarshalInfo {
+ get { return marshal_info ?? (marshal_info = this.GetMarshalInfo (Module)); }
+ set { marshal_info = value; }
+ }
+
#region FieldAttributes
public bool IsCompilerControlled {
- get { return (m_attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Compilercontrolled; }
- set {
- if (value) {
- m_attributes &= ~FieldAttributes.FieldAccessMask;
- m_attributes |= FieldAttributes.Compilercontrolled;
- } else
- m_attributes &= ~(FieldAttributes.FieldAccessMask & FieldAttributes.Compilercontrolled);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.CompilerControlled); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.CompilerControlled, value); }
}
public bool IsPrivate {
- get { return (m_attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Private; }
- set {
- if (value) {
- m_attributes &= ~FieldAttributes.FieldAccessMask;
- m_attributes |= FieldAttributes.Private;
- } else
- m_attributes &= ~(FieldAttributes.FieldAccessMask & FieldAttributes.Private);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Private); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Private, value); }
}
public bool IsFamilyAndAssembly {
- get { return (m_attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamANDAssem; }
- set {
- if (value) {
- m_attributes &= ~FieldAttributes.FieldAccessMask;
- m_attributes |= FieldAttributes.FamANDAssem;
- } else
- m_attributes &= ~(FieldAttributes.FieldAccessMask & FieldAttributes.FamANDAssem);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.FamANDAssem); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.FamANDAssem, value); }
}
public bool IsAssembly {
- get { return (m_attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Assembly; }
- set {
- if (value) {
- m_attributes &= ~FieldAttributes.FieldAccessMask;
- m_attributes |= FieldAttributes.Assembly;
- } else
- m_attributes &= ~(FieldAttributes.FieldAccessMask & FieldAttributes.Assembly);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Assembly); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Assembly, value); }
}
public bool IsFamily {
- get { return (m_attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Family; }
- set {
- if (value) {
- m_attributes &= ~FieldAttributes.FieldAccessMask;
- m_attributes |= FieldAttributes.Family;
- } else
- m_attributes &= ~(FieldAttributes.FieldAccessMask & FieldAttributes.Family);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Family); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Family, value); }
}
public bool IsFamilyOrAssembly {
- get { return (m_attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamORAssem; }
- set {
- if (value) {
- m_attributes &= ~FieldAttributes.FieldAccessMask;
- m_attributes |= FieldAttributes.FamORAssem;
- } else
- m_attributes &= ~(FieldAttributes.FieldAccessMask & FieldAttributes.FamORAssem);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.FamORAssem); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.FamORAssem, value); }
}
public bool IsPublic {
- get { return (m_attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Public; }
- set {
- if (value) {
- m_attributes &= ~FieldAttributes.FieldAccessMask;
- m_attributes |= FieldAttributes.Public;
- } else
- m_attributes &= ~(FieldAttributes.FieldAccessMask & FieldAttributes.Public);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Public); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Public, value); }
}
public bool IsStatic {
- get { return (m_attributes & FieldAttributes.Static) != 0; }
- set {
- if (value)
- m_attributes |= FieldAttributes.Static;
- else
- m_attributes &= ~FieldAttributes.Static;
- }
+ get { return attributes.GetAttributes ((ushort) FieldAttributes.Static); }
+ set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.Static, value); }
}
public bool IsInitOnly {
- get { return (m_attributes & FieldAttributes.InitOnly) != 0; }
- set {
- if (value)
- m_attributes |= FieldAttributes.InitOnly;
- else
- m_attributes &= ~FieldAttributes.InitOnly;
- }
+ get { return attributes.GetAttributes ((ushort) FieldAttributes.InitOnly); }
+ set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.InitOnly, value); }
}
public bool IsLiteral {
- get { return (m_attributes & FieldAttributes.Literal) != 0; }
- set {
- if (value)
- m_attributes |= FieldAttributes.Literal;
- else
- m_attributes &= ~FieldAttributes.Literal;
- }
+ get { return attributes.GetAttributes ((ushort) FieldAttributes.Literal); }
+ set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.Literal, value); }
}
public bool IsNotSerialized {
- get { return (m_attributes & FieldAttributes.NotSerialized) != 0; }
- set {
- if (value)
- m_attributes |= FieldAttributes.NotSerialized;
- else
- m_attributes &= ~FieldAttributes.NotSerialized;
- }
+ get { return attributes.GetAttributes ((ushort) FieldAttributes.NotSerialized); }
+ set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.NotSerialized, value); }
}
public bool IsSpecialName {
- get { return (m_attributes & FieldAttributes.SpecialName) != 0; }
- set {
- if (value)
- m_attributes |= FieldAttributes.SpecialName;
- else
- m_attributes &= ~FieldAttributes.SpecialName;
- }
+ get { return attributes.GetAttributes ((ushort) FieldAttributes.SpecialName); }
+ set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.SpecialName, value); }
}
public bool IsPInvokeImpl {
- get { return (m_attributes & FieldAttributes.PInvokeImpl) != 0; }
- set {
- if (value)
- m_attributes |= FieldAttributes.PInvokeImpl;
- else
- m_attributes &= ~FieldAttributes.PInvokeImpl;
- }
+ get { return attributes.GetAttributes ((ushort) FieldAttributes.PInvokeImpl); }
+ set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.PInvokeImpl, value); }
}
public bool IsRuntimeSpecialName {
- get { return (m_attributes & FieldAttributes.RTSpecialName) != 0; }
- set {
- if (value)
- m_attributes |= FieldAttributes.RTSpecialName;
- else
- m_attributes &= ~FieldAttributes.RTSpecialName;
- }
+ get { return attributes.GetAttributes ((ushort) FieldAttributes.RTSpecialName); }
+ set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.RTSpecialName, value); }
}
public bool HasDefault {
- get { return (m_attributes & FieldAttributes.HasDefault) != 0; }
- set {
- if (value)
- m_attributes |= FieldAttributes.HasDefault;
- else
- m_attributes &= ~FieldAttributes.HasDefault;
- }
+ get { return attributes.GetAttributes ((ushort) FieldAttributes.HasDefault); }
+ set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.HasDefault, value); }
}
#endregion
- public FieldDefinition (string name, TypeReference fieldType,
- FieldAttributes attrs) : base (name, fieldType)
- {
- m_attributes = attrs;
+ public override bool IsDefinition {
+ get { return true; }
}
- public FieldDefinition Clone ()
- {
- return Clone (this, new ImportContext (NullReferenceImporter.Instance, this.DeclaringType));
+ public new TypeDefinition DeclaringType {
+ get { return (TypeDefinition) base.DeclaringType; }
+ set { base.DeclaringType = value; }
}
- internal static FieldDefinition Clone (FieldDefinition field, ImportContext context)
+ public FieldDefinition (string name, FieldAttributes attributes, TypeReference fieldType)
+ : base (name, fieldType)
{
- FieldDefinition nf = new FieldDefinition (
- field.Name,
- context.Import (field.FieldType),
- field.Attributes);
-
- if (field.HasConstant)
- nf.Constant = field.Constant;
- if (field.MarshalSpec != null)
- nf.MarshalSpec = field.MarshalSpec;
- if (field.RVA != RVA.Zero)
- nf.InitialValue = field.InitialValue;
- else
- nf.InitialValue = new byte [0];
- if (field.HasLayoutInfo)
- nf.Offset = field.Offset;
-
- foreach (CustomAttribute ca in field.CustomAttributes)
- nf.CustomAttributes.Add (CustomAttribute.Clone (ca, context));
-
- return nf;
+ this.attributes = (ushort) attributes;
}
- public override void Accept (IReflectionVisitor visitor)
+ public override FieldDefinition Resolve ()
{
- visitor.VisitFieldDefinition (this);
+ return this;
+ }
+ }
- if (this.MarshalSpec != null)
- this.MarshalSpec.Accept (visitor);
+ static partial class Mixin {
- this.CustomAttributes.Accept (visitor);
- }
+ public const int NotResolvedMarker = -2;
+ public const int NoDataMarker = -1;
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinitionCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinitionCollection.cs
deleted file mode 100644
index 366ec3d..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldDefinitionCollection.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-//
-// FieldDefinitionCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Fri Mar 30 18:43:57 +0200 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class FieldDefinitionCollection : CollectionBase, IReflectionVisitable {
-
- TypeDefinition m_container;
-
- public FieldDefinition this [int index] {
- get { return List [index] as FieldDefinition; }
- set { List [index] = value; }
- }
-
- public TypeDefinition Container {
- get { return m_container; }
- }
-
- public FieldDefinitionCollection (TypeDefinition container)
- {
- m_container = container;
- }
-
- public void Add (FieldDefinition value)
- {
- Attach (value);
-
- List.Add (value);
- }
-
-
- public new void Clear ()
- {
- foreach (FieldDefinition item in this)
- Detach (item);
-
- base.Clear ();
- }
-
- public bool Contains (FieldDefinition value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (FieldDefinition value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, FieldDefinition value)
- {
- Attach (value);
-
- List.Insert (index, value);
- }
-
- public void Remove (FieldDefinition value)
- {
- List.Remove (value);
-
- Detach (value);
- }
-
-
- public new void RemoveAt (int index)
- {
- FieldDefinition item = this [index];
- Remove (item);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is FieldDefinition))
- throw new ArgumentException ("Must be of type " + typeof (FieldDefinition).FullName);
- }
-
- public FieldDefinition GetField (string name)
- {
- foreach (FieldDefinition field in this)
- if (field.Name == name)
- return field;
-
- return null;
- }
-
- void Attach (MemberReference member)
- {
- if (member.DeclaringType != null)
- throw new ReflectionException ("Member already attached, clone it instead");
-
- member.DeclaringType = m_container;
- }
-
- void Detach (MemberReference member)
- {
- member.DeclaringType = null;
- }
-
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitFieldDefinitionCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldReference.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldReference.cs
index d81a01a..1c812bb 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldReference.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FieldReference.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,33 +26,58 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
- using Mono.Cecil;
+namespace Mono.Cecil {
public class FieldReference : MemberReference {
- TypeReference m_fieldType;
+ TypeReference field_type;
public TypeReference FieldType {
- get { return m_fieldType; }
- set { m_fieldType = value; }
+ get { return field_type; }
+ set { field_type = value; }
+ }
+
+ public override string FullName {
+ get { return field_type.FullName + " " + MemberFullName (); }
+ }
+
+ internal override bool ContainsGenericParameter {
+ get { return field_type.ContainsGenericParameter || base.ContainsGenericParameter; }
}
- internal FieldReference (string name, TypeReference fieldType) : base (name)
+ internal FieldReference ()
{
- m_fieldType = fieldType;
+ this.token = new MetadataToken (TokenType.MemberRef);
}
- public FieldReference (string name, TypeReference declaringType, TypeReference fieldType) :
- this (name, fieldType)
+ public FieldReference (string name, TypeReference fieldType)
+ : base (name)
{
+ if (fieldType == null)
+ throw new ArgumentNullException ("fieldType");
+
+ this.field_type = fieldType;
+ this.token = new MetadataToken (TokenType.MemberRef);
+ }
+
+ public FieldReference (string name, TypeReference fieldType, TypeReference declaringType)
+ : this (name, fieldType)
+ {
+ if (declaringType == null)
+ throw new ArgumentNullException("declaringType");
+
this.DeclaringType = declaringType;
}
- public override string ToString ()
+ public virtual FieldDefinition Resolve ()
{
- return string.Concat (m_fieldType.FullName, " ", base.ToString ());
+ var module = this.Module;
+ if (module == null)
+ throw new NotSupportedException ();
+
+ return module.Resolve (this);
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FileAttributes.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FileAttributes.cs
index 1379a86..6c2781c 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FileAttributes.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FileAttributes.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,7 +28,7 @@
namespace Mono.Cecil {
- public enum FileAttributes : uint {
+ enum FileAttributes : uint {
ContainsMetaData = 0x0000, // This is not a resource file
ContainsNoMetaData = 0x0001, // This is a resource file or other non-metadata-containing file
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FunctionPointerType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FunctionPointerType.cs
index e454f19..4c1f1ba 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FunctionPointerType.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/FunctionPointerType.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 - 2007 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,41 +26,51 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
+using System.Text;
+using Mono.Collections.Generic;
+using MD = Mono.Cecil.Metadata;
- using System;
- using System.Text;
+namespace Mono.Cecil {
public sealed class FunctionPointerType : TypeSpecification, IMethodSignature {
- MethodReference m_function;
+ readonly MethodReference function;
public bool HasThis {
- get { return m_function.HasThis; }
- set { m_function.HasThis = value; }
+ get { return function.HasThis; }
+ set { function.HasThis = value; }
}
public bool ExplicitThis {
- get { return m_function.ExplicitThis; }
- set { m_function.ExplicitThis = value; }
+ get { return function.ExplicitThis; }
+ set { function.ExplicitThis = value; }
}
public MethodCallingConvention CallingConvention {
- get { return m_function.CallingConvention; }
- set { m_function.CallingConvention = value; }
+ get { return function.CallingConvention; }
+ set { function.CallingConvention = value; }
+ }
+
+ public bool HasParameters {
+ get { return function.HasParameters; }
}
- public ParameterDefinitionCollection Parameters {
- get { return m_function.Parameters; }
+ public Collection<ParameterDefinition> Parameters {
+ get { return function.Parameters; }
}
- public MethodReturnType ReturnType {
- get { return m_function.ReturnType; }
- set { m_function.ReturnType = value; }
+ public TypeReference ReturnType {
+ get { return function.MethodReturnType.ReturnType; }
+ set { function.MethodReturnType.ReturnType = value; }
+ }
+
+ public MethodReturnType MethodReturnType {
+ get { return function.MethodReturnType; }
}
public override string Name {
- get { return m_function.Name; }
+ get { return function.Name; }
set { throw new InvalidOperationException (); }
}
@@ -69,42 +79,40 @@ namespace Mono.Cecil {
set { throw new InvalidOperationException (); }
}
+ public override ModuleDefinition Module {
+ get { return ReturnType.Module; }
+ }
+
public override IMetadataScope Scope {
- get { return m_function.DeclaringType.Scope; }
+ get { return function.ReturnType.Scope; }
+ }
+
+ public override bool IsFunctionPointer {
+ get { return true; }
+ }
+
+ internal override bool ContainsGenericParameter {
+ get { return function.ContainsGenericParameter; }
}
public override string FullName {
get {
- int sentinel = GetSentinel ();
- StringBuilder sb = new StringBuilder ();
- sb.Append (m_function.Name);
- sb.Append (" ");
- sb.Append (m_function.ReturnType.ReturnType.FullName);
- sb.Append (" *(");
- for (int i = 0; i < m_function.Parameters.Count; i++) {
- if (i > 0)
- sb.Append (",");
-
- if (i == sentinel)
- sb.Append ("...,");
-
- sb.Append (m_function.Parameters [i].ParameterType.FullName);
- }
- sb.Append (")");
- return sb.ToString ();
+ var signature = new StringBuilder ();
+ signature.Append (function.Name);
+ signature.Append (" ");
+ signature.Append (function.ReturnType.FullName);
+ signature.Append (" *");
+ this.MethodSignatureFullName (signature);
+ return signature.ToString ();
}
}
- public FunctionPointerType (bool hasThis, bool explicitThis, MethodCallingConvention callConv, MethodReturnType retType) :
- base (retType.ReturnType)
- {
- m_function = new MethodReference ("method", hasThis, explicitThis, callConv);
- m_function.ReturnType = retType;
- }
-
- public int GetSentinel ()
+ public FunctionPointerType ()
+ : base (null)
{
- return m_function.GetSentinel ();
+ this.function = new MethodReference ();
+ this.function.Name = "method";
+ this.etype = MD.ElementType.FnPtr;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericArgumentCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericArgumentCollection.cs
deleted file mode 100644
index cdb82e9..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericArgumentCollection.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-//
-// GenericArgumentCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:54 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class GenericArgumentCollection : CollectionBase {
-
- IGenericInstance m_container;
-
- public TypeReference this [int index] {
- get { return List [index] as TypeReference; }
- set { List [index] = value; }
- }
-
- public IGenericInstance Container {
- get { return m_container; }
- }
-
- public GenericArgumentCollection (IGenericInstance container)
- {
- m_container = container;
- }
-
- public void Add (TypeReference value)
- {
- List.Add (value);
- }
-
- public bool Contains (TypeReference value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (TypeReference value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, TypeReference value)
- {
- List.Insert (index, value);
- }
-
- public void Remove (TypeReference value)
- {
- List.Remove (value);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is TypeReference))
- throw new ArgumentException ("Must be of type " + typeof (TypeReference).FullName);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericContext.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericContext.cs
deleted file mode 100644
index b3c198d..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericContext.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-//
-// GenericContext.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- public class GenericContext {
-
- TypeReference m_type;
- MethodReference m_method;
-
- public TypeReference Type {
- get { return m_type; }
- set { m_type = value; }
- }
-
- public MethodReference Method {
- get { return m_method; }
- set { m_method = value; }
- }
-
- public bool AllowCreation {
- get { return m_type != null && m_type.GetType () == typeof (TypeReference); }
- }
-
- public bool Null {
- get { return m_type == null && m_method == null; }
- }
-
- public GenericContext ()
- {
- }
-
- public GenericContext (TypeReference type, MethodReference meth)
- {
- m_type = type;
- m_method = meth;
- }
-
- public GenericContext (IGenericParameterProvider provider)
- {
- if (provider is TypeReference)
- m_type = provider as TypeReference;
- else if (provider is MethodReference) {
- MethodReference meth = provider as MethodReference;
- m_method = meth;
- m_type = meth.DeclaringType;
- }
- }
-
- internal void CheckProvider (IGenericParameterProvider provider, int count)
- {
- if (!AllowCreation)
- return;
-
- for (int i = provider.GenericParameters.Count; i < count; i++)
- provider.GenericParameters.Add (new GenericParameter (i, provider));
- }
-
- public GenericContext Clone ()
- {
- GenericContext ctx = new GenericContext ();
- ctx.Type = m_type;
- ctx.Method = m_method;
- return ctx;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceMethod.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceMethod.cs
index 6926bb0..d4871c3 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceMethod.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceMethod.cs
@@ -1,10 +1,10 @@
//
-// IGenericInstanceMethod.cs
+// GenericInstanceMethod.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,50 +26,65 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+using System.Text;
+
+using Mono.Collections.Generic;
+
namespace Mono.Cecil {
- using System.Text;
+ public sealed class GenericInstanceMethod : MethodSpecification, IGenericInstance, IGenericContext {
- public sealed class GenericInstanceMethod : MethodSpecification, IGenericInstance {
+ Collection<TypeReference> arguments;
- private GenericArgumentCollection m_genArgs;
+ public bool HasGenericArguments {
+ get { return !arguments.IsNullOrEmpty (); }
+ }
- public GenericArgumentCollection GenericArguments {
+ public Collection<TypeReference> GenericArguments {
get {
- if (m_genArgs == null)
- m_genArgs = new GenericArgumentCollection (this);
- return m_genArgs;
+ if (arguments == null)
+ arguments = new Collection<TypeReference> ();
+
+ return arguments;
}
}
- public GenericInstanceMethod (MethodReference elemMethod) : base (elemMethod)
- {
+ public override bool IsGenericInstance {
+ get { return true; }
}
- public override string ToString ()
- {
- StringBuilder sb = new StringBuilder ();
- MethodReference meth = this.ElementMethod;
- sb.Append (meth.ReturnType.ReturnType.FullName);
- sb.Append (" ");
- sb.Append (meth.DeclaringType.FullName);
- sb.Append ("::");
- sb.Append (meth.Name);
- sb.Append ("<");
- for (int i = 0; i < this.GenericArguments.Count; i++) {
- if (i > 0)
- sb.Append (",");
- sb.Append (this.GenericArguments [i].FullName);
- }
- sb.Append (">");
- sb.Append ("(");
- for (int i = 0; i < meth.Parameters.Count; i++) {
- sb.Append (meth.Parameters [i].ParameterType.FullName);
- if (i < meth.Parameters.Count - 1)
- sb.Append (",");
+ IGenericParameterProvider IGenericContext.Method {
+ get { return ElementMethod; }
+ }
+
+ IGenericParameterProvider IGenericContext.Type {
+ get { return ElementMethod.DeclaringType; }
+ }
+
+ internal override bool ContainsGenericParameter {
+ get { return this.ContainsGenericParameter () || base.ContainsGenericParameter; }
+ }
+
+ public override string FullName {
+ get {
+ var signature = new StringBuilder ();
+ var method = this.ElementMethod;
+ signature.Append (method.ReturnType.FullName);
+ signature.Append (" ");
+ signature.Append (method.DeclaringType.FullName);
+ signature.Append ("::");
+ signature.Append (method.Name);
+ this.GenericInstanceFullName (signature);
+ this.MethodSignatureFullName (signature);
+ return signature.ToString ();
+
}
- sb.Append (")");
- return sb.ToString ();
+ }
+
+ public GenericInstanceMethod (MethodReference method)
+ : base (method)
+ {
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceType.cs
index df015dc..699acad 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceType.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericInstanceType.cs
@@ -2,10 +2,9 @@
// GenericInstanceType.cs
//
// Author:
-// Martin Baulig <martin@ximian.com>
-// Jb Evain <jbevain@gmail.com>
+// Jb Evain (jbevain@gmail.com)
//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -27,45 +26,58 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+using System.Text;
+
+using Mono.Collections.Generic;
+
+using MD = Mono.Cecil.Metadata;
+
namespace Mono.Cecil {
- using System.Text;
+ public sealed class GenericInstanceType : TypeSpecification, IGenericInstance, IGenericContext {
- public sealed class GenericInstanceType : TypeSpecification, IGenericInstance {
+ Collection<TypeReference> arguments;
- private GenericArgumentCollection m_genArgs;
+ public bool HasGenericArguments {
+ get { return !arguments.IsNullOrEmpty (); }
+ }
- public GenericArgumentCollection GenericArguments {
+ public Collection<TypeReference> GenericArguments {
get {
- if (m_genArgs == null)
- m_genArgs = new GenericArgumentCollection (this);
- return m_genArgs;
- }
- }
+ if (arguments == null)
+ arguments = new Collection<TypeReference> ();
- public override bool IsValueType {
- get { return m_isValueType; }
- set { m_isValueType = value; }
+ return arguments;
+ }
}
public override string FullName {
get {
- StringBuilder sb = new StringBuilder ();
- sb.Append (base.FullName);
- sb.Append ("<");
- for (int i = 0; i < this.GenericArguments.Count; i++) {
- if (i > 0)
- sb.Append (",");
- sb.Append (this.GenericArguments [i].FullName);
- }
- sb.Append (">");
- return sb.ToString ();
+ var name = new StringBuilder ();
+ name.Append (base.FullName);
+ this.GenericInstanceFullName (name);
+ return name.ToString ();
}
}
- public GenericInstanceType (TypeReference elementType) : base (elementType)
+ public override bool IsGenericInstance {
+ get { return true; }
+ }
+
+ internal override bool ContainsGenericParameter {
+ get { return this.ContainsGenericParameter () || base.ContainsGenericParameter; }
+ }
+
+ IGenericParameterProvider IGenericContext.Type {
+ get { return ElementType; }
+ }
+
+ public GenericInstanceType (TypeReference type)
+ : base (type)
{
- m_isValueType = elementType.IsValueType;
+ base.IsValueType = type.IsValueType;
+ this.etype = MD.ElementType.GenericInst;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameter.cs
index 3a1b7a1..d9efb5e 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameter.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameter.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,54 +26,101 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
+using Mono.Collections.Generic;
+
+using Mono.Cecil.Metadata;
+
namespace Mono.Cecil {
- using System;
+ public sealed class GenericParameter : TypeReference, ICustomAttributeProvider {
- public sealed class GenericParameter : TypeReference {
+ readonly IGenericParameterProvider owner;
- int m_position;
- string m_name;
- GenericParameterAttributes m_attributes;
- IGenericParameterProvider m_owner;
- ConstraintCollection m_constraints;
+ ushort attributes;
+ Collection<TypeReference> constraints;
+ Collection<CustomAttribute> custom_attributes;
- public int Position {
- get { return m_position; }
- set { m_position = value; }
+ public GenericParameterAttributes Attributes {
+ get { return (GenericParameterAttributes) attributes; }
+ set { attributes = (ushort) value; }
}
- public GenericParameterAttributes Attributes {
- get { return m_attributes; }
- set { m_attributes = value; }
+ public int Position {
+ get {
+ if (owner == null)
+ return -1;
+
+ return owner.GenericParameters.IndexOf (this);
+ }
}
public IGenericParameterProvider Owner {
- get { return m_owner; }
+ get { return owner; }
+ }
+
+ public bool HasConstraints {
+ get {
+ if (constraints != null)
+ return constraints.Count > 0;
+
+ if (HasImage)
+ return Module.Read (this, (generic_parameter, reader) => reader.HasGenericConstraints (generic_parameter));
+
+ return false;
+ }
+ }
+
+ public Collection<TypeReference> Constraints {
+ get {
+ if (constraints != null)
+ return constraints;
+
+ if (HasImage)
+ return constraints = Module.Read (this, (generic_parameter, reader) => reader.ReadGenericConstraints (generic_parameter));
+
+ return constraints = new Collection<TypeReference> ();
+ }
+ }
+
+ public bool HasCustomAttributes {
+ get {
+ if (custom_attributes != null)
+ return custom_attributes.Count > 0;
+
+ return this.GetHasCustomAttributes (Module);
+ }
+ }
+
+ public Collection<CustomAttribute> CustomAttributes {
+ get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); }
+ }
+
+ internal new bool HasImage {
+ get { return Module != null && Module.HasImage; }
}
- public ConstraintCollection Constraints {
+ public override IMetadataScope Scope {
get {
- if (m_constraints == null)
- m_constraints = new ConstraintCollection (this);
+ if (owner.GenericParameterType == GenericParameterType.Method)
+ return ((MethodReference) owner).DeclaringType.Scope;
- return m_constraints;
+ return ((TypeReference) owner).Scope;
}
}
+ public override ModuleDefinition Module {
+ get { return ((MemberReference) owner).Module; }
+ }
+
public override string Name {
get {
- if (m_name != null)
- return m_name;
-
- if (m_owner is TypeReference)
- return string.Concat ("!", m_position.ToString ());
- else if (m_owner is MethodReference)
- return string.Concat ("!!", m_position.ToString ());
- else
- throw new InvalidOperationException ();
+ if (!string.IsNullOrEmpty (base.Name))
+ return base.Name;
+
+ return base.Name = (owner.GenericParameterType == GenericParameterType.Type ? "!" : "!!") + Position;
}
- set { m_name = value; }
}
public override string Namespace {
@@ -85,109 +132,65 @@ namespace Mono.Cecil {
get { return Name; }
}
+ public override bool IsGenericParameter {
+ get { return true; }
+ }
+
+ internal override bool ContainsGenericParameter {
+ get { return true; }
+ }
+
+ public override MetadataType MetadataType {
+ get { return (MetadataType) etype; }
+ }
+
#region GenericParameterAttributes
public bool IsNonVariant {
- get { return (m_attributes & GenericParameterAttributes.VarianceMask) == GenericParameterAttributes.NonVariant; }
- set {
- if (value) {
- m_attributes &= ~GenericParameterAttributes.VarianceMask;
- m_attributes |= GenericParameterAttributes.NonVariant;
- } else
- m_attributes &= ~(GenericParameterAttributes.VarianceMask & GenericParameterAttributes.NonVariant);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) GenericParameterAttributes.VarianceMask, (ushort) GenericParameterAttributes.NonVariant); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) GenericParameterAttributes.VarianceMask, (ushort) GenericParameterAttributes.NonVariant, value); }
}
public bool IsCovariant {
- get { return (m_attributes & GenericParameterAttributes.VarianceMask) == GenericParameterAttributes.Covariant; }
- set {
- if (value) {
- m_attributes &= ~GenericParameterAttributes.VarianceMask;
- m_attributes |= GenericParameterAttributes.Covariant;
- } else
- m_attributes &= ~(GenericParameterAttributes.VarianceMask & GenericParameterAttributes.Covariant);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) GenericParameterAttributes.VarianceMask, (ushort) GenericParameterAttributes.Covariant); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) GenericParameterAttributes.VarianceMask, (ushort) GenericParameterAttributes.Covariant, value); }
}
public bool IsContravariant {
- get { return (m_attributes & GenericParameterAttributes.VarianceMask) == GenericParameterAttributes.Contravariant; }
- set {
- if (value) {
- m_attributes &= ~GenericParameterAttributes.VarianceMask;
- m_attributes |= GenericParameterAttributes.Contravariant;
- } else
- m_attributes &= ~(GenericParameterAttributes.VarianceMask & GenericParameterAttributes.Contravariant);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) GenericParameterAttributes.VarianceMask, (ushort) GenericParameterAttributes.Contravariant); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) GenericParameterAttributes.VarianceMask, (ushort) GenericParameterAttributes.Contravariant, value); }
}
public bool HasReferenceTypeConstraint {
- get { return (m_attributes & GenericParameterAttributes.SpecialConstraintMask) == GenericParameterAttributes.ReferenceTypeConstraint; }
- set {
- if (value) {
- m_attributes &= ~GenericParameterAttributes.SpecialConstraintMask;
- m_attributes |= GenericParameterAttributes.ReferenceTypeConstraint;
- } else
- m_attributes &= ~(GenericParameterAttributes.SpecialConstraintMask & GenericParameterAttributes.ReferenceTypeConstraint);
- }
+ get { return attributes.GetAttributes ((ushort) GenericParameterAttributes.ReferenceTypeConstraint); }
+ set { attributes = attributes.SetAttributes ((ushort) GenericParameterAttributes.ReferenceTypeConstraint, value); }
}
public bool HasNotNullableValueTypeConstraint {
- get { return (m_attributes & GenericParameterAttributes.SpecialConstraintMask) == GenericParameterAttributes.NotNullableValueTypeConstraint; }
- set {
- if (value) {
- m_attributes &= ~GenericParameterAttributes.SpecialConstraintMask;
- m_attributes |= GenericParameterAttributes.NotNullableValueTypeConstraint;
- } else
- m_attributes &= ~(GenericParameterAttributes.SpecialConstraintMask & GenericParameterAttributes.NotNullableValueTypeConstraint);
- }
+ get { return attributes.GetAttributes ((ushort) GenericParameterAttributes.NotNullableValueTypeConstraint); }
+ set { attributes = attributes.SetAttributes ((ushort) GenericParameterAttributes.NotNullableValueTypeConstraint, value); }
}
public bool HasDefaultConstructorConstraint {
- get { return (m_attributes & GenericParameterAttributes.SpecialConstraintMask) == GenericParameterAttributes.DefaultConstructorConstraint; }
- set {
- if (value) {
- m_attributes &= ~GenericParameterAttributes.SpecialConstraintMask;
- m_attributes |= GenericParameterAttributes.DefaultConstructorConstraint;
- } else
- m_attributes &= ~(GenericParameterAttributes.SpecialConstraintMask & GenericParameterAttributes.DefaultConstructorConstraint);
- }
+ get { return attributes.GetAttributes ((ushort) GenericParameterAttributes.DefaultConstructorConstraint); }
+ set { attributes = attributes.SetAttributes ((ushort) GenericParameterAttributes.DefaultConstructorConstraint, value); }
}
#endregion
- internal GenericParameter (int pos, IGenericParameterProvider owner) :
- base (string.Empty, string.Empty)
+ public GenericParameter (IGenericParameterProvider owner)
+ : this (string.Empty, owner)
{
- m_position = pos;
- m_owner = owner;
}
- public GenericParameter (string name, IGenericParameterProvider owner) :
- base (string.Empty, string.Empty)
+ public GenericParameter (string name, IGenericParameterProvider owner)
+ : base (string.Empty, name)
{
- m_name = name;
- m_owner = owner;
- }
+ if (owner == null)
+ throw new ArgumentNullException ();
- internal static GenericParameter Clone (GenericParameter gp, ImportContext context)
- {
- GenericParameter ngp;
- if (gp.Owner is TypeReference)
- ngp = new GenericParameter (gp.m_name, context.GenericContext.Type);
- else if (gp.Owner is MethodReference)
- ngp = new GenericParameter (gp.m_name, context.GenericContext.Method);
- else
- throw new NotSupportedException ();
-
- ngp.Position = gp.Owner.GenericParameters.IndexOf (gp);
- ngp.Attributes = gp.Attributes;
-
- foreach (TypeReference constraint in gp.Constraints)
- ngp.Constraints.Add (context.Import (constraint));
- foreach (CustomAttribute ca in gp.CustomAttributes)
- ngp.CustomAttributes.Add (CustomAttribute.Clone (ca, context));
-
- return ngp;
+ this.owner = owner;
+ this.etype = owner.GenericParameterType == GenericParameterType.Type ? ElementType.Var : ElementType.MVar;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterAttributes.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterAttributes.cs
index d7d65c7..8999614 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterAttributes.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterAttributes.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 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,9 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
- using System;
+namespace Mono.Cecil {
[Flags]
public enum GenericParameterAttributes : ushort {
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterCollection.cs
deleted file mode 100644
index fc00972..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/GenericParameterCollection.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// GenericParameterCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:53 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class GenericParameterCollection : CollectionBase, IReflectionVisitable {
-
- IGenericParameterProvider m_container;
-
- public GenericParameter this [int index] {
- get { return List [index] as GenericParameter; }
- set { List [index] = value; }
- }
-
- public IGenericParameterProvider Container {
- get { return m_container; }
- }
-
- public GenericParameterCollection (IGenericParameterProvider container)
- {
- m_container = container;
- }
-
- public void Add (GenericParameter value)
- {
- List.Add (value);
- }
-
- public bool Contains (GenericParameter value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (GenericParameter value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, GenericParameter value)
- {
- List.Insert (index, value);
- }
-
- public void Remove (GenericParameter value)
- {
- List.Remove (value);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is GenericParameter))
- throw new ArgumentException ("Must be of type " + typeof (GenericParameter).FullName);
- }
-
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitGenericParameterCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAnnotationProvider.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAnnotationProvider.cs
deleted file mode 100644
index bf5e249..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAnnotationProvider.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// AssemblyDefinition.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System.Collections;
-
- public interface IAnnotationProvider {
-
- IDictionary Annotations { get; }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAssemblyResolver.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAssemblyResolver.cs
deleted file mode 100644
index 3619d4e..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IAssemblyResolver.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// IAssemblyResolver.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- public interface IAssemblyResolver {
-
- AssemblyDefinition Resolve (string fullName);
- AssemblyDefinition Resolve (AssemblyNameReference name);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasConstant.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IConstantProvider.cs
index e2126b4..361fbe4 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasConstant.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IConstantProvider.cs
@@ -1,10 +1,10 @@
//
-// IHasConstant.cs
+// IConstantProvider.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,9 +28,25 @@
namespace Mono.Cecil {
- public interface IHasConstant : IMetadataTokenProvider {
+ public interface IConstantProvider : IMetadataTokenProvider {
bool HasConstant { get; }
object Constant { get; set; }
}
+
+ static partial class Mixin {
+
+ internal static object NoValue = new object ();
+ internal static object NotResolved = new object ();
+
+ public static void ResolveConstant (
+ this IConstantProvider self,
+ ref object constant,
+ ModuleDefinition module)
+ {
+ constant = module.HasImage ()
+ ? module.Read (self, (provider, reader) => reader.ReadConstant (provider))
+ : Mixin.NoValue;
+ }
+ }
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ICustomAttributeProvider.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ICustomAttributeProvider.cs
index 10c1f1d..08e5f92 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ICustomAttributeProvider.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ICustomAttributeProvider.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,12 +26,37 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
+using Mono.Collections.Generic;
+
namespace Mono.Cecil {
- using System.Reflection;
+ public interface ICustomAttributeProvider : IMetadataTokenProvider {
+
+ Collection<CustomAttribute> CustomAttributes { get; }
+
+ bool HasCustomAttributes { get; }
+ }
+
+ static partial class Mixin {
- public interface ICustomAttributeProvider {
+ public static bool GetHasCustomAttributes (
+ this ICustomAttributeProvider self,
+ ModuleDefinition module)
+ {
+ return module.HasImage ()
+ ? module.Read (self, (provider, reader) => reader.HasCustomAttributes (provider))
+ : false;
+ }
- CustomAttributeCollection CustomAttributes { get; }
+ public static Collection<CustomAttribute> GetCustomAttributes (
+ this ICustomAttributeProvider self,
+ ModuleDefinition module)
+ {
+ return module.HasImage ()
+ ? module.Read (self, (provider, reader) => reader.ReadCustomAttributes (provider))
+ : new Collection<CustomAttribute> ();
+ }
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IDetailReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IDetailReader.cs
deleted file mode 100644
index ca70132..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IDetailReader.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// IDetailReader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- internal interface IDetailReader {
-
- void ReadSemantic (EventDefinition evt);
- void ReadSemantic (PropertyDefinition prop);
-
- void ReadMarshalSpec (ParameterDefinition param);
- void ReadMarshalSpec (FieldDefinition field);
-
- void ReadLayout (TypeDefinition type);
- void ReadLayout (FieldDefinition field);
-
- void ReadConstant (FieldDefinition field);
- void ReadConstant (PropertyDefinition prop);
- void ReadConstant (ParameterDefinition param);
-
- void ReadInitialValue (FieldDefinition field);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericInstance.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericInstance.cs
index 43f60fc..2750ad0 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericInstance.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericInstance.cs
@@ -1,10 +1,10 @@
//
-// IGenericInstanceMethod.cs
+// IGenericInstance.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,10 +26,41 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System.Text;
+
+using Mono.Collections.Generic;
+
namespace Mono.Cecil {
public interface IGenericInstance : IMetadataTokenProvider {
- GenericArgumentCollection GenericArguments { get; }
+ bool HasGenericArguments { get; }
+ Collection<TypeReference> GenericArguments { get; }
+ }
+
+ static partial class Mixin {
+
+ public static bool ContainsGenericParameter (this IGenericInstance self)
+ {
+ var arguments = self.GenericArguments;
+
+ for (int i = 0; i < arguments.Count; i++)
+ if (arguments [i].ContainsGenericParameter)
+ return true;
+
+ return false;
+ }
+
+ public static void GenericInstanceFullName (this IGenericInstance self, StringBuilder builder)
+ {
+ builder.Append ("<");
+ var arguments = self.GenericArguments;
+ for (int i = 0; i < arguments.Count; i++) {
+ if (i > 0)
+ builder.Append (",");
+ builder.Append (arguments [i].FullName);
+ }
+ builder.Append (">");
+ }
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericParameterProvider.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericParameterProvider.cs
index df2c23f..27d1669 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericParameterProvider.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IGenericParameterProvider.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,10 +26,50 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+
+using Mono.Collections.Generic;
+
namespace Mono.Cecil {
public interface IGenericParameterProvider : IMetadataTokenProvider {
- GenericParameterCollection GenericParameters { get; }
+ bool HasGenericParameters { get; }
+ bool IsDefinition { get; }
+ ModuleDefinition Module { get; }
+ Collection<GenericParameter> GenericParameters { get; }
+ GenericParameterType GenericParameterType { get; }
+ }
+
+ public enum GenericParameterType {
+ Type,
+ Method
+ }
+
+ interface IGenericContext {
+
+ bool IsDefinition { get; }
+ IGenericParameterProvider Type { get; }
+ IGenericParameterProvider Method { get; }
+ }
+
+ static partial class Mixin {
+
+ public static bool GetHasGenericParameters (
+ this IGenericParameterProvider self,
+ ModuleDefinition module)
+ {
+ return module.HasImage ()
+ ? module.Read (self, (provider, reader) => reader.HasGenericParameters (provider))
+ : false;
+ }
+
+ public static Collection<GenericParameter> GetGenericParameters (
+ this IGenericParameterProvider self,
+ ModuleDefinition module)
+ {
+ return module.HasImage ()
+ ? module.Read (self, (provider, reader) => reader.ReadGenericParameters (provider))
+ : new Collection<GenericParameter> ();
+ }
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasMarshalSpec.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasMarshalSpec.cs
deleted file mode 100644
index 69f69d6..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasMarshalSpec.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// IHasMarshalSpec.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- public interface IHasMarshalSpec : IMetadataTokenProvider {
-
- MarshalSpec MarshalSpec { get; set; }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasSecurity.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasSecurity.cs
deleted file mode 100644
index a8f5b9a..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IHasSecurity.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// IHasSecurity.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- public interface IHasSecurity : IMetadataTokenProvider {
-
- SecurityDeclarationCollection SecurityDeclarations { get; }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IImporter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IImporter.cs
deleted file mode 100644
index b9ee8b0..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IImporter.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// IImporter.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- public interface IImporter {
-
- TypeReference ImportTypeReference (TypeReference type, ImportContext context);
- FieldReference ImportFieldReference (FieldReference field, ImportContext context);
- MethodReference ImportMethodReference (MethodReference method, ImportContext context);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayDimension.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMarshalInfoProvider.cs
index e7dafbb..a3bba6d 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayDimension.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMarshalInfoProvider.cs
@@ -1,10 +1,10 @@
//
-// ArrayDimension.cs
+// IMarshalInfoProvider.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,32 +28,30 @@
namespace Mono.Cecil {
- public sealed class ArrayDimension {
+ public interface IMarshalInfoProvider : IMetadataTokenProvider {
- int m_lowerBound;
- int m_upperBound;
-
- public int LowerBound {
- get { return m_lowerBound; }
- set { m_lowerBound = value; }
- }
+ bool HasMarshalInfo { get; }
+ MarshalInfo MarshalInfo { get; set; }
+ }
- public int UpperBound {
- get { return m_upperBound; }
- set { m_upperBound = value; }
- }
+ static partial class Mixin {
- public ArrayDimension (int lb, int ub)
+ public static bool GetHasMarshalInfo (
+ this IMarshalInfoProvider self,
+ ModuleDefinition module)
{
- m_lowerBound = lb;
- m_upperBound = ub;
+ return module.HasImage ()
+ ? module.Read (self, (provider, reader) => reader.HasMarshalInfo (provider))
+ : false;
}
- public override string ToString ()
+ public static MarshalInfo GetMarshalInfo (
+ this IMarshalInfoProvider self,
+ ModuleDefinition module)
{
- if (m_upperBound == 0)
- return string.Empty;
- return string.Concat (m_lowerBound, "...", m_upperBound);
+ return module.HasImage ()
+ ? module.Read (self, (provider, reader) => reader.ReadMarshalInfo (provider))
+ : null;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberDefinition.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberDefinition.cs
index dc618fa..09878f7 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberDefinition.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberDefinition.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,9 +28,73 @@
namespace Mono.Cecil {
- public interface IMemberDefinition : IMemberReference {
+ public interface IMemberDefinition : ICustomAttributeProvider {
+
+ string Name { get; set; }
+ string FullName { get; }
bool IsSpecialName { get; set; }
bool IsRuntimeSpecialName { get; set; }
+
+ TypeDefinition DeclaringType { get; set; }
+ }
+
+ static partial class Mixin {
+
+ public static bool GetAttributes (this uint self, uint attributes)
+ {
+ return (self & attributes) != 0;
+ }
+
+ public static uint SetAttributes (this uint self, uint attributes, bool value)
+ {
+ if (value)
+ return self | attributes;
+
+ return self & ~attributes;
+ }
+
+ public static bool GetMaskedAttributes (this uint self, uint mask, uint attributes)
+ {
+ return (self & mask) == attributes;
+ }
+
+ public static uint SetMaskedAttributes (this uint self, uint mask, uint attributes, bool value)
+ {
+ if (value) {
+ self &= ~mask;
+ return self | attributes;
+ }
+
+ return self & ~(mask & attributes);
+ }
+
+ public static bool GetAttributes (this ushort self, ushort attributes)
+ {
+ return (self & attributes) != 0;
+ }
+
+ public static ushort SetAttributes (this ushort self, ushort attributes, bool value)
+ {
+ if (value)
+ return (ushort) (self | attributes);
+
+ return (ushort) (self & ~attributes);
+ }
+
+ public static bool GetMaskedAttributes (this ushort self, ushort mask, uint attributes)
+ {
+ return (self & mask) == attributes;
+ }
+
+ public static ushort SetMaskedAttributes (this ushort self, ushort mask, uint attributes, bool value)
+ {
+ if (value) {
+ self = (ushort) (self & ~mask);
+ return (ushort) (self | attributes);
+ }
+
+ return (ushort) (self & ~(mask & attributes));
+ }
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberReference.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberReference.cs
deleted file mode 100644
index 016565f..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMemberReference.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// IMemberReference.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- public interface IMemberReference : IMetadataTokenProvider, IAnnotationProvider, IReflectionVisitable {
-
- string Name { get; set; }
- TypeReference DeclaringType { get; }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataScope.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataScope.cs
index d0a0eac..f0ab506 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataScope.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataScope.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,7 +28,14 @@
namespace Mono.Cecil {
+ public enum MetadataScopeType {
+ AssemblyNameReference,
+ ModuleReference,
+ ModuleDefinition,
+ }
+
public interface IMetadataScope : IMetadataTokenProvider {
+ MetadataScopeType MetadataScopeType { get; }
string Name { get; set; }
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataTokenProvider.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataTokenProvider.cs
index 332f1af..ff77724 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataTokenProvider.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMetadataTokenProvider.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,8 +28,6 @@
namespace Mono.Cecil {
- using Mono.Cecil.Metadata;
-
public interface IMetadataTokenProvider {
MetadataToken MetadataToken { get; set; }
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMethodSignature.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMethodSignature.cs
index 385a481..6bae56a 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMethodSignature.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IMethodSignature.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 - 2007 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,17 +26,45 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System.Text;
+
+using Mono.Collections.Generic;
+
namespace Mono.Cecil {
- public interface IMethodSignature {
+ public interface IMethodSignature : IMetadataTokenProvider {
bool HasThis { get; set; }
bool ExplicitThis { get; set; }
MethodCallingConvention CallingConvention { get; set; }
- ParameterDefinitionCollection Parameters { get; }
- MethodReturnType ReturnType { get; }
+ bool HasParameters { get; }
+ Collection<ParameterDefinition> Parameters { get; }
+ TypeReference ReturnType { get; set; }
+ MethodReturnType MethodReturnType { get; }
+ }
+
+ static partial class Mixin {
+
+ public static void MethodSignatureFullName (this IMethodSignature self, StringBuilder builder)
+ {
+ builder.Append ("(");
+
+ if (self.HasParameters) {
+ var parameters = self.Parameters;
+ for (int i = 0; i < parameters.Count; i++) {
+ var parameter = parameters [i];
+ if (i > 0)
+ builder.Append (",");
+
+ if (parameter.ParameterType.IsSentinel)
+ builder.Append ("...,");
+
+ builder.Append (parameter.ParameterType.FullName);
+ }
+ }
- int GetSentinel ();
+ builder.Append (")");
+ }
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitable.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitable.cs
deleted file mode 100644
index f522cf1..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitable.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// IReflectionStructureVisitable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- public interface IReflectionStructureVisitable {
-
- void Accept (IReflectionStructureVisitor visitor);
- }
-}
-
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitor.cs
deleted file mode 100644
index 81a6e3b..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionStructureVisitor.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// IReflectionStructureVisitor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- public interface IReflectionStructureVisitor {
-
- void VisitAssemblyDefinition (AssemblyDefinition asm);
- void VisitAssemblyNameDefinition (AssemblyNameDefinition name);
- void VisitAssemblyNameReferenceCollection (AssemblyNameReferenceCollection names);
- void VisitAssemblyNameReference (AssemblyNameReference name);
- void VisitResourceCollection (ResourceCollection resources);
- void VisitEmbeddedResource (EmbeddedResource res);
- void VisitLinkedResource (LinkedResource res);
- void VisitAssemblyLinkedResource (AssemblyLinkedResource res);
- void VisitModuleDefinition (ModuleDefinition module);
- void VisitModuleDefinitionCollection (ModuleDefinitionCollection modules);
- void VisitModuleReference (ModuleReference module);
- void VisitModuleReferenceCollection (ModuleReferenceCollection modules);
-
- void TerminateAssemblyDefinition (AssemblyDefinition asm);
- }
-}
-
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitable.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitable.cs
deleted file mode 100644
index ac4f706..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitable.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// IReflectionVisitable.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- public interface IReflectionVisitable {
-
- void Accept (IReflectionVisitor visitor);
- }
-}
-
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitor.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitor.cs
deleted file mode 100644
index c85633b..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IReflectionVisitor.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-//
-// IReflectionVisitor.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- public interface IReflectionVisitor {
-
- void VisitModuleDefinition (ModuleDefinition module);
- void VisitTypeDefinitionCollection (TypeDefinitionCollection types);
- void VisitTypeDefinition (TypeDefinition type);
- void VisitTypeReferenceCollection (TypeReferenceCollection refs);
- void VisitTypeReference (TypeReference type);
- void VisitMemberReferenceCollection (MemberReferenceCollection members);
- void VisitMemberReference (MemberReference member);
- void VisitInterfaceCollection (InterfaceCollection interfaces);
- void VisitInterface (TypeReference interf);
- void VisitExternTypeCollection (ExternTypeCollection externs);
- void VisitExternType (TypeReference externType);
- void VisitOverrideCollection (OverrideCollection meth);
- void VisitOverride (MethodReference ov);
- void VisitNestedTypeCollection (NestedTypeCollection nestedTypes);
- void VisitNestedType (TypeDefinition nestedType);
- void VisitParameterDefinitionCollection (ParameterDefinitionCollection parameters);
- void VisitParameterDefinition (ParameterDefinition parameter);
- void VisitMethodDefinitionCollection (MethodDefinitionCollection methods);
- void VisitMethodDefinition (MethodDefinition method);
- void VisitConstructorCollection (ConstructorCollection ctors);
- void VisitConstructor (MethodDefinition ctor);
- void VisitPInvokeInfo (PInvokeInfo pinvk);
- void VisitEventDefinitionCollection (EventDefinitionCollection events);
- void VisitEventDefinition (EventDefinition evt);
- void VisitFieldDefinitionCollection (FieldDefinitionCollection fields);
- void VisitFieldDefinition (FieldDefinition field);
- void VisitPropertyDefinitionCollection (PropertyDefinitionCollection properties);
- void VisitPropertyDefinition (PropertyDefinition property);
- void VisitSecurityDeclarationCollection (SecurityDeclarationCollection secDecls);
- void VisitSecurityDeclaration (SecurityDeclaration secDecl);
- void VisitCustomAttributeCollection (CustomAttributeCollection customAttrs);
- void VisitCustomAttribute (CustomAttribute customAttr);
- void VisitGenericParameterCollection (GenericParameterCollection genparams);
- void VisitGenericParameter (GenericParameter genparam);
- void VisitMarshalSpec (MarshalSpec marshalSpec);
-
- void TerminateModuleDefinition (ModuleDefinition module);
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IRequireResolving.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IRequireResolving.cs
deleted file mode 100644
index 92eac83..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/IRequireResolving.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// IRequireResolving.cs
-//
-// Author:
-// Jb Evain <jbevain@gmail.com>
-//
-// Copyright (C) 2006 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- public interface IRequireResolving {
-
- byte [] Blob { get; }
- bool Resolved { get; }
- bool Resolve ();
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Import.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Import.cs
new file mode 100644
index 0000000..52a31b0
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Import.cs
@@ -0,0 +1,568 @@
+//
+// Import.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using SR = System.Reflection;
+
+using Mono.Cecil.Metadata;
+
+namespace Mono.Cecil {
+
+ enum ImportGenericKind {
+ Definition,
+ Open,
+ }
+
+ class MetadataImporter {
+
+ readonly ModuleDefinition module;
+
+ public MetadataImporter (ModuleDefinition module)
+ {
+ this.module = module;
+ }
+
+#if !CF
+ static readonly Dictionary<Type, ElementType> type_etype_mapping = new Dictionary<Type, ElementType> (18) {
+ { typeof (void), ElementType.Void },
+ { typeof (bool), ElementType.Boolean },
+ { typeof (char), ElementType.Char },
+ { typeof (sbyte), ElementType.I1 },
+ { typeof (byte), ElementType.U1 },
+ { typeof (short), ElementType.I2 },
+ { typeof (ushort), ElementType.U2 },
+ { typeof (int), ElementType.I4 },
+ { typeof (uint), ElementType.U4 },
+ { typeof (long), ElementType.I8 },
+ { typeof (ulong), ElementType.U8 },
+ { typeof (float), ElementType.R4 },
+ { typeof (double), ElementType.R8 },
+ { typeof (string), ElementType.String },
+ { typeof (TypedReference), ElementType.TypedByRef },
+ { typeof (IntPtr), ElementType.I },
+ { typeof (UIntPtr), ElementType.U },
+ { typeof (object), ElementType.Object },
+ };
+
+ public TypeReference ImportType (Type type, IGenericContext context)
+ {
+ return ImportType (type, context, ImportGenericKind.Open);
+ }
+
+ public TypeReference ImportType (Type type, IGenericContext context, ImportGenericKind import_kind)
+ {
+ if (IsTypeSpecification (type) || ImportOpenGenericType (type, import_kind))
+ return ImportTypeSpecification (type, context);
+
+ var reference = new TypeReference (
+ string.Empty,
+ type.Name,
+ ImportScope (type.Assembly),
+ type.IsValueType);
+
+ reference.etype = ImportElementType (type);
+ reference.module = module;
+
+ if (IsNestedType (type))
+ reference.DeclaringType = ImportType (type.DeclaringType, context, import_kind);
+ else
+ reference.Namespace = type.Namespace;
+
+ if (type.IsGenericType)
+ ImportGenericParameters (reference, type.GetGenericArguments ());
+
+ return reference;
+ }
+
+ static bool ImportOpenGenericType (Type type, ImportGenericKind import_kind)
+ {
+ return type.IsGenericType && type.IsGenericTypeDefinition && import_kind == ImportGenericKind.Open;
+ }
+
+ static bool ImportOpenGenericMethod (SR.MethodBase method, ImportGenericKind import_kind)
+ {
+ return method.IsGenericMethod && method.IsGenericMethodDefinition && import_kind == ImportGenericKind.Open;
+ }
+
+ static bool IsNestedType (Type type)
+ {
+#if !SILVERLIGHT
+ return type.IsNested;
+#else
+ return type.DeclaringType != null;
+#endif
+ }
+
+ TypeReference ImportTypeSpecification (Type type, IGenericContext context)
+ {
+ if (type.IsByRef)
+ return new ByReferenceType (ImportType (type.GetElementType (), context));
+
+ if (type.IsPointer)
+ return new PointerType (ImportType (type.GetElementType (), context));
+
+ if (type.IsArray)
+ return new ArrayType (ImportType (type.GetElementType (), context), type.GetArrayRank ());
+
+ if (type.IsGenericType)
+ return ImportGenericInstance (type, context);
+
+ if (type.IsGenericParameter)
+ return ImportGenericParameter (type, context);
+
+ throw new NotSupportedException (type.FullName);
+ }
+
+ static TypeReference ImportGenericParameter (Type type, IGenericContext context)
+ {
+ if (context == null)
+ throw new InvalidOperationException ();
+
+ var owner = type.DeclaringMethod != null
+ ? context.Method
+ : context.Type;
+
+ if (owner == null)
+ throw new InvalidOperationException ();
+
+ return owner.GenericParameters [type.GenericParameterPosition];
+ }
+
+ TypeReference ImportGenericInstance (Type type, IGenericContext context)
+ {
+ var element_type = ImportType (type.GetGenericTypeDefinition (), context, ImportGenericKind.Definition);
+ var instance = new GenericInstanceType (element_type);
+ var arguments = type.GetGenericArguments ();
+ var instance_arguments = instance.GenericArguments;
+
+ for (int i = 0; i < arguments.Length; i++)
+ instance_arguments.Add (ImportType (arguments [i], context ?? element_type));
+
+ return instance;
+ }
+
+ static bool IsTypeSpecification (Type type)
+ {
+ return type.HasElementType
+ || IsGenericInstance (type)
+ || type.IsGenericParameter;
+ }
+
+ static bool IsGenericInstance (Type type)
+ {
+ return type.IsGenericType && !type.IsGenericTypeDefinition;
+ }
+
+ static ElementType ImportElementType (Type type)
+ {
+ ElementType etype;
+ if (!type_etype_mapping.TryGetValue (type, out etype))
+ return ElementType.None;
+
+ return etype;
+ }
+
+ AssemblyNameReference ImportScope (SR.Assembly assembly)
+ {
+ AssemblyNameReference scope;
+#if !SILVERLIGHT
+ var name = assembly.GetName ();
+
+ if (TryGetAssemblyNameReference (name, out scope))
+ return scope;
+
+ scope = new AssemblyNameReference (name.Name, name.Version) {
+ Culture = name.CultureInfo.Name,
+ PublicKeyToken = name.GetPublicKeyToken (),
+ HashAlgorithm = (AssemblyHashAlgorithm) name.HashAlgorithm,
+ };
+
+ module.AssemblyReferences.Add (scope);
+
+ return scope;
+#else
+ var name = AssemblyNameReference.Parse (assembly.FullName);
+
+ if (TryGetAssemblyNameReference (name, out scope))
+ return scope;
+
+ module.AssemblyReferences.Add (name);
+
+ return name;
+#endif
+ }
+
+#if !SILVERLIGHT
+ bool TryGetAssemblyNameReference (SR.AssemblyName name, out AssemblyNameReference assembly_reference)
+ {
+ var references = module.AssemblyReferences;
+
+ for (int i = 0; i < references.Count; i++) {
+ var reference = references [i];
+ if (name.FullName != reference.FullName) // TODO compare field by field
+ continue;
+
+ assembly_reference = reference;
+ return true;
+ }
+
+ assembly_reference = null;
+ return false;
+ }
+#endif
+
+ public FieldReference ImportField (SR.FieldInfo field, IGenericContext context)
+ {
+ var declaring_type = ImportType (field.DeclaringType, context);
+
+ if (IsGenericInstance (field.DeclaringType))
+ field = ResolveFieldDefinition (field);
+
+ return new FieldReference {
+ Name = field.Name,
+ DeclaringType = declaring_type,
+ FieldType = ImportType (field.FieldType, context ?? declaring_type),
+ };
+ }
+
+ static SR.FieldInfo ResolveFieldDefinition (SR.FieldInfo field)
+ {
+#if !SILVERLIGHT
+ return field.Module.ResolveField (field.MetadataToken);
+#else
+ return field.DeclaringType.GetGenericTypeDefinition ().GetField (field.Name,
+ SR.BindingFlags.Public
+ | SR.BindingFlags.NonPublic
+ | (field.IsStatic ? SR.BindingFlags.Static : SR.BindingFlags.Instance));
+#endif
+ }
+
+ public MethodReference ImportMethod (SR.MethodBase method, IGenericContext context, ImportGenericKind import_kind)
+ {
+ if (IsMethodSpecification (method) || ImportOpenGenericMethod (method, import_kind))
+ return ImportMethodSpecification (method, context);
+
+ var declaring_type = ImportType (method.DeclaringType, context);
+
+ if (IsGenericInstance (method.DeclaringType))
+ method = method.Module.ResolveMethod (method.MetadataToken);
+
+ var reference = new MethodReference {
+ Name = method.Name,
+ HasThis = HasCallingConvention (method, SR.CallingConventions.HasThis),
+ ExplicitThis = HasCallingConvention (method, SR.CallingConventions.ExplicitThis),
+ DeclaringType = ImportType (method.DeclaringType, context, ImportGenericKind.Definition),
+ };
+
+ if (HasCallingConvention (method, SR.CallingConventions.VarArgs))
+ reference.CallingConvention &= MethodCallingConvention.VarArg;
+
+ if (method.IsGenericMethod)
+ ImportGenericParameters (reference, method.GetGenericArguments ());
+
+ var method_info = method as SR.MethodInfo;
+ reference.ReturnType = method_info != null
+ ? ImportType (method_info.ReturnType, context ?? reference)
+ : ImportType (typeof (void), null);
+
+ var parameters = method.GetParameters ();
+ var reference_parameters = reference.Parameters;
+
+ for (int i = 0; i < parameters.Length; i++)
+ reference_parameters.Add (
+ new ParameterDefinition (ImportType (parameters [i].ParameterType, context ?? reference)));
+
+ reference.DeclaringType = declaring_type;
+
+ return reference;
+ }
+
+ static void ImportGenericParameters (IGenericParameterProvider provider, Type [] arguments)
+ {
+ var provider_parameters = provider.GenericParameters;
+
+ for (int i = 0; i < arguments.Length; i++)
+ provider_parameters.Add (new GenericParameter (arguments [i].Name, provider));
+ }
+
+ static bool IsMethodSpecification (SR.MethodBase method)
+ {
+ return method.IsGenericMethod && !method.IsGenericMethodDefinition;
+ }
+
+ MethodReference ImportMethodSpecification (SR.MethodBase method, IGenericContext context)
+ {
+ var method_info = method as SR.MethodInfo;
+ if (method_info == null)
+ throw new InvalidOperationException ();
+
+ var element_method = ImportMethod (method_info.GetGenericMethodDefinition (), context, ImportGenericKind.Definition);
+ var instance = new GenericInstanceMethod (element_method);
+ var arguments = method.GetGenericArguments ();
+ var instance_arguments = instance.GenericArguments;
+
+ for (int i = 0; i < arguments.Length; i++)
+ instance_arguments.Add (ImportType (arguments [i], context ?? element_method));
+
+ return instance;
+ }
+
+ static bool HasCallingConvention (SR.MethodBase method, SR.CallingConventions conventions)
+ {
+ return (method.CallingConvention & conventions) != 0;
+ }
+#endif
+
+ public TypeReference ImportType (TypeReference type, IGenericContext context)
+ {
+ if (type.IsTypeSpecification ())
+ return ImportTypeSpecification (type, context);
+
+ var reference = new TypeReference (
+ type.Namespace,
+ type.Name,
+ ImportScope (type.Scope),
+ type.IsValueType);
+
+ reference.module = module;
+
+ MetadataSystem.TryProcessPrimitiveType (reference);
+
+ if (type.IsNested)
+ reference.DeclaringType = ImportType (type.DeclaringType, context);
+
+ if (type.HasGenericParameters)
+ ImportGenericParameters (reference, type);
+
+ return reference;
+ }
+
+ IMetadataScope ImportScope (IMetadataScope scope)
+ {
+ switch (scope.MetadataScopeType) {
+ case MetadataScopeType.AssemblyNameReference:
+ return ImportAssemblyName ((AssemblyNameReference) scope);
+ case MetadataScopeType.ModuleDefinition:
+ return ImportAssemblyName (((ModuleDefinition) scope).Assembly.Name);
+ case MetadataScopeType.ModuleReference:
+ throw new NotImplementedException ();
+ }
+
+ throw new NotSupportedException ();
+ }
+
+ AssemblyNameReference ImportAssemblyName (AssemblyNameReference name)
+ {
+ AssemblyNameReference reference;
+ if (TryGetAssemblyNameReference (name, out reference))
+ return reference;
+
+ reference = new AssemblyNameReference (name.Name, name.Version) {
+ Culture = name.Culture,
+ HashAlgorithm = name.HashAlgorithm,
+ };
+
+ var pk_token = !name.PublicKeyToken.IsNullOrEmpty ()
+ ? new byte [name.PublicKeyToken.Length]
+ : Empty<byte>.Array;
+
+ if (pk_token.Length > 0)
+ Buffer.BlockCopy (name.PublicKeyToken, 0, pk_token, 0, pk_token.Length);
+
+ reference.PublicKeyToken = pk_token;
+
+ module.AssemblyReferences.Add (reference);
+
+ return reference;
+ }
+
+ bool TryGetAssemblyNameReference (AssemblyNameReference name_reference, out AssemblyNameReference assembly_reference)
+ {
+ var references = module.AssemblyReferences;
+
+ for (int i = 0; i < references.Count; i++) {
+ var reference = references [i];
+ if (name_reference.FullName != reference.FullName) // TODO compare field by field
+ continue;
+
+ assembly_reference = reference;
+ return true;
+ }
+
+ assembly_reference = null;
+ return false;
+ }
+
+ static void ImportGenericParameters (IGenericParameterProvider imported, IGenericParameterProvider original)
+ {
+ var parameters = original.GenericParameters;
+ var imported_parameters = imported.GenericParameters;
+
+ for (int i = 0; i < parameters.Count; i++)
+ imported_parameters.Add (new GenericParameter (parameters [i].Name, imported));
+ }
+
+ TypeReference ImportTypeSpecification (TypeReference type, IGenericContext context)
+ {
+ switch (type.etype) {
+ case ElementType.SzArray:
+ var vector = (ArrayType) type;
+ return new ArrayType (ImportType (vector.ElementType, context));
+ case ElementType.Ptr:
+ var pointer = (PointerType) type;
+ return new PointerType (ImportType (pointer.ElementType, context));
+ case ElementType.ByRef:
+ var byref = (ByReferenceType) type;
+ return new ByReferenceType (ImportType (byref.ElementType, context));
+ case ElementType.Pinned:
+ var pinned = (PinnedType) type;
+ return new PinnedType (ImportType (pinned.ElementType, context));
+ case ElementType.Sentinel:
+ var sentinel = (SentinelType) type;
+ return new SentinelType (ImportType (sentinel.ElementType, context));
+ case ElementType.CModOpt:
+ var modopt = (OptionalModifierType) type;
+ return new OptionalModifierType (
+ ImportType (modopt.ModifierType, context),
+ ImportType (modopt.ElementType, context));
+ case ElementType.CModReqD:
+ var modreq = (RequiredModifierType) type;
+ return new RequiredModifierType (
+ ImportType (modreq.ModifierType, context),
+ ImportType (modreq.ElementType, context));
+ case ElementType.Array:
+ var array = (ArrayType) type;
+ var imported_array = new ArrayType (ImportType (array.ElementType, context));
+ if (array.IsVector)
+ return imported_array;
+
+ var dimensions = array.Dimensions;
+ var imported_dimensions = imported_array.Dimensions;
+
+ imported_dimensions.Clear ();
+
+ for (int i = 0; i < dimensions.Count; i++) {
+ var dimension = dimensions [i];
+
+ imported_dimensions.Add (new ArrayDimension (dimension.LowerBound, dimension.UpperBound));
+ }
+
+ return imported_array;
+ case ElementType.GenericInst:
+ var instance = (GenericInstanceType) type;
+ var element_type = ImportType (instance.ElementType, context);
+ var imported_instance = new GenericInstanceType (element_type);
+
+ var arguments = instance.GenericArguments;
+ var imported_arguments = imported_instance.GenericArguments;
+
+ for (int i = 0; i < arguments.Count; i++)
+ imported_arguments.Add (ImportType (arguments [i], context));
+
+ return imported_instance;
+ case ElementType.Var:
+ if (context == null || context.Type == null)
+ throw new InvalidOperationException ();
+
+ return ((TypeReference) context.Type).GetElementType ().GenericParameters [((GenericParameter) type).Position];
+ case ElementType.MVar:
+ if (context == null || context.Method == null)
+ throw new InvalidOperationException ();
+
+ return context.Method.GenericParameters [((GenericParameter) type).Position];
+ }
+
+ throw new NotSupportedException (type.etype.ToString ());
+ }
+
+ public FieldReference ImportField (FieldReference field, IGenericContext context)
+ {
+ var declaring_type = ImportType (field.DeclaringType, context);
+
+ return new FieldReference {
+ Name = field.Name,
+ DeclaringType = declaring_type,
+ FieldType = ImportType (field.FieldType, context ?? declaring_type),
+ };
+ }
+
+ public MethodReference ImportMethod (MethodReference method, IGenericContext context)
+ {
+ if (method.IsGenericInstance)
+ return ImportMethodSpecification (method, context);
+
+ var declaring_type = ImportType (method.DeclaringType, context);
+
+ var reference = new MethodReference {
+ Name = method.Name,
+ HasThis = method.HasThis,
+ ExplicitThis = method.ExplicitThis,
+ DeclaringType = declaring_type,
+ };
+
+ if (method.IsVarArg ())
+ reference.CallingConvention &= MethodCallingConvention.VarArg;
+
+ if (method.HasGenericParameters)
+ ImportGenericParameters (reference, method);
+
+ reference.ReturnType = ImportType (method.ReturnType, context ?? reference);
+
+ if (!method.HasParameters)
+ return reference;
+
+ var reference_parameters = reference.Parameters;
+
+ var parameters = method.Parameters;
+ for (int i = 0; i < parameters.Count; i++)
+ reference_parameters.Add (
+ new ParameterDefinition (ImportType (parameters [i].ParameterType, context ?? reference)));
+
+ return reference;
+ }
+
+ MethodSpecification ImportMethodSpecification (MethodReference method, IGenericContext context)
+ {
+ if (!method.IsGenericInstance)
+ throw new NotSupportedException ();
+
+ var instance = (GenericInstanceMethod) method;
+ var element_method = ImportMethod (instance.ElementMethod, context);
+ var imported_instance = new GenericInstanceMethod (element_method);
+
+ var arguments = instance.GenericArguments;
+ var imported_arguments = imported_instance.GenericArguments;
+
+ for (int i = 0; i < arguments.Count; i++)
+ imported_arguments.Add (ImportType (arguments [i], context));
+
+ return imported_instance;
+ }
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ImportContext.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ImportContext.cs
deleted file mode 100644
index 9fd36b6..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ImportContext.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-//
-// ImportContext.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2006 Evaluant RC S.A.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- public class ImportContext {
-
- GenericContext m_genContext;
- IImporter m_importer;
-
- public GenericContext GenericContext {
- get { return m_genContext; }
- }
-
- public ImportContext (IImporter importer)
- {
- m_genContext = new GenericContext ();
- m_importer = importer;
- }
-
- public ImportContext (IImporter importer, IGenericParameterProvider provider)
- {
- m_importer = importer;
- m_genContext = new GenericContext (provider);
- }
-
- public TypeReference Import (TypeReference type)
- {
- return m_importer.ImportTypeReference (type, this);
- }
-
- public MethodReference Import (MethodReference meth)
- {
- return m_importer.ImportMethodReference (meth, this);
- }
-
- public FieldReference Import (FieldReference field)
- {
- return m_importer.ImportFieldReference (field, this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/InterfaceCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/InterfaceCollection.cs
deleted file mode 100644
index 9999680..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/InterfaceCollection.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// InterfaceCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:52 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class InterfaceCollection : CollectionBase, IReflectionVisitable {
-
- TypeDefinition m_container;
-
- public TypeReference this [int index] {
- get { return List [index] as TypeReference; }
- set { List [index] = value; }
- }
-
- public TypeDefinition Container {
- get { return m_container; }
- }
-
- public InterfaceCollection (TypeDefinition container)
- {
- m_container = container;
- }
-
- public void Add (TypeReference value)
- {
- List.Add (value);
- }
-
- public bool Contains (TypeReference value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (TypeReference value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, TypeReference value)
- {
- List.Insert (index, value);
- }
-
- public void Remove (TypeReference value)
- {
- List.Remove (value);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is TypeReference))
- throw new ArgumentException ("Must be of type " + typeof (TypeReference).FullName);
- }
-
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitInterfaceCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/LinkedResource.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/LinkedResource.cs
index 09d4588..a5530fc 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/LinkedResource.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/LinkedResource.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 - 2007 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -30,28 +30,31 @@ namespace Mono.Cecil {
public sealed class LinkedResource : Resource {
- byte [] m_hash;
- string m_file;
+ internal byte [] hash;
+ string file;
public byte [] Hash {
- get { return m_hash; }
- set { m_hash = value; }
+ get { return hash; }
}
public string File {
- get { return m_file; }
- set { m_file = value; }
+ get { return file; }
+ set { file = value; }
}
- public LinkedResource (string name, ManifestResourceAttributes flags, string file) :
- base (name, flags)
+ public override ResourceType ResourceType {
+ get { return ResourceType.Linked; }
+ }
+
+ public LinkedResource (string name, ManifestResourceAttributes flags)
+ : base (name, flags)
{
- m_file = file;
}
- public override void Accept (IReflectionStructureVisitor visitor)
+ public LinkedResource (string name, ManifestResourceAttributes flags, string file)
+ : base (name, flags)
{
- visitor.VisitLinkedResource (this);
+ this.file = file;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ManifestResourceAttributes.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ManifestResourceAttributes.cs
index 1d77f9f..d72d1d0 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ManifestResourceAttributes.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ManifestResourceAttributes.cs
@@ -1,10 +1,10 @@
//
-// ManigestResourceAttributes.cs
+// ManifestResourceAttributes.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,12 +26,12 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
- using System;
+namespace Mono.Cecil {
[Flags]
- public enum ManifestResourceAttributes {
+ public enum ManifestResourceAttributes : uint {
VisibilityMask = 0x0007,
Public = 0x0001, // The resource is exported from the Assembly
Private = 0x0002 // The resource is private to the Assembly
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalInfo.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalInfo.cs
new file mode 100644
index 0000000..1fce23a
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalInfo.cs
@@ -0,0 +1,171 @@
+//
+// MarshalInfo.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Cecil {
+
+ public class MarshalInfo {
+
+ internal NativeType native;
+
+ public NativeType NativeType {
+ get { return native; }
+ set { native = value; }
+ }
+
+ public MarshalInfo (NativeType native)
+ {
+ this.native = native;
+ }
+ }
+
+ public sealed class ArrayMarshalInfo : MarshalInfo {
+
+ internal NativeType element_type;
+ internal int size_parameter_index;
+ internal int size;
+ internal int size_parameter_multiplier;
+
+ public NativeType ElementType {
+ get { return element_type; }
+ set { element_type = value; }
+ }
+
+ public int SizeParameterIndex {
+ get { return size_parameter_index; }
+ set { size_parameter_index = value; }
+ }
+
+ public int Size {
+ get { return size; }
+ set { size = value; }
+ }
+
+ public int SizeParameterMultiplier {
+ get { return size_parameter_multiplier; }
+ set { size_parameter_multiplier = value; }
+ }
+
+ public ArrayMarshalInfo ()
+ : base (NativeType.Array)
+ {
+ element_type = NativeType.None;
+ size_parameter_index = -1;
+ size = -1;
+ size_parameter_multiplier = -1;
+ }
+ }
+
+ public sealed class CustomMarshalInfo : MarshalInfo {
+
+ internal Guid guid;
+ internal string unmanaged_type;
+ internal TypeReference managed_type;
+ internal string cookie;
+
+ public Guid Guid {
+ get { return guid; }
+ set { guid = value; }
+ }
+
+ public string UnmanagedType {
+ get { return unmanaged_type; }
+ set { unmanaged_type = value; }
+ }
+
+ public TypeReference ManagedType {
+ get { return managed_type; }
+ set { managed_type = value; }
+ }
+
+ public string Cookie {
+ get { return cookie; }
+ set { cookie = value; }
+ }
+
+ public CustomMarshalInfo ()
+ : base (NativeType.CustomMarshaler)
+ {
+ }
+ }
+
+ public sealed class SafeArrayMarshalInfo : MarshalInfo {
+
+ internal VariantType element_type;
+
+ public VariantType ElementType {
+ get { return element_type; }
+ set { element_type = value; }
+ }
+
+ public SafeArrayMarshalInfo ()
+ : base (NativeType.SafeArray)
+ {
+ element_type = VariantType.None;
+ }
+ }
+
+ public sealed class FixedArrayMarshalInfo : MarshalInfo {
+
+ internal NativeType element_type;
+ internal int size;
+
+ public NativeType ElementType {
+ get { return element_type; }
+ set { element_type = value; }
+ }
+
+ public int Size {
+ get { return size; }
+ set { size = value; }
+ }
+
+ public FixedArrayMarshalInfo ()
+ : base (NativeType.FixedArray)
+ {
+ element_type = NativeType.None;
+ }
+ }
+
+ public sealed class FixedSysStringMarshalInfo : MarshalInfo {
+
+ internal int size;
+
+ public int Size {
+ get { return size; }
+ set { size = value; }
+ }
+
+ public FixedSysStringMarshalInfo ()
+ : base (NativeType.FixedSysString)
+ {
+ size = -1;
+ }
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalSpec.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalSpec.cs
deleted file mode 100644
index 4610c09..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MarshalSpec.cs
+++ /dev/null
@@ -1,171 +0,0 @@
-//
-// MarshalDesc.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
-
- public class MarshalSpec {
-
- NativeType m_natIntr;
- IHasMarshalSpec m_container;
-
- public NativeType NativeIntrinsic {
- get { return m_natIntr; }
- set { m_natIntr = value; }
- }
-
- public IHasMarshalSpec Container {
- get { return m_container; }
- set { m_container = value; }
- }
-
- public MarshalSpec (NativeType natIntr, IHasMarshalSpec container)
- {
- m_natIntr = natIntr;
- m_container = container;
- }
-
- public virtual void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitMarshalSpec (this);
- }
- }
-
- public sealed class ArrayMarshalSpec : MarshalSpec {
-
- NativeType m_elemType;
- int m_paramNum;
- int m_elemMult;
- int m_numElem;
-
- public NativeType ElemType {
- get { return m_elemType; }
- set { m_elemType = value; }
- }
-
- public int ParamNum {
- get { return m_paramNum; }
- set { m_paramNum = value; }
- }
-
- public int ElemMult {
- get { return m_elemMult; }
- set { m_elemMult = value; }
- }
-
- public int NumElem {
- get { return m_numElem; }
- set { m_numElem = value; }
- }
-
- public ArrayMarshalSpec (IHasMarshalSpec container) : base (NativeType.ARRAY, container)
- {
- }
- }
-
- public sealed class CustomMarshalerSpec : MarshalSpec {
-
- Guid m_guid;
- string m_unmanagedType;
- string m_managedType;
- string m_cookie;
-
- public Guid Guid {
- get { return m_guid; }
- set { m_guid = value; }
- }
-
- public String UnmanagedType {
- get { return m_unmanagedType; }
- set { m_unmanagedType = value; }
- }
-
- public string ManagedType {
- get { return m_managedType; }
- set { m_managedType = value; }
- }
-
- public string Cookie {
- get { return m_cookie; }
- set { m_cookie = value; }
- }
-
- public CustomMarshalerSpec (IHasMarshalSpec container) : base (NativeType.CUSTOMMARSHALER, container)
- {
- }
- }
-
- public sealed class SafeArraySpec : MarshalSpec {
-
- private VariantType m_elemType;
-
- public VariantType ElemType {
- get { return m_elemType; }
- set { m_elemType = value; }
- }
-
- public SafeArraySpec (IHasMarshalSpec container) : base (NativeType.SAFEARRAY, container)
- {
- }
- }
-
- public sealed class FixedArraySpec : MarshalSpec {
-
- private int m_numElem;
- private NativeType m_elemType;
-
- public int NumElem {
- get { return m_numElem; }
- set { m_numElem = value; }
- }
-
- public NativeType ElemType {
- get { return m_elemType; }
- set { m_elemType = value; }
- }
-
- public FixedArraySpec (IHasMarshalSpec container) : base (NativeType.FIXEDARRAY, container)
- {
- }
- }
-
- public sealed class FixedSysStringSpec : MarshalSpec {
-
- private int m_size;
-
- public int Size {
- get { return m_size; }
- set { m_size = value; }
- }
-
- public FixedSysStringSpec (IHasMarshalSpec container) : base (NativeType.FIXEDSYSSTRING, container)
- {
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayDimensionCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberDefinitionCollection.cs
index c31cfb1..1e70302 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ArrayDimensionCollection.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberDefinitionCollection.cs
@@ -1,13 +1,10 @@
//
-// ArrayDimensionCollection.cs
+// MemberDefinitionCollection.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:53 CEST 2006
-//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -29,60 +26,67 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
- using System;
- using System.Collections;
+using Mono.Collections.Generic;
- using Mono.Cecil.Cil;
+namespace Mono.Cecil {
- public sealed class ArrayDimensionCollection : CollectionBase {
+ class MemberDefinitionCollection<T> : Collection<T> where T : IMemberDefinition {
- ArrayType m_container;
+ TypeDefinition container;
- public ArrayDimension this [int index] {
- get { return List [index] as ArrayDimension; }
- set { List [index] = value; }
+ internal MemberDefinitionCollection (TypeDefinition container)
+ {
+ this.container = container;
}
- public ArrayType Container {
- get { return m_container; }
+ internal MemberDefinitionCollection (TypeDefinition container, int capacity)
+ : base (capacity)
+ {
+ this.container = container;
}
- public ArrayDimensionCollection (ArrayType container)
+ protected override void OnAdd (T item, int index)
{
- m_container = container;
+ Attach (item);
}
- public void Add (ArrayDimension value)
+ protected sealed override void OnSet (T item, int index)
{
- List.Add (value);
+ Attach (item);
}
- public bool Contains (ArrayDimension value)
+ protected sealed override void OnInsert (T item, int index)
{
- return List.Contains (value);
+ Attach (item);
}
- public int IndexOf (ArrayDimension value)
+ protected sealed override void OnRemove (T item, int index)
{
- return List.IndexOf (value);
+ Detach (item);
}
- public void Insert (int index, ArrayDimension value)
+ protected sealed override void OnClear ()
{
- List.Insert (index, value);
+ foreach (var definition in this)
+ Detach (definition);
}
- public void Remove (ArrayDimension value)
+ void Attach (T element)
{
- List.Remove (value);
+ if (element.DeclaringType == container)
+ return;
+
+ if (element.DeclaringType != null)
+ throw new ArgumentException ("Member already attached");
+
+ element.DeclaringType = this.container;
}
- protected override void OnValidate (object o)
+ static void Detach (T element)
{
- if (! (o is ArrayDimension))
- throw new ArgumentException ("Must be of type " + typeof (ArrayDimension).FullName);
+ element.DeclaringType = null;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReference.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReference.cs
index 95fcb69..b3edf39 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReference.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReference.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,55 +28,74 @@
namespace Mono.Cecil {
- using System.Collections;
+ public abstract class MemberReference : IMetadataTokenProvider {
- using Mono.Cecil.Metadata;
+ string name;
+ TypeReference declaring_type;
- public abstract class MemberReference : IMemberReference {
-
- string m_name;
- TypeReference m_decType;
- MetadataToken m_token;
- IDictionary m_annotations;
+ internal MetadataToken token;
public virtual string Name {
- get { return m_name; }
- set { m_name = value; }
+ get { return name; }
+ set { name = value; }
+ }
+
+ public abstract string FullName {
+ get;
}
public virtual TypeReference DeclaringType {
- get { return m_decType; }
- set { m_decType = value; }
+ get { return declaring_type; }
+ set { declaring_type = value; }
}
public MetadataToken MetadataToken {
- get { return m_token; }
- set { m_token = value; }
+ get { return token; }
+ set { token = value; }
}
- IDictionary IAnnotationProvider.Annotations {
+ internal bool HasImage {
get {
- if (m_annotations == null)
- m_annotations = new Hashtable ();
- return m_annotations;
+ var module = Module;
+ if (module == null)
+ return false;
+
+ return module.HasImage;
}
}
- public MemberReference (string name)
+ public virtual ModuleDefinition Module {
+ get { return declaring_type != null ? declaring_type.Module : null; }
+ }
+
+ public virtual bool IsDefinition {
+ get { return false; }
+ }
+
+ internal virtual bool ContainsGenericParameter {
+ get { return declaring_type != null && declaring_type.ContainsGenericParameter; }
+ }
+
+ internal MemberReference ()
{
- m_name = name;
}
- public override string ToString ()
+ internal MemberReference (string name)
{
- if (m_decType == null)
- return m_name;
+ this.name = name ?? string.Empty;
+ }
- return string.Concat (m_decType.FullName, "::", m_name);
+ internal string MemberFullName ()
+ {
+ if (declaring_type == null)
+ return name;
+
+ return declaring_type.FullName + "::" + name;
}
- public virtual void Accept (IReflectionVisitor visitor)
+ public override string ToString ()
{
+ return FullName;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReferenceCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReferenceCollection.cs
deleted file mode 100644
index fd69d6c..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MemberReferenceCollection.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// MemberReferenceCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:53 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class MemberReferenceCollection : CollectionBase, IReflectionVisitable {
-
- ModuleDefinition m_container;
-
- public MemberReference this [int index] {
- get { return List [index] as MemberReference; }
- set { List [index] = value; }
- }
-
- public ModuleDefinition Container {
- get { return m_container; }
- }
-
- public MemberReferenceCollection (ModuleDefinition container)
- {
- m_container = container;
- }
-
- public void Add (MemberReference value)
- {
- List.Add (value);
- }
-
- public bool Contains (MemberReference value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (MemberReference value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, MemberReference value)
- {
- List.Insert (index, value);
- }
-
- public void Remove (MemberReference value)
- {
- List.Remove (value);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is MemberReference))
- throw new ArgumentException ("Must be of type " + typeof (MemberReference).FullName);
- }
-
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitMemberReferenceCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataResolver.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataResolver.cs
new file mode 100644
index 0000000..1cfddb9
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataResolver.cs
@@ -0,0 +1,270 @@
+//
+// MetadataResolver.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+
+using Mono.Collections.Generic;
+
+namespace Mono.Cecil {
+
+ public interface IAssemblyResolver {
+ AssemblyDefinition Resolve (AssemblyNameReference name);
+ AssemblyDefinition Resolve (string fullName);
+ }
+
+ static class MetadataResolver {
+
+ public static TypeDefinition Resolve (IAssemblyResolver resolver, TypeReference type)
+ {
+ type = type.GetElementType ();
+
+ var scope = type.Scope;
+ switch (scope.MetadataScopeType) {
+ case MetadataScopeType.AssemblyNameReference:
+ var assembly = resolver.Resolve ((AssemblyNameReference) scope);
+ if (assembly == null)
+ return null;
+
+ return GetType (assembly.MainModule, type);
+ case MetadataScopeType.ModuleDefinition:
+ return GetType ((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);
+ }
+ break;
+ }
+
+ throw new NotSupportedException ();
+ }
+
+ static TypeDefinition GetType (ModuleDefinition module, TypeReference type)
+ {
+ if (!type.IsNested)
+ return module.GetType (type.Namespace, type.Name);
+
+ var declaring_type = type.DeclaringType.Resolve ();
+ if (declaring_type == null)
+ return null;
+
+ return declaring_type.GetNestedType (type.Name);
+ }
+
+ public static FieldDefinition Resolve (IAssemblyResolver resolver, FieldReference field)
+ {
+ var type = Resolve (resolver, field.DeclaringType);
+ if (type == null)
+ return null;
+
+ if (!type.HasFields)
+ return null;
+
+ return GetField (resolver, type, field);
+ }
+
+ static FieldDefinition GetField (IAssemblyResolver resolver, TypeDefinition type, FieldReference reference)
+ {
+ while (type != null) {
+ var field = GetField (type.Fields, reference);
+ if (field != null)
+ return field;
+
+ if (type.BaseType == null)
+ return null;
+
+ type = Resolve (resolver, type.BaseType);
+ }
+
+ return null;
+ }
+
+ static FieldDefinition GetField (IList<FieldDefinition> fields, FieldReference reference)
+ {
+ for (int i = 0; i < fields.Count; i++) {
+ var field = fields [i];
+
+ if (field.Name != reference.Name)
+ continue;
+
+ if (!AreSame (field.FieldType, reference.FieldType))
+ continue;
+
+ return field;
+ }
+
+ return null;
+ }
+
+ public static MethodDefinition Resolve (IAssemblyResolver resolver, MethodReference method)
+ {
+ var type = Resolve (resolver, method.DeclaringType);
+ if (type == null)
+ return null;
+
+ method = method.GetElementMethod ();
+
+ if (!type.HasMethods)
+ return null;
+
+ return GetMethod (resolver, type, method);
+ }
+
+ static MethodDefinition GetMethod (IAssemblyResolver resolver, TypeDefinition type, MethodReference reference)
+ {
+ while (type != null) {
+ var method = GetMethod (type.Methods, reference);
+ if (method != null)
+ return method;
+
+ if (type.BaseType == null)
+ return null;
+
+ type = Resolve (resolver, type.BaseType);
+ }
+
+ return null;
+ }
+
+ public static MethodDefinition GetMethod (IList<MethodDefinition> methods, MethodReference reference)
+ {
+ for (int i = 0; i < methods.Count; i++) {
+ var method = methods [i];
+
+ if (method.Name != reference.Name)
+ continue;
+
+ if (!AreSame (method.ReturnType, reference.ReturnType))
+ continue;
+
+ if (method.HasParameters != reference.HasParameters)
+ continue;
+
+ if (!method.HasParameters && !reference.HasParameters)
+ return method;
+
+ if (!AreSame (method.Parameters, reference.Parameters))
+ continue;
+
+ return method;
+ }
+
+ return null;
+ }
+
+ static bool AreSame (Collection<ParameterDefinition> a, Collection<ParameterDefinition> b)
+ {
+ var count = a.Count;
+
+ if (count != b.Count)
+ return false;
+
+ if (count == 0)
+ return true;
+
+ for (int i = 0; i < count; i++)
+ if (!AreSame (a [i].ParameterType, b [i].ParameterType))
+ return false;
+
+ return true;
+ }
+
+ static bool AreSame (TypeSpecification a, TypeSpecification b)
+ {
+ if (!AreSame (a.ElementType, b.ElementType))
+ return false;
+
+ if (a.IsGenericInstance)
+ return AreSame ((GenericInstanceType) a, (GenericInstanceType) b);
+
+ if (a.IsRequiredModifier || a.IsOptionalModifier)
+ return AreSame ((IModifierType) a, (IModifierType) b);
+
+ if (a.IsArray)
+ return AreSame ((ArrayType) a, (ArrayType) b);
+
+ return true;
+ }
+
+ static bool AreSame (ArrayType a, ArrayType b)
+ {
+ if (a.Rank != b.Rank)
+ return false;
+
+ // TODO: dimensions
+
+ return true;
+ }
+
+ static bool AreSame (IModifierType a, IModifierType b)
+ {
+ return AreSame (a.ModifierType, b.ModifierType);
+ }
+
+ 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;
+
+ for (int i = 0; i < a.GenericArguments.Count; i++)
+ if (!AreSame (a.GenericArguments [i], b.GenericArguments [i]))
+ return false;
+
+ return true;
+ }
+
+ static bool AreSame (GenericParameter a, GenericParameter b)
+ {
+ return a.Position == b.Position;
+ }
+
+ static bool AreSame (TypeReference a, TypeReference b)
+ {
+ if (a.etype != b.etype)
+ return false;
+
+ if (a.IsGenericParameter)
+ return AreSame ((GenericParameter) a, (GenericParameter) b);
+
+ if (a.IsTypeSpecification ())
+ return AreSame ((TypeSpecification) a, (TypeSpecification) b);
+
+ return a.FullName == b.FullName;
+ }
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataSystem.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataSystem.cs
new file mode 100644
index 0000000..a114707
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MetadataSystem.cs
@@ -0,0 +1,374 @@
+//
+// MetadataSystem.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+
+using Mono.Cecil.Metadata;
+
+namespace Mono.Cecil {
+
+ struct Range {
+ public uint Start;
+ public uint Length;
+
+ public Range (uint index, uint length)
+ {
+ this.Start = index;
+ this.Length = length;
+ }
+ }
+
+ sealed class MetadataSystem {
+
+ internal TypeDefinition [] Types;
+ internal TypeReference [] TypeReferences;
+
+ internal FieldDefinition [] Fields;
+ internal MethodDefinition [] Methods;
+ internal MemberReference [] MemberReferences;
+
+ internal Dictionary<uint, uint []> NestedTypes;
+ internal Dictionary<uint, uint> ReverseNestedTypes;
+ internal Dictionary<uint, MetadataToken []> Interfaces;
+ internal Dictionary<uint, Row<ushort, uint>> ClassLayouts;
+ internal Dictionary<uint, uint> FieldLayouts;
+ internal Dictionary<uint, uint> FieldRVAs;
+ internal Dictionary<MetadataToken, uint> FieldMarshals;
+ internal Dictionary<MetadataToken, Row<ElementType, uint>> Constants;
+ internal Dictionary<uint, MetadataToken []> Overrides;
+ internal Dictionary<MetadataToken, Range> CustomAttributes;
+ internal Dictionary<MetadataToken, Range> SecurityDeclarations;
+ internal Dictionary<uint, Range> Events;
+ internal Dictionary<uint, Range> Properties;
+ internal Dictionary<uint, Row<MethodSemanticsAttributes, MetadataToken>> Semantics;
+ internal Dictionary<uint, Row<PInvokeAttributes, uint, uint>> PInvokes;
+ internal Dictionary<MetadataToken, Range> GenericParameters;
+ internal Dictionary<uint, MetadataToken []> GenericConstraints;
+
+ static Dictionary<string, Row<ElementType, bool>> primitive_value_types;
+
+ static void InitializePrimitives ()
+ {
+ primitive_value_types = new Dictionary<string, Row<ElementType, bool>> (18) {
+ { "Void", new Row<ElementType, bool> (ElementType.Void, false) },
+ { "Boolean", new Row<ElementType, bool> (ElementType.Boolean, true) },
+ { "Char", new Row<ElementType, bool> (ElementType.Char, true) },
+ { "SByte", new Row<ElementType, bool> (ElementType.I1, true) },
+ { "Byte", new Row<ElementType, bool> (ElementType.U1, true) },
+ { "Int16", new Row<ElementType, bool> (ElementType.I2, true) },
+ { "UInt16", new Row<ElementType, bool> (ElementType.U2, true) },
+ { "Int32", new Row<ElementType, bool> (ElementType.I4, true) },
+ { "UInt32", new Row<ElementType, bool> (ElementType.U4, true) },
+ { "Int64", new Row<ElementType, bool> (ElementType.I8, true) },
+ { "UInt64", new Row<ElementType, bool> (ElementType.U8, true) },
+ { "Single", new Row<ElementType, bool> (ElementType.R4, true) },
+ { "Double", new Row<ElementType, bool> (ElementType.R8, true) },
+ { "String", new Row<ElementType, bool> (ElementType.String, false) },
+ { "TypedReference", new Row<ElementType, bool> (ElementType.TypedByRef, false) },
+ { "IntPtr", new Row<ElementType, bool> (ElementType.I, true) },
+ { "UIntPtr", new Row<ElementType, bool> (ElementType.U, true) },
+ { "Object", new Row<ElementType, bool> (ElementType.Object, false) },
+ };
+ }
+
+ public static void TryProcessPrimitiveType (TypeReference type)
+ {
+ var scope = type.scope;
+ if (scope.MetadataScopeType != MetadataScopeType.AssemblyNameReference)
+ return;
+
+ if (scope.Name != "mscorlib")
+ return;
+
+ if (type.Namespace != "System")
+ return;
+
+ if (primitive_value_types == null)
+ InitializePrimitives ();
+
+ Row<ElementType, bool> primitive_data;
+ if (!primitive_value_types.TryGetValue (type.Name, out primitive_data))
+ return;
+
+ type.etype = primitive_data.Col1;
+ type.IsValueType = primitive_data.Col2;
+ }
+
+ public void Clear ()
+ {
+ if (NestedTypes != null) NestedTypes.Clear ();
+ if (ReverseNestedTypes != null) ReverseNestedTypes.Clear ();
+ if (Interfaces != null) Interfaces.Clear ();
+ if (ClassLayouts != null) ClassLayouts.Clear ();
+ if (FieldLayouts != null) FieldLayouts.Clear ();
+ if (FieldRVAs != null) FieldRVAs.Clear ();
+ if (FieldMarshals != null) FieldMarshals.Clear ();
+ if (Constants != null) Constants.Clear ();
+ if (Overrides != null) Overrides.Clear ();
+ if (CustomAttributes != null) CustomAttributes.Clear ();
+ if (SecurityDeclarations != null) SecurityDeclarations.Clear ();
+ if (Events != null) Events.Clear ();
+ if (Properties != null) Properties.Clear ();
+ if (Semantics != null) Semantics.Clear ();
+ if (PInvokes != null) PInvokes.Clear ();
+ if (GenericParameters != null) GenericParameters.Clear ();
+ if (GenericConstraints != null) GenericConstraints.Clear ();
+ }
+
+ public TypeDefinition GetTypeDefinition (uint rid)
+ {
+ if (rid < 1 || rid > Types.Length)
+ return null;
+
+ return Types [rid - 1];
+ }
+
+ public void AddTypeDefinition (TypeDefinition type)
+ {
+ Types [type.token.RID - 1] = type;
+ }
+
+ public TypeReference GetTypeReference (uint rid)
+ {
+ if (rid < 1 || rid > TypeReferences.Length)
+ return null;
+
+ return TypeReferences [rid - 1];
+ }
+
+ public void AddTypeReference (TypeReference type)
+ {
+ TypeReferences [type.token.RID - 1] = type;
+ }
+
+ public FieldDefinition GetFieldDefinition (uint rid)
+ {
+ if (rid < 1 || rid > Fields.Length)
+ return null;
+
+ return Fields [rid - 1];
+ }
+
+ public void AddFieldDefinition (FieldDefinition field)
+ {
+ Fields [field.token.RID - 1] = field;
+ }
+
+ public MethodDefinition GetMethodDefinition (uint rid)
+ {
+ if (rid < 1 || rid > Methods.Length)
+ return null;
+
+ return Methods [rid - 1];
+ }
+
+ public void AddMethodDefinition (MethodDefinition method)
+ {
+ Methods [method.token.RID - 1] = method;
+ }
+
+ public MemberReference GetMemberReference (uint rid)
+ {
+ if (rid < 1 || rid > MemberReferences.Length)
+ return null;
+
+ return MemberReferences [rid - 1];
+ }
+
+ public void AddMemberReference (MemberReference member)
+ {
+ MemberReferences [member.token.RID - 1] = member;
+ }
+
+ public bool TryGetNestedTypeMapping (TypeDefinition type, out uint [] mapping)
+ {
+ return NestedTypes.TryGetValue (type.token.RID, out mapping);
+ }
+
+ public void SetNestedTypeMapping (uint type_rid, uint [] mapping)
+ {
+ NestedTypes [type_rid] = mapping;
+ }
+
+ public void RemoveNestedTypeMapping (TypeDefinition type)
+ {
+ NestedTypes.Remove (type.token.RID);
+ }
+
+ public bool TryGetReverseNestedTypeMapping (TypeDefinition type, out uint declaring)
+ {
+ return ReverseNestedTypes.TryGetValue (type.token.RID, out declaring);
+ }
+
+ public void SetReverseNestedTypeMapping (uint nested, uint declaring)
+ {
+ ReverseNestedTypes.Add (nested, declaring);
+ }
+
+ public void RemoveReverseNestedTypeMapping (TypeDefinition type)
+ {
+ ReverseNestedTypes.Remove (type.token.RID);
+ }
+
+ public bool TryGetInterfaceMapping (TypeDefinition type, out MetadataToken [] mapping)
+ {
+ return Interfaces.TryGetValue (type.token.RID, out mapping);
+ }
+
+ public void SetInterfaceMapping (uint type_rid, MetadataToken [] mapping)
+ {
+ Interfaces [type_rid] = mapping;
+ }
+
+ public void RemoveInterfaceMapping (TypeDefinition type)
+ {
+ Interfaces.Remove (type.token.RID);
+ }
+
+ public void AddPropertiesRange (uint type_rid, Range range)
+ {
+ Properties.Add (type_rid, range);
+ }
+
+ public bool TryGetPropertiesRange (TypeDefinition type, out Range range)
+ {
+ return Properties.TryGetValue (type.token.RID, out range);
+ }
+
+ public void RemovePropertiesRange (TypeDefinition type)
+ {
+ Properties.Remove (type.token.RID);
+ }
+
+ public void AddEventsRange (uint type_rid, Range range)
+ {
+ Events.Add (type_rid, range);
+ }
+
+ public bool TryGetEventsRange (TypeDefinition type, out Range range)
+ {
+ return Events.TryGetValue (type.token.RID, out range);
+ }
+
+ public void RemoveEventsRange (TypeDefinition type)
+ {
+ Events.Remove (type.token.RID);
+ }
+
+ public bool TryGetGenericParameterRange (IGenericParameterProvider owner, out Range range)
+ {
+ return GenericParameters.TryGetValue (owner.MetadataToken, out range);
+ }
+
+ public void RemoveGenericParameterRange (IGenericParameterProvider owner)
+ {
+ GenericParameters.Remove (owner.MetadataToken);
+ }
+
+ public bool TryGetCustomAttributeRange (ICustomAttributeProvider owner, out Range range)
+ {
+ return CustomAttributes.TryGetValue (owner.MetadataToken, out range);
+ }
+
+ public void RemoveCustomAttributeRange (ICustomAttributeProvider owner)
+ {
+ CustomAttributes.Remove (owner.MetadataToken);
+ }
+
+ public bool TryGetSecurityDeclarationRange (ISecurityDeclarationProvider owner, out Range range)
+ {
+ return SecurityDeclarations.TryGetValue (owner.MetadataToken, out range);
+ }
+
+ public void RemoveSecurityDeclarationRange (ISecurityDeclarationProvider owner)
+ {
+ SecurityDeclarations.Remove (owner.MetadataToken);
+ }
+
+ public bool TryGetGenericConstraintMapping (GenericParameter generic_parameter, out MetadataToken [] mapping)
+ {
+ return GenericConstraints.TryGetValue (generic_parameter.token.RID, out mapping);
+ }
+
+ public void SetGenericConstraintMapping (uint gp_rid, MetadataToken [] mapping)
+ {
+ GenericConstraints [gp_rid] = mapping;
+ }
+
+ public void RemoveGenericConstraintMapping (GenericParameter generic_parameter)
+ {
+ GenericConstraints.Remove (generic_parameter.token.RID);
+ }
+
+ public bool TryGetOverrideMapping (MethodDefinition method, out MetadataToken [] mapping)
+ {
+ return Overrides.TryGetValue (method.token.RID, out mapping);
+ }
+
+ public void SetOverrideMapping (uint rid, MetadataToken [] mapping)
+ {
+ Overrides [rid] = mapping;
+ }
+
+ public void RemoveOverrideMapping (MethodDefinition method)
+ {
+ Overrides.Remove (method.token.RID);
+ }
+
+ public TypeDefinition GetFieldDeclaringType (uint field_rid)
+ {
+ return BinaryRangeSearch (Types, field_rid, true);
+ }
+
+ public TypeDefinition GetMethodDeclaringType (uint method_rid)
+ {
+ return BinaryRangeSearch (Types, method_rid, false);
+ }
+
+ static TypeDefinition BinaryRangeSearch (TypeDefinition [] types, uint rid, bool field)
+ {
+ int min = 0;
+ int max = types.Length - 1;
+ while (min <= max) {
+ int mid = min + ((max - min) / 2);
+ var type = types [mid];
+ var range = field ? type.fields_range : type.methods_range;
+
+ if (rid < range.Start)
+ max = mid - 1;
+ else if (rid >= range.Start + range.Length)
+ min = mid + 1;
+ else
+ return type;
+ }
+
+ throw new ArgumentException ();
+ }
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodAttributes.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodAttributes.cs
index c57b906..3446702 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodAttributes.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodAttributes.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,17 +26,17 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
- using System;
+namespace Mono.Cecil {
[Flags]
public enum MethodAttributes : ushort {
MemberAccessMask = 0x0007,
- Compilercontrolled = 0x0000, // Member not referenceable
+ CompilerControlled = 0x0000, // Member not referenceable
Private = 0x0001, // Accessible only by the parent type
FamANDAssem = 0x0002, // Accessible by sub-types only in this Assembly
- Assem = 0x0003, // Accessibly by anyone in the Assembly
+ Assembly = 0x0003, // Accessibly by anyone in the Assembly
Family = 0x0004, // Accessible only by type and sub-types
FamORAssem = 0x0005, // Accessibly by sub-types anywhere, plus anyone in assembly
Public = 0x0006, // Accessibly by anyone who has visibility to this scope
@@ -50,6 +50,7 @@ namespace Mono.Cecil {
ReuseSlot = 0x0000, // Method reuses existing slot in vtable
NewSlot = 0x0100, // Method always gets a new slot in the vtable
+ CheckAccessOnOverride = 0x0200, // Method can only be overriden if also accessible
Abstract = 0x0400, // Method does not provide an implementation
SpecialName = 0x0800, // Method is special
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodCallingConvention.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodCallingConvention.cs
index 0eb6088..c96dc1c 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodCallingConvention.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodCallingConvention.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -35,6 +35,6 @@ namespace Mono.Cecil {
ThisCall = 0x3,
FastCall = 0x4,
VarArg = 0x5,
- Generic = 0x10
+ Generic = 0x10,
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinition.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinition.cs
index 8d28807..fff1fb9 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinition.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinition.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,304 +26,291 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using Mono.Cecil.Cil;
+using Mono.Collections.Generic;
- using Mono.Cecil.Binary;
- using Mono.Cecil.Cil;
+using RVA = System.UInt32;
- public sealed class MethodDefinition : MethodReference, IMemberDefinition,
- IHasSecurity, ICustomAttributeProvider {
+namespace Mono.Cecil {
- public const string Cctor = ".cctor";
- public const string Ctor = ".ctor";
+ public sealed class MethodDefinition : MethodReference, IMemberDefinition, ISecurityDeclarationProvider {
- MethodAttributes m_attributes;
- MethodImplAttributes m_implAttrs;
- MethodSemanticsAttributes m_semAttrs;
- SecurityDeclarationCollection m_secDecls;
- CustomAttributeCollection m_customAttrs;
+ ushort attributes;
+ ushort impl_attributes;
+ MethodSemanticsAttributes? sem_attrs;
+ Collection<CustomAttribute> custom_attributes;
+ Collection<SecurityDeclaration> security_declarations;
- ModuleDefinition m_module;
+ internal RVA rva;
+ internal PInvokeInfo pinvoke;
+ Collection<MethodReference> overrides;
- MethodBody m_body;
- RVA m_rva;
- OverrideCollection m_overrides;
- PInvokeInfo m_pinvoke;
- readonly ParameterDefinition m_this;
+ internal MethodBody body;
public MethodAttributes Attributes {
- get { return m_attributes; }
- set { m_attributes = value; }
+ get { return (MethodAttributes) attributes; }
+ set { attributes = (ushort) value; }
}
public MethodImplAttributes ImplAttributes {
- get { return m_implAttrs; }
- set { m_implAttrs = value; }
+ get { return (MethodImplAttributes) impl_attributes; }
+ set { impl_attributes = (ushort) value; }
}
public MethodSemanticsAttributes SemanticsAttributes {
- get { return m_semAttrs; }
- set { m_semAttrs = value; }
- }
+ get {
+ if (sem_attrs.HasValue)
+ return sem_attrs.Value;
- public override TypeReference DeclaringType {
- get { return base.DeclaringType; }
- set {
- base.DeclaringType = value;
- TypeDefinition t = value as TypeDefinition;
- if (t != null)
- m_module = t.Module;
+ if (HasImage) {
+ ReadSemantics ();
+ return sem_attrs.Value;
+ }
+
+ sem_attrs = MethodSemanticsAttributes.None;
+ return sem_attrs.Value;
}
+ set { sem_attrs = value; }
+ }
+
+ internal void ReadSemantics ()
+ {
+ if (sem_attrs.HasValue)
+ return;
+
+ var type = DeclaringType;
+ if (type == null)
+ return;
+
+ var module = type.Module;
+ if (module == null)
+ return;
+
+ if (!module.HasImage)
+ return;
+
+ sem_attrs = module.Read (this, (method, reader) => reader.ReadMethodSemantics (method));
}
- public SecurityDeclarationCollection SecurityDeclarations {
+ public bool HasSecurityDeclarations {
get {
- if (m_secDecls == null)
- m_secDecls = new SecurityDeclarationCollection (this);
+ if (security_declarations != null)
+ return security_declarations.Count > 0;
- return m_secDecls;
+ return this.GetHasSecurityDeclarations (Module);
}
}
- public CustomAttributeCollection CustomAttributes {
+ public Collection<SecurityDeclaration> SecurityDeclarations {
+ get { return security_declarations ?? (security_declarations = this.GetSecurityDeclarations (Module)); }
+ }
+
+ public bool HasCustomAttributes {
get {
- if (m_customAttrs == null)
- m_customAttrs = new CustomAttributeCollection (this);
+ if (custom_attributes != null)
+ return custom_attributes.Count > 0;
- return m_customAttrs;
+ return this.GetHasCustomAttributes (Module);
}
}
- public RVA RVA {
- get { return m_rva; }
- set { m_rva = value; }
+ public Collection<CustomAttribute> CustomAttributes {
+ get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); }
+ }
+
+ public int RVA {
+ get { return (int) rva; }
+ }
+
+ public bool HasBody {
+ get {
+ return (attributes & (ushort) MethodAttributes.Abstract) == 0 &&
+ (attributes & (ushort) MethodAttributes.PInvokeImpl) == 0 &&
+ (impl_attributes & (ushort) MethodImplAttributes.InternalCall) == 0 &&
+ (impl_attributes & (ushort) MethodImplAttributes.Native) == 0 &&
+ (impl_attributes & (ushort) MethodImplAttributes.Unmanaged) == 0 &&
+ (impl_attributes & (ushort) MethodImplAttributes.Runtime) == 0;
+ }
}
public MethodBody Body {
get {
- LoadBody ();
- return m_body;
+ if (body != null)
+ return body;
+
+ if (!HasBody)
+ return null;
+
+ if (HasImage && rva != 0)
+ return body = Module.Read (this, (method, reader) => reader.ReadMethodBody (method));
+
+ return body = new MethodBody (this);
+ }
+ set { body = value; }
+ }
+
+ public bool HasPInvokeInfo {
+ get {
+ if (pinvoke != null)
+ return true;
+
+ return IsPInvokeImpl;
}
- set { m_body = value; }
}
public PInvokeInfo PInvokeInfo {
- get { return m_pinvoke; }
- set { m_pinvoke = value; }
+ get {
+ if (pinvoke != null)
+ return pinvoke;
+
+ if (HasImage && IsPInvokeImpl)
+ return pinvoke = Module.Read (this, (method, reader) => reader.ReadPInvokeInfo (method));
+
+ return null;
+ }
+ set {
+ IsPInvokeImpl = true;
+ pinvoke = value;
+ }
}
- public OverrideCollection Overrides {
+ public bool HasOverrides {
get {
- if (m_overrides == null)
- m_overrides = new OverrideCollection (this);
+ if (overrides != null)
+ return overrides.Count > 0;
- return m_overrides;
+ if (HasImage)
+ return Module.Read (this, (method, reader) => reader.HasOverrides (method));
+
+ return false;
+ }
+ }
+
+ public Collection<MethodReference> Overrides {
+ get {
+ if (overrides != null)
+ return overrides;
+
+ if (HasImage)
+ return overrides = Module.Read (this, (method, reader) => reader.ReadOverrides (method));
+
+ return overrides = new Collection<MethodReference> ();
+ }
+ }
+
+ public override bool HasGenericParameters {
+ get {
+ if (generic_parameters != null)
+ return generic_parameters.Count > 0;
+
+ return this.GetHasGenericParameters (Module);
}
}
- public ParameterDefinition This {
- get { return m_this; }
+ public override Collection<GenericParameter> GenericParameters {
+ get { return generic_parameters ?? (generic_parameters = this.GetGenericParameters (Module)); }
}
#region MethodAttributes
public bool IsCompilerControlled {
- get { return (m_attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Compilercontrolled; }
- set {
- if (value) {
- m_attributes &= ~MethodAttributes.MemberAccessMask;
- m_attributes |= MethodAttributes.Compilercontrolled;
- } else
- m_attributes &= ~(MethodAttributes.MemberAccessMask & MethodAttributes.Compilercontrolled);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.CompilerControlled); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.CompilerControlled, value); }
}
public bool IsPrivate {
- get { return (m_attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; }
- set {
- if (value) {
- m_attributes &= ~MethodAttributes.MemberAccessMask;
- m_attributes |= MethodAttributes.Private;
- } else
- m_attributes &= ~(MethodAttributes.MemberAccessMask & MethodAttributes.Private);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Private); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Private, value); }
}
public bool IsFamilyAndAssembly {
- get { return (m_attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamANDAssem; }
- set {
- if (value) {
- m_attributes &= ~MethodAttributes.MemberAccessMask;
- m_attributes |= MethodAttributes.FamANDAssem;
- } else
- m_attributes &= ~(MethodAttributes.MemberAccessMask & MethodAttributes.FamANDAssem);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.FamANDAssem); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.FamANDAssem, value); }
}
public bool IsAssembly {
- get { return (m_attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Assem; }
- set {
- if (value) {
- m_attributes &= ~MethodAttributes.MemberAccessMask;
- m_attributes |= MethodAttributes.Assem;
- } else
- m_attributes &= ~(MethodAttributes.MemberAccessMask & MethodAttributes.Assem);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Assembly); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Assembly, value); }
}
public bool IsFamily {
- get { return (m_attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Family; }
- set {
- if (value) {
- m_attributes &= ~MethodAttributes.MemberAccessMask;
- m_attributes |= MethodAttributes.Family;
- } else
- m_attributes &= ~(MethodAttributes.MemberAccessMask & MethodAttributes.Family);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Family); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Family, value); }
}
public bool IsFamilyOrAssembly {
- get { return (m_attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamORAssem; }
- set {
- if (value) {
- m_attributes &= ~MethodAttributes.MemberAccessMask;
- m_attributes |= MethodAttributes.FamORAssem;
- } else
- m_attributes &= ~(MethodAttributes.MemberAccessMask & MethodAttributes.FamORAssem);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.FamORAssem); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.FamORAssem, value); }
}
public bool IsPublic {
- get { return (m_attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public; }
- set {
- if (value) {
- m_attributes &= ~MethodAttributes.MemberAccessMask;
- m_attributes |= MethodAttributes.Public;
- } else
- m_attributes &= ~(MethodAttributes.MemberAccessMask & MethodAttributes.Public);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Public); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Public, value); }
}
public bool IsStatic {
- get { return (m_attributes & MethodAttributes.Static) != 0; }
- set {
- if (value)
- m_attributes |= MethodAttributes.Static;
- else
- m_attributes &= ~MethodAttributes.Static;
- }
+ get { return attributes.GetAttributes ((ushort) MethodAttributes.Static); }
+ set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.Static, value); }
}
public bool IsFinal {
- get { return (m_attributes & MethodAttributes.Final) != 0; }
- set {
- if (value)
- m_attributes |= MethodAttributes.Final;
- else
- m_attributes &= ~MethodAttributes.Final;
- }
+ get { return attributes.GetAttributes ((ushort) MethodAttributes.Final); }
+ set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.Final, value); }
}
public bool IsVirtual {
- get { return (m_attributes & MethodAttributes.Virtual) != 0; }
- set {
- if (value)
- m_attributes |= MethodAttributes.Virtual;
- else
- m_attributes &= ~MethodAttributes.Virtual;
- }
+ get { return attributes.GetAttributes ((ushort) MethodAttributes.Virtual); }
+ set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.Virtual, value); }
}
public bool IsHideBySig {
- get { return (m_attributes & MethodAttributes.HideBySig) != 0; }
- set {
- if (value)
- m_attributes |= MethodAttributes.HideBySig;
- else
- m_attributes &= ~MethodAttributes.HideBySig;
- }
+ get { return attributes.GetAttributes ((ushort) MethodAttributes.HideBySig); }
+ set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.HideBySig, value); }
}
public bool IsReuseSlot {
- get { return (m_attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.ReuseSlot; }
- set {
- if (value) {
- m_attributes &= ~MethodAttributes.VtableLayoutMask;
- m_attributes |= MethodAttributes.ReuseSlot;
- } else
- m_attributes &= ~(MethodAttributes.VtableLayoutMask & MethodAttributes.ReuseSlot);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.VtableLayoutMask, (ushort) MethodAttributes.ReuseSlot); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.VtableLayoutMask, (ushort) MethodAttributes.ReuseSlot, value); }
}
public bool IsNewSlot {
- get { return (m_attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.NewSlot; }
- set {
- if (value) {
- m_attributes &= ~MethodAttributes.VtableLayoutMask;
- m_attributes |= MethodAttributes.NewSlot;
- } else
- m_attributes &= ~(MethodAttributes.VtableLayoutMask & MethodAttributes.NewSlot);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) MethodAttributes.VtableLayoutMask, (ushort) MethodAttributes.NewSlot); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.VtableLayoutMask, (ushort) MethodAttributes.NewSlot, value); }
+ }
+
+ public bool IsCheckAccessOnOverride {
+ get { return attributes.GetAttributes ((ushort) MethodAttributes.CheckAccessOnOverride); }
+ set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.CheckAccessOnOverride, value); }
}
public bool IsAbstract {
- get { return (m_attributes & MethodAttributes.Abstract) != 0; }
- set {
- if (value)
- m_attributes |= MethodAttributes.Abstract;
- else
- m_attributes &= ~MethodAttributes.Abstract;
- }
+ get { return attributes.GetAttributes ((ushort) MethodAttributes.Abstract); }
+ set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.Abstract, value); }
}
public bool IsSpecialName {
- get { return (m_attributes & MethodAttributes.SpecialName) != 0; }
- set {
- if (value)
- m_attributes |= MethodAttributes.SpecialName;
- else
- m_attributes &= ~MethodAttributes.SpecialName;
- }
+ get { return attributes.GetAttributes ((ushort) MethodAttributes.SpecialName); }
+ set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.SpecialName, value); }
}
public bool IsPInvokeImpl {
- get { return (m_attributes & MethodAttributes.PInvokeImpl) != 0; }
- set {
- if (value)
- m_attributes |= MethodAttributes.PInvokeImpl;
- else
- m_attributes &= ~MethodAttributes.PInvokeImpl;
- }
+ get { return attributes.GetAttributes ((ushort) MethodAttributes.PInvokeImpl); }
+ set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.PInvokeImpl, value); }
}
public bool IsUnmanagedExport {
- get { return (m_attributes & MethodAttributes.UnmanagedExport) != 0; }
- set {
- if (value)
- m_attributes |= MethodAttributes.UnmanagedExport;
- else
- m_attributes &= ~MethodAttributes.UnmanagedExport;
- }
+ get { return attributes.GetAttributes ((ushort) MethodAttributes.UnmanagedExport); }
+ set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.UnmanagedExport, value); }
}
public bool IsRuntimeSpecialName {
- get { return (m_attributes & MethodAttributes.RTSpecialName) != 0; }
- set {
- if (value)
- m_attributes |= MethodAttributes.RTSpecialName;
- else
- m_attributes &= ~MethodAttributes.RTSpecialName;
- }
+ get { return attributes.GetAttributes ((ushort) MethodAttributes.RTSpecialName); }
+ set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.RTSpecialName, value); }
}
public bool HasSecurity {
- get { return (m_attributes & MethodAttributes.HasSecurity) != 0; }
- set {
- if (value)
- m_attributes |= MethodAttributes.HasSecurity;
- else
- m_attributes &= ~MethodAttributes.HasSecurity;
- }
+ get { return attributes.GetAttributes ((ushort) MethodAttributes.HasSecurity); }
+ set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.HasSecurity, value); }
}
#endregion
@@ -331,229 +318,159 @@ namespace Mono.Cecil {
#region MethodImplAttributes
public bool IsIL {
- get { return (m_implAttrs & MethodImplAttributes.CodeTypeMask) == MethodImplAttributes.IL; }
- set {
- if (value) {
- m_implAttrs &= ~MethodImplAttributes.CodeTypeMask;
- m_implAttrs |= MethodImplAttributes.IL;
- } else
- m_implAttrs &= ~(MethodImplAttributes.CodeTypeMask & MethodImplAttributes.IL);
- }
+ get { return impl_attributes.GetMaskedAttributes ((ushort) MethodImplAttributes.CodeTypeMask, (ushort) MethodImplAttributes.IL); }
+ set { impl_attributes = impl_attributes.SetMaskedAttributes ((ushort) MethodImplAttributes.CodeTypeMask, (ushort) MethodImplAttributes.IL, value); }
}
public bool IsNative {
- get { return (m_implAttrs & MethodImplAttributes.CodeTypeMask) == MethodImplAttributes.Native; }
- set {
- if (value) {
- m_implAttrs &= ~MethodImplAttributes.CodeTypeMask;
- m_implAttrs |= MethodImplAttributes.Native;
- } else
- m_implAttrs &= ~(MethodImplAttributes.CodeTypeMask & MethodImplAttributes.Native);
- }
+ get { return impl_attributes.GetMaskedAttributes ((ushort) MethodImplAttributes.CodeTypeMask, (ushort) MethodImplAttributes.Native); }
+ set { impl_attributes = impl_attributes.SetMaskedAttributes ((ushort) MethodImplAttributes.CodeTypeMask, (ushort) MethodImplAttributes.Native, value); }
}
public bool IsRuntime {
- get { return (m_implAttrs & MethodImplAttributes.CodeTypeMask) == MethodImplAttributes.Runtime; }
- set {
- if (value) {
- m_implAttrs &= ~MethodImplAttributes.CodeTypeMask;
- m_implAttrs |= MethodImplAttributes.Runtime;
- } else
- m_implAttrs &= ~(MethodImplAttributes.CodeTypeMask & MethodImplAttributes.Runtime);
- }
+ get { return impl_attributes.GetMaskedAttributes ((ushort) MethodImplAttributes.CodeTypeMask, (ushort) MethodImplAttributes.Runtime); }
+ set { impl_attributes = impl_attributes.SetMaskedAttributes ((ushort) MethodImplAttributes.CodeTypeMask, (ushort) MethodImplAttributes.Runtime, value); }
}
public bool IsUnmanaged {
- get { return (m_implAttrs & MethodImplAttributes.ManagedMask) == MethodImplAttributes.Unmanaged; }
- set {
- if (value) {
- m_implAttrs &= ~MethodImplAttributes.ManagedMask;
- m_implAttrs |= MethodImplAttributes.Unmanaged;
- } else
- m_implAttrs &= ~(MethodImplAttributes.ManagedMask & MethodImplAttributes.Unmanaged);
- }
+ get { return impl_attributes.GetMaskedAttributes ((ushort) MethodImplAttributes.ManagedMask, (ushort) MethodImplAttributes.Unmanaged); }
+ set { impl_attributes = impl_attributes.SetMaskedAttributes ((ushort) MethodImplAttributes.ManagedMask, (ushort) MethodImplAttributes.Unmanaged, value); }
}
public bool IsManaged {
- get { return (m_implAttrs & MethodImplAttributes.ManagedMask) == MethodImplAttributes.Managed; }
- set {
- if (value) {
- m_implAttrs &= ~MethodImplAttributes.ManagedMask;
- m_implAttrs |= MethodImplAttributes.Managed;
- } else
- m_implAttrs &= ~(MethodImplAttributes.ManagedMask & MethodImplAttributes.Managed);
- }
+ get { return impl_attributes.GetMaskedAttributes ((ushort) MethodImplAttributes.ManagedMask, (ushort) MethodImplAttributes.Managed); }
+ set { impl_attributes = impl_attributes.SetMaskedAttributes ((ushort) MethodImplAttributes.ManagedMask, (ushort) MethodImplAttributes.Managed, value); }
}
public bool IsForwardRef {
- get { return (m_implAttrs & MethodImplAttributes.ForwardRef) != 0; }
- set {
- if (value)
- m_implAttrs |= MethodImplAttributes.ForwardRef;
- else
- m_implAttrs &= ~MethodImplAttributes.ForwardRef;
- }
+ get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.ForwardRef); }
+ set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.ForwardRef, value); }
}
public bool IsPreserveSig {
- get { return (m_implAttrs & MethodImplAttributes.PreserveSig) != 0; }
- set {
- if (value)
- m_implAttrs |= MethodImplAttributes.PreserveSig;
- else
- m_implAttrs &= ~MethodImplAttributes.PreserveSig;
- }
+ get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.PreserveSig); }
+ set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.PreserveSig, value); }
}
public bool IsInternalCall {
- get { return (m_implAttrs & MethodImplAttributes.InternalCall) != 0; }
- set {
- if (value)
- m_implAttrs |= MethodImplAttributes.InternalCall;
- else
- m_implAttrs &= ~MethodImplAttributes.InternalCall;
- }
+ get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.InternalCall); }
+ set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.InternalCall, value); }
}
public bool IsSynchronized {
- get { return (m_implAttrs & MethodImplAttributes.Synchronized) != 0; }
- set {
- if (value)
- m_implAttrs |= MethodImplAttributes.Synchronized;
- else
- m_implAttrs &= ~MethodImplAttributes.Synchronized;
- }
+ get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.Synchronized); }
+ set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.Synchronized, value); }
}
public bool NoInlining {
- get { return (m_implAttrs & MethodImplAttributes.NoInlining) != 0; }
- set {
- if (value)
- m_implAttrs |= MethodImplAttributes.NoInlining;
- else
- m_implAttrs &= ~MethodImplAttributes.NoInlining;
- }
+ get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.NoInlining); }
+ set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.NoInlining, value); }
+ }
+
+ public bool NoOptimization {
+ get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.NoOptimization); }
+ set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.NoOptimization, value); }
}
#endregion
- public bool IsConstructor {
- get {
- return this.IsRuntimeSpecialName && this.IsSpecialName &&
- (this.Name == Cctor || this.Name == Ctor);
- }
+ #region MethodSemanticsAttributes
+
+ public bool IsSetter {
+ get { return this.GetSemantics (MethodSemanticsAttributes.Setter); }
+ set { this.SetSemantics (MethodSemanticsAttributes.Setter, value); }
}
- public bool HasBody {
- get {
- return (m_attributes & MethodAttributes.Abstract) == 0 &&
- (m_attributes & MethodAttributes.PInvokeImpl) == 0 &&
- (m_implAttrs & MethodImplAttributes.InternalCall) == 0 &&
- (m_implAttrs & MethodImplAttributes.Native) == 0 &&
- (m_implAttrs & MethodImplAttributes.Unmanaged) == 0 &&
- (m_implAttrs & MethodImplAttributes.Runtime) == 0;
- }
+ public bool IsGetter {
+ get { return this.GetSemantics (MethodSemanticsAttributes.Getter); }
+ set { this.SetSemantics (MethodSemanticsAttributes.Getter, value); }
}
- public MethodDefinition (string name, RVA rva,
- MethodAttributes attrs, MethodImplAttributes implAttrs,
- bool hasThis, bool explicitThis, MethodCallingConvention callConv) :
- base (name, hasThis, explicitThis, callConv)
- {
- m_rva = rva;
- m_attributes = attrs;
- m_implAttrs = implAttrs;
+ public bool IsOther {
+ get { return this.GetSemantics (MethodSemanticsAttributes.Other); }
+ set { this.SetSemantics (MethodSemanticsAttributes.Other, value); }
+ }
- if (!IsStatic)
- m_this = new ParameterDefinition ("this", 0, (ParameterAttributes) 0, null);
+ public bool IsAddOn {
+ get { return this.GetSemantics (MethodSemanticsAttributes.AddOn); }
+ set { this.SetSemantics (MethodSemanticsAttributes.AddOn, value); }
}
- internal MethodDefinition (string name, MethodAttributes attrs) : base (name)
- {
- m_attributes = attrs;
+ public bool IsRemoveOn {
+ get { return this.GetSemantics (MethodSemanticsAttributes.RemoveOn); }
+ set { this.SetSemantics (MethodSemanticsAttributes.RemoveOn, value); }
+ }
- this.HasThis = !this.IsStatic;
- if (!IsStatic)
- m_this = new ParameterDefinition ("this", 0, (ParameterAttributes) 0, null);
+ public bool IsFire {
+ get { return this.GetSemantics (MethodSemanticsAttributes.Fire); }
+ set { this.SetSemantics (MethodSemanticsAttributes.Fire, value); }
}
- public MethodDefinition (string name, MethodAttributes attrs, TypeReference returnType) :
- this (name, attrs)
- {
- this.ReturnType.ReturnType = returnType;
+ #endregion
+
+ public new TypeDefinition DeclaringType {
+ get { return (TypeDefinition) base.DeclaringType; }
+ set { base.DeclaringType = value; }
}
- internal void LoadBody ()
- {
- if (m_body == null && this.HasBody) {
- m_body = new MethodBody (this);
- if (m_module != null && m_rva != RVA.Zero)
- m_module.Controller.Reader.Code.VisitMethodBody (m_body);
+ public bool IsConstructor {
+ get {
+ return this.IsRuntimeSpecialName
+ && this.IsSpecialName
+ && (this.Name == ".cctor" || this.Name == ".ctor");
}
}
- public MethodDefinition Clone ()
- {
- return Clone (this, new ImportContext (NullReferenceImporter.Instance, this));
+ public override bool IsDefinition {
+ get { return true; }
}
- internal static MethodDefinition Clone (MethodDefinition meth, ImportContext context)
+ internal MethodDefinition ()
{
- MethodDefinition nm = new MethodDefinition (
- meth.Name,
- RVA.Zero,
- meth.Attributes,
- meth.ImplAttributes,
- meth.HasThis,
- meth.ExplicitThis,
- meth.CallingConvention);
-
- context.GenericContext.Method = nm;
-
- foreach (GenericParameter p in meth.GenericParameters)
- nm.GenericParameters.Add (GenericParameter.Clone (p, context));
+ this.token = new MetadataToken (TokenType.Method);
+ }
- nm.ReturnType.ReturnType = context.Import (meth.ReturnType.ReturnType);
+ public MethodDefinition (string name, MethodAttributes attributes, TypeReference returnType)
+ : base (name, returnType)
+ {
+ this.attributes = (ushort) attributes;
+ this.HasThis = !this.IsStatic;
+ this.token = new MetadataToken (TokenType.Method);
+ }
- if (meth.ReturnType.HasConstant)
- nm.ReturnType.Constant = meth.ReturnType.Constant;
+ public override MethodDefinition Resolve ()
+ {
+ return this;
+ }
+ }
- if (meth.ReturnType.MarshalSpec != null)
- nm.ReturnType.MarshalSpec = meth.ReturnType.MarshalSpec;
+ static partial class Mixin {
- foreach (CustomAttribute ca in meth.ReturnType.CustomAttributes)
- nm.ReturnType.CustomAttributes.Add (CustomAttribute.Clone (ca, context));
+ public static ParameterDefinition GetParameter (this MethodBody self, int index)
+ {
+ var method = self.method;
- if (meth.PInvokeInfo != null)
- nm.PInvokeInfo = meth.PInvokeInfo; // TODO: import module ?
- foreach (ParameterDefinition param in meth.Parameters)
- nm.Parameters.Add (ParameterDefinition.Clone (param, context));
- foreach (MethodReference ov in meth.Overrides)
- nm.Overrides.Add (context.Import (ov));
- foreach (CustomAttribute ca in meth.CustomAttributes)
- nm.CustomAttributes.Add (CustomAttribute.Clone (ca, context));
- foreach (SecurityDeclaration sec in meth.SecurityDeclarations)
- nm.SecurityDeclarations.Add (SecurityDeclaration.Clone (sec));
+ if (method.HasThis) {
+ if (index == 0)
+ return self.ThisParameter;
- if (meth.Body != null)
- nm.Body = MethodBody.Clone (meth.Body, nm, context);
+ index--;
+ }
- return nm;
+ return method.Parameters [index];
}
- public override void Accept (IReflectionVisitor visitor)
+ public static bool GetSemantics (this MethodDefinition self, MethodSemanticsAttributes semantics)
{
- visitor.VisitMethodDefinition (this);
-
- this.GenericParameters.Accept (visitor);
- this.Parameters.Accept (visitor);
-
- if (this.PInvokeInfo != null)
- this.PInvokeInfo.Accept (visitor);
+ return (self.SemanticsAttributes & semantics) != 0;
+ }
- this.SecurityDeclarations.Accept (visitor);
- this.Overrides.Accept (visitor);
- this.CustomAttributes.Accept (visitor);
+ public static void SetSemantics (this MethodDefinition self, MethodSemanticsAttributes semantics, bool value)
+ {
+ if (value)
+ self.SemanticsAttributes |= semantics;
+ else
+ self.SemanticsAttributes &= ~semantics;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinitionCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinitionCollection.cs
deleted file mode 100644
index ec0b1de..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodDefinitionCollection.cs
+++ /dev/null
@@ -1,185 +0,0 @@
-//
-// MethodDefinitionCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Fri Mar 30 18:43:56 +0200 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class MethodDefinitionCollection : CollectionBase, IReflectionVisitable {
-
- TypeDefinition m_container;
-
- public MethodDefinition this [int index] {
- get { return List [index] as MethodDefinition; }
- set { List [index] = value; }
- }
-
- public TypeDefinition Container {
- get { return m_container; }
- }
-
- public MethodDefinitionCollection (TypeDefinition container)
- {
- m_container = container;
- }
-
- public void Add (MethodDefinition value)
- {
- Attach (value);
-
- List.Add (value);
- }
-
-
- public new void Clear ()
- {
- foreach (MethodDefinition item in this)
- Detach (item);
-
- base.Clear ();
- }
-
- public bool Contains (MethodDefinition value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (MethodDefinition value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, MethodDefinition value)
- {
- Attach (value);
-
- List.Insert (index, value);
- }
-
- public void Remove (MethodDefinition value)
- {
- List.Remove (value);
-
- Detach (value);
- }
-
-
- public new void RemoveAt (int index)
- {
- MethodDefinition item = this [index];
- Remove (item);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is MethodDefinition))
- throw new ArgumentException ("Must be of type " + typeof (MethodDefinition).FullName);
- }
-
- public MethodDefinition [] GetMethod (string name)
- {
- ArrayList ret = new ArrayList ();
- foreach (MethodDefinition meth in this)
- if (meth.Name == name)
- ret.Add (meth);
-
- return ret.ToArray (typeof (MethodDefinition)) as MethodDefinition [];
- }
-
- internal MethodDefinition GetMethodInternal (string name, IList parameters)
- {
- foreach (MethodDefinition meth in this) {
- if (meth.Name != name || meth.Parameters.Count != parameters.Count)
- continue;
-
- bool match = true;
- for (int i = 0; i < parameters.Count; i++) {
- string pname;
- object param = parameters [i];
- if (param is Type)
- pname = ReflectionHelper.GetTypeSignature (param as Type);
- else if (param is TypeReference)
- pname = (param as TypeReference).FullName;
- else if (param is ParameterDefinition)
- pname = (param as ParameterDefinition).ParameterType.FullName;
- else
- throw new NotSupportedException ();
-
- if (meth.Parameters [i].ParameterType.FullName != pname) {
- match = false;
- break;
- }
- }
-
- if (match)
- return meth;
- }
-
- return null;
- }
-
- public MethodDefinition GetMethod (string name, Type [] parameters)
- {
- return GetMethodInternal (name, parameters);
- }
-
- public MethodDefinition GetMethod (string name, TypeReference [] parameters)
- {
- return GetMethodInternal (name, parameters);
- }
-
- public MethodDefinition GetMethod (string name, ParameterDefinitionCollection parameters)
- {
- return GetMethodInternal (name, parameters);
- }
-
- void Attach (MemberReference member)
- {
- if (member.DeclaringType != null)
- throw new ReflectionException ("Member already attached, clone it instead");
-
- member.DeclaringType = m_container;
- }
-
- void Detach (MemberReference member)
- {
- member.DeclaringType = null;
- }
-
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitMethodDefinitionCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodImplAttributes.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodImplAttributes.cs
index ed70118..8a2b422 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodImplAttributes.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodImplAttributes.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 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,9 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
- using System;
+namespace Mono.Cecil {
[Flags]
public enum MethodImplAttributes : ushort {
@@ -47,6 +47,7 @@ namespace Mono.Cecil {
PreserveSig = 0x0080, // Reserved: conforming implementations may ignore
InternalCall = 0x1000, // Reserved: shall be zero in conforming implementations
Synchronized = 0x0020, // Method is single threaded through the body
+ NoOptimization = 0x0040, // Method is not optimized by the JIT.
NoInlining = 0x0008, // Method may not be inlined
MaxMethodImplVal = 0xffff // Range check value
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReference.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReference.cs
index 8c1aced..1ea47a0 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReference.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReference.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 - 2007 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,113 +26,189 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
+using System.Text;
+
+using Mono.Collections.Generic;
- using System.Text;
+namespace Mono.Cecil {
- public class MethodReference : MemberReference, IMethodSignature, IGenericParameterProvider {
+ public class MethodReference : MemberReference, IMethodSignature, IGenericParameterProvider, IGenericContext {
- ParameterDefinitionCollection m_parameters;
- MethodReturnType m_returnType;
+ internal ParameterDefinitionCollection parameters;
+ MethodReturnType return_type;
- bool m_hasThis;
- bool m_explicitThis;
- MethodCallingConvention m_callConv;
- GenericParameterCollection m_genparams;
+ bool has_this;
+ bool explicit_this;
+ MethodCallingConvention calling_convention;
+ internal Collection<GenericParameter> generic_parameters;
public virtual bool HasThis {
- get { return m_hasThis; }
- set { m_hasThis = value; }
+ get { return has_this; }
+ set { has_this = value; }
}
public virtual bool ExplicitThis {
- get { return m_explicitThis; }
- set { m_explicitThis = value; }
+ get { return explicit_this; }
+ set { explicit_this = value; }
}
public virtual MethodCallingConvention CallingConvention {
- get { return m_callConv; }
- set { m_callConv = value; }
+ get { return calling_convention; }
+ set { calling_convention = value; }
+ }
+
+ public virtual bool HasParameters {
+ get { return !parameters.IsNullOrEmpty (); }
+ }
+
+ public virtual Collection<ParameterDefinition> Parameters {
+ get {
+ if (parameters == null)
+ parameters = new ParameterDefinitionCollection (this);
+
+ return parameters;
+ }
+ }
+
+ IGenericParameterProvider IGenericContext.Type {
+ get {
+ var declaring_type = this.DeclaringType;
+ var instance = declaring_type as GenericInstanceType;
+ if (instance != null)
+ return instance.ElementType;
+
+ return declaring_type;
+ }
+ }
+
+ IGenericParameterProvider IGenericContext.Method {
+ get { return this; }
+ }
+
+ GenericParameterType IGenericParameterProvider.GenericParameterType {
+ get { return GenericParameterType.Method; }
+ }
+
+ public virtual bool HasGenericParameters {
+ get { return !generic_parameters.IsNullOrEmpty (); }
}
- public virtual ParameterDefinitionCollection Parameters {
+ public virtual Collection<GenericParameter> GenericParameters {
get {
- if (m_parameters == null)
- m_parameters = new ParameterDefinitionCollection (this);
- return m_parameters;
+ if (generic_parameters != null)
+ return generic_parameters;
+
+ return generic_parameters = new Collection<GenericParameter> ();
}
}
- public GenericParameterCollection GenericParameters {
+ public TypeReference ReturnType {
get {
- if (m_genparams == null)
- m_genparams = new GenericParameterCollection (this);
- return m_genparams;
+ var return_type = MethodReturnType;
+ return return_type != null ? return_type.ReturnType : null;
+ }
+ set {
+ var return_type = MethodReturnType;
+ if (return_type != null)
+ return_type.ReturnType = value;
}
}
- public virtual MethodReturnType ReturnType {
- get { return m_returnType;}
- set { m_returnType = value; }
+ public virtual MethodReturnType MethodReturnType {
+ get { return return_type; }
+ set { return_type = value; }
}
- internal MethodReference (string name, bool hasThis,
- bool explicitThis, MethodCallingConvention callConv) : this (name)
+ public override string FullName {
+ get {
+ var builder = new StringBuilder ();
+ builder.Append (ReturnType.FullName);
+ builder.Append (" ");
+ builder.Append (MemberFullName ());
+ this.MethodSignatureFullName (builder);
+ return builder.ToString ();
+ }
+ }
+
+ public virtual bool IsGenericInstance {
+ get { return false; }
+ }
+
+ internal override bool ContainsGenericParameter {
+ get {
+ if (this.ReturnType.ContainsGenericParameter || base.ContainsGenericParameter)
+ return true;
+
+ var parameters = this.Parameters;
+
+ for (int i = 0; i < parameters.Count; i++)
+ if (parameters [i].ParameterType.ContainsGenericParameter)
+ return true;
+
+ return false;
+ }
+ }
+
+ internal MethodReference ()
{
- m_parameters = new ParameterDefinitionCollection (this);
- m_hasThis = hasThis;
- m_explicitThis = explicitThis;
- m_callConv = callConv;
+ this.return_type = new MethodReturnType (this);
+ this.token = new MetadataToken (TokenType.MemberRef);
}
- internal MethodReference (string name) : base (name)
+ public MethodReference (string name, TypeReference returnType)
+ : base (name)
{
- m_returnType = new MethodReturnType (null);
+ if (returnType == null)
+ throw new ArgumentNullException ("returnType");
+
+ this.return_type = new MethodReturnType (this);
+ this.return_type.ReturnType = returnType;
+ this.token = new MetadataToken (TokenType.MemberRef);
}
- public MethodReference (string name,
- TypeReference declaringType, TypeReference returnType,
- bool hasThis, bool explicitThis, MethodCallingConvention callConv) :
- this (name, hasThis, explicitThis, callConv)
+ public MethodReference (string name, TypeReference returnType, TypeReference declaringType)
+ : this (name, returnType)
{
+ if (declaringType == null)
+ throw new ArgumentNullException ("declaringType");
+
this.DeclaringType = declaringType;
- this.ReturnType.ReturnType = returnType;
}
- public virtual MethodReference GetOriginalMethod ()
+ public virtual MethodReference GetElementMethod ()
{
return this;
}
- public int GetSentinel ()
+ public virtual MethodDefinition Resolve ()
{
- for (int i = 0; i < Parameters.Count; i++)
- if (Parameters [i].ParameterType is SentinelType)
- return i;
+ var module = this.Module;
+ if (module == null)
+ throw new NotSupportedException ();
- return -1;
+ return module.Resolve (this);
}
+ }
+
+ static partial class Mixin {
- public override string ToString ()
+ public static bool IsVarArg (this IMethodSignature self)
{
- int sentinel = GetSentinel ();
+ return (self.CallingConvention & MethodCallingConvention.VarArg) != 0;
+ }
- StringBuilder sb = new StringBuilder ();
- sb.Append (m_returnType.ReturnType.FullName);
- sb.Append (" ");
- sb.Append (base.ToString ());
- sb.Append ("(");
- for (int i = 0; i < this.Parameters.Count; i++) {
- if (i > 0)
- sb.Append (",");
+ public static int GetSentinelPosition (this IMethodSignature self)
+ {
+ if (!self.HasParameters)
+ return -1;
- if (i == sentinel)
- sb.Append ("...,");
+ var parameters = self.Parameters;
+ for (int i = 0; i < parameters.Count; i++)
+ if (parameters [i].ParameterType.IsSentinel)
+ return i;
- sb.Append (this.Parameters [i].ParameterType.FullName);
- }
- sb.Append (")");
- return sb.ToString ();
+ return -1;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReturnType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReturnType.cs
index 4406199..4b571f3 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReturnType.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodReturnType.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,85 +26,74 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
-
- using System.Reflection;
-
- using Mono.Cecil.Metadata;
+using Mono.Collections.Generic;
- public sealed class MethodReturnType : ICustomAttributeProvider, IHasMarshalSpec, IHasConstant {
+namespace Mono.Cecil {
- MethodReference m_method;
- ParameterDefinition m_param;
+ public sealed class MethodReturnType : IConstantProvider, ICustomAttributeProvider, IMarshalInfoProvider {
- TypeReference m_returnType;
+ internal IMethodSignature method;
+ internal ParameterDefinition parameter;
+ TypeReference return_type;
- public MethodReference Method {
- get { return m_method; }
- set { m_method = value; }
+ public IMethodSignature Method {
+ get { return method; }
}
public TypeReference ReturnType {
- get { return m_returnType; }
- set { m_returnType = value; }
+ get { return return_type; }
+ set { return_type = value; }
}
internal ParameterDefinition Parameter {
- get { return m_param; }
- set { m_param = value; }
+ get { return parameter ?? (parameter = new ParameterDefinition (return_type)); }
+ set { parameter = value; }
}
public MetadataToken MetadataToken {
- get { return m_param.MetadataToken; }
- set { m_param.MetadataToken = value; }
+ get { return Parameter.MetadataToken; }
+ set { Parameter.MetadataToken = value; }
}
- public CustomAttributeCollection CustomAttributes {
- get {
- if (m_param == null) {
- m_param = new ParameterDefinition (
- string.Empty, 0, (ParameterAttributes) 0, m_returnType);
- m_param.Method = m_method;
- }
+ public bool HasCustomAttributes {
+ get { return parameter != null && parameter.HasCustomAttributes; }
+ }
- return m_param.CustomAttributes;
- }
+ public Collection<CustomAttribute> CustomAttributes {
+ get { return Parameter.CustomAttributes; }
}
- public bool HasConstant {
- get {
- if (m_param == null)
- return false;
+ public bool HasDefault {
+ get { return parameter != null && parameter.HasDefault; }
+ set { Parameter.HasDefault = value; }
+ }
- return m_param.HasConstant;
- }
+ public bool HasConstant {
+ get { return parameter != null && parameter.HasConstant; }
}
public object Constant {
- get {
- if (m_param == null)
- return null;
-
- return m_param.Constant;
- }
- set {
- m_param.Constant = value;
- }
+ get { return Parameter.Constant; }
+ set { Parameter.Constant = value; }
}
- public MarshalSpec MarshalSpec {
- get {
- if (m_param == null)
- return null;
+ public bool HasFieldMarshal {
+ get { return parameter != null && parameter.HasFieldMarshal; }
+ set { Parameter.HasFieldMarshal = value; }
+ }
+
+ public bool HasMarshalInfo {
+ get { return parameter != null && parameter.HasMarshalInfo; }
+ }
- return m_param.MarshalSpec;
- }
- set { m_param.MarshalSpec = value; }
+ public MarshalInfo MarshalInfo {
+ get { return Parameter.MarshalInfo; }
+ set { Parameter.MarshalInfo = value; }
}
- public MethodReturnType (TypeReference retType)
+ public MethodReturnType (IMethodSignature method)
{
- m_returnType = retType;
+ this.method = method;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSemanticsAttributes.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSemanticsAttributes.cs
index 6db44b5..f44a3fa 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSemanticsAttributes.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSemanticsAttributes.cs
@@ -1,10 +1,10 @@
//
-// MethodSemanticsAttributes.cs
+// MethodSemanticsattributes.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,12 +26,13 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
- using System;
+namespace Mono.Cecil {
[Flags]
public enum MethodSemanticsAttributes : ushort {
+ None = 0x0000,
Setter = 0x0001, // Setter for property
Getter = 0x0002, // Getter for property
Other = 0x0004, // Other method for property or event
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSpecification.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSpecification.cs
index d7e6285..e907d6c 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSpecification.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/MethodSpecification.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,61 +26,78 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
+
+using Mono.Collections.Generic;
- using System;
+namespace Mono.Cecil {
public abstract class MethodSpecification : MethodReference {
- MethodReference m_elementMethod;
+ readonly MethodReference method;
public MethodReference ElementMethod {
- get { return m_elementMethod; }
- set { m_elementMethod = value; }
+ get { return method; }
}
public override string Name {
- get { return m_elementMethod.Name; }
+ get { return method.Name; }
set { throw new InvalidOperationException (); }
}
public override MethodCallingConvention CallingConvention {
- get { return m_elementMethod.CallingConvention; }
+ get { return method.CallingConvention; }
set { throw new InvalidOperationException (); }
}
public override bool HasThis {
- get { return m_elementMethod.HasThis; }
+ get { return method.HasThis; }
set { throw new InvalidOperationException (); }
}
public override bool ExplicitThis {
- get { return m_elementMethod.ExplicitThis; }
+ get { return method.ExplicitThis; }
set { throw new InvalidOperationException (); }
}
- public override MethodReturnType ReturnType {
- get { return m_elementMethod.ReturnType; }
+ public override MethodReturnType MethodReturnType {
+ get { return method.MethodReturnType; }
set { throw new InvalidOperationException (); }
}
public override TypeReference DeclaringType {
- get { return m_elementMethod.DeclaringType; }
+ get { return method.DeclaringType; }
set { throw new InvalidOperationException (); }
}
- public override ParameterDefinitionCollection Parameters {
- get { return m_elementMethod.Parameters; }
+ public override ModuleDefinition Module {
+ get { return method.Module; }
+ }
+
+ public override bool HasParameters {
+ get { return method.HasParameters; }
}
- internal MethodSpecification (MethodReference elemMethod) : base (string.Empty)
+ public override Collection<ParameterDefinition> Parameters {
+ get { return method.Parameters; }
+ }
+
+ internal override bool ContainsGenericParameter {
+ get { return method.ContainsGenericParameter; }
+ }
+
+ internal MethodSpecification (MethodReference method)
{
- m_elementMethod = elemMethod;
+ if (method == null)
+ throw new ArgumentNullException ("method");
+
+ this.method = method;
+ this.token = new MetadataToken (TokenType.MethodSpec);
}
- public override MethodReference GetOriginalMethod()
+ public sealed override MethodReference GetElementMethod ()
{
- return m_elementMethod.GetOriginalMethod ();
+ return method.GetElementMethod ();
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Modifiers.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Modifiers.cs
index 7007636..f7ff611 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Modifiers.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Modifiers.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,62 +26,112 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
+using MD = Mono.Cecil.Metadata;
+
namespace Mono.Cecil {
- public abstract class ModType : TypeSpecification {
+ public interface IModifierType {
+ TypeReference ModifierType { get; }
+ TypeReference ElementType { get; }
+ }
+
+ public sealed class OptionalModifierType : TypeSpecification, IModifierType {
- TypeReference m_modifierType;
+ TypeReference modifier_type;
public TypeReference ModifierType {
- get { return m_modifierType; }
- set { m_modifierType = value; }
+ get { return modifier_type; }
+ set { modifier_type = value; }
}
- public override string Name
- {
- get { return string.Concat (base.Name, Suffix ()); }
+ public override string Name {
+ get { return base.Name + Suffix; }
}
- public override string FullName
- {
- get { return string.Concat (base.FullName, Suffix ()); }
+ public override string FullName {
+ get { return base.FullName + Suffix; }
}
- string Suffix ()
- {
- return string.Concat (" ", ModifierName, "(", this.ModifierType.FullName, ")");
+ string Suffix {
+ get { return " modopt(" + modifier_type + ")"; }
}
- protected abstract string ModifierName {
- get;
+ public override bool IsValueType {
+ get { return false; }
+ set { throw new InvalidOperationException (); }
}
- public ModType (TypeReference elemType, TypeReference modType) : base (elemType)
+ public override bool IsOptionalModifier {
+ get { return true; }
+ }
+
+ internal override bool ContainsGenericParameter {
+ get { return modifier_type.ContainsGenericParameter || base.ContainsGenericParameter; }
+ }
+
+ public OptionalModifierType (TypeReference modifierType, TypeReference type)
+ : base (type)
{
- m_modifierType = modType;
+ Mixin.CheckModifier (modifierType, type);
+ this.modifier_type = modifierType;
+ this.etype = MD.ElementType.CModOpt;
}
}
- public sealed class ModifierOptional : ModType {
+ public sealed class RequiredModifierType : TypeSpecification, IModifierType {
- protected override string ModifierName {
- get { return "modopt"; }
+ TypeReference modifier_type;
+
+ public TypeReference ModifierType {
+ get { return modifier_type; }
+ set { modifier_type = value; }
}
- public ModifierOptional (TypeReference elemType, TypeReference modType) : base (elemType, modType)
- {
+ public override string Name {
+ get { return base.Name + Suffix; }
}
- }
+ public override string FullName {
+ get { return base.FullName + Suffix; }
+ }
+
+ string Suffix {
+ get { return " modreq(" + modifier_type + ")"; }
+ }
- public sealed class ModifierRequired : ModType {
+ public override bool IsValueType {
+ get { return false; }
+ set { throw new InvalidOperationException (); }
+ }
+
+ public override bool IsRequiredModifier {
+ get { return true; }
+ }
- protected override string ModifierName {
- get { return "modreq"; }
+ internal override bool ContainsGenericParameter {
+ get { return modifier_type.ContainsGenericParameter || base.ContainsGenericParameter; }
}
- public ModifierRequired (TypeReference elemType, TypeReference modType) : base (elemType, modType)
+ public RequiredModifierType (TypeReference modifierType, TypeReference type)
+ : base (type)
+ {
+ Mixin.CheckModifier (modifierType, type);
+ this.modifier_type = modifierType;
+ this.etype = MD.ElementType.CModReqD;
+ }
+
+ }
+
+ static partial class Mixin {
+
+ public static void CheckModifier (TypeReference modifierType, TypeReference type)
{
+ if (modifierType == null)
+ throw new ArgumentNullException ("modifierType");
+ if (type == null)
+ throw new ArgumentNullException ("type");
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinition.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinition.cs
index 7526b81..597a4b6 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinition.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinition.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,503 +26,921 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using SR = System.Reflection;
+
+using Mono.Cecil.Cil;
+using Mono.Cecil.Metadata;
+using Mono.Cecil.PE;
+using Mono.Collections.Generic;
+
namespace Mono.Cecil {
- using System;
- using SR = System.Reflection;
- using SS = System.Security;
- using SSP = System.Security.Permissions;
- using System.Text;
+ public enum ReadingMode {
+ Immediate = 1,
+ Deferred = 2,
+ }
+
+ public sealed class ReaderParameters {
+
+ ReadingMode reading_mode;
+ IAssemblyResolver assembly_resolver;
+ Stream symbol_stream;
+ ISymbolReaderProvider symbol_reader_provider;
+ bool read_symbols;
+
+ public ReadingMode ReadingMode {
+ get { return reading_mode; }
+ set { reading_mode = value; }
+ }
+
+ public IAssemblyResolver AssemblyResolver {
+ get { return assembly_resolver; }
+ set { assembly_resolver = value; }
+ }
+
+ public Stream SymbolStream {
+ get { return symbol_stream; }
+ set { symbol_stream = value; }
+ }
+
+ public ISymbolReaderProvider SymbolReaderProvider {
+ get { return symbol_reader_provider; }
+ set { symbol_reader_provider = value; }
+ }
+
+ public bool ReadSymbols {
+ get { return read_symbols; }
+ set { read_symbols = value; }
+ }
+
+ public ReaderParameters ()
+ : this (ReadingMode.Deferred)
+ {
+ }
+
+ public ReaderParameters (ReadingMode readingMode)
+ {
+ this.reading_mode = readingMode;
+ }
+ }
+
+#if !READ_ONLY
+
+ public sealed class ModuleParameters {
+
+ ModuleKind kind;
+ TargetRuntime runtime;
+ TargetArchitecture architecture;
+ IAssemblyResolver assembly_resolver;
+
+ public ModuleKind Kind {
+ get { return kind; }
+ set { kind = value; }
+ }
+
+ public TargetRuntime Runtime {
+ get { return runtime; }
+ set { runtime = value; }
+ }
+
+ public TargetArchitecture Architecture {
+ get { return architecture; }
+ set { architecture = value; }
+ }
+
+ public IAssemblyResolver AssemblyResolver {
+ get { return assembly_resolver; }
+ set { assembly_resolver = value; }
+ }
- using Mono.Cecil.Cil;
- using Mono.Cecil.Binary;
- using Mono.Cecil.Metadata;
+ public ModuleParameters ()
+ {
+ this.kind = ModuleKind.Dll;
+ this.runtime = GetCurrentRuntime ();
+ this.architecture = TargetArchitecture.I386;
+ }
- public sealed class ModuleDefinition : ModuleReference, ICustomAttributeProvider, IMetadataScope,
- IReflectionStructureVisitable, IReflectionVisitable {
+ static TargetRuntime GetCurrentRuntime ()
+ {
+#if !CF
+ return typeof (object).Assembly.ImageRuntimeVersion.ParseRuntime ();
+#else
+ var corlib_version = typeof (object).Assembly.GetName ().Version;
+ switch (corlib_version.Major) {
+ case 1:
+ return corlib_version.Minor == 0
+ ? TargetRuntime.Net_1_0
+ : TargetRuntime.Net_1_1;
+ case 2:
+ return TargetRuntime.Net_2_0;
+ case 4:
+ return TargetRuntime.Net_4_0;
+ default:
+ throw new NotSupportedException ();
+ }
+#endif
+ }
+ }
- Guid m_mvid;
- bool m_main;
- bool m_manifestOnly;
+ public sealed class WriterParameters {
- AssemblyNameReferenceCollection m_asmRefs;
- ModuleReferenceCollection m_modRefs;
- ResourceCollection m_res;
- TypeDefinitionCollection m_types;
- TypeReferenceCollection m_refs;
- ExternTypeCollection m_externs;
- MemberReferenceCollection m_members;
- CustomAttributeCollection m_customAttrs;
+ Stream symbol_stream;
+ ISymbolWriterProvider symbol_writer_provider;
+ bool write_symbols;
+#if !SILVERLIGHT && !CF
+ SR.StrongNameKeyPair key_pair;
+#endif
+ public Stream SymbolStream {
+ get { return symbol_stream; }
+ set { symbol_stream = value; }
+ }
- AssemblyDefinition m_asm;
- Image m_image;
+ public ISymbolWriterProvider SymbolWriterProvider {
+ get { return symbol_writer_provider; }
+ set { symbol_writer_provider = value; }
+ }
- ImageReader m_imgReader;
- ReflectionController m_controller;
- SecurityDeclarationReader m_secReader;
+ public bool WriteSymbols {
+ get { return write_symbols; }
+ set { write_symbols = value; }
+ }
+#if !SILVERLIGHT && !CF
+ public SR.StrongNameKeyPair StrongNameKeyPair {
+ get { return key_pair; }
+ set { key_pair = value; }
+ }
+#endif
+ }
+
+#endif
+
+ public sealed class ModuleDefinition : ModuleReference, ICustomAttributeProvider {
+
+ internal Image Image;
+ internal MetadataSystem MetadataSystem;
+ internal ReadingMode ReadingMode;
+ internal IAssemblyResolver AssemblyResolver;
+ internal ISymbolReaderProvider SymbolReaderProvider;
+ internal ISymbolReader SymbolReader;
+
+ TypeSystem type_system;
+
+ readonly MetadataReader reader;
+ readonly string fq_name;
+
+ internal ModuleKind kind;
+ TargetRuntime runtime;
+ TargetArchitecture architecture;
+ ModuleAttributes attributes;
+ Guid mvid;
+
+ internal AssemblyDefinition assembly;
+ MethodDefinition entry_point;
+
+#if !READ_ONLY
+ MetadataImporter importer;
+#endif
+ Collection<CustomAttribute> custom_attributes;
+ Collection<AssemblyNameReference> references;
+ Collection<ModuleReference> modules;
+ Collection<Resource> resources;
+ Collection<ExportedType> exported_types;
+ TypeDefinitionCollection types;
+
+ public bool IsMain {
+ get { return kind != ModuleKind.NetModule; }
+ }
+
+ public ModuleKind Kind {
+ get { return kind; }
+ }
+
+ public TargetRuntime Runtime {
+ get { return runtime; }
+ set { runtime = value; }
+ }
+
+ public TargetArchitecture Architecture {
+ get { return architecture; }
+ set { architecture = value; }
+ }
+
+ public ModuleAttributes Attributes {
+ get { return attributes; }
+ set { attributes = value; }
+ }
+
+ public string FullyQualifiedName {
+ get { return fq_name; }
+ }
public Guid Mvid {
- get { return m_mvid; }
- set { m_mvid = value; }
+ get { return mvid; }
+ set { mvid = value; }
}
- public bool Main {
- get { return m_main; }
- set { m_main = value; }
+ internal bool HasImage {
+ get { return Image != null; }
}
- public AssemblyNameReferenceCollection AssemblyReferences {
- get { return m_asmRefs; }
+ public bool HasSymbols {
+ get { return SymbolReader != null; }
}
- public ModuleReferenceCollection ModuleReferences {
- get { return m_modRefs; }
+ public override MetadataScopeType MetadataScopeType {
+ get { return MetadataScopeType.ModuleDefinition; }
}
- public ResourceCollection Resources {
- get { return m_res; }
+ public AssemblyDefinition Assembly {
+ get { return assembly; }
}
- public TypeDefinitionCollection Types {
- get { return m_types; }
+#if !READ_ONLY
+ internal MetadataImporter MetadataImporter {
+ get { return importer ?? (importer = new MetadataImporter (this)); }
}
+#endif
- public TypeReferenceCollection TypeReferences {
- get { return m_refs; }
+ public TypeSystem TypeSystem {
+ get { return type_system ?? (type_system = TypeSystem.CreateTypeSystem (this)); }
}
- public MemberReferenceCollection MemberReferences {
- get { return m_members; }
+ public bool HasAssemblyReferences {
+ get {
+ if (references != null)
+ return references.Count > 0;
+
+ return HasImage && Image.HasTable (Table.AssemblyRef);
+ }
}
- public ExternTypeCollection ExternTypes {
+ public Collection<AssemblyNameReference> AssemblyReferences {
get {
- if (m_externs == null)
- m_externs = new ExternTypeCollection (this);
+ if (references != null)
+ return references;
- return m_externs;
+ if (HasImage)
+ return references = Read (this, (_, reader) => reader.ReadAssemblyReferences ());
+
+ return references = new Collection<AssemblyNameReference> ();
}
}
- public CustomAttributeCollection CustomAttributes {
+ public bool HasModuleReferences {
get {
- if (m_customAttrs == null)
- m_customAttrs = new CustomAttributeCollection (this);
+ if (modules != null)
+ return modules.Count > 0;
- return m_customAttrs;
+ return HasImage && Image.HasTable (Table.ModuleRef);
}
}
- public AssemblyDefinition Assembly {
- get { return m_asm; }
+ public Collection<ModuleReference> ModuleReferences {
+ get {
+ if (modules != null)
+ return modules;
+
+ if (HasImage)
+ return modules = Read (this, (_, reader) => reader.ReadModuleReferences ());
+
+ return modules = new Collection<ModuleReference> ();
+ }
}
- internal ReflectionController Controller {
- get { return m_controller; }
+ public bool HasResources {
+ get {
+ if (resources != null)
+ return resources.Count > 0;
+
+ if (HasImage)
+ return Image.HasTable (Table.ManifestResource) || Read (this, (_, reader) => reader.HasFileResource ());
+
+ return false;
+ }
}
- internal ImageReader ImageReader {
- get { return m_imgReader; }
+ public Collection<Resource> Resources {
+ get {
+ if (resources != null)
+ return resources;
+
+ if (HasImage)
+ return resources = Read (this, (_, reader) => reader.ReadResources ());
+
+ return resources = new Collection<Resource> ();
+ }
}
- public Image Image {
- get { return m_image; }
- set {
- m_image = value;
- m_secReader = null;
+ public bool HasCustomAttributes {
+ get {
+ if (custom_attributes != null)
+ return custom_attributes.Count > 0;
+
+ return this.GetHasCustomAttributes (this);
}
}
- public ModuleDefinition (string name, AssemblyDefinition asm) :
- this (name, asm, null, false)
+ public Collection<CustomAttribute> CustomAttributes {
+ get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (this)); }
+ }
+
+ public bool HasTypes {
+ get {
+ if (types != null)
+ return types.Count > 0;
+
+ return HasImage && Image.HasTable (Table.TypeDef);
+ }
+ }
+
+ public Collection<TypeDefinition> Types {
+ get {
+ if (types != null)
+ return types;
+
+ if (HasImage)
+ return types = Read (this, (_, reader) => reader.ReadTypes ());
+
+ return types = new TypeDefinitionCollection (this);
+ }
+ }
+
+ public bool HasExportedTypes {
+ get {
+ if (exported_types != null)
+ return exported_types.Count > 0;
+
+ return HasImage && Image.HasTable (Table.ExportedType);
+ }
+ }
+
+ public Collection<ExportedType> ExportedTypes {
+ get {
+ if (exported_types != null)
+ return exported_types;
+
+ if (HasImage)
+ return exported_types = Read (this, (_, reader) => reader.ReadExportedTypes ());
+
+ return exported_types = new Collection<ExportedType> ();
+ }
+ }
+
+ public MethodDefinition EntryPoint {
+ get {
+ if (entry_point != null)
+ return entry_point;
+
+ if (HasImage)
+ return entry_point = Read (this, (_, reader) => reader.ReadEntryPoint ());
+
+ return entry_point = null;
+ }
+ set { entry_point = value; }
+ }
+
+ internal ModuleDefinition ()
{
+ this.MetadataSystem = new MetadataSystem ();
+ this.token = new MetadataToken (TokenType.Module, 1);
+ this.AssemblyResolver = GlobalAssemblyResolver.Instance;
}
- public ModuleDefinition (string name, AssemblyDefinition asm, bool main) :
- this (name, asm, null, main)
+ internal ModuleDefinition (Image image)
+ : this ()
{
+ this.Image = image;
+ this.kind = image.Kind;
+ this.runtime = image.Runtime;
+ this.architecture = image.Architecture;
+ this.attributes = image.Attributes;
+ this.fq_name = image.FileName;
+
+ this.reader = new MetadataReader (this);
}
- internal ModuleDefinition (string name, AssemblyDefinition asm, StructureReader reader) :
- this (name, asm, reader, false)
+ public bool HasTypeReference (string fullName)
{
+ return HasTypeReference (string.Empty, fullName);
}
- internal ModuleDefinition (string name, AssemblyDefinition asm, StructureReader reader, bool main) : base (name)
+ public bool HasTypeReference (string scope, string fullName)
{
- if (asm == null)
- throw new ArgumentNullException ("asm");
- if (name == null || name.Length == 0)
- throw new ArgumentNullException ("name");
+ CheckFullName (fullName);
- m_asm = asm;
- m_main = main;
-#if !CF_1_0
- m_mvid = Guid.NewGuid ();
-#endif
- if (reader != null) {
- m_image = reader.Image;
- m_imgReader = reader.ImageReader;
- m_manifestOnly = reader.ManifestOnly;
- } else
- m_image = Image.CreateImage ();
+ return Read (this, (_, reader) => reader.GetTypeReference (scope, fullName) != null);
+ }
- m_modRefs = new ModuleReferenceCollection (this);
- m_asmRefs = new AssemblyNameReferenceCollection (this);
- m_res = new ResourceCollection (this);
- m_types = new TypeDefinitionCollection (this);
- m_refs = new TypeReferenceCollection (this);
- m_members = new MemberReferenceCollection (this);
+ public bool TryGetTypeReference (string fullName, out TypeReference type)
+ {
+ return TryGetTypeReference (string.Empty, fullName, out type);
+ }
+
+ public bool TryGetTypeReference (string scope, string fullName, out TypeReference type)
+ {
+ CheckFullName (fullName);
- m_controller = new ReflectionController (this);
+ return (type = Read (this, (_, reader) => reader.GetTypeReference (scope, fullName))) != null;
}
- public IMetadataTokenProvider LookupByToken (MetadataToken token)
+ public IEnumerable<TypeReference> GetTypeReferences ()
{
- return m_controller.Reader.LookupByToken (token);
+ return Read (this, (_, reader) => reader.GetTypeReferences ());
}
- public IMetadataTokenProvider LookupByToken (TokenType table, int rid)
+ public IEnumerable<MemberReference> GetMemberReferences ()
{
- return LookupByToken (new MetadataToken (table, (uint) rid));
+ return Read (this, (_, reader) => reader.GetMemberReferences ());
}
- void CheckContext (TypeDefinition context)
+ public TypeDefinition GetType (string fullName)
{
- if (context == null)
- throw new ArgumentNullException ("context");
- if (context.Module != this)
- throw new ArgumentException ("The context parameter does not belongs to this module");
- if (context.GenericParameters.Count == 0)
- throw new ArgumentException ("The context parameter is not a generic type");
+ CheckFullName (fullName);
+
+ var position = fullName.IndexOf ('/');
+ if (position > 0)
+ return GetNestedType (fullName);
+
+ return ((TypeDefinitionCollection) this.Types).GetType (fullName);
}
- ImportContext GetContext ()
+ public TypeDefinition GetType (string @namespace, string name)
{
- return new ImportContext (m_controller.Importer);
+ Mixin.CheckName (name);
+
+ return ((TypeDefinitionCollection) this.Types).GetType (@namespace ?? string.Empty, name);
}
- static ImportContext GetContext (IImporter importer)
+ static void CheckFullName (string fullName)
{
- return new ImportContext (importer);
+ if (fullName == null)
+ throw new ArgumentNullException ("fullName");
+ if (fullName.Length == 0)
+ throw new ArgumentException ();
}
- ImportContext GetContext (TypeDefinition context)
+ TypeDefinition GetNestedType (string fullname)
{
- return new ImportContext (m_controller.Importer, context);
+ var names = fullname.Split ('/');
+ var type = GetType (names [0]);
+
+ if (type == null)
+ return null;
+
+ for (int i = 1; i < names.Length; i++) {
+ var nested_type = type.GetNestedType (names [i]);
+ if (nested_type == null)
+ return null;
+
+ type = nested_type;
+ }
+
+ return type;
}
- static ImportContext GetContext (IImporter importer, TypeDefinition context)
+ internal FieldDefinition Resolve (FieldReference field)
{
- return new ImportContext (importer, context);
+ return MetadataResolver.Resolve (AssemblyResolver, field);
}
- public TypeReference Import (Type type)
+ internal MethodDefinition Resolve (MethodReference method)
{
- if (type == null)
- throw new ArgumentNullException ("type");
+ return MetadataResolver.Resolve (AssemblyResolver, method);
+ }
- return m_controller.Helper.ImportSystemType (type, GetContext ());
+ internal TypeDefinition Resolve (TypeReference type)
+ {
+ return MetadataResolver.Resolve (AssemblyResolver, type);
}
- public TypeReference Import (Type type, TypeDefinition context)
+#if !READ_ONLY
+
+ static void CheckType (object type)
{
if (type == null)
throw new ArgumentNullException ("type");
- CheckContext (context);
+ }
+
+ static void CheckField (object field)
+ {
+ if (field == null)
+ throw new ArgumentNullException ("field");
+ }
+
+ static void CheckMethod (object method)
+ {
+ if (method == null)
+ throw new ArgumentNullException ("method");
+ }
+
+ static void CheckContext (IGenericParameterProvider context, ModuleDefinition module)
+ {
+ if (context == null)
+ return;
+
+ if (context.Module != module)
+ throw new ArgumentException ();
+ }
- return m_controller.Helper.ImportSystemType (type, GetContext (context));
+#if !CF
+ public TypeReference Import (Type type)
+ {
+ CheckType (type);
+
+ return MetadataImporter.ImportType (type, null, ImportGenericKind.Definition);
}
- public MethodReference Import (SR.MethodBase meth)
+ public TypeReference Import (Type type, TypeReference context)
{
- if (meth == null)
- throw new ArgumentNullException ("meth");
+ return Import (type, (IGenericParameterProvider) context);
+ }
- if (meth is SR.ConstructorInfo)
- return m_controller.Helper.ImportConstructorInfo (
- meth as SR.ConstructorInfo, GetContext ());
- else
- return m_controller.Helper.ImportMethodInfo (
- meth as SR.MethodInfo, GetContext ());
+ public TypeReference Import (Type type, MethodReference context)
+ {
+ return Import (type, (IGenericParameterProvider) context);
}
- public MethodReference Import (SR.MethodBase meth, TypeDefinition context)
+ TypeReference Import (Type type, IGenericParameterProvider context)
{
- if (meth == null)
- throw new ArgumentNullException ("meth");
- CheckContext (context);
+ CheckType (type);
+ CheckContext (context, this);
- if (meth is SR.ConstructorInfo)
- return m_controller.Helper.ImportConstructorInfo (
- meth as SR.ConstructorInfo, GetContext (context));
- else
- return m_controller.Helper.ImportMethodInfo (
- meth as SR.MethodInfo, GetContext (context));
+ return MetadataImporter.ImportType (
+ type,
+ (IGenericContext) context,
+ context != null
+ ? ImportGenericKind.Open
+ : ImportGenericKind.Definition);
}
public FieldReference Import (SR.FieldInfo field)
{
- if (field == null)
- throw new ArgumentNullException ("field");
+ CheckField (field);
- return m_controller.Helper.ImportFieldInfo (field, GetContext ());
+ return MetadataImporter.ImportField (field, null);
}
- public FieldReference Import (SR.FieldInfo field, TypeDefinition context)
+ public FieldReference Import (SR.FieldInfo field, TypeReference context)
{
- if (field == null)
- throw new ArgumentNullException ("field");
- CheckContext (context);
+ return Import (field, (IGenericParameterProvider) context);
+ }
- return m_controller.Helper.ImportFieldInfo (field, GetContext (context));
+ public FieldReference Import (SR.FieldInfo field, MethodReference context)
+ {
+ return Import (field, (IGenericParameterProvider) context);
}
- public TypeReference Import (TypeReference type)
+ FieldReference Import (SR.FieldInfo field, IGenericParameterProvider context)
{
- if (type == null)
- throw new ArgumentNullException ("type");
+ CheckField (field);
+ CheckContext (context, this);
- return m_controller.Importer.ImportTypeReference (type, GetContext ());
+ return MetadataImporter.ImportField (field, (IGenericContext) context);
}
- public TypeReference Import (TypeReference type, TypeDefinition context)
+ public MethodReference Import (SR.MethodBase method)
{
- if (type == null)
- throw new ArgumentNullException ("type");
- CheckContext (context);
+ CheckMethod (method);
- return m_controller.Importer.ImportTypeReference (type, GetContext (context));
+ return MetadataImporter.ImportMethod (method, null, ImportGenericKind.Definition);
}
- public MethodReference Import (MethodReference meth)
+ public MethodReference Import (SR.MethodBase method, TypeReference context)
{
- if (meth == null)
- throw new ArgumentNullException ("meth");
+ return Import (method, (IGenericParameterProvider) context);
+ }
- return m_controller.Importer.ImportMethodReference (meth, GetContext ());
+ public MethodReference Import (SR.MethodBase method, MethodReference context)
+ {
+ return Import (method, (IGenericParameterProvider) context);
}
- public MethodReference Import (MethodReference meth, TypeDefinition context)
+ MethodReference Import (SR.MethodBase method, IGenericParameterProvider context)
{
- if (meth == null)
- throw new ArgumentNullException ("meth");
- CheckContext (context);
+ CheckMethod (method);
+ CheckContext (context, this);
- return m_controller.Importer.ImportMethodReference (meth, GetContext (context));
+ return MetadataImporter.ImportMethod (method,
+ (IGenericContext) context,
+ context != null
+ ? ImportGenericKind.Open
+ : ImportGenericKind.Definition);
}
+#endif
- public FieldReference Import (FieldReference field)
+ public TypeReference Import (TypeReference type)
{
- if (field == null)
- throw new ArgumentNullException ("field");
+ CheckType (type);
+
+ if (type.Module == this)
+ return type;
- return m_controller.Importer.ImportFieldReference (field, GetContext ());
+ return MetadataImporter.ImportType (type, null);
}
- public FieldReference Import (FieldReference field, TypeDefinition context)
+ public TypeReference Import (TypeReference type, TypeReference context)
{
- if (field == null)
- throw new ArgumentNullException ("field");
- CheckContext (context);
+ return Import (type, (IGenericParameterProvider) context);
+ }
- return m_controller.Importer.ImportFieldReference (field, GetContext (context));
+ public TypeReference Import (TypeReference type, MethodReference context)
+ {
+ return Import (type, (IGenericParameterProvider) context);
}
- static FieldDefinition ImportFieldDefinition (FieldDefinition field, ImportContext context)
+ TypeReference Import (TypeReference type, IGenericParameterProvider context)
{
- return FieldDefinition.Clone (field, context);
+ CheckType (type);
+
+ if (type.Module == this)
+ return type;
+
+ CheckContext (context, this);
+
+ return MetadataImporter.ImportType (type, (IGenericContext) context);
}
- static MethodDefinition ImportMethodDefinition (MethodDefinition meth, ImportContext context)
+ public FieldReference Import (FieldReference field)
{
- return MethodDefinition.Clone (meth, context);
+ CheckField (field);
+
+ if (field.Module == this)
+ return field;
+
+ return MetadataImporter.ImportField (field, null);
}
- static TypeDefinition ImportTypeDefinition (TypeDefinition type, ImportContext context)
+ public FieldReference Import (FieldReference field, TypeReference context)
{
- return TypeDefinition.Clone (type, context);
+ return Import (field, (IGenericParameterProvider) context);
}
- public TypeDefinition Inject (TypeDefinition type)
+ public FieldReference Import (FieldReference field, MethodReference context)
{
- return Inject (type, m_controller.Importer);
+ return Import (field, (IGenericParameterProvider) context);
}
- public TypeDefinition Inject (TypeDefinition type, IImporter importer)
+ FieldReference Import (FieldReference field, IGenericParameterProvider context)
{
- if (type == null)
- throw new ArgumentNullException ("type");
- if (importer == null)
- throw new ArgumentNullException ("importer");
+ CheckField (field);
+
+ if (field.Module == this)
+ return field;
- TypeDefinition definition = ImportTypeDefinition (type, GetContext (importer));
- this.Types.Add (definition);
- return definition;
+ CheckContext (context, this);
+
+ return MetadataImporter.ImportField (field, (IGenericContext) context);
}
- public TypeDefinition Inject (TypeDefinition type, TypeDefinition context)
+ public MethodReference Import (MethodReference method)
{
- return Inject (type, context, m_controller.Importer);
+ CheckMethod (method);
+
+ if (method.Module == this)
+ return method;
+
+ return MetadataImporter.ImportMethod (method, null);
}
- public TypeDefinition Inject (TypeDefinition type, TypeDefinition context, IImporter importer)
+ public MethodReference Import (MethodReference method, TypeReference context)
{
- Check (type, context, importer);
+ return Import (method, (IGenericParameterProvider) context);
+ }
- TypeDefinition definition = ImportTypeDefinition (type, GetContext (importer, context));
- context.NestedTypes.Add (definition);
- return definition;
+ public MethodReference Import (MethodReference method, MethodReference context)
+ {
+ return Import (method, (IGenericParameterProvider) context);
}
- public MethodDefinition Inject (MethodDefinition meth, TypeDefinition context)
+ MethodReference Import (MethodReference method, IGenericParameterProvider context)
{
- return Inject (meth, context, m_controller.Importer);
+ CheckMethod (method);
+
+ if (method.Module == this)
+ return method;
+
+ CheckContext (context, this);
+
+ return MetadataImporter.ImportMethod (method, (IGenericContext) context);
+ }
+
+#endif
+
+ public IMetadataTokenProvider LookupToken (int token)
+ {
+ return LookupToken (new MetadataToken ((uint) token));
}
- void Check (IMemberDefinition definition, TypeDefinition context, IImporter importer)
+ public IMetadataTokenProvider LookupToken (MetadataToken token)
{
- if (definition == null)
- throw new ArgumentNullException ("definition");
- if (context == null)
- throw new ArgumentNullException ("context");
- if (importer == null)
- throw new ArgumentNullException ("importer");
- if (context.Module != this)
- throw new ArgumentException ("The context parameter does not belongs to this module");
+ return Read (this, (_, reader) => reader.LookupToken (token));
}
- public MethodDefinition Inject (MethodDefinition meth, TypeDefinition context, IImporter importer)
+ internal TRet Read<TItem, TRet> (TItem item, Func<TItem, MetadataReader, TRet> read)
{
- Check (meth, context, importer);
+ var position = reader.position;
+ var context = reader.context;
- MethodDefinition definition = ImportMethodDefinition (meth, GetContext (importer, context));
- context.Methods.Add (definition);
- return definition;
+ var ret = read (item, reader);
+
+ reader.position = position;
+ reader.context = context;
+
+ return ret;
}
- public FieldDefinition Inject (FieldDefinition field, TypeDefinition context, IImporter importer)
+ void ProcessDebugHeader ()
{
- Check (field, context, importer);
+ if (Image == null || Image.Debug.IsZero)
+ return;
+
+ byte [] header;
+ var directory = Image.GetDebugHeader (out header);
- FieldDefinition definition = ImportFieldDefinition (field, GetContext (importer, context));
- context.Fields.Add (definition);
- return definition;
+ if (!SymbolReader.ProcessDebugHeader (directory, header))
+ throw new InvalidOperationException ();
}
- public void FullLoad ()
+#if !READ_ONLY
+
+ public static ModuleDefinition CreateModule (string name, ModuleKind kind)
{
- if (m_manifestOnly)
- m_controller.Reader.VisitModuleDefinition (this);
+ return CreateModule (name, new ModuleParameters { Kind = kind });
+ }
- foreach (TypeDefinition type in this.Types) {
- foreach (MethodDefinition meth in type.Methods)
- meth.LoadBody ();
- foreach (MethodDefinition ctor in type.Constructors)
- ctor.LoadBody ();
+ public static ModuleDefinition CreateModule (string name, ModuleParameters parameters)
+ {
+ Mixin.CheckName (name);
+ Mixin.CheckParameters (parameters);
+
+ var module = new ModuleDefinition {
+ Name = name,
+ kind = parameters.Kind,
+ runtime = parameters.Runtime,
+ architecture = parameters.Architecture,
+ mvid = Guid.NewGuid (),
+ Attributes = ModuleAttributes.ILOnly,
+ };
+
+ if (parameters.AssemblyResolver != null)
+ module.AssemblyResolver = parameters.AssemblyResolver;
+
+ if (parameters.Kind != ModuleKind.NetModule) {
+ var assembly = new AssemblyDefinition ();
+ module.assembly = assembly;
+ module.assembly.Name = new AssemblyNameDefinition (name, new Version (0, 0));
+ assembly.main_module = module;
}
- if (m_controller.Reader.SymbolReader == null)
- return;
+ module.Types.Add (new TypeDefinition (string.Empty, "<Module>", TypeAttributes.NotPublic));
- m_controller.Reader.SymbolReader.Dispose ();
- m_controller.Reader.SymbolReader = null;
+ return module;
}
- public void LoadSymbols ()
+#endif
+
+ public void ReadSymbols ()
{
- m_controller.Reader.SymbolReader = SymbolStoreHelper.GetReader (this);
+ if (string.IsNullOrEmpty (fq_name))
+ throw new InvalidOperationException ();
+
+ var provider = SymbolProvider.GetPlatformReaderProvider ();
+
+ SymbolReader = provider.GetSymbolReader (this, fq_name);
+
+ ProcessDebugHeader ();
}
- public void LoadSymbols (ISymbolReader reader)
+ public void ReadSymbols (ISymbolReader reader)
{
- m_controller.Reader.SymbolReader = reader;
+ if (reader == null)
+ throw new ArgumentNullException ("reader");
+
+ SymbolReader = reader;
+
+ ProcessDebugHeader ();
}
- public void SaveSymbols ()
+ public static ModuleDefinition ReadModule (string fileName)
{
- m_controller.Writer.SaveSymbols = true;
+ return ReadModule (fileName, new ReaderParameters (ReadingMode.Deferred));
}
- public void SaveSymbols (ISymbolWriter writer)
+ public static ModuleDefinition ReadModule (Stream stream)
{
- SaveSymbols ();
- m_controller.Writer.SymbolWriter = writer;
+ return ReadModule (stream, new ReaderParameters (ReadingMode.Deferred));
}
- public void SaveSymbols (string outputDirectory)
+ public static ModuleDefinition ReadModule (string fileName, ReaderParameters parameters)
{
- SaveSymbols ();
- m_controller.Writer.OutputFile = outputDirectory;
+ using (var stream = GetFileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) {
+ return ReadModule (stream, parameters);
+ }
}
- public void SaveSymbols (string outputDirectory, ISymbolWriter writer)
+ static void CheckStream (object stream)
{
- SaveSymbols (outputDirectory);
- m_controller.Writer.SymbolWriter = writer;
+ if (stream == null)
+ throw new ArgumentNullException ("stream");
}
- public byte [] GetAsByteArray (CustomAttribute ca)
+ public static ModuleDefinition ReadModule (Stream stream, ReaderParameters parameters)
{
- CustomAttribute customAttr = ca;
- if (!ca.Resolved)
- if (customAttr.Blob != null)
- return customAttr.Blob;
- else
- return new byte [0];
+ CheckStream (stream);
+ if (!stream.CanRead || !stream.CanSeek)
+ throw new ArgumentException ();
+ Mixin.CheckParameters (parameters);
- return m_controller.Writer.SignatureWriter.CompressCustomAttribute (
- ReflectionWriter.GetCustomAttributeSig (ca), ca.Constructor);
+ return ModuleReader.CreateModuleFrom (
+ ImageReader.ReadImageFrom (stream),
+ parameters);
}
- public byte [] GetAsByteArray (SecurityDeclaration dec)
+ static Stream GetFileStream (string fileName, FileMode mode, FileAccess access, FileShare share)
{
- // TODO - add support for 2.0 format
- // note: the 1.x format is still supported in 2.0 so this isn't an immediate problem
- if (!dec.Resolved)
- return dec.Blob;
+ if (fileName == null)
+ throw new ArgumentNullException ("fileName");
+ if (fileName.Length == 0)
+ throw new ArgumentException ();
-#if !CF_1_0 && !CF_2_0
- if (dec.PermissionSet != null)
- return Encoding.Unicode.GetBytes (dec.PermissionSet.ToXml ().ToString ());
-#endif
+ return new FileStream (fileName, mode, access, share);
+ }
+
+#if !READ_ONLY
- return new byte [0];
+ public void Write (string fileName)
+ {
+ Write (fileName, new WriterParameters ());
}
- public CustomAttribute FromByteArray (MethodReference ctor, byte [] data)
+ public void Write (Stream stream)
{
- return m_controller.Reader.GetCustomAttribute (ctor, data);
+ Write (stream, new WriterParameters ());
}
- public SecurityDeclaration FromByteArray (SecurityAction action, byte [] declaration)
+ public void Write (string fileName, WriterParameters parameters)
{
- if (m_secReader == null)
- m_secReader = new SecurityDeclarationReader (Image.MetadataRoot, m_controller.Reader);
- return m_secReader.FromByteArray (action, declaration);
+ using (var stream = GetFileStream (fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.None)) {
+ Write (stream, parameters);
+ }
}
- public override void Accept (IReflectionStructureVisitor visitor)
+ public void Write (Stream stream, WriterParameters parameters)
{
- visitor.VisitModuleDefinition (this);
+ CheckStream (stream);
+ if (!stream.CanWrite || !stream.CanSeek)
+ throw new ArgumentException ();
+ Mixin.CheckParameters (parameters);
- this.AssemblyReferences.Accept (visitor);
- this.ModuleReferences.Accept (visitor);
- this.Resources.Accept (visitor);
+ ModuleWriter.WriteModuleTo (this, stream, parameters);
}
- public void Accept (IReflectionVisitor visitor)
+#endif
+
+ }
+
+ static partial class Mixin {
+
+ public static void CheckParameters (object parameters)
{
- visitor.VisitModuleDefinition (this);
+ if (parameters == null)
+ throw new ArgumentNullException ("parameters");
+ }
- this.Types.Accept (visitor);
- this.TypeReferences.Accept (visitor);
+ public static bool HasImage (this ModuleDefinition self)
+ {
+ return self != null && self.HasImage;
}
- public override string ToString ()
+ public static string GetFullyQualifiedName (this Stream self)
{
- string s = (m_main ? "(main), Mvid=" : "Mvid=");
- return s + m_mvid;
+#if !SILVERLIGHT
+ var file_stream = self as FileStream;
+ if (file_stream == null)
+ return string.Empty;
+
+ return Path.GetFullPath (file_stream.Name);
+#else
+ return string.Empty;
+#endif
+ }
+
+ public static TargetRuntime ParseRuntime (this string self)
+ {
+ switch (self [1]) {
+ case '1':
+ return self [3] == '0'
+ ? TargetRuntime.Net_1_0
+ : TargetRuntime.Net_1_1;
+ case '2':
+ return TargetRuntime.Net_2_0;
+ case '4':
+ default:
+ return TargetRuntime.Net_4_0;
+ }
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinitionCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinitionCollection.cs
deleted file mode 100644
index 71d1619..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleDefinitionCollection.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// ModuleDefinitionCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:54 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class ModuleDefinitionCollection : CollectionBase, IReflectionStructureVisitable {
-
- AssemblyDefinition m_container;
-
- public ModuleDefinition this [int index] {
- get { return List [index] as ModuleDefinition; }
- set { List [index] = value; }
- }
-
- public AssemblyDefinition Container {
- get { return m_container; }
- }
-
- public ModuleDefinitionCollection (AssemblyDefinition container)
- {
- m_container = container;
- }
-
- public void Add (ModuleDefinition value)
- {
- List.Add (value);
- }
-
- public bool Contains (ModuleDefinition value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (ModuleDefinition value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, ModuleDefinition value)
- {
- List.Insert (index, value);
- }
-
- public void Remove (ModuleDefinition value)
- {
- List.Remove (value);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is ModuleDefinition))
- throw new ArgumentException ("Must be of type " + typeof (ModuleDefinition).FullName);
- }
-
- public void Accept (IReflectionStructureVisitor visitor)
- {
- visitor.VisitModuleDefinitionCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyKind.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleKind.cs
index 7d5e7c0..eb57890 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/AssemblyKind.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleKind.cs
@@ -1,10 +1,10 @@
//
-// AssemblyKind.cs
+// ModuleKind.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,11 +26,27 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
namespace Mono.Cecil {
- public enum AssemblyKind {
+ public enum ModuleKind {
Dll,
Console,
- Windows
+ Windows,
+ NetModule,
+ }
+
+ public enum TargetArchitecture {
+ I386,
+ AMD64,
+ IA64,
+ }
+
+ [Flags]
+ public enum ModuleAttributes {
+ ILOnly = 1,
+ Required32Bit = 2,
+ StrongNameSigned = 8,
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReference.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReference.cs
index 713b96a..11d98b7 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReference.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReference.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,44 +28,41 @@
namespace Mono.Cecil {
- using System.Collections;
+ public class ModuleReference : IMetadataScope {
- using Mono.Cecil;
- using Mono.Cecil.Metadata;
+ string name;
- public class ModuleReference : IMetadataScope, IAnnotationProvider, IReflectionStructureVisitable {
-
- string m_name;
- MetadataToken m_token;
- IDictionary m_annotations;
+ internal MetadataToken token;
public string Name {
- get { return m_name; }
- set { m_name = value; }
+ get { return name; }
+ set { name = value; }
+ }
+
+ public virtual MetadataScopeType MetadataScopeType {
+ get { return MetadataScopeType.ModuleReference; }
}
public MetadataToken MetadataToken {
- get { return m_token; }
- set { m_token = value; }
+ get { return token; }
+ set { token = value; }
}
- IDictionary IAnnotationProvider.Annotations {
- get {
- if (m_annotations == null)
- m_annotations = new Hashtable ();
- return m_annotations;
- }
+ internal ModuleReference ()
+ {
+ this.token = new MetadataToken (TokenType.ModuleRef);
}
public ModuleReference (string name)
+ : this ()
{
- m_name = name;
+ Mixin.CheckName (name);
+ this.name = name;
}
- public virtual void Accept (IReflectionStructureVisitor visitor)
+ public override string ToString ()
{
- visitor.VisitModuleReference (this);
+ return name;
}
}
}
-
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReferenceCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReferenceCollection.cs
deleted file mode 100644
index 03057b3..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ModuleReferenceCollection.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// ModuleReferenceCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:53 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class ModuleReferenceCollection : CollectionBase, IReflectionStructureVisitable {
-
- ModuleDefinition m_container;
-
- public ModuleReference this [int index] {
- get { return List [index] as ModuleReference; }
- set { List [index] = value; }
- }
-
- public ModuleDefinition Container {
- get { return m_container; }
- }
-
- public ModuleReferenceCollection (ModuleDefinition container)
- {
- m_container = container;
- }
-
- public void Add (ModuleReference value)
- {
- List.Add (value);
- }
-
- public bool Contains (ModuleReference value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (ModuleReference value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, ModuleReference value)
- {
- List.Insert (index, value);
- }
-
- public void Remove (ModuleReference value)
- {
- List.Remove (value);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is ModuleReference))
- throw new ArgumentException ("Must be of type " + typeof (ModuleReference).FullName);
- }
-
- public void Accept (IReflectionStructureVisitor visitor)
- {
- visitor.VisitModuleReferenceCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NativeType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NativeType.cs
index c0df049..afa107f 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NativeType.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NativeType.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -29,9 +29,9 @@
namespace Mono.Cecil {
public enum NativeType {
- NONE = 0x66,
+ None = 0x66,
- BOOLEAN = 0x02,
+ Boolean = 0x02,
I1 = 0x03,
U1 = 0x04,
I2 = 0x05,
@@ -42,32 +42,32 @@ namespace Mono.Cecil {
U8 = 0x0a,
R4 = 0x0b,
R8 = 0x0c,
- LPSTR = 0x14,
- INT = 0x1f,
- UINT = 0x20,
- FUNC = 0x26,
- ARRAY = 0x2a,
+ LPStr = 0x14,
+ Int = 0x1f,
+ UInt = 0x20,
+ Func = 0x26,
+ Array = 0x2a,
// Msft specific
- CURRENCY = 0x0f,
- BSTR = 0x13,
- LPWSTR = 0x15,
- LPTSTR = 0x16,
- FIXEDSYSSTRING = 0x17,
- IUNKNOWN = 0x19,
- IDISPATCH = 0x1a,
- STRUCT = 0x1b,
- INTF = 0x1c,
- SAFEARRAY = 0x1d,
- FIXEDARRAY = 0x1e,
- BYVALSTR = 0x22,
- ANSIBSTR = 0x23,
- TBSTR = 0x24,
- VARIANTBOOL = 0x25,
- ASANY = 0x28,
- LPSTRUCT = 0x2b,
- CUSTOMMARSHALER = 0x2c,
- ERROR = 0x2d,
- MAX = 0x50
+ Currency = 0x0f,
+ BStr = 0x13,
+ LPWStr = 0x15,
+ LPTStr = 0x16,
+ FixedSysString = 0x17,
+ IUnknown = 0x19,
+ IDispatch = 0x1a,
+ Struct = 0x1b,
+ IntF = 0x1c,
+ SafeArray = 0x1d,
+ FixedArray = 0x1e,
+ ByValStr = 0x22,
+ ANSIBStr = 0x23,
+ TBStr = 0x24,
+ VariantBool = 0x25,
+ ASAny = 0x28,
+ LPStruct = 0x2b,
+ CustomMarshaler = 0x2c,
+ Error = 0x2d,
+ Max = 0x50
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NestedTypeCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NestedTypeCollection.cs
deleted file mode 100644
index 9e0ee29..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NestedTypeCollection.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-//
-// NestedTypeCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Fri Mar 30 18:43:57 +0200 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class NestedTypeCollection : CollectionBase, IReflectionVisitable {
-
- TypeDefinition m_container;
-
- public TypeDefinition this [int index] {
- get { return List [index] as TypeDefinition; }
- set { List [index] = value; }
- }
-
- public TypeDefinition Container {
- get { return m_container; }
- }
-
- public NestedTypeCollection (TypeDefinition container)
- {
- m_container = container;
- }
-
- public void Add (TypeDefinition value)
- {
- Attach (value);
-
- List.Add (value);
- }
-
-
- public new void Clear ()
- {
- foreach (TypeDefinition item in this)
- Detach (item);
-
- base.Clear ();
- }
-
- public bool Contains (TypeDefinition value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (TypeDefinition value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, TypeDefinition value)
- {
- Attach (value);
-
- List.Insert (index, value);
- }
-
- public void Remove (TypeDefinition value)
- {
- List.Remove (value);
-
- Detach (value);
- }
-
-
- public new void RemoveAt (int index)
- {
- TypeDefinition item = this [index];
- Remove (item);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is TypeDefinition))
- throw new ArgumentException ("Must be of type " + typeof (TypeDefinition).FullName);
- }
-
- void Attach (MemberReference member)
- {
- if (member.DeclaringType != null)
- throw new ReflectionException ("Member already attached, clone it instead");
-
- member.DeclaringType = m_container;
- }
-
- void Detach (MemberReference member)
- {
- member.DeclaringType = null;
- }
-
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitNestedTypeCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NullReferenceImporter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NullReferenceImporter.cs
deleted file mode 100644
index 0df44b7..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/NullReferenceImporter.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// NullReferenceImporter.cs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// (C) 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- class NullReferenceImporter : IImporter {
-
- public static readonly NullReferenceImporter Instance = new NullReferenceImporter ();
-
- public TypeReference ImportTypeReference (TypeReference type, ImportContext context)
- {
- return type;
- }
-
- public FieldReference ImportFieldReference (FieldReference field, ImportContext context)
- {
- return field;
- }
-
- public MethodReference ImportMethodReference (MethodReference method, ImportContext context)
- {
- return method;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/OverrideCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/OverrideCollection.cs
deleted file mode 100644
index 77341af..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/OverrideCollection.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// OverrideCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:53 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class OverrideCollection : CollectionBase, IReflectionVisitable {
-
- MethodDefinition m_container;
-
- public MethodReference this [int index] {
- get { return List [index] as MethodReference; }
- set { List [index] = value; }
- }
-
- public MethodDefinition Container {
- get { return m_container; }
- }
-
- public OverrideCollection (MethodDefinition container)
- {
- m_container = container;
- }
-
- public void Add (MethodReference value)
- {
- List.Add (value);
- }
-
- public bool Contains (MethodReference value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (MethodReference value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, MethodReference value)
- {
- List.Insert (index, value);
- }
-
- public void Remove (MethodReference value)
- {
- List.Remove (value);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is MethodReference))
- throw new ArgumentException ("Must be of type " + typeof (MethodReference).FullName);
- }
-
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitOverrideCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeAttributes.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeAttributes.cs
index 30d3935..fc94692 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeAttributes.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeAttributes.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 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,9 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
- using System;
+namespace Mono.Cecil {
[Flags]
public enum PInvokeAttributes : ushort {
@@ -40,6 +40,7 @@ namespace Mono.Cecil {
CharSetAnsi = 0x0002,
CharSetUnicode = 0x0004,
CharSetAuto = 0x0006,
+
SupportsLastError = 0x0040, // Information about target function. Not relevant for fields
// Calling convetion
@@ -48,6 +49,14 @@ namespace Mono.Cecil {
CallConvCdecl = 0x0200,
CallConvStdCall = 0x0300,
CallConvThiscall = 0x0400,
- CallConvFastcall = 0x0500
+ CallConvFastcall = 0x0500,
+
+ BestFitMask = 0x0030,
+ BestFitEnabled = 0x0010,
+ BestFidDisabled = 0x0020,
+
+ ThrowOnUnmappableCharMask = 0x3000,
+ ThrowOnUnmappableCharEnabled = 0x1000,
+ ThrowOnUnmappableCharDisabled = 0x2000,
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeInfo.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeInfo.cs
index 40c1551..53aae2c 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeInfo.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PInvokeInfo.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,173 +28,111 @@
namespace Mono.Cecil {
- public sealed class PInvokeInfo : IReflectionVisitable {
+ public sealed class PInvokeInfo {
- MethodDefinition m_meth;
-
- PInvokeAttributes m_attributes;
- string m_entryPoint;
- ModuleReference m_module;
-
- public MethodDefinition Method {
- get { return m_meth; }
- }
+ ushort attributes;
+ string entry_point;
+ ModuleReference module;
public PInvokeAttributes Attributes {
- get { return m_attributes; }
- set { m_attributes = value; }
+ get { return (PInvokeAttributes) attributes; }
+ set { attributes = (ushort) value; }
}
public string EntryPoint {
- get { return m_entryPoint; }
- set { m_entryPoint = value; }
+ get { return entry_point; }
+ set { entry_point = value; }
}
public ModuleReference Module {
- get { return m_module; }
- set { m_module = value; }
+ get { return module; }
+ set { module = value; }
}
#region PInvokeAttributes
public bool IsNoMangle {
- get { return (m_attributes & PInvokeAttributes.NoMangle) != 0; }
- set {
- if (value)
- m_attributes |= PInvokeAttributes.NoMangle;
- else
- m_attributes &= ~PInvokeAttributes.NoMangle;
- }
+ get { return attributes.GetAttributes ((ushort) PInvokeAttributes.NoMangle); }
+ set { attributes = attributes.SetAttributes ((ushort) PInvokeAttributes.NoMangle, value); }
}
public bool IsCharSetNotSpec {
- get { return (m_attributes & PInvokeAttributes.CharSetMask) == PInvokeAttributes.CharSetNotSpec; }
- set {
- if (value) {
- m_attributes &= ~PInvokeAttributes.CharSetMask;
- m_attributes |= PInvokeAttributes.CharSetNotSpec;
- } else
- m_attributes &= ~(PInvokeAttributes.CharSetMask & PInvokeAttributes.CharSetNotSpec);
- }
+ get { return attributes.GetMaskedAttributes((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetNotSpec); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetNotSpec, value); }
}
public bool IsCharSetAnsi {
- get { return (m_attributes & PInvokeAttributes.CharSetMask) == PInvokeAttributes.CharSetAnsi; }
- set {
- if (value) {
- m_attributes &= ~PInvokeAttributes.CharSetMask;
- m_attributes |= PInvokeAttributes.CharSetAnsi;
- } else
- m_attributes &= ~(PInvokeAttributes.CharSetMask & PInvokeAttributes.CharSetAnsi);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAnsi); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAnsi, value); }
}
public bool IsCharSetUnicode {
- get { return (m_attributes & PInvokeAttributes.CharSetMask) == PInvokeAttributes.CharSetUnicode; }
- set {
- if (value) {
- m_attributes &= ~PInvokeAttributes.CharSetMask;
- m_attributes |= PInvokeAttributes.CharSetUnicode;
- } else
- m_attributes &= ~(PInvokeAttributes.CharSetMask & PInvokeAttributes.CharSetUnicode);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetUnicode); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetUnicode, value); }
}
public bool IsCharSetAuto {
- get { return (m_attributes & PInvokeAttributes.CharSetMask) == PInvokeAttributes.CharSetAuto; }
- set {
- if (value) {
- m_attributes &= ~PInvokeAttributes.CharSetMask;
- m_attributes |= PInvokeAttributes.CharSetAuto;
- } else
- m_attributes &= ~(PInvokeAttributes.CharSetMask & PInvokeAttributes.CharSetAuto);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAuto); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAuto, value); }
}
public bool SupportsLastError {
- get { return (m_attributes & PInvokeAttributes.CharSetMask) == PInvokeAttributes.SupportsLastError; }
- set {
- if (value) {
- m_attributes &= ~PInvokeAttributes.CharSetMask;
- m_attributes |= PInvokeAttributes.SupportsLastError;
- } else
- m_attributes &= ~(PInvokeAttributes.CharSetMask & PInvokeAttributes.SupportsLastError);
- }
+ get { return attributes.GetAttributes ((ushort) PInvokeAttributes.SupportsLastError); }
+ set { attributes = attributes.SetAttributes ((ushort) PInvokeAttributes.SupportsLastError, value); }
}
public bool IsCallConvWinapi {
- get { return (m_attributes & PInvokeAttributes.CallConvMask) == PInvokeAttributes.CallConvWinapi; }
- set {
- if (value) {
- m_attributes &= ~PInvokeAttributes.CallConvMask;
- m_attributes |= PInvokeAttributes.CallConvWinapi;
- } else
- m_attributes &= ~(PInvokeAttributes.CallConvMask & PInvokeAttributes.CallConvWinapi);
- }
+ get { return attributes.GetMaskedAttributes((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvWinapi); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvWinapi, value); }
}
public bool IsCallConvCdecl {
- get { return (m_attributes & PInvokeAttributes.CallConvMask) == PInvokeAttributes.CallConvCdecl; }
- set {
- if (value) {
- m_attributes &= ~PInvokeAttributes.CallConvMask;
- m_attributes |= PInvokeAttributes.CallConvCdecl;
- } else
- m_attributes &= ~(PInvokeAttributes.CallConvMask & PInvokeAttributes.CallConvCdecl);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvCdecl); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvCdecl, value); }
}
public bool IsCallConvStdCall {
- get { return (m_attributes & PInvokeAttributes.CallConvMask) == PInvokeAttributes.CallConvStdCall; }
- set {
- if (value) {
- m_attributes &= ~PInvokeAttributes.CallConvMask;
- m_attributes |= PInvokeAttributes.CallConvStdCall;
- } else
- m_attributes &= ~(PInvokeAttributes.CallConvMask & PInvokeAttributes.CallConvStdCall);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvStdCall); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvStdCall, value); }
}
public bool IsCallConvThiscall {
- get { return (m_attributes & PInvokeAttributes.CallConvMask) == PInvokeAttributes.CallConvThiscall; }
- set {
- if (value) {
- m_attributes &= ~PInvokeAttributes.CallConvMask;
- m_attributes |= PInvokeAttributes.CallConvThiscall;
- } else
- m_attributes &= ~(PInvokeAttributes.CallConvMask & PInvokeAttributes.CallConvThiscall);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvThiscall); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvThiscall, value); }
}
public bool IsCallConvFastcall {
- get { return (m_attributes & PInvokeAttributes.CallConvMask) == PInvokeAttributes.CallConvFastcall; }
- set {
- if (value) {
- m_attributes &= ~PInvokeAttributes.CallConvMask;
- m_attributes |= PInvokeAttributes.CallConvFastcall;
- } else
- m_attributes &= ~(PInvokeAttributes.CallConvMask & PInvokeAttributes.CallConvFastcall);
- }
+ get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvFastcall); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvFastcall, value); }
}
- #endregion
+ public bool IsBestFistEnabled {
+ get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitEnabled); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitEnabled, value); }
+ }
- public PInvokeInfo (MethodDefinition meth)
- {
- m_meth = meth;
+ 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 PInvokeInfo (MethodDefinition meth, PInvokeAttributes attrs,
- string entryPoint, ModuleReference mod) : this (meth)
- {
- m_attributes = attrs;
- m_entryPoint = entryPoint;
- m_module = mod;
+ public bool IsThrowOnUnmappableCharEnabled {
+ get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.ThrowOnUnmappableCharMask, (ushort) PInvokeAttributes.ThrowOnUnmappableCharEnabled); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.ThrowOnUnmappableCharMask, (ushort) PInvokeAttributes.ThrowOnUnmappableCharEnabled, value); }
+ }
+
+ public bool IsThrowOnUnmappableCharDisabled {
+ get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.ThrowOnUnmappableCharMask, (ushort) PInvokeAttributes.ThrowOnUnmappableCharDisabled); }
+ set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.ThrowOnUnmappableCharMask, (ushort) PInvokeAttributes.ThrowOnUnmappableCharDisabled, value); }
}
- public void Accept (IReflectionVisitor visitor)
+ #endregion
+
+ public PInvokeInfo (PInvokeAttributes attributes, string entryPoint, ModuleReference module)
{
- visitor.VisitPInvokeInfo (this);
+ this.attributes = (ushort) attributes;
+ this.entry_point = entryPoint;
+ this.module = module;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterAttributes.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterAttributes.cs
index d112209..8f8d1d5 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterAttributes.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterAttributes.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 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,9 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
- using System;
+namespace Mono.Cecil {
[Flags]
public enum ParameterAttributes : ushort {
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinition.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinition.cs
index 5aef109..2e73a07 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinition.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinition.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 - 2007 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,150 +26,122 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using Mono.Collections.Generic;
- public sealed class ParameterDefinition : ParameterReference, IHasMarshalSpec,
- IMetadataTokenProvider, ICustomAttributeProvider, IHasConstant {
+namespace Mono.Cecil {
- ParameterAttributes m_attributes;
+ public sealed class ParameterDefinition : ParameterReference, ICustomAttributeProvider, IConstantProvider, IMarshalInfoProvider {
- bool m_hasConstant;
- object m_const;
+ ushort attributes;
- MethodReference m_method;
- CustomAttributeCollection m_customAttrs;
+ internal IMethodSignature method;
- MarshalSpec m_marshalDesc;
+ object constant = Mixin.NotResolved;
+ Collection<CustomAttribute> custom_attributes;
+ MarshalInfo marshal_info;
public ParameterAttributes Attributes {
- get { return m_attributes; }
- set { m_attributes = value; }
+ get { return (ParameterAttributes) attributes; }
+ set { attributes = (ushort) value; }
+ }
+
+ public IMethodSignature Method {
+ get { return method; }
}
public bool HasConstant {
- get { return m_hasConstant; }
+ get {
+ ResolveConstant ();
+
+ return constant != Mixin.NoValue;
+ }
+ set { if (!value) constant = Mixin.NoValue; }
}
public object Constant {
- get { return m_const; }
- set {
- m_hasConstant = true;
- m_const = value;
- }
+ get { return HasConstant ? constant : null; }
+ set { constant = value; }
}
- public MethodReference Method {
- get { return m_method; }
- set { m_method = value; }
+ void ResolveConstant ()
+ {
+ if (constant != Mixin.NotResolved)
+ return;
+
+ this.ResolveConstant (ref constant, parameter_type.Module);
}
- public CustomAttributeCollection CustomAttributes {
+ public bool HasCustomAttributes {
get {
- if (m_customAttrs == null)
- m_customAttrs = new CustomAttributeCollection (this);
+ if (custom_attributes != null)
+ return custom_attributes.Count > 0;
- return m_customAttrs;
+ return this.GetHasCustomAttributes (parameter_type.Module);
}
}
- public MarshalSpec MarshalSpec {
- get { return m_marshalDesc; }
- set {
- m_marshalDesc = value;
- if (value != null)
- m_attributes |= ParameterAttributes.HasFieldMarshal;
- else
- m_attributes &= ~ParameterAttributes.HasFieldMarshal;
+ public Collection<CustomAttribute> CustomAttributes {
+ get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (parameter_type.Module)); }
+ }
+
+ public bool HasMarshalInfo {
+ get {
+ if (marshal_info != null)
+ return true;
+
+ return this.GetHasMarshalInfo (parameter_type.Module);
}
}
+ public MarshalInfo MarshalInfo {
+ get { return marshal_info ?? (marshal_info = this.GetMarshalInfo (parameter_type.Module)); }
+ set { marshal_info = value; }
+ }
+
#region ParameterAttributes
public bool IsIn {
- get { return (m_attributes & ParameterAttributes.In) != 0; }
- set {
- if (value)
- m_attributes |= ParameterAttributes.In;
- else
- m_attributes &= ~ParameterAttributes.In;
- }
+ get { return attributes.GetAttributes ((ushort) ParameterAttributes.In); }
+ set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.In, value); }
}
public bool IsOut {
- get { return (m_attributes & ParameterAttributes.Out) != 0; }
- set {
- if (value)
- m_attributes |= ParameterAttributes.Out;
- else
- m_attributes &= ~ParameterAttributes.Out;
- }
+ get { return attributes.GetAttributes ((ushort) ParameterAttributes.Out); }
+ set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.Out, value); }
}
public bool IsOptional {
- get { return (m_attributes & ParameterAttributes.Optional) != 0; }
- set {
- if (value)
- m_attributes |= ParameterAttributes.Optional;
- else
- m_attributes &= ~ParameterAttributes.Optional;
- }
+ get { return attributes.GetAttributes ((ushort) ParameterAttributes.Optional); }
+ set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.Optional, value); }
}
public bool HasDefault {
- get { return (m_attributes & ParameterAttributes.HasDefault) != 0; }
- set {
- if (value)
- m_attributes |= ParameterAttributes.HasDefault;
- else
- m_attributes &= ~ParameterAttributes.HasDefault;
- }
+ get { return attributes.GetAttributes ((ushort) ParameterAttributes.HasDefault); }
+ set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.HasDefault, value); }
}
- #endregion
-
- public ParameterDefinition (TypeReference paramType) :
- this (string.Empty, -1, (ParameterAttributes) 0, paramType)
- {
+ public bool HasFieldMarshal {
+ get { return attributes.GetAttributes ((ushort) ParameterAttributes.HasFieldMarshal); }
+ set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.HasFieldMarshal, value); }
}
- public ParameterDefinition (string name, int seq, ParameterAttributes attrs, TypeReference paramType) : base (name, seq, paramType)
- {
- m_attributes = attrs;
- }
+ #endregion
- public ParameterDefinition Clone ()
+ public ParameterDefinition (TypeReference parameterType)
+ : this (string.Empty, ParameterAttributes.None, parameterType)
{
- return Clone (this, new ImportContext (NullReferenceImporter.Instance, m_method));
}
- internal static ParameterDefinition Clone (ParameterDefinition param, ImportContext context)
+ public ParameterDefinition (string name, ParameterAttributes attributes, TypeReference parameterType)
+ : base (name, parameterType)
{
- ParameterDefinition np = new ParameterDefinition (
- param.Name,
- param.Sequence,
- param.Attributes,
- context.Import (param.ParameterType));
-
- if (param.HasConstant)
- np.Constant = param.Constant;
-
- if (param.MarshalSpec != null)
- np.MarshalSpec = param.MarshalSpec;
-
- foreach (CustomAttribute ca in param.CustomAttributes)
- np.CustomAttributes.Add (CustomAttribute.Clone (ca, context));
-
- return np;
+ this.attributes = (ushort) attributes;
+ this.token = new MetadataToken (TokenType.Param);
}
- public override void Accept (IReflectionVisitor visitor)
+ public override ParameterDefinition Resolve ()
{
- visitor.VisitParameterDefinition (this);
-
- if (this.MarshalSpec != null)
- this.MarshalSpec.Accept (visitor);
-
- this.CustomAttributes.Accept (visitor);
+ return this;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinitionCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinitionCollection.cs
index 5fa2229..86538bb 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinitionCollection.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterDefinitionCollection.cs
@@ -4,10 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:52 CEST 2006
-//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -29,65 +26,55 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
+using System;
- using Mono.Cecil.Cil;
+using Mono.Collections.Generic;
- public sealed class ParameterDefinitionCollection : CollectionBase, IReflectionVisitable {
+namespace Mono.Cecil {
- IMemberReference m_container;
+ sealed class ParameterDefinitionCollection : Collection<ParameterDefinition> {
- public ParameterDefinition this [int index] {
- get { return List [index] as ParameterDefinition; }
- set { List [index] = value; }
- }
+ readonly IMethodSignature method;
- public IMemberReference Container {
- get { return m_container; }
- }
-
- public ParameterDefinitionCollection (IMemberReference container)
+ internal ParameterDefinitionCollection (IMethodSignature method)
{
- m_container = container;
+ this.method = method;
}
- public void Add (ParameterDefinition value)
+ internal ParameterDefinitionCollection (IMethodSignature method, int capacity)
+ : base (capacity)
{
- List.Add (value);
+ this.method = method;
}
- public bool Contains (ParameterDefinition value)
+ protected override void OnAdd (ParameterDefinition item, int index)
{
- return List.Contains (value);
+ item.method = method;
+ item.index = index;
}
- public int IndexOf (ParameterDefinition value)
+ protected override void OnInsert (ParameterDefinition item, int index)
{
- return List.IndexOf (value);
- }
+ item.method = method;
+ item.index = index;
- public void Insert (int index, ParameterDefinition value)
- {
- List.Insert (index, value);
+ for (int i = index; i < size; i++)
+ items [i].index = i + 1;
}
- public void Remove (ParameterDefinition value)
+ protected override void OnSet (ParameterDefinition item, int index)
{
- List.Remove (value);
+ item.method = method;
+ item.index = index;
}
- protected override void OnValidate (object o)
+ protected override void OnRemove (ParameterDefinition item, int index)
{
- if (! (o is ParameterDefinition))
- throw new ArgumentException ("Must be of type " + typeof (ParameterDefinition).FullName);
- }
+ item.method = null;
+ item.index = -1;
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitParameterDefinitionCollection (this);
+ for (int i = index + 1; i < size; i++)
+ items [i].index = i - 1;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterReference.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterReference.cs
index f7bda3e..cfe648f 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterReference.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ParameterReference.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,63 +26,50 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
-
- using System.Collections;
+using System;
- using Mono.Cecil.Metadata;
+namespace Mono.Cecil {
- public abstract class ParameterReference : IMetadataTokenProvider, IAnnotationProvider, IReflectionVisitable {
+ public abstract class ParameterReference : IMetadataTokenProvider {
- string m_name;
- int m_sequence;
- TypeReference m_paramType;
- MetadataToken m_token;
- IDictionary m_annotations;
+ string name;
+ internal int index = -1;
+ protected TypeReference parameter_type;
+ internal MetadataToken token;
public string Name {
- get { return m_name; }
- set { m_name = value; }
+ get { return name; }
+ set { name = value; }
}
- public int Sequence {
- get { return m_sequence; }
- set { m_sequence = value; }
+ public int Index {
+ get { return index; }
}
public TypeReference ParameterType {
- get { return m_paramType; }
- set { m_paramType = value; }
+ get { return parameter_type; }
+ set { parameter_type = value; }
}
public MetadataToken MetadataToken {
- get { return m_token; }
- set { m_token = value; }
+ get { return token; }
+ set { token = value; }
}
- IDictionary IAnnotationProvider.Annotations {
- get {
- if (m_annotations == null)
- m_annotations = new Hashtable ();
- return m_annotations;
- }
- }
-
- public ParameterReference (string name, int sequence, TypeReference parameterType)
+ internal ParameterReference (string name, TypeReference parameterType)
{
- m_name = name;
- m_sequence = sequence;
- m_paramType = parameterType;
+ if (parameterType == null)
+ throw new ArgumentNullException ("parameterType");
+
+ this.name = name ?? string.Empty;
+ this.parameter_type = parameterType;
}
public override string ToString ()
{
- if (m_name != null && m_name.Length > 0)
- return m_name;
-
- return string.Concat ("A_", m_sequence);
+ return name;
}
- public abstract void Accept (IReflectionVisitor visitor);
+ public abstract ParameterDefinition Resolve ();
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PinnedType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PinnedType.cs
index f62a6bd..d5e7a80 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PinnedType.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PinnedType.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,12 +26,28 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
+using MD = Mono.Cecil.Metadata;
+
namespace Mono.Cecil {
public sealed class PinnedType : TypeSpecification {
- public PinnedType (TypeReference pType) : base (pType)
+ public override bool IsValueType {
+ get { return false; }
+ set { throw new InvalidOperationException (); }
+ }
+
+ public override bool IsPinned {
+ get { return true; }
+ }
+
+ public PinnedType (TypeReference type)
+ : base (type)
{
+ Mixin.CheckType (type);
+ this.etype = MD.ElementType.Pinned;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PointerType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PointerType.cs
index 1228733..54ab775 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PointerType.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PointerType.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,20 +26,36 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
+using MD = Mono.Cecil.Metadata;
+
namespace Mono.Cecil {
public sealed class PointerType : TypeSpecification {
public override string Name {
- get { return string.Concat (base.Name, "*"); }
+ get { return base.Name + "*"; }
}
public override string FullName {
- get { return string.Concat (base.FullName, "*"); }
+ get { return base.FullName + "*"; }
+ }
+
+ public override bool IsValueType {
+ get { return false; }
+ set { throw new InvalidOperationException (); }
+ }
+
+ public override bool IsPointer {
+ get { return true; }
}
- public PointerType (TypeReference pType) : base (pType)
+ public PointerType (TypeReference type)
+ : base (type)
{
+ Mixin.CheckType (type);
+ this.etype = MD.ElementType.Ptr;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyAttributes.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyAttributes.cs
index f11468f..ad6fd9e 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyAttributes.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyAttributes.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,12 +26,13 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
- using System;
+namespace Mono.Cecil {
[Flags]
public enum PropertyAttributes : ushort {
+ None = 0x0000,
SpecialName = 0x0200, // Property is special
RTSpecialName = 0x0400, // Runtime(metadata internal APIs) should check name encoding
HasDefault = 0x1000, // Property has default
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinition.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinition.cs
index 23086e8..835a929 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinition.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinition.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,200 +26,233 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System.Text;
+
+using Mono.Collections.Generic;
- using System;
- using System.Text;
+namespace Mono.Cecil {
- public sealed class PropertyDefinition : PropertyReference,
- IMemberDefinition, ICustomAttributeProvider, IHasConstant {
+ public sealed class PropertyDefinition : PropertyReference, IMemberDefinition, IConstantProvider {
- PropertyAttributes m_attributes;
+ bool? has_this;
+ ushort attributes;
- CustomAttributeCollection m_customAttrs;
+ Collection<CustomAttribute> custom_attributes;
- MethodDefinition m_getMeth;
- MethodDefinition m_setMeth;
+ internal MethodDefinition get_method;
+ internal MethodDefinition set_method;
+ internal Collection<MethodDefinition> other_methods;
- bool m_hasConstant;
- object m_const;
+ object constant = Mixin.NotResolved;
public PropertyAttributes Attributes {
- get { return m_attributes; }
- set { m_attributes = value; }
+ get { return (PropertyAttributes) attributes; }
+ set { attributes = (ushort) value; }
}
- public CustomAttributeCollection CustomAttributes {
+ public bool HasThis {
get {
- if (m_customAttrs == null)
- m_customAttrs = new CustomAttributeCollection (this);
+ if (has_this.HasValue)
+ return has_this.Value;
+
+ if (GetMethod != null)
+ return get_method.HasThis;
+
+ if (SetMethod != null)
+ return set_method.HasThis;
- return m_customAttrs;
+ return false;
}
+ set { has_this = value; }
}
- public override ParameterDefinitionCollection Parameters {
+ public bool HasCustomAttributes {
get {
- if (this.GetMethod != null)
- return CloneParameterCollection (this.GetMethod.Parameters);
- else if (this.SetMethod != null) {
- ParameterDefinitionCollection parameters =
- CloneParameterCollection (this.SetMethod.Parameters);
- if (parameters.Count > 0)
- parameters.RemoveAt (parameters.Count - 1);
- return parameters;
- }
-
- if (m_parameters == null)
- m_parameters = new ParameterDefinitionCollection (this);
+ if (custom_attributes != null)
+ return custom_attributes.Count > 0;
- return m_parameters;
+ return this.GetHasCustomAttributes (Module);
}
}
+ public Collection<CustomAttribute> CustomAttributes {
+ get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); }
+ }
+
public MethodDefinition GetMethod {
- get { return m_getMeth; }
- set { m_getMeth = value; }
+ get {
+ if (get_method != null)
+ return get_method;
+
+ InitializeMethods ();
+ return get_method;
+ }
+ set { get_method = value; }
}
public MethodDefinition SetMethod {
- get { return m_setMeth; }
- set { m_setMeth = value; }
- }
+ get {
+ if (set_method != null)
+ return set_method;
- ParameterDefinitionCollection CloneParameterCollection (ParameterDefinitionCollection original)
- {
- ParameterDefinitionCollection clone = new ParameterDefinitionCollection (
- original.Container);
- foreach (ParameterDefinition param in original)
- clone.Add (param);
- return clone;
+ InitializeMethods ();
+ return set_method;
+ }
+ set { set_method = value; }
}
- public bool HasConstant {
- get { return m_hasConstant; }
- }
+ public bool HasOtherMethods {
+ get {
+ if (other_methods != null)
+ return other_methods.Count > 0;
- public object Constant {
- get { return m_const; }
- set {
- m_hasConstant = true;
- m_const = value;
+ InitializeMethods ();
+ return !other_methods.IsNullOrEmpty ();
}
}
- #region PropertyAttributes
+ public Collection<MethodDefinition> OtherMethods {
+ get {
+ if (other_methods != null)
+ return other_methods;
- public bool IsSpecialName {
- get { return (m_attributes & PropertyAttributes.SpecialName) != 0; }
- set {
- if (value)
- m_attributes |= PropertyAttributes.SpecialName;
- else
- m_attributes &= ~PropertyAttributes.SpecialName;
+ InitializeMethods ();
+
+ if (other_methods != null)
+ return other_methods;
+
+ return other_methods = new Collection<MethodDefinition> ();
}
}
- public bool IsRuntimeSpecialName {
- get { return (m_attributes & PropertyAttributes.RTSpecialName) != 0; }
- set {
- if (value)
- m_attributes |= PropertyAttributes.RTSpecialName;
- else
- m_attributes &= ~PropertyAttributes.RTSpecialName;
+ public bool HasParameters {
+ get {
+ if (get_method != null)
+ return get_method.HasParameters;
+
+ if (set_method != null)
+ return set_method.HasParameters && set_method.Parameters.Count > 1;
+
+ return false;
}
}
- public bool HasDefault {
- get { return (m_attributes & PropertyAttributes.HasDefault) != 0; }
- set {
- if (value)
- m_attributes |= PropertyAttributes.HasDefault;
- else
- m_attributes &= ~PropertyAttributes.HasDefault;
+ public override Collection<ParameterDefinition> Parameters {
+ get {
+ InitializeMethods ();
+
+ if (get_method != null)
+ return MirrorParameters (get_method, 0);
+
+ if (set_method != null)
+ return MirrorParameters (set_method, 1);
+
+ return new Collection<ParameterDefinition> ();
}
}
- #endregion
-
- public PropertyDefinition (string name, TypeReference propertyType, PropertyAttributes attrs) : base (name, propertyType)
+ static Collection<ParameterDefinition> MirrorParameters (MethodDefinition method, int bound)
{
- m_attributes = attrs;
+ var parameters = new Collection<ParameterDefinition> ();
+ if (!method.HasParameters)
+ return parameters;
+
+ var original_parameters = method.Parameters;
+ var end = original_parameters.Count - bound;
+
+ for (int i = 0; i < end; i++)
+ parameters.Add (original_parameters [i]);
+
+ return parameters;
}
- public static MethodDefinition CreateGetMethod (PropertyDefinition prop)
- {
- MethodDefinition get = new MethodDefinition (
- string.Concat ("get_", prop.Name), (MethodAttributes) 0, prop.PropertyType);
- prop.GetMethod = get;
- return get;
+ public bool HasConstant {
+ get {
+ ResolveConstant ();
+
+ return constant != Mixin.NoValue;
+ }
+ set { if (!value) constant = Mixin.NoValue; }
}
- public static MethodDefinition CreateSetMethod (PropertyDefinition prop)
- {
- MethodDefinition set = new MethodDefinition (
- string.Concat ("set_", prop.Name), (MethodAttributes) 0, prop.PropertyType);
- prop.SetMethod = set;
- return set;
+ public object Constant {
+ get { return HasConstant ? constant : null; }
+ set { constant = value; }
}
- public PropertyDefinition Clone ()
+ void ResolveConstant ()
{
- return Clone (this, new ImportContext (NullReferenceImporter.Instance, this.DeclaringType));
+ if (constant != Mixin.NotResolved)
+ return;
+
+ this.ResolveConstant (ref constant, Module);
}
- internal static PropertyDefinition Clone (PropertyDefinition prop, ImportContext context)
- {
- PropertyDefinition np = new PropertyDefinition (
- prop.Name,
- context.Import (prop.PropertyType),
- prop.Attributes);
-
- if (prop.HasConstant)
- np.Constant = prop.Constant;
-
- if (context.GenericContext.Type is TypeDefinition) {
- TypeDefinition type = context.GenericContext.Type as TypeDefinition;
- if (prop.SetMethod != null)
- np.SetMethod = type.Methods.GetMethod (prop.SetMethod.Name, prop.SetMethod.Parameters);
- if (prop.GetMethod != null)
- np.GetMethod = type.Methods.GetMethod (prop.GetMethod.Name, prop.GetMethod.Parameters);
- }
+ #region PropertyAttributes
+
+ public bool IsSpecialName {
+ get { return attributes.GetAttributes ((ushort) PropertyAttributes.SpecialName); }
+ set { attributes = attributes.SetAttributes ((ushort) PropertyAttributes.SpecialName, value); }
+ }
- foreach (CustomAttribute ca in prop.CustomAttributes)
- np.CustomAttributes.Add (CustomAttribute.Clone (ca, context));
+ public bool IsRuntimeSpecialName {
+ get { return attributes.GetAttributes ((ushort) PropertyAttributes.RTSpecialName); }
+ set { attributes = attributes.SetAttributes ((ushort) PropertyAttributes.RTSpecialName, value); }
+ }
- return np;
+ public bool HasDefault {
+ get { return attributes.GetAttributes ((ushort) PropertyAttributes.HasDefault); }
+ set { attributes = attributes.SetAttributes ((ushort) PropertyAttributes.HasDefault, value); }
}
- public override string ToString ()
- {
- StringBuilder sb = new StringBuilder ();
- sb.Append (PropertyType.ToString ());
- sb.Append (' ');
+ #endregion
- if (this.DeclaringType != null) {
- sb.Append (this.DeclaringType.ToString ());
- sb.Append ("::");
- }
+ public new TypeDefinition DeclaringType {
+ get { return (TypeDefinition) base.DeclaringType; }
+ set { base.DeclaringType = value; }
+ }
- sb.Append (this.Name);
- sb.Append ('(');
- ParameterDefinitionCollection parameters = this.Parameters;
- for (int i = 0; i < parameters.Count; i++) {
- if (i > 0)
- sb.Append (',');
- sb.Append (parameters [i].ParameterType.ToString ());
+ public override bool IsDefinition {
+ get { return true; }
+ }
+
+ public override string FullName {
+ get {
+ var builder = new StringBuilder ();
+ builder.Append (PropertyType.ToString ());
+ builder.Append (' ');
+ builder.Append (MemberFullName ());
+ builder.Append ('(');
+ if (HasParameters) {
+ var parameters = Parameters;
+ for (int i = 0; i < parameters.Count; i++) {
+ if (i > 0)
+ builder.Append (',');
+ builder.Append (parameters [i].ParameterType.FullName);
+ }
+ }
+ builder.Append (')');
+ return builder.ToString ();
}
- sb.Append (')');
- return sb.ToString ();
}
- public override void Accept (IReflectionVisitor visitor)
+ public PropertyDefinition (string name, PropertyAttributes attributes, TypeReference propertyType)
+ : base (name, propertyType)
{
- visitor.VisitPropertyDefinition (this);
+ this.attributes = (ushort) attributes;
+ this.token = new MetadataToken (TokenType.Property);
+ }
+
+ void InitializeMethods ()
+ {
+ if (get_method != null || set_method != null)
+ return;
+
+ var module = this.Module;
+ if (!module.HasImage ())
+ return;
- this.CustomAttributes.Accept (visitor);
+ module.Read (this, (property, reader) => reader.ReadMethods (property));
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinitionCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinitionCollection.cs
deleted file mode 100644
index 7860b6c..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyDefinitionCollection.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-//
-// PropertyDefinitionCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Fri Mar 30 18:43:57 +0200 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class PropertyDefinitionCollection : CollectionBase, IReflectionVisitable {
-
- TypeDefinition m_container;
-
- public PropertyDefinition this [int index] {
- get { return List [index] as PropertyDefinition; }
- set { List [index] = value; }
- }
-
- public TypeDefinition Container {
- get { return m_container; }
- }
-
- public PropertyDefinitionCollection (TypeDefinition container)
- {
- m_container = container;
- }
-
- public void Add (PropertyDefinition value)
- {
- Attach (value);
-
- List.Add (value);
- }
-
-
- public new void Clear ()
- {
- foreach (PropertyDefinition item in this)
- Detach (item);
-
- base.Clear ();
- }
-
- public bool Contains (PropertyDefinition value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (PropertyDefinition value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, PropertyDefinition value)
- {
- Attach (value);
-
- List.Insert (index, value);
- }
-
- public void Remove (PropertyDefinition value)
- {
- List.Remove (value);
-
- Detach (value);
- }
-
-
- public new void RemoveAt (int index)
- {
- PropertyDefinition item = this [index];
- Remove (item);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is PropertyDefinition))
- throw new ArgumentException ("Must be of type " + typeof (PropertyDefinition).FullName);
- }
-
- public PropertyDefinition [] GetProperties (string name)
- {
- ArrayList ret = new ArrayList ();
- foreach (PropertyDefinition prop in this)
- if (prop.Name == name)
- ret.Add (prop);
-
- return ret.ToArray (typeof (PropertyDefinition)) as PropertyDefinition [];
- }
-
- void Attach (MemberReference member)
- {
- if (member.DeclaringType != null)
- throw new ReflectionException ("Member already attached, clone it instead");
-
- member.DeclaringType = m_container;
- }
-
- void Detach (MemberReference member)
- {
- member.DeclaringType = null;
- }
-
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitPropertyDefinitionCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyReference.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyReference.cs
index 20112b6..5022cd3 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyReference.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/PropertyReference.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,25 +26,32 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
+using Mono.Collections.Generic;
+
namespace Mono.Cecil {
public abstract class PropertyReference : MemberReference {
- TypeReference m_propertyType;
- protected ParameterDefinitionCollection m_parameters;
+ TypeReference property_type;
public TypeReference PropertyType {
- get { return m_propertyType; }
- set { m_propertyType = value; }
+ get { return property_type; }
+ set { property_type = value; }
}
- public abstract ParameterDefinitionCollection Parameters {
+ public abstract Collection<ParameterDefinition> Parameters {
get;
}
- public PropertyReference (string name, TypeReference propertyType) : base (name)
+ internal PropertyReference (string name, TypeReference propertyType)
+ : base (name)
{
- m_propertyType = propertyType;
+ if (propertyType == null)
+ throw new ArgumentNullException ("propertyType");
+
+ property_type = propertyType;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReferenceType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReferenceType.cs
index 6d1e0e8..3a6b326 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReferenceType.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReferenceType.cs
@@ -1,10 +1,10 @@
//
-// ReferenceType.cs
+// ByReferenceType.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,20 +26,36 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
+using MD = Mono.Cecil.Metadata;
+
namespace Mono.Cecil {
- public sealed class ReferenceType : TypeSpecification {
+ public sealed class ByReferenceType : TypeSpecification {
public override string Name {
- get { return string.Concat (base.Name, "&"); }
+ get { return base.Name + "&"; }
}
public override string FullName {
- get { return string.Concat (base.FullName, "&"); }
+ get { return base.FullName + "&"; }
+ }
+
+ public override bool IsValueType {
+ get { return false; }
+ set { throw new InvalidOperationException (); }
+ }
+
+ public override bool IsByReference {
+ get { return true; }
}
- public ReferenceType (TypeReference type) : base (type)
+ public ByReferenceType (TypeReference type)
+ : base (type)
{
+ Mixin.CheckType (type);
+ this.etype = MD.ElementType.ByRef;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionController.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionController.cs
deleted file mode 100644
index 22fdab1..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionController.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-//
-// ReflectionController.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- internal sealed class ReflectionController {
-
- ReflectionReader m_reader;
- ReflectionWriter m_writer;
- ReflectionHelper m_helper;
- DefaultImporter m_importer;
-
- public ReflectionReader Reader {
- get { return m_reader; }
- }
-
- public ReflectionWriter Writer {
- get { return m_writer; }
- }
-
- public ReflectionHelper Helper {
- get { return m_helper; }
- }
-
- public IImporter Importer {
- get { return m_importer; }
- }
-
- public ReflectionController (ModuleDefinition module)
- {
- m_reader = new AggressiveReflectionReader (module);
- m_writer = new ReflectionWriter (module);
- m_helper = new ReflectionHelper (module);
- m_importer = new DefaultImporter (module);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionHelper.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionHelper.cs
deleted file mode 100644
index d3e2a87..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionHelper.cs
+++ /dev/null
@@ -1,395 +0,0 @@
-//
-// ReflectionHelper.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-// (C) 2006 Evaluant RC S.A.
-// (C) 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
- using SR = System.Reflection;
- using System.Text;
-
- internal sealed class ReflectionHelper {
-
- ModuleDefinition m_module;
-
- public ReflectionHelper (ModuleDefinition module)
- {
- m_module = module;
- }
-
- public AssemblyNameReference ImportAssembly (SR.Assembly asm)
- {
- AssemblyNameReference asmRef = GetAssemblyNameReference (asm.GetName ());
- if (asmRef != null)
- return asmRef;
-
- SR.AssemblyName asmName = asm.GetName ();
- asmRef = new AssemblyNameReference (
- asmName.Name, asmName.CultureInfo.Name, asmName.Version);
- asmRef.PublicKeyToken = asmName.GetPublicKeyToken ();
- asmRef.HashAlgorithm = (AssemblyHashAlgorithm) asmName.HashAlgorithm;
- asmRef.Culture = asmName.CultureInfo.ToString ();
- m_module.AssemblyReferences.Add (asmRef);
- return asmRef;
- }
-
- AssemblyNameReference GetAssemblyNameReference (SR.AssemblyName name)
- {
- foreach (AssemblyNameReference reference in m_module.AssemblyReferences)
- if (reference.FullName == name.FullName)
- return reference;
-
- return null;
- }
-
- public static string GetTypeSignature (Type t)
- {
- if (t.HasElementType) {
- if (t.IsPointer)
- return string.Concat (GetTypeSignature (t.GetElementType ()), "*");
- else if (t.IsArray) // deal with complex arrays
- return string.Concat (GetTypeSignature (t.GetElementType ()), "[]");
- else if (t.IsByRef)
- return string.Concat (GetTypeSignature (t.GetElementType ()), "&");
- }
-
- if (IsGenericTypeSpec (t)) {
- StringBuilder sb = new StringBuilder ();
- sb.Append (GetTypeSignature (GetGenericTypeDefinition (t)));
- sb.Append ("<");
- Type [] genArgs = GetGenericArguments (t);
- for (int i = 0; i < genArgs.Length; i++) {
- if (i > 0)
- sb.Append (",");
- sb.Append (GetTypeSignature (genArgs [i]));
- }
- sb.Append (">");
- return sb.ToString ();
- }
-
- if (IsGenericParameter (t))
- return t.Name;
-
- if (t.DeclaringType != null)
- return string.Concat (t.DeclaringType.FullName, "/", t.Name);
-
- if (t.Namespace == null || t.Namespace.Length == 0)
- return t.Name;
-
- return string.Concat (t.Namespace, ".", t.Name);
- }
-
- static bool GetProperty (object o, string prop)
- {
- SR.PropertyInfo pi = o.GetType ().GetProperty (prop);
- if (pi == null)
- return false;
-
- return (bool) pi.GetValue (o, null);
- }
-
- public static bool IsGenericType (Type t)
- {
- return GetProperty (t, "IsGenericType");
- }
-
- static bool IsGenericParameter (Type t)
- {
- return GetProperty (t, "IsGenericParameter");
- }
-
- static bool IsGenericTypeDefinition (Type t)
- {
- return GetProperty (t, "IsGenericTypeDefinition");
- }
-
- static bool IsGenericTypeSpec (Type t)
- {
- return IsGenericType (t) && !IsGenericTypeDefinition (t);
- }
-
- static Type GetGenericTypeDefinition (Type t)
- {
- return (Type) t.GetType ().GetMethod ("GetGenericTypeDefinition").Invoke (t, null);
- }
-
- static Type [] GetGenericArguments (Type t)
- {
- return (Type []) t.GetType ().GetMethod ("GetGenericArguments").Invoke (t, null);
- }
-
- GenericInstanceType GetGenericType (Type t, TypeReference element, ImportContext context)
- {
- GenericInstanceType git = new GenericInstanceType (element);
- foreach (Type genArg in GetGenericArguments (t))
- git.GenericArguments.Add (ImportSystemType (genArg, context));
-
- return git;
- }
-
- static bool GenericParameterOfMethod (Type t)
- {
- return t.GetType ().GetProperty ("DeclaringMethod").GetValue (t, null) != null;
- }
-
- static GenericParameter GetGenericParameter (Type t, ImportContext context)
- {
- int pos = (int) t.GetType ().GetProperty ("GenericParameterPosition").GetValue (t, null);
- if (GenericParameterOfMethod (t))
- return context.GenericContext.Method.GenericParameters [pos];
- else
- return context.GenericContext.Type.GenericParameters [pos];
- }
-
- TypeReference GetTypeSpec (Type t, ImportContext context)
- {
- Stack s = new Stack ();
- while (t.HasElementType || IsGenericTypeSpec (t)) {
- s.Push (t);
- if (t.HasElementType)
- t = t.GetElementType ();
- else if (IsGenericTypeSpec (t)) {
- t = (Type) t.GetType ().GetMethod ("GetGenericTypeDefinition").Invoke (t, null);
- break;
- }
- }
-
- TypeReference elementType = ImportSystemType (t, context);
- while (s.Count > 0) {
- t = (Type) s.Pop ();
- if (t.IsPointer)
- elementType = new PointerType (elementType);
- else if (t.IsArray) // deal with complex arrays
- elementType = new ArrayType (elementType);
- else if (t.IsByRef)
- elementType = new ReferenceType (elementType);
- else if (IsGenericTypeSpec (t))
- elementType = GetGenericType (t, elementType, context);
- else
- throw new ReflectionException ("Unknown element type");
- }
-
- return elementType;
- }
-
- public TypeReference ImportSystemType (Type t, ImportContext context)
- {
- if (t.HasElementType || IsGenericTypeSpec (t))
- return GetTypeSpec (t, context);
-
- if (IsGenericParameter (t))
- return GetGenericParameter (t, context);
-
- TypeReference type = m_module.TypeReferences [GetTypeSignature (t)];
- if (type != null) {
- if (t.IsValueType && !type.IsValueType)
- type.IsValueType = true;
-
- return type;
- }
-
- AssemblyNameReference asm = ImportAssembly (t.Assembly);
- type = new TypeReference (t.Name, t.Namespace, asm, t.IsValueType);
-
- if (IsGenericTypeDefinition (t))
- foreach (Type genParam in GetGenericArguments (t))
- type.GenericParameters.Add (new GenericParameter (genParam.Name, type));
-
- context.GenericContext.Type = type;
-
- m_module.TypeReferences.Add (type);
- return type;
- }
-
- static string GetMethodBaseSignature (SR.MethodBase meth, Type declaringType, Type retType)
- {
- StringBuilder sb = new StringBuilder ();
- sb.Append (GetTypeSignature (retType));
- sb.Append (' ');
- sb.Append (GetTypeSignature (declaringType));
- sb.Append ("::");
- sb.Append (meth.Name);
- if (IsGenericMethodSpec (meth)) {
- sb.Append ("<");
- Type [] genArgs = GetGenericArguments (meth as SR.MethodInfo);
- for (int i = 0; i < genArgs.Length; i++) {
- if (i > 0)
- sb.Append (",");
- sb.Append (GetTypeSignature (genArgs [i]));
- }
- sb.Append (">");
- }
- sb.Append ("(");
- SR.ParameterInfo [] parameters = meth.GetParameters ();
- for (int i = 0; i < parameters.Length; i++) {
- if (i > 0)
- sb.Append (", ");
- sb.Append (GetTypeSignature (parameters [i].ParameterType));
- }
- sb.Append (")");
- return sb.ToString ();
- }
-
- static bool IsGenericMethod (SR.MethodBase mb)
- {
- return GetProperty (mb, "IsGenericMethod");
- }
-
- static bool IsGenericMethodDefinition (SR.MethodBase mb)
- {
- return GetProperty (mb, "IsGenericMethodDefinition");
- }
-
- static bool IsGenericMethodSpec (SR.MethodBase mb)
- {
- return IsGenericMethod (mb) && !IsGenericMethodDefinition (mb);
- }
-
- static Type [] GetGenericArguments (SR.MethodInfo mi)
- {
- return (Type []) mi.GetType ().GetMethod ("GetGenericArguments").Invoke (mi, null);
- }
-
- static int GetMetadataToken (SR.MethodInfo mi)
- {
- return (int) mi.GetType ().GetProperty ("MetadataToken").GetValue (mi, null);
- }
-
- MethodReference ImportGenericInstanceMethod (SR.MethodInfo mi, ImportContext context)
- {
- SR.MethodInfo gmd = (SR.MethodInfo) mi.GetType ().GetMethod ("GetGenericMethodDefinition").Invoke (mi, null);
- GenericInstanceMethod gim = new GenericInstanceMethod (
- ImportMethodBase (gmd, gmd.ReturnType, context));
-
- foreach (Type genArg in GetGenericArguments (mi))
- gim.GenericArguments.Add (ImportSystemType (genArg, context));
-
- return gim;
- }
-
- MethodReference ImportMethodBase (SR.MethodBase mb, Type retType, ImportContext context)
- {
- if (IsGenericMethod (mb) && !IsGenericMethodDefinition (mb))
- return ImportGenericInstanceMethod ((SR.MethodInfo) mb, context);
-
- Type originalDecType = mb.DeclaringType;
- Type declaringTypeDef = originalDecType;
- while (IsGenericTypeSpec (declaringTypeDef))
- declaringTypeDef = GetGenericTypeDefinition (declaringTypeDef);
-
- if (mb.DeclaringType != declaringTypeDef && mb is SR.MethodInfo) {
- int mt = GetMetadataToken (mb as SR.MethodInfo);
- // hack to get the generic method definition from the constructed method
- foreach (SR.MethodInfo mi in declaringTypeDef.GetMethods ()) {
- if (GetMetadataToken (mi) == mt) {
- mb = mi;
- retType = mi.ReturnType;
- break;
- }
- }
- }
-
- string sig = GetMethodBaseSignature (mb, originalDecType, retType);
- MethodReference meth = (MethodReference) GetMemberReference (sig);
- if (meth != null)
- return meth;
-
- meth = new MethodReference (
- mb.Name,
- (mb.CallingConvention & SR.CallingConventions.HasThis) > 0,
- (mb.CallingConvention & SR.CallingConventions.ExplicitThis) > 0,
- MethodCallingConvention.Default); // TODO: get the real callconv
- meth.DeclaringType = ImportSystemType (originalDecType, context);
-
- if (IsGenericMethod (mb))
- foreach (Type genParam in GetGenericArguments (mb as SR.MethodInfo))
- meth.GenericParameters.Add (new GenericParameter (genParam.Name, meth));
-
- context.GenericContext.Method = meth;
- context.GenericContext.Type = ImportSystemType (declaringTypeDef, context);
-
- meth.ReturnType.ReturnType = ImportSystemType (retType, context);
-
- SR.ParameterInfo [] parameters = mb.GetParameters ();
- for (int i = 0; i < parameters.Length; i++)
- meth.Parameters.Add (new ParameterDefinition (
- ImportSystemType (parameters [i].ParameterType, context)));
-
- m_module.MemberReferences.Add (meth);
- return meth;
- }
-
- public MethodReference ImportConstructorInfo (SR.ConstructorInfo ci, ImportContext context)
- {
- return ImportMethodBase (ci, typeof (void), context);
- }
-
- public MethodReference ImportMethodInfo (SR.MethodInfo mi, ImportContext context)
- {
- return ImportMethodBase (mi, mi.ReturnType, context);
- }
-
- static string GetFieldSignature (SR.FieldInfo field)
- {
- StringBuilder sb = new StringBuilder ();
- sb.Append (GetTypeSignature (field.FieldType));
- sb.Append (' ');
- sb.Append (GetTypeSignature (field.DeclaringType));
- sb.Append ("::");
- sb.Append (field.Name);
- return sb.ToString ();
- }
-
- public FieldReference ImportFieldInfo (SR.FieldInfo fi, ImportContext context)
- {
- string sig = GetFieldSignature (fi);
- FieldReference f = (FieldReference) GetMemberReference (sig);
- if (f != null)
- return f;
-
- f = new FieldReference (
- fi.Name,
- ImportSystemType (fi.DeclaringType, context),
- ImportSystemType (fi.FieldType, context));
-
- m_module.MemberReferences.Add (f);
- return f;
- }
-
- MemberReference GetMemberReference (string signature)
- {
- foreach (MemberReference reference in m_module.MemberReferences)
- if (reference.ToString () == signature)
- return reference;
-
- return null;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionReader.cs
deleted file mode 100644
index a6296ab..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionReader.cs
+++ /dev/null
@@ -1,1179 +0,0 @@
-//
-// ReflectionReader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 - 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.IO;
- using System.Text;
-
- using Mono.Cecil.Binary;
- using Mono.Cecil.Cil;
- using Mono.Cecil.Metadata;
- using Mono.Cecil.Signatures;
-
- internal abstract class ReflectionReader : BaseReflectionReader {
-
- ModuleDefinition m_module;
- ImageReader m_reader;
- SecurityDeclarationReader m_secReader;
- protected MetadataTableReader m_tableReader;
- protected MetadataRoot m_root;
- protected TablesHeap m_tHeap;
- protected bool m_checkDeleted;
-
- protected TypeDefinition [] m_typeDefs;
- protected TypeReference [] m_typeRefs;
- protected TypeReference [] m_typeSpecs;
- protected MethodDefinition [] m_meths;
- protected FieldDefinition [] m_fields;
- protected EventDefinition [] m_events;
- protected PropertyDefinition [] m_properties;
- protected MemberReference [] m_memberRefs;
- protected ParameterDefinition [] m_parameters;
- protected GenericParameter [] m_genericParameters;
- protected GenericInstanceMethod [] m_methodSpecs;
-
- bool m_isCorlib;
- AssemblyNameReference m_corlib;
-
- protected SignatureReader m_sigReader;
- protected CodeReader m_codeReader;
- protected ISymbolReader m_symbolReader;
-
- internal AssemblyNameReference Corlib {
- get {
- if (m_corlib != null)
- return m_corlib;
-
- foreach (AssemblyNameReference ar in m_module.AssemblyReferences) {
- if (ar.Name == Constants.Corlib) {
- m_corlib = ar;
- return m_corlib;
- }
- }
-
- return null;
- }
- }
-
- public ModuleDefinition Module {
- get { return m_module; }
- }
-
- public SignatureReader SigReader {
- get { return m_sigReader; }
- }
-
- public MetadataTableReader TableReader {
- get { return m_tableReader; }
- }
-
- public CodeReader Code {
- get { return m_codeReader; }
- }
-
- public ISymbolReader SymbolReader {
- get { return m_symbolReader; }
- set { m_symbolReader = value; }
- }
-
- public MetadataRoot MetadataRoot {
- get { return m_root; }
- }
-
- public ReflectionReader (ModuleDefinition module)
- {
- m_module = module;
- m_reader = m_module.ImageReader;
- m_root = m_module.Image.MetadataRoot;
- m_tHeap = m_root.Streams.TablesHeap;
- m_checkDeleted = (m_tHeap.HeapSizes & 0x80) != 0;
- if (m_reader != null)
- m_tableReader = m_reader.MetadataReader.TableReader;
- m_codeReader = new CodeReader (this);
- m_sigReader = new SignatureReader (m_root, this);
- m_isCorlib = module.Assembly.Name.Name == Constants.Corlib;
- }
-
- public TypeDefinition GetTypeDefAt (uint rid)
- {
- return m_typeDefs [rid - 1];
- }
-
- public TypeReference GetTypeRefAt (uint rid)
- {
- return m_typeRefs [rid - 1];
- }
-
- public TypeReference GetTypeSpecAt (uint rid, GenericContext context)
- {
- int index = (int) rid - 1;
- TypeReference tspec = m_typeSpecs [index];
- if (tspec != null)
- return tspec;
-
- TypeSpecTable tsTable = m_tableReader.GetTypeSpecTable ();
- TypeSpecRow tsRow = tsTable [index];
- TypeSpec ts = m_sigReader.GetTypeSpec (tsRow.Signature);
- tspec = GetTypeRefFromSig (ts.Type, context);
- tspec = GetModifierType (ts.CustomMods, tspec);
- tspec.MetadataToken = MetadataToken.FromMetadataRow (TokenType.TypeSpec, index);
- m_typeSpecs [index] = tspec;
-
- return tspec;
- }
-
- public FieldDefinition GetFieldDefAt (uint rid)
- {
- return m_fields [rid - 1];
- }
-
- public MethodDefinition GetMethodDefAt (uint rid)
- {
- return m_meths [rid - 1];
- }
-
- protected bool IsDeleted (IMemberDefinition member)
- {
- if (!m_checkDeleted)
- return false;
-
- if (!member.IsSpecialName || !member.IsRuntimeSpecialName)
- return false;
-
- return member.Name.StartsWith (Constants.Deleted);
- }
-
- public MemberReference GetMemberRefAt (uint rid, GenericContext context)
- {
- int index = (int) rid - 1;
- MemberReference member = m_memberRefs [rid - 1];
- if (member != null)
- return member;
-
- MemberRefTable mrTable = m_tableReader.GetMemberRefTable ();
- MemberRefRow mrefRow = mrTable [index];
-
- Signature sig = m_sigReader.GetMemberRefSig (mrefRow.Class.TokenType, mrefRow.Signature);
- switch (mrefRow.Class.TokenType) {
- case TokenType.TypeDef :
- case TokenType.TypeRef :
- case TokenType.TypeSpec :
- TypeReference declaringType = GetTypeDefOrRef (mrefRow.Class, context);
- GenericContext nc = context.Clone ();
-
- if (declaringType is GenericInstanceType) {
- TypeReference ct = declaringType;
- while (ct is GenericInstanceType)
- ct = (ct as GenericInstanceType).ElementType;
-
- nc.Type = ct;
- }
-
- if (sig is FieldSig) {
- FieldSig fs = sig as FieldSig;
- TypeReference fieldType = GetTypeRefFromSig (fs.Type, nc);
- fieldType = GetModifierType (fs.CustomMods, fieldType);
-
- member = new FieldReference (
- m_root.Streams.StringsHeap [mrefRow.Name],
- declaringType,
- fieldType);
- } else {
- string name = m_root.Streams.StringsHeap [mrefRow.Name];
- MethodSig ms = (MethodSig) sig;
-
- member = CreateMethodReferenceFromSig (ms, name, declaringType, nc);
- }
- break;
- case TokenType.Method :
- // really not sure about this
- MethodDefinition methdef = GetMethodDefAt (mrefRow.Class.RID);
-
- member = CreateMethodReferenceFromSig ((MethodSig) sig, methdef.Name, methdef.DeclaringType, new GenericContext ());
- break;
- case TokenType.ModuleRef :
- break; // TODO, implement that, or not
- }
-
- member.MetadataToken = MetadataToken.FromMetadataRow (TokenType.MemberRef, index);
- m_module.MemberReferences.Add (member);
- m_memberRefs [index] = member;
-
- return member;
- }
-
- MethodReference CreateMethodReferenceFromSig (MethodSig ms, string name, TypeReference declaringType, GenericContext context)
- {
- MethodReference methref = new MethodReference (
- name, ms.HasThis, ms.ExplicitThis, ms.MethCallConv);
- methref.DeclaringType = declaringType;
-
- if (ms is MethodDefSig) {
- int arity = (ms as MethodDefSig).GenericParameterCount;
- for (int i = 0; i < arity; i++)
- methref.GenericParameters.Add (new GenericParameter (i, methref));
- }
-
- if (methref.GenericParameters.Count > 0)
- context.Method = methref;
-
- methref.ReturnType = GetMethodReturnType (ms, context);
-
- methref.ReturnType.Method = methref;
- for (int j = 0; j < ms.ParamCount; j++) {
- Param p = ms.Parameters [j];
- ParameterDefinition pdef = BuildParameterDefinition (j, p, context);
- pdef.Method = methref;
- methref.Parameters.Add (pdef);
- }
-
- CreateSentinelIfNeeded (methref, ms);
-
- return methref;
- }
-
- public static void CreateSentinelIfNeeded (IMethodSignature meth, MethodSig signature)
- {
- MethodDefSig sig = signature as MethodDefSig;
- if (sig == null)
- return;
-
- int sentinel = sig.Sentinel;
-
- if (sig.Sentinel < 0 || sig.Sentinel >= meth.Parameters.Count)
- return;
-
- ParameterDefinition param = meth.Parameters [sentinel];
- param.ParameterType = new SentinelType (param.ParameterType);
- }
-
- public PropertyDefinition GetPropertyDefAt (uint rid)
- {
- return m_properties [rid - 1];
- }
-
- public EventDefinition GetEventDefAt (uint rid)
- {
- return m_events [rid - 1];
- }
-
- public ParameterDefinition GetParamDefAt (uint rid)
- {
- return m_parameters [rid - 1];
- }
-
- public GenericParameter GetGenericParameterAt (uint rid)
- {
- return m_genericParameters [rid - 1];
- }
-
- public GenericInstanceMethod GetMethodSpecAt (uint rid, GenericContext context)
- {
- int index = (int) rid - 1;
- GenericInstanceMethod gim = m_methodSpecs [index];
- if (gim != null)
- return gim;
-
- MethodSpecTable msTable = m_tableReader.GetMethodSpecTable ();
- MethodSpecRow msRow = msTable [index];
-
- MethodSpec sig = m_sigReader.GetMethodSpec (msRow.Instantiation);
-
- MethodReference meth;
- if (msRow.Method.TokenType == TokenType.Method)
- meth = GetMethodDefAt (msRow.Method.RID);
- else if (msRow.Method.TokenType == TokenType.MemberRef)
- meth = (MethodReference) GetMemberRefAt (msRow.Method.RID, context);
- else
- throw new ReflectionException ("Unknown method type for method spec");
-
- gim = new GenericInstanceMethod (meth);
- context.CheckProvider (meth, sig.Signature.Arity);
- foreach (GenericArg arg in sig.Signature.Types)
- gim.GenericArguments.Add (GetGenericArg (arg, context));
-
- m_methodSpecs [index] = gim;
-
- return gim;
- }
-
- public TypeReference GetTypeDefOrRef (MetadataToken token, GenericContext context)
- {
- if (token.RID == 0)
- return null;
-
- switch (token.TokenType) {
- case TokenType.TypeDef :
- return GetTypeDefAt (token.RID);
- case TokenType.TypeRef :
- return GetTypeRefAt (token.RID);
- case TokenType.TypeSpec :
- return GetTypeSpecAt (token.RID, context);
- default :
- return null;
- }
- }
-
- public TypeReference SearchCoreType (string fullName)
- {
- if (m_isCorlib)
- return m_module.Types [fullName];
-
- TypeReference coreType = m_module.TypeReferences [fullName];
- if (coreType == null) {
- string [] parts = fullName.Split ('.');
- if (parts.Length != 2)
- throw new ReflectionException ("Unvalid core type name");
- coreType = new TypeReference (parts [1], parts [0], Corlib);
- m_module.TypeReferences.Add (coreType);
- }
- if (!coreType.IsValueType) {
- switch (coreType.FullName) {
- case Constants.Boolean :
- case Constants.Char :
- case Constants.Single :
- case Constants.Double :
- case Constants.SByte :
- case Constants.Byte :
- case Constants.Int16 :
- case Constants.UInt16 :
- case Constants.Int32 :
- case Constants.UInt32 :
- case Constants.Int64 :
- case Constants.UInt64 :
- case Constants.IntPtr :
- case Constants.UIntPtr :
- coreType.IsValueType = true;
- break;
- }
- }
- return coreType;
- }
-
- public IMetadataTokenProvider LookupByToken (MetadataToken token)
- {
- switch (token.TokenType) {
- case TokenType.TypeDef :
- return GetTypeDefAt (token.RID);
- case TokenType.TypeRef :
- return GetTypeRefAt (token.RID);
- case TokenType.Method :
- return GetMethodDefAt (token.RID);
- case TokenType.Field :
- return GetFieldDefAt (token.RID);
- case TokenType.Event :
- return GetEventDefAt (token.RID);
- case TokenType.Property :
- return GetPropertyDefAt (token.RID);
- case TokenType.Param :
- return GetParamDefAt (token.RID);
- default :
- throw new NotSupportedException ("Lookup is not allowed on this kind of token");
- }
- }
-
- public CustomAttribute GetCustomAttribute (MethodReference ctor, byte [] data, bool resolve)
- {
- CustomAttrib sig = m_sigReader.GetCustomAttrib (data, ctor, resolve);
- return BuildCustomAttribute (ctor, sig);
- }
-
- public CustomAttribute GetCustomAttribute (MethodReference ctor, byte [] data)
- {
- return GetCustomAttribute (ctor, data, false);
- }
-
- public override void VisitModuleDefinition (ModuleDefinition mod)
- {
- VisitTypeDefinitionCollection (mod.Types);
- }
-
- public override void VisitTypeDefinitionCollection (TypeDefinitionCollection types)
- {
- // type def reading
- TypeDefTable typesTable = m_tableReader.GetTypeDefTable ();
- m_typeDefs = new TypeDefinition [typesTable.Rows.Count];
- for (int i = 0; i < typesTable.Rows.Count; i++) {
- TypeDefRow type = typesTable [i];
- TypeDefinition t = new TypeDefinition (
- m_root.Streams.StringsHeap [type.Name],
- m_root.Streams.StringsHeap [type.Namespace],
- type.Flags);
- t.MetadataToken = MetadataToken.FromMetadataRow (TokenType.TypeDef, i);
-
- m_typeDefs [i] = t;
- }
-
- // nested types
- if (m_tHeap.HasTable (NestedClassTable.RId)) {
- NestedClassTable nested = m_tableReader.GetNestedClassTable ();
- for (int i = 0; i < nested.Rows.Count; i++) {
- NestedClassRow row = nested [i];
-
- TypeDefinition parent = GetTypeDefAt (row.EnclosingClass);
- TypeDefinition child = GetTypeDefAt (row.NestedClass);
-
- if (!IsDeleted (child))
- parent.NestedTypes.Add (child);
- }
- }
-
- foreach (TypeDefinition type in m_typeDefs)
- if (!IsDeleted (type))
- types.Add (type);
-
- // type ref reading
- if (m_tHeap.HasTable (TypeRefTable.RId)) {
- TypeRefTable typesRef = m_tableReader.GetTypeRefTable ();
-
- m_typeRefs = new TypeReference [typesRef.Rows.Count];
-
- for (int i = 0; i < typesRef.Rows.Count; i++)
- AddTypeRef (typesRef, i);
- } else
- m_typeRefs = new TypeReference [0];
-
- ReadTypeSpecs ();
- ReadMethodSpecs ();
-
- ReadMethods ();
- ReadGenericParameters ();
-
- // set base types
- for (int i = 0; i < typesTable.Rows.Count; i++) {
- TypeDefRow type = typesTable [i];
- TypeDefinition child = m_typeDefs [i];
- child.BaseType = GetTypeDefOrRef (type.Extends, new GenericContext (child));
- }
-
- CompleteMethods ();
- ReadAllFields ();
- ReadMemberReferences ();
- }
-
- void AddTypeRef (TypeRefTable typesRef, int i)
- {
- // Check if index has been already added.
- if (m_typeRefs [i] != null)
- return;
-
- TypeRefRow type = typesRef [i];
- IMetadataScope scope = null;
- TypeReference parent = null;
-
- if (type.ResolutionScope.RID != 0) {
- int rid = (int) type.ResolutionScope.RID - 1;
- switch (type.ResolutionScope.TokenType) {
- case TokenType.AssemblyRef:
- scope = m_module.AssemblyReferences [rid];
- break;
- case TokenType.ModuleRef:
- scope = m_module.ModuleReferences [rid];
- break;
- case TokenType.Module:
- scope = m_module.Assembly.Modules [rid];
- break;
- case TokenType.TypeRef:
- AddTypeRef (typesRef, rid);
- parent = GetTypeRefAt (type.ResolutionScope.RID);
- scope = parent.Scope;
- break;
- }
- }
-
- TypeReference t = new TypeReference (
- m_root.Streams.StringsHeap [type.Name],
- m_root.Streams.StringsHeap [type.Namespace],
- scope);
- t.MetadataToken = MetadataToken.FromMetadataRow (TokenType.TypeRef, i);
-
- if (parent != null)
- t.DeclaringType = parent;
-
- m_typeRefs [i] = t;
- m_module.TypeReferences.Add (t);
- }
-
- void ReadTypeSpecs ()
- {
- if (!m_tHeap.HasTable (TypeSpecTable.RId))
- return;
-
- TypeSpecTable tsTable = m_tableReader.GetTypeSpecTable ();
- m_typeSpecs = new TypeReference [tsTable.Rows.Count];
- }
-
- void ReadMethodSpecs ()
- {
- if (!m_tHeap.HasTable (MethodSpecTable.RId))
- return;
-
- MethodSpecTable msTable = m_tableReader.GetMethodSpecTable ();
- m_methodSpecs = new GenericInstanceMethod [msTable.Rows.Count];
- }
-
- void ReadGenericParameters ()
- {
- if (!m_tHeap.HasTable (GenericParamTable.RId))
- return;
-
- GenericParamTable gpTable = m_tableReader.GetGenericParamTable ();
- m_genericParameters = new GenericParameter [gpTable.Rows.Count];
- for (int i = 0; i < gpTable.Rows.Count; i++) {
- GenericParamRow gpRow = gpTable [i];
- IGenericParameterProvider owner;
- if (gpRow.Owner.TokenType == TokenType.Method)
- owner = GetMethodDefAt (gpRow.Owner.RID);
- else if (gpRow.Owner.TokenType == TokenType.TypeDef)
- owner = GetTypeDefAt (gpRow.Owner.RID);
- else
- throw new ReflectionException ("Unknown owner type for generic parameter");
-
- GenericParameter gp = new GenericParameter (gpRow.Number, owner);
- gp.Attributes = gpRow.Flags;
- gp.Name = MetadataRoot.Streams.StringsHeap [gpRow.Name];
- gp.MetadataToken = MetadataToken.FromMetadataRow (TokenType.GenericParam, i);
-
- owner.GenericParameters.Add (gp);
- m_genericParameters [i] = gp;
- }
- }
-
- void ReadAllFields ()
- {
- TypeDefTable tdefTable = m_tableReader.GetTypeDefTable ();
-
- if (!m_tHeap.HasTable (FieldTable.RId)) {
- m_fields = new FieldDefinition [0];
- return;
- }
-
- FieldTable fldTable = m_tableReader.GetFieldTable ();
- m_fields = new FieldDefinition [fldTable.Rows.Count];
-
- for (int i = 0; i < m_typeDefs.Length; i++) {
- TypeDefinition dec = m_typeDefs [i];
- GenericContext context = new GenericContext (dec);
-
- int index = i, next;
-
- if (index == tdefTable.Rows.Count - 1)
- next = fldTable.Rows.Count + 1;
- else
- next = (int) (tdefTable [index + 1]).FieldList;
-
- for (int j = (int) tdefTable [index].FieldList; j < next; j++) {
- FieldRow frow = fldTable [j - 1];
- FieldSig fsig = m_sigReader.GetFieldSig (frow.Signature);
-
- FieldDefinition fdef = new FieldDefinition (
- m_root.Streams.StringsHeap [frow.Name],
- GetTypeRefFromSig (fsig.Type, context), frow.Flags);
- fdef.MetadataToken = MetadataToken.FromMetadataRow (TokenType.Field, j - 1);
-
- if (fsig.CustomMods.Length > 0)
- fdef.FieldType = GetModifierType (fsig.CustomMods, fdef.FieldType);
-
- if (!IsDeleted (fdef))
- dec.Fields.Add (fdef);
-
- m_fields [j - 1] = fdef;
- }
- }
- }
-
- void ReadMethods ()
- {
- if (!m_tHeap.HasTable (MethodTable.RId)) {
- m_meths = new MethodDefinition [0];
- return;
- }
-
- MethodTable mTable = m_tableReader.GetMethodTable ();
- m_meths = new MethodDefinition [mTable.Rows.Count];
- for (int i = 0; i < mTable.Rows.Count; i++) {
- MethodRow mRow = mTable [i];
- MethodDefinition meth = new MethodDefinition (
- m_root.Streams.StringsHeap [mRow.Name],
- mRow.Flags);
- meth.RVA = mRow.RVA;
- meth.ImplAttributes = mRow.ImplFlags;
-
- meth.MetadataToken = MetadataToken.FromMetadataRow (TokenType.Method, i);
-
- m_meths [i] = meth;
- }
- }
-
- void CompleteMethods ()
- {
- TypeDefTable tdefTable = m_tableReader.GetTypeDefTable ();
-
- if (!m_tHeap.HasTable (MethodTable.RId)) {
- m_meths = new MethodDefinition [0];
- return;
- }
-
- MethodTable methTable = m_tableReader.GetMethodTable ();
- ParamTable paramTable = m_tableReader.GetParamTable ();
- if (!m_tHeap.HasTable (ParamTable.RId))
- m_parameters = new ParameterDefinition [0];
- else
- m_parameters = new ParameterDefinition [paramTable.Rows.Count];
-
- for (int i = 0; i < m_typeDefs.Length; i++) {
- TypeDefinition dec = m_typeDefs [i];
-
- int index = i, next;
-
- if (index == tdefTable.Rows.Count - 1)
- next = methTable.Rows.Count + 1;
- else
- next = (int) (tdefTable [index + 1]).MethodList;
-
- for (int j = (int) tdefTable [index].MethodList; j < next; j++) {
- MethodRow methRow = methTable [j - 1];
- MethodDefinition mdef = m_meths [j - 1];
-
- if (!IsDeleted (mdef)) {
- if (mdef.IsConstructor)
- dec.Constructors.Add (mdef);
- else
- dec.Methods.Add (mdef);
- }
-
- GenericContext context = new GenericContext (mdef);
-
- MethodDefSig msig = m_sigReader.GetMethodDefSig (methRow.Signature);
- mdef.HasThis = msig.HasThis;
- mdef.ExplicitThis = msig.ExplicitThis;
- mdef.CallingConvention = msig.MethCallConv;
-
- int prms;
- if (j == methTable.Rows.Count)
- prms = m_parameters.Length + 1;
- else
- prms = (int) (methTable [j]).ParamList;
-
- ParameterDefinition retparam = null;
-
- //TODO: optimize this
- int start = (int) methRow.ParamList - 1;
-
- if (paramTable != null && start < prms - 1) {
-
- ParamRow pRetRow = paramTable [start];
-
- if (pRetRow != null && pRetRow.Sequence == 0) { // ret type
-
- retparam = new ParameterDefinition (
- m_root.Streams.StringsHeap [pRetRow.Name],
- 0,
- pRetRow.Flags,
- null);
-
- retparam.Method = mdef;
- m_parameters [start] = retparam;
- start++;
- }
- }
-
- for (int k = 0; k < msig.ParamCount; k++) {
-
- int pointer = start + k;
-
- ParamRow pRow = null;
-
- if (paramTable != null && pointer < prms - 1)
- pRow = paramTable [pointer];
-
- Param psig = msig.Parameters [k];
-
- ParameterDefinition pdef;
- if (pRow != null) {
- pdef = BuildParameterDefinition (
- m_root.Streams.StringsHeap [pRow.Name],
- pRow.Sequence, pRow.Flags, psig, context);
- pdef.MetadataToken = MetadataToken.FromMetadataRow (TokenType.Param, pointer);
- m_parameters [pointer] = pdef;
- } else
- pdef = BuildParameterDefinition (k + 1, psig, context);
-
- pdef.Method = mdef;
- mdef.Parameters.Add (pdef);
- }
-
- mdef.ReturnType = GetMethodReturnType (msig, context);
- MethodReturnType mrt = mdef.ReturnType;
- mrt.Method = mdef;
- if (retparam != null) {
- mrt.Parameter = retparam;
- mrt.Parameter.ParameterType = mrt.ReturnType;
- }
- }
- }
-
- uint eprid = CodeReader.GetRid ((int) m_reader.Image.CLIHeader.EntryPointToken);
- if (eprid > 0 && eprid <= m_meths.Length)
- m_module.Assembly.EntryPoint = GetMethodDefAt (eprid);
- }
-
- void ReadMemberReferences ()
- {
- if (!m_tHeap.HasTable (MemberRefTable.RId))
- return;
-
- MemberRefTable mrefTable = m_tableReader.GetMemberRefTable ();
- m_memberRefs = new MemberReference [mrefTable.Rows.Count];
- }
-
- public override void VisitExternTypeCollection (ExternTypeCollection externs)
- {
- ExternTypeCollection ext = externs;
-
- if (!m_tHeap.HasTable (ExportedTypeTable.RId))
- return;
-
- ExportedTypeTable etTable = m_tableReader.GetExportedTypeTable ();
- TypeReference [] buffer = new TypeReference [etTable.Rows.Count];
-
- for (int i = 0; i < etTable.Rows.Count; i++) {
- ExportedTypeRow etRow = etTable [i];
- if (etRow.Implementation.TokenType != TokenType.File)
- continue;
-
- string name = m_root.Streams.StringsHeap [etRow.TypeName];
- string ns = m_root.Streams.StringsHeap [etRow.TypeNamespace];
- if (ns.Length == 0)
- buffer [i] = m_module.TypeReferences [name];
- else
- buffer [i] = m_module.TypeReferences [string.Concat (ns, '.', name)];
- }
-
- for (int i = 0; i < etTable.Rows.Count; i++) {
- ExportedTypeRow etRow = etTable [i];
- if (etRow.Implementation.TokenType != TokenType.ExportedType)
- continue;
-
- TypeReference owner = buffer [etRow.Implementation.RID - 1];
- string name = m_root.Streams.StringsHeap [etRow.TypeName];
- buffer [i] = m_module.TypeReferences [string.Concat (owner.FullName, '/', name)];
- }
-
- for (int i = 0; i < buffer.Length; i++) {
- TypeReference curs = buffer [i];
- if (curs != null)
- ext.Add (curs);
- }
- }
-
- static object GetFixedArgValue (CustomAttrib.FixedArg fa)
- {
- if (fa.SzArray) {
- object [] vals = new object [fa.NumElem];
- for (int j = 0; j < vals.Length; j++)
- vals [j] = fa.Elems [j].Value;
- return vals;
- } else
- return fa.Elems [0].Value;
- }
-
- TypeReference GetFixedArgType (CustomAttrib.FixedArg fa)
- {
- if (fa.SzArray) {
- if (fa.NumElem == 0)
- return new ArrayType (SearchCoreType (Constants.Object));
- else
- return new ArrayType (fa.Elems [0].ElemType);
- } else
- return fa.Elems [0].ElemType;
- }
-
- TypeReference GetNamedArgType (CustomAttrib.NamedArg na)
- {
- if (na.FieldOrPropType == ElementType.Boxed)
- return SearchCoreType (Constants.Object);
-
- return GetFixedArgType (na.FixedArg);
- }
-
- protected CustomAttribute BuildCustomAttribute (MethodReference ctor, CustomAttrib sig)
- {
- CustomAttribute cattr = new CustomAttribute (ctor);
-
- foreach (CustomAttrib.FixedArg fa in sig.FixedArgs)
- cattr.ConstructorParameters.Add (GetFixedArgValue (fa));
-
- foreach (CustomAttrib.NamedArg na in sig.NamedArgs) {
- object value = GetFixedArgValue (na.FixedArg);
- if (na.Field) {
- cattr.Fields [na.FieldOrPropName] = value;
- cattr.SetFieldType (na.FieldOrPropName, GetNamedArgType (na));
- } else if (na.Property) {
- cattr.Properties [na.FieldOrPropName] = value;
- cattr.SetPropertyType (na.FieldOrPropName, GetNamedArgType (na));
- } else
- throw new ReflectionException ("Non valid named arg");
- }
-
- return cattr;
- }
-
- void CompleteParameter (ParameterDefinition parameter, Param signature, GenericContext context)
- {
- TypeReference paramType;
-
- if (signature.ByRef)
- paramType = new ReferenceType (GetTypeRefFromSig (signature.Type, context));
- else if (signature.TypedByRef)
- paramType = SearchCoreType (Constants.TypedReference);
- else
- paramType = GetTypeRefFromSig (signature.Type, context);
-
- paramType = GetModifierType (signature.CustomMods, paramType);
-
- parameter.ParameterType = paramType;
- }
-
- public ParameterDefinition BuildParameterDefinition (int sequence, Param psig, GenericContext context)
- {
- ParameterDefinition parameter = new ParameterDefinition (null);
- parameter.Sequence = sequence;
-
- CompleteParameter (parameter, psig, context);
-
- return parameter;
- }
-
- public ParameterDefinition BuildParameterDefinition (string name, int sequence, ParameterAttributes attrs, Param psig, GenericContext context)
- {
- ParameterDefinition parameter = new ParameterDefinition (name, sequence, attrs, null);
-
- CompleteParameter (parameter, psig, context);
-
- return parameter;
- }
-
- protected SecurityDeclaration BuildSecurityDeclaration (DeclSecurityRow dsRow)
- {
- return BuildSecurityDeclaration (dsRow.Action, m_root.Streams.BlobHeap.Read (dsRow.PermissionSet));
- }
-
- public SecurityDeclaration BuildSecurityDeclaration (SecurityAction action, byte [] permset)
- {
- if (m_secReader == null)
- m_secReader = new SecurityDeclarationReader (m_root, this);
-
- return m_secReader.FromByteArray (action, permset);
- }
-
- protected MarshalSpec BuildMarshalDesc (MarshalSig ms, IHasMarshalSpec container)
- {
- if (ms.Spec is MarshalSig.Array) {
- ArrayMarshalSpec amd = new ArrayMarshalSpec (container);
- MarshalSig.Array ar = (MarshalSig.Array) ms.Spec;
- amd.ElemType = ar.ArrayElemType;
- amd.NumElem = ar.NumElem;
- amd.ParamNum = ar.ParamNum;
- amd.ElemMult = ar.ElemMult;
- return amd;
- } else if (ms.Spec is MarshalSig.CustomMarshaler) {
- CustomMarshalerSpec cmd = new CustomMarshalerSpec (container);
- MarshalSig.CustomMarshaler cmsig = (MarshalSig.CustomMarshaler) ms.Spec;
- cmd.Guid = cmsig.Guid.Length > 0 ? new Guid (cmsig.Guid) : new Guid ();
- cmd.UnmanagedType = cmsig.UnmanagedType;
- cmd.ManagedType = cmsig.ManagedType;
- cmd.Cookie = cmsig.Cookie;
- return cmd;
- } else if (ms.Spec is MarshalSig.FixedArray) {
- FixedArraySpec fad = new FixedArraySpec (container);
- MarshalSig.FixedArray fasig = (MarshalSig.FixedArray) ms.Spec;
- fad.ElemType = fasig.ArrayElemType;
- fad.NumElem = fasig.NumElem;
- return fad;
- } else if (ms.Spec is MarshalSig.FixedSysString) {
- FixedSysStringSpec fssc = new FixedSysStringSpec (container);
- fssc.Size = ((MarshalSig.FixedSysString) ms.Spec).Size;
- return fssc;
- } else if (ms.Spec is MarshalSig.SafeArray) {
- SafeArraySpec sad = new SafeArraySpec (container);
- sad.ElemType = ((MarshalSig.SafeArray) ms.Spec).ArrayElemType;
- return sad;
- } else {
- return new MarshalSpec (ms.NativeInstrinsic, container);
- }
- }
-
- public TypeReference GetModifierType (CustomMod [] cmods, TypeReference type)
- {
- if (cmods == null || cmods.Length == 0)
- return type;
-
- TypeReference ret = type;
- for (int i = cmods.Length - 1; i >= 0; i--) {
- CustomMod cmod = cmods [i];
- TypeReference modType;
-
- if (cmod.TypeDefOrRef.TokenType == TokenType.TypeDef)
- modType = GetTypeDefAt (cmod.TypeDefOrRef.RID);
- else
- modType = GetTypeRefAt (cmod.TypeDefOrRef.RID);
-
- if (cmod.CMOD == CustomMod.CMODType.OPT)
- ret = new ModifierOptional (ret, modType);
- else if (cmod.CMOD == CustomMod.CMODType.REQD)
- ret = new ModifierRequired (ret, modType);
- }
- return ret;
- }
-
- public MethodReturnType GetMethodReturnType (MethodSig msig, GenericContext context)
- {
- TypeReference retType;
- if (msig.RetType.Void)
- retType = SearchCoreType (Constants.Void);
- else if (msig.RetType.ByRef)
- retType = new ReferenceType (GetTypeRefFromSig (msig.RetType.Type, context));
- else if (msig.RetType.TypedByRef)
- retType = SearchCoreType (Constants.TypedReference);
- else
- retType = GetTypeRefFromSig (msig.RetType.Type, context);
-
- retType = GetModifierType (msig.RetType.CustomMods, retType);
-
- return new MethodReturnType (retType);
- }
-
- public TypeReference GetTypeRefFromSig (SigType t, GenericContext context)
- {
- switch (t.ElementType) {
- case ElementType.Class :
- CLASS c = t as CLASS;
- return GetTypeDefOrRef (c.Type, context);
- case ElementType.ValueType :
- VALUETYPE vt = t as VALUETYPE;
- TypeReference vtr = GetTypeDefOrRef (vt.Type, context);
- vtr.IsValueType = true;
- return vtr;
- case ElementType.String :
- return SearchCoreType (Constants.String);
- case ElementType.Object :
- return SearchCoreType (Constants.Object);
- case ElementType.Void :
- return SearchCoreType (Constants.Void);
- case ElementType.Boolean :
- return SearchCoreType (Constants.Boolean);
- case ElementType.Char :
- return SearchCoreType (Constants.Char);
- case ElementType.I1 :
- return SearchCoreType (Constants.SByte);
- case ElementType.U1 :
- return SearchCoreType (Constants.Byte);
- case ElementType.I2 :
- return SearchCoreType (Constants.Int16);
- case ElementType.U2 :
- return SearchCoreType (Constants.UInt16);
- case ElementType.I4 :
- return SearchCoreType (Constants.Int32);
- case ElementType.U4 :
- return SearchCoreType (Constants.UInt32);
- case ElementType.I8 :
- return SearchCoreType (Constants.Int64);
- case ElementType.U8 :
- return SearchCoreType (Constants.UInt64);
- case ElementType.R4 :
- return SearchCoreType (Constants.Single);
- case ElementType.R8 :
- return SearchCoreType (Constants.Double);
- case ElementType.I :
- return SearchCoreType (Constants.IntPtr);
- case ElementType.U :
- return SearchCoreType (Constants.UIntPtr);
- case ElementType.TypedByRef :
- return SearchCoreType (Constants.TypedReference);
- case ElementType.Array :
- ARRAY ary = t as ARRAY;
- return new ArrayType (GetTypeRefFromSig (ary.Type, context), ary.Shape);
- case ElementType.SzArray :
- SZARRAY szary = t as SZARRAY;
- ArrayType at = new ArrayType (GetTypeRefFromSig (szary.Type, context));
- return at;
- case ElementType.Ptr :
- PTR pointer = t as PTR;
- if (pointer.Void)
- return new PointerType (SearchCoreType (Constants.Void));
- return new PointerType (GetTypeRefFromSig (pointer.PtrType, context));
- case ElementType.FnPtr :
- FNPTR funcptr = t as FNPTR;
- FunctionPointerType fnptr = new FunctionPointerType (funcptr.Method.HasThis, funcptr.Method.ExplicitThis,
- funcptr.Method.MethCallConv, GetMethodReturnType (funcptr.Method, context));
-
- for (int i = 0; i < funcptr.Method.ParamCount; i++) {
- Param p = funcptr.Method.Parameters [i];
- fnptr.Parameters.Add (BuildParameterDefinition (i, p, context));
- }
-
- CreateSentinelIfNeeded (fnptr, funcptr.Method);
-
- return fnptr;
- case ElementType.Var:
- VAR var = t as VAR;
- context.CheckProvider (context.Type, var.Index + 1);
-
- if (context.Type is GenericInstanceType)
- return (context.Type as GenericInstanceType).GenericArguments [var.Index];
- else
- return context.Type.GenericParameters [var.Index];
- case ElementType.MVar:
- MVAR mvar = t as MVAR;
- context.CheckProvider (context.Method, mvar.Index + 1);
-
- if (context.Method is GenericInstanceMethod)
- return (context.Method as GenericInstanceMethod).GenericArguments [mvar.Index];
- else
- return context.Method.GenericParameters [mvar.Index];
- case ElementType.GenericInst:
- GENERICINST ginst = t as GENERICINST;
- GenericInstanceType instance = new GenericInstanceType (GetTypeDefOrRef (ginst.Type, context));
- instance.IsValueType = ginst.ValueType;
- context.CheckProvider (instance.GetOriginalType (), ginst.Signature.Arity);
-
- for (int i = 0; i < ginst.Signature.Arity; i++)
- instance.GenericArguments.Add (GetGenericArg (
- ginst.Signature.Types [i], context));
-
- return instance;
- default:
- break;
- }
- return null;
- }
-
- TypeReference GetGenericArg (GenericArg arg, GenericContext context)
- {
- TypeReference type = GetTypeRefFromSig (arg.Type, context);
- type = GetModifierType (arg.CustomMods, type);
- return type;
- }
-
- static bool IsOdd (int i)
- {
- return (i & 1) == 1;
- }
-
- protected object GetConstant (uint pos, ElementType elemType)
- {
- if (elemType == ElementType.Class)
- return null;
-
- byte [] constant = m_root.Streams.BlobHeap.Read (pos);
-
- if (elemType == ElementType.String) {
- int length = constant.Length;
- if (IsOdd (length))
- length--;
-
- return Encoding.Unicode.GetString (constant, 0, length);
- }
-
- BinaryReader br = new BinaryReader (new MemoryStream (constant));
-
- switch (elemType) {
- case ElementType.Boolean :
- return br.ReadByte () == 1;
- case ElementType.Char :
- return (char) br.ReadUInt16 ();
- case ElementType.I1 :
- return br.ReadSByte ();
- case ElementType.I2 :
- return br.ReadInt16 ();
- case ElementType.I4 :
- return br.ReadInt32 ();
- case ElementType.I8 :
- return br.ReadInt64 ();
- case ElementType.U1 :
- return br.ReadByte ();
- case ElementType.U2 :
- return br.ReadUInt16 ();
- case ElementType.U4 :
- return br.ReadUInt32 ();
- case ElementType.U8 :
- return br.ReadUInt64 ();
- case ElementType.R4 :
- return br.ReadSingle ();
- case ElementType.R8 :
- return br.ReadDouble ();
- default :
- throw new ReflectionException ("Non valid element in constant table");
- }
- }
-
- protected void SetInitialValue (FieldDefinition field)
- {
- int size = 0;
- TypeReference fieldType = field.FieldType;
- switch (fieldType.FullName) {
- case Constants.Byte:
- case Constants.SByte:
- size = 1;
- break;
- case Constants.Int16:
- case Constants.UInt16:
- case Constants.Char:
- size = 2;
- break;
- case Constants.Int32:
- case Constants.UInt32:
- case Constants.Single:
- size = 4;
- break;
- case Constants.Int64:
- case Constants.UInt64:
- case Constants.Double:
- size = 8;
- break;
- default:
- fieldType = fieldType.GetOriginalType ();
-
- TypeDefinition fieldTypeDef = fieldType as TypeDefinition;
-
- if (fieldTypeDef != null)
- size = (int) fieldTypeDef.ClassSize;
- break;
- }
-
- if (size > 0 && field.RVA != RVA.Zero) {
- BinaryReader br = m_reader.MetadataReader.GetDataReader (field.RVA);
- field.InitialValue = br == null ? new byte [size] : br.ReadBytes (size);
- } else
- field.InitialValue = new byte [0];
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionWriter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionWriter.cs
deleted file mode 100644
index 01cab15..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ReflectionWriter.cs
+++ /dev/null
@@ -1,1522 +0,0 @@
-//
-// ReflectionWriter.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 - 2007 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
- using System.Globalization;
- using System.Text;
-
- using Mono.Cecil.Binary;
- using Mono.Cecil.Cil;
- using Mono.Cecil.Metadata;
- using Mono.Cecil.Signatures;
-
- internal sealed class ReflectionWriter : BaseReflectionVisitor {
-
- StructureWriter m_structureWriter;
- ModuleDefinition m_mod;
- SignatureWriter m_sigWriter;
- CodeWriter m_codeWriter;
- MetadataWriter m_mdWriter;
- MetadataTableWriter m_tableWriter;
- MetadataRowWriter m_rowWriter;
-
- bool m_saveSymbols;
- string m_asmOutput;
- ISymbolWriter m_symbolWriter;
-
- ArrayList m_typeDefStack;
- ArrayList m_methodStack;
- ArrayList m_fieldStack;
- ArrayList m_genericParamStack;
- IDictionary m_typeSpecTokenCache;
- IDictionary m_memberRefTokenCache;
-
- uint m_methodIndex;
- uint m_fieldIndex;
- uint m_paramIndex;
- uint m_eventIndex;
- uint m_propertyIndex;
-
- MemoryBinaryWriter m_constWriter;
-
- public StructureWriter StructureWriter {
- get { return m_structureWriter; }
- set {
- m_structureWriter = value;
-
- Initialize ();
- }
- }
-
- public CodeWriter CodeWriter {
- get { return m_codeWriter; }
- }
-
- public bool SaveSymbols {
- get { return m_saveSymbols; }
- set { m_saveSymbols = value; }
- }
-
- public string OutputFile
- {
- get { return m_asmOutput; }
- set { m_asmOutput = value; }
- }
-
- public ISymbolWriter SymbolWriter {
- get { return m_symbolWriter; }
- set { m_symbolWriter = value; }
- }
-
- public SignatureWriter SignatureWriter {
- get { return m_sigWriter; }
- }
-
- public MetadataWriter MetadataWriter {
- get { return m_mdWriter; }
- }
-
- public MetadataTableWriter MetadataTableWriter {
- get { return m_tableWriter; }
- }
-
- public MetadataRowWriter MetadataRowWriter {
- get { return m_rowWriter; }
- }
-
- public ReflectionWriter (ModuleDefinition mod)
- {
- m_mod = mod;
- }
-
- void Initialize ()
- {
- m_mdWriter = new MetadataWriter (
- m_mod.Assembly,
- m_mod.Image.MetadataRoot,
- m_structureWriter.Assembly.Kind,
- m_mod.Assembly.Runtime,
- m_structureWriter.GetWriter ());
- m_tableWriter = m_mdWriter.GetTableVisitor ();
- m_rowWriter = m_tableWriter.GetRowVisitor () as MetadataRowWriter;
- m_sigWriter = new SignatureWriter (m_mdWriter);
- m_codeWriter = new CodeWriter (this, m_mdWriter.CilWriter);
-
- m_typeDefStack = new ArrayList ();
- m_methodStack = new ArrayList ();
- m_fieldStack = new ArrayList ();
- m_genericParamStack = new ArrayList ();
- m_typeSpecTokenCache = new Hashtable ();
- m_memberRefTokenCache = new Hashtable ();
-
- m_methodIndex = 1;
- m_fieldIndex = 1;
- m_paramIndex = 1;
- m_eventIndex = 1;
- m_propertyIndex = 1;
-
- m_constWriter = new MemoryBinaryWriter ();
- }
-
- public TypeReference GetCoreType (string name)
- {
- return m_mod.Controller.Reader.SearchCoreType (name);
- }
-
- public static uint GetRidFor (IMetadataTokenProvider tp)
- {
- return tp.MetadataToken.RID;
- }
-
- public uint GetRidFor (AssemblyNameReference asmName)
- {
- return (uint) m_mod.AssemblyReferences.IndexOf (asmName) + 1;
- }
-
- public uint GetRidFor (ModuleDefinition mod)
- {
- return (uint) m_mod.Assembly.Modules.IndexOf (mod) + 1;
- }
-
- public uint GetRidFor (ModuleReference modRef)
- {
- return (uint) m_mod.ModuleReferences.IndexOf (modRef) + 1;
- }
-
- static bool IsTypeSpec (TypeReference type)
- {
- return type is TypeSpecification || type is GenericParameter;
- }
-
- public MetadataToken GetTypeDefOrRefToken (TypeReference type)
- {
- if (IsTypeSpec (type)) {
- uint sig = m_sigWriter.AddTypeSpec (GetTypeSpecSig (type));
- if (m_typeSpecTokenCache.Contains (sig))
- return (MetadataToken) m_typeSpecTokenCache [sig];
-
- TypeSpecTable tsTable = m_tableWriter.GetTypeSpecTable ();
- TypeSpecRow tsRow = m_rowWriter.CreateTypeSpecRow (sig);
- tsTable.Rows.Add (tsRow);
-
- MetadataToken token = new MetadataToken (TokenType.TypeSpec, (uint) tsTable.Rows.Count);
- if (! (type is GenericParameter))
- type.MetadataToken = token;
-
- m_typeSpecTokenCache [sig] = token;
- return token;
- } else if (type != null)
- return type.MetadataToken;
- else // <Module> and interfaces
- return new MetadataToken (TokenType.TypeRef, 0);
- }
-
- public MetadataToken GetMemberRefToken (MemberReference member)
- {
- if (member is MethodSpecification)
- return GetMemberRefToken (((MethodSpecification) member).ElementMethod);
- if (member is IMemberDefinition)
- return member.MetadataToken;
- if (m_memberRefTokenCache.Contains (member))
- return (MetadataToken) m_memberRefTokenCache [member];
-
- MemberRefTable mrTable = m_tableWriter.GetMemberRefTable ();
-
- uint sig = 0;
- if (member is FieldReference)
- sig = m_sigWriter.AddFieldSig (GetFieldSig ((FieldReference) member));
- else if (member is MethodReference)
- sig = m_sigWriter.AddMethodRefSig (GetMethodRefSig ((MethodReference) member));
-
- MetadataToken declaringType = GetTypeDefOrRefToken (member.DeclaringType);
- uint name = m_mdWriter.AddString (member.Name);
-
- for (int i = 0; i < mrTable.Rows.Count; i++) {
- MemberRefRow row = mrTable [i];
- if (row.Class == declaringType && row.Name == name && row.Signature == sig)
- return MetadataToken.FromMetadataRow (TokenType.MemberRef, i);
- }
-
- MemberRefRow mrRow = m_rowWriter.CreateMemberRefRow (
- declaringType,
- name,
- sig);
-
- mrTable.Rows.Add (mrRow);
- member.MetadataToken = new MetadataToken (
- TokenType.MemberRef, (uint) mrTable.Rows.Count);
- m_memberRefTokenCache [member] = member.MetadataToken;
- return member.MetadataToken;
- }
-
- public MetadataToken GetMethodSpecToken (GenericInstanceMethod gim)
- {
- uint sig = m_sigWriter.AddMethodSpec (GetMethodSpecSig (gim));
- MethodSpecTable msTable = m_tableWriter.GetMethodSpecTable ();
-
- MetadataToken meth = GetMemberRefToken (gim.ElementMethod);
-
- for (int i = 0; i < msTable.Rows.Count; i++) {
- MethodSpecRow row = msTable [i];
- if (row.Method == meth && row.Instantiation == sig)
- return MetadataToken.FromMetadataRow (TokenType.MethodSpec, i);
- }
-
- MethodSpecRow msRow = m_rowWriter.CreateMethodSpecRow (
- meth,
- sig);
- msTable.Rows.Add (msRow);
- gim.MetadataToken = new MetadataToken (TokenType.MethodSpec, (uint) msTable.Rows.Count);
- return gim.MetadataToken;
- }
-
- public override void VisitModuleDefinition (ModuleDefinition mod)
- {
- mod.FullLoad ();
- }
-
- public override void VisitTypeDefinitionCollection (TypeDefinitionCollection types)
- {
- TypeDefTable tdTable = m_tableWriter.GetTypeDefTable ();
-
- if (types [Constants.ModuleType] == null)
- types.Add (new TypeDefinition (
- Constants.ModuleType, string.Empty, TypeAttributes.NotPublic));
-
- foreach (TypeDefinition t in types)
- m_typeDefStack.Add (t);
-
- m_typeDefStack.Sort (TableComparers.TypeDef.Instance);
-
- for (int i = 0; i < m_typeDefStack.Count; i++) {
- TypeDefinition t = (TypeDefinition) m_typeDefStack [i];
- if (t.Module.Assembly != m_mod.Assembly)
- throw new ReflectionException ("A type as not been correctly imported");
-
- t.MetadataToken = new MetadataToken (TokenType.TypeDef, (uint) (i + 1));
- }
-
- foreach (TypeDefinition t in m_typeDefStack) {
- TypeDefRow tdRow = m_rowWriter.CreateTypeDefRow (
- t.Attributes,
- m_mdWriter.AddString (t.Name),
- m_mdWriter.AddString (t.Namespace),
- GetTypeDefOrRefToken (t.BaseType),
- 0,
- 0);
-
- tdTable.Rows.Add (tdRow);
- }
- }
-
- public void CompleteTypeDefinitions ()
- {
- TypeDefTable tdTable = m_tableWriter.GetTypeDefTable ();
-
- for (int i = 0; i < m_typeDefStack.Count; i++) {
- TypeDefRow tdRow = tdTable [i];
- TypeDefinition t = (TypeDefinition) m_typeDefStack [i];
- tdRow.FieldList = m_fieldIndex;
- tdRow.MethodList = m_methodIndex;
- foreach (FieldDefinition field in t.Fields)
- VisitFieldDefinition (field);
- foreach (MethodDefinition ctor in t.Constructors)
- VisitMethodDefinition (ctor);
- foreach (MethodDefinition meth in t.Methods)
- VisitMethodDefinition (meth);
-
- if (t.HasLayoutInfo)
- WriteLayout (t);
- }
-
- foreach (FieldDefinition field in m_fieldStack) {
- VisitCustomAttributeCollection (field.CustomAttributes);
- if (field.MarshalSpec != null)
- VisitMarshalSpec (field.MarshalSpec);
- }
-
- foreach (MethodDefinition meth in m_methodStack) {
- VisitCustomAttributeCollection (meth.ReturnType.CustomAttributes);
- foreach (ParameterDefinition param in meth.Parameters)
- VisitCustomAttributeCollection (param.CustomAttributes);
- VisitGenericParameterCollection (meth.GenericParameters);
- VisitOverrideCollection (meth.Overrides);
- VisitCustomAttributeCollection (meth.CustomAttributes);
- VisitSecurityDeclarationCollection (meth.SecurityDeclarations);
- if (meth.PInvokeInfo != null) {
- meth.Attributes |= MethodAttributes.PInvokeImpl;
- VisitPInvokeInfo (meth.PInvokeInfo);
- }
- }
-
- foreach (TypeDefinition t in m_typeDefStack)
- t.Accept (this);
- }
-
- public override void VisitTypeReferenceCollection (TypeReferenceCollection refs)
- {
- ArrayList orderedTypeRefs = new ArrayList (refs.Count);
- foreach (TypeReference tr in refs)
- orderedTypeRefs.Add (tr);
-
- orderedTypeRefs.Sort (TableComparers.TypeRef.Instance);
-
- TypeRefTable trTable = m_tableWriter.GetTypeRefTable ();
- foreach (TypeReference t in orderedTypeRefs) {
- MetadataToken scope;
-
- if (t.Module.Assembly != m_mod.Assembly)
- throw new ReflectionException ("A type as not been correctly imported");
-
- if (t.Scope == null)
- continue;
-
- if (t.DeclaringType != null)
- scope = new MetadataToken (TokenType.TypeRef, GetRidFor (t.DeclaringType));
- else if (t.Scope is AssemblyNameReference)
- scope = new MetadataToken (TokenType.AssemblyRef,
- GetRidFor ((AssemblyNameReference) t.Scope));
- else if (t.Scope is ModuleDefinition)
- scope = new MetadataToken (TokenType.Module,
- GetRidFor ((ModuleDefinition) t.Scope));
- else if (t.Scope is ModuleReference)
- scope = new MetadataToken (TokenType.ModuleRef,
- GetRidFor ((ModuleReference) t.Scope));
- else
- scope = new MetadataToken (TokenType.ExportedType, 0);
-
- TypeRefRow trRow = m_rowWriter.CreateTypeRefRow (
- scope,
- m_mdWriter.AddString (t.Name),
- m_mdWriter.AddString (t.Namespace));
-
- trTable.Rows.Add (trRow);
- t.MetadataToken = new MetadataToken (TokenType.TypeRef, (uint) trTable.Rows.Count);
- }
- }
-
- public override void VisitGenericParameterCollection (GenericParameterCollection parameters)
- {
- if (parameters.Count == 0)
- return;
-
- foreach (GenericParameter gp in parameters)
- m_genericParamStack.Add (gp);
- }
-
- public override void VisitInterfaceCollection (InterfaceCollection interfaces)
- {
- if (interfaces.Count == 0)
- return;
-
- InterfaceImplTable iiTable = m_tableWriter.GetInterfaceImplTable ();
- foreach (TypeReference interf in interfaces) {
- InterfaceImplRow iiRow = m_rowWriter.CreateInterfaceImplRow (
- GetRidFor (interfaces.Container),
- GetTypeDefOrRefToken (interf));
-
- iiTable.Rows.Add (iiRow);
- }
- }
-
- public override void VisitExternTypeCollection (ExternTypeCollection externs)
- {
- VisitCollection (externs);
- }
-
- public override void VisitExternType (TypeReference externType)
- {
- // TODO
- }
-
- public override void VisitOverrideCollection (OverrideCollection meths)
- {
- if (meths.Count == 0)
- return;
-
- MethodImplTable miTable = m_tableWriter.GetMethodImplTable ();
- foreach (MethodReference ov in meths) {
- MethodImplRow miRow = m_rowWriter.CreateMethodImplRow (
- GetRidFor (meths.Container.DeclaringType as TypeDefinition),
- new MetadataToken (TokenType.Method, GetRidFor (meths.Container)),
- GetMemberRefToken (ov));
-
- miTable.Rows.Add (miRow);
- }
- }
-
- public override void VisitNestedTypeCollection (NestedTypeCollection nestedTypes)
- {
- if (nestedTypes.Count == 0)
- return;
-
- NestedClassTable ncTable = m_tableWriter.GetNestedClassTable ();
- foreach (TypeDefinition nested in nestedTypes) {
- NestedClassRow ncRow = m_rowWriter.CreateNestedClassRow (
- nested.MetadataToken.RID,
- GetRidFor (nestedTypes.Container));
-
- ncTable.Rows.Add (ncRow);
- }
- }
-
- public override void VisitParameterDefinitionCollection (ParameterDefinitionCollection parameters)
- {
- if (parameters.Count == 0)
- return;
-
- ushort seq = 1;
- ParamTable pTable = m_tableWriter.GetParamTable ();
- foreach (ParameterDefinition param in parameters)
- InsertParameter (pTable, param, seq++);
- }
-
- void InsertParameter (ParamTable pTable, ParameterDefinition param, ushort seq)
- {
- ParamRow pRow = m_rowWriter.CreateParamRow (
- param.Attributes,
- seq,
- m_mdWriter.AddString (param.Name));
-
- pTable.Rows.Add (pRow);
- param.MetadataToken = new MetadataToken (TokenType.Param, (uint) pTable.Rows.Count);
-
- if (param.MarshalSpec != null)
- param.MarshalSpec.Accept (this);
-
- if (param.HasConstant)
- WriteConstant (param, param.ParameterType);
-
- m_paramIndex++;
- }
-
- static bool RequiresParameterRow (MethodReturnType mrt)
- {
- return mrt.HasConstant || mrt.MarshalSpec != null ||
- mrt.CustomAttributes.Count > 0 || mrt.Parameter.Attributes != (ParameterAttributes) 0;
- }
-
- public override void VisitMethodDefinition (MethodDefinition method)
- {
- MethodTable mTable = m_tableWriter.GetMethodTable ();
- MethodRow mRow = m_rowWriter.CreateMethodRow (
- RVA.Zero,
- method.ImplAttributes,
- method.Attributes,
- m_mdWriter.AddString (method.Name),
- m_sigWriter.AddMethodDefSig (GetMethodDefSig (method)),
- m_paramIndex);
-
- mTable.Rows.Add (mRow);
- m_methodStack.Add (method);
- method.MetadataToken = new MetadataToken (TokenType.Method, (uint) mTable.Rows.Count);
- m_methodIndex++;
-
- if (RequiresParameterRow (method.ReturnType))
- InsertParameter (m_tableWriter.GetParamTable (), method.ReturnType.Parameter, 0);
-
- VisitParameterDefinitionCollection (method.Parameters);
- }
-
- public override void VisitPInvokeInfo (PInvokeInfo pinvk)
- {
- ImplMapTable imTable = m_tableWriter.GetImplMapTable ();
- ImplMapRow imRow = m_rowWriter.CreateImplMapRow (
- pinvk.Attributes,
- new MetadataToken (TokenType.Method, GetRidFor (pinvk.Method)),
- m_mdWriter.AddString (pinvk.EntryPoint),
- GetRidFor (pinvk.Module));
-
- imTable.Rows.Add (imRow);
- }
-
- public override void VisitEventDefinitionCollection (EventDefinitionCollection events)
- {
- if (events.Count == 0)
- return;
-
- EventMapTable emTable = m_tableWriter.GetEventMapTable ();
- EventMapRow emRow = m_rowWriter.CreateEventMapRow (
- GetRidFor (events.Container),
- m_eventIndex);
-
- emTable.Rows.Add (emRow);
- VisitCollection (events);
- }
-
- public override void VisitEventDefinition (EventDefinition evt)
- {
- EventTable eTable = m_tableWriter.GetEventTable ();
- EventRow eRow = m_rowWriter.CreateEventRow (
- evt.Attributes,
- m_mdWriter.AddString (evt.Name),
- GetTypeDefOrRefToken (evt.EventType));
-
- eTable.Rows.Add (eRow);
- evt.MetadataToken = new MetadataToken (TokenType.Event, (uint) eTable.Rows.Count);
-
- if (evt.AddMethod != null)
- WriteSemantic (MethodSemanticsAttributes.AddOn, evt, evt.AddMethod);
-
- if (evt.InvokeMethod != null)
- WriteSemantic (MethodSemanticsAttributes.Fire, evt, evt.InvokeMethod);
-
- if (evt.RemoveMethod != null)
- WriteSemantic (MethodSemanticsAttributes.RemoveOn, evt, evt.RemoveMethod);
-
- m_eventIndex++;
- }
-
- public override void VisitFieldDefinition (FieldDefinition field)
- {
- FieldTable fTable = m_tableWriter.GetFieldTable ();
- FieldRow fRow = m_rowWriter.CreateFieldRow (
- field.Attributes,
- m_mdWriter.AddString (field.Name),
- m_sigWriter.AddFieldSig (GetFieldSig (field)));
-
- fTable.Rows.Add (fRow);
- field.MetadataToken = new MetadataToken (TokenType.Field, (uint) fTable.Rows.Count);
- m_fieldIndex++;
-
- if (field.HasConstant)
- WriteConstant (field, field.FieldType);
-
- if (field.HasLayoutInfo)
- WriteLayout (field);
-
- m_fieldStack.Add (field);
- }
-
- public override void VisitPropertyDefinitionCollection (PropertyDefinitionCollection properties)
- {
- if (properties.Count == 0)
- return;
-
- PropertyMapTable pmTable = m_tableWriter.GetPropertyMapTable ();
- PropertyMapRow pmRow = m_rowWriter.CreatePropertyMapRow (
- GetRidFor (properties.Container),
- m_propertyIndex);
-
- pmTable.Rows.Add (pmRow);
- VisitCollection (properties);
- }
-
- public override void VisitPropertyDefinition (PropertyDefinition property)
- {
- PropertyTable pTable = m_tableWriter.GetPropertyTable ();
- PropertyRow pRow = m_rowWriter.CreatePropertyRow (
- property.Attributes,
- m_mdWriter.AddString (property.Name),
- m_sigWriter.AddPropertySig (GetPropertySig (property)));
-
- pTable.Rows.Add (pRow);
- property.MetadataToken = new MetadataToken (TokenType.Property, (uint) pTable.Rows.Count);
-
- if (property.GetMethod != null)
- WriteSemantic (MethodSemanticsAttributes.Getter, property, property.GetMethod);
-
- if (property.SetMethod != null)
- WriteSemantic (MethodSemanticsAttributes.Setter, property, property.SetMethod);
-
- if (property.HasConstant)
- WriteConstant (property, property.PropertyType);
-
- m_propertyIndex++;
- }
-
- public override void VisitSecurityDeclarationCollection (SecurityDeclarationCollection secDecls)
- {
- if (secDecls.Count == 0)
- return;
-
- DeclSecurityTable dsTable = m_tableWriter.GetDeclSecurityTable ();
- foreach (SecurityDeclaration secDec in secDecls) {
- DeclSecurityRow dsRow = m_rowWriter.CreateDeclSecurityRow (
- secDec.Action,
- secDecls.Container.MetadataToken,
- m_mdWriter.AddBlob (secDec.Resolved ?
- m_mod.GetAsByteArray (secDec) : secDec.Blob));
-
- dsTable.Rows.Add (dsRow);
- }
- }
-
- public override void VisitCustomAttributeCollection (CustomAttributeCollection customAttrs)
- {
- if (customAttrs.Count == 0)
- return;
-
- CustomAttributeTable caTable = m_tableWriter.GetCustomAttributeTable ();
- foreach (CustomAttribute ca in customAttrs) {
- MetadataToken parent;
- if (customAttrs.Container is AssemblyDefinition)
- parent = new MetadataToken (TokenType.Assembly, 1);
- else if (customAttrs.Container is ModuleDefinition)
- parent = new MetadataToken (TokenType.Module, 1);
- else if (customAttrs.Container is IMetadataTokenProvider)
- parent = ((IMetadataTokenProvider) customAttrs.Container).MetadataToken;
- else
- throw new ReflectionException ("Unknown Custom Attribute parent");
-
- uint value = ca.Resolved ?
- m_sigWriter.AddCustomAttribute (GetCustomAttributeSig (ca), ca.Constructor) :
- m_mdWriter.AddBlob (m_mod.GetAsByteArray (ca));
- CustomAttributeRow caRow = m_rowWriter.CreateCustomAttributeRow (
- parent,
- GetMemberRefToken (ca.Constructor),
- value);
-
- caTable.Rows.Add (caRow);
- }
- }
-
- public override void VisitMarshalSpec (MarshalSpec marshalSpec)
- {
- FieldMarshalTable fmTable = m_tableWriter.GetFieldMarshalTable ();
- FieldMarshalRow fmRow = m_rowWriter.CreateFieldMarshalRow (
- marshalSpec.Container.MetadataToken,
- m_sigWriter.AddMarshalSig (GetMarshalSig (marshalSpec)));
-
- fmTable.Rows.Add (fmRow);
- }
-
- void WriteConstant (IHasConstant hc, TypeReference type)
- {
- ConstantTable cTable = m_tableWriter.GetConstantTable ();
- ElementType et;
- if (type is TypeDefinition && (type as TypeDefinition).IsEnum) {
- Type t = hc.Constant.GetType ();
- if (t.IsEnum)
- t = Enum.GetUnderlyingType (t);
-
- et = GetCorrespondingType (string.Concat (t.Namespace, '.', t.Name));
- } else
- et = GetCorrespondingType (type.FullName);
-
- if (et == ElementType.Object)
- et = hc.Constant == null ?
- ElementType.Class :
- GetCorrespondingType (hc.Constant.GetType ().FullName);
-
- ConstantRow cRow = m_rowWriter.CreateConstantRow (
- et,
- hc.MetadataToken,
- m_mdWriter.AddBlob (EncodeConstant (et, hc.Constant)));
-
- cTable.Rows.Add (cRow);
- }
-
- void WriteLayout (FieldDefinition field)
- {
- FieldLayoutTable flTable = m_tableWriter.GetFieldLayoutTable ();
- FieldLayoutRow flRow = m_rowWriter.CreateFieldLayoutRow (
- field.Offset,
- GetRidFor (field));
-
- flTable.Rows.Add (flRow);
- }
-
- void WriteLayout (TypeDefinition type)
- {
- ClassLayoutTable clTable = m_tableWriter.GetClassLayoutTable ();
- ClassLayoutRow clRow = m_rowWriter.CreateClassLayoutRow (
- type.PackingSize,
- type.ClassSize,
- GetRidFor (type));
-
- clTable.Rows.Add (clRow);
- }
-
- void WriteSemantic (MethodSemanticsAttributes attrs,
- IMetadataTokenProvider member, MethodDefinition meth)
- {
- MethodSemanticsTable msTable = m_tableWriter.GetMethodSemanticsTable ();
- MethodSemanticsRow msRow = m_rowWriter.CreateMethodSemanticsRow (
- attrs,
- GetRidFor (meth),
- member.MetadataToken);
-
- msTable.Rows.Add (msRow);
- }
-
- void SortTables ()
- {
- TablesHeap th = m_mdWriter.GetMetadataRoot ().Streams.TablesHeap;
- th.Sorted = 0;
-
- if (th.HasTable (NestedClassTable.RId))
- m_tableWriter.GetNestedClassTable ().Rows.Sort (
- TableComparers.NestedClass.Instance);
- th.Sorted |= ((long) 1 << NestedClassTable.RId);
-
- if (th.HasTable (InterfaceImplTable.RId))
- m_tableWriter.GetInterfaceImplTable ().Rows.Sort (
- TableComparers.InterfaceImpl.Instance);
- th.Sorted |= ((long) 1 << InterfaceImplTable.RId);
-
- if (th.HasTable (ConstantTable.RId))
- m_tableWriter.GetConstantTable ().Rows.Sort (
- TableComparers.Constant.Instance);
- th.Sorted |= ((long) 1 << ConstantTable.RId);
-
- if (th.HasTable (MethodSemanticsTable.RId))
- m_tableWriter.GetMethodSemanticsTable ().Rows.Sort (
- TableComparers.MethodSem.Instance);
- th.Sorted |= ((long) 1 << MethodSemanticsTable.RId);
-
- if (th.HasTable (FieldMarshalTable.RId))
- m_tableWriter.GetFieldMarshalTable ().Rows.Sort (
- TableComparers.FieldMarshal.Instance);
- th.Sorted |= ((long) 1 << FieldMarshalTable.RId);
-
- if (th.HasTable (ClassLayoutTable.RId))
- m_tableWriter.GetClassLayoutTable ().Rows.Sort (
- TableComparers.TypeLayout.Instance);
- th.Sorted |= ((long) 1 << ClassLayoutTable.RId);
-
- if (th.HasTable (FieldLayoutTable.RId))
- m_tableWriter.GetFieldLayoutTable ().Rows.Sort (
- TableComparers.FieldLayout.Instance);
- th.Sorted |= ((long) 1 << FieldLayoutTable.RId);
-
- if (th.HasTable (ImplMapTable.RId))
- m_tableWriter.GetImplMapTable ().Rows.Sort (
- TableComparers.PInvoke.Instance);
- th.Sorted |= ((long) 1 << ImplMapTable.RId);
-
- if (th.HasTable (FieldRVATable.RId))
- m_tableWriter.GetFieldRVATable ().Rows.Sort (
- TableComparers.FieldRVA.Instance);
- th.Sorted |= ((long) 1 << FieldRVATable.RId);
-
- if (th.HasTable (MethodImplTable.RId))
- m_tableWriter.GetMethodImplTable ().Rows.Sort (
- TableComparers.Override.Instance);
- th.Sorted |= ((long) 1 << MethodImplTable.RId);
-
- if (th.HasTable (CustomAttributeTable.RId))
- m_tableWriter.GetCustomAttributeTable ().Rows.Sort (
- TableComparers.CustomAttribute.Instance);
- th.Sorted |= ((long) 1 << CustomAttributeTable.RId);
-
- if (th.HasTable (DeclSecurityTable.RId))
- m_tableWriter.GetDeclSecurityTable ().Rows.Sort (
- TableComparers.SecurityDeclaration.Instance);
- th.Sorted |= ((long) 1 << DeclSecurityTable.RId);
- }
-
- void CompleteGenericTables ()
- {
- if (m_genericParamStack.Count == 0)
- return;
-
- TablesHeap th = m_mdWriter.GetMetadataRoot ().Streams.TablesHeap;
- GenericParamTable gpTable = m_tableWriter.GetGenericParamTable ();
- GenericParamConstraintTable gpcTable = m_tableWriter.GetGenericParamConstraintTable ();
-
- m_genericParamStack.Sort (TableComparers.GenericParam.Instance);
-
- foreach (GenericParameter gp in m_genericParamStack) {
- GenericParamRow gpRow = m_rowWriter.CreateGenericParamRow (
- (ushort) gp.Owner.GenericParameters.IndexOf (gp),
- gp.Attributes,
- gp.Owner.MetadataToken,
- m_mdWriter.AddString (gp.Name));
-
- gpTable.Rows.Add (gpRow);
- gp.MetadataToken = new MetadataToken (TokenType.GenericParam, (uint) gpTable.Rows.Count);
-
- VisitCustomAttributeCollection (gp.CustomAttributes);
-
- if (gp.Constraints.Count == 0)
- continue;
-
- foreach (TypeReference constraint in gp.Constraints) {
- GenericParamConstraintRow gpcRow = m_rowWriter.CreateGenericParamConstraintRow (
- (uint) gpTable.Rows.Count,
- GetTypeDefOrRefToken (constraint));
-
- gpcTable.Rows.Add (gpcRow);
- }
- }
-
- th.Sorted |= ((long) 1 << GenericParamTable.RId);
- th.Sorted |= ((long) 1 << GenericParamConstraintTable.RId);
- }
-
- public override void TerminateModuleDefinition (ModuleDefinition module)
- {
- VisitCustomAttributeCollection (module.Assembly.CustomAttributes);
- VisitSecurityDeclarationCollection (module.Assembly.SecurityDeclarations);
- VisitCustomAttributeCollection (module.CustomAttributes);
-
- CompleteGenericTables ();
- SortTables ();
-
- MethodTable mTable = m_tableWriter.GetMethodTable ();
- for (int i = 0; i < m_methodStack.Count; i++) {
- MethodDefinition meth = (MethodDefinition) m_methodStack [i];
- if (meth.HasBody)
- mTable [i].RVA = m_codeWriter.WriteMethodBody (meth);
- }
-
- if (m_fieldStack.Count > 0) {
- FieldRVATable frTable = null;
- foreach (FieldDefinition field in m_fieldStack) {
- if (field.InitialValue != null && field.InitialValue.Length > 0) {
- if (frTable == null)
- frTable = m_tableWriter.GetFieldRVATable ();
-
- FieldRVARow frRow = m_rowWriter.CreateFieldRVARow (
- m_mdWriter.GetDataCursor (),
- field.MetadataToken.RID);
-
- m_mdWriter.AddData (field.InitialValue.Length + 3 & (~3));
- m_mdWriter.AddFieldInitData (field.InitialValue);
-
- frTable.Rows.Add (frRow);
- }
- }
- }
-
- if (m_symbolWriter != null)
- m_symbolWriter.Dispose ();
-
- if (m_mod.Assembly.EntryPoint != null)
- m_mdWriter.EntryPointToken =
- ((uint) TokenType.Method) | GetRidFor (m_mod.Assembly.EntryPoint);
-
- m_mod.Image.MetadataRoot.Accept (m_mdWriter);
- }
-
- public static ElementType GetCorrespondingType (string fullName)
- {
- switch (fullName) {
- case Constants.Boolean :
- return ElementType.Boolean;
- case Constants.Char :
- return ElementType.Char;
- case Constants.SByte :
- return ElementType.I1;
- case Constants.Int16 :
- return ElementType.I2;
- case Constants.Int32 :
- return ElementType.I4;
- case Constants.Int64 :
- return ElementType.I8;
- case Constants.Byte :
- return ElementType.U1;
- case Constants.UInt16 :
- return ElementType.U2;
- case Constants.UInt32 :
- return ElementType.U4;
- case Constants.UInt64 :
- return ElementType.U8;
- case Constants.Single :
- return ElementType.R4;
- case Constants.Double :
- return ElementType.R8;
- case Constants.String :
- return ElementType.String;
- case Constants.Type :
- return ElementType.Type;
- case Constants.Object :
- return ElementType.Object;
- default:
- return ElementType.Class;
- }
- }
-
- byte [] EncodeConstant (ElementType et, object value)
- {
- m_constWriter.Empty ();
-
- if (value == null)
- et = ElementType.Class;
-
- IConvertible ic = value as IConvertible;
- IFormatProvider fp = CultureInfo.CurrentCulture.NumberFormat;
-
- switch (et) {
- case ElementType.Boolean :
- m_constWriter.Write ((byte) (ic.ToBoolean (fp) ? 1 : 0));
- break;
- case ElementType.Char :
- m_constWriter.Write ((ushort) ic.ToChar (fp));
- break;
- case ElementType.I1 :
- m_constWriter.Write (ic.ToSByte (fp));
- break;
- case ElementType.I2 :
- m_constWriter.Write (ic.ToInt16 (fp));
- break;
- case ElementType.I4 :
- m_constWriter.Write (ic.ToInt32 (fp));
- break;
- case ElementType.I8 :
- m_constWriter.Write (ic.ToInt64 (fp));
- break;
- case ElementType.U1 :
- m_constWriter.Write (ic.ToByte (fp));
- break;
- case ElementType.U2 :
- m_constWriter.Write (ic.ToUInt16 (fp));
- break;
- case ElementType.U4 :
- m_constWriter.Write (ic.ToUInt32 (fp));
- break;
- case ElementType.U8 :
- m_constWriter.Write (ic.ToUInt64 (fp));
- break;
- case ElementType.R4 :
- m_constWriter.Write (ic.ToSingle (fp));
- break;
- case ElementType.R8 :
- m_constWriter.Write (ic.ToDouble (fp));
- break;
- case ElementType.String :
- m_constWriter.Write (Encoding.Unicode.GetBytes ((string) value));
- break;
- case ElementType.Class :
- m_constWriter.Write (new byte [4]);
- break;
- default :
- throw new ArgumentException ("Non valid element for a constant");
- }
-
- return m_constWriter.ToArray ();
- }
-
- public SigType GetSigType (TypeReference type)
- {
- string name = type.FullName;
-
- switch (name) {
- case Constants.Void :
- return new SigType (ElementType.Void);
- case Constants.Object :
- return new SigType (ElementType.Object);
- case Constants.Boolean :
- return new SigType (ElementType.Boolean);
- case Constants.String :
- return new SigType (ElementType.String);
- case Constants.Char :
- return new SigType (ElementType.Char);
- case Constants.SByte :
- return new SigType (ElementType.I1);
- case Constants.Byte :
- return new SigType (ElementType.U1);
- case Constants.Int16 :
- return new SigType (ElementType.I2);
- case Constants.UInt16 :
- return new SigType (ElementType.U2);
- case Constants.Int32 :
- return new SigType (ElementType.I4);
- case Constants.UInt32 :
- return new SigType (ElementType.U4);
- case Constants.Int64 :
- return new SigType (ElementType.I8);
- case Constants.UInt64 :
- return new SigType (ElementType.U8);
- case Constants.Single :
- return new SigType (ElementType.R4);
- case Constants.Double :
- return new SigType (ElementType.R8);
- case Constants.IntPtr :
- return new SigType (ElementType.I);
- case Constants.UIntPtr :
- return new SigType (ElementType.U);
- case Constants.TypedReference :
- return new SigType (ElementType.TypedByRef);
- }
-
- if (type is GenericParameter) {
- GenericParameter gp = type as GenericParameter;
- int pos = gp.Owner.GenericParameters.IndexOf (gp);
- if (gp.Owner is TypeReference)
- return new VAR (pos);
- else if (gp.Owner is MethodReference)
- return new MVAR (pos);
- else
- throw new ReflectionException ("Unkown generic parameter type");
- } else if (type is GenericInstanceType) {
- GenericInstanceType git = type as GenericInstanceType;
- GENERICINST gi = new GENERICINST ();
- gi.ValueType = git.IsValueType;
- gi.Type = GetTypeDefOrRefToken (git.ElementType);
- gi.Signature = new GenericInstSignature ();
- gi.Signature.Arity = git.GenericArguments.Count;
- gi.Signature.Types = new GenericArg [gi.Signature.Arity];
- for (int i = 0; i < git.GenericArguments.Count; i++)
- gi.Signature.Types [i] = GetGenericArgSig (git.GenericArguments [i]);
-
- return gi;
- } else if (type is ArrayType) {
- ArrayType aryType = type as ArrayType;
- if (aryType.IsSizedArray) {
- SZARRAY szary = new SZARRAY ();
- szary.CustomMods = GetCustomMods (aryType.ElementType);
- szary.Type = GetSigType (aryType.ElementType);
- return szary;
- }
-
- // not optimized
- ArrayShape shape = new ArrayShape ();
- shape.Rank = aryType.Dimensions.Count;
- shape.NumSizes = 0;
-
- for (int i = 0; i < shape.Rank; i++) {
- ArrayDimension dim = aryType.Dimensions [i];
- if (dim.UpperBound > 0)
- shape.NumSizes++;
- }
-
- shape.Sizes = new int [shape.NumSizes];
- shape.NumLoBounds = shape.Rank;
- shape.LoBounds = new int [shape.NumLoBounds];
-
- for (int i = 0; i < shape.Rank; i++) {
- ArrayDimension dim = aryType.Dimensions [i];
- shape.LoBounds [i] = dim.LowerBound;
- if (dim.UpperBound > 0)
- shape.Sizes [i] = dim.UpperBound - dim.LowerBound + 1;
- }
-
- ARRAY ary = new ARRAY ();
- ary.Shape = shape;
- ary.CustomMods = GetCustomMods (aryType.ElementType);
- ary.Type = GetSigType (aryType.ElementType);
- return ary;
- } else if (type is PointerType) {
- PTR p = new PTR ();
- TypeReference elementType = (type as PointerType).ElementType;
- p.Void = elementType.FullName == Constants.Void;
- if (!p.Void) {
- p.CustomMods = GetCustomMods (elementType);
- p.PtrType = GetSigType (elementType);
- }
- return p;
- } else if (type is FunctionPointerType) {
- FNPTR fp = new FNPTR ();
- FunctionPointerType fptr = type as FunctionPointerType;
-
- int sentinel = fptr.GetSentinel ();
- if (sentinel < 0)
- fp.Method = GetMethodDefSig (fptr);
- else
- fp.Method = GetMethodRefSig (fptr);
-
- return fp;
- } else if (type is TypeSpecification) {
- return GetSigType ((type as TypeSpecification).ElementType);
- } else if (type.IsValueType) {
- VALUETYPE vt = new VALUETYPE ();
- vt.Type = GetTypeDefOrRefToken (type);
- return vt;
- } else {
- CLASS c = new CLASS ();
- c.Type = GetTypeDefOrRefToken (type);
- return c;
- }
- }
-
- public GenericArg GetGenericArgSig (TypeReference type)
- {
- GenericArg arg = new GenericArg (GetSigType (type));
- arg.CustomMods = GetCustomMods (type);
- return arg;
- }
-
- public CustomMod [] GetCustomMods (TypeReference type)
- {
- ModType modifier = type as ModType;
- if (modifier == null)
- return new CustomMod [0];
-
- ArrayList cmods = new ArrayList ();
- do {
- CustomMod cmod = new CustomMod ();
- cmod.TypeDefOrRef = GetTypeDefOrRefToken (modifier.ModifierType);
-
- if (modifier is ModifierOptional)
- cmod.CMOD = CustomMod.CMODType.OPT;
- else if (modifier is ModifierRequired)
- cmod.CMOD = CustomMod.CMODType.REQD;
-
- cmods.Add (cmod);
- modifier = modifier.ElementType as ModType;
- } while (modifier != null);
-
- return cmods.ToArray (typeof (CustomMod)) as CustomMod [];
- }
-
- public Signature GetMemberRefSig (MemberReference member)
- {
- if (member is FieldReference)
- return GetFieldSig (member as FieldReference);
- else
- return GetMemberRefSig (member as MethodReference);
- }
-
- public FieldSig GetFieldSig (FieldReference field)
- {
- FieldSig sig = new FieldSig ();
- sig.CallingConvention |= 0x6;
- sig.Field = true;
- sig.CustomMods = GetCustomMods (field.FieldType);
- sig.Type = GetSigType (field.FieldType);
- return sig;
- }
-
- Param [] GetParametersSig (ParameterDefinitionCollection parameters)
- {
- Param [] ret = new Param [parameters.Count];
- for (int i = 0; i < ret.Length; i++) {
- ParameterDefinition pDef = parameters [i];
- Param p = new Param ();
- p.CustomMods = GetCustomMods (pDef.ParameterType);
- if (pDef.ParameterType.FullName == Constants.TypedReference)
- p.TypedByRef = true;
- else if (IsByReferenceType (pDef.ParameterType)) {
- p.ByRef = true;
- p.Type = GetSigType (pDef.ParameterType);
- } else
- p.Type = GetSigType (pDef.ParameterType);
- ret [i] = p;
- }
- return ret;
- }
-
- void CompleteMethodSig (IMethodSignature meth, MethodSig sig)
- {
- sig.HasThis = meth.HasThis;
- sig.ExplicitThis = meth.ExplicitThis;
- if (sig.HasThis)
- sig.CallingConvention |= 0x20;
- if (sig.ExplicitThis)
- sig.CallingConvention |= 0x40;
-
- if ((meth.CallingConvention & MethodCallingConvention.VarArg) != 0)
- sig.CallingConvention |= 0x5;
-
- sig.ParamCount = meth.Parameters.Count;
- sig.Parameters = GetParametersSig (meth.Parameters);
-
- RetType rtSig = new RetType ();
- rtSig.CustomMods = GetCustomMods (meth.ReturnType.ReturnType);
-
- if (meth.ReturnType.ReturnType.FullName == Constants.Void)
- rtSig.Void = true;
- else if (meth.ReturnType.ReturnType.FullName == Constants.TypedReference)
- rtSig.TypedByRef = true;
- else if (IsByReferenceType (meth.ReturnType.ReturnType)) {
- rtSig.ByRef = true;
- rtSig.Type = GetSigType (meth.ReturnType.ReturnType);
- } else
- rtSig.Type = GetSigType (meth.ReturnType.ReturnType);
-
- sig.RetType = rtSig;
- }
-
- static bool IsByReferenceType (TypeReference type)
- {
- TypeSpecification ts = type as TypeSpecification;
- while (ts != null) {
- if (ts is ReferenceType)
- return true;
- ts = ts.ElementType as TypeSpecification;
- }
- return false;
- }
-
- public MethodRefSig GetMethodRefSig (IMethodSignature meth)
- {
- MethodReference methodRef = meth as MethodReference;
- if (methodRef != null && methodRef.GenericParameters.Count > 0)
- return GetMethodDefSig (meth);
-
- MethodRefSig methSig = new MethodRefSig ();
-
- CompleteMethodSig (meth, methSig);
-
- int sentinel = meth.GetSentinel ();
- if (sentinel >= 0)
- methSig.Sentinel = sentinel;
-
- if ((meth.CallingConvention & MethodCallingConvention.C) != 0)
- methSig.CallingConvention |= 0x1;
- else if ((meth.CallingConvention & MethodCallingConvention.StdCall) != 0)
- methSig.CallingConvention |= 0x2;
- else if ((meth.CallingConvention & MethodCallingConvention.ThisCall) != 0)
- methSig.CallingConvention |= 0x3;
- else if ((meth.CallingConvention & MethodCallingConvention.FastCall) != 0)
- methSig.CallingConvention |= 0x4;
-
- return methSig;
- }
-
- public MethodDefSig GetMethodDefSig (IMethodSignature meth)
- {
- MethodDefSig sig = new MethodDefSig ();
-
- CompleteMethodSig (meth, sig);
-
- MethodReference methodRef = meth as MethodReference;
- if (methodRef != null && methodRef.GenericParameters.Count > 0) {
- sig.CallingConvention |= 0x10;
- sig.GenericParameterCount = methodRef.GenericParameters.Count;
- }
-
- return sig;
- }
-
- public PropertySig GetPropertySig (PropertyDefinition prop)
- {
- PropertySig ps = new PropertySig ();
- ps.CallingConvention |= 0x8;
-
- bool hasThis;
- bool explicitThis;
- MethodCallingConvention mcc;
- ParameterDefinitionCollection parameters = prop.Parameters;
-
- MethodDefinition meth;
- if (prop.GetMethod != null)
- meth = prop.GetMethod;
- else if (prop.SetMethod != null)
- meth = prop.SetMethod;
- else
- meth = null;
-
- if (meth != null) {
- hasThis = meth.HasThis;
- explicitThis = meth.ExplicitThis;
- mcc = meth.CallingConvention;
- } else {
- hasThis = explicitThis = false;
- mcc = MethodCallingConvention.Default;
- }
-
- if (hasThis)
- ps.CallingConvention |= 0x20;
- if (explicitThis)
- ps.CallingConvention |= 0x40;
-
- if ((mcc & MethodCallingConvention.VarArg) != 0)
- ps.CallingConvention |= 0x5;
-
- int paramCount = parameters != null ? parameters.Count : 0;
-
- ps.ParamCount = paramCount;
- ps.Parameters = GetParametersSig (parameters);
- ps.CustomMods = GetCustomMods (prop.PropertyType);
- ps.Type = GetSigType (prop.PropertyType);
-
- return ps;
- }
-
- public TypeSpec GetTypeSpecSig (TypeReference type)
- {
- TypeSpec ts = new TypeSpec ();
- ts.CustomMods = GetCustomMods (type);
- ts.Type = GetSigType (type);
- return ts;
- }
-
- public MethodSpec GetMethodSpecSig (GenericInstanceMethod gim)
- {
- GenericInstSignature gis = new GenericInstSignature ();
- gis.Arity = gim.GenericArguments.Count;
- gis.Types = new GenericArg [gis.Arity];
- for (int i = 0; i < gis.Arity; i++)
- gis.Types [i] = GetGenericArgSig (gim.GenericArguments [i]);
-
- return new MethodSpec (gis);
- }
-
- static string GetObjectTypeName (object o)
- {
- Type t = o.GetType ();
- return string.Concat (t.Namespace, ".", t.Name);
- }
-
- static CustomAttrib.Elem CreateElem (TypeReference type, object value)
- {
- CustomAttrib.Elem elem = new CustomAttrib.Elem ();
- elem.Value = value;
- elem.ElemType = type;
- elem.FieldOrPropType = GetCorrespondingType (type.FullName);
-
- switch (elem.FieldOrPropType) {
- case ElementType.Boolean :
- case ElementType.Char :
- case ElementType.R4 :
- case ElementType.R8 :
- case ElementType.I1 :
- case ElementType.I2 :
- case ElementType.I4 :
- case ElementType.I8 :
- case ElementType.U1 :
- case ElementType.U2 :
- case ElementType.U4 :
- case ElementType.U8 :
- elem.Simple = true;
- break;
- case ElementType.String:
- elem.String = true;
- break;
- case ElementType.Type:
- elem.Type = true;
- break;
- case ElementType.Object:
- elem.BoxedValueType = true;
- if (value == null)
- elem.FieldOrPropType = ElementType.String;
- else
- elem.FieldOrPropType = GetCorrespondingType (
- GetObjectTypeName (value));
- break;
- }
-
- return elem;
- }
-
- static CustomAttrib.FixedArg CreateFixedArg (TypeReference type, object value)
- {
- CustomAttrib.FixedArg fa = new CustomAttrib.FixedArg ();
- if (value is object []) {
- fa.SzArray = true;
- object [] values = value as object [];
- TypeReference obj = ((ArrayType) type).ElementType;
- fa.NumElem = (uint) values.Length;
- fa.Elems = new CustomAttrib.Elem [values.Length];
- for (int i = 0; i < values.Length; i++)
- fa.Elems [i] = CreateElem (obj, values [i]);
- } else {
- fa.Elems = new CustomAttrib.Elem [1];
- fa.Elems [0] = CreateElem (type, value);
- }
-
- return fa;
- }
-
- static CustomAttrib.NamedArg CreateNamedArg (TypeReference type, string name,
- object value, bool field)
- {
- CustomAttrib.NamedArg na = new CustomAttrib.NamedArg ();
- na.Field = field;
- na.Property = !field;
-
- na.FieldOrPropName = name;
- na.FieldOrPropType = GetCorrespondingType (type.FullName);
- na.FixedArg = CreateFixedArg (type, value);
-
- return na;
- }
-
- public static CustomAttrib GetCustomAttributeSig (CustomAttribute ca)
- {
- CustomAttrib cas = new CustomAttrib (ca.Constructor);
- cas.Prolog = CustomAttrib.StdProlog;
-
- cas.FixedArgs = new CustomAttrib.FixedArg [ca.Constructor.Parameters.Count];
-
- for (int i = 0; i < cas.FixedArgs.Length; i++)
- cas.FixedArgs [i] = CreateFixedArg (
- ca.Constructor.Parameters [i].ParameterType, ca.ConstructorParameters [i]);
-
- int nn = ca.Fields.Count + ca.Properties.Count;
- cas.NumNamed = (ushort) nn;
- cas.NamedArgs = new CustomAttrib.NamedArg [nn];
-
- if (cas.NamedArgs.Length > 0) {
- int curs = 0;
- foreach (DictionaryEntry entry in ca.Fields) {
- string field = (string) entry.Key;
- cas.NamedArgs [curs++] = CreateNamedArg (
- ca.GetFieldType (field), field, entry.Value, true);
- }
-
- foreach (DictionaryEntry entry in ca.Properties) {
- string property = (string) entry.Key;
- cas.NamedArgs [curs++] = CreateNamedArg (
- ca.GetPropertyType (property), property, entry.Value, false);
- }
- }
-
- return cas;
- }
-
- static MarshalSig GetMarshalSig (MarshalSpec mSpec)
- {
- MarshalSig ms = new MarshalSig (mSpec.NativeIntrinsic);
-
- if (mSpec is ArrayMarshalSpec) {
- ArrayMarshalSpec amd = mSpec as ArrayMarshalSpec;
- MarshalSig.Array ar = new MarshalSig.Array ();
- ar.ArrayElemType = amd.ElemType;
- ar.NumElem = amd.NumElem;
- ar.ParamNum = amd.ParamNum;
- ar.ElemMult = amd.ElemMult;
- ms.Spec = ar;
- } else if (mSpec is CustomMarshalerSpec) {
- CustomMarshalerSpec cmd = mSpec as CustomMarshalerSpec;
- MarshalSig.CustomMarshaler cm = new MarshalSig.CustomMarshaler ();
- cm.Guid = cmd.Guid.ToString ();
- cm.UnmanagedType = cmd.UnmanagedType;
- cm.ManagedType = cmd.ManagedType;
- cm.Cookie = cmd.Cookie;
- ms.Spec = cm;
- } else if (mSpec is FixedArraySpec) {
- FixedArraySpec fad = mSpec as FixedArraySpec;
- MarshalSig.FixedArray fa = new MarshalSig.FixedArray ();
- fa.ArrayElemType = fad.ElemType;
- fa.NumElem = fad.NumElem;
- ms.Spec = fa;
- } else if (mSpec is FixedSysStringSpec) {
- MarshalSig.FixedSysString fss = new MarshalSig.FixedSysString ();
- fss.Size = (mSpec as FixedSysStringSpec).Size;
- ms.Spec = fss;
- } else if (mSpec is SafeArraySpec) {
- MarshalSig.SafeArray sa = new MarshalSig.SafeArray ();
- sa.ArrayElemType = (mSpec as SafeArraySpec).ElemType;
- ms.Spec = sa;
- }
-
- return ms;
- }
-
- public void WriteSymbols (ModuleDefinition module)
- {
- if (!m_saveSymbols)
- return;
-
- if (m_asmOutput == null)
- m_asmOutput = module.Assembly.Name.Name + "." + (module.Assembly.Kind == AssemblyKind.Dll ? "dll" : "exe");
-
- if (m_symbolWriter == null)
- m_symbolWriter = SymbolStoreHelper.GetWriter (module, m_asmOutput);
-
- foreach (TypeDefinition type in module.Types) {
- foreach (MethodDefinition method in type.Methods)
- WriteSymbols (method);
- foreach (MethodDefinition ctor in type.Constructors)
- WriteSymbols (ctor);
- }
-
- m_symbolWriter.Dispose ();
- }
-
- void WriteSymbols (MethodDefinition meth)
- {
- if (!meth.HasBody)
- return;
-
- m_symbolWriter.Write (meth.Body, GetVariablesSig (meth));
- }
-
- byte [][] GetVariablesSig (MethodDefinition meth)
- {
- VariableDefinitionCollection variables = meth.Body.Variables;
- byte [][] signatures = new byte [variables.Count][];
- for (int i = 0; i < variables.Count; i++) {
- signatures [i] = GetVariableSig (variables [i]);
- }
- return signatures;
- }
-
- byte [] GetVariableSig (VariableDefinition var)
- {
- return m_sigWriter.CompressLocalVar (m_codeWriter.GetLocalVariableSig (var));
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Resource.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Resource.cs
index 9790803..0432ae7 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Resource.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/Resource.cs
@@ -1,10 +1,10 @@
//
-// Resource.cs
+// ResourceType.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -28,64 +28,49 @@
namespace Mono.Cecil {
- using System.Collections;
+ public enum ResourceType {
+ Linked,
+ Embedded,
+ AssemblyLinked,
+ }
- public abstract class Resource : IAnnotationProvider, IReflectionStructureVisitable {
+ public abstract class Resource {
- string m_name;
- ManifestResourceAttributes m_attributes;
- IDictionary m_annotations;
+ string name;
+ uint attributes;
public string Name {
- get { return m_name; }
- set { m_name = value; }
+ get { return name; }
+ set { name = value; }
}
- public ManifestResourceAttributes Flags {
- get { return m_attributes; }
- set { m_attributes = value; }
+ public ManifestResourceAttributes Attributes {
+ get { return (ManifestResourceAttributes) attributes; }
+ set { attributes = (uint) value; }
}
- IDictionary IAnnotationProvider.Annotations {
- get {
- if (m_annotations == null)
- m_annotations = new Hashtable ();
- return m_annotations;
- }
+ public abstract ResourceType ResourceType {
+ get;
}
#region ManifestResourceAttributes
public bool IsPublic {
- get { return (m_attributes & ManifestResourceAttributes.VisibilityMask) == ManifestResourceAttributes.Public; }
- set {
- if (value) {
- m_attributes &= ~ManifestResourceAttributes.VisibilityMask;
- m_attributes |= ManifestResourceAttributes.Public;
- } else
- m_attributes &= ~(ManifestResourceAttributes.VisibilityMask & ManifestResourceAttributes.Public);
- }
+ get { return attributes.GetMaskedAttributes ((uint) ManifestResourceAttributes.VisibilityMask, (uint) ManifestResourceAttributes.Public); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) ManifestResourceAttributes.VisibilityMask, (uint) ManifestResourceAttributes.Public, value); }
}
public bool IsPrivate {
- get { return (m_attributes & ManifestResourceAttributes.VisibilityMask) == ManifestResourceAttributes.Private; }
- set {
- if (value) {
- m_attributes &= ~ManifestResourceAttributes.VisibilityMask;
- m_attributes |= ManifestResourceAttributes.Private;
- } else
- m_attributes &= ~(ManifestResourceAttributes.VisibilityMask & ManifestResourceAttributes.Private);
- }
+ get { return attributes.GetMaskedAttributes ((uint) ManifestResourceAttributes.VisibilityMask, (uint) ManifestResourceAttributes.Private); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) ManifestResourceAttributes.VisibilityMask, (uint) ManifestResourceAttributes.Private, value); }
}
#endregion
internal Resource (string name, ManifestResourceAttributes attributes)
{
- m_name = name;
- m_attributes = attributes;
+ this.name = name;
+ this.attributes = (uint) attributes;
}
-
- public abstract void Accept (IReflectionStructureVisitor visitor);
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ResourceCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ResourceCollection.cs
deleted file mode 100644
index 5a9696a..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/ResourceCollection.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// ResourceCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Wed Sep 27 12:46:54 CEST 2006
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Cil;
-
- public sealed class ResourceCollection : CollectionBase, IReflectionStructureVisitable {
-
- ModuleDefinition m_container;
-
- public Resource this [int index] {
- get { return List [index] as Resource; }
- set { List [index] = value; }
- }
-
- public ModuleDefinition Container {
- get { return m_container; }
- }
-
- public ResourceCollection (ModuleDefinition container)
- {
- m_container = container;
- }
-
- public void Add (Resource value)
- {
- List.Add (value);
- }
-
- public bool Contains (Resource value)
- {
- return List.Contains (value);
- }
-
- public int IndexOf (Resource value)
- {
- return List.IndexOf (value);
- }
-
- public void Insert (int index, Resource value)
- {
- List.Insert (index, value);
- }
-
- public void Remove (Resource value)
- {
- List.Remove (value);
- }
-
- protected override void OnValidate (object o)
- {
- if (! (o is Resource))
- throw new ArgumentException ("Must be of type " + typeof (Resource).FullName);
- }
-
- public void Accept (IReflectionStructureVisitor visitor)
- {
- visitor.VisitResourceCollection (this);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityAction.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityAction.cs
deleted file mode 100644
index b1ac330..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityAction.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// SecurityAction.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- public enum SecurityAction : short {
- Request = 1,
- Demand = 2,
- Assert = 3,
- Deny = 4,
- PermitOnly = 5,
- LinkDemand = 6,
- InheritDemand = 7,
- RequestMinimum = 8,
- RequestOptional = 9,
- RequestRefuse = 10,
- PreJitGrant = 11,
- PreJitDeny = 12,
- NonCasDemand = 13,
- NonCasLinkDemand = 14,
- NonCasInheritance = 15
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclaration.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclaration.cs
index b9feca6..4e57ada 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclaration.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclaration.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,89 +26,157 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
+using Mono.Collections.Generic;
+
namespace Mono.Cecil {
- using System;
- using System.Collections;
- using System.Security;
+ public enum SecurityAction : ushort {
+ Request = 1,
+ Demand = 2,
+ Assert = 3,
+ Deny = 4,
+ PermitOnly = 5,
+ LinkDemand = 6,
+ InheritDemand = 7,
+ RequestMinimum = 8,
+ RequestOptional = 9,
+ RequestRefuse = 10,
+ PreJitGrant = 11,
+ PreJitDeny = 12,
+ NonCasDemand = 13,
+ NonCasLinkDemand = 14,
+ NonCasInheritance = 15
+ }
- public sealed class SecurityDeclaration : IRequireResolving, IAnnotationProvider, IReflectionVisitable {
+ public interface ISecurityDeclarationProvider : IMetadataTokenProvider {
- SecurityAction m_action;
- IDictionary m_annotations;
+ bool HasSecurityDeclarations { get; }
+ Collection<SecurityDeclaration> SecurityDeclarations { get; }
+ }
-#if !CF_1_0 && !CF_2_0
- PermissionSet m_permSet;
-#endif
+ public sealed class SecurityAttribute : ICustomAttribute {
- bool m_resolved;
- byte [] m_blob;
+ TypeReference attribute_type;
- public SecurityAction Action {
- get { return m_action; }
- set { m_action = value; }
+ internal Collection<CustomAttributeNamedArgument> fields;
+ internal Collection<CustomAttributeNamedArgument> properties;
+
+ public TypeReference AttributeType {
+ get { return attribute_type; }
+ set { attribute_type = value; }
+ }
+
+ public bool HasFields {
+ get { return !fields.IsNullOrEmpty (); }
+ }
+
+ public Collection<CustomAttributeNamedArgument> Fields {
+ get { return fields ?? (fields = new Collection<CustomAttributeNamedArgument> ()); }
}
-#if !CF_1_0 && !CF_2_0
- public PermissionSet PermissionSet {
- get { return m_permSet; }
- set { m_permSet = value; }
+ public bool HasProperties {
+ get { return !properties.IsNullOrEmpty (); }
}
-#endif
- public bool Resolved {
- get { return m_resolved; }
- set { m_resolved = value; }
+ public Collection<CustomAttributeNamedArgument> Properties {
+ get { return properties ?? (properties = new Collection<CustomAttributeNamedArgument> ()); }
}
- public byte [] Blob {
- get { return m_blob; }
- set { m_blob = value; }
+ public SecurityAttribute (TypeReference attributeType)
+ {
+ this.attribute_type = attributeType;
+ }
+ }
+
+ public sealed class SecurityDeclaration {
+
+ readonly internal uint signature;
+ readonly ModuleDefinition module;
+
+ internal bool resolved;
+ SecurityAction action;
+ internal Collection<SecurityAttribute> security_attributes;
+
+ public SecurityAction Action {
+ get { return action; }
+ set { action = value; }
}
- IDictionary IAnnotationProvider.Annotations {
+ public bool HasSecurityAttributes {
get {
- if (m_annotations == null)
- m_annotations = new Hashtable ();
- return m_annotations;
+ Resolve ();
+
+ return !security_attributes.IsNullOrEmpty ();
}
}
+ public Collection<SecurityAttribute> SecurityAttributes {
+ get {
+ Resolve ();
+
+ return security_attributes ?? (security_attributes = new Collection<SecurityAttribute> ());
+ }
+ }
+
+ internal bool HasImage {
+ get { return module != null && module.HasImage; }
+ }
+
+ internal SecurityDeclaration (SecurityAction action, uint signature, ModuleDefinition module)
+ {
+ this.action = action;
+ this.signature = signature;
+ this.module = module;
+ }
+
public SecurityDeclaration (SecurityAction action)
{
- m_action = action;
- m_resolved = true;
+ this.action = action;
+ this.resolved = true;
}
- public SecurityDeclaration Clone ()
+ public byte [] GetBlob ()
{
- return Clone (this);
+ if (!HasImage || signature == 0)
+ throw new NotSupportedException ();
+
+ return module.Read (this, (declaration, reader) => reader.ReadSecurityDeclarationBlob (declaration.signature)); ;
}
- internal static SecurityDeclaration Clone (SecurityDeclaration sec)
+ void Resolve ()
{
- SecurityDeclaration sd = new SecurityDeclaration (sec.Action);
- if (!sec.Resolved) {
- sd.Resolved = false;
- sd.Blob = sec.Blob;
- return sd;
- }
+ if (resolved || !HasImage)
+ return;
-#if !CF_1_0 && !CF_2_0
- sd.PermissionSet = sec.PermissionSet.Copy ();
-#endif
- return sd;
+ module.Read (this, (declaration, reader) => {
+ reader.ReadSecurityDeclarationSignature (declaration);
+ return this;
+ });
+
+ resolved = true;
}
+ }
- public bool Resolve ()
+ static partial class Mixin {
+
+ public static bool GetHasSecurityDeclarations (
+ this ISecurityDeclarationProvider self,
+ ModuleDefinition module)
{
- throw new NotImplementedException ();
+ return module.HasImage ()
+ ? module.Read (self, (provider, reader) => reader.HasSecurityDeclarations (provider))
+ : false;
}
- public void Accept (IReflectionVisitor visitor)
+ public static Collection<SecurityDeclaration> GetSecurityDeclarations (
+ this ISecurityDeclarationProvider self,
+ ModuleDefinition module)
{
- visitor.VisitSecurityDeclaration (this);
+ return module.HasImage ()
+ ? module.Read (self, (provider, reader) => reader.ReadSecurityDeclarations (provider))
+ : new Collection<SecurityDeclaration> ();
}
}
}
-
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationCollection.cs
deleted file mode 100644
index 9aa14e7..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationCollection.cs
+++ /dev/null
@@ -1,157 +0,0 @@
-//
-// SecurityDeclarationCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- public sealed class SecurityDeclarationCollection : IReflectionVisitable {
-
- IDictionary m_items;
- IHasSecurity m_container;
-
- public SecurityDeclaration this [int index] {
- get { return m_items [index] as SecurityDeclaration; }
- set { m_items [index] = value; }
- }
-
- public SecurityDeclaration this [SecurityAction action] {
- get { return m_items [action] as SecurityDeclaration; }
- set { m_items [action] = value; }
- }
-
- public IHasSecurity Container {
- get { return m_container; }
- }
-
- public int Count {
- get { return m_items.Count; }
- }
-
- public bool IsSynchronized {
- get { return false; }
- }
-
- public object SyncRoot {
- get { return this; }
- }
-
- public SecurityDeclarationCollection (IHasSecurity container)
- {
- m_container = container;
- m_items = new Hashtable ();
- }
-
- public void Add (SecurityDeclaration value)
- {
- if (value == null)
- throw new ArgumentNullException ("value");
-
- // Each action can only be added once so...
- SecurityDeclaration current = (SecurityDeclaration) m_items[value.Action];
- if (current != null) {
- // ... further additions are transformed into unions
-#if !CF_1_0 && !CF_2_0
- current.PermissionSet = current.PermissionSet.Union (value.PermissionSet);
-#endif
- } else {
- m_items.Add (value.Action, value);
- SetHasSecurity (true);
- }
- }
-
- public void Clear ()
- {
- m_items.Clear ();
- SetHasSecurity (false);
- }
-
- public bool Contains (SecurityAction action)
- {
- return (m_items [action] != null);
- }
-
- public bool Contains (SecurityDeclaration value)
- {
- if (value == null)
- return (m_items.Count == 0);
-
- SecurityDeclaration item = (SecurityDeclaration) m_items[value.Action];
- if (item == null)
- return false;
-
-#if !CF_1_0 && !CF_2_0
- return value.PermissionSet.IsSubsetOf (item.PermissionSet);
-#else
- // XXX For CF, this concept does not exist--so always be true
- return true;
-#endif
- }
-
- public void Remove (SecurityAction action)
- {
- m_items.Remove (action);
- SetHasSecurity (this.Count > 0);
- }
-
- public void CopyTo (Array ary, int index)
- {
- m_items.Values.CopyTo (ary, index);
- }
-
- public IEnumerator GetEnumerator ()
- {
- return m_items.Values.GetEnumerator ();
- }
-
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitSecurityDeclarationCollection (this);
- }
-
- private void SetHasSecurity (bool value)
- {
- TypeDefinition td = (m_container as TypeDefinition);
- if (td != null) {
- if (value)
- td.Attributes |= TypeAttributes.HasSecurity;
- else
- td.Attributes &= ~TypeAttributes.HasSecurity;
- return;
- }
- MethodDefinition md = (m_container as MethodDefinition);
- if (md != null) {
- if (value)
- md.Attributes |= MethodAttributes.HasSecurity;
- else
- md.Attributes &= ~MethodAttributes.HasSecurity;
- }
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationReader.cs
deleted file mode 100644
index 512b493..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SecurityDeclarationReader.cs
+++ /dev/null
@@ -1,160 +0,0 @@
-//
-// SecurityDeclarationReader.cs
-//
-// Author:
-// Sebastien Pouliot <sebastien@ximian.com>
-//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.IO;
- using System.Reflection;
- using System.Security;
- using SSP = System.Security.Permissions;
- using System.Text;
-
- using Mono.Cecil.Metadata;
- using Mono.Cecil.Signatures;
- using Mono.Xml;
-
- internal class SecurityDeclarationReader {
-
- private SecurityParser m_parser;
- private SignatureReader sr;
-
- public SecurityDeclarationReader (MetadataRoot root, ReflectionReader reader)
- {
- sr = new SignatureReader (root, reader);
- }
-
- public SecurityParser Parser {
- get {
- if (m_parser == null)
- m_parser = new SecurityParser ();
- return m_parser;
- }
- }
-
- public SecurityDeclaration FromByteArray (SecurityAction action, byte [] declaration)
- {
- return FromByteArray (action, declaration, false);
- }
-
- static bool IsEmptyDeclaration (byte [] declaration)
- {
- return declaration == null || declaration.Length == 0 ||
- (declaration.Length == 1 && declaration [0] == 0);
- }
-
- public SecurityDeclaration FromByteArray (SecurityAction action, byte [] declaration, bool resolve)
- {
- SecurityDeclaration dec = new SecurityDeclaration (action);
-#if !CF_1_0 && !CF_2_0
- dec.PermissionSet = new PermissionSet (SSP.PermissionState.None);
-
- if (IsEmptyDeclaration (declaration))
- return dec;
-
- if (declaration[0] == 0x2e) {
- // new binary format introduced in 2.0
- int pos = 1;
- int start;
- int numattr = Utilities.ReadCompressedInteger (declaration, pos, out start);
- if (numattr == 0)
- return dec;
-
- BinaryReader br = new BinaryReader (new MemoryStream (declaration));
- for (int i = 0; i < numattr; i++) {
- pos = start;
- SSP.SecurityAttribute sa = CreateSecurityAttribute (action, br, declaration, pos, out start, resolve);
- if (sa == null) {
- dec.Resolved = false;
- dec.Blob = declaration;
- return dec;
- }
-
- IPermission p = sa.CreatePermission ();
- dec.PermissionSet.AddPermission (p);
- }
- } else {
- Parser.LoadXml (Encoding.Unicode.GetString (declaration));
- try {
- dec.PermissionSet.FromXml (Parser.ToXml ());
- dec.PermissionSet.ToXml ();
- } catch {
- dec.Resolved = false;
- dec.Blob = declaration;
- }
- }
-#endif
- return dec;
- }
-
-#if !CF_1_0 && !CF_2_0
- private SSP.SecurityAttribute CreateSecurityAttribute (SecurityAction action, BinaryReader br, byte [] permset, int pos, out int start, bool resolve)
- {
- string cname = SignatureReader.ReadUTF8String (permset, pos, out start);
- Type secattr = null;
-
- // note: the SecurityAction parameter isn't important to generate the XML
- SSP.SecurityAttribute sa = null;
- try {
- secattr = Type.GetType (cname, false);
- if (secattr == null)
- return null;
-
- sa = Activator.CreateInstance (secattr, new object [] {(SSP.SecurityAction) action}) as SSP.SecurityAttribute;
- } catch {}
-
- if (sa == null)
- return null;
-
- // encoded length of all parameters (we don't need the value - except the updated pos)
- Utilities.ReadCompressedInteger (permset, start, out pos);
- int numparams = Utilities.ReadCompressedInteger (permset, pos, out start);
- if (numparams == 0)
- return sa;
-
- br.BaseStream.Position = start;
- for (int j = 0; j < numparams; j++) {
- bool read = false;
- CustomAttrib.NamedArg na = sr.ReadNamedArg (permset, br, ref read, resolve);
- if (!read)
- return null;
-
- if (na.Field) {
- FieldInfo fi = secattr.GetField (na.FieldOrPropName);
- fi.SetValue (sa, na.FixedArg.Elems[0].Value);
- } else if (na.Property) {
- PropertyInfo pi = secattr.GetProperty (na.FieldOrPropName);
- pi.SetValue (sa, na.FixedArg.Elems[0].Value, null);
- }
- }
-
- return sa;
- }
-#endif
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SentinelType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SentinelType.cs
index 1aed160..d0d5a1d 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SentinelType.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/SentinelType.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2007 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,12 +26,28 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
+using MD = Mono.Cecil.Metadata;
+
namespace Mono.Cecil {
public sealed class SentinelType : TypeSpecification {
- public SentinelType (TypeReference elementType) : base (elementType)
+ public override bool IsValueType {
+ get { return false; }
+ set { throw new InvalidOperationException (); }
+ }
+
+ public override bool IsSentinel {
+ get { return true; }
+ }
+
+ public SentinelType (TypeReference type)
+ : base (type)
{
+ Mixin.CheckType (type);
+ this.etype = MD.ElementType.Sentinel;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureReader.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureReader.cs
deleted file mode 100644
index 4dc5423..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureReader.cs
+++ /dev/null
@@ -1,274 +0,0 @@
-//
-// StructureReader.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.IO;
-
- using Mono.Cecil.Binary;
- using Mono.Cecil.Metadata;
-
- internal sealed class StructureReader : BaseStructureVisitor {
-
- ImageReader m_ir;
- Image m_img;
- bool m_manifestOnly;
- AssemblyDefinition m_asmDef;
- ModuleDefinition m_module;
- MetadataStreamCollection m_streams;
- TablesHeap m_tHeap;
- MetadataTableReader m_tableReader;
-
- public bool ManifestOnly {
- get { return m_manifestOnly; }
- }
-
- public ImageReader ImageReader {
- get { return m_ir; }
- }
-
- public Image Image {
- get { return m_img; }
- }
-
- public StructureReader (ImageReader ir)
- {
- if (ir.Image.CLIHeader == null)
- throw new ImageFormatException ("The image is not a managed assembly");
-
- m_ir = ir;
- m_img = ir.Image;
- m_streams = m_img.MetadataRoot.Streams;
- m_tHeap = m_streams.TablesHeap;
- m_tableReader = ir.MetadataReader.TableReader;
- }
-
- public StructureReader (ImageReader ir, bool manifestOnly) : this (ir)
- {
- m_manifestOnly = manifestOnly;
- }
-
- byte [] ReadBlob (uint pointer)
- {
- if (pointer == 0)
- return new byte [0];
-
- return m_streams.BlobHeap.Read (pointer);
- }
-
- string ReadString (uint pointer)
- {
- return m_streams.StringsHeap [pointer];
- }
-
- public override void VisitAssemblyDefinition (AssemblyDefinition asm)
- {
- if (!m_tHeap.HasTable (AssemblyTable.RId))
- throw new ReflectionException ("No assembly manifest");
-
- asm.MetadataToken = new MetadataToken (TokenType.Assembly, 1);
- m_asmDef = asm;
-
- switch (m_img.MetadataRoot.Header.Version) {
- case "v1.0.3705" :
- asm.Runtime = TargetRuntime.NET_1_0;
- break;
- case "v1.1.4322" :
- asm.Runtime = TargetRuntime.NET_1_1;
- break;
- default :
- asm.Runtime = TargetRuntime.NET_2_0;
- break;
- }
-
- if ((m_img.PEFileHeader.Characteristics & ImageCharacteristics.Dll) != 0)
- asm.Kind = AssemblyKind.Dll;
- else if (m_img.PEOptionalHeader.NTSpecificFields.SubSystem == SubSystem.WindowsGui ||
- m_img.PEOptionalHeader.NTSpecificFields.SubSystem == SubSystem.WindowsCeGui)
- asm.Kind = AssemblyKind.Windows;
- else
- asm.Kind = AssemblyKind.Console;
- }
-
- public override void VisitAssemblyNameDefinition (AssemblyNameDefinition name)
- {
- AssemblyTable atable = m_tableReader.GetAssemblyTable ();
- AssemblyRow arow = atable [0];
- name.Name = ReadString (arow.Name);
- name.Flags = arow.Flags;
- name.PublicKey = ReadBlob (arow.PublicKey);
-
- name.Culture = ReadString (arow.Culture);
- name.Version = new Version (
- arow.MajorVersion, arow.MinorVersion,
- arow.BuildNumber, arow.RevisionNumber);
- name.HashAlgorithm = arow.HashAlgId;
- name.MetadataToken = new MetadataToken (TokenType.Assembly, 1);
- }
-
- public override void VisitAssemblyNameReferenceCollection (AssemblyNameReferenceCollection names)
- {
- if (!m_tHeap.HasTable (AssemblyRefTable.RId))
- return;
-
- AssemblyRefTable arTable = m_tableReader.GetAssemblyRefTable ();
- for (int i = 0; i < arTable.Rows.Count; i++) {
- AssemblyRefRow arRow = arTable [i];
- AssemblyNameReference aname = new AssemblyNameReference (
- ReadString (arRow.Name),
- ReadString (arRow.Culture),
- new Version (arRow.MajorVersion, arRow.MinorVersion,
- arRow.BuildNumber, arRow.RevisionNumber));
- aname.PublicKeyToken = ReadBlob (arRow.PublicKeyOrToken);
- aname.Hash = ReadBlob (arRow.HashValue);
- aname.Flags = arRow.Flags;
- aname.MetadataToken = new MetadataToken (TokenType.AssemblyRef, (uint) i + 1);
- names.Add (aname);
- }
- }
-
- public override void VisitResourceCollection (ResourceCollection resources)
- {
- if (!m_tHeap.HasTable (ManifestResourceTable.RId))
- return;
-
- ManifestResourceTable mrTable = m_tableReader.GetManifestResourceTable ();
- FileTable fTable = m_tableReader.GetFileTable ();
-
- for (int i = 0; i < mrTable.Rows.Count; i++) {
- ManifestResourceRow mrRow = mrTable [i];
- if (mrRow.Implementation.RID == 0) {
- EmbeddedResource eres = new EmbeddedResource (
- ReadString (mrRow.Name), mrRow.Flags);
-
- BinaryReader br = m_ir.MetadataReader.GetDataReader (
- m_img.CLIHeader.Resources.VirtualAddress);
- br.BaseStream.Position += mrRow.Offset;
-
- eres.Data = br.ReadBytes (br.ReadInt32 ());
-
- resources.Add (eres);
- continue;
- }
-
- switch (mrRow.Implementation.TokenType) {
- case TokenType.File :
- FileRow fRow = fTable [(int) mrRow.Implementation.RID - 1];
- LinkedResource lres = new LinkedResource (
- ReadString (mrRow.Name), mrRow.Flags,
- ReadString (fRow.Name));
- lres.Hash = ReadBlob (fRow.HashValue);
- resources.Add (lres);
- break;
- case TokenType.AssemblyRef :
- AssemblyNameReference asm =
- m_module.AssemblyReferences [(int) mrRow.Implementation.RID - 1];
- AssemblyLinkedResource alr = new AssemblyLinkedResource (
- ReadString (mrRow.Name),
- mrRow.Flags, asm);
- resources.Add (alr);
- break;
- }
- }
- }
-
- public override void VisitModuleDefinitionCollection (ModuleDefinitionCollection modules)
- {
- ModuleTable mt = m_tableReader.GetModuleTable ();
- if (mt == null || mt.Rows.Count != 1)
- throw new ReflectionException ("Can not read main module");
-
- ModuleRow mr = mt [0];
- string name = ReadString (mr.Name);
- ModuleDefinition main = new ModuleDefinition (name, m_asmDef, this, true);
- main.Mvid = m_streams.GuidHeap [mr.Mvid];
- main.MetadataToken = new MetadataToken (TokenType.Module, 1);
- modules.Add (main);
- m_module = main;
- m_module.Accept (this);
-
- FileTable ftable = m_tableReader.GetFileTable ();
- if (ftable == null || ftable.Rows.Count == 0)
- return;
-
- foreach (FileRow frow in ftable.Rows) {
- if (frow.Flags != FileAttributes.ContainsMetaData)
- continue;
-
- name = ReadString (frow.Name);
- FileInfo location = new FileInfo (
- m_img.FileInformation != null ? Path.Combine (m_img.FileInformation.DirectoryName, name) : name);
- if (!File.Exists (location.FullName))
- throw new FileNotFoundException ("Module not found : " + name);
-
- try {
- ImageReader module = ImageReader.Read (location.FullName);
- mt = module.Image.MetadataRoot.Streams.TablesHeap [ModuleTable.RId] as ModuleTable;
- if (mt == null || mt.Rows.Count != 1)
- throw new ReflectionException ("Can not read module : " + name);
-
- mr = mt [0];
- ModuleDefinition modext = new ModuleDefinition (name, m_asmDef,
- new StructureReader (module, m_manifestOnly), false);
- modext.Mvid = module.Image.MetadataRoot.Streams.GuidHeap [mr.Mvid];
-
- modules.Add (modext);
- modext.Accept (this);
- } catch (ReflectionException) {
- throw;
- } catch (Exception e) {
- throw new ReflectionException ("Can not read module : " + name, e);
- }
- }
- }
-
- public override void VisitModuleReferenceCollection (ModuleReferenceCollection modules)
- {
- if (!m_tHeap.HasTable (ModuleRefTable.RId))
- return;
-
- ModuleRefTable mrTable = m_tableReader.GetModuleRefTable ();
- for (int i = 0; i < mrTable.Rows.Count; i++) {
- ModuleRefRow mrRow = mrTable [i];
- ModuleReference mod = new ModuleReference (ReadString (mrRow.Name));
- mod.MetadataToken = MetadataToken.FromMetadataRow (TokenType.ModuleRef, i);
- modules.Add (mod);
- }
- }
-
- public override void TerminateAssemblyDefinition (AssemblyDefinition asm)
- {
- if (m_manifestOnly)
- return;
-
- foreach (ModuleDefinition mod in asm.Modules)
- mod.Controller.Reader.VisitModuleDefinition (mod);
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureWriter.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureWriter.cs
deleted file mode 100644
index 6c24aac..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/StructureWriter.cs
+++ /dev/null
@@ -1,246 +0,0 @@
-//
-// StructureWriter.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.IO;
-
- using Mono.Cecil.Binary;
- using Mono.Cecil.Metadata;
-
- internal sealed class StructureWriter : BaseStructureVisitor {
-
- MetadataWriter m_mdWriter;
- MetadataTableWriter m_tableWriter;
- MetadataRowWriter m_rowWriter;
-
- AssemblyDefinition m_asm;
- BinaryWriter m_binaryWriter;
-
- public AssemblyDefinition Assembly {
- get { return m_asm; }
- }
-
- static void ResetImage (ModuleDefinition mod)
- {
- Image ni = Image.CreateImage ();
- ni.Accept (new CopyImageVisitor (mod.Image));
- mod.Image = ni;
- }
-
- public StructureWriter (AssemblyDefinition asm, BinaryWriter writer)
- {
- m_asm = asm;
- m_binaryWriter = writer;
- }
-
- public BinaryWriter GetWriter ()
- {
- return m_binaryWriter;
- }
-
- public override void VisitAssemblyDefinition (AssemblyDefinition asm)
- {
- if (asm.Kind != AssemblyKind.Dll && asm.EntryPoint == null)
- throw new ReflectionException ("Assembly does not have an entry point defined");
-
- if ((asm.MainModule.Image.CLIHeader.Flags & RuntimeImage.ILOnly) == 0)
- throw new NotSupportedException ("Can not write a mixed mode assembly");
-
- foreach (ModuleDefinition module in asm.Modules)
- if (module.Image.CLIHeader.Metadata.VirtualAddress != RVA.Zero)
- ResetImage (module);
-
- ReflectionWriter rw = asm.MainModule.Controller.Writer;
- rw.StructureWriter = this;
-
- m_mdWriter = rw.MetadataWriter;
- m_tableWriter = rw.MetadataTableWriter;
- m_rowWriter = rw.MetadataRowWriter;
-
- if (!rw.SaveSymbols)
- return;
-
- FileStream fs = m_binaryWriter.BaseStream as FileStream;
- if (fs != null)
- rw.OutputFile = fs.Name;
- }
-
- public override void VisitAssemblyNameDefinition (AssemblyNameDefinition name)
- {
- AssemblyTable asmTable = m_tableWriter.GetAssemblyTable ();
-
- if (name.PublicKey != null && name.PublicKey.Length > 0)
- name.Flags |= AssemblyFlags.PublicKey;
-
- AssemblyRow asmRow = m_rowWriter.CreateAssemblyRow (
- name.HashAlgorithm,
- (ushort) name.Version.Major,
- (ushort) name.Version.Minor,
- (ushort) name.Version.Build,
- (ushort) name.Version.Revision,
- name.Flags,
- m_mdWriter.AddBlob (name.PublicKey),
- m_mdWriter.AddString (name.Name),
- m_mdWriter.AddString (name.Culture));
-
- asmTable.Rows.Add (asmRow);
- }
-
- public override void VisitAssemblyNameReferenceCollection (AssemblyNameReferenceCollection references)
- {
- foreach (AssemblyNameReference name in references)
- VisitAssemblyNameReference (name);
- }
-
- public override void VisitAssemblyNameReference (AssemblyNameReference name)
- {
- byte [] pkortoken;
- if (name.PublicKey != null && name.PublicKey.Length > 0)
- pkortoken = name.PublicKey;
- else if (name.PublicKeyToken != null && name.PublicKeyToken.Length > 0)
- pkortoken = name.PublicKeyToken;
- else
- pkortoken = new byte [0];
-
- AssemblyRefTable arTable = m_tableWriter.GetAssemblyRefTable ();
- AssemblyRefRow arRow = m_rowWriter.CreateAssemblyRefRow (
- (ushort) name.Version.Major,
- (ushort) name.Version.Minor,
- (ushort) name.Version.Build,
- (ushort) name.Version.Revision,
- name.Flags,
- m_mdWriter.AddBlob (pkortoken),
- m_mdWriter.AddString (name.Name),
- m_mdWriter.AddString (name.Culture),
- m_mdWriter.AddBlob (name.Hash));
-
- arTable.Rows.Add (arRow);
- }
-
- public override void VisitResourceCollection (ResourceCollection resources)
- {
- VisitCollection (resources);
- }
-
- public override void VisitEmbeddedResource (EmbeddedResource res)
- {
- AddManifestResource (
- m_mdWriter.AddResource (res.Data),
- res.Name, res.Flags,
- new MetadataToken (TokenType.ManifestResource, 0));
- }
-
- public override void VisitLinkedResource (LinkedResource res)
- {
- FileTable fTable = m_tableWriter.GetFileTable ();
- FileRow fRow = m_rowWriter.CreateFileRow (
- Mono.Cecil.FileAttributes.ContainsNoMetaData,
- m_mdWriter.AddString (res.File),
- m_mdWriter.AddBlob (res.Hash));
-
- fTable.Rows.Add (fRow);
-
- AddManifestResource (
- 0, res.Name, res.Flags,
- new MetadataToken (TokenType.File, (uint) fTable.Rows.IndexOf (fRow) + 1));
- }
-
- public override void VisitAssemblyLinkedResource (AssemblyLinkedResource res)
- {
- MetadataToken impl = new MetadataToken (TokenType.AssemblyRef,
- (uint) m_asm.MainModule.AssemblyReferences.IndexOf (res.Assembly) + 1);
-
- AddManifestResource (0, res.Name, res.Flags, impl);
- }
-
- void AddManifestResource (uint offset, string name, ManifestResourceAttributes flags, MetadataToken impl)
- {
- ManifestResourceTable mrTable = m_tableWriter.GetManifestResourceTable ();
- ManifestResourceRow mrRow = m_rowWriter.CreateManifestResourceRow (
- offset,
- flags,
- m_mdWriter.AddString (name),
- impl);
-
- mrTable.Rows.Add (mrRow);
- }
-
- public override void VisitModuleDefinitionCollection (ModuleDefinitionCollection modules)
- {
- VisitCollection (modules);
- }
-
- public override void VisitModuleDefinition (ModuleDefinition module)
- {
- if (module.Main) {
- ModuleTable modTable = m_tableWriter.GetModuleTable ();
- ModuleRow modRow = m_rowWriter.CreateModuleRow (
- 0,
- m_mdWriter.AddString (module.Name),
- m_mdWriter.AddGuid (module.Mvid),
- 0,
- 0);
-
- modTable.Rows.Add (modRow);
- } else {
- // multiple module assemblies
- throw new NotImplementedException ();
- }
- }
-
- public override void VisitModuleReferenceCollection (ModuleReferenceCollection modules)
- {
- VisitCollection (modules);
- }
-
- public override void VisitModuleReference (ModuleReference module)
- {
- ModuleRefTable mrTable = m_tableWriter.GetModuleRefTable ();
- ModuleRefRow mrRow = m_rowWriter.CreateModuleRefRow (
- m_mdWriter.AddString (module.Name));
-
- mrTable.Rows.Add (mrRow);
- }
-
- public override void TerminateAssemblyDefinition (AssemblyDefinition asm)
- {
- foreach (ModuleDefinition mod in asm.Modules) {
- ReflectionWriter writer = mod.Controller.Writer;
- writer.VisitModuleDefinition (mod);
- writer.VisitTypeReferenceCollection (mod.TypeReferences);
- writer.VisitTypeDefinitionCollection (mod.Types);
- writer.VisitMemberReferenceCollection (mod.MemberReferences);
- writer.CompleteTypeDefinitions ();
-
- writer.TerminateModuleDefinition (mod);
- }
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TableComparers.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TableComparers.cs
deleted file mode 100644
index 88b76ba..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TableComparers.cs
+++ /dev/null
@@ -1,276 +0,0 @@
-//
-// TableComparers.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
-
- using Mono.Cecil.Metadata;
-
- class TableComparers {
-
- public sealed class TypeDef : IComparer {
-
- public static readonly TypeDef Instance = new TypeDef ();
-
- public int Compare (object x, object y)
- {
- TypeDefinition a = x as TypeDefinition;
- TypeDefinition b = y as TypeDefinition;
-
- if (a == null || b == null)
- throw new ReflectionException ("TypeDefComparer can only compare TypeDefinition");
-
- if (a.Name == Constants.ModuleType && b.Name == Constants.ModuleType)
- return 0;
- else if (a.Name == Constants.ModuleType)
- return -1;
- else if (b.Name == Constants.ModuleType)
- return 1;
-
- return Comparer.Default.Compare (a.FullName, b.FullName);
- }
- }
-
- public class TypeRef : IComparer {
-
- public static readonly TypeRef Instance = new TypeRef ();
-
- public int Compare (object x, object y)
- {
- TypeReference a = x as TypeReference;
- TypeReference b = y as TypeReference;
-
- if (a == null || b == null)
- throw new ReflectionException ("TypeRefComparer can only compare TypeReference");
-
- if (b.DeclaringType == a)
- return -1;
- else if (a.DeclaringType == b)
- return 1;
-
- return Comparer.Default.Compare (a.FullName, b.FullName);
- }
- }
-
- public class NestedClass : IComparer {
-
- public static readonly NestedClass Instance = new NestedClass ();
-
- public int Compare (object x, object y)
- {
- NestedClassRow a = x as NestedClassRow;
- NestedClassRow b = y as NestedClassRow;
-
- return Comparer.Default.Compare (a.NestedClass, b.NestedClass);
- }
- }
-
- public class Constant : IComparer {
-
- public static readonly Constant Instance = new Constant ();
-
- public int Compare (object x, object y)
- {
- ConstantRow a = x as ConstantRow;
- ConstantRow b = y as ConstantRow;
-
- return Comparer.Default.Compare (
- Utilities.CompressMetadataToken (CodedIndex.HasConstant, a.Parent),
- Utilities.CompressMetadataToken (CodedIndex.HasConstant, b.Parent));
- }
-
- }
-
- public class InterfaceImpl : IComparer {
-
- public static readonly InterfaceImpl Instance = new InterfaceImpl ();
-
- public int Compare (object x, object y)
- {
- InterfaceImplRow a = x as InterfaceImplRow;
- InterfaceImplRow b = y as InterfaceImplRow;
-
- int klass = Comparer.Default.Compare (a.Class, b.Class);
-
- if (klass == 0)
- return Comparer.Default.Compare (
- Utilities.CompressMetadataToken (CodedIndex.TypeDefOrRef, a.Interface),
- Utilities.CompressMetadataToken (CodedIndex.TypeDefOrRef, b.Interface));
-
- return klass;
- }
- }
-
- public class MethodSem : IComparer {
-
- public static readonly MethodSem Instance = new MethodSem ();
-
- public int Compare (object x, object y)
- {
- MethodSemanticsRow a = x as MethodSemanticsRow;
- MethodSemanticsRow b = y as MethodSemanticsRow;
-
- return Comparer.Default.Compare (
- Utilities.CompressMetadataToken (CodedIndex.HasSemantics, a.Association),
- Utilities.CompressMetadataToken (CodedIndex.HasSemantics, b.Association));
- }
- }
-
- public class CustomAttribute : IComparer {
-
- public static readonly CustomAttribute Instance = new CustomAttribute ();
-
- public int Compare (object x, object y)
- {
- CustomAttributeRow a = x as CustomAttributeRow;
- CustomAttributeRow b = y as CustomAttributeRow;
-
- return Comparer.Default.Compare (
- Utilities.CompressMetadataToken (CodedIndex.HasCustomAttribute, a.Parent),
- Utilities.CompressMetadataToken (CodedIndex.HasCustomAttribute, b.Parent));
- }
- }
-
- public class SecurityDeclaration : IComparer {
-
- public static readonly SecurityDeclaration Instance = new SecurityDeclaration ();
-
- public int Compare (object x, object y)
- {
- DeclSecurityRow a = x as DeclSecurityRow;
- DeclSecurityRow b = y as DeclSecurityRow;
-
- return Comparer.Default.Compare (
- Utilities.CompressMetadataToken (CodedIndex.HasDeclSecurity, a.Parent),
- Utilities.CompressMetadataToken (CodedIndex.HasDeclSecurity, b.Parent));
- }
- }
-
- public class Override : IComparer {
-
- public static readonly Override Instance = new Override ();
-
- public int Compare (object x, object y)
- {
- MethodImplRow a = x as MethodImplRow;
- MethodImplRow b = y as MethodImplRow;
-
- return Comparer.Default.Compare (a.Class, b.Class);
- }
- }
-
- public class PInvoke : IComparer {
-
- public static readonly PInvoke Instance = new PInvoke ();
-
- public int Compare (object x, object y)
- {
- ImplMapRow a = x as ImplMapRow;
- ImplMapRow b = y as ImplMapRow;
-
- return Comparer.Default.Compare (a.MemberForwarded.RID, b.MemberForwarded.RID);
- }
- }
-
- public class FieldRVA : IComparer {
-
- public static readonly FieldRVA Instance = new FieldRVA ();
-
- public int Compare (object x, object y)
- {
- FieldRVARow a = x as FieldRVARow;
- FieldRVARow b = y as FieldRVARow;
-
- return Comparer.Default.Compare (a.Field, b.Field);
- }
- }
-
- public class FieldLayout : IComparer {
-
- public static readonly FieldLayout Instance = new FieldLayout ();
-
- public int Compare (object x, object y)
- {
- FieldLayoutRow a = x as FieldLayoutRow;
- FieldLayoutRow b = y as FieldLayoutRow;
-
- return Comparer.Default.Compare (a.Field, b.Field);
- }
- }
-
- public class FieldMarshal : IComparer {
-
- public static readonly FieldMarshal Instance = new FieldMarshal ();
-
- public int Compare (object x, object y)
- {
- FieldMarshalRow a = x as FieldMarshalRow;
- FieldMarshalRow b = y as FieldMarshalRow;
-
- return Comparer.Default.Compare (
- Utilities.CompressMetadataToken (CodedIndex.HasFieldMarshal, a.Parent),
- Utilities.CompressMetadataToken (CodedIndex.HasFieldMarshal, b.Parent));
- }
- }
-
- public class TypeLayout : IComparer {
-
- public static readonly TypeLayout Instance = new TypeLayout ();
-
- public int Compare (object x, object y)
- {
- ClassLayoutRow a = x as ClassLayoutRow;
- ClassLayoutRow b = y as ClassLayoutRow;
-
- return Comparer.Default.Compare (a.Parent, b.Parent);
- }
- }
-
- public class GenericParam : IComparer {
-
- public static readonly GenericParam Instance = new GenericParam ();
-
- public int Compare (object x, object y)
- {
- GenericParameter a = x as GenericParameter;
- GenericParameter b = y as GenericParameter;
-
- int token = Comparer.Default.Compare (
- Utilities.CompressMetadataToken (CodedIndex.TypeOrMethodDef, a.Owner.MetadataToken),
- Utilities.CompressMetadataToken (CodedIndex.TypeOrMethodDef, b.Owner.MetadataToken));
-
- if (token == 0)
- return Comparer.Default.Compare (a.Position, b.Position);
-
- return token;
- }
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TargetRuntime.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TargetRuntime.cs
index 38bdf6e..9931fc6 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TargetRuntime.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TargetRuntime.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -29,8 +29,9 @@
namespace Mono.Cecil {
public enum TargetRuntime {
- NET_1_0,
- NET_1_1,
- NET_2_0
+ Net_1_0,
+ Net_1_1,
+ Net_2_0,
+ Net_4_0,
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeAttributes.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeAttributes.cs
index e35f2ce..6e263e8 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeAttributes.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeAttributes.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 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,9 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
- using System;
+namespace Mono.Cecil {
[Flags]
public enum TypeAttributes : uint {
@@ -74,6 +74,7 @@ namespace Mono.Cecil {
// Additional flags
RTSpecialName = 0x00000800, // CLI provides 'special' behavior, depending upon the name of the Type
- HasSecurity = 0x00040000 // Type has security associate with it
+ HasSecurity = 0x00040000, // Type has security associate with it
+ Forwarder = 0x00200000, // Exported type is a type forwarder
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinition.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinition.cs
index ea34d9f..c83531a 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinition.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinition.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,474 +26,474 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
+using Mono.Collections.Generic;
+
namespace Mono.Cecil {
- public sealed class TypeDefinition : TypeReference, IMemberDefinition, IHasSecurity {
+ public sealed class TypeDefinition : TypeReference, IMemberDefinition, ISecurityDeclarationProvider {
- TypeAttributes m_attributes;
- TypeReference m_baseType;
+ uint attributes;
+ TypeReference base_type;
+ internal Range fields_range;
+ internal Range methods_range;
- bool m_hasInfo;
- ushort m_packingSize;
- uint m_classSize;
+ short packing_size = Mixin.NotResolvedMarker;
+ int class_size = Mixin.NotResolvedMarker;
- InterfaceCollection m_interfaces;
- NestedTypeCollection m_nestedTypes;
- MethodDefinitionCollection m_methods;
- ConstructorCollection m_ctors;
- FieldDefinitionCollection m_fields;
- EventDefinitionCollection m_events;
- PropertyDefinitionCollection m_properties;
- SecurityDeclarationCollection m_secDecls;
+ Collection<TypeReference> interfaces;
+ Collection<TypeDefinition> nested_types;
+ Collection<MethodDefinition> methods;
+ Collection<FieldDefinition> fields;
+ Collection<EventDefinition> events;
+ Collection<PropertyDefinition> properties;
+ Collection<CustomAttribute> custom_attributes;
+ Collection<SecurityDeclaration> security_declarations;
public TypeAttributes Attributes {
- get { return m_attributes; }
- set { m_attributes = value; }
+ get { return (TypeAttributes) attributes; }
+ set { attributes = (uint) value; }
}
public TypeReference BaseType {
- get { return m_baseType; }
- set { m_baseType = value; }
+ get { return base_type; }
+ set { base_type = value; }
+ }
+
+ void ResolveLayout ()
+ {
+ if (packing_size != Mixin.NotResolvedMarker || class_size != Mixin.NotResolvedMarker)
+ return;
+
+ if (!HasImage) {
+ packing_size = Mixin.NoDataMarker;
+ class_size = Mixin.NoDataMarker;
+ return;
+ }
+
+ var row = Module.Read (this, (type, reader) => reader.ReadTypeLayout (type));
+
+ packing_size = row.Col1;
+ class_size = row.Col2;
}
public bool HasLayoutInfo {
- get { return m_hasInfo; }
+ get {
+ if (packing_size >= 0 || class_size >= 0)
+ return true;
+
+ ResolveLayout ();
+
+ return packing_size >= 0 || class_size >= 0;
+ }
+ }
+
+ public short PackingSize {
+ get {
+ if (packing_size >= 0)
+ return packing_size;
+
+ ResolveLayout ();
+
+ return packing_size >= 0 ? packing_size : (short) -1;
+ }
+ set { packing_size = value; }
+ }
+
+ public int ClassSize {
+ get {
+ if (class_size >= 0)
+ return class_size;
+
+ ResolveLayout ();
+
+ return class_size >= 0 ? class_size : -1;
+ }
+ set { class_size = value; }
+ }
+
+ public bool HasInterfaces {
+ get {
+ if (interfaces != null)
+ return interfaces.Count > 0;
+
+ if (HasImage)
+ return Module.Read (this, (type, reader) => reader.HasInterfaces (type));
+
+ return false;
+ }
+ }
+
+ public Collection<TypeReference> Interfaces {
+ get {
+ if (interfaces != null)
+ return interfaces;
+
+ if (HasImage)
+ return interfaces = Module.Read (this, (type, reader) => reader.ReadInterfaces (type));
+
+ return interfaces = new Collection<TypeReference> ();
+ }
+ }
+
+ public bool HasNestedTypes {
+ get {
+ if (nested_types != null)
+ return nested_types.Count > 0;
+
+ if (HasImage)
+ return Module.Read (this, (type, reader) => reader.HasNestedTypes (type));
+
+ return false;
+ }
+ }
+
+ public Collection<TypeDefinition> NestedTypes {
+ get {
+ if (nested_types != null)
+ return nested_types;
+
+ if (HasImage)
+ return nested_types = Module.Read (this, (type, reader) => reader.ReadNestedTypes (type));
+
+ return nested_types = new MemberDefinitionCollection<TypeDefinition> (this);
+ }
+ }
+
+ internal new bool HasImage {
+ get { return Module != null && Module.HasImage; }
+ }
+
+ public bool HasMethods {
+ get {
+ if (methods != null)
+ return methods.Count > 0;
+
+ if (HasImage)
+ return methods_range.Length > 0;
+
+ return false;
+ }
}
- public ushort PackingSize {
- get { return m_packingSize; }
- set {
- m_hasInfo = true;
- m_packingSize = value;
+ public Collection<MethodDefinition> Methods {
+ get {
+ if (methods != null)
+ return methods;
+
+ if (HasImage)
+ return methods = Module.Read (this, (type, reader) => reader.ReadMethods (type));
+
+ return methods = new MemberDefinitionCollection<MethodDefinition> (this);
}
}
- public uint ClassSize {
- get { return m_classSize; }
- set {
- m_hasInfo = true;
- m_classSize = value;
+ public bool HasFields {
+ get {
+ if (fields != null)
+ return fields.Count > 0;
+
+ if (HasImage)
+ return fields_range.Length > 0;
+
+ return false;
}
}
- public InterfaceCollection Interfaces {
+ public Collection<FieldDefinition> Fields {
get {
- if (m_interfaces == null)
- m_interfaces = new InterfaceCollection (this);
+ if (fields != null)
+ return fields;
+
+ if (HasImage)
+ return fields = Module.Read (this, (type, reader) => reader.ReadFields (type));
- return m_interfaces;
+ return fields = new MemberDefinitionCollection<FieldDefinition> (this);
}
}
- public NestedTypeCollection NestedTypes {
+ public bool HasEvents {
get {
- if (m_nestedTypes == null)
- m_nestedTypes = new NestedTypeCollection (this);
+ if (events != null)
+ return events.Count > 0;
- return m_nestedTypes;
+ if (HasImage)
+ return Module.Read (this, (type, reader) => reader.HasEvents (type));
+
+ return false;
}
}
- public MethodDefinitionCollection Methods {
+ public Collection<EventDefinition> Events {
get {
- if (m_methods == null)
- m_methods = new MethodDefinitionCollection (this);
+ if (events != null)
+ return events;
+
+ if (HasImage)
+ return events = Module.Read (this, (type, reader) => reader.ReadEvents (type));
- return m_methods;
+ return events = new MemberDefinitionCollection<EventDefinition> (this);
}
}
- public ConstructorCollection Constructors {
+ public bool HasProperties {
get {
- if (m_ctors == null)
- m_ctors = new ConstructorCollection (this);
+ if (properties != null)
+ return properties.Count > 0;
- return m_ctors;
+ if (HasImage)
+ return Module.Read (this, (type, reader) => reader.HasProperties (type));
+
+ return false;
}
}
- public FieldDefinitionCollection Fields {
+ public Collection<PropertyDefinition> Properties {
get {
- if (m_fields == null)
- m_fields = new FieldDefinitionCollection (this);
+ if (properties != null)
+ return properties;
+
+ if (HasImage)
+ return properties = Module.Read (this, (type, reader) => reader.ReadProperties (type));
- return m_fields;
+ return properties = new MemberDefinitionCollection<PropertyDefinition> (this);
}
}
- public EventDefinitionCollection Events {
+ public bool HasSecurityDeclarations {
get {
- if (m_events == null)
- m_events = new EventDefinitionCollection (this);
+ if (security_declarations != null)
+ return security_declarations.Count > 0;
- return m_events;
+ return this.GetHasSecurityDeclarations (Module);
}
}
- public PropertyDefinitionCollection Properties {
+ public Collection<SecurityDeclaration> SecurityDeclarations {
+ get { return security_declarations ?? (security_declarations = this.GetSecurityDeclarations (Module)); }
+ }
+
+ public bool HasCustomAttributes {
get {
- if (m_properties == null)
- m_properties = new PropertyDefinitionCollection (this);
+ if (custom_attributes != null)
+ return custom_attributes.Count > 0;
- return m_properties;
+ return this.GetHasCustomAttributes (Module);
}
}
- public SecurityDeclarationCollection SecurityDeclarations {
+ public Collection<CustomAttribute> CustomAttributes {
+ get { return custom_attributes ?? (custom_attributes = this.GetCustomAttributes (Module)); }
+ }
+
+ public override bool HasGenericParameters {
get {
- if (m_secDecls == null)
- m_secDecls = new SecurityDeclarationCollection (this);
+ if (generic_parameters != null)
+ return generic_parameters.Count > 0;
- return m_secDecls;
+ return this.GetHasGenericParameters (Module);
}
}
+ public override Collection<GenericParameter> GenericParameters {
+ get { return generic_parameters ?? (generic_parameters = this.GetGenericParameters (Module)); }
+ }
+
#region TypeAttributes
public bool IsNotPublic {
- get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.VisibilityMask;
- m_attributes |= TypeAttributes.NotPublic;
- } else
- m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.NotPublic);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NotPublic); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NotPublic, value); }
}
public bool IsPublic {
- get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.Public; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.VisibilityMask;
- m_attributes |= TypeAttributes.Public;
- } else
- m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.Public);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.Public); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.Public, value); }
}
public bool IsNestedPublic {
- get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPublic; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.VisibilityMask;
- m_attributes |= TypeAttributes.NestedPublic;
- } else
- m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.NestedPublic);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPublic); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPublic, value); }
}
public bool IsNestedPrivate {
- get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPrivate; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.VisibilityMask;
- m_attributes |= TypeAttributes.NestedPrivate;
- } else
- m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.NestedPrivate);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPrivate); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedPrivate, value); }
}
public bool IsNestedFamily {
- get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedFamily; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.VisibilityMask;
- m_attributes |= TypeAttributes.NestedFamily;
- } else
- m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.NestedFamily);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamily); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamily, value); }
}
public bool IsNestedAssembly {
- get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedAssembly; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.VisibilityMask;
- m_attributes |= TypeAttributes.NestedAssembly;
- } else
- m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.NestedAssembly);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedAssembly); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedAssembly, value); }
}
public bool IsNestedFamilyAndAssembly {
- get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedFamANDAssem; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.VisibilityMask;
- m_attributes |= TypeAttributes.NestedFamANDAssem;
- } else
- m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.NestedFamANDAssem);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamANDAssem); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamANDAssem, value); }
}
public bool IsNestedFamilyOrAssembly {
- get { return (m_attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedFamORAssem; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.VisibilityMask;
- m_attributes |= TypeAttributes.NestedFamORAssem;
- } else
- m_attributes &= ~(TypeAttributes.VisibilityMask & TypeAttributes.NestedFamORAssem);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamORAssem); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.VisibilityMask, (uint) TypeAttributes.NestedFamORAssem, value); }
}
public bool IsAutoLayout {
- get { return (m_attributes & TypeAttributes.LayoutMask) == TypeAttributes.AutoLayout; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.LayoutMask;
- m_attributes |= TypeAttributes.AutoLayout;
- } else
- m_attributes &= ~(TypeAttributes.LayoutMask & TypeAttributes.AutoLayout);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.AutoLayout); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.AutoLayout, value); }
}
public bool IsSequentialLayout {
- get { return (m_attributes & TypeAttributes.LayoutMask) == TypeAttributes.SequentialLayout; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.LayoutMask;
- m_attributes |= TypeAttributes.SequentialLayout;
- } else
- m_attributes &= ~(TypeAttributes.LayoutMask & TypeAttributes.SequentialLayout);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.SequentialLayout); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.SequentialLayout, value); }
}
public bool IsExplicitLayout {
- get { return (m_attributes & TypeAttributes.LayoutMask) == TypeAttributes.ExplicitLayout; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.LayoutMask;
- m_attributes |= TypeAttributes.ExplicitLayout;
- } else
- m_attributes &= ~(TypeAttributes.LayoutMask & TypeAttributes.ExplicitLayout);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.ExplicitLayout); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.LayoutMask, (uint) TypeAttributes.ExplicitLayout, value); }
}
public bool IsClass {
- get { return (m_attributes & TypeAttributes.ClassSemanticMask) == TypeAttributes.Class; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.ClassSemanticMask;
- m_attributes |= TypeAttributes.Class;
- } else
- m_attributes &= ~(TypeAttributes.ClassSemanticMask & TypeAttributes.Class);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Class); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Class, value); }
}
public bool IsInterface {
- get { return (m_attributes & TypeAttributes.ClassSemanticMask) == TypeAttributes.Interface; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.ClassSemanticMask;
- m_attributes |= TypeAttributes.Interface;
- } else
- m_attributes &= ~(TypeAttributes.ClassSemanticMask & TypeAttributes.Interface);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Interface); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.ClassSemanticMask, (uint) TypeAttributes.Interface, value); }
}
public bool IsAbstract {
- get { return (m_attributes & TypeAttributes.Abstract) != 0; }
- set {
- if (value)
- m_attributes |= TypeAttributes.Abstract;
- else
- m_attributes &= ~TypeAttributes.Abstract;
- }
+ get { return attributes.GetAttributes ((uint) TypeAttributes.Abstract); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Abstract, value); }
}
public bool IsSealed {
- get { return (m_attributes & TypeAttributes.Sealed) != 0; }
- set {
- if (value)
- m_attributes |= TypeAttributes.Sealed;
- else
- m_attributes &= ~TypeAttributes.Sealed;
- }
+ get { return attributes.GetAttributes ((uint) TypeAttributes.Sealed); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Sealed, value); }
}
public bool IsSpecialName {
- get { return (m_attributes & TypeAttributes.SpecialName) != 0; }
- set {
- if (value)
- m_attributes |= TypeAttributes.SpecialName;
- else
- m_attributes &= ~TypeAttributes.SpecialName;
- }
+ get { return attributes.GetAttributes ((uint) TypeAttributes.SpecialName); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.SpecialName, value); }
}
public bool IsImport {
- get { return (m_attributes & TypeAttributes.Import) != 0; }
- set {
- if (value)
- m_attributes |= TypeAttributes.Import;
- else
- m_attributes &= ~TypeAttributes.Import;
- }
+ get { return attributes.GetAttributes ((uint) TypeAttributes.Import); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Import, value); }
}
public bool IsSerializable {
- get { return (m_attributes & TypeAttributes.Serializable) != 0; }
- set {
- if (value)
- m_attributes |= TypeAttributes.Serializable;
- else
- m_attributes &= ~TypeAttributes.Serializable;
- }
+ get { return attributes.GetAttributes ((uint) TypeAttributes.Serializable); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Serializable, value); }
}
public bool IsAnsiClass {
- get { return (m_attributes & TypeAttributes.StringFormatMask) == TypeAttributes.AnsiClass; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.StringFormatMask;
- m_attributes |= TypeAttributes.AnsiClass;
- } else
- m_attributes &= ~(TypeAttributes.StringFormatMask & TypeAttributes.AnsiClass);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass, value); }
}
public bool IsUnicodeClass {
- get { return (m_attributes & TypeAttributes.StringFormatMask) == TypeAttributes.UnicodeClass; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.StringFormatMask;
- m_attributes |= TypeAttributes.UnicodeClass;
- } else
- m_attributes &= ~(TypeAttributes.StringFormatMask & TypeAttributes.UnicodeClass);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.UnicodeClass); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.UnicodeClass, value); }
}
public bool IsAutoClass {
- get { return (m_attributes & TypeAttributes.StringFormatMask) == TypeAttributes.AutoClass; }
- set {
- if (value) {
- m_attributes &= ~TypeAttributes.StringFormatMask;
- m_attributes |= TypeAttributes.AutoClass;
- } else
- m_attributes &= ~(TypeAttributes.StringFormatMask & TypeAttributes.AutoClass);
- }
+ get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AutoClass); }
+ set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AutoClass, value); }
}
public bool IsBeforeFieldInit {
- get { return (m_attributes & TypeAttributes.BeforeFieldInit) != 0; }
- set {
- if (value)
- m_attributes |= TypeAttributes.BeforeFieldInit;
- else
- m_attributes &= ~TypeAttributes.BeforeFieldInit;
- }
+ get { return attributes.GetAttributes ((uint) TypeAttributes.BeforeFieldInit); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.BeforeFieldInit, value); }
}
public bool IsRuntimeSpecialName {
- get { return (m_attributes & TypeAttributes.RTSpecialName) != 0; }
- set {
- if (value)
- m_attributes |= TypeAttributes.RTSpecialName;
- else
- m_attributes &= ~TypeAttributes.RTSpecialName;
- }
+ get { return attributes.GetAttributes ((uint) TypeAttributes.RTSpecialName); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.RTSpecialName, value); }
}
public bool HasSecurity {
- get { return (m_attributes & TypeAttributes.HasSecurity) != 0; }
- set {
- if (value)
- m_attributes |= TypeAttributes.HasSecurity;
- else
- m_attributes &= ~TypeAttributes.HasSecurity;
- }
+ get { return attributes.GetAttributes ((uint) TypeAttributes.HasSecurity); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.HasSecurity, value); }
}
#endregion
public bool IsEnum {
- get { return m_baseType != null && m_baseType.FullName == Constants.Enum; }
+ get { return base_type != null && base_type.IsTypeOf ("System", "Enum"); }
}
public override bool IsValueType {
get {
- return m_baseType != null && (
- this.IsEnum || m_baseType.FullName == Constants.ValueType);
+ if (base_type == null)
+ return false;
+
+ return base_type.IsTypeOf ("System", "Enum") || (base_type.IsTypeOf ("System", "ValueType") && !this.IsTypeOf ("System", "Enum"));
}
}
- internal TypeDefinition (string name, string ns, TypeAttributes attrs) :
- base (name, ns)
+ public override bool IsDefinition {
+ get { return true; }
+ }
+
+ public new TypeDefinition DeclaringType {
+ get { return (TypeDefinition) base.DeclaringType; }
+ set { base.DeclaringType = value; }
+ }
+
+ public TypeDefinition (string @namespace, string name, TypeAttributes attributes)
+ : base (@namespace, name)
{
- m_hasInfo = false;
- m_attributes = attrs;
+ this.attributes = (uint) attributes;
+ this.token = new MetadataToken (TokenType.TypeDef);
}
- public TypeDefinition (string name, string ns,
- TypeAttributes attributes, TypeReference baseType) :
- this (name, ns, attributes)
+ public TypeDefinition (string @namespace, string name, TypeAttributes attributes, TypeReference baseType) :
+ this (@namespace, name, attributes)
{
this.BaseType = baseType;
}
- public TypeDefinition Clone ()
+ public override TypeDefinition Resolve ()
{
- return Clone (this, new ImportContext (NullReferenceImporter.Instance, this));
+ return this;
}
+ }
- internal static TypeDefinition Clone (TypeDefinition type, ImportContext context)
+ static partial class Mixin {
+
+ public static TypeReference GetEnumUnderlyingType (this TypeDefinition self)
{
- TypeDefinition nt = new TypeDefinition (
- type.Name,
- type.Namespace,
- type.Attributes);
+ var fields = self.Fields;
+
+ for (int i = 0; i < fields.Count; i++) {
+ var field = fields [i];
+ if (!field.IsStatic)
+ return field.FieldType;
+ }
- context.GenericContext.Type = nt;
+ throw new ArgumentException ();
+ }
- foreach (GenericParameter p in type.GenericParameters)
- nt.GenericParameters.Add (GenericParameter.Clone (p, context));
+ public static TypeDefinition GetNestedType (this TypeDefinition self, string name)
+ {
+ if (!self.HasNestedTypes)
+ return null;
- if (type.BaseType != null)
- nt.BaseType = context.Import (type.BaseType);
+ var nested_types = self.NestedTypes;
- if (type.HasLayoutInfo) {
- nt.ClassSize = type.ClassSize;
- nt.PackingSize = type.PackingSize;
+ for (int i = 0; i < nested_types.Count; i++) {
+ var nested_type = nested_types [i];
+ if (nested_type.Name == name)
+ return nested_type;
}
- foreach (FieldDefinition field in type.Fields)
- nt.Fields.Add (FieldDefinition.Clone (field, context));
- foreach (MethodDefinition ctor in type.Constructors)
- nt.Constructors.Add (MethodDefinition.Clone (ctor, context));
- foreach (MethodDefinition meth in type.Methods)
- nt.Methods.Add (MethodDefinition.Clone (meth, context));
- foreach (EventDefinition evt in type.Events)
- nt.Events.Add (EventDefinition.Clone (evt, context));
- foreach (PropertyDefinition prop in type.Properties)
- nt.Properties.Add (PropertyDefinition.Clone (prop, context));
- foreach (TypeReference intf in type.Interfaces)
- nt.Interfaces.Add (context.Import (intf));
- foreach (TypeDefinition nested in type.NestedTypes)
- nt.NestedTypes.Add (Clone (nested, context));
- foreach (CustomAttribute ca in type.CustomAttributes)
- nt.CustomAttributes.Add (CustomAttribute.Clone (ca, context));
- foreach (SecurityDeclaration dec in type.SecurityDeclarations)
- nt.SecurityDeclarations.Add (SecurityDeclaration.Clone (dec));
-
- return nt;
- }
-
- public override void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitTypeDefinition (this);
-
- this.GenericParameters.Accept (visitor);
- this.Interfaces.Accept (visitor);
- this.Constructors.Accept (visitor);
- this.Methods.Accept (visitor);
- this.Fields.Accept (visitor);
- this.Properties.Accept (visitor);
- this.Events.Accept (visitor);
- this.NestedTypes.Accept (visitor);
- this.CustomAttributes.Accept (visitor);
- this.SecurityDeclarations.Accept (visitor);
+ return null;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinitionCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinitionCollection.cs
index 6bd233b..702fe27 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinitionCollection.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeDefinitionCollection.cs
@@ -4,10 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Fri Mar 30 18:43:56 +0200 2007
-//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -29,188 +26,93 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
- using System.Collections.Specialized;
-
- using Mono.Cecil.Cil;
+using System;
+using System.Collections.Generic;
- using Hcp = Mono.Cecil.HashCodeProvider;
- using Cmp = System.Collections.Comparer;
+using Mono.Cecil.Metadata;
- public sealed class TypeDefinitionCollection : NameObjectCollectionBase, IList, IReflectionVisitable {
-
- ModuleDefinition m_container;
-
- public TypeDefinition this [int index] {
- get { return this.BaseGet (index) as TypeDefinition; }
- set { this.BaseSet (index, value); }
- }
-
- public TypeDefinition this [string fullName] {
- get { return this.BaseGet (fullName) as TypeDefinition; }
- set { this.BaseSet (fullName, value); }
- }
-
- public ModuleDefinition Container {
- get { return m_container; }
- }
-
- public bool IsSynchronized {
- get { return false; }
- }
+using Mono.Collections.Generic;
- public object SyncRoot {
- get { return this; }
- }
-
- bool IList.IsReadOnly {
- get { return false; }
- }
+namespace Mono.Cecil {
- bool IList.IsFixedSize {
- get { return false; }
- }
+ using Slot = Row<string, string>;
- object IList.this [int index] {
- get { return BaseGet (index); }
- set {
- Check (value);
- BaseSet (index, value);
- }
- }
+ sealed class TypeDefinitionCollection : Collection<TypeDefinition> {
- public TypeDefinitionCollection (ModuleDefinition container) :
- base (Hcp.Instance, Cmp.Default)
- {
- m_container = container;
- }
+ readonly ModuleDefinition container;
+ readonly Dictionary<Slot, TypeDefinition> name_cache;
- public void Add (TypeDefinition value)
+ internal TypeDefinitionCollection (ModuleDefinition container)
{
- if (value == null)
- throw new ArgumentNullException ("value");
-
- Attach (value);
-
- this.BaseAdd (value.FullName, value);
+ this.container = container;
+ this.name_cache = new Dictionary<Slot, TypeDefinition> (new RowEqualityComparer ());
}
- public void Clear ()
+ internal TypeDefinitionCollection (ModuleDefinition container, int capacity)
+ : base (capacity)
{
- foreach (TypeDefinition item in this)
- Detach (item);
-
- this.BaseClear ();
+ this.container = container;
+ this.name_cache = new Dictionary<Slot, TypeDefinition> (capacity, new RowEqualityComparer ());
}
- public bool Contains (TypeDefinition value)
+ protected override void OnAdd (TypeDefinition item, int index)
{
- return Contains (value.FullName);
+ Attach (item);
}
- public bool Contains (string fullName)
+ protected override void OnSet (TypeDefinition item, int index)
{
- return this.BaseGet (fullName) != null;
+ Attach (item);
}
- public int IndexOf (TypeDefinition value)
+ protected override void OnInsert (TypeDefinition item, int index)
{
- string [] keys = this.BaseGetAllKeys ();
- return Array.IndexOf (keys, value.FullName, 0, keys.Length);
+ Attach (item);
}
- public void Remove (TypeDefinition value)
+ protected override void OnRemove (TypeDefinition item, int index)
{
- this.BaseRemove (value.FullName);
-
- Detach (value);
- }
-
- public void RemoveAt (int index)
- {
- TypeDefinition item = this [index];
- Remove (item);
-
Detach (item);
}
- public void CopyTo (Array ary, int index)
- {
- this.BaseGetAllValues ().CopyTo (ary, index);
- }
-
- public new IEnumerator GetEnumerator ()
- {
- return this.BaseGetAllValues ().GetEnumerator ();
- }
-
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitTypeDefinitionCollection (this);
- }
-
-#if CF_1_0 || CF_2_0
- internal object [] BaseGetAllValues ()
- {
- object [] values = new object [this.Count];
- for (int i=0; i < values.Length; ++i) {
- values [i] = this.BaseGet (i);
- }
- return values;
- }
-#endif
-
- void Check (object value)
- {
- if (!(value is TypeDefinition))
- throw new ArgumentException ();
- }
-
- int IList.Add (object value)
+ protected override void OnClear ()
{
- Check (value);
- Add (value as TypeDefinition);
- return 0;
+ foreach (var type in this)
+ Detach (type);
}
- bool IList.Contains (object value)
+ void Attach (TypeDefinition type)
{
- Check (value);
- return Contains (value as TypeDefinition);
- }
+ if (type.Module != null && type.Module != container)
+ throw new ArgumentException ("Type already attached");
- int IList.IndexOf (object value)
- {
- throw new NotSupportedException ();
+ type.module = container;
+ type.scope = container;
+ name_cache [new Slot (type.Namespace, type.Name)] = type;
}
- void IList.Insert (int index, object value)
+ void Detach (TypeDefinition type)
{
- throw new NotSupportedException ();
+ type.module = null;
+ type.scope = null;
+ name_cache.Remove (new Slot (type.Namespace, type.Name));
}
- void IList.Remove (object value)
+ public TypeDefinition GetType (string fullname)
{
- Check (value);
- Remove (value as TypeDefinition);
- }
+ string @namespace, name;
+ TypeParser.SplitFullName (fullname, out @namespace, out name);
- void Detach (TypeReference type)
- {
- type.Module = null;
+ return GetType (@namespace, name);
}
- void Attach (TypeReference type)
+ public TypeDefinition GetType (string @namespace, string name)
{
- if (type.Module != null)
- throw new ReflectionException ("Type is already attached, clone it instead");
-
- type.Module = m_container;
- type.AttachToScope (m_container);
+ TypeDefinition type;
+ if (name_cache.TryGetValue (new Slot (@namespace, name), out type))
+ return type;
+ return null;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeParser.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeParser.cs
new file mode 100644
index 0000000..cd3d11a
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeParser.cs
@@ -0,0 +1,557 @@
+//
+// TypeParser.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Text;
+
+using Mono.Cecil.Metadata;
+
+namespace Mono.Cecil {
+
+ class TypeParser {
+
+ class Type {
+ public const int Ptr = -1;
+ public const int ByRef = -2;
+ public const int SzArray = -3;
+
+ public string type_fullname;
+ public string [] nested_names;
+ public int arity;
+ public int [] specs;
+ public Type [] generic_arguments;
+ public string assembly;
+ }
+
+ readonly string fullname;
+ readonly int length;
+
+ int position;
+
+ TypeParser (string fullname)
+ {
+ this.fullname = fullname;
+ this.length = fullname.Length;
+ }
+
+ Type ParseType (bool fq_name)
+ {
+ var type = new Type ();
+ type.type_fullname = ParsePart ();
+
+ type.nested_names = ParseNestedNames ();
+
+ if (TryGetArity (type))
+ type.generic_arguments = ParseGenericArguments (type.arity);
+
+ type.specs = ParseSpecs ();
+
+ if (fq_name)
+ type.assembly = ParseAssemblyName ();
+
+ return type;
+ }
+
+ static bool TryGetArity (Type type)
+ {
+ int arity = 0;
+
+ TryAddArity (type.type_fullname, ref arity);
+
+ var nested_names = type.nested_names;
+ if (!nested_names.IsNullOrEmpty ()) {
+ for (int i = 0; i < nested_names.Length; i++)
+ TryAddArity (nested_names [i], ref arity);
+ }
+
+ type.arity = arity;
+ return arity > 0;
+ }
+
+ static bool TryGetArity (string name, out int arity)
+ {
+ arity = 0;
+ var index = name.LastIndexOf ('`');
+ if (index == -1)
+ return false;
+
+ return ParseInt32 (name.Substring (index + 1), out arity);
+ }
+
+ static bool ParseInt32 (string value, out int result)
+ {
+#if CF
+ try {
+ result = int.Parse (value);
+ return true;
+ } catch {
+ result = 0;
+ return false;
+ }
+#else
+ return int.TryParse (value, out result);
+#endif
+ }
+
+ static void TryAddArity (string name, ref int arity)
+ {
+ int type_arity;
+ if (!TryGetArity (name, out type_arity))
+ return;
+
+ arity += type_arity;
+ }
+
+ string ParsePart ()
+ {
+ int start = position;
+ while (position < length && !IsDelimiter (fullname [position]))
+ position++;
+
+ return fullname.Substring (start, position - start);
+ }
+
+ static bool IsDelimiter (char chr)
+ {
+ return "+,[]*&".IndexOf (chr) != -1;
+ }
+
+ void TryParseWhiteSpace ()
+ {
+ while (position < length && Char.IsWhiteSpace (fullname [position]))
+ position++;
+ }
+
+ string [] ParseNestedNames ()
+ {
+ string [] nested_names = null;
+ while (TryParse ('+'))
+ Add (ref nested_names, ParsePart ());
+
+ return nested_names;
+ }
+
+ bool TryParse (char chr)
+ {
+ if (position < length && fullname [position] == chr) {
+ position++;
+ return true;
+ }
+
+ return false;
+ }
+
+ static void Add<T> (ref T [] array, T item)
+ {
+ if (array == null) {
+ array = new [] { item };
+ return;
+ }
+
+#if !CF
+ Array.Resize (ref array, array.Length + 1);
+#else
+ var copy = new T [array.Length + 1];
+ Array.Copy (array, copy, array.Length);
+ array = copy;
+#endif
+ array [array.Length - 1] = item;
+ }
+
+ int [] ParseSpecs ()
+ {
+ int [] specs = null;
+
+ while (position < length) {
+ switch (fullname [position]) {
+ case '*':
+ position++;
+ Add (ref specs, Type.Ptr);
+ break;
+ case '&':
+ position++;
+ Add (ref specs, Type.ByRef);
+ break;
+ case '[':
+ position++;
+ switch (fullname [position]) {
+ case ']':
+ position++;
+ Add (ref specs, Type.SzArray);
+ break;
+ case '*':
+ position++;
+ Add (ref specs, 1);
+ break;
+ default:
+ var rank = 1;
+ while (TryParse (','))
+ rank++;
+
+ Add (ref specs, rank);
+
+ TryParse (']');
+ break;
+ }
+ break;
+ default:
+ return specs;
+ }
+ }
+
+ return specs;
+ }
+
+ Type [] ParseGenericArguments (int arity)
+ {
+ Type [] generic_arguments = null;
+
+ if (position == length || fullname [position] != '[')
+ return generic_arguments;
+
+ TryParse ('[');
+
+ for (int i = 0; i < arity; i++) {
+ var fq_argument = TryParse ('[');
+ Add (ref generic_arguments, ParseType (fq_argument));
+ if (fq_argument)
+ TryParse (']');
+
+ TryParse (',');
+ TryParseWhiteSpace ();
+ }
+
+ TryParse (']');
+
+ return generic_arguments;
+ }
+
+ string ParseAssemblyName ()
+ {
+ if (!TryParse (','))
+ return string.Empty;
+
+ TryParseWhiteSpace ();
+
+ var start = position;
+ while (position < length) {
+ var chr = fullname [position];
+ if (chr == '[' || chr == ']')
+ break;
+
+ position++;
+ }
+
+ return fullname.Substring (start, position - start);
+ }
+
+ public static TypeReference ParseType (ModuleDefinition module, string fullname)
+ {
+ if (fullname == null)
+ return null;
+
+ var parser = new TypeParser (fullname);
+ return GetTypeReference (module, parser.ParseType (true));
+ }
+
+ static TypeReference GetTypeReference (ModuleDefinition module, Type type_info)
+ {
+ TypeReference type;
+ if (!TryGetDefinition (module, type_info, out type))
+ type = CreateReference (type_info, module, GetMetadataScope (module, type_info));
+
+ return CreateSpecs (type, type_info);
+ }
+
+ static TypeReference CreateSpecs (TypeReference type, Type type_info)
+ {
+ type = TryCreateGenericInstanceType (type, type_info);
+
+ var specs = type_info.specs;
+ if (specs.IsNullOrEmpty ())
+ return type;
+
+ for (int i = 0; i < specs.Length; i++) {
+ switch (specs [i]) {
+ case Type.Ptr:
+ type = new PointerType (type);
+ break;
+ case Type.ByRef:
+ type = new ByReferenceType (type);
+ break;
+ case Type.SzArray:
+ type = new ArrayType (type);
+ break;
+ default:
+ var array = new ArrayType (type);
+ array.Dimensions.Clear ();
+
+ for (int j = 0; j < specs [i]; j++)
+ array.Dimensions.Add (new ArrayDimension ());
+
+ type = array;
+ break;
+ }
+ }
+
+ return type;
+ }
+
+ static TypeReference TryCreateGenericInstanceType (TypeReference type, Type type_info)
+ {
+ var generic_arguments = type_info.generic_arguments;
+ if (generic_arguments.IsNullOrEmpty ())
+ return type;
+
+ var instance = new GenericInstanceType (type);
+ var instance_arguments = instance.GenericArguments;
+
+ for (int i = 0; i < generic_arguments.Length; i++)
+ instance_arguments.Add (GetTypeReference (type.Module, generic_arguments [i]));
+
+ return instance;
+ }
+
+ public static void SplitFullName (string fullname, out string @namespace, out string name)
+ {
+ var last_dot = fullname.LastIndexOf ('.');
+
+ if (last_dot == -1) {
+ @namespace = string.Empty;
+ name = fullname;
+ } else {
+ @namespace = fullname.Substring (0, last_dot);
+ name = fullname.Substring (last_dot + 1);
+ }
+ }
+
+ static TypeReference CreateReference (Type type_info, ModuleDefinition module, IMetadataScope scope)
+ {
+ string @namespace, name;
+ SplitFullName (type_info.type_fullname, out @namespace, out name);
+
+ var type = new TypeReference (@namespace, name, scope) {
+ module = module,
+ };
+
+ AdjustGenericParameters (type);
+
+ var nested_names = type_info.nested_names;
+ if (nested_names.IsNullOrEmpty ())
+ return type;
+
+ for (int i = 0; i < nested_names.Length; i++) {
+ type = new TypeReference (string.Empty, nested_names [i], null) {
+ DeclaringType = type,
+ module = module,
+ };
+
+ AdjustGenericParameters (type);
+ }
+
+ return type;
+ }
+
+ static void AdjustGenericParameters (TypeReference type)
+ {
+ int arity;
+ if (!TryGetArity (type.Name, out arity))
+ return;
+
+ for (int i = 0; i < arity; i++)
+ type.GenericParameters.Add (new GenericParameter (type));
+ }
+
+ static IMetadataScope GetMetadataScope (ModuleDefinition module, Type type_info)
+ {
+ if (string.IsNullOrEmpty (type_info.assembly))
+ return module.TypeSystem.Corlib;
+
+ return MatchReference (module, AssemblyNameReference.Parse (type_info.assembly));
+ }
+
+ static AssemblyNameReference MatchReference (ModuleDefinition module, AssemblyNameReference pattern)
+ {
+ var references = module.AssemblyReferences;
+
+ for (int i = 0; i < references.Count; i++) {
+ var reference = references [i];
+ if (reference.FullName == pattern.FullName)
+ return reference;
+ }
+
+ return pattern;
+ }
+
+ static bool TryGetDefinition (ModuleDefinition module, Type type_info, out TypeReference type)
+ {
+ type = null;
+ if (!TryCurrentModule (module, type_info))
+ return false;
+
+ var typedef = module.GetType (type_info.type_fullname);
+ if (typedef == null)
+ return false;
+
+ var nested_names = type_info.nested_names;
+ if (!nested_names.IsNullOrEmpty ()) {
+ for (int i = 0; i < nested_names.Length; i++)
+ typedef = typedef.GetNestedType (nested_names [i]);
+ }
+
+ type = typedef;
+ return true;
+ }
+
+ static bool TryCurrentModule (ModuleDefinition module, Type type_info)
+ {
+ if (string.IsNullOrEmpty (type_info.assembly))
+ return true;
+
+ if (module.assembly != null && module.assembly.Name.FullName == type_info.assembly)
+ return true;
+
+ return false;
+ }
+
+ public static string ToParseable (TypeReference type)
+ {
+ if (type == null)
+ return null;
+
+ var name = new StringBuilder ();
+ AppendType (type, name, true, true);
+ return name.ToString ();
+ }
+
+ static void AppendType (TypeReference type, StringBuilder name, bool fq_name, bool top_level)
+ {
+ var declaring_type = type.DeclaringType;
+ if (declaring_type != null) {
+ AppendType (declaring_type, name, false, top_level);
+ name.Append ('+');
+ }
+
+ var @namespace = type.Namespace;
+ if (!string.IsNullOrEmpty (@namespace)) {
+ name.Append (@namespace);
+ name.Append ('.');
+ }
+
+ name.Append (type.GetElementType ().Name);
+
+ if (!fq_name)
+ return;
+
+ if (type.IsTypeSpecification ())
+ AppendTypeSpecification ((TypeSpecification) type, name);
+
+ if (RequiresFullyQualifiedName (type, top_level)) {
+ name.Append (", ");
+ name.Append (GetScopeFullName (type));
+ }
+ }
+
+ static string GetScopeFullName (TypeReference type)
+ {
+ var scope = type.Scope;
+ switch (scope.MetadataScopeType) {
+ case MetadataScopeType.AssemblyNameReference:
+ return ((AssemblyNameReference) scope).FullName;
+ case MetadataScopeType.ModuleDefinition:
+ return ((ModuleDefinition) scope).Assembly.Name.FullName;
+ }
+
+ throw new ArgumentException ();
+ }
+
+ static void AppendTypeSpecification (TypeSpecification type, StringBuilder name)
+ {
+ if (type.ElementType.IsTypeSpecification ())
+ AppendTypeSpecification ((TypeSpecification) type.ElementType, name);
+
+ switch (type.etype) {
+ case ElementType.Ptr:
+ name.Append ('*');
+ break;
+ case ElementType.ByRef:
+ name.Append ('&');
+ break;
+ case ElementType.SzArray:
+ case ElementType.Array:
+ var array = (ArrayType) type;
+ if (array.IsVector) {
+ name.Append ("[]");
+ } else {
+ name.Append ('[');
+ for (int i = 1; i < array.Rank; i++)
+ name.Append (',');
+ name.Append (']');
+ }
+ break;
+ case ElementType.GenericInst:
+ var instance = (GenericInstanceType) type;
+ var arguments = instance.GenericArguments;
+
+ name.Append ('[');
+
+ for (int i = 0; i < arguments.Count; i++) {
+ if (i > 0)
+ name.Append (',');
+
+ var argument = arguments [i];
+ var requires_fqname = argument.Scope != argument.Module;
+
+ if (requires_fqname)
+ name.Append ('[');
+
+ AppendType (argument, name, true, false);
+
+ if (requires_fqname)
+ name.Append (']');
+ }
+
+ name.Append (']');
+ break;
+ default:
+ return;
+ }
+ }
+
+ static bool RequiresFullyQualifiedName (TypeReference type, bool top_level)
+ {
+ if (type.Scope == type.Module)
+ return false;
+
+ if (type.Scope.Name == "mscorlib" && top_level)
+ return false;
+
+ return true;
+ }
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReference.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReference.cs
index 9e373ee..4ccd86f 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReference.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReference.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,69 +26,92 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
+using Mono.Cecil.Metadata;
+using Mono.Collections.Generic;
+
namespace Mono.Cecil {
- public class TypeReference : MemberReference, IGenericParameterProvider, ICustomAttributeProvider {
+ public class TypeReference : MemberReference, IGenericParameterProvider, IGenericContext {
+
+ string @namespace;
+ bool value_type;
+ internal IMetadataScope scope;
+ internal ModuleDefinition module;
+
+ internal ElementType etype = ElementType.None;
- string m_namespace;
- bool m_fullNameDiscarded;
- string m_fullName;
- protected bool m_isValueType;
- IMetadataScope m_scope;
- ModuleDefinition m_module;
+ string fullname;
- CustomAttributeCollection m_customAttrs;
- GenericParameterCollection m_genparams;
+ protected Collection<GenericParameter> generic_parameters;
public override string Name {
get { return base.Name; }
set {
base.Name = value;
- m_fullNameDiscarded = true;
+ fullname = null;
}
}
public virtual string Namespace {
- get { return m_namespace; }
+ get { return @namespace; }
set {
- m_namespace = value;
- m_fullNameDiscarded = true;
+ @namespace = value;
+ fullname = null;
}
}
public virtual bool IsValueType {
- get { return m_isValueType; }
- set { m_isValueType = value; }
+ get { return value_type; }
+ set { value_type = value; }
}
- public virtual ModuleDefinition Module {
- get { return m_module; }
- set { m_module = value; }
- }
-
- public CustomAttributeCollection CustomAttributes {
+ public override ModuleDefinition Module {
get {
- if (m_customAttrs == null)
- m_customAttrs = new CustomAttributeCollection (this);
+ if (module != null)
+ return module;
- return m_customAttrs;
+ var declaring_type = this.DeclaringType;
+ if (declaring_type != null)
+ return declaring_type.Module;
+
+ return null;
}
}
- public GenericParameterCollection GenericParameters {
+ IGenericParameterProvider IGenericContext.Type {
+ get { return this; }
+ }
+
+ IGenericParameterProvider IGenericContext.Method {
+ get { return null; }
+ }
+
+ GenericParameterType IGenericParameterProvider.GenericParameterType {
+ get { return GenericParameterType.Type; }
+ }
+
+ public virtual bool HasGenericParameters {
+ get { return !generic_parameters.IsNullOrEmpty (); }
+ }
+
+ public virtual Collection<GenericParameter> GenericParameters {
get {
- if (m_genparams == null)
- m_genparams = new GenericParameterCollection (this);
- return m_genparams;
+ if (generic_parameters != null)
+ return generic_parameters;
+
+ return generic_parameters = new Collection<GenericParameter> ();
}
}
public virtual IMetadataScope Scope {
get {
- if (this.DeclaringType != null)
- return this.DeclaringType.Scope;
+ var declaring_type = this.DeclaringType;
+ if (declaring_type != null)
+ return declaring_type.Scope;
- return m_scope;
+ return scope;
}
}
@@ -96,58 +119,173 @@ namespace Mono.Cecil {
get { return this.DeclaringType != null; }
}
- public virtual string FullName {
+ public override TypeReference DeclaringType {
+ get { return base.DeclaringType; }
+ set {
+ base.DeclaringType = value;
+ fullname = null;
+ }
+ }
+
+ public override string FullName {
get {
- if (m_fullName != null && !m_fullNameDiscarded)
- return m_fullName;
+ if (fullname != null)
+ return fullname;
- if (this.IsNested)
- return string.Concat (this.DeclaringType.FullName, "/", this.Name);
+ if (IsNested)
+ return fullname = DeclaringType.FullName + "/" + Name;
- if (m_namespace == null || m_namespace.Length == 0)
- return this.Name;
+ if (string.IsNullOrEmpty (@namespace))
+ return fullname = Name;
- m_fullName = string.Concat (m_namespace, ".", this.Name);
- m_fullNameDiscarded = false;
- return m_fullName;
+ return fullname = @namespace + "." + Name;
}
}
- protected TypeReference (string name, string ns) : base (name)
+ public virtual bool IsByReference {
+ get { return false; }
+ }
+
+ public virtual bool IsPointer {
+ get { return false; }
+ }
+
+ public virtual bool IsSentinel {
+ get { return false; }
+ }
+
+ public virtual bool IsArray {
+ get { return false; }
+ }
+
+ public virtual bool IsGenericParameter {
+ get { return false; }
+ }
+
+ public virtual bool IsGenericInstance {
+ get { return false; }
+ }
+
+ public virtual bool IsRequiredModifier {
+ get { return false; }
+ }
+
+ public virtual bool IsOptionalModifier {
+ get { return false; }
+ }
+
+ public virtual bool IsPinned {
+ get { return false; }
+ }
+
+ public virtual bool IsFunctionPointer {
+ get { return false; }
+ }
+
+ public bool IsPrimitive {
+ get {
+ switch (etype) {
+ case ElementType.Boolean:
+ case ElementType.Char:
+ case ElementType.I:
+ case ElementType.U:
+ case ElementType.I1:
+ case ElementType.U1:
+ case ElementType.I2:
+ case ElementType.U2:
+ case ElementType.I4:
+ case ElementType.U4:
+ case ElementType.I8:
+ case ElementType.U8:
+ case ElementType.R4:
+ case ElementType.R8:
+ return true;
+ default:
+ return false;
+ }
+ }
+ }
+
+ public virtual MetadataType MetadataType {
+ get {
+ switch (etype) {
+ case ElementType.None:
+ return IsValueType ? MetadataType.ValueType : MetadataType.Class;
+ default:
+ return (MetadataType) etype;
+ }
+ }
+ }
+
+ protected TypeReference (string @namespace, string name)
+ : base (name)
{
- m_namespace = ns;
- m_fullNameDiscarded = false;
+ this.@namespace = @namespace ?? string.Empty;
+ this.token = new MetadataToken (TokenType.TypeRef, 0);
}
- internal TypeReference (string name, string ns, IMetadataScope scope) : this (name, ns)
+ public TypeReference (string @namespace, string name, IMetadataScope scope)
+ : this (@namespace, name)
{
- m_scope = scope;
+ this.scope = scope;
}
- public TypeReference (string name, string ns, IMetadataScope scope, bool valueType) :
- this (name, ns, scope)
+ public TypeReference (string @namespace, string name, IMetadataScope scope, bool valueType) :
+ this (@namespace, name, scope)
{
- this.IsValueType = valueType;
+ value_type = valueType;
}
- public virtual TypeReference GetOriginalType ()
+ public virtual TypeReference GetElementType ()
{
return this;
}
- internal void AttachToScope (IMetadataScope scope)
+ public virtual TypeDefinition Resolve ()
+ {
+ var module = this.Module;
+ if (module == null)
+ throw new NotSupportedException ();
+
+ return module.Resolve (this);
+ }
+ }
+
+ static partial class Mixin {
+
+ public static bool IsTypeOf (this TypeReference self, string @namespace, string name)
{
- m_scope = scope;
+ return self.Name == name
+ && self.Namespace == @namespace;
}
- public override void Accept (IReflectionVisitor visitor)
+ public static bool IsTypeSpecification (this TypeReference type)
{
- visitor.VisitTypeReference (this);
+ switch (type.etype) {
+ case ElementType.Array:
+ case ElementType.ByRef:
+ case ElementType.CModOpt:
+ case ElementType.CModReqD:
+ case ElementType.FnPtr:
+ case ElementType.GenericInst:
+ case ElementType.MVar:
+ case ElementType.Pinned:
+ case ElementType.Ptr:
+ case ElementType.SzArray:
+ case ElementType.Var:
+ return true;
+ }
+
+ return false;
}
- public override string ToString ()
+ public static TypeDefinition CheckedResolve (this TypeReference self)
{
- return this.FullName;
+ var type = self.Resolve ();
+ if (type == null)
+ throw new InvalidOperationException (string.Format ("Failed to resolve type: {0}", self.FullName));
+
+ return type;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReferenceCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReferenceCollection.cs
deleted file mode 100644
index 2482e38..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeReferenceCollection.cs
+++ /dev/null
@@ -1,214 +0,0 @@
-//
-// TypeReferenceCollection.cs
-//
-// Author:
-// Jb Evain (jbevain@gmail.com)
-//
-// Generated by /CodeGen/cecil-gen.rb do not edit
-// Fri Mar 30 18:43:56 +0200 2007
-//
-// (C) 2005 Jb Evain
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace Mono.Cecil {
-
- using System;
- using System.Collections;
- using System.Collections.Specialized;
-
- using Mono.Cecil.Cil;
-
- using Hcp = Mono.Cecil.HashCodeProvider;
- using Cmp = System.Collections.Comparer;
-
- public sealed class TypeReferenceCollection : NameObjectCollectionBase, IList, IReflectionVisitable {
-
- ModuleDefinition m_container;
-
- public TypeReference this [int index] {
- get { return this.BaseGet (index) as TypeReference; }
- set { this.BaseSet (index, value); }
- }
-
- public TypeReference this [string fullName] {
- get { return this.BaseGet (fullName) as TypeReference; }
- set { this.BaseSet (fullName, value); }
- }
-
- public ModuleDefinition Container {
- get { return m_container; }
- }
-
- public bool IsSynchronized {
- get { return false; }
- }
-
- public object SyncRoot {
- get { return this; }
- }
-
- bool IList.IsReadOnly {
- get { return false; }
- }
-
- bool IList.IsFixedSize {
- get { return false; }
- }
-
- object IList.this [int index] {
- get { return BaseGet (index); }
- set {
- Check (value);
- BaseSet (index, value);
- }
- }
-
- public TypeReferenceCollection (ModuleDefinition container) :
- base (Hcp.Instance, Cmp.Default)
- {
- m_container = container;
- }
-
- public void Add (TypeReference value)
- {
- if (value == null)
- throw new ArgumentNullException ("value");
-
- Attach (value);
-
- this.BaseAdd (value.FullName, value);
- }
-
- public void Clear ()
- {
- foreach (TypeReference item in this)
- Detach (item);
-
- this.BaseClear ();
- }
-
- public bool Contains (TypeReference value)
- {
- return Contains (value.FullName);
- }
-
- public bool Contains (string fullName)
- {
- return this.BaseGet (fullName) != null;
- }
-
- public int IndexOf (TypeReference value)
- {
- string [] keys = this.BaseGetAllKeys ();
- return Array.IndexOf (keys, value.FullName, 0, keys.Length);
- }
-
- public void Remove (TypeReference value)
- {
- this.BaseRemove (value.FullName);
-
- Detach (value);
- }
-
- public void RemoveAt (int index)
- {
- TypeReference item = this [index];
- Remove (item);
-
- Detach (item);
- }
-
- public void CopyTo (Array ary, int index)
- {
- this.BaseGetAllValues ().CopyTo (ary, index);
- }
-
- public new IEnumerator GetEnumerator ()
- {
- return this.BaseGetAllValues ().GetEnumerator ();
- }
-
- public void Accept (IReflectionVisitor visitor)
- {
- visitor.VisitTypeReferenceCollection (this);
- }
-
-#if CF_1_0 || CF_2_0
- internal object [] BaseGetAllValues ()
- {
- object [] values = new object [this.Count];
- for (int i=0; i < values.Length; ++i) {
- values [i] = this.BaseGet (i);
- }
- return values;
- }
-#endif
-
- void Check (object value)
- {
- if (!(value is TypeReference))
- throw new ArgumentException ();
- }
-
- int IList.Add (object value)
- {
- Check (value);
- Add (value as TypeReference);
- return 0;
- }
-
- bool IList.Contains (object value)
- {
- Check (value);
- return Contains (value as TypeReference);
- }
-
- int IList.IndexOf (object value)
- {
- throw new NotSupportedException ();
- }
-
- void IList.Insert (int index, object value)
- {
- throw new NotSupportedException ();
- }
-
- void IList.Remove (object value)
- {
- Check (value);
- Remove (value as TypeReference);
- }
-
- void Detach (TypeReference type)
- {
- type.Module = null;
- }
-
- void Attach (TypeReference type)
- {
- if (type.Module != null)
- throw new ReflectionException ("Type is already attached, clone it instead");
-
- type.Module = m_container;
- }
- }
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSpecification.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSpecification.cs
index 9648a4b..d484eff 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSpecification.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSpecification.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,55 +26,69 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
+
+using Mono.Cecil.Metadata;
- using System;
+namespace Mono.Cecil {
public abstract class TypeSpecification : TypeReference {
- private TypeReference m_elementType;
+ readonly TypeReference element_type;
+
+ public TypeReference ElementType {
+ get { return element_type; }
+ }
public override string Name {
- get { return m_elementType.Name; }
+ get { return element_type.Name; }
set { throw new NotSupportedException (); }
}
public override string Namespace {
- get { return m_elementType.Namespace; }
+ get { return element_type.Namespace; }
set { throw new NotSupportedException (); }
}
- public override bool IsValueType {
- get { return m_elementType.IsValueType; }
- set { throw new InvalidOperationException (); }
- }
-
public override IMetadataScope Scope {
- get { return m_elementType.Scope; }
+ get { return element_type.Scope; }
}
public override ModuleDefinition Module {
- get { return m_elementType.Module; }
- set { throw new InvalidOperationException (); }
+ get { return element_type.Module; }
}
- public TypeReference ElementType {
- get { return m_elementType; }
- set { m_elementType = value; }
+ public override string FullName {
+ get { return element_type.FullName; }
}
- public override string FullName {
- get { return m_elementType.FullName; }
+ internal override bool ContainsGenericParameter {
+ get { return element_type.ContainsGenericParameter; }
}
- internal TypeSpecification (TypeReference elementType) : base (string.Empty, string.Empty)
+ public override MetadataType MetadataType {
+ get { return (MetadataType) etype; }
+ }
+
+ internal TypeSpecification (TypeReference type)
+ : base (null, null)
{
- m_elementType = elementType;
+ this.element_type = type;
+ this.token = new MetadataToken (TokenType.TypeSpec);
}
- public override TypeReference GetOriginalType ()
+ public sealed override TypeReference GetElementType ()
+ {
+ return element_type.GetElementType ();
+ }
+ }
+
+ static partial class Mixin {
+
+ public static void CheckType (TypeReference type)
{
- return m_elementType.GetOriginalType ();
+ if (type == null)
+ throw new ArgumentNullException ("type");
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSystem.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSystem.cs
new file mode 100644
index 0000000..59f72a8
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/TypeSystem.cs
@@ -0,0 +1,272 @@
+//
+// TypeSystem.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+using Mono.Cecil.Metadata;
+
+namespace Mono.Cecil {
+
+ public abstract class TypeSystem {
+
+ sealed class CorlibTypeSystem : TypeSystem {
+
+ public CorlibTypeSystem (ModuleDefinition module)
+ : base (module)
+ {
+ }
+
+ internal override TypeReference LookupType (string @namespace, string name)
+ {
+ var metadata = module.MetadataSystem;
+ if (metadata.Types == null)
+ Initialize (module.Types);
+
+ var types = metadata.Types;
+
+ for (int i = 0; i < types.Length; i++) {
+ var type = types [i];
+ if (type == null)
+ continue;
+
+ if (type.Name == name && type.Namespace == @namespace)
+ return type;
+ }
+
+ return null;
+ }
+
+ static void Initialize (object obj)
+ {
+ }
+ }
+
+ sealed class CommonTypeSystem : TypeSystem {
+
+ AssemblyNameReference corlib;
+
+ public CommonTypeSystem (ModuleDefinition module)
+ : base (module)
+ {
+ }
+
+ internal override TypeReference LookupType (string @namespace, string name)
+ {
+ return CreateTypeReference (@namespace, name);
+ }
+
+ public AssemblyNameReference GetCorlibReference ()
+ {
+ if (corlib != null)
+ return corlib;
+
+ const string mscorlib = "mscorlib";
+
+ var references = module.AssemblyReferences;
+
+ for (int i = 0; i < references.Count; i++) {
+ var reference = references [i];
+ if (reference.Name == mscorlib)
+ return corlib = reference;
+ }
+
+ corlib = new AssemblyNameReference {
+ Name = mscorlib,
+ Version = GetCorlibVersion (),
+ PublicKeyToken = new byte [] { 0xb7, 0x7a, 0x5c, 0x56, 0x19, 0x34, 0xe0, 0x89 },
+ };
+
+ references.Add (corlib);
+
+ return corlib;
+ }
+
+ Version GetCorlibVersion ()
+ {
+ switch (module.Runtime) {
+ case TargetRuntime.Net_1_0:
+ case TargetRuntime.Net_1_1:
+ return new Version (1, 0, 0, 0);
+ case TargetRuntime.Net_2_0:
+ return new Version (2, 0, 0, 0);
+ case TargetRuntime.Net_4_0:
+ return new Version (4, 0, 0, 0);
+ default:
+ throw new NotSupportedException ();
+ }
+ }
+
+ TypeReference CreateTypeReference (string @namespace, string name)
+ {
+ var type = new TypeReference (@namespace, name, GetCorlibReference ());
+ type.module = module;
+ return type;
+ }
+ }
+
+ readonly ModuleDefinition module;
+
+ TypeReference type_object;
+ TypeReference type_void;
+ TypeReference type_bool;
+ TypeReference type_char;
+ TypeReference type_sbyte;
+ TypeReference type_byte;
+ TypeReference type_int16;
+ TypeReference type_uint16;
+ TypeReference type_int32;
+ TypeReference type_uint32;
+ TypeReference type_int64;
+ TypeReference type_uint64;
+ TypeReference type_single;
+ TypeReference type_double;
+ TypeReference type_intptr;
+ TypeReference type_uintptr;
+ TypeReference type_string;
+ TypeReference type_typedref;
+
+ TypeSystem (ModuleDefinition module)
+ {
+ this.module = module;
+ }
+
+ internal static TypeSystem CreateTypeSystem (ModuleDefinition module)
+ {
+ if (IsCorlib (module))
+ return new CorlibTypeSystem (module);
+
+ return new CommonTypeSystem (module);
+ }
+
+ static bool IsCorlib (ModuleDefinition module)
+ {
+ if (module.Assembly == null)
+ return false;
+
+ return module.Assembly.Name.Name == "mscorlib";
+ }
+
+ internal abstract TypeReference LookupType (string @namespace, string name);
+
+ TypeReference LookupSystemType (string name, ElementType element_type)
+ {
+ var type = LookupType ("System", name);
+ type.etype = element_type;
+ return type;
+ }
+
+ TypeReference LookupSystemValueType (string name, ElementType element_type)
+ {
+ var type = LookupSystemType (name, element_type);
+ type.IsValueType = true;
+ return type;
+ }
+
+ public IMetadataScope Corlib {
+ get {
+ var common = this as CommonTypeSystem;
+ if (common == null)
+ return module;
+
+ return common.GetCorlibReference ();
+ }
+ }
+
+ public TypeReference Object {
+ get { return type_object ?? (type_object = LookupSystemType ("Object", ElementType.Object)); }
+ }
+
+ public TypeReference Void {
+ get { return type_void ?? (type_void = LookupSystemType ("Void", ElementType.Void)); }
+ }
+
+ public TypeReference Boolean {
+ get { return type_bool ?? (type_bool = LookupSystemValueType ("Boolean", ElementType.Boolean)); }
+ }
+
+ public TypeReference Char {
+ get { return type_char ?? (type_char = LookupSystemValueType ("Char", ElementType.Char)); }
+ }
+
+ public TypeReference SByte {
+ get { return type_sbyte ?? (type_sbyte = LookupSystemValueType ("SByte", ElementType.I1)); }
+ }
+
+ public TypeReference Byte {
+ get { return type_byte ?? (type_byte = LookupSystemValueType ("Byte", ElementType.U1)); }
+ }
+
+ public TypeReference Int16 {
+ get { return type_int16 ?? (type_int16 = LookupSystemValueType ("Int16", ElementType.I2)); }
+ }
+
+ public TypeReference UInt16 {
+ get { return type_uint16 ?? (type_uint16 = LookupSystemValueType ("UInt16", ElementType.U2)); }
+ }
+
+ public TypeReference Int32 {
+ get { return type_int32 ?? (type_int32 = LookupSystemValueType ("Int32", ElementType.I4)); }
+ }
+
+ public TypeReference UInt32 {
+ get { return type_uint32 ?? (type_uint32 = LookupSystemValueType ("UInt32", ElementType.U4)); }
+ }
+
+ public TypeReference Int64 {
+ get { return type_int64 ?? (type_int64 = LookupSystemValueType ("Int64", ElementType.I8)); }
+ }
+
+ public TypeReference UInt64 {
+ get { return type_uint64 ?? (type_uint64 = LookupSystemValueType ("UInt64", ElementType.U8)); }
+ }
+
+ public TypeReference Single {
+ get { return type_single ?? (type_single = LookupSystemValueType ("Single", ElementType.R4)); }
+ }
+
+ public TypeReference Double {
+ get { return type_double ?? (type_double = LookupSystemValueType ("Double", ElementType.R8)); }
+ }
+
+ public TypeReference IntPtr {
+ get { return type_intptr ?? (type_intptr = LookupSystemValueType ("IntPtr", ElementType.I)); }
+ }
+
+ public TypeReference UIntPtr {
+ get { return type_uintptr ?? (type_uintptr = LookupSystemValueType ("UIntPtr", ElementType.U)); }
+ }
+
+ public TypeReference String {
+ get { return type_string ?? (type_string = LookupSystemType ("String", ElementType.String)); }
+ }
+
+ public TypeReference TypedReference {
+ get { return type_typedref ?? (type_typedref = LookupSystemValueType ("TypedReference", ElementType.TypedByRef)); }
+ }
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/VariantType.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/VariantType.cs
index eeeff2a..86d6daa 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/VariantType.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/VariantType.cs
@@ -4,7 +4,7 @@
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -29,24 +29,25 @@
namespace Mono.Cecil {
public enum VariantType {
+ None = 0,
I2 = 2,
I4 = 3,
R4 = 4,
R8 = 5,
CY = 6,
- DATE = 7,
- BSTR = 8,
- DISPATCH = 9,
- ERROR = 10,
- BOOL = 11,
- VARIANT = 12,
- UNKNOWN = 13,
- DECIMAL = 14,
+ Date = 7,
+ BStr = 8,
+ Dispatch = 9,
+ Error = 10,
+ Bool = 11,
+ Variant = 12,
+ Unknown = 13,
+ Decimal = 14,
I1 = 16,
UI1 = 17,
UI2 = 18,
UI4 = 19,
- INT = 22,
- UINT = 23
+ Int = 22,
+ UInt = 23
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Collections.Generic/Collection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Collections.Generic/Collection.cs
new file mode 100644
index 0000000..9177e39
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Collections.Generic/Collection.cs
@@ -0,0 +1,410 @@
+//
+// Collection.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Mono.Collections.Generic {
+
+ public class Collection<T> : IList<T>, IList {
+
+ internal T [] items;
+ internal int size;
+ int version;
+
+ public int Count {
+ get { return size; }
+ }
+
+ public T this [int index] {
+ get {
+ if (index >= size)
+ throw new ArgumentOutOfRangeException ();
+
+ return items [index];
+ }
+ set {
+ CheckIndex (index);
+ if (index == size)
+ throw new ArgumentOutOfRangeException ();
+
+ OnSet (value, index);
+
+ items [index] = value;
+ }
+ }
+
+ bool ICollection<T>.IsReadOnly {
+ get { return false; }
+ }
+
+ bool IList.IsFixedSize {
+ get { return false; }
+ }
+
+ bool IList.IsReadOnly {
+ get { return false; }
+ }
+
+ object IList.this [int index] {
+ get { return this [index]; }
+ set {
+ CheckIndex (index);
+
+ try {
+ this [index] = (T) value;
+ return;
+ } catch (InvalidCastException) {
+ } catch (NullReferenceException) {
+ }
+
+ throw new ArgumentException ();
+ }
+ }
+
+ int ICollection.Count {
+ get { return Count; }
+ }
+
+ bool ICollection.IsSynchronized {
+ get { return false; }
+ }
+
+ object ICollection.SyncRoot {
+ get { return this; }
+ }
+
+ public Collection ()
+ {
+ items = Empty<T>.Array;
+ }
+
+ public Collection (int capacity)
+ {
+ if (capacity < 0)
+ throw new ArgumentOutOfRangeException ();
+
+ items = new T [capacity];
+ }
+
+ public void Add (T item)
+ {
+ if (size == items.Length)
+ Grow (1);
+
+ OnAdd (item, size);
+
+ items [size++] = item;
+ version++;
+ }
+
+ public bool Contains (T item)
+ {
+ return IndexOf (item) != -1;
+ }
+
+ public int IndexOf (T item)
+ {
+ return Array.IndexOf (items, item, 0, size);
+ }
+
+ public void Insert (int index, T item)
+ {
+ CheckIndex (index);
+ if (size == items.Length)
+ Grow (1);
+
+ OnInsert (item, index);
+
+ Shift (index, 1);
+ items [index] = item;
+ version++;
+ }
+
+ public void RemoveAt (int index)
+ {
+ if (index < 0 || index >= size)
+ throw new ArgumentOutOfRangeException ();
+
+ var item = items [index];
+
+ OnRemove (item, index);
+
+ Shift (index, -1);
+ Array.Clear (items, size, 1);
+ version++;
+ }
+
+ public bool Remove (T item)
+ {
+ var index = IndexOf (item);
+ if (index == -1)
+ return false;
+
+ OnRemove (item, index);
+
+ Shift (index, -1);
+ Array.Clear (items, size, 1);
+ version++;
+
+ return true;
+ }
+
+ public void Clear ()
+ {
+ OnClear ();
+
+ Array.Clear (items, 0, size);
+ size = 0;
+ version++;
+ }
+
+ public void CopyTo (T [] array, int arrayIndex)
+ {
+ Array.Copy (items, 0, array, arrayIndex, size);
+ }
+
+ public T [] ToArray ()
+ {
+ var array = new T [size];
+ Array.Copy (items, 0, array, 0, size);
+ return array;
+ }
+
+ void CheckIndex (int index)
+ {
+ if (index < 0 || index > size)
+ throw new ArgumentOutOfRangeException ();
+ }
+
+ void Shift (int start, int delta)
+ {
+ if (delta < 0)
+ start -= delta;
+
+ if (start < size)
+ Array.Copy (items, start, items, start + delta, size - start);
+
+ size += delta;
+
+ if (delta < 0)
+ Array.Clear (items, size, -delta);
+ }
+
+ protected virtual void OnAdd (T item, int index)
+ {
+ }
+
+ protected virtual void OnInsert (T item, int index)
+ {
+ }
+
+ protected virtual void OnSet (T item, int index)
+ {
+ }
+
+ protected virtual void OnRemove (T item, int index)
+ {
+ }
+
+ protected virtual void OnClear ()
+ {
+ }
+
+ internal virtual void Grow (int desired)
+ {
+ int new_size = size + desired;
+ if (new_size <= items.Length)
+ return;
+
+ const int default_capacity = 4;
+
+ new_size = System.Math.Max (
+ System.Math.Max (items.Length * 2, default_capacity),
+ new_size);
+
+#if !CF
+ Array.Resize (ref items, new_size);
+#else
+ var array = new T [new_size];
+ Array.Copy (items, array, size);
+ items = array;
+#endif
+ }
+
+ int IList.Add (object value)
+ {
+ try {
+ Add ((T) value);
+ return size - 1;
+ } catch (InvalidCastException) {
+ } catch (NullReferenceException) {
+ }
+
+ throw new ArgumentException ();
+ }
+
+ void IList.Clear ()
+ {
+ Clear ();
+ }
+
+ bool IList.Contains (object value)
+ {
+ return ((IList) this).IndexOf (value) > -1;
+ }
+
+ int IList.IndexOf (object value)
+ {
+ try {
+ return IndexOf ((T) value);
+ } catch (InvalidCastException) {
+ } catch (NullReferenceException) {
+ }
+
+ return -1;
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ CheckIndex (index);
+
+ try {
+ Insert (index, (T) value);
+ return;
+ } catch (InvalidCastException) {
+ } catch (NullReferenceException) {
+ }
+
+ throw new ArgumentException ();
+ }
+
+ void IList.Remove (object value)
+ {
+ try {
+ Remove ((T) value);
+ } catch (InvalidCastException) {
+ } catch (NullReferenceException) {
+ }
+ }
+
+ void IList.RemoveAt (int index)
+ {
+ RemoveAt (index);
+ }
+
+ void ICollection.CopyTo (Array array, int index)
+ {
+ Array.Copy (items, 0, array, index, size);
+ }
+
+ public Enumerator GetEnumerator ()
+ {
+ return new Enumerator (this);
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return new Enumerator (this);
+ }
+
+ IEnumerator<T> IEnumerable<T>.GetEnumerator ()
+ {
+ return new Enumerator (this);
+ }
+
+ public struct Enumerator : IEnumerator<T>, IDisposable {
+
+ Collection<T> collection;
+ T current;
+
+ int next;
+ readonly int version;
+
+ public T Current {
+ get { return current; }
+ }
+
+ object IEnumerator.Current {
+ get {
+ CheckState ();
+
+ if (next <= 0)
+ throw new InvalidOperationException ();
+
+ return current;
+ }
+ }
+
+ internal Enumerator (Collection<T> collection)
+ : this ()
+ {
+ this.collection = collection;
+ this.version = collection.version;
+ }
+
+ public bool MoveNext ()
+ {
+ CheckState ();
+
+ if (next < 0)
+ return false;
+
+ if (next < collection.size) {
+ current = collection.items [next++];
+ return true;
+ }
+
+ next = -1;
+ return false;
+ }
+
+ public void Reset ()
+ {
+ CheckState ();
+
+ next = 0;
+ }
+
+ void CheckState ()
+ {
+ if (collection == null)
+ throw new ObjectDisposedException (GetType ().FullName);
+
+ if (version != collection.version)
+ throw new InvalidOperationException ();
+ }
+
+ public void Dispose ()
+ {
+ collection = null;
+ }
+ }
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Collections.Generic/ReadOnlyCollection.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Collections.Generic/ReadOnlyCollection.cs
new file mode 100644
index 0000000..35c9cd8
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Collections.Generic/ReadOnlyCollection.cs
@@ -0,0 +1,98 @@
+//
+// ReadOnlyCollection.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+
+namespace Mono.Collections.Generic {
+
+ public sealed class ReadOnlyCollection<T> : Collection<T>, IList {
+
+ static ReadOnlyCollection<T> empty;
+
+ public static ReadOnlyCollection<T> Empty {
+ get { return empty ?? (empty = new ReadOnlyCollection<T> ()); }
+ }
+
+ bool IList.IsReadOnly {
+ get { return true; }
+ }
+
+ private ReadOnlyCollection ()
+ {
+ }
+
+ public ReadOnlyCollection (T [] array)
+ {
+ if (array == null)
+ throw new ArgumentNullException ();
+
+ this.items = array;
+ this.size = array.Length;
+ }
+
+ public ReadOnlyCollection (Collection<T> collection)
+ {
+ if (collection == null)
+ throw new ArgumentNullException ();
+
+ this.items = collection.items;
+ this.size = collection.size;
+ }
+
+ internal override void Grow (int desired)
+ {
+ throw new InvalidOperationException ();
+ }
+
+ protected override void OnAdd (T item, int index)
+ {
+ throw new InvalidOperationException ();
+ }
+
+ protected override void OnClear ()
+ {
+ throw new InvalidOperationException ();
+ }
+
+ protected override void OnInsert (T item, int index)
+ {
+ throw new InvalidOperationException ();
+ }
+
+ protected override void OnRemove (T item, int index)
+ {
+ throw new InvalidOperationException ();
+ }
+
+ protected override void OnSet (T item, int index)
+ {
+ throw new InvalidOperationException ();
+ }
+ }
+}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoConvert.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoConvert.cs
new file mode 100644
index 0000000..26a4ba2
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoConvert.cs
@@ -0,0 +1,243 @@
+//
+// CryptoConvert.cs - Crypto Convertion Routines
+//
+// Author:
+// Sebastien Pouliot <sebastien@ximian.com>
+//
+// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+// Copyright (C) 2004-2006 Novell Inc. (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+
+#if !(SILVERLIGHT || READ_ONLY)
+
+namespace Mono.Security.Cryptography {
+
+ static class CryptoConvert {
+
+ static private int ToInt32LE (byte [] bytes, int offset)
+ {
+ return (bytes [offset+3] << 24) | (bytes [offset+2] << 16) | (bytes [offset+1] << 8) | bytes [offset];
+ }
+
+ static private uint ToUInt32LE (byte [] bytes, int offset)
+ {
+ return (uint)((bytes [offset+3] << 24) | (bytes [offset+2] << 16) | (bytes [offset+1] << 8) | bytes [offset]);
+ }
+
+ static private byte[] Trim (byte[] array)
+ {
+ for (int i=0; i < array.Length; i++) {
+ if (array [i] != 0x00) {
+ byte[] result = new byte [array.Length - i];
+ Buffer.BlockCopy (array, i, result, 0, result.Length);
+ return result;
+ }
+ }
+ return null;
+ }
+
+ static RSA FromCapiPrivateKeyBlob (byte[] blob, int offset)
+ {
+ RSAParameters rsap = new RSAParameters ();
+ try {
+ if ((blob [offset] != 0x07) || // PRIVATEKEYBLOB (0x07)
+ (blob [offset+1] != 0x02) || // Version (0x02)
+ (blob [offset+2] != 0x00) || // Reserved (word)
+ (blob [offset+3] != 0x00) ||
+ (ToUInt32LE (blob, offset+8) != 0x32415352)) // DWORD magic = RSA2
+ throw new CryptographicException ("Invalid blob header");
+
+ // ALGID (CALG_RSA_SIGN, CALG_RSA_KEYX, ...)
+ // int algId = ToInt32LE (blob, offset+4);
+
+ // DWORD bitlen
+ int bitLen = ToInt32LE (blob, offset+12);
+
+ // DWORD public exponent
+ byte[] exp = new byte [4];
+ Buffer.BlockCopy (blob, offset+16, exp, 0, 4);
+ Array.Reverse (exp);
+ rsap.Exponent = Trim (exp);
+
+ int pos = offset+20;
+ // BYTE modulus[rsapubkey.bitlen/8];
+ int byteLen = (bitLen >> 3);
+ rsap.Modulus = new byte [byteLen];
+ Buffer.BlockCopy (blob, pos, rsap.Modulus, 0, byteLen);
+ Array.Reverse (rsap.Modulus);
+ pos += byteLen;
+
+ // BYTE prime1[rsapubkey.bitlen/16];
+ int byteHalfLen = (byteLen >> 1);
+ rsap.P = new byte [byteHalfLen];
+ Buffer.BlockCopy (blob, pos, rsap.P, 0, byteHalfLen);
+ Array.Reverse (rsap.P);
+ pos += byteHalfLen;
+
+ // BYTE prime2[rsapubkey.bitlen/16];
+ rsap.Q = new byte [byteHalfLen];
+ Buffer.BlockCopy (blob, pos, rsap.Q, 0, byteHalfLen);
+ Array.Reverse (rsap.Q);
+ pos += byteHalfLen;
+
+ // BYTE exponent1[rsapubkey.bitlen/16];
+ rsap.DP = new byte [byteHalfLen];
+ Buffer.BlockCopy (blob, pos, rsap.DP, 0, byteHalfLen);
+ Array.Reverse (rsap.DP);
+ pos += byteHalfLen;
+
+ // BYTE exponent2[rsapubkey.bitlen/16];
+ rsap.DQ = new byte [byteHalfLen];
+ Buffer.BlockCopy (blob, pos, rsap.DQ, 0, byteHalfLen);
+ Array.Reverse (rsap.DQ);
+ pos += byteHalfLen;
+
+ // BYTE coefficient[rsapubkey.bitlen/16];
+ rsap.InverseQ = new byte [byteHalfLen];
+ Buffer.BlockCopy (blob, pos, rsap.InverseQ, 0, byteHalfLen);
+ Array.Reverse (rsap.InverseQ);
+ pos += byteHalfLen;
+
+ // ok, this is hackish but CryptoAPI support it so...
+ // note: only works because CRT is used by default
+ // http://bugzilla.ximian.com/show_bug.cgi?id=57941
+ rsap.D = new byte [byteLen]; // must be allocated
+ if (pos + byteLen + offset <= blob.Length) {
+ // BYTE privateExponent[rsapubkey.bitlen/8];
+ Buffer.BlockCopy (blob, pos, rsap.D, 0, byteLen);
+ Array.Reverse (rsap.D);
+ }
+ }
+ catch (Exception e) {
+ throw new CryptographicException ("Invalid blob.", e);
+ }
+
+ RSA rsa = null;
+ try {
+ rsa = RSA.Create ();
+ rsa.ImportParameters (rsap);
+ }
+ catch (CryptographicException ce) {
+ // this may cause problem when this code is run under
+ // the SYSTEM identity on Windows (e.g. ASP.NET). See
+ // http://bugzilla.ximian.com/show_bug.cgi?id=77559
+ try {
+ CspParameters csp = new CspParameters ();
+ csp.Flags = CspProviderFlags.UseMachineKeyStore;
+ rsa = new RSACryptoServiceProvider (csp);
+ rsa.ImportParameters (rsap);
+ }
+ catch {
+ // rethrow original, not the later, exception if this fails
+ throw ce;
+ }
+ }
+ return rsa;
+ }
+
+ static RSA FromCapiPublicKeyBlob (byte[] blob, int offset)
+ {
+ try {
+ if ((blob [offset] != 0x06) || // PUBLICKEYBLOB (0x06)
+ (blob [offset+1] != 0x02) || // Version (0x02)
+ (blob [offset+2] != 0x00) || // Reserved (word)
+ (blob [offset+3] != 0x00) ||
+ (ToUInt32LE (blob, offset+8) != 0x31415352)) // DWORD magic = RSA1
+ throw new CryptographicException ("Invalid blob header");
+
+ // ALGID (CALG_RSA_SIGN, CALG_RSA_KEYX, ...)
+ // int algId = ToInt32LE (blob, offset+4);
+
+ // DWORD bitlen
+ int bitLen = ToInt32LE (blob, offset+12);
+
+ // DWORD public exponent
+ RSAParameters rsap = new RSAParameters ();
+ rsap.Exponent = new byte [3];
+ rsap.Exponent [0] = blob [offset+18];
+ rsap.Exponent [1] = blob [offset+17];
+ rsap.Exponent [2] = blob [offset+16];
+
+ int pos = offset+20;
+ // BYTE modulus[rsapubkey.bitlen/8];
+ int byteLen = (bitLen >> 3);
+ rsap.Modulus = new byte [byteLen];
+ Buffer.BlockCopy (blob, pos, rsap.Modulus, 0, byteLen);
+ Array.Reverse (rsap.Modulus);
+
+ RSA rsa = null;
+ try {
+ rsa = RSA.Create ();
+ rsa.ImportParameters (rsap);
+ }
+ catch (CryptographicException) {
+ // this may cause problem when this code is run under
+ // the SYSTEM identity on Windows (e.g. ASP.NET). See
+ // http://bugzilla.ximian.com/show_bug.cgi?id=77559
+ CspParameters csp = new CspParameters ();
+ csp.Flags = CspProviderFlags.UseMachineKeyStore;
+ rsa = new RSACryptoServiceProvider (csp);
+ rsa.ImportParameters (rsap);
+ }
+ return rsa;
+ }
+ catch (Exception e) {
+ throw new CryptographicException ("Invalid blob.", e);
+ }
+ }
+
+ // PRIVATEKEYBLOB
+ // PUBLICKEYBLOB
+ static public RSA FromCapiKeyBlob (byte[] blob)
+ {
+ return FromCapiKeyBlob (blob, 0);
+ }
+
+ static public RSA FromCapiKeyBlob (byte[] blob, int offset)
+ {
+ if (blob == null)
+ throw new ArgumentNullException ("blob");
+ if (offset >= blob.Length)
+ throw new ArgumentException ("blob is too small.");
+
+ switch (blob [offset]) {
+ case 0x00:
+ // this could be a public key inside an header
+ // like "sn -e" would produce
+ if (blob [offset + 12] == 0x06) {
+ return FromCapiPublicKeyBlob (blob, offset + 12);
+ }
+ break;
+ case 0x06:
+ return FromCapiPublicKeyBlob (blob, offset);
+ case 0x07:
+ return FromCapiPrivateKeyBlob (blob, offset);
+ }
+ throw new CryptographicException ("Unknown blob format.");
+ }
+ }
+}
+
+#endif
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoService.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoService.cs
new file mode 100644
index 0000000..f504f5e
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Security.Cryptography/CryptoService.cs
@@ -0,0 +1,177 @@
+//
+// CryptoService.cs
+//
+// Author:
+// Jb Evain (jbevain@gmail.com)
+//
+// Copyright (c) 2008 - 2010 Jb Evain
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Security.Cryptography;
+
+#if !READ_ONLY
+
+#if !SILVERLIGHT && !CF
+using System.Runtime.Serialization;
+using Mono.Security.Cryptography;
+#endif
+
+using Mono.Cecil.PE;
+
+namespace Mono.Cecil {
+
+ // Most of this code has been adapted
+ // from Jeroen Frijters' fantastic work
+ // in IKVM.Reflection.Emit. Thanks!
+
+ static class CryptoService {
+
+#if !SILVERLIGHT && !CF
+ public static void StrongName (Stream stream, ImageWriter writer, StrongNameKeyPair key_pair)
+ {
+ int strong_name_pointer;
+
+ var strong_name = CreateStrongName (key_pair, HashStream (stream, writer, out strong_name_pointer));
+ PatchStrongName (stream, strong_name_pointer, strong_name);
+ }
+
+ static void PatchStrongName (Stream stream, int strong_name_pointer, byte [] strong_name)
+ {
+ stream.Seek (strong_name_pointer, SeekOrigin.Begin);
+ stream.Write (strong_name, 0, strong_name.Length);
+ }
+
+ static byte [] CreateStrongName (StrongNameKeyPair key_pair, byte [] hash)
+ {
+ const string hash_algo = "SHA1";
+
+ using (var rsa = key_pair.CreateRSA ()) {
+ var formatter = new RSAPKCS1SignatureFormatter (rsa);
+ formatter.SetHashAlgorithm (hash_algo);
+
+ byte [] signature = formatter.CreateSignature (hash);
+ Array.Reverse (signature);
+
+ return signature;
+ }
+ }
+
+ static byte [] HashStream (Stream stream, ImageWriter writer, out int strong_name_pointer)
+ {
+ const int buffer_size = 8192;
+
+ var text = writer.text;
+ var header_size = (int) writer.GetHeaderSize ();
+ var text_section_pointer = (int) text.PointerToRawData;
+ var strong_name_directory = writer.GetStrongNameSignatureDirectory ();
+
+ if (strong_name_directory.Size == 0)
+ throw new InvalidOperationException ();
+
+ strong_name_pointer = (int) (text_section_pointer
+ + (strong_name_directory.VirtualAddress - text.VirtualAddress));
+ var strong_name_length = (int) strong_name_directory.Size;
+
+ var sha1 = new SHA1Managed ();
+ var buffer = new byte [buffer_size];
+ using (var crypto_stream = new CryptoStream (Stream.Null, sha1, CryptoStreamMode.Write)) {
+
+ stream.Seek (0, SeekOrigin.Begin);
+ CopyStreamChunk (stream, crypto_stream, buffer, header_size);
+
+ stream.Seek (text_section_pointer, SeekOrigin.Begin);
+ CopyStreamChunk (stream, crypto_stream, buffer, (int) strong_name_pointer - text_section_pointer);
+
+ stream.Seek (strong_name_length, SeekOrigin.Current);
+ CopyStreamChunk (stream, crypto_stream, buffer, (int) (stream.Length - (strong_name_pointer + strong_name_length)));
+ }
+
+ return sha1.Hash;
+ }
+#endif
+ static void CopyStreamChunk (Stream stream, Stream dest_stream, byte [] buffer, int length)
+ {
+ while (length > 0) {
+ int read = stream.Read (buffer, 0, System.Math.Min (buffer.Length, length));
+ dest_stream.Write (buffer, 0, read);
+ length -= read;
+ }
+ }
+
+ public static byte [] ComputeHash (string file)
+ {
+ if (!File.Exists (file))
+ return Empty<byte>.Array;
+
+ const int buffer_size = 8192;
+
+ var sha1 = new SHA1Managed ();
+
+ using (var stream = new FileStream (file, FileMode.Open, FileAccess.Read, FileShare.Read)) {
+
+ var buffer = new byte [buffer_size];
+
+ using (var crypto_stream = new CryptoStream (Stream.Null, sha1, CryptoStreamMode.Write))
+ CopyStreamChunk (stream, crypto_stream, buffer, (int) stream.Length);
+ }
+
+ return sha1.Hash;
+ }
+ }
+
+#if !SILVERLIGHT && !CF
+ static partial class Mixin {
+
+ public static RSA CreateRSA (this StrongNameKeyPair key_pair)
+ {
+ byte [] key;
+ string key_container;
+
+ if (!TryGetKeyContainer (key_pair, out key, out key_container))
+ return CryptoConvert.FromCapiKeyBlob (key);
+
+ var parameters = new CspParameters {
+ Flags = CspProviderFlags.UseMachineKeyStore,
+ KeyContainerName = key_container,
+ KeyNumber = 2,
+ };
+
+ return new RSACryptoServiceProvider (parameters);
+ }
+
+ static bool TryGetKeyContainer (ISerializable key_pair, out byte [] key, out string key_container)
+ {
+ var info = new SerializationInfo (typeof (StrongNameKeyPair), new FormatterConverter ());
+ key_pair.GetObjectData (info, new StreamingContext ());
+
+ key = (byte []) info.GetValue ("_keyPairArray", typeof (byte []));
+ key_container = info.GetString ("_keyPairContainer");
+ return key_container != null;
+ }
+ }
+#endif
+}
+
+#endif
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/ChangeLog b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/ChangeLog
deleted file mode 100644
index 6fc2a0c..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/ChangeLog
+++ /dev/null
@@ -1,34 +0,0 @@
-2008-02-06 Lluis Sanchez Gual <lluis@novell.com>
-
- * ChangeLog, SecurityParser.cs, SmallXmlParser.cs, MiniParser.cs: Added
- support for pluggable add-in assembly reflectors. Implemented an add-in
- assembly reflector based on Cecil.
-
-2005-06-15 Atsushi Enomoto <atsushi@ximian.com>
-
- * SmallXmlParser.cs, SecurityParser.cs : they can be CLSCompliant now.
-
-2005-05-12 Atsushi Enomoto <atsushi@ximian.com>
-
- * SmallXmlParser.cs,
- SecurityParser.cs : Use new SmallXmlParser.cs instead of MiniParser.
-
-2004-09-16 Sebastien Pouliot <sebastien@ximian.com>
-
- * MiniParser.cs: Fixed warning (l4) for unused variables. Removed
- duplicate (and identical) license.
-
-2004-05-14 Marek Safar <marek.safar@seznam.cz>
-
- * MiniParser.cs, SecurityParser.cs: [CLSCompliant (false)]
- only for public mode.
-
-2003-07-05 Sebastien Pouliot <spouliot@videotron.ca>
-
- * SecurityParser.cs: Parse an XML string and convert it to a
- SecurityElement object.
-
-2003-02-08 Sebastien Pouliot <spouliot@videotron.ca>
-
- * MiniParser.cs: Renamed namespace to match new location.
-
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/MiniParser.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/MiniParser.cs
deleted file mode 100644
index 4c3da2d..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/MiniParser.cs
+++ /dev/null
@@ -1,621 +0,0 @@
-//
-// System.Security.Cryptography.MiniParser: Internal XML parser implementation
-//
-// Authors:
-// Sergey Chaban
-//
-// Copyright (c) 2001, 2002 Wild West Software
-// Copyright (c) 2002 Sergey Chaban
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Text;
-using System.Collections;
-using System.Globalization;
-
-namespace Mono.Xml {
-
- internal class MiniParser {
-
- public interface IReader {
- int Read();
- }
-
- public interface IAttrList {
- int Length {get;}
- bool IsEmpty {get;}
- string GetName(int i);
- string GetValue(int i);
- string GetValue(string name);
- void ChangeValue(string name, string newValue);
- string[] Names {get;}
- string[] Values {get;}
- }
-
- public interface IMutableAttrList : IAttrList {
- void Clear();
- void Add(string name, string value);
- void CopyFrom(IAttrList attrs);
- void Remove(int i);
- void Remove(string name);
- }
-
- public interface IHandler {
- void OnStartParsing(MiniParser parser);
- void OnStartElement(string name, IAttrList attrs);
- void OnEndElement(string name);
- void OnChars(string ch);
- void OnEndParsing(MiniParser parser);
- }
-
- public class HandlerAdapter : IHandler {
- public HandlerAdapter() {}
- public void OnStartParsing(MiniParser parser) {}
- public void OnStartElement(string name, IAttrList attrs) {}
- public void OnEndElement(string name) {}
- public void OnChars(string ch) {}
- public void OnEndParsing(MiniParser parser) {}
- }
-
- private enum CharKind : byte {
- LEFT_BR = 0,
- RIGHT_BR = 1,
- SLASH = 2,
- PI_MARK = 3,
- EQ = 4,
- AMP = 5,
- SQUOTE = 6,
- DQUOTE = 7,
- BANG = 8,
- LEFT_SQBR = 9,
- SPACE = 0xA,
- RIGHT_SQBR = 0xB,
- TAB = 0xC,
- CR = 0xD,
- EOL = 0xE,
- CHARS = 0xF,
- UNKNOWN = 0x1F
- }
-
- private enum ActionCode : byte {
- START_ELEM = 0,
- END_ELEM = 1,
- END_NAME = 2,
- SET_ATTR_NAME = 3,
- SET_ATTR_VAL = 4,
- SEND_CHARS = 5,
- START_CDATA = 6,
- END_CDATA = 7,
- ERROR = 8,
- STATE_CHANGE = 9,
- FLUSH_CHARS_STATE_CHANGE = 0xA,
- ACC_CHARS_STATE_CHANGE = 0xB,
- ACC_CDATA = 0xC,
- PROC_CHAR_REF = 0xD,
- UNKNOWN = 0xF
- }
-
- public class AttrListImpl : IMutableAttrList {
- protected ArrayList names;
- protected ArrayList values;
-
- public AttrListImpl() : this(0) {}
-
- public AttrListImpl(int initialCapacity) {
- if (initialCapacity <= 0) {
- names = new ArrayList();
- values = new ArrayList();
- } else {
- names = new ArrayList(initialCapacity);
- values = new ArrayList(initialCapacity);
- }
- }
-
- public AttrListImpl(IAttrList attrs)
- : this(attrs != null ? attrs.Length : 0) {
- if (attrs != null) this.CopyFrom(attrs);
- }
-
- public int Length {
- get {return names.Count;}
- }
-
- public bool IsEmpty {
- get {return this.Length != 0;}
- }
-
- public string GetName(int i) {
- string res = null;
- if (i >= 0 && i < this.Length) {
- res = names[i] as string;
- }
- return res;
- }
-
- public string GetValue(int i) {
- string res = null;
- if (i >= 0 && i < this.Length) {
- res = values[i] as string;
- }
- return res;
- }
-
- public string GetValue(string name) {
- return this.GetValue(names.IndexOf(name));
- }
-
- public void ChangeValue(string name, string newValue) {
- int i = names.IndexOf(name);
- if (i >= 0 && i < this.Length) {
- values[i] = newValue;
- }
- }
-
- public string[] Names {
- get {return names.ToArray(typeof(string)) as string[];}
- }
-
- public string[] Values {
- get {return values.ToArray(typeof(string)) as string[];}
- }
-
- public void Clear() {
- names.Clear();
- values.Clear();
- }
-
- public void Add(string name, string value) {
- names.Add(name);
- values.Add(value);
- }
-
- public void Remove(int i) {
- if (i >= 0) {
- names.RemoveAt(i);
- values.RemoveAt(i);
- }
- }
-
- public void Remove(string name) {
- this.Remove(names.IndexOf(name));
- }
-
- public void CopyFrom(IAttrList attrs) {
- if (attrs != null && ((object)this == (object)attrs)) {
- this.Clear();
- int n = attrs.Length;
- for (int i = 0; i < n; i++) {
- this.Add(attrs.GetName(i), attrs.GetValue(i));
- }
- }
- }
- }
-
- public class XMLError : Exception {
- protected string descr;
- protected int line, column;
- public XMLError() : this("Unknown") {}
- public XMLError(string descr) : this(descr, -1, -1) {}
- public XMLError(string descr, int line, int column)
- : base(descr) {
- this.descr = descr;
- this.line = line;
- this.column = column;
- }
- public int Line {get {return line;}}
- public int Column {get {return column;}}
- public override string ToString() {
- return (String.Format("{0} @ (line = {1}, col = {2})", descr, line, column));
- }
- }
-
- private static readonly int INPUT_RANGE = 13;
- private static readonly ushort[] tbl = {
- (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 1), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 0), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 128), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 128),
- (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 2), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 133), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 16), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.FLUSH_CHARS_STATE_CHANGE << 8) | 4),
- (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.END_ELEM << 8) | 0), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 2), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 2), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129),
- (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 5), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3),
- (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 4), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.END_NAME << 8) | 6), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.END_NAME << 8) | 7), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.END_NAME << 8) | 8), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129),
- (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 0), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 3),
- (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 0), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ERROR << 8) | 129),
- (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.FLUSH_CHARS_STATE_CHANGE << 8) | 1), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.PROC_CHAR_REF << 8) | 10), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 7), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10),
- (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 9), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.START_ELEM << 8) | 6), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.START_ELEM << 8) | 7), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 8), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129),
- (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 9), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.SET_ATTR_NAME << 8) | 11), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 12), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 130),
- (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 13), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.PROC_CHAR_REF << 8) | 10), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 10),
- (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 11), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 132), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ERROR << 8) | 132),
- (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.SET_ATTR_NAME << 8) | 11), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 12), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 130), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ERROR << 8) | 130),
- (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.SEND_CHARS << 8) | 2), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 16), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 134), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ERROR << 8) | 134),
- (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.SET_ATTR_VAL << 8) | 17), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.PROC_CHAR_REF << 8) | 14), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 14),
- (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.SET_ATTR_VAL << 8) | 17), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.PROC_CHAR_REF << 8) | 15), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 15),
- (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.START_CDATA << 8) | 18), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 0), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.START_CDATA << 8) | 19),
- (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.START_ELEM << 8) | 6), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.START_ELEM << 8) | 7), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.STATE_CHANGE << 8) | 17), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CHARS_STATE_CHANGE << 8) | 9), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ERROR << 8) | 129), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ERROR << 8) | 129),
- (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.END_CDATA << 8) | 10), (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 18),
- (ushort)(((ushort)CharKind.LEFT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SLASH << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.RIGHT_BR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.PI_MARK << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.EQ << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.AMP << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.BANG << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.LEFT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.SPACE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.RIGHT_SQBR << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.DQUOTE << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19), (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.ACC_CDATA << 8) | 19),
- (ushort)(((ushort)CharKind.CHARS << 12) | ((ushort)ActionCode.UNKNOWN << 8) | 255),
- 0xFFFF
- };
-
- protected static string[] errors = {
- /* 0 */ "Expected element",
- /* 1 */ "Invalid character in tag",
- /* 2 */ "No '='",
- /* 3 */ "Invalid character entity",
- /* 4 */ "Invalid attr value",
- /* 5 */ "Empty tag",
- /* 6 */ "No end tag",
- /* 7 */ "Bad entity ref"
- };
-
- protected int line;
- protected int col;
- protected int[] twoCharBuff;
- protected bool splitCData;
-
- public MiniParser() {
- twoCharBuff = new int[2];
- splitCData = false;
- Reset();
- }
-
- public void Reset() {
- line = 0;
- col = 0;
- }
-
- protected static bool StrEquals(string str, StringBuilder sb, int sbStart, int len) {
- if (len != str.Length) return false;
- for (int i = 0; i < len; i++) {
- if (str[i] != sb[sbStart + i]) return false;
- }
- return true;
- }
-
- protected void FatalErr(string descr) {
- throw new XMLError(descr, this.line, this.col);
- }
-
- protected static int Xlat(int charCode, int state) {
- int p = state * INPUT_RANGE;
- int n = System.Math.Min(tbl.Length - p, INPUT_RANGE);
- for (;--n >= 0;) {
- ushort code = tbl[p];
- if (charCode == (code >> 12)) return (code & 0xFFF);
- p++;
- }
- return 0xFFF;
- }
-
- public void Parse(IReader reader, IHandler handler) {
- if (reader == null) throw new ArgumentNullException("reader");
- if (handler == null) handler = new HandlerAdapter();
-
- AttrListImpl attrList = new AttrListImpl();
- string lastAttrName = null;
- Stack tagStack = new Stack();
- string elementName = null;
- line = 1;
- col = 0;
- int currCh = 0;
- int stateCode = 0;
- StringBuilder sbChars = new StringBuilder();
- bool seenCData = false;
- bool isComment = false;
- bool isDTD = false;
- int bracketSwitch = 0;
-
- handler.OnStartParsing(this);
-
- while (true) {
- ++this.col;
-
- currCh = reader.Read();
-
- if (currCh == -1) {
- if (stateCode != 0) {
- FatalErr("Unexpected EOF");
- }
- break;
- }
-
- int charCode = "<>/?=&'\"![ ]\t\r\n".IndexOf((char)currCh) & 0xF;
- if (charCode == (int)CharKind.CR) continue; // ignore
- // whitepace ::= (#x20 | #x9 | #xd | #xa)+
- if (charCode == (int)CharKind.TAB) charCode = (int)CharKind.SPACE; // tab == space
- if (charCode == (int)CharKind.EOL) {
- this.col = 0;
- this.line++;
- charCode = (int)CharKind.SPACE;
- }
-
- int actionCode = MiniParser.Xlat(charCode, stateCode);
- stateCode = actionCode & 0xFF;
- // Ignore newline inside attribute value.
- if (currCh == '\n' && (stateCode == 0xE || stateCode == 0xF)) continue;
- actionCode >>= 8;
-
- if (stateCode >= 0x80) {
- if (stateCode == 0xFF) {
- FatalErr("State dispatch error.");
- } else {
- FatalErr(errors[stateCode ^ 0x80]);
- }
- }
-
- switch (actionCode) {
- case (int)ActionCode.START_ELEM:
- handler.OnStartElement(elementName, attrList);
- if (currCh != '/') {
- tagStack.Push(elementName);
- } else {
- handler.OnEndElement(elementName);
- }
- attrList.Clear();
- break;
-
- case (int)ActionCode.END_ELEM:
- elementName = sbChars.ToString();
- sbChars = new StringBuilder();
- string endName = null;
- if (tagStack.Count == 0 ||
- elementName != (endName = tagStack.Pop() as string)) {
- if (endName == null) {
- FatalErr("Tag stack underflow");
- } else {
- FatalErr(String.Format("Expected end tag '{0}' but found '{1}'", elementName, endName));
- }
- }
- handler.OnEndElement(elementName);
- break;
-
- case (int)ActionCode.END_NAME:
- elementName = sbChars.ToString();
- sbChars = new StringBuilder();
- if (currCh != '/' && currCh != '>') break;
- goto case (int)ActionCode.START_ELEM;
-
- case (int)ActionCode.SET_ATTR_NAME:
- lastAttrName = sbChars.ToString();
- sbChars = new StringBuilder();
- break;
-
- case (int)ActionCode.SET_ATTR_VAL:
- if (lastAttrName == null) FatalErr("Internal error.");
- attrList.Add(lastAttrName, sbChars.ToString());
- sbChars = new StringBuilder();
- lastAttrName = null;
- break;
-
- case (int)ActionCode.SEND_CHARS:
- handler.OnChars(sbChars.ToString());
- sbChars = new StringBuilder();
- break;
-
- case (int)ActionCode.START_CDATA:
- string cdata = "CDATA[";
- isComment = false;
- isDTD = false;
-
- if (currCh == '-') {
- currCh = reader.Read();
-
- if (currCh != '-') FatalErr("Invalid comment");
-
- this.col++;
- isComment = true;
- twoCharBuff[0] = -1;
- twoCharBuff[1] = -1;
- } else {
- if (currCh != '[') {
- isDTD = true;
- bracketSwitch = 0;
- break;
- }
-
- for (int i = 0; i < cdata.Length; i++) {
- if (reader.Read() != cdata[i]) {
- this.col += i+1;
- break;
- }
- }
- this.col += cdata.Length;
- seenCData = true;
- }
- break;
-
- case (int)ActionCode.END_CDATA:
- int n = 0;
- currCh = ']';
-
- while (currCh == ']') {
- currCh = reader.Read();
- n++;
- }
-
- if (currCh != '>') {
- for (int i = 0; i < n; i++) sbChars.Append(']');
- sbChars.Append((char)currCh);
- stateCode = 0x12;
- } else {
- for (int i = 0; i < n-2; i++) sbChars.Append(']');
- seenCData = false;
- }
-
- this.col += n;
- break;
-
- case (int)ActionCode.ERROR:
- FatalErr(String.Format("Error {0}", stateCode));
- break;
-
- case (int)ActionCode.STATE_CHANGE:
- break;
-
- case (int)ActionCode.FLUSH_CHARS_STATE_CHANGE:
- sbChars = new StringBuilder();
- if (currCh != '<') goto case (int)ActionCode.ACC_CHARS_STATE_CHANGE;
- break;
-
- case (int)ActionCode.ACC_CHARS_STATE_CHANGE:
- sbChars.Append((char)currCh);
- break;
-
- case (int)ActionCode.ACC_CDATA:
- if (isComment) {
- if (currCh == '>'
- && twoCharBuff[0] == '-'
- && twoCharBuff[1] == '-') {
- isComment = false;
- stateCode = 0;
- } else {
- twoCharBuff[0] = twoCharBuff[1];
- twoCharBuff[1] = currCh;
- }
- } else if (isDTD) {
- if (currCh == '<' || currCh == '>') bracketSwitch ^= 1;
- if (currCh == '>' && bracketSwitch != 0) {
- isDTD = false;
- stateCode = 0;
- }
- } else {
- if (this.splitCData
- && sbChars.Length > 0
- && seenCData) {
- handler.OnChars(sbChars.ToString());
- sbChars = new StringBuilder();
- }
- seenCData = false;
- sbChars.Append((char)currCh);
- }
- break;
-
- case (int)ActionCode.PROC_CHAR_REF:
- currCh = reader.Read();
- int cl = this.col + 1;
- if (currCh == '#') { // character reference
- int r = 10;
- int chCode = 0;
- int nDigits = 0;
- currCh = reader.Read();
- cl++;
-
- if (currCh == 'x') {
- currCh = reader.Read();
- cl++;
- r=16;
- }
-
- NumberStyles style = r == 16 ? NumberStyles.HexNumber : NumberStyles.Integer;
-
- while (true) {
- int x = -1;
- if (Char.IsNumber((char)currCh) || "abcdef".IndexOf(Char.ToLower((char)currCh)) != -1) {
- try {
- x = Int32.Parse(new string((char)currCh, 1), style);
- } catch (FormatException) {x = -1;}
- }
- if (x == -1) break;
- chCode *= r;
- chCode += x;
- nDigits++;
- currCh = reader.Read();
- cl++;
- }
-
- if (currCh == ';' && nDigits > 0) {
- sbChars.Append((char)chCode);
- } else {
- FatalErr("Bad char ref");
- }
- } else {
- // entity reference
- string entityRefChars = "aglmopqstu"; // amp | apos | quot | gt | lt
- string entities = "&'\"><";
-
- int pos = 0;
- int entIdx = 0xF;
- int predShift = 0;
-
- int sbLen = sbChars.Length;
-
- while (true) {
- if (pos != 0xF) pos = entityRefChars.IndexOf((char)currCh) & 0xF;
- if (pos == 0xF) FatalErr(errors[7]);
- sbChars.Append((char)currCh);
-
- int path = "\uFF35\u3F8F\u4F8F\u0F5F\uFF78\uE1F4\u2299\uEEFF\uEEFF\uFF4F"[pos];
- int lBr = (path >> 4) & 0xF;
- int rBr = path & 0xF;
- int lPred = path >> 12;
- int rPred = (path >> 8) & 0xF;
- currCh = reader.Read();
- cl++;
- pos = 0xF;
- if (lBr != 0xF && currCh == entityRefChars[lBr]) {
- if (lPred < 0xE) entIdx = lPred;
-// pred = lPred;
- predShift = 12; // left
- } else if (rBr != 0xF && currCh == entityRefChars[rBr]) {
- if (rPred < 0xE) entIdx = rPred;
-// pred = rPred;
- predShift = 8; // right
- } else if (currCh == ';') {
- if (entIdx != 0xF
- && predShift != 0
- && ((path >> predShift) & 0xF) == 0xE) break;
- continue; // pos == 0xF
- }
-
- pos=0;
-
- }
-
- int l = cl - this.col - 1;
-
- if ((l > 0 && l < 5)
- &&(StrEquals("amp", sbChars, sbLen, l)
- || StrEquals("apos", sbChars, sbLen, l)
- || StrEquals("quot", sbChars, sbLen, l)
- || StrEquals("lt", sbChars, sbLen, l)
- || StrEquals("gt", sbChars, sbLen, l))
- ) {
- sbChars.Length = sbLen;
- sbChars.Append(entities[entIdx]);
- } else FatalErr(errors[7]);
- }
-
- this.col = cl;
- break;
-
- default:
- FatalErr(String.Format("Unexpected action code - {0}.", actionCode));
- break;
- }
- } // while (true)
-
- handler.OnEndParsing(this);
-
- } // Parse
-
- }
-
-}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SecurityParser.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SecurityParser.cs
deleted file mode 100644
index ec53830..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SecurityParser.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-//
-// Mono.Xml.SecurityParser.cs class implementation
-//
-// Author:
-// Sebastien Pouliot (spouliot@motus.com)
-//
-// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-using System.IO;
-using System.Security;
-
-namespace Mono.Xml {
-
- // convert an XML document into SecurityElement objects
- internal class SecurityParser : SmallXmlParser, SmallXmlParser.IContentHandler {
-
- private SecurityElement root;
-
- public SecurityParser () : base ()
- {
- stack = new Stack ();
- }
-
- public void LoadXml (string xml)
- {
- root = null;
-#if CF_1_0
- stack = new Stack ();
-#else
- stack.Clear ();
-#endif
- Parse (new StringReader (xml), this);
- }
-
- public SecurityElement ToXml ()
- {
- return root;
- }
-
- // IContentHandler
-
- private SecurityElement current;
- private Stack stack;
-
- public void OnStartParsing (SmallXmlParser parser) {}
-
- public void OnProcessingInstruction (string name, string text) {}
-
- public void OnIgnorableWhitespace (string s) {}
-
- public void OnStartElement (string name, SmallXmlParser.IAttrList attrs)
- {
- SecurityElement newel = new SecurityElement (name);
- if (root == null) {
- root = newel;
- current = newel;
- }
- else {
- SecurityElement parent = (SecurityElement) stack.Peek ();
- parent.AddChild (newel);
- }
- stack.Push (newel);
- current = newel;
- // attributes
- int n = attrs.Length;
- for (int i=0; i < n; i++)
- current.AddAttribute (attrs.GetName (i), attrs.GetValue (i));
- }
-
- public void OnEndElement (string name)
- {
- current = (SecurityElement) stack.Pop ();
- }
-
- public void OnChars (string ch)
- {
- current.Text = ch;
- }
-
- public void OnEndParsing (SmallXmlParser parser) {}
- }
-}
-
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SmallXmlParser.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SmallXmlParser.cs
deleted file mode 100644
index 4a492ef..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Xml/SmallXmlParser.cs
+++ /dev/null
@@ -1,637 +0,0 @@
-//
-// SmallXmlParser.cs
-//
-// Author:
-// Atsushi Enomoto <atsushi@ximian.com>
-//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-//
-// small xml parser that is mostly compatible with
-//
-
-using System;
-using System.Collections;
-using System.Globalization;
-using System.IO;
-using System.Text;
-
-namespace Mono.Xml
-{
- internal class DefaultHandler : SmallXmlParser.IContentHandler
- {
- public void OnStartParsing (SmallXmlParser parser)
- {
- }
-
- public void OnEndParsing (SmallXmlParser parser)
- {
- }
-
- public void OnStartElement (string name, SmallXmlParser.IAttrList attrs)
- {
- }
-
- public void OnEndElement (string name)
- {
- }
-
- public void OnChars (string s)
- {
- }
-
- public void OnIgnorableWhitespace (string s)
- {
- }
-
- public void OnProcessingInstruction (string name, string text)
- {
- }
- }
-
- internal class SmallXmlParser
- {
- public interface IContentHandler
- {
- void OnStartParsing (SmallXmlParser parser);
- void OnEndParsing (SmallXmlParser parser);
- void OnStartElement (string name, IAttrList attrs);
- void OnEndElement (string name);
- void OnProcessingInstruction (string name, string text);
- void OnChars (string text);
- void OnIgnorableWhitespace (string text);
- }
-
- public interface IAttrList
- {
- int Length { get; }
- bool IsEmpty { get; }
- string GetName (int i);
- string GetValue (int i);
- string GetValue (string name);
- string [] Names { get; }
- string [] Values { get; }
- }
-
- class AttrListImpl : IAttrList
- {
- public int Length {
- get { return attrNames.Count; }
- }
- public bool IsEmpty {
- get { return attrNames.Count == 0; }
- }
- public string GetName (int i)
- {
- return (string) attrNames [i];
- }
- public string GetValue (int i)
- {
- return (string) attrValues [i];
- }
- public string GetValue (string name)
- {
- for (int i = 0; i < attrNames.Count; i++)
- if ((string) attrNames [i] == name)
- return (string) attrValues [i];
- return null;
- }
- public string [] Names {
- get { return (string []) attrNames.ToArray (typeof (string)); }
- }
- public string [] Values {
- get { return (string []) attrValues.ToArray (typeof (string)); }
- }
-
- ArrayList attrNames = new ArrayList ();
- ArrayList attrValues = new ArrayList ();
-
- internal void Clear ()
- {
- attrNames.Clear ();
- attrValues.Clear ();
- }
-
- internal void Add (string name, string value)
- {
- attrNames.Add (name);
- attrValues.Add (value);
- }
- }
-
- IContentHandler handler;
- TextReader reader;
- Stack elementNames = new Stack ();
- Stack xmlSpaces = new Stack ();
- string xmlSpace;
- StringBuilder buffer = new StringBuilder (200);
- char [] nameBuffer = new char [30];
- bool isWhitespace;
-
- AttrListImpl attributes = new AttrListImpl ();
- int line = 1, column;
- bool resetColumn;
-
- public SmallXmlParser ()
- {
- }
-
- private Exception Error (string msg)
- {
- return new SmallXmlParserException (msg, line, column);
- }
-
- private Exception UnexpectedEndError ()
- {
- string [] arr = new string [elementNames.Count];
- // COMPACT FRAMEWORK NOTE: CopyTo is not visible through the Stack class
- (elementNames as ICollection).CopyTo (arr, 0);
- return Error (String.Format (
- "Unexpected end of stream. Element stack content is {0}", String.Join (",", arr)));
- }
-
-
- private bool IsNameChar (char c, bool start)
- {
- switch (c) {
- case ':':
- case '_':
- return true;
- case '-':
- case '.':
- return !start;
- }
- if (c > 0x100) { // optional condition for optimization
- switch (c) {
- case '\u0559':
- case '\u06E5':
- case '\u06E6':
- return true;
- }
- if ('\u02BB' <= c && c <= '\u02C1')
- return true;
- }
- switch (Char.GetUnicodeCategory (c)) {
- case UnicodeCategory.LowercaseLetter:
- case UnicodeCategory.UppercaseLetter:
- case UnicodeCategory.OtherLetter:
- case UnicodeCategory.TitlecaseLetter:
- case UnicodeCategory.LetterNumber:
- return true;
- case UnicodeCategory.SpacingCombiningMark:
- case UnicodeCategory.EnclosingMark:
- case UnicodeCategory.NonSpacingMark:
- case UnicodeCategory.ModifierLetter:
- case UnicodeCategory.DecimalDigitNumber:
- return !start;
- default:
- return false;
- }
- }
-
- private bool IsWhitespace (int c)
- {
- switch (c) {
- case ' ':
- case '\r':
- case '\t':
- case '\n':
- return true;
- default:
- return false;
- }
- }
-
-
- public void SkipWhitespaces ()
- {
- SkipWhitespaces (false);
- }
-
- private void HandleWhitespaces ()
- {
- while (IsWhitespace (Peek ()))
- buffer.Append ((char) Read ());
- if (Peek () != '<' && Peek () >= 0)
- isWhitespace = false;
- }
-
- public void SkipWhitespaces (bool expected)
- {
- while (true) {
- switch (Peek ()) {
- case ' ':
- case '\r':
- case '\t':
- case '\n':
- Read ();
- if (expected)
- expected = false;
- continue;
- }
- if (expected)
- throw Error ("Whitespace is expected.");
- return;
- }
- }
-
-
- private int Peek ()
- {
- return reader.Peek ();
- }
-
- private int Read ()
- {
- int i = reader.Read ();
- if (i == '\n')
- resetColumn = true;
- if (resetColumn) {
- line++;
- resetColumn = false;
- column = 1;
- }
- else
- column++;
- return i;
- }
-
- public void Expect (int c)
- {
- int p = Read ();
- if (p < 0)
- throw UnexpectedEndError ();
- else if (p != c)
- throw Error (String.Format ("Expected '{0}' but got {1}", (char) c, (char) p));
- }
-
- private string ReadUntil (char until, bool handleReferences)
- {
- while (true) {
- if (Peek () < 0)
- throw UnexpectedEndError ();
- char c = (char) Read ();
- if (c == until)
- break;
- else if (handleReferences && c == '&')
- ReadReference ();
- else
- buffer.Append (c);
- }
- string ret = buffer.ToString ();
- buffer.Length = 0;
- return ret;
- }
-
- public string ReadName ()
- {
- int idx = 0;
- if (Peek () < 0 || !IsNameChar ((char) Peek (), true))
- throw Error ("XML name start character is expected.");
- for (int i = Peek (); i >= 0; i = Peek ()) {
- char c = (char) i;
- if (!IsNameChar (c, false))
- break;
- if (idx == nameBuffer.Length) {
- char [] tmp = new char [idx * 2];
- // COMPACT FRAMEWORK NOTE: Array.Copy(sourceArray, destinationArray, count) is not available.
- Array.Copy (nameBuffer, 0, tmp, 0, idx);
- nameBuffer = tmp;
- }
- nameBuffer [idx++] = c;
- Read ();
- }
- if (idx == 0)
- throw Error ("Valid XML name is expected.");
- return new string (nameBuffer, 0, idx);
- }
-
-
- public void Parse (TextReader input, IContentHandler handler)
- {
- this.reader = input;
- this.handler = handler;
-
- handler.OnStartParsing (this);
-
- while (Peek () >= 0)
- ReadContent ();
- HandleBufferedContent ();
- if (elementNames.Count > 0)
- throw Error (String.Format ("Insufficient close tag: {0}", elementNames.Peek ()));
-
- handler.OnEndParsing (this);
-
- Cleanup ();
- }
-
- private void Cleanup ()
- {
- line = 1;
- column = 0;
- handler = null;
- reader = null;
-#if CF_1_0
- elementNames = new Stack ();
- xmlSpaces = new Stack ();
-#else
- elementNames.Clear ();
- xmlSpaces.Clear ();
-#endif
- attributes.Clear ();
- buffer.Length = 0;
- xmlSpace = null;
- isWhitespace = false;
- }
-
- public void ReadContent ()
- {
- string name;
- if (IsWhitespace (Peek ())) {
- if (buffer.Length == 0)
- isWhitespace = true;
- HandleWhitespaces ();
- }
- if (Peek () == '<') {
- Read ();
- switch (Peek ()) {
- case '!': // declarations
- Read ();
- if (Peek () == '[') {
- Read ();
- if (ReadName () != "CDATA")
- throw Error ("Invalid declaration markup");
- Expect ('[');
- ReadCDATASection ();
- return;
- }
- else if (Peek () == '-') {
- ReadComment ();
- return;
- }
- else if (ReadName () != "DOCTYPE")
- throw Error ("Invalid declaration markup.");
- else
- throw Error ("This parser does not support document type.");
- case '?': // PIs
- HandleBufferedContent ();
- Read ();
- name = ReadName ();
- SkipWhitespaces ();
- string text = String.Empty;
- if (Peek () != '?') {
- while (true) {
- text += ReadUntil ('?', false);
- if (Peek () == '>')
- break;
- text += "?";
- }
- }
- handler.OnProcessingInstruction (
- name, text);
- Expect ('>');
- return;
- case '/': // end tags
- HandleBufferedContent ();
- if (elementNames.Count == 0)
- throw UnexpectedEndError ();
- Read ();
- name = ReadName ();
- SkipWhitespaces ();
- string expected = (string) elementNames.Pop ();
- xmlSpaces.Pop ();
- if (xmlSpaces.Count > 0)
- xmlSpace = (string) xmlSpaces.Peek ();
- else
- xmlSpace = null;
- if (name != expected)
- throw Error (String.Format ("End tag mismatch: expected {0} but found {1}", expected, name));
- handler.OnEndElement (name);
- Expect ('>');
- return;
- default: // start tags (including empty tags)
- HandleBufferedContent ();
- name = ReadName ();
- while (Peek () != '>' && Peek () != '/')
- ReadAttribute (attributes);
- handler.OnStartElement (name, attributes);
- attributes.Clear ();
- SkipWhitespaces ();
- if (Peek () == '/') {
- Read ();
- handler.OnEndElement (name);
- }
- else {
- elementNames.Push (name);
- xmlSpaces.Push (xmlSpace);
- }
- Expect ('>');
- return;
- }
- }
- else
- ReadCharacters ();
- }
-
- private void HandleBufferedContent ()
- {
- if (buffer.Length == 0)
- return;
- if (isWhitespace)
- handler.OnIgnorableWhitespace (buffer.ToString ());
- else
- handler.OnChars (buffer.ToString ());
- buffer.Length = 0;
- isWhitespace = false;
- }
-
- private void ReadCharacters ()
- {
- isWhitespace = false;
- while (true) {
- int i = Peek ();
- switch (i) {
- case -1:
- return;
- case '<':
- return;
- case '&':
- Read ();
- ReadReference ();
- continue;
- default:
- buffer.Append ((char) Read ());
- continue;
- }
- }
- }
-
- private void ReadReference ()
- {
- if (Peek () == '#') {
- // character reference
- Read ();
- ReadCharacterReference ();
- } else {
- string name = ReadName ();
- Expect (';');
- switch (name) {
- case "amp":
- buffer.Append ('&');
- break;
- case "quot":
- buffer.Append ('"');
- break;
- case "apos":
- buffer.Append ('\'');
- break;
- case "lt":
- buffer.Append ('<');
- break;
- case "gt":
- buffer.Append ('>');
- break;
- default:
- throw Error ("General non-predefined entity reference is not supported in this parser.");
- }
- }
- }
-
- private int ReadCharacterReference ()
- {
- int n = 0;
- if (Peek () == 'x') { // hex
- Read ();
- for (int i = Peek (); i >= 0; i = Peek ()) {
- if ('0' <= i && i <= '9')
- n = n << 4 + i - '0';
- else if ('A' <= i && i <='F')
- n = n << 4 + i - 'A' + 10;
- else if ('a' <= i && i <='f')
- n = n << 4 + i - 'a' + 10;
- else
- break;
- Read ();
- }
- } else {
- for (int i = Peek (); i >= 0; i = Peek ()) {
- if ('0' <= i && i <= '9')
- n = n << 4 + i - '0';
- else
- break;
- Read ();
- }
- }
- return n;
- }
-
- private void ReadAttribute (AttrListImpl a)
- {
- SkipWhitespaces (true);
- if (Peek () == '/' || Peek () == '>')
- // came here just to spend trailing whitespaces
- return;
-
- string name = ReadName ();
- string value;
- SkipWhitespaces ();
- Expect ('=');
- SkipWhitespaces ();
- switch (Read ()) {
- case '\'':
- value = ReadUntil ('\'', true);
- break;
- case '"':
- value = ReadUntil ('"', true);
- break;
- default:
- throw Error ("Invalid attribute value markup.");
- }
- if (name == "xml:space")
- xmlSpace = value;
- a.Add (name, value);
- }
-
- private void ReadCDATASection ()
- {
- int nBracket = 0;
- while (true) {
- if (Peek () < 0)
- throw UnexpectedEndError ();
- char c = (char) Read ();
- if (c == ']')
- nBracket++;
- else if (c == '>' && nBracket > 1) {
- for (int i = nBracket; i > 2; i--)
- buffer.Append (']');
- break;
- }
- else {
- for (int i = 0; i < nBracket; i++)
- buffer.Append (']');
- nBracket = 0;
- buffer.Append (c);
- }
- }
- }
-
- private void ReadComment ()
- {
- Expect ('-');
- Expect ('-');
- while (true) {
- if (Read () != '-')
- continue;
- if (Read () != '-')
- continue;
- if (Read () != '>')
- throw Error ("'--' is not allowed inside comment markup.");
- break;
- }
- }
- }
-
- internal class SmallXmlParserException : SystemException
- {
- int line;
- int column;
-
- public SmallXmlParserException (string msg, int line, int column)
- : base (String.Format ("{0}. At ({1},{2})", msg, line, column))
- {
- this.line = line;
- this.column = column;
- }
-
- public int Line {
- get { return line; }
- }
-
- public int Column {
- get { return column; }
- }
- }
-}
-
-
-
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceNode.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Actions.cs
index b51ebd5..071b149 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceNode.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Actions.cs
@@ -1,10 +1,10 @@
//
-// ResourceNode.cs
+// Actions.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2006 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,19 +26,13 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil.Binary {
+#if !NET_3_5 && !NET_4_0
- public abstract class ResourceNode {
-
- public int Offset;
-
- internal ResourceNode (int offset)
- {
- this.Offset = offset;
- }
-
- internal ResourceNode ()
- {
- }
- }
+namespace Mono {
+ //delegate void Action ();
+ //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);
}
+
+#endif
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/HashCodeProvider.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Empty.cs
index 6b7b80c..70739af 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil/HashCodeProvider.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Empty.cs
@@ -1,10 +1,10 @@
//
-// HashCodeProvider.cs
+// Empty.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,21 +26,30 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil {
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Mono {
+
+ static class Empty<T> {
- using System.Collections;
+ public static readonly T [] Array = new T [0];
+ }
+}
- internal sealed class HashCodeProvider : IHashCodeProvider {
+namespace Mono.Cecil {
- public static readonly HashCodeProvider Instance = new HashCodeProvider ();
+ static partial class Mixin {
- HashCodeProvider ()
+ public static bool IsNullOrEmpty<T> (this T [] self)
{
+ return self == null || self.Length == 0;
}
- public int GetHashCode (object o)
+ public static bool IsNullOrEmpty<T> (this ICollection<T> self)
{
- return o.GetHashCode ();
+ return self == null || self.Count == 0;
}
}
}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDataEntry.cs b/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Funcs.cs
index c2b3b3f..40f2225 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Binary/ResourceDataEntry.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/Mono/Funcs.cs
@@ -1,10 +1,10 @@
//
-// ResourceDataEntry.cs
+// Funcs.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2006 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,23 +26,14 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil.Binary {
+#if !NET_3_5 && !NET_4_0
- public class ResourceDataEntry : ResourceNode {
-
- public RVA Data;
- public uint Size;
- public uint Codepage;
- public uint Reserved = 0;
-
- public byte [] ResourceData;
-
- public ResourceDataEntry (int offset) : base (offset)
- {
- }
-
- public ResourceDataEntry ()
- {
- }
- }
+namespace Mono {
+ delegate TResult Func<TResult> ();
+ delegate TResult Func<T, TResult> (T arg1);
+ delegate TResult Func<T1, T2, TResult> (T1 arg1, T2 arg2);
+ //delegate TResult Func<T1, T2, T3, TResult> (T1 arg1, T2 arg2, T3 arg3);
+ //delegate TResult Func<T1, T2, T3, T4, TResult> (T1 arg1, T2 arg2, T3 arg3, T4 arg4);
}
+
+#endif
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/NEWS b/Mono.Addins.CecilReflector/Mono.Cecil/NEWS
deleted file mode 100644
index a8518da..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/NEWS
+++ /dev/null
@@ -1,3 +0,0 @@
-2005-10-31 Jb Evain <jbevain@gmail.com>
-
- * Release of Mono.Cecil 0.1 "Trick or Treat"
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/NOTES.txt b/Mono.Addins.CecilReflector/Mono.Cecil/NOTES.txt
new file mode 100644
index 0000000..6f3618b
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/NOTES.txt
@@ -0,0 +1,189 @@
+namespaces:
+
+ Mono.Cecil.Binary: deleted,
+ Mono.Cecil.Metadata: metadata table/rows: deleted.
+
+collections:
+
+ * Cecil now only exposes Collection of T as a public collection API.
+
+types:
+
+Mono.Cecil
+
+ - AssemblyFactory:
+ Use static Read methods on ModuleDefinition and AssemblyDefinition
+ to get them.
+
+ + ReadingMode:
+ specifies if the assembly is either loaded in a deffered
+ or immediate fashion.
+
+ + ReaderParameters
+ + ReadingMode
+ + ISymbolReaderProvider
+
+ + WriterParameters
+ + ISymbolWriterProvider
+
+ * AssemblyDefinition:
+
+ * Runtime, Kind: moved to ModuleDefiniton
+
+ * ModuleDefinition:
+
+ properties:
+
+ - Image
+ - MemberReferences
+ - TypeReferences
+ - ExternTypes
+
+ * Main -> IsMain. (set removed) : bool
+ + FullyQualifiedName : string
+ + Kind : ModuleKind
+ + Runtime : TargetRuntime
+ + Architecture : TargetArchitecture
+ + Attributes : ModuleAttributes
+ + HasSymbols : bool
+ + HasExportedTypes : bool
+ + ExportedTypes : ExportedTypeCollection
+
+ * Types: doesn't contain NestedTypes anymore.
+
+ - AssemblyKind:
+ renamed to ModuleKind.
+
+ + ModuleKind:
+ + NetModule
+
+ + TargetArchitecture:
+ + I386
+ + AMD64
+ + IA64
+
+ + ModuleAttributes:
+ + ILOnly
+ + Required32Bit
+ + StrongNameSigned
+
+ * FieldDefinition:
+
+ * RVA : int
+
+ * IMethodSignature:
+ * ReturnType : TypeReference
+ + MethodReturnType : MethodReturnType
+
+ * TypeDefinition:
+ - HasConstructors
+ - Constructors
+ * ctor: swapped namespace and name parameter.
+
+ * ParameterDefinition:
+ * Method : IMethodSignature
+ * Sequence -> Index : int (0 based instead of 1)
+
+ * ArrayType:
+ * IsSizedArray -> IsVector : bool
+
+ * IHasConstant -> IConstantProvider
+ * IHasSecurity -> ISecurityDeclarationProvider
+ * IHasMarshal -> IMarshalInfoProvider
+
+ * MemberReference
+ + Module : ModuleDefinition
+
+ * MethodDefinition:
+ - This: moved to MethodBody
+ + HasPInvokeInfo : bool
+
+ * PInvokeInfo:
+ - Method
+
+ * MarshalSpec -> MarshalInfo
+
+ - ModType
+
+ * ModifierRequiredType -> RequiredModifierType
+ * ModifierOptionalType -> OptionalModifierType
+ * ReferenceType -> ByReferenceType
+
+ * TypeReference
+ + IsArray : bool
+ + IsPointer : bool
+ + IsByReference : bool
+ + IsRequiredModifier : bool
+ + IsOptionalModifier : bool
+ + IsSentinel : bool
+ + IsGenericInstance : bool
+ + IsGenericParameter : bool
+ + IsPinned : bool
+ + IsFunctionPointer : bool
+ + IsDefinition : bool
+
+ * GetOriginalType -> GetElementType
+ * ctor: swapped namespace and name parameter.
+
+ * MethodReference
+ + IsGenericInstance : bool
+ + IsDefinition : bool
+
+ * GetOriginalMethod -> GetElementMethod
+
+ * FieldReference
+ + IsDefinition : bool
+
+ + CustomAttributeArgument
+ + Type : TypeReference
+ + Value : object
+
+ * CustomAttribute
+ * ConstructorParameters -> ConstructorArguments : CustomAttributeArgumentCollection
+ * Properties : CustomAttributeNamedArgumentCollection
+ * Fields : CustomAttributeNamedArgumentCollection
+
+ * SecurityDeclaration
+ - PermissionSet
+ + SecurityAttributes : SecurityAttributeCollection
+
+ + SecurityAttribute
+ + AttributeType : TypeReference
+ + Fields : CustomAttributeNamedArgumentCollection
+ + Properties : CustomAttributeNamedArgumentCollection
+
+ * IMetadataScope
+ + MetadataScopeType
+
+ + MetadataScopeType
+ + AssemblyNameReference
+ + ModuleDefinition
+ + ModuleReference
+
+Mono.Cecil.Cil:
+
+ * ExceptionHandler
+ * Type -> HandlerType : TypeReference
+
+ * VariableDefinition
+ - Method
+
+ * Document* : from Guid to enums, the reader/writers are responsible for assigning them.
+
+ * MethodBody
+ * LocalVarToken : MetadataToken
+ * MaxStack -> MaxStackSize : int
+ + ThisParameter: from MethodDefinition
+
+ * OperandType
+ * ShortInlineParam : ShortInlineArg
+ * InlineParam : InlineArg
+
+ * CilWorker -> ILProcessor
+
+TODO:
+
+ * Mono.Cecil.Rocks
+ * ILGenerator
+
+ * HOWTOs
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/README b/Mono.Addins.CecilReflector/Mono.Cecil/README
deleted file mode 100644
index b95c65e..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/README
+++ /dev/null
@@ -1,78 +0,0 @@
-Cecil is a library to generate and inspect programs and libraries in the ECMA CIL format.
-
-* Building
-
- The standard Makefile works inside /mcs (SVN or tarball). If you want to build
- Cecil as a standalone library (e.g. in /cecil SVN) you'll need to:
-
- ./configure --prefix=/your/prefix
- make -f standalone.make
- make -f standalone.make install
-
-* Bugs
-
- Please report bugs at:
- http://bugzilla.novell.com,
- Product: Mono: Class Library
- Component: Cecil
-
-* Layout
-
- CodeGen/
- Here is a ruby code generation script. Do not modify generated files.
- Please modify template then run:
-
- ./cecil-gen.rb
-
- in this folder. If you add or remove files, please run:
-
- ./cecil-gen-sources.rb
-
- to update the file Mono.Cecil.dll.sources
-
- Mono.Cecil/
- General implementation of Cecil.
-
- Mono.Cecil.Binary/
- Here are files dealing with PE format.
-
- Mono.Cecil.Metadata/
- Here lies files dealing with the format of metadata.
-
- Mono.Cecil.Cil/
- Files dealing with CIL intermediate code.
-
- Mono.Cecil.Signatures/
- Here are files dealing with signatures in blobs.
-
-* Acknowledgements
-
- Thanks to:
- - Sébastien Pouliot,
- - Todd Berman,
- - Martin Baulig,
- - Sébastien Ros,
- - Thomas Gil
-
-* License
-
- Copyright (C) 2005 Jb Evain
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Class.cs b/Mono.Addins.CecilReflector/Mono.Cecil/System.Runtime.CompilerServices/ExtensionAttribute.cs
index ef908e6..ae79cda 100644
--- a/Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Signatures/Class.cs
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/System.Runtime.CompilerServices/ExtensionAttribute.cs
@@ -1,10 +1,10 @@
//
-// Class.cs
+// ExtensionAttribute.cs
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
-// (C) 2005 Jb Evain
+// Copyright (c) 2008 - 2010 Jb Evain
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,16 +26,15 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-namespace Mono.Cecil.Signatures {
+using System;
- using Mono.Cecil.Metadata;
+#if !NET_3_5 && !NET_4_0
- internal sealed class CLASS : SigType {
+namespace System.Runtime.CompilerServices {
- public MetadataToken Type;
-
- public CLASS () : base (ElementType.Class)
- {
- }
+ [AttributeUsage (AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)]
+ sealed class ExtensionAttribute : Attribute {
}
}
+
+#endif
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/TODO b/Mono.Addins.CecilReflector/Mono.Cecil/TODO
deleted file mode 100644
index d373d8e..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/TODO
+++ /dev/null
@@ -1,19 +0,0 @@
-Cecil TODO
-
-* debugs infos
-
- Cecil should be able to emit debug infos along with assemblies.
-
-* strong name
-
- For the moment, Cecil only create space for strong name signatures.
- Can we do better ?
-
-* win32 resource
-
- Cecil does not suppport win32 resources and globaly the .rsrc section
- into PE files.
-
-* verify
-
- Cecil does absolutely no verification on what it emits.
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/configure b/Mono.Addins.CecilReflector/Mono.Cecil/configure
deleted file mode 100755
index 28f12e1..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/configure
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/sh
-
-help()
-{
- echo ""
- echo "Usage is: configure [--prefix=PREFIX]"
- echo ""
-}
-
-prefix=/usr/local
-profile=default
-
-while [ $# -ne 0 ]; do
- case $1 in
- --help)
- help
- exit 0
- ;;
- --prefix=*)
- prefix=`echo $1 | sed 's/--prefix=//'`;
- shift
- ;;
- --prefix)
- shift
- prefix="$1"
- shift
- ;;
- *)
- echo Unknown option: $1
- help
- shift
- esac
-done
-
-echo "prefix=$prefix" > config.make
-
-echo ""
-echo "Mono.Cecil module configured"
-echo ""
-echo " Prefix: $prefix"
-echo ""
-
-exit 0;
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/default.build b/Mono.Addins.CecilReflector/Mono.Cecil/default.build
deleted file mode 100644
index 73f7d84..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/default.build
+++ /dev/null
@@ -1,84 +0,0 @@
-<?xml version="1.0"?>
-<project name="Cecil" default="cecil" basedir=".">
-
- <property name="debug" value="false" />
- <property name="optimize" value="true" />
- <property name="build.dir" value="${path::get-full-path('bin')}" />
- <property name="keyfile" value="../mono.snk" />
- <property name="csc.defines" value="NO_DEFINE" />
-
- <!-- allow properties to be customized in external file" -->
- <include buildfile="build.properties" if="${file::exists('build.properties')}" />
-
- <fileset id="all-files">
- <include name="./**/*.cs" />
- <exclude name="CodeGen/**/*.*" />
- </fileset>
-
- <target name="clean">
- <delete failonerror="false">
- <fileset>
- <include name="**/bin/**" />
- <include name="**/obj/**" />
- <include name="${build.dir}/**" />
- </fileset>
- </delete>
- </target>
-
- <target name="init">
- <mkdir dir="${build.dir}" />
- </target>
-
- <target name="cecil" depends="init">
- <csc output="${build.dir}/Mono.Cecil.dll"
- target="library" debug="${debug}"
- unsafe="false" optimize="${optimize}"
- keyfile="${keyfile}"
- define="${csc.defines}">
- <sources refid="all-files"/>
- </csc>
- </target>
-
- <target name="compactframework" depends="init" description="compiles cecil to run on the CompactFramework 1.0">
- <property name="compactframework.defines" value="CF_1_0;${csc.defines}" />
- <property name="compactframework.dir" value="${compactframework.v1.dir}" />
- <call target="compactframework-compilation" />
- </target>
-
- <target name="compactframework2" depends="init" description="compiles cecil to run on the CompactFramework 2.0">
- <property name="compactframework.defines" value="CF_2_0;${csc.defines}" />
- <property name="compactframework.dir" value="${compactframework.v2.dir}" />
- <call target="compactframework-compilation" />
- </target>
-
- <target name="compactframework-compilation">
- <property name="temp.dir" value="${path::combine(path::get-temp-path(), 'cecil')}" />
- <delete dir="${temp.dir}" if="${directory::exists(temp.dir)}" />
- <mkdir dir="${temp.dir}" />
-
- <property name="framework.dir" value="${framework::get-framework-directory(framework::get-target-framework())}" />
- <property name="csc.exe" value="${path::combine(framework.dir, 'csc.exe')}" />
-
- <copy todir="${temp.dir}">
- <fileset refid="all-files" />
- </copy>
-
- <exec program="${csc.exe}" workingdir="${temp.dir}" failonerror="true">
- <arg value="/optimize" />
- <arg value="/debug-" />
- <arg value="/define:${compactframework.defines}" />
- <arg value="/out:${build.dir}/Mono.Cecil.dll" />
- <arg value="/target:library" />
- <arg value="/warn:0" />
- <arg value="/noconfig" />
- <arg value="/nostdlib+" />
- <arg value="/reference:${compactframework.dir}/mscorlib.dll" />
- <arg value="/reference:${compactframework.dir}/System.dll" />
- <arg value="/recurse:*.cs" />
- </exec>
- </target>
-
- <target name="codegen">
- <exec program="ruby" commandline="cecil-gen.rb" workingdir="CodeGen" />
- </target>
-</project>
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/mono-cecil.pc.in b/Mono.Addins.CecilReflector/Mono.Cecil/mono-cecil.pc.in
deleted file mode 100644
index c2829d9..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/mono-cecil.pc.in
+++ /dev/null
@@ -1,8 +0,0 @@
-prefix=@prefix@
-assemblies_dir=${prefix}/lib/Mono.Cecil
-Libraries=${assemblies_dir}/Mono.Cecil.dll
-
-Name: Mono.Cecil
-Description: Mono.Cecil Library
-Version: 0.6
-Libs: -r:${Libraries}
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/mono.snk b/Mono.Addins.CecilReflector/Mono.Cecil/mono.snk
new file mode 100644
index 0000000..380116c
--- /dev/null
+++ b/Mono.Addins.CecilReflector/Mono.Cecil/mono.snk
Binary files differ
diff --git a/Mono.Addins.CecilReflector/Mono.Cecil/standalone.make b/Mono.Addins.CecilReflector/Mono.Cecil/standalone.make
deleted file mode 100644
index 075be29..0000000
--- a/Mono.Addins.CecilReflector/Mono.Cecil/standalone.make
+++ /dev/null
@@ -1,23 +0,0 @@
-include config.make
-
-MCS = mcs
-KEY_FILE = ../../mcs/class/mono.snk
-MCS_FLAGS = -keyfile:$(KEY_FILE)
-
-all: Mono.Cecil.dll mono-cecil.pc
-
-Mono.Cecil.dll: Mono.Cecil.dll.sources */*.cs
- $(MCS) $(MCS_FLAGS) @Mono.Cecil.dll.sources /target:library /out:Mono.Cecil.dll
-
-clean:
- rm -f Mono.Cecil.dll
- rm -f mono-cecil.pc
-
-mono-cecil.pc: mono-cecil.pc.in
- sed -e 's,@prefix@,$(prefix),g' mono-cecil.pc.in > $@.tmp
- mv $@.tmp $@
-
-install: all mono-cecil.pc
- mkdir -p $(prefix)/lib/Mono.Cecil
- cp Mono.Cecil.dll $(prefix)/lib/Mono.Cecil
- cp mono-cecil.pc $(prefix)/lib/pkgconfig/mono-cecil.pc