diff --git a/configure.REMOVED.git-id b/configure.REMOVED.git-id index a4615559d0..07c07142c5 100644 --- a/configure.REMOVED.git-id +++ b/configure.REMOVED.git-id @@ -1 +1 @@ -f06ad86485ad0fb3a677c75554655e7d49bab9b3 \ No newline at end of file +72075fe503f90a8c9087954fd13cae555b0fd10e \ No newline at end of file diff --git a/configure.ac.REMOVED.git-id b/configure.ac.REMOVED.git-id index 10ef956e79..03f2c3facf 100644 --- a/configure.ac.REMOVED.git-id +++ b/configure.ac.REMOVED.git-id @@ -1 +1 @@ -af4c4839fbd110ae58a023d4e83cd5d4cf77b03b \ No newline at end of file +5cf967df968a4cd55c0acb463f01a9a4b019cee0 \ No newline at end of file diff --git a/external/corefx/src/System.Reflection/tests/TypeInfoTests.cs b/external/corefx/src/System.Reflection/tests/TypeInfoTests.cs index f3228cd3a3..920f861933 100644 --- a/external/corefx/src/System.Reflection/tests/TypeInfoTests.cs +++ b/external/corefx/src/System.Reflection/tests/TypeInfoTests.cs @@ -1006,8 +1006,8 @@ namespace System.Reflection.Tests Assert.Equal(expected, type.GetTypeInfo().GetElementType()); } - [Theory] - public void GenericParameterConstraints(Type type) + [Fact] + public void GenericParameterConstraints() { Type[] genericTypeParameters = typeof(MethodClassWithConstraints<,>).GetTypeInfo().GenericTypeParameters; Assert.Equal(2, genericTypeParameters.Length); diff --git a/external/linker/cecil/.editorconfig b/external/linker/cecil/.editorconfig deleted file mode 100644 index 6868a57dab..0000000000 --- a/external/linker/cecil/.editorconfig +++ /dev/null @@ -1,11 +0,0 @@ -# top-most EditorConfig file -root = true - -[*.cs] -indent_style = tab -csharp_space_between_method_declaration_name_and_open_parenthesis = true -csharp_space_between_method_call_name_and_opening_parenthesis = true -csharp_space_before_open_square_brackets = true -csharp_new_line_before_open_brace = methods -csharp_new_line_before_else = false -csharp_indent_switch_labels = false \ No newline at end of file diff --git a/external/linker/cecil/.gitattributes b/external/linker/cecil/.gitattributes deleted file mode 100644 index c87ac422f3..0000000000 --- a/external/linker/cecil/.gitattributes +++ /dev/null @@ -1,8 +0,0 @@ -* text=auto - -.md text -.cs text - -.sln text=crlf -.*proj text=crlf -.settings text=crlf diff --git a/external/linker/cecil/.gitignore b/external/linker/cecil/.gitignore deleted file mode 100644 index 08c8509f51..0000000000 --- a/external/linker/cecil/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -bin -obj -*.suo -*.iml -*.user -*.pidb -*.userprefs -*.xml -*.nupkg -**/test-results/* -*Resharper* -Mono.Cecil.sln.ide* -TestResults -project.lock.json -.vs/ diff --git a/external/linker/cecil/.travis.yml b/external/linker/cecil/.travis.yml deleted file mode 100644 index 0f102833a3..0000000000 --- a/external/linker/cecil/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: csharp -solution: Mono.Cecil.sln -install: - - nuget restore Mono.Cecil.sln - - nuget install NUnit.Runners -Version 2.6.4 -OutputDirectory testrunner -script: - - xbuild /p:Configuration=net_4_0_Debug Mono.Cecil.sln - - mono ./testrunner/NUnit.Runners.2.6.4/tools/nunit-console.exe Mono.Cecil.nunit diff --git a/external/linker/cecil/LICENSE.txt b/external/linker/cecil/LICENSE.txt deleted file mode 100644 index afd0ae6818..0000000000 --- a/external/linker/cecil/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -Copyright (c) 2008 - 2015 Jb Evain -Copyright (c) 2008 - 2011 Novell, Inc. - -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/external/linker/cecil/Mono.Cecil.Cil/Code.cs b/external/linker/cecil/Mono.Cecil.Cil/Code.cs deleted file mode 100644 index cd929fcc34..0000000000 --- a/external/linker/cecil/Mono.Cecil.Cil/Code.cs +++ /dev/null @@ -1,234 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil.Cil { - - public enum Code { - 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, - 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, - 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, - Conv_Ovf_I1, - Conv_Ovf_U1, - Conv_Ovf_I2, - Conv_Ovf_U2, - Conv_Ovf_I4, - Conv_Ovf_U4, - Conv_Ovf_I8, - Conv_Ovf_U8, - Refanyval, - Ckfinite, - Mkrefany, - 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, - Arglist, - Ceq, - Cgt, - Cgt_Un, - Clt, - Clt_Un, - Ldftn, - Ldvirtftn, - Ldarg, - Ldarga, - Starg, - Ldloc, - Ldloca, - Stloc, - Localloc, - Endfilter, - Unaligned, - Volatile, - Tail, - Initobj, - Constrained, - Cpblk, - Initblk, - No, - Rethrow, - Sizeof, - Refanytype, - Readonly, - } -} diff --git a/external/linker/cecil/Mono.Cecil.Cil/CodeReader.cs b/external/linker/cecil/Mono.Cecil.Cil/CodeReader.cs deleted file mode 100644 index f7f11d5d9e..0000000000 --- a/external/linker/cecil/Mono.Cecil.Cil/CodeReader.cs +++ /dev/null @@ -1,671 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using Mono.Cecil.PE; -using Mono.Collections.Generic; - -using RVA = System.UInt32; - -namespace Mono.Cecil.Cil { - - sealed class CodeReader : BinaryStreamReader { - - readonly internal MetadataReader reader; - - int start; - - MethodDefinition method; - MethodBody body; - - int Offset { - get { return Position - start; } - } - - public CodeReader (MetadataReader reader) - : base (reader.image.Stream.value) - { - this.reader = reader; - } - - public int MoveTo (MethodDefinition method) - { - this.method = method; - this.reader.context = method; - var position = this.Position; - this.Position = (int) reader.image.ResolveVirtualAddress ((uint) method.RVA); - return position; - } - - public void MoveBackTo (int position) - { - this.reader.context = null; - this.Position = position; - } - - public MethodBody ReadMethodBody (MethodDefinition method) - { - var position = MoveTo (method); - this.body = new MethodBody (method); - - ReadMethodBody (); - - MoveBackTo (position); - return this.body; - } - - public int ReadCodeSize (MethodDefinition method) - { - var position = MoveTo (method); - - var code_size = ReadCodeSize (); - - MoveBackTo (position); - return code_size; - } - - int ReadCodeSize () - { - var flags = ReadByte (); - switch (flags & 0x3) { - case 0x2: // tiny - return flags >> 2; - case 0x3: // fat - Advance (-1 + 2 + 2); // go back, 2 bytes flags, 2 bytes stack size - return (int) ReadUInt32 (); - default: - throw new InvalidOperationException (); - } - } - - void ReadMethodBody () - { - var flags = ReadByte (); - switch (flags & 0x3) { - case 0x2: // tiny - body.code_size = flags >> 2; - body.MaxStackSize = 8; - ReadCode (); - break; - case 0x3: // fat - Advance (-1); - ReadFatMethod (); - break; - default: - throw new InvalidOperationException (); - } - - var symbol_reader = reader.module.symbol_reader; - - if (symbol_reader != null && method.debug_info == null) - method.debug_info = symbol_reader.Read (method); - - if (method.debug_info != null) - ReadDebugInfo (); - } - - void ReadFatMethod () - { - 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.local_var_token.RID != 0) - body.variables = ReadVariables (body.local_var_token); - - ReadCode (); - - if ((flags & 0x8) != 0) - ReadSection (); - } - - public VariableDefinitionCollection ReadVariables (MetadataToken local_var_token) - { - var position = reader.position; - var variables = reader.ReadVariables (local_var_token); - reader.position = position; - - return variables; - } - - void ReadCode () - { - start = Position; - var code_size = body.code_size; - - if (code_size < 0 || Length <= (uint) (code_size + Position)) - code_size = 0; - - var end = start + code_size; - var instructions = body.instructions = new InstructionCollection (method, (code_size + 1) / 2); - - while (Position < end) { - var offset = 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); - } - - OpCode ReadOpCode () - { - var il_opcode = ReadByte (); - return il_opcode != 0xfe - ? OpCodes.OneByteOpCode [il_opcode] - : OpCodes.TwoBytesOpCode [ReadByte ()]; - } - - 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 (); - } - } - - public string GetString (MetadataToken token) - { - return reader.image.UserStringHeap.Read (token.RID); - } - - public ParameterDefinition GetParameter (int index) - { - return body.GetParameter (index); - } - - public VariableDefinition GetVariable (int index) - { - return body.GetVariable (index); - } - - public CallSite GetCallSite (MetadataToken token) - { - return reader.ReadCallSite (token); - } - - void ResolveBranches (Collection instructions) - { - var items = instructions.items; - var size = instructions.size; - - for (int i = 0; i < size; i++) { - var instruction = items [i]; - switch (instruction.opcode.OperandType) { - case OperandType.ShortInlineBrTarget: - case OperandType.InlineBrTarget: - instruction.operand = GetInstruction ((int) instruction.operand); - break; - case OperandType.InlineSwitch: - 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; - } - } - } - - Instruction GetInstruction (int offset) - { - return GetInstruction (body.Instructions, offset); - } - - static Instruction GetInstruction (Collection 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 () - { - Align (4); - - const byte fat_format = 0x40; - const byte more_sects = 0x80; - - 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); - - ReadExceptionHandlers ( - count, - () => (int) ReadUInt16 (), - () => (int) ReadByte ()); - } - - void ReadFatSection () - { - Advance (-1); - var count = (ReadInt32 () >> 8) / 24; - - ReadExceptionHandlers ( - count, - ReadInt32, - ReadInt32); - } - - // inline ? - void ReadExceptionHandlers (int count, Func read_entry, Func 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 ()); - break; - default: - Advance (4); - break; - } - } - - public MetadataToken ReadToken () - { - return new MetadataToken (ReadUInt32 ()); - } - - void ReadDebugInfo () - { - if (method.debug_info.sequence_points != null) - ReadSequencePoints (); - - if (method.debug_info.scope != null) - ReadScope (method.debug_info.scope); - - if (method.custom_infos != null) - ReadCustomDebugInformations (method); - } - - void ReadCustomDebugInformations (MethodDefinition method) - { - var custom_infos = method.custom_infos; - - for (int i = 0; i < custom_infos.Count; i++) { - var state_machine_scope = custom_infos [i] as StateMachineScopeDebugInformation; - if (state_machine_scope != null) - ReadStateMachineScope (state_machine_scope); - - var async_method = custom_infos [i] as AsyncMethodBodyDebugInformation; - if (async_method != null) - ReadAsyncMethodBody (async_method); - } - } - - void ReadAsyncMethodBody (AsyncMethodBodyDebugInformation async_method) - { - if (async_method.catch_handler.Offset > -1) - async_method.catch_handler = new InstructionOffset (GetInstruction (async_method.catch_handler.Offset)); - - if (!async_method.yields.IsNullOrEmpty ()) - for (int i = 0; i < async_method.yields.Count; i++) - async_method.yields [i] = new InstructionOffset (GetInstruction (async_method.yields [i].Offset)); - - if (!async_method.resumes.IsNullOrEmpty ()) - for (int i = 0; i < async_method.resumes.Count; i++) - async_method.resumes [i] = new InstructionOffset (GetInstruction (async_method.resumes [i].Offset)); - } - - void ReadStateMachineScope (StateMachineScopeDebugInformation state_machine_scope) - { - if (state_machine_scope.scopes.IsNullOrEmpty ()) - return; - - foreach (var scope in state_machine_scope.scopes) { - scope.start = new InstructionOffset (GetInstruction (scope.start.Offset)); - - var end_instruction = GetInstruction (scope.end.Offset); - scope.end = end_instruction == null - ? new InstructionOffset () - : new InstructionOffset (end_instruction); - } - } - - void ReadSequencePoints () - { - var symbol = method.debug_info; - - for (int i = 0; i < symbol.sequence_points.Count; i++) { - var sequence_point = symbol.sequence_points [i]; - var instruction = GetInstruction (sequence_point.Offset); - if (instruction != null) - sequence_point.offset = new InstructionOffset (instruction); - } - } - - void ReadScopes (Collection scopes) - { - for (int i = 0; i < scopes.Count; i++) - ReadScope (scopes [i]); - } - - void ReadScope (ScopeDebugInformation scope) - { - var start_instruction = GetInstruction (scope.Start.Offset); - if (start_instruction != null) - scope.Start = new InstructionOffset (start_instruction); - - var end_instruction = GetInstruction (scope.End.Offset); - scope.End = end_instruction != null - ? new InstructionOffset (end_instruction) - : new InstructionOffset (); - - if (!scope.variables.IsNullOrEmpty ()) { - for (int i = 0; i < scope.variables.Count; i++) { - var variable_info = scope.variables [i]; - var variable = GetVariable (variable_info.Index); - if (variable != null) - variable_info.index = new VariableIndex (variable); - } - } - - if (!scope.scopes.IsNullOrEmpty ()) - ReadScopes (scope.scopes); - } - -#if !READ_ONLY - - public ByteBuffer PatchRawMethodBody (MethodDefinition method, CodeWriter writer, out int code_size, out MetadataToken local_var_token) - { - var position = MoveTo (method); - - var buffer = new ByteBuffer (); - - var flags = ReadByte (); - - switch (flags & 0x3) { - case 0x2: // tiny - buffer.WriteByte (flags); - local_var_token = MetadataToken.Zero; - code_size = flags >> 2; - PatchRawCode (buffer, code_size, writer); - break; - case 0x3: // fat - Advance (-1); - PatchRawFatMethod (buffer, writer, out code_size, out local_var_token); - break; - default: - throw new NotSupportedException (); - } - - MoveBackTo (position); - - return buffer; - } - - void PatchRawFatMethod (ByteBuffer buffer, CodeWriter writer, out int code_size, out MetadataToken local_var_token) - { - var flags = ReadUInt16 (); - buffer.WriteUInt16 (flags); - buffer.WriteUInt16 (ReadUInt16 ()); - code_size = ReadInt32 (); - buffer.WriteInt32 (code_size); - local_var_token = ReadToken (); - - if (local_var_token.RID > 0) { - var variables = ReadVariables (local_var_token); - buffer.WriteUInt32 (variables != null - ? writer.GetStandAloneSignature (variables).ToUInt32 () - : 0); - } else - buffer.WriteUInt32 (0); - - PatchRawCode (buffer, code_size, writer); - - if ((flags & 0x8) != 0) - PatchRawSection (buffer, writer.metadata); - } - - 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]; - } - - 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 = Position; - Align (4); - buffer.WriteBytes (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); - - var count = length / 12; - - PatchRawExceptionHandlers (buffer, metadata, count, false); - } - - void PatchRawFatSection (ByteBuffer buffer, MetadataBuilder metadata) - { - Advance (-1); - var length = ReadInt32 (); - buffer.WriteInt32 (length); - - var count = (length >> 8) / 24; - - PatchRawExceptionHandlers (buffer, metadata, count, true); - } - - 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); - } - - 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/external/linker/cecil/Mono.Cecil.Cil/CodeWriter.cs b/external/linker/cecil/Mono.Cecil.Cil/CodeWriter.cs deleted file mode 100644 index 2003f104f6..0000000000 --- a/external/linker/cecil/Mono.Cecil.Cil/CodeWriter.cs +++ /dev/null @@ -1,659 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; - -using Mono.Collections.Generic; - -using Mono.Cecil.Metadata; -using Mono.Cecil.PE; - -using RVA = System.UInt32; - -#if !READ_ONLY - -namespace Mono.Cecil.Cil { - - sealed class CodeWriter : ByteBuffer { - - readonly RVA code_base; - internal readonly MetadataBuilder metadata; - readonly Dictionary standalone_signatures; - readonly Dictionary tiny_method_bodies; - - MethodBody body; - - public CodeWriter (MetadataBuilder metadata) - : base (0) - { - this.code_base = metadata.text_map.GetNextRVA (TextSegment.CLIHeader); - this.metadata = metadata; - this.standalone_signatures = new Dictionary (); - this.tiny_method_bodies = new Dictionary (new ByteBufferEqualityComparer ()); - } - - public RVA WriteMethodBody (MethodDefinition method) - { - RVA rva; - - if (IsUnresolved (method)) { - if (method.rva == 0) - return 0; - - rva = WriteUnresolvedMethodBody (method); - } else { - if (IsEmptyMethodBody (method.Body)) - return 0; - - rva = WriteResolvedMethodBody (method); - } - - return rva; - } - - static bool IsEmptyMethodBody (MethodBody body) - { - return body.instructions.IsNullOrEmpty () - && body.variables.IsNullOrEmpty (); - } - - static bool IsUnresolved (MethodDefinition method) - { - return method.HasBody && method.HasImage && method.body == null; - } - - RVA WriteUnresolvedMethodBody (MethodDefinition method) - { - var code_reader = metadata.module.reader.code; - - int code_size; - MetadataToken local_var_token; - var raw_body = code_reader.PatchRawMethodBody (method, this, out code_size, out local_var_token); - var fat_header = (raw_body.buffer [0] & 0x3) == 0x3; - if (fat_header) - Align (4); - - var rva = BeginMethod (); - - if (fat_header || !GetOrMapTinyMethodBody (raw_body, ref rva)) { - WriteBytes (raw_body); - } - - if (method.debug_info == null) - return rva; - - var symbol_writer = metadata.symbol_writer; - if (symbol_writer != null) { - method.debug_info.code_size = code_size; - method.debug_info.local_var_token = local_var_token; - symbol_writer.Write (method.debug_info); - } - - return rva; - } - - RVA WriteResolvedMethodBody(MethodDefinition method) - { - RVA rva; - - body = method.Body; - ComputeHeader (); - if (RequiresFatHeader ()) { - Align (4); - rva = BeginMethod (); - WriteFatHeader (); - WriteInstructions (); - - if (body.HasExceptionHandlers) - WriteExceptionHandlers (); - } else { - rva = BeginMethod (); - WriteByte ((byte) (0x2 | (body.CodeSize << 2))); // tiny - WriteInstructions (); - - var start_position = (int) (rva - code_base); - var body_size = position - start_position; - var body_bytes = new byte [body_size]; - - Array.Copy (buffer, start_position, body_bytes, 0, body_size); - - if (GetOrMapTinyMethodBody (new ByteBuffer (body_bytes), ref rva)) - position = start_position; - } - - var symbol_writer = metadata.symbol_writer; - if (symbol_writer != null && method.debug_info != null) { - method.debug_info.code_size = body.CodeSize; - method.debug_info.local_var_token = body.local_var_token; - symbol_writer.Write (method.debug_info); - } - - return rva; - } - - bool GetOrMapTinyMethodBody (ByteBuffer body, ref RVA rva) - { - RVA existing_rva; - if (tiny_method_bodies.TryGetValue (body, out existing_rva)) { - rva = existing_rva; - return true; - } - - tiny_method_bodies.Add (body, rva); - return false; - } - - 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); - } - } - - 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; - - var operand = instruction.operand; - if (operand == null && !(operand_type == OperandType.InlineBrTarget || operand_type == OperandType.ShortInlineBrTarget)) { - 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; - var offset = target != null ? GetTargetOffset (target) : body.code_size; - WriteSByte ((sbyte) (offset - (instruction.Offset + opcode.Size + 1))); - break; - } - case OperandType.InlineBrTarget: { - var target = (Instruction) operand; - var offset = target != null ? GetTargetOffset (target) : body.code_size; - WriteInt32 (offset - (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 (); - } - } - - int GetTargetOffset (Instruction instruction) - { - if (instruction == null) { - var last = body.instructions [body.instructions.size - 1]; - return last.offset + last.GetSize (); - } - - return instruction.offset; - } - - uint GetUserStringIndex (string @string) - { - if (@string == null) - return 0; - - return metadata.user_string_heap.GetStringIndex (@string); - } - - static int GetVariableIndex (VariableDefinition variable) - { - return variable.Index; - } - - int GetParameterIndex (ParameterDefinition parameter) - { - if (body.method.HasThis) { - if (parameter == body.this_parameter) - return 0; - - return parameter.Index + 1; - } - - return parameter.Index; - } - - bool RequiresFatHeader () - { - var body = this.body; - return body.CodeSize >= 64 - || body.InitLocals - || body.HasVariables - || body.HasExceptionHandlers - || body.MaxStackSize > 8; - } - - void ComputeHeader () - { - int offset = 0; - var instructions = body.instructions; - var items = instructions.items; - var count = instructions.size; - var stack_size = 0; - var max_stack = 0; - Dictionary 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); - } - - body.code_size = offset; - body.max_stack_size = max_stack; - } - - void ComputeExceptionHandlerStackSize (ref Dictionary stack_sizes) - { - var exception_handlers = body.ExceptionHandlers; - - for (int i = 0; i < exception_handlers.Count; i++) { - var exception_handler = exception_handlers [i]; - - 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; - } - } - } - - static void AddExceptionStackSize (Instruction handler_start, ref Dictionary stack_sizes) - { - if (handler_start == null) - return; - - if (stack_sizes == null) - stack_sizes = new Dictionary (); - - stack_sizes [handler_start] = 1; - } - - static void ComputeStackSize (Instruction instruction, ref Dictionary stack_sizes, ref int stack_size, ref int max_stack) - { - int computed_size; - if (stack_sizes != null && stack_sizes.TryGetValue (instruction, out computed_size)) - stack_size = computed_size; - - 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 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 stack_sizes, Instruction target, int stack_size) - { - if (stack_sizes == null) - stack_sizes = new Dictionary (); - - 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; - } - } - - static void ComputeStackDelta (Instruction instruction, ref int stack_size) - { - switch (instruction.opcode.FlowControl) { - case FlowControl.Call: { - var method = (IMethodSignature) instruction.operand; - // pop 'this' argument - if (method.HasImplicitThis() && instruction.opcode.Code != Code.Newobj) - stack_size--; - // pop normal arguments - if (method.HasParameters) - stack_size -= method.Parameters.Count; - // pop function pointer - if (instruction.opcode.Code == Code.Calli) - stack_size--; - // push return value - if (method.ReturnType.etype != ElementType.Void || instruction.opcode.Code == Code.Newobj) - stack_size++; - break; - } - default: - ComputePopDelta (instruction.opcode.StackBehaviourPop, ref stack_size); - ComputePushDelta (instruction.opcode.StackBehaviourPush, ref stack_size); - break; - } - } - - static void ComputePopDelta (StackBehaviour pop_behavior, ref int stack_size) - { - switch (pop_behavior) { - case StackBehaviour.Popi: - case StackBehaviour.Popref: - case StackBehaviour.Pop1: - stack_size--; - break; - 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; - 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; - } - } - - static void ComputePushDelta (StackBehaviour push_behaviour, ref int stack_size) - { - 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; - } - } - - void WriteExceptionHandlers () - { - Align (4); - - var handlers = body.ExceptionHandlers; - - if (handlers.Count < 0x15 && !RequiresFatSection (handlers)) - WriteSmallSection (handlers); - else - WriteFatSection (handlers); - } - - static bool RequiresFatSection (Collection 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.HandlerStart)) - return true; - } - - return false; - } - - static bool IsFatRange (Instruction start, Instruction end) - { - if (start == null) - throw new ArgumentException (); - - if (end == null) - return true; - - return end.Offset - start.Offset > 255 || start.Offset > 65535; - } - - void WriteSmallSection (Collection handlers) - { - const byte eh_table = 0x1; - - WriteByte (eh_table); - WriteByte ((byte) (handlers.Count * 12 + 4)); - WriteBytes (2); - - WriteExceptionHandlers ( - handlers, - i => WriteUInt16 ((ushort) i), - i => WriteByte ((byte) i)); - } - - void WriteFatSection (Collection handlers) - { - const byte eh_table = 0x1; - const byte fat_format = 0x40; - - WriteByte (eh_table | fat_format); - - int size = handlers.Count * 24 + 4; - WriteByte ((byte) (size & 0xff)); - WriteByte ((byte) ((size >> 8) & 0xff)); - WriteByte ((byte) ((size >> 16) & 0xff)); - - WriteExceptionHandlers (handlers, WriteInt32, WriteInt32); - } - - void WriteExceptionHandlers (Collection handlers, Action write_entry, Action write_length) - { - for (int i = 0; i < handlers.Count; i++) { - var handler = handlers [i]; - - write_entry ((int) handler.HandlerType); - - write_entry (handler.TryStart.Offset); - write_length (GetTargetOffset (handler.TryEnd) - handler.TryStart.Offset); - - write_entry (handler.HandlerStart.Offset); - write_length (GetTargetOffset (handler.HandlerEnd) - handler.HandlerStart.Offset); - - WriteExceptionHandlerSpecific (handler); - } - } - - 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; - } - } - - public MetadataToken GetStandAloneSignature (Collection variables) - { - var signature = metadata.GetLocalVariableBlobIndex (variables); - - return GetStandAloneSignatureToken (signature); - } - - public MetadataToken GetStandAloneSignature (CallSite call_site) - { - var signature = metadata.GetCallSiteBlobIndex (call_site); - var token = GetStandAloneSignatureToken (signature); - call_site.MetadataToken = token; - return token; - } - - 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; - } - - RVA BeginMethod () - { - return (RVA)(code_base + position); - } - - void WriteMetadataToken (MetadataToken token) - { - WriteUInt32 (token.ToUInt32 ()); - } - - void Align (int align) - { - align--; - WriteBytes (((position + align) & ~align) - position); - } - } -} - -#endif diff --git a/external/linker/cecil/Mono.Cecil.Cil/Document.cs b/external/linker/cecil/Mono.Cecil.Cil/Document.cs deleted file mode 100644 index 2c2d21e1c2..0000000000 --- a/external/linker/cecil/Mono.Cecil.Cil/Document.cs +++ /dev/null @@ -1,96 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil.Cil { - - public enum DocumentType { - Other, - Text, - } - - public enum DocumentHashAlgorithm { - None, - MD5, - SHA1, - SHA256, - } - - public enum DocumentLanguage { - Other, - C, - Cpp, - CSharp, - Basic, - Java, - Cobol, - Pascal, - Cil, - JScript, - Smc, - MCpp, - FSharp, - } - - public enum DocumentLanguageVendor { - Other, - Microsoft, - } - - public sealed class Document : DebugInformation { - - string url; - - byte type; - byte hash_algorithm; - byte language; - byte language_vendor; - - byte [] hash; - - public string Url { - get { return url; } - set { url = value; } - } - - public DocumentType Type { - get { return (DocumentType) type; } - set { type = (byte) value; } - } - - public DocumentHashAlgorithm HashAlgorithm { - get { return (DocumentHashAlgorithm) hash_algorithm; } - set { hash_algorithm = (byte) value; } - } - - public DocumentLanguage Language { - get { return (DocumentLanguage) language; } - set { language = (byte) value; } - } - - public DocumentLanguageVendor LanguageVendor { - get { return (DocumentLanguageVendor) language_vendor; } - set { language_vendor = (byte) value; } - } - - public byte [] Hash { - get { return hash; } - set { hash = value; } - } - - public Document (string url) - { - this.url = url; - this.hash = Empty.Array; - this.token = new MetadataToken (TokenType.Document); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Cil/ExceptionHandler.cs b/external/linker/cecil/Mono.Cecil.Cil/ExceptionHandler.cs deleted file mode 100644 index 6bdb1aa327..0000000000 --- a/external/linker/cecil/Mono.Cecil.Cil/ExceptionHandler.cs +++ /dev/null @@ -1,71 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil.Cil { - - public enum ExceptionHandlerType { - Catch = 0, - Filter = 1, - Finally = 2, - Fault = 4, - } - - public sealed class ExceptionHandler { - - Instruction try_start; - Instruction try_end; - Instruction filter_start; - Instruction handler_start; - Instruction handler_end; - - TypeReference catch_type; - ExceptionHandlerType handler_type; - - public Instruction TryStart { - get { return try_start; } - set { try_start = value; } - } - - public Instruction TryEnd { - get { return try_end; } - set { try_end = value; } - } - - public Instruction FilterStart { - get { return filter_start; } - set { filter_start = value; } - } - - public Instruction HandlerStart { - get { return handler_start; } - set { handler_start = value; } - } - - public Instruction HandlerEnd { - get { return handler_end; } - set { handler_end = value; } - } - - public TypeReference CatchType { - get { return catch_type; } - set { catch_type = value; } - } - - public ExceptionHandlerType HandlerType { - get { return handler_type; } - set { handler_type = value; } - } - - public ExceptionHandler (ExceptionHandlerType handlerType) - { - this.handler_type = handlerType; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Cil/ILProcessor.cs b/external/linker/cecil/Mono.Cecil.Cil/ILProcessor.cs deleted file mode 100644 index 039d2fc3a0..0000000000 --- a/external/linker/cecil/Mono.Cecil.Cil/ILProcessor.cs +++ /dev/null @@ -1,260 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using Mono.Collections.Generic; - -namespace Mono.Cecil.Cil { - - public sealed class ILProcessor { - - readonly MethodBody body; - readonly Collection 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/external/linker/cecil/Mono.Cecil.Cil/Instruction.cs b/external/linker/cecil/Mono.Cecil.Cil/Instruction.cs deleted file mode 100644 index 5fb36049b7..0000000000 --- a/external/linker/cecil/Mono.Cecil.Cil/Instruction.cs +++ /dev/null @@ -1,296 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Text; - -namespace Mono.Cecil.Cil { - - public sealed class Instruction { - - internal int offset; - internal OpCode opcode; - internal object operand; - - internal Instruction previous; - internal Instruction next; - - public int Offset { - get { return offset; } - set { offset = value; } - } - - public OpCode OpCode { - get { return opcode; } - set { opcode = value; } - } - - public object Operand { - get { return operand; } - set { operand = value; } - } - - public Instruction Previous { - get { return previous; } - set { previous = value; } - } - - public Instruction Next { - get { return next; } - set { next = value; } - } - - internal Instruction (int offset, OpCode opCode) - { - this.offset = offset; - this.opcode = opCode; - } - - internal Instruction (OpCode opcode, object operand) - { - this.opcode = opcode; - this.operand = operand; - } - - public int GetSize () - { - int size = opcode.Size; - - switch (opcode.OperandType) { - case OperandType.InlineSwitch: - return size + (1 + ((Instruction []) operand).Length) * 4; - case OperandType.InlineI8: - case OperandType.InlineR: - return size + 8; - case OperandType.InlineBrTarget: - case OperandType.InlineField: - case OperandType.InlineI: - case OperandType.InlineMethod: - case OperandType.InlineString: - case OperandType.InlineTok: - case OperandType.InlineType: - case OperandType.ShortInlineR: - case OperandType.InlineSig: - return size + 4; - case OperandType.InlineArg: - case OperandType.InlineVar: - return size + 2; - case OperandType.ShortInlineBrTarget: - case OperandType.ShortInlineI: - case OperandType.ShortInlineArg: - case OperandType.ShortInlineVar: - 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 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 static Instruction Create (OpCode opcode, FieldReference field) - { - 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/external/linker/cecil/Mono.Cecil.Cil/MethodBody.cs b/external/linker/cecil/Mono.Cecil.Cil/MethodBody.cs deleted file mode 100644 index eb8baf5b93..0000000000 --- a/external/linker/cecil/Mono.Cecil.Cil/MethodBody.cs +++ /dev/null @@ -1,248 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Threading; - -using Mono.Collections.Generic; - -namespace Mono.Cecil.Cil { - - public sealed class MethodBody { - - readonly internal MethodDefinition method; - - internal ParameterDefinition this_parameter; - internal int max_stack_size; - internal int code_size; - internal bool init_locals; - internal MetadataToken local_var_token; - - internal Collection instructions; - internal Collection exceptions; - internal Collection variables; - - public MethodDefinition Method { - get { return method; } - } - - public int MaxStackSize { - get { return max_stack_size; } - set { max_stack_size = value; } - } - - public int CodeSize { - get { return code_size; } - } - - public bool InitLocals { - get { return init_locals; } - set { init_locals = value; } - } - - public MetadataToken LocalVarToken { - get { return local_var_token; } - set { local_var_token = value; } - } - - public Collection Instructions { - get { return instructions ?? (instructions = new InstructionCollection (method)); } - } - - public bool HasExceptionHandlers { - get { return !exceptions.IsNullOrEmpty (); } - } - - public Collection ExceptionHandlers { - get { return exceptions ?? (exceptions = new Collection ()); } - } - - public bool HasVariables { - get { return !variables.IsNullOrEmpty (); } - } - - public Collection Variables { - get { return variables ?? (variables = new VariableDefinitionCollection ()); } - } - - public ParameterDefinition ThisParameter { - get { - if (method == null || method.DeclaringType == null) - throw new NotSupportedException (); - - if (!method.HasThis) - return null; - - if (this_parameter == null) - Interlocked.CompareExchange (ref this_parameter, CreateThisParameter (method), null); - - return this_parameter; - } - } - - static ParameterDefinition CreateThisParameter (MethodDefinition method) - { - var parameter_type = method.DeclaringType as TypeReference; - - if (parameter_type.HasGenericParameters) { - var instance = new GenericInstanceType (parameter_type); - for (int i = 0; i < parameter_type.GenericParameters.Count; i++) - instance.GenericArguments.Add (parameter_type.GenericParameters [i]); - - parameter_type = instance; - - } - - if (parameter_type.IsValueType || parameter_type.IsPrimitive) - parameter_type = new ByReferenceType (parameter_type); - - return new ParameterDefinition (parameter_type, method); - } - - public MethodBody (MethodDefinition method) - { - this.method = method; - } - - public ILProcessor GetILProcessor () - { - return new ILProcessor (this); - } - } - - sealed class VariableDefinitionCollection : Collection { - - internal VariableDefinitionCollection () - { - } - - internal VariableDefinitionCollection (int capacity) - : base (capacity) - { - } - - protected override void OnAdd (VariableDefinition item, int index) - { - item.index = index; - } - - protected override void OnInsert (VariableDefinition item, int index) - { - item.index = index; - - for (int i = index; i < size; i++) - items [i].index = i + 1; - } - - protected override void OnSet (VariableDefinition item, int index) - { - item.index = index; - } - - protected override void OnRemove (VariableDefinition item, int index) - { - item.index = -1; - - for (int i = index + 1; i < size; i++) - items [i].index = i - 1; - } - } - - class InstructionCollection : Collection { - - readonly MethodDefinition method; - - internal InstructionCollection (MethodDefinition method) - { - this.method = method; - } - - internal InstructionCollection (MethodDefinition method, int capacity) - : base (capacity) - { - this.method = method; - } - - protected override void OnAdd (Instruction item, int index) - { - if (index == 0) - return; - - var previous = items [index - 1]; - previous.next = item; - item.previous = previous; - } - - protected override void OnInsert (Instruction item, int index) - { - if (size == 0) - return; - - var current = items [index]; - if (current == null) { - var last = items [index - 1]; - last.next = item; - item.previous = last; - return; - } - - var previous = current.previous; - if (previous != null) { - previous.next = item; - item.previous = previous; - } - - current.previous = item; - item.next = current; - } - - protected override void OnSet (Instruction item, int index) - { - var current = items [index]; - - item.previous = current.previous; - item.next = current.next; - - current.previous = null; - current.next = null; - } - - protected override void OnRemove (Instruction item, int index) - { - var previous = item.previous; - if (previous != null) - previous.next = item.next; - - var next = item.next; - if (next != null) - next.previous = item.previous; - - RemoveSequencePoint (item); - - item.previous = null; - item.next = null; - } - - void RemoveSequencePoint (Instruction instruction) - { - var debug_info = method.debug_info; - if (debug_info == null || !debug_info.HasSequencePoints) - return; - - var sequence_points = debug_info.sequence_points; - for (int i = 0; i < sequence_points.Count; i++) { - if (sequence_points [i].Offset == instruction.offset) { - sequence_points.RemoveAt (i); - return; - } - } - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Cil/OpCode.cs b/external/linker/cecil/Mono.Cecil.Cil/OpCode.cs deleted file mode 100644 index 81ab0e12ac..0000000000 --- a/external/linker/cecil/Mono.Cecil.Cil/OpCode.cs +++ /dev/null @@ -1,439 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil.Cil { - - public enum FlowControl { - Branch, - Break, - Call, - Cond_Branch, - Meta, - Next, - Phi, - Return, - Throw, - } - - 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 : IEquatable { - - 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 OpCodeNames.names [(int) Code]; } - } - - public int Size { - get { return op1 == 0xff ? 1 : 2; } - } - - public byte Op1 { - get { return op1; } - } - - public byte Op2 { - get { return op2; } - } - - public short Value { - get { return op1 == 0xff ? op2 : (short) ((op1 << 8) | op2); } - } - - public Code Code { - get { return (Code) code; } - } - - public FlowControl FlowControl { - get { return (FlowControl) flow_control; } - } - - public OpCodeType OpCodeType { - get { return (OpCodeType) opcode_type; } - } - - public OperandType OperandType { - get { return (OperandType) operand_type; } - } - - public StackBehaviour StackBehaviourPop { - get { return (StackBehaviour) stack_behavior_pop; } - } - - public StackBehaviour StackBehaviourPush { - get { return (StackBehaviour) stack_behavior_push; } - } - - internal OpCode (int x, int y) - { - 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; - else - OpCodes.TwoBytesOpCode [op2] = this; - } - - public override int GetHashCode () - { - return Value; - } - - public override bool Equals (object obj) - { - if (!(obj is OpCode)) - return false; - - 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.op1 == other.op1 && one.op2 == other.op2; - } - - public static bool operator != (OpCode one, OpCode other) - { - return one.op1 != other.op1 || one.op2 != other.op2; - } - - public override string ToString () - { - return Name; - } - } - - static class OpCodeNames { - - internal static readonly string [] names; - - static OpCodeNames () - { - var table = new byte [] { - 3, 110, 111, 112, - 5, 98, 114, 101, 97, 107, - 7, 108, 100, 97, 114, 103, 46, 48, - 7, 108, 100, 97, 114, 103, 46, 49, - 7, 108, 100, 97, 114, 103, 46, 50, - 7, 108, 100, 97, 114, 103, 46, 51, - 7, 108, 100, 108, 111, 99, 46, 48, - 7, 108, 100, 108, 111, 99, 46, 49, - 7, 108, 100, 108, 111, 99, 46, 50, - 7, 108, 100, 108, 111, 99, 46, 51, - 7, 115, 116, 108, 111, 99, 46, 48, - 7, 115, 116, 108, 111, 99, 46, 49, - 7, 115, 116, 108, 111, 99, 46, 50, - 7, 115, 116, 108, 111, 99, 46, 51, - 7, 108, 100, 97, 114, 103, 46, 115, - 8, 108, 100, 97, 114, 103, 97, 46, 115, - 7, 115, 116, 97, 114, 103, 46, 115, - 7, 108, 100, 108, 111, 99, 46, 115, - 8, 108, 100, 108, 111, 99, 97, 46, 115, - 7, 115, 116, 108, 111, 99, 46, 115, - 6, 108, 100, 110, 117, 108, 108, - 9, 108, 100, 99, 46, 105, 52, 46, 109, 49, - 8, 108, 100, 99, 46, 105, 52, 46, 48, - 8, 108, 100, 99, 46, 105, 52, 46, 49, - 8, 108, 100, 99, 46, 105, 52, 46, 50, - 8, 108, 100, 99, 46, 105, 52, 46, 51, - 8, 108, 100, 99, 46, 105, 52, 46, 52, - 8, 108, 100, 99, 46, 105, 52, 46, 53, - 8, 108, 100, 99, 46, 105, 52, 46, 54, - 8, 108, 100, 99, 46, 105, 52, 46, 55, - 8, 108, 100, 99, 46, 105, 52, 46, 56, - 8, 108, 100, 99, 46, 105, 52, 46, 115, - 6, 108, 100, 99, 46, 105, 52, - 6, 108, 100, 99, 46, 105, 56, - 6, 108, 100, 99, 46, 114, 52, - 6, 108, 100, 99, 46, 114, 56, - 3, 100, 117, 112, - 3, 112, 111, 112, - 3, 106, 109, 112, - 4, 99, 97, 108, 108, - 5, 99, 97, 108, 108, 105, - 3, 114, 101, 116, - 4, 98, 114, 46, 115, - 9, 98, 114, 102, 97, 108, 115, 101, 46, 115, - 8, 98, 114, 116, 114, 117, 101, 46, 115, - 5, 98, 101, 113, 46, 115, - 5, 98, 103, 101, 46, 115, - 5, 98, 103, 116, 46, 115, - 5, 98, 108, 101, 46, 115, - 5, 98, 108, 116, 46, 115, - 8, 98, 110, 101, 46, 117, 110, 46, 115, - 8, 98, 103, 101, 46, 117, 110, 46, 115, - 8, 98, 103, 116, 46, 117, 110, 46, 115, - 8, 98, 108, 101, 46, 117, 110, 46, 115, - 8, 98, 108, 116, 46, 117, 110, 46, 115, - 2, 98, 114, - 7, 98, 114, 102, 97, 108, 115, 101, - 6, 98, 114, 116, 114, 117, 101, - 3, 98, 101, 113, - 3, 98, 103, 101, - 3, 98, 103, 116, - 3, 98, 108, 101, - 3, 98, 108, 116, - 6, 98, 110, 101, 46, 117, 110, - 6, 98, 103, 101, 46, 117, 110, - 6, 98, 103, 116, 46, 117, 110, - 6, 98, 108, 101, 46, 117, 110, - 6, 98, 108, 116, 46, 117, 110, - 6, 115, 119, 105, 116, 99, 104, - 8, 108, 100, 105, 110, 100, 46, 105, 49, - 8, 108, 100, 105, 110, 100, 46, 117, 49, - 8, 108, 100, 105, 110, 100, 46, 105, 50, - 8, 108, 100, 105, 110, 100, 46, 117, 50, - 8, 108, 100, 105, 110, 100, 46, 105, 52, - 8, 108, 100, 105, 110, 100, 46, 117, 52, - 8, 108, 100, 105, 110, 100, 46, 105, 56, - 7, 108, 100, 105, 110, 100, 46, 105, - 8, 108, 100, 105, 110, 100, 46, 114, 52, - 8, 108, 100, 105, 110, 100, 46, 114, 56, - 9, 108, 100, 105, 110, 100, 46, 114, 101, 102, - 9, 115, 116, 105, 110, 100, 46, 114, 101, 102, - 8, 115, 116, 105, 110, 100, 46, 105, 49, - 8, 115, 116, 105, 110, 100, 46, 105, 50, - 8, 115, 116, 105, 110, 100, 46, 105, 52, - 8, 115, 116, 105, 110, 100, 46, 105, 56, - 8, 115, 116, 105, 110, 100, 46, 114, 52, - 8, 115, 116, 105, 110, 100, 46, 114, 56, - 3, 97, 100, 100, - 3, 115, 117, 98, - 3, 109, 117, 108, - 3, 100, 105, 118, - 6, 100, 105, 118, 46, 117, 110, - 3, 114, 101, 109, - 6, 114, 101, 109, 46, 117, 110, - 3, 97, 110, 100, - 2, 111, 114, - 3, 120, 111, 114, - 3, 115, 104, 108, - 3, 115, 104, 114, - 6, 115, 104, 114, 46, 117, 110, - 3, 110, 101, 103, - 3, 110, 111, 116, - 7, 99, 111, 110, 118, 46, 105, 49, - 7, 99, 111, 110, 118, 46, 105, 50, - 7, 99, 111, 110, 118, 46, 105, 52, - 7, 99, 111, 110, 118, 46, 105, 56, - 7, 99, 111, 110, 118, 46, 114, 52, - 7, 99, 111, 110, 118, 46, 114, 56, - 7, 99, 111, 110, 118, 46, 117, 52, - 7, 99, 111, 110, 118, 46, 117, 56, - 8, 99, 97, 108, 108, 118, 105, 114, 116, - 5, 99, 112, 111, 98, 106, - 5, 108, 100, 111, 98, 106, - 5, 108, 100, 115, 116, 114, - 6, 110, 101, 119, 111, 98, 106, - 9, 99, 97, 115, 116, 99, 108, 97, 115, 115, - 6, 105, 115, 105, 110, 115, 116, - 9, 99, 111, 110, 118, 46, 114, 46, 117, 110, - 5, 117, 110, 98, 111, 120, - 5, 116, 104, 114, 111, 119, - 5, 108, 100, 102, 108, 100, - 6, 108, 100, 102, 108, 100, 97, - 5, 115, 116, 102, 108, 100, - 6, 108, 100, 115, 102, 108, 100, - 7, 108, 100, 115, 102, 108, 100, 97, - 6, 115, 116, 115, 102, 108, 100, - 5, 115, 116, 111, 98, 106, - 14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 49, 46, 117, 110, - 14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 50, 46, 117, 110, - 14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 52, 46, 117, 110, - 14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 56, 46, 117, 110, - 14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 49, 46, 117, 110, - 14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 50, 46, 117, 110, - 14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 52, 46, 117, 110, - 14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 56, 46, 117, 110, - 13, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 46, 117, 110, - 13, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 46, 117, 110, - 3, 98, 111, 120, - 6, 110, 101, 119, 97, 114, 114, - 5, 108, 100, 108, 101, 110, - 7, 108, 100, 101, 108, 101, 109, 97, - 9, 108, 100, 101, 108, 101, 109, 46, 105, 49, - 9, 108, 100, 101, 108, 101, 109, 46, 117, 49, - 9, 108, 100, 101, 108, 101, 109, 46, 105, 50, - 9, 108, 100, 101, 108, 101, 109, 46, 117, 50, - 9, 108, 100, 101, 108, 101, 109, 46, 105, 52, - 9, 108, 100, 101, 108, 101, 109, 46, 117, 52, - 9, 108, 100, 101, 108, 101, 109, 46, 105, 56, - 8, 108, 100, 101, 108, 101, 109, 46, 105, - 9, 108, 100, 101, 108, 101, 109, 46, 114, 52, - 9, 108, 100, 101, 108, 101, 109, 46, 114, 56, - 10, 108, 100, 101, 108, 101, 109, 46, 114, 101, 102, - 8, 115, 116, 101, 108, 101, 109, 46, 105, - 9, 115, 116, 101, 108, 101, 109, 46, 105, 49, - 9, 115, 116, 101, 108, 101, 109, 46, 105, 50, - 9, 115, 116, 101, 108, 101, 109, 46, 105, 52, - 9, 115, 116, 101, 108, 101, 109, 46, 105, 56, - 9, 115, 116, 101, 108, 101, 109, 46, 114, 52, - 9, 115, 116, 101, 108, 101, 109, 46, 114, 56, - 10, 115, 116, 101, 108, 101, 109, 46, 114, 101, 102, - 10, 108, 100, 101, 108, 101, 109, 46, 97, 110, 121, - 10, 115, 116, 101, 108, 101, 109, 46, 97, 110, 121, - 9, 117, 110, 98, 111, 120, 46, 97, 110, 121, - 11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 49, - 11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 49, - 11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 50, - 11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 50, - 11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 52, - 11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 52, - 11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 56, - 11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 56, - 9, 114, 101, 102, 97, 110, 121, 118, 97, 108, - 8, 99, 107, 102, 105, 110, 105, 116, 101, - 8, 109, 107, 114, 101, 102, 97, 110, 121, - 7, 108, 100, 116, 111, 107, 101, 110, - 7, 99, 111, 110, 118, 46, 117, 50, - 7, 99, 111, 110, 118, 46, 117, 49, - 6, 99, 111, 110, 118, 46, 105, - 10, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, - 10, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, - 7, 97, 100, 100, 46, 111, 118, 102, - 10, 97, 100, 100, 46, 111, 118, 102, 46, 117, 110, - 7, 109, 117, 108, 46, 111, 118, 102, - 10, 109, 117, 108, 46, 111, 118, 102, 46, 117, 110, - 7, 115, 117, 98, 46, 111, 118, 102, - 10, 115, 117, 98, 46, 111, 118, 102, 46, 117, 110, - 10, 101, 110, 100, 102, 105, 110, 97, 108, 108, 121, - 5, 108, 101, 97, 118, 101, - 7, 108, 101, 97, 118, 101, 46, 115, - 7, 115, 116, 105, 110, 100, 46, 105, - 6, 99, 111, 110, 118, 46, 117, - 7, 97, 114, 103, 108, 105, 115, 116, - 3, 99, 101, 113, - 3, 99, 103, 116, - 6, 99, 103, 116, 46, 117, 110, - 3, 99, 108, 116, - 6, 99, 108, 116, 46, 117, 110, - 5, 108, 100, 102, 116, 110, - 9, 108, 100, 118, 105, 114, 116, 102, 116, 110, - 5, 108, 100, 97, 114, 103, - 6, 108, 100, 97, 114, 103, 97, - 5, 115, 116, 97, 114, 103, - 5, 108, 100, 108, 111, 99, - 6, 108, 100, 108, 111, 99, 97, - 5, 115, 116, 108, 111, 99, - 8, 108, 111, 99, 97, 108, 108, 111, 99, - 9, 101, 110, 100, 102, 105, 108, 116, 101, 114, - 10, 117, 110, 97, 108, 105, 103, 110, 101, 100, 46, - 9, 118, 111, 108, 97, 116, 105, 108, 101, 46, - 5, 116, 97, 105, 108, 46, - 7, 105, 110, 105, 116, 111, 98, 106, - 12, 99, 111, 110, 115, 116, 114, 97, 105, 110, 101, 100, 46, - 5, 99, 112, 98, 108, 107, - 7, 105, 110, 105, 116, 98, 108, 107, - 3, 110, 111, 46, - 7, 114, 101, 116, 104, 114, 111, 119, - 6, 115, 105, 122, 101, 111, 102, - 10, 114, 101, 102, 97, 110, 121, 116, 121, 112, 101, - 9, 114, 101, 97, 100, 111, 110, 108, 121, 46, - }; - - names = new string [219]; - - for (int i = 0, p = 0; i < names.Length; i++) { - var buffer = new char [table [p++]]; - - for (int j = 0; j < buffer.Length; j++) - buffer [j] = (char) table [p++]; - - names [i] = new string (buffer); - } - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Cil/OpCodes.cs b/external/linker/cecil/Mono.Cecil.Cil/OpCodes.cs deleted file mode 100644 index ba0468d305..0000000000 --- a/external/linker/cecil/Mono.Cecil.Cil/OpCodes.cs +++ /dev/null @@ -1,894 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil.Cil { - - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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 ( - 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/external/linker/cecil/Mono.Cecil.Cil/PortablePdb.cs b/external/linker/cecil/Mono.Cecil.Cil/PortablePdb.cs deleted file mode 100644 index a7883e71d1..0000000000 --- a/external/linker/cecil/Mono.Cecil.Cil/PortablePdb.cs +++ /dev/null @@ -1,614 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; - -using Mono.Cecil.Metadata; -using Mono.Cecil.PE; - -namespace Mono.Cecil.Cil { - - public sealed class PortablePdbReaderProvider : ISymbolReaderProvider { - - public ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName) - { - Mixin.CheckModule (module); - Mixin.CheckFileName (fileName); - - var file = File.OpenRead (Mixin.GetPdbFileName (fileName)); - return GetSymbolReader (module, Disposable.Owned (file as Stream), file.Name); - } - - public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream) - { - Mixin.CheckModule (module); - Mixin.CheckStream (symbolStream); - - return GetSymbolReader (module, Disposable.NotOwned (symbolStream), symbolStream.GetFileName ()); - } - - ISymbolReader GetSymbolReader (ModuleDefinition module, Disposable symbolStream, string fileName) - { - return new PortablePdbReader (ImageReader.ReadPortablePdb (symbolStream, fileName), module); - } - } - - public sealed class PortablePdbReader : ISymbolReader { - - readonly Image image; - readonly ModuleDefinition module; - readonly MetadataReader reader; - readonly MetadataReader debug_reader; - - bool IsEmbedded { get { return reader.image == debug_reader.image; } } - - internal PortablePdbReader (Image image, ModuleDefinition module) - { - this.image = image; - this.module = module; - this.reader = module.reader; - this.debug_reader = new MetadataReader (image, module, this.reader); - } - -#if !READ_ONLY - public ISymbolWriterProvider GetWriterProvider () - { - return new PortablePdbWriterProvider (); - } -#endif - - public bool ProcessDebugHeader (ImageDebugHeader header) - { - if (image == module.Image) - return true; - - var entry = header.GetCodeViewEntry (); - if (entry == null) - return false; - - var data = entry.Data; - - if (data.Length < 24) - return false; - - var magic = ReadInt32 (data, 0); - if (magic != 0x53445352) - return false; - - var buffer = new byte [16]; - Buffer.BlockCopy (data, 4, buffer, 0, 16); - - var module_guid = new Guid (buffer); - - Buffer.BlockCopy (image.PdbHeap.Id, 0, buffer, 0, 16); - - var pdb_guid = new Guid (buffer); - - if (module_guid != pdb_guid) - return false; - - ReadModule (); - return true; - } - - static int ReadInt32 (byte [] bytes, int start) - { - return (bytes [start] - | (bytes [start + 1] << 8) - | (bytes [start + 2] << 16) - | (bytes [start + 3] << 24)); - } - - void ReadModule () - { - module.custom_infos = debug_reader.GetCustomDebugInformation (module); - } - - public MethodDebugInformation Read (MethodDefinition method) - { - var info = new MethodDebugInformation (method); - ReadSequencePoints (info); - ReadScope (info); - ReadStateMachineKickOffMethod (info); - ReadCustomDebugInformations (info); - return info; - } - - void ReadSequencePoints (MethodDebugInformation method_info) - { - method_info.sequence_points = debug_reader.ReadSequencePoints (method_info.method); - } - - void ReadScope (MethodDebugInformation method_info) - { - method_info.scope = debug_reader.ReadScope (method_info.method); - } - - void ReadStateMachineKickOffMethod (MethodDebugInformation method_info) - { - method_info.kickoff_method = debug_reader.ReadStateMachineKickoffMethod (method_info.method); - } - - void ReadCustomDebugInformations (MethodDebugInformation info) - { - info.method.custom_infos = debug_reader.GetCustomDebugInformation (info.method); - } - - public void Dispose () - { - if (IsEmbedded) - return; - - image.Dispose (); - } - } - - public sealed class EmbeddedPortablePdbReaderProvider : ISymbolReaderProvider { - - public ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName) - { - Mixin.CheckModule (module); - Mixin.CheckFileName (fileName); - - var header = module.GetDebugHeader (); - var entry = header.GetEmbeddedPortablePdbEntry (); - if (entry == null) - throw new InvalidOperationException (); - - return new EmbeddedPortablePdbReader ( - (PortablePdbReader) new PortablePdbReaderProvider ().GetSymbolReader (module, GetPortablePdbStream (entry))); - } - - static Stream GetPortablePdbStream (ImageDebugHeaderEntry entry) - { - var compressed_stream = new MemoryStream (entry.Data); - var reader = new BinaryStreamReader (compressed_stream); - reader.ReadInt32 (); // signature - var length = reader.ReadInt32 (); - var decompressed_stream = new MemoryStream (length); - - using (var deflate_stream = new DeflateStream (compressed_stream, CompressionMode.Decompress, leaveOpen: true)) - deflate_stream.CopyTo (decompressed_stream); - - return decompressed_stream; - } - - public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream) - { - throw new NotSupportedException (); - } - } - - public sealed class EmbeddedPortablePdbReader : ISymbolReader - { - private readonly PortablePdbReader reader; - - internal EmbeddedPortablePdbReader (PortablePdbReader reader) - { - if (reader == null) - throw new ArgumentNullException (); - - this.reader = reader; - } - -#if !READ_ONLY - public ISymbolWriterProvider GetWriterProvider () - { - return new EmbeddedPortablePdbWriterProvider (); - } -#endif - public bool ProcessDebugHeader (ImageDebugHeader header) - { - return reader.ProcessDebugHeader (header); - } - - public MethodDebugInformation Read (MethodDefinition method) - { - return reader.Read (method); - } - - public void Dispose () - { - reader.Dispose (); - } - } - - -#if !READ_ONLY - - public sealed class PortablePdbWriterProvider : ISymbolWriterProvider - { - public ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName) - { - Mixin.CheckModule (module); - Mixin.CheckFileName (fileName); - - var file = File.OpenWrite (Mixin.GetPdbFileName (fileName)); - return GetSymbolWriter (module, Disposable.Owned (file as Stream)); - } - - public ISymbolWriter GetSymbolWriter (ModuleDefinition module, Stream symbolStream) - { - Mixin.CheckModule (module); - Mixin.CheckStream (symbolStream); - - return GetSymbolWriter (module, Disposable.NotOwned (symbolStream)); - } - - ISymbolWriter GetSymbolWriter (ModuleDefinition module, Disposable stream) - { - var metadata = new MetadataBuilder (module, this); - var writer = ImageWriter.CreateDebugWriter (module, metadata, stream); - - return new PortablePdbWriter (metadata, module, writer); - } - } - - interface IMetadataSymbolWriter : ISymbolWriter { - void SetMetadata (MetadataBuilder metadata); - void WriteModule (); - } - - public sealed class PortablePdbWriter : ISymbolWriter, IMetadataSymbolWriter { - - readonly MetadataBuilder pdb_metadata; - readonly ModuleDefinition module; - readonly ImageWriter writer; - - MetadataBuilder module_metadata; - - bool IsEmbedded { get { return writer == null; } } - - internal PortablePdbWriter (MetadataBuilder pdb_metadata, ModuleDefinition module) - { - this.pdb_metadata = pdb_metadata; - this.module = module; - } - - internal PortablePdbWriter (MetadataBuilder pdb_metadata, ModuleDefinition module, ImageWriter writer) - : this (pdb_metadata, module) - { - this.writer = writer; - } - - void IMetadataSymbolWriter.SetMetadata (MetadataBuilder metadata) - { - this.module_metadata = metadata; - - if (module_metadata != pdb_metadata) - this.pdb_metadata.metadata_builder = metadata; - } - - void IMetadataSymbolWriter.WriteModule () - { - pdb_metadata.AddCustomDebugInformations (module); - } - - public ISymbolReaderProvider GetReaderProvider () - { - return new PortablePdbReaderProvider (); - } - - public ImageDebugHeader GetDebugHeader () - { - if (IsEmbedded) - return new ImageDebugHeader (); - - var directory = new ImageDebugDirectory () { - MajorVersion = 256, - MinorVersion = 20557, - Type = ImageDebugType.CodeView, - TimeDateStamp = (int) module.timestamp, - }; - - var buffer = new ByteBuffer (); - // RSDS - buffer.WriteUInt32 (0x53445352); - // Module ID - buffer.WriteBytes (module.Mvid.ToByteArray ()); - // PDB Age - buffer.WriteUInt32 (1); - // PDB Path - var filename = writer.BaseStream.GetFileName (); - if (!string.IsNullOrEmpty (filename)) - filename = Path.GetFileName (filename); - - buffer.WriteBytes (System.Text.Encoding.UTF8.GetBytes (filename)); - buffer.WriteByte (0); - - var data = new byte [buffer.length]; - Buffer.BlockCopy (buffer.buffer, 0, data, 0, buffer.length); - directory.SizeOfData = data.Length; - - return new ImageDebugHeader (new ImageDebugHeaderEntry (directory, data)); - } - - public void Write (MethodDebugInformation info) - { - CheckMethodDebugInformationTable (); - - pdb_metadata.AddMethodDebugInformation (info); - } - - void CheckMethodDebugInformationTable () - { - var mdi = pdb_metadata.table_heap.GetTable (Table.MethodDebugInformation); - if (mdi.length > 0) - return; - - // The MethodDebugInformation table has the same length as the Method table - mdi.rows = new Row [module_metadata.method_rid - 1]; - mdi.length = mdi.rows.Length; - } - - public void Dispose () - { - if (IsEmbedded) - return; - - WritePdbFile (); - } - - void WritePdbFile () - { - WritePdbHeap (); - - WriteTableHeap (); - - writer.BuildMetadataTextMap (); - writer.WriteMetadataHeader (); - writer.WriteMetadata (); - - writer.Flush (); - writer.stream.Dispose (); - } - - void WritePdbHeap () - { - var pdb_heap = pdb_metadata.pdb_heap; - - pdb_heap.WriteBytes (module.Mvid.ToByteArray ()); - pdb_heap.WriteUInt32 (module_metadata.timestamp); - - pdb_heap.WriteUInt32 (module_metadata.entry_point.ToUInt32 ()); - - var table_heap = module_metadata.table_heap; - var tables = table_heap.tables; - - ulong valid = 0; - for (int i = 0; i < tables.Length; i++) { - if (tables [i] == null || tables [i].Length == 0) - continue; - - valid |= (1UL << i); - } - - pdb_heap.WriteUInt64 (valid); - - for (int i = 0; i < tables.Length; i++) { - if (tables [i] == null || tables [i].Length == 0) - continue; - - pdb_heap.WriteUInt32 ((uint) tables [i].Length); - } - } - - void WriteTableHeap () - { - pdb_metadata.table_heap.string_offsets = pdb_metadata.string_heap.WriteStrings (); - pdb_metadata.table_heap.ComputeTableInformations (); - pdb_metadata.table_heap.WriteTableHeap (); - } - } - - public sealed class EmbeddedPortablePdbWriterProvider : ISymbolWriterProvider { - - public ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName) - { - Mixin.CheckModule (module); - Mixin.CheckFileName (fileName); - - var stream = new MemoryStream (); - var pdb_writer = (PortablePdbWriter) new PortablePdbWriterProvider ().GetSymbolWriter (module, stream); - return new EmbeddedPortablePdbWriter (stream, pdb_writer); - } - - public ISymbolWriter GetSymbolWriter (ModuleDefinition module, Stream symbolStream) - { - throw new NotSupportedException (); - } - } - - public sealed class EmbeddedPortablePdbWriter : ISymbolWriter, IMetadataSymbolWriter { - - readonly Stream stream; - readonly PortablePdbWriter writer; - - internal EmbeddedPortablePdbWriter (Stream stream, PortablePdbWriter writer) - { - this.stream = stream; - this.writer = writer; - } - - public ISymbolReaderProvider GetReaderProvider () - { - return new EmbeddedPortablePdbReaderProvider (); - } - - public ImageDebugHeader GetDebugHeader () - { - writer.Dispose (); - - var directory = new ImageDebugDirectory { - Type = ImageDebugType.EmbeddedPortablePdb, - }; - - var data = new MemoryStream (); - - var w = new BinaryStreamWriter (data); - w.WriteByte (0x4d); - w.WriteByte (0x50); - w.WriteByte (0x44); - w.WriteByte (0x42); - - w.WriteInt32 ((int) stream.Length); - - stream.Position = 0; - - using (var compress_stream = new DeflateStream (data, CompressionMode.Compress, leaveOpen: true)) - stream.CopyTo (compress_stream); - - directory.SizeOfData = (int) data.Length; - - return new ImageDebugHeader (new [] { - writer.GetDebugHeader ().Entries [0], - new ImageDebugHeaderEntry (directory, data.ToArray ()) - }); - } - - public void Write (MethodDebugInformation info) - { - writer.Write (info); - } - - public void Dispose () - { - } - - void IMetadataSymbolWriter.SetMetadata (MetadataBuilder metadata) - { - ((IMetadataSymbolWriter) writer).SetMetadata (metadata); - } - - void IMetadataSymbolWriter.WriteModule () - { - ((IMetadataSymbolWriter) writer).WriteModule (); - } - } - -#endif - - static class PdbGuidMapping { - - static readonly Dictionary guid_language = new Dictionary (); - static readonly Dictionary language_guid = new Dictionary (); - - static PdbGuidMapping () - { - AddMapping (DocumentLanguage.C, new Guid ("63a08714-fc37-11d2-904c-00c04fa302a1")); - AddMapping (DocumentLanguage.Cpp, new Guid ("3a12d0b7-c26c-11d0-b442-00a0244a1dd2")); - AddMapping (DocumentLanguage.CSharp, new Guid ("3f5162f8-07c6-11d3-9053-00c04fa302a1")); - AddMapping (DocumentLanguage.Basic, new Guid ("3a12d0b8-c26c-11d0-b442-00a0244a1dd2")); - AddMapping (DocumentLanguage.Java, new Guid ("3a12d0b4-c26c-11d0-b442-00a0244a1dd2")); - AddMapping (DocumentLanguage.Cobol, new Guid ("af046cd1-d0e1-11d2-977c-00a0c9b4d50c")); - AddMapping (DocumentLanguage.Pascal, new Guid ("af046cd2-d0e1-11d2-977c-00a0c9b4d50c")); - AddMapping (DocumentLanguage.Cil, new Guid ("af046cd3-d0e1-11d2-977c-00a0c9b4d50c")); - AddMapping (DocumentLanguage.JScript, new Guid ("3a12d0b6-c26c-11d0-b442-00a0244a1dd2")); - AddMapping (DocumentLanguage.Smc, new Guid ("0d9b9f7b-6611-11d3-bd2a-0000f80849bd")); - AddMapping (DocumentLanguage.MCpp, new Guid ("4b35fde8-07c6-11d3-9053-00c04fa302a1")); - AddMapping (DocumentLanguage.FSharp, new Guid ("ab4f38c9-b6e6-43ba-be3b-58080b2ccce3")); - } - - static void AddMapping (DocumentLanguage language, Guid guid) - { - guid_language.Add (guid, language); - language_guid.Add (language, guid); - } - - static readonly Guid type_text = new Guid ("5a869d0b-6611-11d3-bd2a-0000f80849bd"); - - public static DocumentType ToType (this Guid guid) - { - if (guid == type_text) - return DocumentType.Text; - - return DocumentType.Other; - } - - public static Guid ToGuid (this DocumentType type) - { - if (type == DocumentType.Text) - return type_text; - - return new Guid (); - } - - static readonly Guid hash_md5 = new Guid ("406ea660-64cf-4c82-b6f0-42d48172a799"); - static readonly Guid hash_sha1 = new Guid ("ff1816ec-aa5e-4d10-87f7-6f4963833460"); - static readonly Guid hash_sha256 = new Guid ("8829d00f-11b8-4213-878b-770e8597ac16"); - - public static DocumentHashAlgorithm ToHashAlgorithm (this Guid guid) - { - if (guid == hash_md5) - return DocumentHashAlgorithm.MD5; - - if (guid == hash_sha1) - return DocumentHashAlgorithm.SHA1; - - if (guid == hash_sha256) - return DocumentHashAlgorithm.SHA256; - - return DocumentHashAlgorithm.None; - } - - public static Guid ToGuid (this DocumentHashAlgorithm hash_algo) - { - if (hash_algo == DocumentHashAlgorithm.MD5) - return hash_md5; - - if (hash_algo == DocumentHashAlgorithm.SHA1) - return hash_sha1; - - if (hash_algo == DocumentHashAlgorithm.SHA256) - return hash_sha256; - - return new Guid (); - } - - public static DocumentLanguage ToLanguage (this Guid guid) - { - DocumentLanguage language; - if (!guid_language.TryGetValue (guid, out language)) - return DocumentLanguage.Other; - - return language; - } - - public static Guid ToGuid (this DocumentLanguage language) - { - Guid guid; - if (!language_guid.TryGetValue (language, out guid)) - return new Guid (); - - return guid; - } - - static readonly Guid vendor_ms = new Guid ("994b45c4-e6e9-11d2-903f-00c04fa302a1"); - - public static DocumentLanguageVendor ToVendor (this Guid guid) - { - if (guid == vendor_ms) - return DocumentLanguageVendor.Microsoft; - - return DocumentLanguageVendor.Other; - } - - public static Guid ToGuid (this DocumentLanguageVendor vendor) - { - if (vendor == DocumentLanguageVendor.Microsoft) - return vendor_ms; - - return new Guid (); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Cil/SequencePoint.cs b/external/linker/cecil/Mono.Cecil.Cil/SequencePoint.cs deleted file mode 100644 index 725d307ae9..0000000000 --- a/external/linker/cecil/Mono.Cecil.Cil/SequencePoint.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil.Cil { - - public sealed class SequencePoint { - - internal InstructionOffset offset; - Document document; - - int start_line; - int start_column; - int end_line; - int end_column; - - public int Offset { - get { return offset.Offset; } - } - - public int StartLine { - get { return start_line; } - set { start_line = value; } - } - - public int StartColumn { - get { return start_column; } - set { start_column = value; } - } - - public int EndLine { - get { return end_line; } - set { end_line = value; } - } - - public int EndColumn { - get { return end_column; } - set { end_column = value; } - } - - public bool IsHidden { - get { return start_line == 0xfeefee && start_line == end_line; } - } - - public Document Document { - get { return document; } - set { document = value; } - } - - internal SequencePoint (int offset, Document document) - { - if (document == null) - throw new ArgumentNullException ("document"); - - this.offset = new InstructionOffset (offset); - this.document = document; - } - - public SequencePoint (Instruction instruction, Document document) - { - if (document == null) - throw new ArgumentNullException ("document"); - - this.offset = new InstructionOffset (instruction); - this.document = document; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Cil/Symbols.cs b/external/linker/cecil/Mono.Cecil.Cil/Symbols.cs deleted file mode 100644 index c47761dd90..0000000000 --- a/external/linker/cecil/Mono.Cecil.Cil/Symbols.cs +++ /dev/null @@ -1,1021 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.InteropServices; -using SR = System.Reflection; - -using Mono.Collections.Generic; -using Mono.Cecil.Cil; - -namespace Mono.Cecil.Cil { - - [StructLayout (LayoutKind.Sequential)] - public struct ImageDebugDirectory { - public const int Size = 28; - - public int Characteristics; - public int TimeDateStamp; - public short MajorVersion; - public short MinorVersion; - public ImageDebugType Type; - public int SizeOfData; - public int AddressOfRawData; - public int PointerToRawData; - } - - public enum ImageDebugType { - CodeView = 2, - Deterministic = 16, - EmbeddedPortablePdb = 17, - } - - public sealed class ImageDebugHeader { - - readonly ImageDebugHeaderEntry [] entries; - - public bool HasEntries { - get { return !entries.IsNullOrEmpty (); } - } - - public ImageDebugHeaderEntry [] Entries { - get { return entries; } - } - - public ImageDebugHeader (ImageDebugHeaderEntry [] entries) - { - this.entries = entries ?? Empty.Array; - } - - public ImageDebugHeader () - : this (Empty.Array) - { - } - - public ImageDebugHeader (ImageDebugHeaderEntry entry) - : this (new [] { entry }) - { - } - } - - public sealed class ImageDebugHeaderEntry { - - ImageDebugDirectory directory; - readonly byte [] data; - - public ImageDebugDirectory Directory { - get { return directory; } - internal set { directory = value; } - } - - public byte [] Data { - get { return data; } - } - - public ImageDebugHeaderEntry (ImageDebugDirectory directory, byte [] data) - { - this.directory = directory; - this.data = data ?? Empty.Array; - } - } - - public sealed class ScopeDebugInformation : DebugInformation { - - internal InstructionOffset start; - internal InstructionOffset end; - internal ImportDebugInformation import; - internal Collection scopes; - internal Collection variables; - internal Collection constants; - - public InstructionOffset Start { - get { return start; } - set { start = value; } - } - - public InstructionOffset End { - get { return end; } - set { end = value; } - } - - public ImportDebugInformation Import { - get { return import; } - set { import = value; } - } - - public bool HasScopes { - get { return !scopes.IsNullOrEmpty (); } - } - - public Collection Scopes { - get { return scopes ?? (scopes = new Collection ()); } - } - - public bool HasVariables { - get { return !variables.IsNullOrEmpty (); } - } - - public Collection Variables { - get { return variables ?? (variables = new Collection ()); } - } - - public bool HasConstants { - get { return !constants.IsNullOrEmpty (); } - } - - public Collection Constants { - get { return constants ?? (constants = new Collection ()); } - } - - internal ScopeDebugInformation () - { - this.token = new MetadataToken (TokenType.LocalScope); - } - - public ScopeDebugInformation (Instruction start, Instruction end) - : this () - { - if (start == null) - throw new ArgumentNullException ("start"); - - this.start = new InstructionOffset (start); - - if (end != null) - this.end = new InstructionOffset (end); - } - - public bool TryGetName (VariableDefinition variable, out string name) - { - name = null; - if (variables == null || variables.Count == 0) - return false; - - for (int i = 0; i < variables.Count; i++) { - if (variables [i].Index == variable.Index) { - name = variables [i].Name; - return true; - } - } - - return false; - } - } - - public struct InstructionOffset { - - readonly Instruction instruction; - readonly int? offset; - - public int Offset { - get { - if (instruction != null) - return instruction.Offset; - if (offset.HasValue) - return offset.Value; - - throw new NotSupportedException (); - } - } - - public bool IsEndOfMethod { - get { return instruction == null && !offset.HasValue; } - } - - public InstructionOffset (Instruction instruction) - { - if (instruction == null) - throw new ArgumentNullException ("instruction"); - - this.instruction = instruction; - this.offset = null; - } - - public InstructionOffset (int offset) - { - this.instruction = null; - this.offset = offset; - } - } - - [Flags] - public enum VariableAttributes : ushort { - None = 0, - DebuggerHidden = 1, - } - - public struct VariableIndex { - readonly VariableDefinition variable; - readonly int? index; - - public int Index { - get { - if (variable != null) - return variable.Index; - if (index.HasValue) - return index.Value; - - throw new NotSupportedException (); - } - } - - public VariableIndex (VariableDefinition variable) - { - if (variable == null) - throw new ArgumentNullException ("variable"); - - this.variable = variable; - this.index = null; - } - - public VariableIndex (int index) - { - this.variable = null; - this.index = index; - } - } - - public abstract class DebugInformation : ICustomDebugInformationProvider { - - internal MetadataToken token; - internal Collection custom_infos; - - public MetadataToken MetadataToken { - get { return token; } - set { token = value; } - } - - public bool HasCustomDebugInformations { - get { return !custom_infos.IsNullOrEmpty (); } - } - - public Collection CustomDebugInformations { - get { return custom_infos ?? (custom_infos = new Collection ()); } - } - - internal DebugInformation () - { - } - } - - public sealed class VariableDebugInformation : DebugInformation { - - string name; - ushort attributes; - internal VariableIndex index; - - public int Index { - get { return index.Index; } - } - - public string Name { - get { return name; } - set { name = value; } - } - - public VariableAttributes Attributes { - get { return (VariableAttributes) attributes; } - set { attributes = (ushort) value; } - } - - public bool IsDebuggerHidden { - get { return attributes.GetAttributes ((ushort) VariableAttributes.DebuggerHidden); } - set { attributes = attributes.SetAttributes ((ushort) VariableAttributes.DebuggerHidden, value); } - } - - internal VariableDebugInformation (int index, string name) - { - if (name == null) - throw new ArgumentNullException ("name"); - - this.index = new VariableIndex (index); - this.name = name; - } - - public VariableDebugInformation (VariableDefinition variable, string name) - { - if (variable == null) - throw new ArgumentNullException ("variable"); - if (name == null) - throw new ArgumentNullException ("name"); - - this.index = new VariableIndex (variable); - this.name = name; - this.token = new MetadataToken (TokenType.LocalVariable); - } - } - - public sealed class ConstantDebugInformation : DebugInformation { - - string name; - TypeReference constant_type; - object value; - - public string Name { - get { return name; } - set { name = value; } - } - - public TypeReference ConstantType { - get { return constant_type; } - set { constant_type = value; } - } - - public object Value { - get { return value; } - set { this.value = value; } - } - - public ConstantDebugInformation (string name, TypeReference constant_type, object value) - { - if (name == null) - throw new ArgumentNullException ("name"); - - this.name = name; - this.constant_type = constant_type; - this.value = value; - this.token = new MetadataToken (TokenType.LocalConstant); - } - } - - public enum ImportTargetKind : byte { - ImportNamespace = 1, - ImportNamespaceInAssembly = 2, - ImportType = 3, - ImportXmlNamespaceWithAlias = 4, - ImportAlias = 5, - DefineAssemblyAlias = 6, - DefineNamespaceAlias = 7, - DefineNamespaceInAssemblyAlias = 8, - DefineTypeAlias = 9, - } - - public sealed class ImportTarget { - - internal ImportTargetKind kind; - - internal string @namespace; - internal TypeReference type; - internal AssemblyNameReference reference; - internal string alias; - - public string Namespace { - get { return @namespace; } - set { @namespace = value; } - } - - public TypeReference Type { - get { return type; } - set { type = value; } - } - - public AssemblyNameReference AssemblyReference { - get { return reference; } - set { reference = value; } - } - - public string Alias { - get { return alias; } - set { alias = value; } - } - - public ImportTargetKind Kind { - get { return kind; } - set { kind = value; } - } - - public ImportTarget (ImportTargetKind kind) - { - this.kind = kind; - } - } - - public sealed class ImportDebugInformation : DebugInformation { - - internal ImportDebugInformation parent; - internal Collection targets; - - public bool HasTargets { - get { return !targets.IsNullOrEmpty (); } - } - - public Collection Targets { - get { return targets ?? (targets = new Collection ()); } - } - - public ImportDebugInformation Parent { - get { return parent; } - set { parent = value; } - } - - public ImportDebugInformation () - { - this.token = new MetadataToken (TokenType.ImportScope); - } - } - - public interface ICustomDebugInformationProvider : IMetadataTokenProvider { - bool HasCustomDebugInformations { get; } - Collection CustomDebugInformations { get; } - } - - public enum CustomDebugInformationKind { - Binary, - StateMachineScope, - DynamicVariable, - DefaultNamespace, - AsyncMethodBody, - EmbeddedSource, - SourceLink, - } - - public abstract class CustomDebugInformation : DebugInformation { - - Guid identifier; - - public Guid Identifier { - get { return identifier; } - } - - public abstract CustomDebugInformationKind Kind { get; } - - internal CustomDebugInformation (Guid identifier) - { - this.identifier = identifier; - this.token = new MetadataToken (TokenType.CustomDebugInformation); - } - } - - public sealed class BinaryCustomDebugInformation : CustomDebugInformation { - - byte [] data; - - public byte [] Data { - get { return data; } - set { data = value; } - } - - public override CustomDebugInformationKind Kind { - get { return CustomDebugInformationKind.Binary; } - } - - public BinaryCustomDebugInformation (Guid identifier, byte [] data) - : base (identifier) - { - this.data = data; - } - } - - public sealed class AsyncMethodBodyDebugInformation : CustomDebugInformation { - - internal InstructionOffset catch_handler; - internal Collection yields; - internal Collection resumes; - internal Collection resume_methods; - - public InstructionOffset CatchHandler { - get { return catch_handler; } - set { catch_handler = value; } - } - - public Collection Yields { - get { return yields ?? (yields = new Collection ()); } - } - - public Collection Resumes { - get { return resumes ?? (resumes = new Collection ()); } - } - - public Collection ResumeMethods { - get { return resume_methods ?? (resume_methods = new Collection ()); } - } - - public override CustomDebugInformationKind Kind { - get { return CustomDebugInformationKind.AsyncMethodBody; } - } - - public static Guid KindIdentifier = new Guid ("{54FD2AC5-E925-401A-9C2A-F94F171072F8}"); - - internal AsyncMethodBodyDebugInformation (int catchHandler) - : base (KindIdentifier) - { - this.catch_handler = new InstructionOffset (catchHandler); - } - - public AsyncMethodBodyDebugInformation (Instruction catchHandler) - : base (KindIdentifier) - { - this.catch_handler = new InstructionOffset (catchHandler); - } - - public AsyncMethodBodyDebugInformation () - : base (KindIdentifier) - { - this.catch_handler = new InstructionOffset (-1); - } - } - - public sealed class StateMachineScope { - - internal InstructionOffset start; - internal InstructionOffset end; - - public InstructionOffset Start { - get { return start; } - set { start = value; } - } - - public InstructionOffset End { - get { return end; } - set { end = value; } - } - - internal StateMachineScope (int start, int end) - { - this.start = new InstructionOffset (start); - this.end = new InstructionOffset (end); - } - - public StateMachineScope (Instruction start, Instruction end) - { - this.start = new InstructionOffset (start); - this.end = end != null ? new InstructionOffset (end) : new InstructionOffset (); - } - } - - public sealed class StateMachineScopeDebugInformation : CustomDebugInformation { - - internal Collection scopes; - - public Collection Scopes { - get { return scopes ?? (scopes = new Collection ()); } - } - - public override CustomDebugInformationKind Kind { - get { return CustomDebugInformationKind.StateMachineScope; } - } - - public static Guid KindIdentifier = new Guid ("{6DA9A61E-F8C7-4874-BE62-68BC5630DF71}"); - - public StateMachineScopeDebugInformation () - : base (KindIdentifier) - { - } - } - - public sealed class EmbeddedSourceDebugInformation : CustomDebugInformation { - - internal byte [] content; - internal bool compress; - - public byte [] Content { - get { return content; } - set { content = value; } - } - - public bool Compress { - get { return compress; } - set { compress = value; } - } - - public override CustomDebugInformationKind Kind { - get { return CustomDebugInformationKind.EmbeddedSource; } - } - - public static Guid KindIdentifier = new Guid ("{0E8A571B-6926-466E-B4AD-8AB04611F5FE}"); - - public EmbeddedSourceDebugInformation (byte [] content, bool compress) - : base (KindIdentifier) - { - this.content = content; - this.compress = compress; - } - } - - public sealed class SourceLinkDebugInformation : CustomDebugInformation { - - internal string content; - - public string Content { - get { return content; } - set { content = value; } - } - - public override CustomDebugInformationKind Kind { - get { return CustomDebugInformationKind.SourceLink; } - } - - public static Guid KindIdentifier = new Guid ("{CC110556-A091-4D38-9FEC-25AB9A351A6A}"); - - public SourceLinkDebugInformation (string content) - : base (KindIdentifier) - { - this.content = content; - } - } - - public sealed class MethodDebugInformation : DebugInformation { - - internal MethodDefinition method; - internal Collection sequence_points; - internal ScopeDebugInformation scope; - internal MethodDefinition kickoff_method; - internal int code_size; - internal MetadataToken local_var_token; - - public MethodDefinition Method { - get { return method; } - } - - public bool HasSequencePoints { - get { return !sequence_points.IsNullOrEmpty (); } - } - - public Collection SequencePoints { - get { return sequence_points ?? (sequence_points = new Collection ()); } - } - - public ScopeDebugInformation Scope { - get { return scope; } - set { scope = value; } - } - - public MethodDefinition StateMachineKickOffMethod { - get { return kickoff_method; } - set { kickoff_method = value; } - } - - internal MethodDebugInformation (MethodDefinition method) - { - if (method == null) - throw new ArgumentNullException ("method"); - - this.method = method; - this.token = new MetadataToken (TokenType.MethodDebugInformation, method.MetadataToken.RID); - } - - public SequencePoint GetSequencePoint (Instruction instruction) - { - if (!HasSequencePoints) - return null; - - for (int i = 0; i < sequence_points.Count; i++) - if (sequence_points [i].Offset == instruction.Offset) - return sequence_points [i]; - - return null; - } - - public IDictionary GetSequencePointMapping () - { - var instruction_mapping = new Dictionary (); - if (!HasSequencePoints || !method.HasBody) - return instruction_mapping; - - var offset_mapping = new Dictionary (sequence_points.Count); - - for (int i = 0; i < sequence_points.Count; i++) { - if (!offset_mapping.ContainsKey (sequence_points [i].Offset)) - offset_mapping.Add (sequence_points [i].Offset, sequence_points [i]); - } - - var instructions = method.Body.Instructions; - - for (int i = 0; i < instructions.Count; i++) { - SequencePoint sequence_point; - if (offset_mapping.TryGetValue (instructions [i].Offset, out sequence_point)) - instruction_mapping.Add (instructions [i], sequence_point); - } - - return instruction_mapping; - } - - public IEnumerable GetScopes () - { - if (scope == null) - return Empty.Array; - - return GetScopes (new[] { scope }); - } - - static IEnumerable GetScopes (IList scopes) - { - for (int i = 0; i < scopes.Count; i++) { - var scope = scopes [i]; - - yield return scope; - - if (!scope.HasScopes) - continue; - - foreach (var sub_scope in GetScopes (scope.Scopes)) - yield return sub_scope; - } - } - - public bool TryGetName (VariableDefinition variable, out string name) - { - name = null; - - var has_name = false; - var unique_name = ""; - - foreach (var scope in GetScopes ()) { - string slot_name; - if (!scope.TryGetName (variable, out slot_name)) - continue; - - if (!has_name) { - has_name = true; - unique_name = slot_name; - continue; - } - - if (unique_name != slot_name) - return false; - } - - name = unique_name; - return has_name; - } - } - - public interface ISymbolReader : IDisposable { -#if !READ_ONLY - ISymbolWriterProvider GetWriterProvider (); -#endif - bool ProcessDebugHeader (ImageDebugHeader header); - MethodDebugInformation Read (MethodDefinition method); - } - - public interface ISymbolReaderProvider { - ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName); - ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream); - } - - public class DefaultSymbolReaderProvider : ISymbolReaderProvider { - - readonly bool throw_if_no_symbol; - - public DefaultSymbolReaderProvider () - : this (throwIfNoSymbol: true) - { - } - - public DefaultSymbolReaderProvider (bool throwIfNoSymbol) - { - throw_if_no_symbol = throwIfNoSymbol; - } - - public ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName) - { - if (module.Image.HasDebugTables ()) - return null; - - if (module.HasDebugHeader) { - var header = module.GetDebugHeader (); - var entry = header.GetEmbeddedPortablePdbEntry (); - if (entry != null) - return new EmbeddedPortablePdbReaderProvider ().GetSymbolReader (module, fileName); - } - - var pdb_file_name = Mixin.GetPdbFileName (fileName); - - if (File.Exists (pdb_file_name)) { - if (Mixin.IsPortablePdb (Mixin.GetPdbFileName (fileName))) - return new PortablePdbReaderProvider ().GetSymbolReader (module, fileName); - - try { - return SymbolProvider.GetReaderProvider (SymbolKind.NativePdb).GetSymbolReader (module, fileName); - } catch (Exception) { - // We might not include support for native pdbs. - } - } - - var mdb_file_name = Mixin.GetMdbFileName (fileName); - if (File.Exists (mdb_file_name)) { - try { - return SymbolProvider.GetReaderProvider (SymbolKind.Mdb).GetSymbolReader (module, fileName); - } catch (Exception) { - // We might not include support for mdbs. - } - } - - if (throw_if_no_symbol) - throw new FileNotFoundException (string.Format ("No symbol found for file: {0}", fileName)); - - return null; - } - - public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream) - { - throw new NotSupportedException (); - } - } - - enum SymbolKind { - NativePdb, - PortablePdb, - EmbeddedPortablePdb, - Mdb, - } - - static class SymbolProvider { - - static SR.AssemblyName GetSymbolAssemblyName (SymbolKind kind) - { - if (kind == SymbolKind.PortablePdb) - throw new ArgumentException (); - - var suffix = GetSymbolNamespace (kind); - - var cecil_name = typeof (SymbolProvider).Assembly ().GetName (); - - var name = new SR.AssemblyName { - Name = cecil_name.Name + "." + suffix, - Version = cecil_name.Version, - }; - - name.SetPublicKeyToken (cecil_name.GetPublicKeyToken ()); - - return name; - } - - static Type GetSymbolType (SymbolKind kind, string fullname) - { - var type = Type.GetType (fullname); - if (type != null) - return type; - - var assembly_name = GetSymbolAssemblyName (kind); - - 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) { - } catch (FileLoadException) { - } - - return null; - } - - public static ISymbolReaderProvider GetReaderProvider (SymbolKind kind) - { - if (kind == SymbolKind.PortablePdb) - return new PortablePdbReaderProvider (); - if (kind == SymbolKind.EmbeddedPortablePdb) - return new EmbeddedPortablePdbReaderProvider (); - - var provider_name = GetSymbolTypeName (kind, "ReaderProvider"); - var type = GetSymbolType (kind, provider_name); - if (type == null) - throw new TypeLoadException ("Could not find symbol provider type " + provider_name); - - return (ISymbolReaderProvider) Activator.CreateInstance (type); - } - - static string GetSymbolTypeName (SymbolKind kind, string name) - { - return "Mono.Cecil" + "." + GetSymbolNamespace (kind) + "." + kind + name; - } - - static string GetSymbolNamespace (SymbolKind kind) - { - if (kind == SymbolKind.PortablePdb || kind == SymbolKind.EmbeddedPortablePdb) - return "Cil"; - if (kind == SymbolKind.NativePdb) - return "Pdb"; - if (kind == SymbolKind.Mdb) - return "Mdb"; - - throw new ArgumentException (); - } - } - -#if !READ_ONLY - - public interface ISymbolWriter : IDisposable { - - ISymbolReaderProvider GetReaderProvider (); - ImageDebugHeader GetDebugHeader (); - void Write (MethodDebugInformation info); - } - - public interface ISymbolWriterProvider { - - ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName); - ISymbolWriter GetSymbolWriter (ModuleDefinition module, Stream symbolStream); - } - - public class DefaultSymbolWriterProvider : ISymbolWriterProvider { - - public ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName) - { - var reader = module.SymbolReader; - if (reader == null) - throw new InvalidOperationException (); - - if (module.Image != null && module.Image.HasDebugTables ()) - return null; - - return reader.GetWriterProvider ().GetSymbolWriter (module, fileName); - } - - public ISymbolWriter GetSymbolWriter (ModuleDefinition module, Stream symbolStream) - { - throw new NotSupportedException (); - } - } - -#endif -} - -namespace Mono.Cecil { - - static partial class Mixin { - - public static ImageDebugHeaderEntry GetCodeViewEntry (this ImageDebugHeader header) - { - return GetEntry (header, ImageDebugType.CodeView); - } - - public static ImageDebugHeaderEntry GetDeterministicEntry (this ImageDebugHeader header) - { - return GetEntry (header, ImageDebugType.Deterministic); - } - - public static ImageDebugHeader AddDeterministicEntry (this ImageDebugHeader header) - { - var entry = new ImageDebugHeaderEntry (new ImageDebugDirectory { Type = ImageDebugType.Deterministic }, Empty.Array); - if (header == null) - return new ImageDebugHeader (entry); - - var entries = new ImageDebugHeaderEntry [header.Entries.Length + 1]; - Array.Copy (header.Entries, entries, header.Entries.Length); - entries [entries.Length - 1] = entry; - return new ImageDebugHeader (entries); - } - - public static ImageDebugHeaderEntry GetEmbeddedPortablePdbEntry (this ImageDebugHeader header) - { - return GetEntry (header, ImageDebugType.EmbeddedPortablePdb); - } - - private static ImageDebugHeaderEntry GetEntry (this ImageDebugHeader header, ImageDebugType type) - { - if (!header.HasEntries) - return null; - - for (var i = 0; i < header.Entries.Length; i++) { - var entry = header.Entries [i]; - if (entry.Directory.Type == type) - return entry; - } - - return null; - } - - public static string GetPdbFileName (string assemblyFileName) - { - return Path.ChangeExtension (assemblyFileName, ".pdb"); - } - - public static string GetMdbFileName (string assemblyFileName) - { - return assemblyFileName + ".mdb"; - } - - public static bool IsPortablePdb (string fileName) - { - using (var file = new FileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - return IsPortablePdb (file); - } - - public static bool IsPortablePdb (Stream stream) - { - const uint ppdb_signature = 0x424a5342; - - if (stream.Length < 4) return false; - var position = stream.Position; - try { - var reader = new BinaryReader (stream); - return reader.ReadUInt32 () == ppdb_signature; - } finally { - stream.Position = position; - } - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Cil/VariableDefinition.cs b/external/linker/cecil/Mono.Cecil.Cil/VariableDefinition.cs deleted file mode 100644 index bd1328464a..0000000000 --- a/external/linker/cecil/Mono.Cecil.Cil/VariableDefinition.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil.Cil { - - public sealed class VariableDefinition : VariableReference { - - public bool IsPinned { - get { return variable_type.IsPinned; } - } - - public VariableDefinition (TypeReference variableType) - : base (variableType) - { - } - - public override VariableDefinition Resolve () - { - return this; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Cil/VariableReference.cs b/external/linker/cecil/Mono.Cecil.Cil/VariableReference.cs deleted file mode 100644 index fb12e8c14d..0000000000 --- a/external/linker/cecil/Mono.Cecil.Cil/VariableReference.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil.Cil { - - public abstract class VariableReference { - - internal int index = -1; - protected TypeReference variable_type; - - public TypeReference VariableType { - get { return variable_type; } - set { variable_type = value; } - } - - public int Index { - get { return index; } - } - - internal VariableReference (TypeReference variable_type) - { - this.variable_type = variable_type; - } - - public abstract VariableDefinition Resolve (); - - public override string ToString () - { - if (index >= 0) - return "V_" + index; - - return string.Empty; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Metadata/BlobHeap.cs b/external/linker/cecil/Mono.Cecil.Metadata/BlobHeap.cs deleted file mode 100644 index 574a130c98..0000000000 --- a/external/linker/cecil/Mono.Cecil.Metadata/BlobHeap.cs +++ /dev/null @@ -1,54 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil.Metadata { - - sealed class BlobHeap : Heap { - - public BlobHeap (byte [] data) - : base (data) - { - } - - public byte [] Read (uint index) - { - if (index == 0 || index > this.data.Length - 1) - return Empty.Array; - - int position = (int) index; - int length = (int) data.ReadCompressedUInt32 (ref position); - - if (length > data.Length - position) - return Empty.Array; - - var buffer = new byte [length]; - - Buffer.BlockCopy (data, position, buffer, 0, length); - - return buffer; - } - - public void GetView (uint signature, out byte [] buffer, out int index, out int length) - { - if (signature == 0 || signature > data.Length - 1) { - buffer = null; - index = length = 0; - return; - } - - buffer = data; - - index = (int) signature; - length = (int) buffer.ReadCompressedUInt32 (ref index); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Metadata/Buffers.cs b/external/linker/cecil/Mono.Cecil.Metadata/Buffers.cs deleted file mode 100644 index d87cb2a225..0000000000 --- a/external/linker/cecil/Mono.Cecil.Metadata/Buffers.cs +++ /dev/null @@ -1,505 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -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; - - readonly internal TableInformation [] table_infos = new TableInformation [Mixin.TableCount]; - readonly internal MetadataTable [] tables = new MetadataTable [Mixin.TableCount]; - - bool large_string; - bool large_blob; - bool large_guid; - - readonly int [] coded_index_sizes = new int [Mixin.CodedIndexCount]; - readonly Func counter; - - internal uint [] string_offsets; - - 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) - { - return (int) table_infos [(int) table].Length; - } - - public TTable GetTable (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_offsets [@string], large_string); - } - - public void WriteBlob (uint blob) - { - WriteBySize (blob, large_blob); - } - - public void WriteGuid (uint guid) - { - WriteBySize (guid, large_guid); - } - - public void WriteRID (uint rid, Table table) - { - WriteBySize (rid, table_infos [(int) 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 (0xc416003301fa00); // 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; - } - - public void ComputeTableInformations () - { - if (metadata.metadata_builder != null) - ComputeTableInformations (metadata.metadata_builder.table_heap); - - ComputeTableInformations (metadata.table_heap); - } - - void ComputeTableInformations (TableHeapBuffer table_heap) - { - var tables = table_heap.tables; - for (int i = 0; i < tables.Length; i++) { - var table = tables [i]; - if (table != null && table.Length > 0) - table_infos [i].Length = (uint) table.Length; - } - } - - byte GetHeapSizes () - { - byte heap_sizes = 0; - - if (metadata.string_heap.IsLarge) { - large_string = true; - heap_sizes |= 0x01; - } - - if (metadata.guid_heap.IsLarge) { - large_guid = true; - heap_sizes |= 0x02; - } - - 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 (Table.FieldRVA); - if (table.length == 0) - return; - - var field_idx_size = GetTable (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 > 65535; } - } - - public abstract bool IsEmpty { get; } - - protected HeapBuffer (int length) - : base (length) - { - } - } - - sealed class GuidHeapBuffer : HeapBuffer { - - readonly Dictionary guids = new Dictionary (); - - public override bool IsEmpty { - get { return length == 0; } - } - - public GuidHeapBuffer () - : base (16) - { - } - - public uint GetGuidIndex (Guid guid) - { - uint index; - if (guids.TryGetValue (guid, out index)) - return index; - - index = (uint) guids.Count + 1; - WriteGuid (guid); - guids.Add (guid, index); - return index; - } - - void WriteGuid (Guid guid) - { - WriteBytes (guid.ToByteArray ()); - } - } - - class StringHeapBuffer : HeapBuffer { - - protected Dictionary strings = new Dictionary (StringComparer.Ordinal); - - public sealed override bool IsEmpty { - get { return length <= 1; } - } - - public StringHeapBuffer () - : base (1) - { - WriteByte (0); - } - - public virtual uint GetStringIndex (string @string) - { - uint index; - if (strings.TryGetValue (@string, out index)) - return index; - - index = (uint) strings.Count + 1; - strings.Add (@string, index); - return index; - } - - public uint [] WriteStrings () - { - var sorted = SortStrings (strings); - strings = null; - - // Add 1 for empty string whose index and offset are both 0 - var string_offsets = new uint [sorted.Count + 1]; - string_offsets [0] = 0; - - // Find strings that can be folded - var previous = string.Empty; - foreach (var entry in sorted) { - var @string = entry.Key; - var index = entry.Value; - var position = base.position; - - if (previous.EndsWith (@string, StringComparison.Ordinal) && !IsLowSurrogateChar (entry.Key [0])) { - // Map over the tail of prev string. Watch for null-terminator of prev string. - string_offsets [index] = (uint) (position - (Encoding.UTF8.GetByteCount (entry.Key) + 1)); - } else { - string_offsets [index] = (uint) position; - WriteString (@string); - } - - previous = entry.Key; - } - - return string_offsets; - } - - static List> SortStrings (Dictionary strings) - { - var sorted = new List> (strings); - sorted.Sort (new SuffixSort ()); - return sorted; - } - - static bool IsLowSurrogateChar (int c) - { - return unchecked((uint)(c - 0xDC00)) <= 0xDFFF - 0xDC00; - } - - protected virtual void WriteString (string @string) - { - WriteBytes (Encoding.UTF8.GetBytes (@string)); - WriteByte (0); - } - - // Sorts strings such that a string is followed immediately by all strings - // that are a suffix of it. - private class SuffixSort : IComparer> { - - public int Compare(KeyValuePair xPair, KeyValuePair yPair) - { - var x = xPair.Key; - var y = yPair.Key; - - for (int i = x.Length - 1, j = y.Length - 1; i >= 0 & j >= 0; i--, j--) { - if (x [i] < y [j]) { - return -1; - } - - if (x [i] > y [j]) { - return +1; - } - } - - return y.Length.CompareTo (x.Length); - } - } - } - - sealed class BlobHeapBuffer : HeapBuffer { - - readonly Dictionary blobs = new Dictionary (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 { - - public override 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 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); - } - } - - sealed class PdbHeapBuffer : HeapBuffer { - - public override bool IsEmpty { - get { return false; } - } - - public PdbHeapBuffer () - : base (0) - { - } - } -} - -#endif diff --git a/external/linker/cecil/Mono.Cecil.Metadata/CodedIndex.cs b/external/linker/cecil/Mono.Cecil.Metadata/CodedIndex.cs deleted file mode 100644 index 2026a8a7db..0000000000 --- a/external/linker/cecil/Mono.Cecil.Metadata/CodedIndex.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil.Metadata { - - enum CodedIndex { - TypeDefOrRef, - HasConstant, - HasCustomAttribute, - HasFieldMarshal, - HasDeclSecurity, - MemberRefParent, - HasSemantics, - MethodDefOrRef, - MemberForwarded, - Implementation, - CustomAttributeType, - ResolutionScope, - TypeOrMethodDef, - HasCustomDebugInformation, - } -} diff --git a/external/linker/cecil/Mono.Cecil.Metadata/ElementType.cs b/external/linker/cecil/Mono.Cecil.Metadata/ElementType.cs deleted file mode 100644 index 2190160a6d..0000000000 --- a/external/linker/cecil/Mono.Cecil.Metadata/ElementType.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil.Metadata { - - 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 token - ByRef = 0x10, // Followed by token - ValueType = 0x11, // Followed by token - Class = 0x12, // Followed by token - Var = 0x13, // Followed by generic parameter number - Array = 0x14, // - GenericInst = 0x15, // ... */ - 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 - } -} diff --git a/external/linker/cecil/Mono.Cecil.Metadata/GuidHeap.cs b/external/linker/cecil/Mono.Cecil.Metadata/GuidHeap.cs deleted file mode 100644 index 76ec9d1d11..0000000000 --- a/external/linker/cecil/Mono.Cecil.Metadata/GuidHeap.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil.Metadata { - - sealed class GuidHeap : Heap { - - public GuidHeap (byte [] data) - : base (data) - { - } - - public Guid Read (uint index) - { - const int guid_size = 16; - - if (index == 0 || ((index - 1) + guid_size) > data.Length) - return new Guid (); - - var buffer = new byte [guid_size]; - - Buffer.BlockCopy (this.data, (int) ((index - 1) * guid_size), buffer, 0, guid_size); - - return new Guid (buffer); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Metadata/Heap.cs b/external/linker/cecil/Mono.Cecil.Metadata/Heap.cs deleted file mode 100644 index 6874d7963e..0000000000 --- a/external/linker/cecil/Mono.Cecil.Metadata/Heap.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil.Metadata { - - abstract class Heap { - - public int IndexSize; - - readonly internal byte [] data; - - protected Heap (byte [] data) - { - this.data = data; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Metadata/MetadataToken.cs b/external/linker/cecil/Mono.Cecil.Metadata/MetadataToken.cs deleted file mode 100644 index a8b712e7ff..0000000000 --- a/external/linker/cecil/Mono.Cecil.Metadata/MetadataToken.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - public struct MetadataToken : IEquatable { - - readonly uint token; - - public uint RID { - get { return token & 0x00ffffff; } - } - - public TokenType TokenType { - get { return (TokenType) (token & 0xff000000); } - } - - public static readonly MetadataToken Zero = new MetadataToken ((uint) 0); - - public MetadataToken (uint token) - { - this.token = token; - } - - public MetadataToken (TokenType type) - : this (type, 0) - { - } - - public MetadataToken (TokenType type, uint rid) - { - token = (uint) type | rid; - } - - public MetadataToken (TokenType type, int rid) - { - token = (uint) type | (uint) rid; - } - - public int ToInt32 () - { - return (int) token; - } - - public uint ToUInt32 () - { - return token; - } - - public override int GetHashCode () - { - return (int) token; - } - - public bool Equals (MetadataToken other) - { - return other.token == token; - } - - public override bool Equals (object obj) - { - if (obj is MetadataToken) { - var other = (MetadataToken) obj; - return other.token == token; - } - - return false; - } - - public static bool operator == (MetadataToken one, MetadataToken other) - { - return one.token == other.token; - } - - public static bool operator != (MetadataToken one, MetadataToken other) - { - return one.token != other.token; - } - - public override string ToString () - { - return string.Format ("[{0}:0x{1}]", TokenType, RID.ToString ("x4")); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Metadata/PdbHeap.cs b/external/linker/cecil/Mono.Cecil.Metadata/PdbHeap.cs deleted file mode 100644 index 39e275ad90..0000000000 --- a/external/linker/cecil/Mono.Cecil.Metadata/PdbHeap.cs +++ /dev/null @@ -1,34 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using Mono.Cecil.PE; - -using RID = System.UInt32; - -namespace Mono.Cecil.Metadata { - - sealed class PdbHeap : Heap { - - public byte [] Id; - public RID EntryPoint; - public long TypeSystemTables; - public uint [] TypeSystemTableRows; - - public PdbHeap (byte [] data) - : base (data) - { - } - - public bool HasTable (Table table) - { - return (TypeSystemTables & (1L << (int) table)) != 0; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Metadata/Row.cs b/external/linker/cecil/Mono.Cecil.Metadata/Row.cs deleted file mode 100644 index 0c05ebade6..0000000000 --- a/external/linker/cecil/Mono.Cecil.Metadata/Row.cs +++ /dev/null @@ -1,152 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System.Collections.Generic; - -namespace Mono.Cecil.Metadata { - - struct Row { - internal T1 Col1; - internal T2 Col2; - - public Row (T1 col1, T2 col2) - { - Col1 = col1; - Col2 = col2; - } - } - - struct Row { - 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 { - 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 { - 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 { - 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 { - 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>, IEqualityComparer>, IEqualityComparer> { - - public bool Equals (Row x, Row y) - { - return x.Col1 == y.Col1 - && x.Col2 == y.Col2; - } - - public int GetHashCode (Row obj) - { - string x = obj.Col1, y = obj.Col2; - return (x != null ? x.GetHashCode () : 0) ^ (y != null ? y.GetHashCode () : 0); - } - - public bool Equals (Row x, Row y) - { - return x.Col1 == y.Col1 - && x.Col2 == y.Col2; - } - - public int GetHashCode (Row obj) - { - return (int) (obj.Col1 ^ obj.Col2); - } - - public bool Equals (Row x, Row y) - { - return x.Col1 == y.Col1 - && x.Col2 == y.Col2 - && x.Col3 == y.Col3; - } - - public int GetHashCode (Row obj) - { - return (int) (obj.Col1 ^ obj.Col2 ^ obj.Col3); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Metadata/StringHeap.cs b/external/linker/cecil/Mono.Cecil.Metadata/StringHeap.cs deleted file mode 100644 index 4bde70e233..0000000000 --- a/external/linker/cecil/Mono.Cecil.Metadata/StringHeap.cs +++ /dev/null @@ -1,60 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Mono.Cecil.Metadata { - - class StringHeap : Heap { - - readonly Dictionary strings = new Dictionary (); - - public StringHeap (byte [] data) - : base (data) - { - } - - public string Read (uint index) - { - if (index == 0) - return string.Empty; - - string @string; - if (strings.TryGetValue (index, out @string)) - return @string; - - if (index > data.Length - 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; - int start = (int) index; - - for (int i = start; ; i++) { - if (data [i] == 0) - break; - - length++; - } - - return Encoding.UTF8.GetString (data, start, length); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Metadata/TableHeap.cs b/external/linker/cecil/Mono.Cecil.Metadata/TableHeap.cs deleted file mode 100644 index dee655a343..0000000000 --- a/external/linker/cecil/Mono.Cecil.Metadata/TableHeap.cs +++ /dev/null @@ -1,104 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -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, - EncLog = 0x1e, - EncMap = 0x1f, - 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, - - Document = 0x30, - MethodDebugInformation = 0x31, - LocalScope = 0x32, - LocalVariable = 0x33, - LocalConstant = 0x34, - ImportScope = 0x35, - StateMachineMethod = 0x36, - CustomDebugInformation = 0x37, - } - - struct TableInformation { - public uint Offset; - public uint Length; - public uint RowSize; - - public bool IsLarge { - get { return Length > ushort.MaxValue; } - } - } - - sealed class TableHeap : Heap { - - public long Valid; - public long Sorted; - - public readonly TableInformation [] Tables = new TableInformation [Mixin.TableCount]; - - public TableInformation this [Table table] { - get { return Tables [(int) table]; } - } - - public TableHeap (byte [] data) - : base (data) - { - } - - public bool HasTable (Table table) - { - return (Valid & (1L << (int) table)) != 0; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.Metadata/TokenType.cs b/external/linker/cecil/Mono.Cecil.Metadata/TokenType.cs deleted file mode 100644 index 547f6c6472..0000000000 --- a/external/linker/cecil/Mono.Cecil.Metadata/TokenType.cs +++ /dev/null @@ -1,49 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -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, - GenericParamConstraint = 0x2c000000, - - Document = 0x30000000, - MethodDebugInformation = 0x31000000, - LocalScope = 0x32000000, - LocalVariable = 0x33000000, - LocalConstant = 0x34000000, - ImportScope = 0x35000000, - StateMachineMethod = 0x36000000, - CustomDebugInformation = 0x37000000, - - String = 0x70000000, - } -} diff --git a/external/linker/cecil/Mono.Cecil.Metadata/UserStringHeap.cs b/external/linker/cecil/Mono.Cecil.Metadata/UserStringHeap.cs deleted file mode 100644 index 7b1b42ffa0..0000000000 --- a/external/linker/cecil/Mono.Cecil.Metadata/UserStringHeap.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil.Metadata { - - sealed class UserStringHeap : StringHeap { - - public UserStringHeap (byte [] data) - : base (data) - { - } - - protected override string ReadStringAt (uint index) - { - int start = (int) index; - - uint length = (uint) (data.ReadCompressedUInt32 (ref start) & ~1); - if (length < 1) - return string.Empty; - - 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/external/linker/cecil/Mono.Cecil.Metadata/Utilities.cs b/external/linker/cecil/Mono.Cecil.Metadata/Utilities.cs deleted file mode 100644 index 3a4330da50..0000000000 --- a/external/linker/cecil/Mono.Cecil.Metadata/Utilities.cs +++ /dev/null @@ -1,652 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using Mono.Cecil.Metadata; - -namespace Mono.Cecil { - - static partial class Mixin { - - public const int TableCount = 58; - public const int CodedIndexCount = 14; - - public static uint ReadCompressedUInt32 (this byte [] data, ref int position) - { - 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 = (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 MetadataToken GetMetadataToken (this CodedIndex self, uint data) - { - uint rid; - TokenType token_type; - switch (self) { - case CodedIndex.TypeDefOrRef: - rid = data >> 2; - switch (data & 3) { - 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: - rid = data >> 2; - switch (data & 3) { - 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: - rid = data >> 5; - switch (data & 31) { - 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; - case 20: - token_type = TokenType.GenericParamConstraint; goto ret; - case 21: - token_type = TokenType.MethodSpec; goto ret; - default: - goto exit; - } - case CodedIndex.HasFieldMarshal: - rid = data >> 1; - switch (data & 1) { - case 0: - token_type = TokenType.Field; goto ret; - case 1: - token_type = TokenType.Param; goto ret; - default: - goto exit; - } - case CodedIndex.HasDeclSecurity: - rid = data >> 2; - switch (data & 3) { - 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: - rid = data >> 3; - switch (data & 7) { - 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: - rid = data >> 1; - switch (data & 1) { - case 0: - token_type = TokenType.Event; goto ret; - case 1: - token_type = TokenType.Property; goto ret; - default: - goto exit; - } - case CodedIndex.MethodDefOrRef: - rid = data >> 1; - switch (data & 1) { - case 0: - token_type = TokenType.Method; goto ret; - case 1: - token_type = TokenType.MemberRef; goto ret; - default: - goto exit; - } - case CodedIndex.MemberForwarded: - rid = data >> 1; - switch (data & 1) { - case 0: - token_type = TokenType.Field; goto ret; - case 1: - token_type = TokenType.Method; goto ret; - default: - goto exit; - } - case CodedIndex.Implementation: - rid = data >> 2; - switch (data & 3) { - 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: - rid = data >> 3; - switch (data & 7) { - case 2: - token_type = TokenType.Method; goto ret; - case 3: - token_type = TokenType.MemberRef; goto ret; - default: - goto exit; - } - case CodedIndex.ResolutionScope: - rid = data >> 2; - switch (data & 3) { - 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: - rid = data >> 1; - switch (data & 1) { - case 0: - token_type = TokenType.TypeDef; goto ret; - case 1: - token_type = TokenType.Method; goto ret; - default: goto exit; - } - case CodedIndex.HasCustomDebugInformation: - rid = data >> 5; - switch (data & 31) { - 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; - case 20: - token_type = TokenType.GenericParamConstraint; goto ret; - case 21: - token_type = TokenType.MethodSpec; goto ret; - case 22: - token_type = TokenType.Document; goto ret; - case 23: - token_type = TokenType.LocalScope; goto ret; - case 24: - token_type = TokenType.LocalVariable; goto ret; - case 25: - token_type = TokenType.LocalConstant; goto ret; - case 26: - token_type = TokenType.ImportScope; goto ret; - default: - goto exit; - } - default: - goto exit; - } - ret: - return new MetadataToken (token_type, rid); - exit: - return MetadataToken.Zero; - } - -#if !READ_ONLY - public static uint CompressMetadataToken (this CodedIndex self, MetadataToken token) - { - uint ret = 0; - if (token.RID == 0) - return ret; - switch (self) { - case CodedIndex.TypeDefOrRef: - ret = token.RID << 2; - switch (token.TokenType) { - case TokenType.TypeDef: - return ret | 0; - case TokenType.TypeRef: - return ret | 1; - case TokenType.TypeSpec: - return ret | 2; - default: - goto exit; - } - case CodedIndex.HasConstant: - ret = token.RID << 2; - switch (token.TokenType) { - case TokenType.Field: - return ret | 0; - case TokenType.Param: - return ret | 1; - case TokenType.Property: - return ret | 2; - default: - goto exit; - } - case CodedIndex.HasCustomAttribute: - ret = token.RID << 5; - switch (token.TokenType) { - case TokenType.Method: - return ret | 0; - case TokenType.Field: - return ret | 1; - case TokenType.TypeRef: - return ret | 2; - case TokenType.TypeDef: - return ret | 3; - case TokenType.Param: - return ret | 4; - case TokenType.InterfaceImpl: - return ret | 5; - case TokenType.MemberRef: - return ret | 6; - case TokenType.Module: - return ret | 7; - case TokenType.Permission: - return ret | 8; - case TokenType.Property: - return ret | 9; - case TokenType.Event: - return ret | 10; - case TokenType.Signature: - return ret | 11; - case TokenType.ModuleRef: - return ret | 12; - case TokenType.TypeSpec: - return ret | 13; - case TokenType.Assembly: - return ret | 14; - case TokenType.AssemblyRef: - return ret | 15; - case TokenType.File: - return ret | 16; - case TokenType.ExportedType: - return ret | 17; - case TokenType.ManifestResource: - return ret | 18; - case TokenType.GenericParam: - return ret | 19; - case TokenType.GenericParamConstraint: - return ret | 20; - case TokenType.MethodSpec: - return ret | 21; - default: - goto exit; - } - case CodedIndex.HasFieldMarshal: - ret = token.RID << 1; - switch (token.TokenType) { - case TokenType.Field: - return ret | 0; - case TokenType.Param: - return ret | 1; - default: - goto exit; - } - case CodedIndex.HasDeclSecurity: - ret = token.RID << 2; - switch (token.TokenType) { - case TokenType.TypeDef: - return ret | 0; - case TokenType.Method: - return ret | 1; - case TokenType.Assembly: - return ret | 2; - default: - goto exit; - } - case CodedIndex.MemberRefParent: - ret = token.RID << 3; - switch (token.TokenType) { - case TokenType.TypeDef: - return ret | 0; - case TokenType.TypeRef: - return ret | 1; - case TokenType.ModuleRef: - return ret | 2; - case TokenType.Method: - return ret | 3; - case TokenType.TypeSpec: - return ret | 4; - default: - goto exit; - } - case CodedIndex.HasSemantics: - ret = token.RID << 1; - switch (token.TokenType) { - case TokenType.Event: - return ret | 0; - case TokenType.Property: - return ret | 1; - default: - goto exit; - } - case CodedIndex.MethodDefOrRef: - ret = token.RID << 1; - switch (token.TokenType) { - case TokenType.Method: - return ret | 0; - case TokenType.MemberRef: - return ret | 1; - default: - goto exit; - } - case CodedIndex.MemberForwarded: - ret = token.RID << 1; - switch (token.TokenType) { - case TokenType.Field: - return ret | 0; - case TokenType.Method: - return ret | 1; - default: - goto exit; - } - case CodedIndex.Implementation: - ret = token.RID << 2; - switch (token.TokenType) { - case TokenType.File: - return ret | 0; - case TokenType.AssemblyRef: - return ret | 1; - case TokenType.ExportedType: - return ret | 2; - default: - goto exit; - } - case CodedIndex.CustomAttributeType: - ret = token.RID << 3; - switch (token.TokenType) { - case TokenType.Method: - return ret | 2; - case TokenType.MemberRef: - return ret | 3; - default: - goto exit; - } - case CodedIndex.ResolutionScope: - ret = token.RID << 2; - switch (token.TokenType) { - case TokenType.Module: - return ret | 0; - case TokenType.ModuleRef: - return ret | 1; - case TokenType.AssemblyRef: - return ret | 2; - case TokenType.TypeRef: - return ret | 3; - default: - goto exit; - } - case CodedIndex.TypeOrMethodDef: - ret = token.RID << 1; - switch (token.TokenType) { - case TokenType.TypeDef: - return ret | 0; - case TokenType.Method: - return ret | 1; - default: - goto exit; - } - case CodedIndex.HasCustomDebugInformation: - ret = token.RID << 5; - switch (token.TokenType) { - case TokenType.Method: - return ret | 0; - case TokenType.Field: - return ret | 1; - case TokenType.TypeRef: - return ret | 2; - case TokenType.TypeDef: - return ret | 3; - case TokenType.Param: - return ret | 4; - case TokenType.InterfaceImpl: - return ret | 5; - case TokenType.MemberRef: - return ret | 6; - case TokenType.Module: - return ret | 7; - case TokenType.Permission: - return ret | 8; - case TokenType.Property: - return ret | 9; - case TokenType.Event: - return ret | 10; - case TokenType.Signature: - return ret | 11; - case TokenType.ModuleRef: - return ret | 12; - case TokenType.TypeSpec: - return ret | 13; - case TokenType.Assembly: - return ret | 14; - case TokenType.AssemblyRef: - return ret | 15; - case TokenType.File: - return ret | 16; - case TokenType.ExportedType: - return ret | 17; - case TokenType.ManifestResource: - return ret | 18; - case TokenType.GenericParam: - return ret | 19; - case TokenType.GenericParamConstraint: - return ret | 20; - case TokenType.MethodSpec: - return ret | 21; - case TokenType.Document: - return ret | 22; - case TokenType.LocalScope: - return ret | 23; - case TokenType.LocalVariable: - return ret | 24; - case TokenType.LocalConstant: - return ret | 25; - case TokenType.ImportScope: - return ret | 26; - default: - goto exit; - } - default: - goto exit; - } - exit: - throw new ArgumentException (); - } -#endif - - public static int GetSize (this CodedIndex self, Func counter) - { - int bits; - Table [] tables; - - switch (self) { - case CodedIndex.TypeDefOrRef: - bits = 2; - tables = new [] { Table.TypeDef, Table.TypeRef, Table.TypeSpec }; - break; - case CodedIndex.HasConstant: - bits = 2; - tables = new [] { Table.Field, Table.Param, Table.Property }; - break; - case CodedIndex.HasCustomAttribute: - bits = 5; - 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, Table.GenericParamConstraint, Table.MethodSpec, - }; - break; - case CodedIndex.HasFieldMarshal: - bits = 1; - tables = new [] { Table.Field, Table.Param }; - break; - case CodedIndex.HasDeclSecurity: - bits = 2; - tables = new [] { Table.TypeDef, Table.Method, Table.Assembly }; - break; - case CodedIndex.MemberRefParent: - bits = 3; - tables = new [] { Table.TypeDef, Table.TypeRef, Table.ModuleRef, Table.Method, Table.TypeSpec }; - break; - case CodedIndex.HasSemantics: - bits = 1; - tables = new [] { Table.Event, Table.Property }; - break; - case CodedIndex.MethodDefOrRef: - bits = 1; - tables = new [] { Table.Method, Table.MemberRef }; - break; - case CodedIndex.MemberForwarded: - bits = 1; - tables = new [] { Table.Field, Table.Method }; - break; - case CodedIndex.Implementation: - bits = 2; - tables = new [] { Table.File, Table.AssemblyRef, Table.ExportedType }; - break; - case CodedIndex.CustomAttributeType: - bits = 3; - tables = new [] { Table.Method, Table.MemberRef }; - break; - case CodedIndex.ResolutionScope: - bits = 2; - tables = new [] { Table.Module, Table.ModuleRef, Table.AssemblyRef, Table.TypeRef }; - break; - case CodedIndex.TypeOrMethodDef: - bits = 1; - tables = new [] { Table.TypeDef, Table.Method }; - break; - case CodedIndex.HasCustomDebugInformation: - bits = 5; - 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, Table.GenericParamConstraint, Table.MethodSpec, - Table.Document, Table.LocalScope, Table.LocalVariable, Table.LocalConstant, Table.ImportScope, - }; - break; - default: - throw new ArgumentException (); - } - - int max = 0; - - for (int i = 0; i < tables.Length; i++) { - max = System.Math.Max (counter (tables [i]), max); - } - - return max < (1 << (16 - bits)) ? 2 : 4; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.PE/BinaryStreamReader.cs b/external/linker/cecil/Mono.Cecil.PE/BinaryStreamReader.cs deleted file mode 100644 index 812adbc58f..0000000000 --- a/external/linker/cecil/Mono.Cecil.PE/BinaryStreamReader.cs +++ /dev/null @@ -1,54 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.IO; - -namespace Mono.Cecil.PE { - - class BinaryStreamReader : BinaryReader { - - public int Position { - get { return (int) BaseStream.Position; } - set { BaseStream.Position = value; } - } - - public int Length { - get { return (int) BaseStream.Length; } - } - - public BinaryStreamReader (Stream stream) - : base (stream) - { - } - - public void Advance (int bytes) - { - BaseStream.Seek (bytes, SeekOrigin.Current); - } - - public void MoveTo (uint position) - { - BaseStream.Seek (position, SeekOrigin.Begin); - } - - public void Align (int align) - { - align--; - var position = Position; - Advance (((position + align) & ~align) - position); - } - - public DataDirectory ReadDataDirectory () - { - return new DataDirectory (ReadUInt32 (), ReadUInt32 ()); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.PE/BinaryStreamWriter.cs b/external/linker/cecil/Mono.Cecil.PE/BinaryStreamWriter.cs deleted file mode 100644 index b741f684a6..0000000000 --- a/external/linker/cecil/Mono.Cecil.PE/BinaryStreamWriter.cs +++ /dev/null @@ -1,93 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.IO; - -#if !READ_ONLY - -namespace Mono.Cecil.PE { - - class BinaryStreamWriter : BinaryWriter { - - public int Position { - get { return (int) BaseStream.Position; } - set { BaseStream.Position = value; } - } - - public BinaryStreamWriter (Stream stream) - : base (stream) - { - } - - public void WriteByte (byte value) - { - Write (value); - } - - public void WriteUInt16 (ushort value) - { - Write (value); - } - - public void WriteInt16 (short value) - { - Write (value); - } - - public void WriteUInt32 (uint value) - { - Write (value); - } - - public void WriteInt32 (int value) - { - Write (value); - } - - public void WriteUInt64 (ulong value) - { - Write (value); - } - - public void WriteBytes (byte [] bytes) - { - Write (bytes); - } - - public void WriteDataDirectory (DataDirectory directory) - { - Write (directory.VirtualAddress); - Write (directory.Size); - } - - public void WriteBuffer (ByteBuffer buffer) - { - Write (buffer.buffer, 0, buffer.length); - } - - protected void Advance (int bytes) - { - BaseStream.Seek (bytes, SeekOrigin.Current); - } - - public void Align (int align) - { - align--; - var position = Position; - var bytes = ((position + align) & ~align) - position; - - for (int i = 0; i < bytes; i++) - WriteByte (0); - } - } -} - -#endif diff --git a/external/linker/cecil/Mono.Cecil.PE/ByteBuffer.cs b/external/linker/cecil/Mono.Cecil.PE/ByteBuffer.cs deleted file mode 100644 index 8aee04bafd..0000000000 --- a/external/linker/cecil/Mono.Cecil.PE/ByteBuffer.cs +++ /dev/null @@ -1,341 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil.PE { - - class ByteBuffer { - - internal byte [] buffer; - internal int length; - internal int position; - - public ByteBuffer () - { - this.buffer = Empty.Array; - } - - public ByteBuffer (int length) - { - this.buffer = new byte [length]; - } - - public ByteBuffer (byte [] buffer) - { - this.buffer = buffer ?? Empty.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 b = buffer [position]; - var u = (int) ReadCompressedUInt32 (); - var v = u >> 1; - if ((u & 1) == 0) - return v; - - switch (b & 0xc0) - { - case 0: - case 0x40: - return v - 0x40; - case 0x80: - return v - 0x2000; - default: - return v - 0x10000000; - } - } - - 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) - { - if (value >= 0) { - WriteCompressedUInt32 ((uint) (value << 1)); - return; - } - - if (value > -0x40) - value = 0x40 + value; - else if (value >= -0x2000) - value = 0x2000 + value; - else if (value >= -0x20000000) - value = 0x20000000 + value; - - WriteCompressedUInt32 ((uint) ((value << 1) | 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/external/linker/cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs b/external/linker/cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs deleted file mode 100644 index 8b7cb238e0..0000000000 --- a/external/linker/cecil/Mono.Cecil.PE/ByteBufferEqualityComparer.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; - -namespace Mono.Cecil.PE { - - sealed class ByteBufferEqualityComparer : IEqualityComparer { - - public bool Equals (ByteBuffer x, ByteBuffer y) - { - if (x.length != y.length) - return false; - - var x_buffer = x.buffer; - var y_buffer = y.buffer; - - for (int i = 0; i < x.length; i++) - if (x_buffer [i] != y_buffer [i]) - return false; - - return true; - } - - public int GetHashCode (ByteBuffer buffer) - { - // See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function - const int fnv_offset_bias = unchecked((int)2166136261); - const int fnv_prime = 16777619; - - var hash_code = fnv_offset_bias; - var bytes = buffer.buffer; - - for (int i = 0; i < buffer.length; i++) - hash_code = unchecked ((hash_code ^ bytes [i]) * fnv_prime); - - return hash_code; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.PE/DataDirectory.cs b/external/linker/cecil/Mono.Cecil.PE/DataDirectory.cs deleted file mode 100644 index 4922dd2f46..0000000000 --- a/external/linker/cecil/Mono.Cecil.PE/DataDirectory.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using RVA = System.UInt32; - -namespace Mono.Cecil.PE { - - struct DataDirectory { - - public readonly RVA VirtualAddress; - public readonly uint Size; - - public bool IsZero { - get { return VirtualAddress == 0 && Size == 0; } - } - - public DataDirectory (RVA rva, uint size) - { - this.VirtualAddress = rva; - this.Size = size; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.PE/Image.cs b/external/linker/cecil/Mono.Cecil.PE/Image.cs deleted file mode 100644 index 25ea1869ed..0000000000 --- a/external/linker/cecil/Mono.Cecil.PE/Image.cs +++ /dev/null @@ -1,168 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.IO; - -using Mono.Cecil.Cil; -using Mono.Cecil.Metadata; -using Mono.Collections.Generic; - -using RVA = System.UInt32; - -namespace Mono.Cecil.PE { - - sealed class Image : IDisposable { - - public Disposable Stream; - public string FileName; - - public ModuleKind Kind; - public string RuntimeVersion; - public TargetArchitecture Architecture; - public ModuleCharacteristics Characteristics; - public ushort LinkerVersion; - - public ImageDebugHeader DebugHeader; - - public Section [] Sections; - - public Section MetadataSection; - - public uint EntryPointToken; - public uint Timestamp; - public ModuleAttributes Attributes; - - public DataDirectory Win32Resources; - public DataDirectory Debug; - public DataDirectory Resources; - public DataDirectory StrongName; - - public StringHeap StringHeap; - public BlobHeap BlobHeap; - public UserStringHeap UserStringHeap; - public GuidHeap GuidHeap; - public TableHeap TableHeap; - public PdbHeap PdbHeap; - - readonly int [] coded_index_sizes = new int [14]; - - readonly Func 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; - } - - BinaryStreamReader GetReaderAt (RVA rva) - { - var section = GetSectionAtVirtualAddress (rva); - if (section == null) - return null; - - var reader = new BinaryStreamReader (Stream.value); - reader.MoveTo (ResolveVirtualAddressInSection (rva, section)); - return reader; - } - - public TRet GetReaderAt (RVA rva, TItem item, Func read) where TRet : class - { - var position = Stream.value.Position; - try { - var reader = GetReaderAt (rva); - if (reader == null) - return null; - - return read (item, reader); - } finally { - Stream.value.Position = position; - } - } - - public bool HasDebugTables () - { - return HasTable (Table.Document) - || HasTable (Table.MethodDebugInformation) - || HasTable (Table.LocalScope) - || HasTable (Table.LocalVariable) - || HasTable (Table.LocalConstant) - || HasTable (Table.StateMachineMethod) - || HasTable (Table.CustomDebugInformation); - } - - public void Dispose () - { - Stream.Dispose (); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.PE/ImageReader.cs b/external/linker/cecil/Mono.Cecil.PE/ImageReader.cs deleted file mode 100644 index f3f3d2641a..0000000000 --- a/external/linker/cecil/Mono.Cecil.PE/ImageReader.cs +++ /dev/null @@ -1,789 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.IO; - -using Mono.Cecil.Cil; -using Mono.Cecil.Metadata; -using Mono.Collections.Generic; - -using RVA = System.UInt32; - -namespace Mono.Cecil.PE { - - sealed class ImageReader : BinaryStreamReader { - - readonly Image image; - - DataDirectory cli; - DataDirectory metadata; - - uint table_heap_offset; - - public ImageReader (Disposable stream, string file_name) - : base (stream.value) - { - image = new Image (); - image.Stream = stream; - image.FileName = file_name; - } - - void MoveTo (DataDirectory directory) - { - BaseStream.Position = image.ResolveVirtualAddress (directory.VirtualAddress); - } - - 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 - image.Timestamp = ReadUInt32 (); - // PointerToSymbolTable 4 - // NumberOfSymbols 4 - // OptionalHeaderSize 2 - Advance (10); - - // Characteristics 2 - ushort characteristics = ReadUInt16 (); - - ushort subsystem, dll_characteristics, linker_version; - ReadOptionalHeaders (out subsystem, out dll_characteristics, out linker_version); - ReadSections (sections); - ReadCLIHeader (); - ReadMetadata (); - ReadDebugHeader (); - - image.Kind = GetModuleKind (characteristics, subsystem); - image.Characteristics = (ModuleCharacteristics) dll_characteristics; - image.LinkerVersion = linker_version; - } - - TargetArchitecture ReadArchitecture () - { - return (TargetArchitecture) ReadUInt16 (); - } - - 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, out ushort dll_characteristics, out ushort linker) - { - // - PEOptionalHeader - // - StandardFieldsHeader - - // Magic 2 - bool pe64 = ReadUInt16 () == 0x20b; - - // pe32 || pe64 - - linker = ReadUInt16 (); - // 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 (64); - - // SubSystem 2 - subsystem = ReadUInt16 (); - - // DLLFlags 2 - dll_characteristics = ReadUInt16 (); - // StackReserveSize 4 || 8 - // StackCommitSize 4 || 8 - // HeapReserveSize 4 || 8 - // HeapCommitSize 4 || 8 - // LoaderFlags 4 - // NumberOfDataDir 4 - - // - DataDirectoriesHeader - - // ExportTable 8 - // ImportTable 8 - - Advance (pe64 ? 56 : 40); - - // ResourceTable 8 - - image.Win32Resources = ReadDataDirectory (); - - // ExceptionTable 8 - // CertificateTable 8 - // BaseRelocationTable 8 - - Advance (24); - - // 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; - } - - image.Sections = sections; - } - - 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 - image.StrongName = ReadDataDirectory (); - // 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); - - image.RuntimeVersion = ReadZeroTerminatedString (ReadInt32 ()); - - // 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.PdbHeap != null) - ReadPdbHeap (); - - if (image.TableHeap != null) - ReadTableHeap (); - } - - void ReadDebugHeader () - { - if (image.Debug.IsZero) { - image.DebugHeader = new ImageDebugHeader (Empty.Array); - return; - } - - MoveTo (image.Debug); - - var entries = new ImageDebugHeaderEntry [(int) image.Debug.Size / ImageDebugDirectory.Size]; - - for (int i = 0; i < entries.Length; i++) { - var directory = new ImageDebugDirectory { - Characteristics = ReadInt32 (), - TimeDateStamp = ReadInt32 (), - MajorVersion = ReadInt16 (), - MinorVersion = ReadInt16 (), - Type = (ImageDebugType) ReadInt32 (), - SizeOfData = ReadInt32 (), - AddressOfRawData = ReadInt32 (), - PointerToRawData = ReadInt32 (), - }; - - if (directory.AddressOfRawData == 0) { - entries [i] = new ImageDebugHeaderEntry (directory, Empty.Array); - continue; - } - - var position = Position; - try { - MoveTo ((uint) directory.PointerToRawData); - var data = ReadBytes (directory.SizeOfData); - entries [i] = new ImageDebugHeaderEntry (directory, data); - } finally { - Position = position; - } - } - - image.DebugHeader = new ImageDebugHeader (entries); - } - - void ReadMetadataStream (Section section) - { - // Offset 4 - uint offset = metadata.VirtualAddress - section.VirtualAddress + ReadUInt32 (); // relative to the section start - - // Size 4 - uint size = ReadUInt32 (); - - var data = ReadHeapData (offset, size); - - var name = ReadAlignedString (16); - switch (name) { - case "#~": - case "#-": - image.TableHeap = new TableHeap (data); - table_heap_offset = offset; - break; - case "#Strings": - image.StringHeap = new StringHeap (data); - break; - case "#Blob": - image.BlobHeap = new BlobHeap (data); - break; - case "#GUID": - image.GuidHeap = new GuidHeap (data); - break; - case "#US": - image.UserStringHeap = new UserStringHeap (data); - break; - case "#Pdb": - image.PdbHeap = new PdbHeap (data); - break; - } - } - - byte [] ReadHeapData (uint offset, uint size) - { - var position = BaseStream.Position; - MoveTo (offset + image.MetadataSection.PointerToRawData); - var data = ReadBytes ((int) size); - BaseStream.Position = position; - - return data; - } - - void ReadTableHeap () - { - var heap = image.TableHeap; - - MoveTo (table_heap_offset + image.MetadataSection.PointerToRawData); - - // 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 (); - - if (image.PdbHeap != null) { - for (int i = 0; i < Mixin.TableCount; i++) { - if (!image.PdbHeap.HasTable ((Table) i)) - continue; - - heap.Tables [i].Length = image.PdbHeap.TypeSystemTableRows [i]; - } - } - - for (int i = 0; i < Mixin.TableCount; i++) { - if (!heap.HasTable ((Table) i)) - continue; - - heap.Tables [i].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 - table_heap_offset - image.MetadataSection.PointerToRawData; // header - - int stridx_size = image.StringHeap.IndexSize; - int guididx_size = image.GuidHeap != null ? image.GuidHeap.IndexSize : 2; - int blobidx_size = image.BlobHeap != null ? image.BlobHeap.IndexSize : 2; - - var heap = image.TableHeap; - var tables = heap.Tables; - - for (int i = 0; i < Mixin.TableCount; i++) { - var table = (Table) i; - if (!heap.HasTable (table)) - continue; - - int size; - switch (table) { - case Table.Module: - size = 2 // Generation - + stridx_size // Name - + (guididx_size * 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.EncLog: - size = 8; - break; - case Table.EncMap: - size = 4; - 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; - case Table.Document: - size = blobidx_size // Name - + guididx_size // HashAlgorithm - + blobidx_size // Hash - + guididx_size; // Language - break; - case Table.MethodDebugInformation: - size = GetTableIndexSize (Table.Document) // Document - + blobidx_size; // SequencePoints - break; - case Table.LocalScope: - size = GetTableIndexSize (Table.Method) // Method - + GetTableIndexSize (Table.ImportScope) // ImportScope - + GetTableIndexSize (Table.LocalVariable) // VariableList - + GetTableIndexSize (Table.LocalConstant) // ConstantList - + 4 * 2; // StartOffset, Length - break; - case Table.LocalVariable: - size = 2 // Attributes - + 2 // Index - + stridx_size; // Name - break; - case Table.LocalConstant: - size = stridx_size // Name - + blobidx_size; // Signature - break; - case Table.ImportScope: - size = GetTableIndexSize (Table.ImportScope) // Parent - + blobidx_size; - break; - case Table.StateMachineMethod: - size = GetTableIndexSize (Table.Method) // MoveNextMethod - + GetTableIndexSize (Table.Method); // KickOffMethod - break; - case Table.CustomDebugInformation: - size = GetCodedIndexSize (CodedIndex.HasCustomDebugInformation) // Parent - + guididx_size // Kind - + blobidx_size; // Value - break; - default: - throw new NotSupportedException (); - } - - tables [i].RowSize = (uint) size; - tables [i].Offset = offset; - - offset += (uint) size * tables [i].Length; - } - } - - void ReadPdbHeap () - { - var heap = image.PdbHeap; - - var buffer = new ByteBuffer (heap.data); - - heap.Id = buffer.ReadBytes (20); - heap.EntryPoint = buffer.ReadUInt32 (); - heap.TypeSystemTables = buffer.ReadInt64 (); - heap.TypeSystemTableRows = new uint [Mixin.TableCount]; - - for (int i = 0; i < Mixin.TableCount; i++) { - var table = (Table) i; - if (!heap.HasTable (table)) - continue; - - heap.TypeSystemTableRows [i] = buffer.ReadUInt32 (); - } - } - - public static Image ReadImage (Disposable stream, string file_name) - { - try { - var reader = new ImageReader (stream, file_name); - reader.ReadImage (); - return reader.image; - } catch (EndOfStreamException e) { - throw new BadImageFormatException (stream.value.GetFileName (), e); - } - } - - public static Image ReadPortablePdb (Disposable stream, string file_name) - { - try { - var reader = new ImageReader (stream, file_name); - var length = (uint) stream.value.Length; - - reader.image.Sections = new[] { - new Section { - PointerToRawData = 0, - SizeOfRawData = length, - VirtualAddress = 0, - VirtualSize = length, - } - }; - - reader.metadata = new DataDirectory (0, length); - reader.ReadMetadata (); - return reader.image; - } catch (EndOfStreamException e) { - throw new BadImageFormatException (stream.value.GetFileName (), e); - } - } - } -} diff --git a/external/linker/cecil/Mono.Cecil.PE/ImageWriter.cs b/external/linker/cecil/Mono.Cecil.PE/ImageWriter.cs deleted file mode 100644 index 366f4f4205..0000000000 --- a/external/linker/cecil/Mono.Cecil.PE/ImageWriter.cs +++ /dev/null @@ -1,850 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -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; - readonly internal Disposable stream; - - readonly string runtime_version; - - ImageDebugHeader debug_header; - - ByteBuffer win32_resources; - - const uint pe_header_size = 0x98u; - 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 bool has_reloc; - - internal Section text; - internal Section rsrc; - internal Section reloc; - - ushort sections; - - ImageWriter (ModuleDefinition module, string runtime_version, MetadataBuilder metadata, Disposable stream, bool metadataOnly = false) - : base (stream.value) - { - this.module = module; - this.runtime_version = runtime_version; - this.text_map = metadata.text_map; - this.stream = stream; - this.metadata = metadata; - if (metadataOnly) - return; - - this.pe64 = module.Architecture == TargetArchitecture.AMD64 || module.Architecture == TargetArchitecture.IA64 || module.Architecture == TargetArchitecture.ARM64; - this.has_reloc = module.Architecture == TargetArchitecture.I386; - this.GetDebugHeader (); - this.GetWin32Resources (); - this.BuildTextMap (); - this.sections = (ushort) (has_reloc ? 2 : 1); // text + reloc? - } - - void GetDebugHeader () - { - var symbol_writer = metadata.symbol_writer; - if (symbol_writer != null) - debug_header = symbol_writer.GetDebugHeader (); - - if (module.HasDebugHeader) { - var header = module.GetDebugHeader (); - var deterministic = header.GetDeterministicEntry (); - if (deterministic == null) - return; - - debug_header = debug_header.AddDeterministicEntry (); - } - } - - void GetWin32Resources () - { - if (!module.HasImage) - return; - - DataDirectory win32_resources_directory = module.Image.Win32Resources; - var size = win32_resources_directory.Size; - - if (size > 0) { - win32_resources = module.Image.GetReaderAt (win32_resources_directory.VirtualAddress, size, (s, reader) => new ByteBuffer (reader.ReadBytes ((int) s))); - } - } - - public static ImageWriter CreateWriter (ModuleDefinition module, MetadataBuilder metadata, Disposable stream) - { - var writer = new ImageWriter (module, module.runtime_version, metadata, stream); - writer.BuildSections (); - return writer; - } - - public static ImageWriter CreateDebugWriter (ModuleDefinition module, MetadataBuilder metadata, Disposable stream) - { - var writer = new ImageWriter (module, "PDB v1.0", metadata, stream, metadataOnly: true); - var length = metadata.text_map.GetLength (); - writer.text = new Section { SizeOfRawData = length, VirtualSize = length }; - 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; - } - - if (has_reloc) - 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 - }); - } - - ushort SizeOfOptionalHeader () - { - return (ushort) (!pe64 ? 0xe0 : 0xf0); - } - - void WritePEFileHeader () - { - WriteUInt32 (0x00004550); // Magic - WriteUInt16 ((ushort) module.Architecture); // Machine - WriteUInt16 (sections); // NumberOfSections - WriteUInt32 (metadata.timestamp); - WriteUInt32 (0); // PointerToSymbolTable - WriteUInt32 (0); // NumberOfSymbols - WriteUInt16 (SizeOfOptionalHeader ()); // 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 - } - - Section LastSection () - { - if (reloc != null) - return reloc; - - if (rsrc != null) - return rsrc; - - return text; - } - - void WriteOptionalHeaders () - { - WriteUInt16 ((ushort) (!pe64 ? 0x10b : 0x20b)); // Magic - WriteUInt16 (module.linker_version); - WriteUInt32 (text.SizeOfRawData); // CodeSize - WriteUInt32 ((reloc != null ? reloc.SizeOfRawData : 0) - + (rsrc != null ? rsrc.SizeOfRawData : 0)); // InitializedDataSize - WriteUInt32 (0); // UninitializedDataSize - - var startub_stub = text_map.GetRange (TextSegment.StartupStub); - WriteUInt32 (startub_stub.Length > 0 ? startub_stub.Start : 0); // 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 - - var last_section = LastSection(); - WriteUInt32 (last_section.VirtualAddress + Align (last_section.VirtualSize, section_alignment)); // ImageSize - WriteUInt32 (text.PointerToRawData); // HeaderSize - - WriteUInt32 (0); // Checksum - WriteUInt16 (GetSubSystem ()); // SubSystem - WriteUInt16 ((ushort) module.Characteristics); // 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 != null ? reloc.VirtualAddress : 0); // BaseRelocationTable - WriteUInt32 (reloc != null ? reloc.VirtualSize : 0); - - if (text_map.GetLength (TextSegment.DebugDirectory) > 0) { - WriteUInt32 (text_map.GetRVA (TextSegment.DebugDirectory)); - WriteUInt32 ((uint) (debug_header.Entries.Length * ImageDebugDirectory.Size)); - } 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); - - if (reloc != null) - 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 PrepareSection (Section section) - { - MoveTo (section.PointerToRawData); - - const int buffer_size = 4096; - - if (section.SizeOfRawData <= buffer_size) { - Write (new byte [section.SizeOfRawData]); - MoveTo (section.PointerToRawData); - return; - } - - var written = 0; - var buffer = new byte [buffer_size]; - while (written != section.SizeOfRawData) { - var write_size = System.Math.Min((int) section.SizeOfRawData - written, buffer_size); - Write (buffer, 0, write_size); - written += write_size; - } - - MoveTo (section.PointerToRawData); - } - - void WriteText () - { - PrepareSection (text); - - // ImportAddressTable - - if (has_reloc) { - 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 (); - } - - if (!has_reloc) - return; - - // ImportDirectory - MoveToRVA (TextSegment.ImportDirectory); - WriteImportDirectory (); - - // StartupStub - MoveToRVA (TextSegment.StartupStub); - WriteStartupStub (); - } - - uint GetMetadataLength () - { - return text_map.GetRVA (TextSegment.DebugDirectory) - text_map.GetRVA (TextSegment.MetadataHeader); - } - - public void WriteMetadataHeader () - { - WriteUInt32 (0x424a5342); // Signature - WriteUInt16 (1); // MajorVersion - WriteUInt16 (1); // MinorVersion - WriteUInt32 (0); // Reserved - - var version = GetZeroTerminatedString (runtime_version); - 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"); - WriteStreamHeader (ref offset, TextSegment.PdbHeap, "#Pdb"); - } - - ushort GetStreamCount () - { - return (ushort) ( - 1 // #~ - + 1 // #Strings - + (metadata.user_string_heap.IsEmpty ? 0 : 1) // #US - + (metadata.guid_heap.IsEmpty ? 0 : 1) // GUID - + (metadata.blob_heap.IsEmpty ? 0 : 1) - + (metadata.pdb_heap == null ? 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 int GetZeroTerminatedStringLength (string @string) - { - return (@string.Length + 1 + 3) & ~3; - } - - static byte [] GetZeroTerminatedString (string @string) - { - return GetString (@string, GetZeroTerminatedStringLength (@string)); - } - - 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; - } - - public void WriteMetadata () - { - WriteHeap (TextSegment.TableHeap, metadata.table_heap); - WriteHeap (TextSegment.StringHeap, metadata.string_heap); - WriteHeap (TextSegment.UserStringHeap, metadata.user_string_heap); - WriteHeap (TextSegment.GuidHeap, metadata.guid_heap); - WriteHeap (TextSegment.BlobHeap, metadata.blob_heap); - WriteHeap (TextSegment.PdbHeap, metadata.pdb_heap); - } - - void WriteHeap (TextSegment heap, HeapBuffer buffer) - { - if (buffer == null || buffer.IsEmpty) - return; - - MoveToRVA (heap); - WriteBuffer (buffer); - } - - void WriteDebugDirectory () - { - var data_start = (int) BaseStream.Position + (debug_header.Entries.Length * ImageDebugDirectory.Size); - - for (var i = 0; i < debug_header.Entries.Length; i++) { - var entry = debug_header.Entries [i]; - var directory = entry.Directory; - WriteInt32 (directory.Characteristics); - WriteInt32 (directory.TimeDateStamp); - WriteInt16 (directory.MajorVersion); - WriteInt16 (directory.MinorVersion); - WriteInt32 ((int) directory.Type); - WriteInt32 (directory.SizeOfData); - WriteInt32 (directory.AddressOfRawData); - WriteInt32 (data_start); - - data_start += entry.Data.Length; - } - - for (var i = 0; i < debug_header.Entries.Length; i++) { - var entry = debug_header.Entries [i]; - WriteBytes (entry.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; - default: - throw new NotSupportedException (); - } - } - - void WriteRsrc () - { - PrepareSection (rsrc); - WriteBuffer (win32_resources); - } - - void WriteReloc () - { - PrepareSection (reloc); - - 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; - default: - throw new NotSupportedException(); - } - } - - public void WriteImage () - { - WriteDOSHeader (); - WritePEFileHeader (); - WriteOptionalHeaders (); - WriteSectionHeaders (); - WriteText (); - if (rsrc != null) - WriteRsrc (); - if (reloc != null) - WriteReloc (); - Flush (); - } - - void BuildTextMap () - { - var map = 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); - - BuildMetadataTextMap (); - - int debug_dir_len = 0; - if (debug_header != null && debug_header.HasEntries) { - var directories_len = debug_header.Entries.Length * ImageDebugDirectory.Size; - var data_address = (int) map.GetNextRVA (TextSegment.BlobHeap) + directories_len; - var data_len = 0; - - for (var i = 0; i < debug_header.Entries.Length; i++) { - var entry = debug_header.Entries [i]; - var directory = entry.Directory; - - directory.AddressOfRawData = entry.Data.Length == 0 ? 0 : data_address; - entry.Directory = directory; - - data_len += entry.Data.Length; - data_address += data_len; - } - - debug_dir_len = directories_len + data_len; - } - - map.AddMap (TextSegment.DebugDirectory, debug_dir_len, 4); - - if (!has_reloc) { - var start = map.GetNextRVA (TextSegment.DebugDirectory); - map.AddMap (TextSegment.ImportDirectory, new Range (start, 0)); - map.AddMap (TextSegment.ImportHintNameTable, new Range (start, 0)); - map.AddMap (TextSegment.StartupStub, new Range (start, 0)); - return; - } - - RVA import_dir_rva = map.GetNextRVA (TextSegment.DebugDirectory); - RVA import_hnt_rva = import_dir_rva + 48u; - 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 ())); - } - - public void BuildMetadataTextMap () - { - var map = text_map; - - map.AddMap (TextSegment.MetadataHeader, GetMetadataHeaderLength (module.RuntimeVersion)); - 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, metadata.guid_heap.length, 4); - map.AddMap (TextSegment.BlobHeap, metadata.blob_heap.IsEmpty ? 0 : metadata.blob_heap.length, 4); - map.AddMap (TextSegment.PdbHeap, metadata.pdb_heap == null ? 0 : metadata.pdb_heap.length, 4); - } - - uint GetStartupStubLength () - { - switch (module.Architecture) { - case TargetArchitecture.I386: - return 6; - default: - throw new NotSupportedException (); - } - } - - int GetMetadataHeaderLength (string runtimeVersion) - { - return - // MetadataHeader - 20 + GetZeroTerminatedStringLength (runtimeVersion) - // #~ 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) - // - + (metadata.pdb_heap == null ? 0 : 16); - } - - int GetStrongNameLength () - { - if (module.Assembly == null) - return 0; - - var public_key = module.Assembly.Name.PublicKey; - if (public_key.IsNullOrEmpty ()) - return 0; - - // 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 + SizeOfOptionalHeader () + (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 rva = resources.ReadUInt32 (); - resources.position -= 4; - - resources.WriteUInt32 (rva - module.Image.Win32Resources.VirtualAddress + rsrc.VirtualAddress); - } - } -} - -#endif diff --git a/external/linker/cecil/Mono.Cecil.PE/Section.cs b/external/linker/cecil/Mono.Cecil.PE/Section.cs deleted file mode 100644 index 49d8e90011..0000000000 --- a/external/linker/cecil/Mono.Cecil.PE/Section.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -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; - } -} diff --git a/external/linker/cecil/Mono.Cecil.PE/TextMap.cs b/external/linker/cecil/Mono.Cecil.PE/TextMap.cs deleted file mode 100644 index 614691b6ad..0000000000 --- a/external/linker/cecil/Mono.Cecil.PE/TextMap.cs +++ /dev/null @@ -1,112 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -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, - PdbHeap, - // End Metadata - - DebugDirectory, - ImportDirectory, - ImportHintNameTable, - StartupStub, - } - - sealed class TextMap { - - readonly Range [] map = new Range [17 /*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/external/linker/cecil/Mono.Cecil.Tests.props b/external/linker/cecil/Mono.Cecil.Tests.props deleted file mode 100644 index 49c1a386f1..0000000000 --- a/external/linker/cecil/Mono.Cecil.Tests.props +++ /dev/null @@ -1,49 +0,0 @@ - - - - $(MSBuildProjectDirectory) - true - - - - true - - - false - - - - 3.7.1 - - - 15.3.0 - - - 3.8.0 - - - - - False - $(MSBuildThisFileDirectory)\Test\libs\nunit-2.6.2\nunit.core.dll - - - False - $(MSBuildThisFileDirectory)\Test\libs\nunit-2.6.2\nunit.core.interfaces.dll - - - False - $(MSBuildThisFileDirectory)\Test\libs\nunit-2.6.2\nunit.framework.dll - - - - - - - true - - - diff --git a/external/linker/cecil/Mono.Cecil.csproj b/external/linker/cecil/Mono.Cecil.csproj deleted file mode 100644 index 8bb3b26031..0000000000 --- a/external/linker/cecil/Mono.Cecil.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - {D68133BD-1E63-496E-9EDE-4FBDBF77B486} - Mono.Cecil - Mono.Cecil - - - - - - - - - - - - - - diff --git a/external/linker/cecil/Mono.Cecil.nunit b/external/linker/cecil/Mono.Cecil.nunit deleted file mode 100644 index 6bab390eee..0000000000 --- a/external/linker/cecil/Mono.Cecil.nunit +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/external/linker/cecil/Mono.Cecil.nuspec b/external/linker/cecil/Mono.Cecil.nuspec deleted file mode 100644 index 4fc12bc83d..0000000000 --- a/external/linker/cecil/Mono.Cecil.nuspec +++ /dev/null @@ -1,36 +0,0 @@ - - - - Mono.Cecil - 0.10.0.0-beta7 - Mono.Cecil - Jb Evain - Jb Evain - http://opensource.org/licenses/mit-license.php - false - http://github.com/jbevain/cecil/ - Cecil is a library written by Jb Evain to generate and inspect programs and libraries in the ECMA CIL format. - Cecil is a library written by Jb Evain to generate and inspect programs and libraries in the ECMA CIL format. It has full support for generics, and support some debugging symbol format. In simple English, with Cecil, you can load existing managed assemblies, browse all the contained types, modify them on the fly and save back to the disk the modified assembly. - en-US - assembly assemblies module modules il cil msil bytecode reflection injection cecil mono aop - - - - - - - - - - - - - - - - - - - - - diff --git a/external/linker/cecil/Mono.Cecil.props b/external/linker/cecil/Mono.Cecil.props deleted file mode 100644 index aef3a98a3f..0000000000 --- a/external/linker/cecil/Mono.Cecil.props +++ /dev/null @@ -1,103 +0,0 @@ - - - - net_4_0_Debug - AnyCPU - $(MSBuildThisFileDirectory) - 512 - 2.0 - Library - true - $(MSBuildThisFileDirectory)\cecil.snk - Library - $(BuildDirectory)\bin\$(Configuration)\ - $(MSBuildToolsPath)\Microsoft.CSharp.targets - true - false - false - - - true - full - false - $(DefineConstants);DEBUG;TRACE; - prompt - 4 - - - pdbonly - true - $(DefineConstants);TRACE; - prompt - 4 - false - - - $(DefineConstants);READ_ONLY; - - - v3.5 - $(DefineConstants);NET_3_5; - - - v4.0 - $(DefineConstants);NET_4_0; - - - netcoreapp2.0 - netstandard1.3 - - - - - - - - - - - - - - - - - - - - - - - $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), Mono.Cecil.overrides))\Mono.Cecil.overrides - - - - - - diff --git a/external/linker/cecil/Mono.Cecil.sln b/external/linker/cecil/Mono.Cecil.sln deleted file mode 100644 index a8c436f342..0000000000 --- a/external/linker/cecil/Mono.Cecil.sln +++ /dev/null @@ -1,241 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26927.1 -MinimumVisualStudioVersion = 10.0.40219.1 -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}") = "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 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E0893F44-CB9F-49C5-B38C-70082EFC5072}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - net_3_5_Debug_ReadOnly|Any CPU = net_3_5_Debug_ReadOnly|Any CPU - net_3_5_Debug|Any CPU = net_3_5_Debug|Any CPU - net_3_5_Release_ReadOnly|Any CPU = net_3_5_Release_ReadOnly|Any CPU - net_3_5_Release|Any CPU = net_3_5_Release|Any CPU - net_4_0_Debug_ReadOnly|Any CPU = net_4_0_Debug_ReadOnly|Any CPU - net_4_0_Debug|Any CPU = net_4_0_Debug|Any CPU - net_4_0_Release_ReadOnly|Any CPU = net_4_0_Release_ReadOnly|Any CPU - net_4_0_Release|Any CPU = net_4_0_Release|Any CPU - netstandard_Debug_ReadOnly|Any CPU = netstandard_Debug_ReadOnly|Any CPU - netstandard_Debug|Any CPU = netstandard_Debug|Any CPU - netstandard_Release_ReadOnly|Any CPU = netstandard_Release_ReadOnly|Any CPU - netstandard_Release|Any CPU = netstandard_Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_3_5_Debug_ReadOnly|Any CPU.ActiveCfg = net_3_5_Debug_ReadOnly|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_3_5_Debug_ReadOnly|Any CPU.Build.0 = net_3_5_Debug_ReadOnly|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_3_5_Release_ReadOnly|Any CPU.ActiveCfg = net_3_5_Release_ReadOnly|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_3_5_Release_ReadOnly|Any CPU.Build.0 = net_3_5_Release_ReadOnly|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_3_5_Release|Any CPU.Build.0 = net_3_5_Release|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_0_Debug_ReadOnly|Any CPU.ActiveCfg = net_4_0_Debug_ReadOnly|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_0_Debug_ReadOnly|Any CPU.Build.0 = net_4_0_Debug_ReadOnly|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_0_Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_0_Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_0_Release_ReadOnly|Any CPU.ActiveCfg = net_4_0_Release_ReadOnly|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_0_Release_ReadOnly|Any CPU.Build.0 = net_4_0_Release_ReadOnly|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_0_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_0_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.netstandard_Debug_ReadOnly|Any CPU.ActiveCfg = netstandard_Debug_ReadOnly|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.netstandard_Debug_ReadOnly|Any CPU.Build.0 = netstandard_Debug_ReadOnly|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.netstandard_Debug|Any CPU.ActiveCfg = netstandard_Debug|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.netstandard_Debug|Any CPU.Build.0 = netstandard_Debug|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.netstandard_Release_ReadOnly|Any CPU.ActiveCfg = netstandard_Release_ReadOnly|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.netstandard_Release_ReadOnly|Any CPU.Build.0 = netstandard_Release_ReadOnly|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.netstandard_Release|Any CPU.ActiveCfg = netstandard_Release|Any CPU - {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.netstandard_Release|Any CPU.Build.0 = netstandard_Release|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_3_5_Debug_ReadOnly|Any CPU.ActiveCfg = net_3_5_Debug_ReadOnly|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_3_5_Debug_ReadOnly|Any CPU.Build.0 = net_3_5_Debug_ReadOnly|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_3_5_Release_ReadOnly|Any CPU.ActiveCfg = net_3_5_Release_ReadOnly|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_3_5_Release_ReadOnly|Any CPU.Build.0 = net_3_5_Release_ReadOnly|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_3_5_Release|Any CPU.Build.0 = net_3_5_Release|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_4_0_Debug_ReadOnly|Any CPU.ActiveCfg = net_4_0_Debug_ReadOnly|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_4_0_Debug_ReadOnly|Any CPU.Build.0 = net_4_0_Debug_ReadOnly|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_4_0_Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_4_0_Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_4_0_Release_ReadOnly|Any CPU.ActiveCfg = net_4_0_Release_ReadOnly|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_4_0_Release_ReadOnly|Any CPU.Build.0 = net_4_0_Release_ReadOnly|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_4_0_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.net_4_0_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Debug_ReadOnly|Any CPU.ActiveCfg = netstandard_Debug_ReadOnly|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Debug_ReadOnly|Any CPU.Build.0 = netstandard_Debug_ReadOnly|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Debug|Any CPU.ActiveCfg = netstandard_Debug|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Debug|Any CPU.Build.0 = netstandard_Debug|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Release_ReadOnly|Any CPU.ActiveCfg = netstandard_Release_ReadOnly|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Release_ReadOnly|Any CPU.Build.0 = netstandard_Release_ReadOnly|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Release|Any CPU.ActiveCfg = netstandard_Release|Any CPU - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055}.netstandard_Release|Any CPU.Build.0 = netstandard_Release|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_3_5_Debug_ReadOnly|Any CPU.ActiveCfg = net_3_5_Debug_ReadOnly|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_3_5_Debug_ReadOnly|Any CPU.Build.0 = net_3_5_Debug_ReadOnly|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_3_5_Release_ReadOnly|Any CPU.ActiveCfg = net_3_5_Release_ReadOnly|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_3_5_Release_ReadOnly|Any CPU.Build.0 = net_3_5_Release_ReadOnly|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_3_5_Release|Any CPU.Build.0 = net_3_5_Release|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_4_0_Debug_ReadOnly|Any CPU.ActiveCfg = net_4_0_Debug_ReadOnly|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_4_0_Debug_ReadOnly|Any CPU.Build.0 = net_4_0_Debug_ReadOnly|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_4_0_Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_4_0_Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_4_0_Release_ReadOnly|Any CPU.ActiveCfg = net_4_0_Release_ReadOnly|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_4_0_Release_ReadOnly|Any CPU.Build.0 = net_4_0_Release_ReadOnly|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_4_0_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.net_4_0_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.netstandard_Debug_ReadOnly|Any CPU.ActiveCfg = netstandard_Debug_ReadOnly|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.netstandard_Debug_ReadOnly|Any CPU.Build.0 = netstandard_Debug_ReadOnly|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.netstandard_Debug|Any CPU.ActiveCfg = netstandard_Debug|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.netstandard_Debug|Any CPU.Build.0 = netstandard_Debug|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.netstandard_Release_ReadOnly|Any CPU.ActiveCfg = netstandard_Release_ReadOnly|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.netstandard_Release_ReadOnly|Any CPU.Build.0 = netstandard_Release_ReadOnly|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.netstandard_Release|Any CPU.ActiveCfg = netstandard_Release|Any CPU - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD}.netstandard_Release|Any CPU.Build.0 = netstandard_Release|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_3_5_Debug_ReadOnly|Any CPU.ActiveCfg = net_3_5_Debug_ReadOnly|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_3_5_Debug_ReadOnly|Any CPU.Build.0 = net_3_5_Debug_ReadOnly|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_3_5_Release_ReadOnly|Any CPU.ActiveCfg = net_3_5_Release_ReadOnly|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_3_5_Release_ReadOnly|Any CPU.Build.0 = net_3_5_Release_ReadOnly|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_3_5_Release|Any CPU.Build.0 = net_3_5_Release|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_4_0_Debug_ReadOnly|Any CPU.ActiveCfg = net_4_0_Debug_ReadOnly|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_4_0_Debug_ReadOnly|Any CPU.Build.0 = net_4_0_Debug_ReadOnly|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_4_0_Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_4_0_Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_4_0_Release_ReadOnly|Any CPU.ActiveCfg = net_4_0_Release_ReadOnly|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_4_0_Release_ReadOnly|Any CPU.Build.0 = net_4_0_Release_ReadOnly|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_4_0_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.net_4_0_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.netstandard_Debug_ReadOnly|Any CPU.ActiveCfg = netstandard_Debug_ReadOnly|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.netstandard_Debug|Any CPU.ActiveCfg = netstandard_Debug|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.netstandard_Release_ReadOnly|Any CPU.ActiveCfg = netstandard_Release_ReadOnly|Any CPU - {AC71DF9C-99FA-4A63-990A-66C8010355A6}.netstandard_Release|Any CPU.ActiveCfg = netstandard_Release|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_3_5_Debug_ReadOnly|Any CPU.ActiveCfg = net_3_5_Debug_ReadOnly|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_3_5_Debug_ReadOnly|Any CPU.Build.0 = net_3_5_Debug_ReadOnly|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_3_5_Release_ReadOnly|Any CPU.ActiveCfg = net_3_5_Release_ReadOnly|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_3_5_Release_ReadOnly|Any CPU.Build.0 = net_3_5_Release_ReadOnly|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_3_5_Release|Any CPU.Build.0 = net_3_5_Release|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_0_Debug_ReadOnly|Any CPU.ActiveCfg = net_4_0_Debug_ReadOnly|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_0_Debug_ReadOnly|Any CPU.Build.0 = net_4_0_Debug_ReadOnly|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_0_Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_0_Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_0_Release_ReadOnly|Any CPU.ActiveCfg = net_4_0_Release_ReadOnly|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_0_Release_ReadOnly|Any CPU.Build.0 = net_4_0_Release_ReadOnly|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_0_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.net_4_0_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.netstandard_Debug_ReadOnly|Any CPU.ActiveCfg = netstandard_Debug_ReadOnly|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.netstandard_Debug_ReadOnly|Any CPU.Build.0 = netstandard_Debug_ReadOnly|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.netstandard_Debug|Any CPU.ActiveCfg = netstandard_Debug|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.netstandard_Debug|Any CPU.Build.0 = netstandard_Debug|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.netstandard_Release_ReadOnly|Any CPU.ActiveCfg = netstandard_Release_ReadOnly|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.netstandard_Release_ReadOnly|Any CPU.Build.0 = netstandard_Release_ReadOnly|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.netstandard_Release|Any CPU.ActiveCfg = netstandard_Release|Any CPU - {63E6915C-7EA4-4D76-AB28-0D7191EEA626}.netstandard_Release|Any CPU.Build.0 = netstandard_Release|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_3_5_Debug_ReadOnly|Any CPU.ActiveCfg = net_3_5_Debug_ReadOnly|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_3_5_Debug_ReadOnly|Any CPU.Build.0 = net_3_5_Debug_ReadOnly|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_3_5_Release_ReadOnly|Any CPU.ActiveCfg = net_3_5_Release_ReadOnly|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_3_5_Release_ReadOnly|Any CPU.Build.0 = net_3_5_Release_ReadOnly|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_3_5_Release|Any CPU.Build.0 = net_3_5_Release|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_4_0_Debug_ReadOnly|Any CPU.ActiveCfg = net_4_0_Debug_ReadOnly|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_4_0_Debug_ReadOnly|Any CPU.Build.0 = net_4_0_Debug_ReadOnly|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_4_0_Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_4_0_Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_4_0_Release_ReadOnly|Any CPU.ActiveCfg = net_4_0_Release_ReadOnly|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_4_0_Release_ReadOnly|Any CPU.Build.0 = net_4_0_Release_ReadOnly|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_4_0_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.net_4_0_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.netstandard_Debug_ReadOnly|Any CPU.ActiveCfg = netstandard_Debug_ReadOnly|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.netstandard_Debug|Any CPU.ActiveCfg = netstandard_Debug|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.netstandard_Release_ReadOnly|Any CPU.ActiveCfg = netstandard_Release_ReadOnly|Any CPU - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA}.netstandard_Release|Any CPU.ActiveCfg = netstandard_Release|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_3_5_Debug_ReadOnly|Any CPU.ActiveCfg = net_3_5_Debug_ReadOnly|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_3_5_Debug_ReadOnly|Any CPU.Build.0 = net_3_5_Debug_ReadOnly|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_3_5_Release_ReadOnly|Any CPU.ActiveCfg = net_3_5_Release_ReadOnly|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_3_5_Release_ReadOnly|Any CPU.Build.0 = net_3_5_Release_ReadOnly|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_3_5_Release|Any CPU.Build.0 = net_3_5_Release|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_4_0_Debug_ReadOnly|Any CPU.ActiveCfg = net_4_0_Debug_ReadOnly|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_4_0_Debug_ReadOnly|Any CPU.Build.0 = net_4_0_Debug_ReadOnly|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_4_0_Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_4_0_Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_4_0_Release_ReadOnly|Any CPU.ActiveCfg = net_4_0_Release_ReadOnly|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_4_0_Release_ReadOnly|Any CPU.Build.0 = net_4_0_Release_ReadOnly|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_4_0_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.net_4_0_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.netstandard_Debug_ReadOnly|Any CPU.ActiveCfg = netstandard_Debug_ReadOnly|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.netstandard_Debug|Any CPU.ActiveCfg = netstandard_Debug|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.netstandard_Release_ReadOnly|Any CPU.ActiveCfg = netstandard_Release_ReadOnly|Any CPU - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52}.netstandard_Release|Any CPU.ActiveCfg = netstandard_Release|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_3_5_Debug_ReadOnly|Any CPU.ActiveCfg = net_3_5_Debug_ReadOnly|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_3_5_Debug_ReadOnly|Any CPU.Build.0 = net_3_5_Debug_ReadOnly|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_3_5_Release_ReadOnly|Any CPU.ActiveCfg = net_3_5_Release_ReadOnly|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_3_5_Release_ReadOnly|Any CPU.Build.0 = net_3_5_Release_ReadOnly|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_3_5_Release|Any CPU.Build.0 = net_3_5_Release|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_4_0_Debug_ReadOnly|Any CPU.ActiveCfg = net_4_0_Debug_ReadOnly|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_4_0_Debug_ReadOnly|Any CPU.Build.0 = net_4_0_Debug_ReadOnly|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_4_0_Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_4_0_Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_4_0_Release_ReadOnly|Any CPU.ActiveCfg = net_4_0_Release_ReadOnly|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_4_0_Release_ReadOnly|Any CPU.Build.0 = net_4_0_Release_ReadOnly|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_4_0_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.net_4_0_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.netstandard_Debug_ReadOnly|Any CPU.ActiveCfg = netstandard_Debug_ReadOnly|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.netstandard_Debug_ReadOnly|Any CPU.Build.0 = netstandard_Debug_ReadOnly|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.netstandard_Debug|Any CPU.ActiveCfg = netstandard_Debug|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.netstandard_Debug|Any CPU.Build.0 = netstandard_Debug|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.netstandard_Release_ReadOnly|Any CPU.ActiveCfg = netstandard_Release_ReadOnly|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.netstandard_Release_ReadOnly|Any CPU.Build.0 = netstandard_Release_ReadOnly|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.netstandard_Release|Any CPU.ActiveCfg = netstandard_Release|Any CPU - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC}.netstandard_Release|Any CPU.Build.0 = netstandard_Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055} = {74E5ECE0-06B4-401C-AEBA-E8DD53E17943} - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD} = {929D5B3B-E29A-40CC-93D8-0FF43A6F9FA1} - {AC71DF9C-99FA-4A63-990A-66C8010355A6} = {74E5ECE0-06B4-401C-AEBA-E8DD53E17943} - {63E6915C-7EA4-4D76-AB28-0D7191EEA626} = {929D5B3B-E29A-40CC-93D8-0FF43A6F9FA1} - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA} = {74E5ECE0-06B4-401C-AEBA-E8DD53E17943} - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52} = {74E5ECE0-06B4-401C-AEBA-E8DD53E17943} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {D75C0801-AFCB-4B1F-90AD-2B7852A74E6A} - EndGlobalSection -EndGlobal diff --git a/external/linker/cecil/Mono.Cecil.sln.DotSettings b/external/linker/cecil/Mono.Cecil.sln.DotSettings deleted file mode 100644 index b1aed5eade..0000000000 --- a/external/linker/cecil/Mono.Cecil.sln.DotSettings +++ /dev/null @@ -1,39 +0,0 @@ - - DO_NOT_SHOW - True - <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> - END_OF_LINE - END_OF_LINE - END_OF_LINE - END_OF_LINE - END_OF_LINE - 1 - 1 - False - False - False - False - True - True - True - True - True - True - False - True - True - False - False - False - <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> - <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> - True - C:\sources\cecil\Mono.Cecil.sln.DotSettings - True - 1 - True - True - True - True - None \ No newline at end of file diff --git a/external/linker/cecil/Mono.Cecil/ArrayType.cs b/external/linker/cecil/Mono.Cecil/ArrayType.cs deleted file mode 100644 index 010049cc00..0000000000 --- a/external/linker/cecil/Mono.Cecil/ArrayType.cs +++ /dev/null @@ -1,141 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Text; -using Mono.Collections.Generic; -using MD = Mono.Cecil.Metadata; - -namespace Mono.Cecil { - - 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; - } - - public override string ToString () - { - return !IsSized - ? string.Empty - : lower_bound + "..." + upper_bound; - } - } - - public sealed class ArrayType : TypeSpecification { - - Collection dimensions; - - public Collection Dimensions { - get { - if (dimensions != null) - return dimensions; - - dimensions = new Collection (); - dimensions.Add (new ArrayDimension ()); - return dimensions; - } - } - - public int Rank { - get { return dimensions == null ? 1 : dimensions.Count; } - } - - public bool IsVector { - get { - if (dimensions == null) - return true; - - if (dimensions.Count > 1) - return false; - - var dimension = dimensions [0]; - - return !dimension.IsSized; - } - } - - public override bool IsValueType { - get { return false; } - set { throw new InvalidOperationException (); } - } - - public override string Name { - get { return base.Name + Suffix; } - } - - public override string FullName { - get { return base.FullName + Suffix; } - } - - 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 (); - } - } - - public override bool IsArray { - get { return true; } - } - - public ArrayType (TypeReference type) - : base (type) - { - Mixin.CheckType (type); - this.etype = MD.ElementType.Array; - } - - public ArrayType (TypeReference type, int rank) - : this (type) - { - Mixin.CheckType (type); - - if (rank == 1) - return; - - dimensions = new Collection (rank); - for (int i = 0; i < rank; i++) - dimensions.Add (new ArrayDimension ()); - this.etype = MD.ElementType.Array; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/AssemblyDefinition.cs b/external/linker/cecil/Mono.Cecil/AssemblyDefinition.cs deleted file mode 100644 index f02b93f299..0000000000 --- a/external/linker/cecil/Mono.Cecil/AssemblyDefinition.cs +++ /dev/null @@ -1,194 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.IO; - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public sealed class AssemblyDefinition : ICustomAttributeProvider, ISecurityDeclarationProvider, IDisposable { - - AssemblyNameDefinition name; - - internal ModuleDefinition main_module; - Collection modules; - Collection custom_attributes; - Collection security_declarations; - - public AssemblyNameDefinition Name { - get { return name; } - set { name = value; } - } - - public string FullName { - get { return name != null ? name.FullName : string.Empty; } - } - - public MetadataToken MetadataToken { - get { return new MetadataToken (TokenType.Assembly, 1); } - set { } - } - - public Collection Modules { - get { - if (modules != null) - return modules; - - if (main_module.HasImage) - return main_module.Read (ref modules, this, (_, reader) => reader.ReadModules ()); - - return modules = new Collection (1) { main_module }; - } - } - - public ModuleDefinition MainModule { - get { return main_module; } - } - - public MethodDefinition EntryPoint { - get { return main_module.EntryPoint; } - set { main_module.EntryPoint = value; } - } - - public bool HasCustomAttributes { - get { - if (custom_attributes != null) - return custom_attributes.Count > 0; - - return this.GetHasCustomAttributes (main_module); - } - } - - public Collection CustomAttributes { - get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, main_module)); } - } - - public bool HasSecurityDeclarations { - get { - if (security_declarations != null) - return security_declarations.Count > 0; - - return this.GetHasSecurityDeclarations (main_module); - } - } - - public Collection SecurityDeclarations { - get { return security_declarations ?? (this.GetSecurityDeclarations (ref security_declarations, main_module)); } - } - - internal AssemblyDefinition () - { - } - - public void Dispose () - { - if (this.modules == null) { - main_module.Dispose (); - return; - } - - var modules = this.Modules; - for (int i = 0; i < modules.Count; i++) - modules [i].Dispose (); - } - -#if !READ_ONLY - public static AssemblyDefinition CreateAssembly (AssemblyNameDefinition assemblyName, string moduleName, ModuleKind kind) - { - return CreateAssembly (assemblyName, moduleName, new ModuleParameters { Kind = kind }); - } - - 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"); - - var assembly = ModuleDefinition.CreateModule (moduleName, parameters).Assembly; - assembly.Name = assemblyName; - - return assembly; - } -#endif - - public static AssemblyDefinition ReadAssembly (string fileName) - { - return ReadAssembly (ModuleDefinition.ReadModule (fileName)); - } - - public static AssemblyDefinition ReadAssembly (string fileName, ReaderParameters parameters) - { - return ReadAssembly (ModuleDefinition.ReadModule (fileName, parameters)); - } - - 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)); - } - - static AssemblyDefinition ReadAssembly (ModuleDefinition module) - { - var assembly = module.Assembly; - if (assembly == null) - throw new ArgumentException (); - - return assembly; - } - -#if !READ_ONLY - - public void Write (string fileName) - { - Write (fileName, new WriterParameters ()); - } - - public void Write (string fileName, WriterParameters parameters) - { - main_module.Write (fileName, parameters); - } - - public void Write () - { - main_module.Write (); - } - - public void Write (WriterParameters parameters) - { - main_module.Write (parameters); - } - - public void Write (Stream stream) - { - Write (stream, new WriterParameters ()); - } - - public void Write (Stream stream, WriterParameters parameters) - { - main_module.Write (stream, parameters); - } -#endif - - public override string ToString () - { - return this.FullName; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/AssemblyFlags.cs b/external/linker/cecil/Mono.Cecil/AssemblyFlags.cs deleted file mode 100644 index 6ca5bc274c..0000000000 --- a/external/linker/cecil/Mono.Cecil/AssemblyFlags.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - [Flags] - public enum AssemblyAttributes : uint { - PublicKey = 0x0001, - SideBySideCompatible = 0x0000, - Retargetable = 0x0100, - WindowsRuntime = 0x0200, - DisableJITCompileOptimizer = 0x4000, - EnableJITCompileTracking = 0x8000, - } -} diff --git a/external/linker/cecil/Mono.Cecil/AssemblyHashAlgorithm.cs b/external/linker/cecil/Mono.Cecil/AssemblyHashAlgorithm.cs deleted file mode 100644 index 66ef4cbba7..0000000000 --- a/external/linker/cecil/Mono.Cecil/AssemblyHashAlgorithm.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil { - - public enum AssemblyHashAlgorithm : uint { - None = 0x0000, - Reserved = 0x8003, // MD5 - SHA1 = 0x8004 - } -} diff --git a/external/linker/cecil/Mono.Cecil/AssemblyInfo.cs b/external/linker/cecil/Mono.Cecil/AssemblyInfo.cs deleted file mode 100644 index 5571093b64..0000000000 --- a/external/linker/cecil/Mono.Cecil/AssemblyInfo.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle (Consts.AssemblyName)] - -#if !NET_CORE -[assembly: Guid ("fd225bb4-fa53-44b2-a6db-85f5e48dcb54")] -#endif - -[assembly: InternalsVisibleTo ("Mono.Cecil.Pdb, PublicKey=" + Consts.PublicKey)] -[assembly: InternalsVisibleTo ("Mono.Cecil.Mdb, PublicKey=" + Consts.PublicKey)] -[assembly: InternalsVisibleTo ("Mono.Cecil.Rocks, PublicKey=" + Consts.PublicKey)] -[assembly: InternalsVisibleTo ("Mono.Cecil.Tests, PublicKey=" + Consts.PublicKey)] diff --git a/external/linker/cecil/Mono.Cecil/AssemblyLinkedResource.cs b/external/linker/cecil/Mono.Cecil/AssemblyLinkedResource.cs deleted file mode 100644 index f4896bd245..0000000000 --- a/external/linker/cecil/Mono.Cecil/AssemblyLinkedResource.cs +++ /dev/null @@ -1,39 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - public sealed class AssemblyLinkedResource : Resource { - - AssemblyNameReference reference; - - public AssemblyNameReference Assembly { - get { return reference; } - set { reference = value; } - } - - public override ResourceType ResourceType { - get { return ResourceType.AssemblyLinked; } - } - - public AssemblyLinkedResource (string name, ManifestResourceAttributes flags) - : base (name, flags) - { - } - - public AssemblyLinkedResource (string name, ManifestResourceAttributes flags, AssemblyNameReference reference) - : base (name, flags) - { - this.reference = reference; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/AssemblyNameDefinition.cs b/external/linker/cecil/Mono.Cecil/AssemblyNameDefinition.cs deleted file mode 100644 index 2511d79344..0000000000 --- a/external/linker/cecil/Mono.Cecil/AssemblyNameDefinition.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - public sealed class AssemblyNameDefinition : AssemblyNameReference { - - public override byte [] Hash { - get { return Empty.Array; } - } - - internal AssemblyNameDefinition () - { - this.token = new MetadataToken (TokenType.Assembly, 1); - } - - public AssemblyNameDefinition (string name, Version version) - : base (name, version) - { - this.token = new MetadataToken (TokenType.Assembly, 1); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/AssemblyNameReference.cs b/external/linker/cecil/Mono.Cecil/AssemblyNameReference.cs deleted file mode 100644 index 1d12cc163e..0000000000 --- a/external/linker/cecil/Mono.Cecil/AssemblyNameReference.cs +++ /dev/null @@ -1,266 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Globalization; -using System.Security.Cryptography; -using System.Text; - -namespace Mono.Cecil { - - public class AssemblyNameReference : IMetadataScope { - - string name; - string culture; - Version version; - uint attributes; - byte [] public_key; - byte [] public_key_token; - AssemblyHashAlgorithm hash_algorithm; - byte [] hash; - - internal MetadataToken token; - - string full_name; - - public string Name { - get { return name; } - set { - name = value; - full_name = null; - } - } - - public string Culture { - get { return culture; } - set { - culture = value; - full_name = null; - } - } - - public Version Version { - get { return version; } - set { - version = Mixin.CheckVersion (value); - full_name = null; - } - } - - public AssemblyAttributes Attributes { - get { return (AssemblyAttributes) attributes; } - set { attributes = (uint) value; } - } - - public bool HasPublicKey { - get { return attributes.GetAttributes ((uint) AssemblyAttributes.PublicKey); } - set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.PublicKey, value); } - } - - public bool IsSideBySideCompatible { - get { return attributes.GetAttributes ((uint) AssemblyAttributes.SideBySideCompatible); } - set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.SideBySideCompatible, value); } - } - - public bool IsRetargetable { - get { return attributes.GetAttributes ((uint) AssemblyAttributes.Retargetable); } - set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.Retargetable, value); } - } - - public bool IsWindowsRuntime { - get { return attributes.GetAttributes ((uint) AssemblyAttributes.WindowsRuntime); } - set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.WindowsRuntime, value); } - } - - public byte [] PublicKey { - get { return public_key ?? Empty.Array; } - set { - public_key = value; - HasPublicKey = !public_key.IsNullOrEmpty (); - public_key_token = Empty.Array; - full_name = null; - } - } - - public byte [] PublicKeyToken { - get { - if (public_key_token.IsNullOrEmpty () && !public_key.IsNullOrEmpty ()) { - var hash = HashPublicKey (); - // we need the last 8 bytes in reverse order - var local_public_key_token = new byte [8]; - Array.Copy (hash, (hash.Length - 8), local_public_key_token, 0, 8); - Array.Reverse (local_public_key_token, 0, 8); - public_key_token = local_public_key_token; // publish only once finished (required for thread-safety) - } - return public_key_token ?? Empty.Array; - } - set { - public_key_token = value; - full_name = null; - } - } - - byte [] HashPublicKey () - { - HashAlgorithm algorithm; - - switch (hash_algorithm) { - case AssemblyHashAlgorithm.Reserved: - algorithm = MD5.Create (); - break; - default: - // None default to SHA1 - algorithm = SHA1.Create (); - break; - } - - using (algorithm) - return algorithm.ComputeHash (public_key); - } - - public virtual MetadataScopeType MetadataScopeType { - get { return MetadataScopeType.AssemblyNameReference; } - } - - public string FullName { - get { - if (full_name != null) - return full_name; - - const string sep = ", "; - - var builder = new StringBuilder (); - builder.Append (name); - builder.Append (sep); - builder.Append ("Version="); - builder.Append (version.ToString (fieldCount: 4)); - builder.Append (sep); - builder.Append ("Culture="); - builder.Append (string.IsNullOrEmpty (culture) ? "neutral" : culture); - builder.Append (sep); - builder.Append ("PublicKeyToken="); - - var pk_token = PublicKeyToken; - if (!pk_token.IsNullOrEmpty () && pk_token.Length > 0) { - for (int i = 0 ; i < pk_token.Length ; i++) { - builder.Append (pk_token [i].ToString ("x2")); - } - } else - builder.Append ("null"); - - if (IsRetargetable) { - builder.Append (sep); - builder.Append ("Retargetable=Yes"); - } - - return full_name = builder.ToString (); - } - } - - public static AssemblyNameReference Parse (string fullName) - { - if (fullName == null) - throw new ArgumentNullException ("fullName"); - if (fullName.Length == 0) - throw new ArgumentException ("Name can not be empty"); - - var name = new AssemblyNameReference (); - var tokens = fullName.Split (','); - for (int i = 0; i < tokens.Length; i++) { - var token = tokens [i].Trim (); - - if (i == 0) { - name.Name = token; - continue; - } - - var parts = token.Split ('='); - if (parts.Length != 2) - throw new ArgumentException ("Malformed name"); - - switch (parts [0].ToLowerInvariant ()) { - case "version": - name.Version = new Version (parts [1]); - break; - case "culture": - name.Culture = parts [1] == "neutral" ? "" : parts [1]; - break; - case "publickeytoken": - var pk_token = parts [1]; - if (pk_token == "null") - break; - - name.PublicKeyToken = new byte [pk_token.Length / 2]; - for (int j = 0; j < name.PublicKeyToken.Length; j++) - name.PublicKeyToken [j] = Byte.Parse (pk_token.Substring (j * 2, 2), NumberStyles.HexNumber); - - break; - } - } - - return name; - } - - public AssemblyHashAlgorithm HashAlgorithm { - get { return hash_algorithm; } - set { hash_algorithm = value; } - } - - public virtual byte [] Hash { - get { return hash; } - set { hash = value; } - } - - public MetadataToken MetadataToken { - get { return token; } - set { token = value; } - } - - internal AssemblyNameReference () - { - this.version = Mixin.ZeroVersion; - this.token = new MetadataToken (TokenType.AssemblyRef); - } - - public AssemblyNameReference (string name, Version version) - { - Mixin.CheckName (name); - - this.name = name; - this.version = Mixin.CheckVersion (version); - this.hash_algorithm = AssemblyHashAlgorithm.None; - this.token = new MetadataToken (TokenType.AssemblyRef); - } - - public override string ToString () - { - return this.FullName; - } - } - - partial class Mixin { - - public static Version ZeroVersion = new Version (0, 0, 0 ,0); - - public static Version CheckVersion (Version version) - { - if (version == null) - return ZeroVersion; - - if (version.Build == -1) - return new Version (version.Major, version.Minor, 0, 0); - - if (version.Revision == -1) - return new Version (version.Major, version.Minor, version.Build, 0); - - return version; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/AssemblyReader.cs b/external/linker/cecil/Mono.Cecil/AssemblyReader.cs deleted file mode 100644 index 0be4404289..0000000000 --- a/external/linker/cecil/Mono.Cecil/AssemblyReader.cs +++ /dev/null @@ -1,3846 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -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 ModuleDefinition module; - - protected ModuleReader (Image image, ReadingMode mode) - { - this.module = new ModuleDefinition (image); - this.module.ReadingMode = mode; - } - - protected abstract void ReadModule (); - public abstract void ReadSymbols (ModuleDefinition module); - - 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 CreateModule (Image image, ReaderParameters parameters) - { - var reader = CreateModuleReader (image, parameters.ReadingMode); - var module = reader.module; - - if (parameters.assembly_resolver != null) - module.assembly_resolver = Disposable.NotOwned (parameters.assembly_resolver); - - if (parameters.metadata_resolver != null) - module.metadata_resolver = parameters.metadata_resolver; - -#if !READ_ONLY - if (parameters.metadata_importer_provider != null) - module.metadata_importer = parameters.metadata_importer_provider.GetMetadataImporter (module); - if (parameters.reflection_importer_provider != null) - module.reflection_importer = parameters.reflection_importer_provider.GetReflectionImporter (module); -#endif - - GetMetadataKind (module, parameters); - - reader.ReadModule (); - - ReadSymbols (module, parameters); - - reader.ReadSymbols (module); - - if (parameters.ReadingMode == ReadingMode.Immediate) - module.MetadataSystem.Clear (); - - 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 = new DefaultSymbolReaderProvider (); - - 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.FileName); - - if (reader != null) - module.ReadSymbols (reader); - } - - if (module.Image.HasDebugTables ()) - module.ReadSymbols (new PortablePdbReader (module.Image, module)); - } - - static void GetMetadataKind (ModuleDefinition module, ReaderParameters parameters) - { - if (!parameters.ApplyWindowsRuntimeProjections) { - module.MetadataKind = MetadataKind.Ecma335; - return; - } - - var runtime_version = module.RuntimeVersion; - - if (!runtime_version.Contains ("WindowsRuntime")) - module.MetadataKind = MetadataKind.Ecma335; - else if (runtime_version.Contains ("CLR")) - module.MetadataKind = MetadataKind.ManagedWindowsMetadata; - else - module.MetadataKind = MetadataKind.WindowsMetadata; - } - - 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 { - - bool resolve_attributes; - - public ImmediateModuleReader (Image image) - : base (image, ReadingMode.Immediate) - { - } - - protected override void ReadModule () - { - this.module.Read (this.module, (module, reader) => { - ReadModuleManifest (reader); - ReadModule (module, resolve_attributes: true); - }); - } - - public void ReadModule (ModuleDefinition module, bool resolve_attributes) - { - this.resolve_attributes = resolve_attributes; - - if (module.HasAssemblyReferences) - Mixin.Read (module.AssemblyReferences); - if (module.HasResources) - Mixin.Read (module.Resources); - if (module.HasModuleReferences) - Mixin.Read (module.ModuleReferences); - if (module.HasTypes) - ReadTypes (module.Types); - if (module.HasExportedTypes) - Mixin.Read (module.ExportedTypes); - - ReadCustomAttributes (module); - - var assembly = module.Assembly; - if (assembly == null) - return; - - ReadCustomAttributes (assembly); - ReadSecurityDeclarations (assembly); - } - - void ReadTypes (Collection types) - { - for (int i = 0; i < types.Count; i++) - ReadType (types [i]); - } - - void ReadType (TypeDefinition type) - { - ReadGenericParameters (type); - - if (type.HasInterfaces) - ReadInterfaces (type); - - if (type.HasNestedTypes) - ReadTypes (type.NestedTypes); - - if (type.HasLayoutInfo) - Mixin.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); - } - - void ReadInterfaces (TypeDefinition type) - { - var interfaces = type.Interfaces; - - for (int i = 0; i < interfaces.Count; i++) - ReadCustomAttributes (interfaces [i]); - } - - 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) - Mixin.Read (parameter.Constraints); - - ReadCustomAttributes (parameter); - } - } - - void ReadSecurityDeclarations (ISecurityDeclarationProvider provider) - { - if (!provider.HasSecurityDeclarations) - return; - - var security_declarations = provider.SecurityDeclarations; - - if (!resolve_attributes) - return; - - for (int i = 0; i < security_declarations.Count; i++) { - var security_declaration = security_declarations [i]; - - Mixin.Read (security_declaration.SecurityAttributes); - } - } - - void ReadCustomAttributes (ICustomAttributeProvider provider) - { - if (!provider.HasCustomAttributes) - return; - - var custom_attributes = provider.CustomAttributes; - - if (!resolve_attributes) - return; - - for (int i = 0; i < custom_attributes.Count; i++) { - var custom_attribute = custom_attributes [i]; - - Mixin.Read (custom_attribute.ConstructorArguments); - } - } - - void ReadFields (TypeDefinition type) - { - var fields = type.Fields; - - for (int i = 0; i < fields.Count; i++) { - var field = fields [i]; - - if (field.HasConstant) - Mixin.Read (field.Constant); - - if (field.HasLayoutInfo) - Mixin.Read (field.Offset); - - if (field.RVA > 0) - Mixin.Read (field.InitialValue); - - if (field.HasMarshalInfo) - Mixin.Read (field.MarshalInfo); - - ReadCustomAttributes (field); - } - } - - 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) - Mixin.Read (method.Overrides); - - if (method.IsPInvokeImpl) - Mixin.Read (method.PInvokeInfo); - - ReadSecurityDeclarations (method); - ReadCustomAttributes (method); - - var return_type = method.MethodReturnType; - if (return_type.HasConstant) - Mixin.Read (return_type.Constant); - - if (return_type.HasMarshalInfo) - Mixin.Read (return_type.MarshalInfo); - - ReadCustomAttributes (return_type); - } - } - - void ReadParameters (MethodDefinition method) - { - var parameters = method.Parameters; - - for (int i = 0; i < parameters.Count; i++) { - var parameter = parameters [i]; - - if (parameter.HasConstant) - Mixin.Read (parameter.Constant); - - if (parameter.HasMarshalInfo) - Mixin.Read (parameter.MarshalInfo); - - ReadCustomAttributes (parameter); - } - } - - void ReadProperties (TypeDefinition type) - { - var properties = type.Properties; - - for (int i = 0; i < properties.Count; i++) { - var property = properties [i]; - - Mixin.Read (property.GetMethod); - - if (property.HasConstant) - Mixin.Read (property.Constant); - - ReadCustomAttributes (property); - } - } - - void ReadEvents (TypeDefinition type) - { - var events = type.Events; - - for (int i = 0; i < events.Count; i++) { - var @event = events [i]; - - Mixin.Read (@event.AddMethod); - - ReadCustomAttributes (@event); - } - } - - public override void ReadSymbols (ModuleDefinition module) - { - if (module.symbol_reader == null) - return; - - ReadTypesSymbols (module.Types, module.symbol_reader); - } - - void ReadTypesSymbols (Collection types, ISymbolReader symbol_reader) - { - for (int i = 0; i < types.Count; i++) { - var type = types [i]; - - if (type.HasNestedTypes) - ReadTypesSymbols (type.NestedTypes, symbol_reader); - - if (type.HasMethods) - ReadMethodsSymbols (type, symbol_reader); - } - } - - void ReadMethodsSymbols (TypeDefinition type, ISymbolReader symbol_reader) - { - var methods = type.Methods; - for (int i = 0; i < methods.Count; i++) { - var method = methods [i]; - - if (method.HasBody && method.token.RID != 0 && method.debug_info == null) - method.debug_info = symbol_reader.Read (method); - } - } - } - - sealed class DeferredModuleReader : ModuleReader { - - public DeferredModuleReader (Image image) - : base (image, ReadingMode.Deferred) - { - } - - protected override void ReadModule () - { - this.module.Read (this.module, (_, reader) => ReadModuleManifest (reader)); - } - - public override void ReadSymbols (ModuleDefinition module) - { - } - } - - sealed class MetadataReader : ByteBuffer { - - readonly internal Image image; - readonly internal ModuleDefinition module; - readonly internal MetadataSystem metadata; - - internal CodeReader code; - internal IGenericContext context; - - readonly MetadataReader metadata_reader; - - public MetadataReader (ModuleDefinition module) - : base (module.Image.TableHeap.data) - { - this.image = module.Image; - this.module = module; - this.metadata = module.MetadataSystem; - this.code = new CodeReader (this); - } - - public MetadataReader (Image image, ModuleDefinition module, MetadataReader metadata_reader) - : base (image.TableHeap.data) - { - this.image = image; - this.module = module; - this.metadata = module.MetadataSystem; - this.metadata_reader = metadata_reader; - } - - 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.Array; - } - - return blob_heap.Read (ReadBlobIndex ()); - } - - byte [] ReadBlob (uint signature) - { - var blob_heap = image.BlobHeap; - if (blob_heap == null) - return Empty.Array; - - return blob_heap.Read (signature); - } - - uint ReadBlobIndex () - { - var blob_heap = image.BlobHeap; - return ReadByIndexSize (blob_heap != null ? blob_heap.IndexSize : 2); - } - - void GetBlobView (uint signature, out byte [] blob, out int index, out int count) - { - var blob_heap = image.BlobHeap; - if (blob_heap == null) { - blob = null; - index = count = 0; - return; - } - - blob_heap.GetView (signature, out blob, out index, out count); - } - - string ReadString () - { - return image.StringHeap.Read (ReadByIndexSize (image.StringHeap.IndexSize)); - } - - uint ReadStringIndex () - { - return ReadByIndexSize (image.StringHeap.IndexSize); - } - - Guid ReadGuid () - { - return image.GuidHeap.Read (ReadByIndexSize (image.GuidHeap.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) - this.position = (int) 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; - - this.position = (int) (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 = ReadGuid (); - - return module; - } - - void InitializeAssemblyReferences () - { - if (metadata.AssemblyReferences != null) - return; - - int length = MoveTo (Table.AssemblyRef); - var references = metadata.AssemblyReferences = new AssemblyNameReference [length]; - - for (uint i = 0; i < length; i++) { - var reference = new AssemblyNameReference (); - reference.token = new MetadataToken (TokenType.AssemblyRef, i + 1); - - PopulateVersionAndFlags (reference); - - var key_or_token = ReadBlob (); - - if (reference.HasPublicKey) - reference.PublicKey = key_or_token; - else - reference.PublicKeyToken = key_or_token; - - PopulateNameAndCulture (reference); - - reference.Hash = ReadBlob (); - - references [i] = reference; - } - } - - public Collection ReadAssemblyReferences () - { - InitializeAssemblyReferences (); - - var references = new Collection (metadata.AssemblyReferences); - if (module.IsWindowsMetadata ()) - module.Projections.AddVirtualReferences (references); - - return references; - } - - public MethodDefinition ReadEntryPoint () - { - if (module.Image.EntryPointToken == 0) - return null; - - var token = new MetadataToken (module.Image.EntryPointToken); - return GetMethodDefinition (token.RID); - } - - public Collection ReadModules () - { - var modules = new Collection (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, - AssemblyResolver = module.AssemblyResolver - }; - - modules.Add (ModuleDefinition.ReadModule ( - GetModuleFileName (name), parameters)); - } - - return modules; - } - - string GetModuleFileName (string name) - { - if (module.FileName == null) - throw new NotSupportedException (); - - var path = Path.GetDirectoryName (module.FileName); - return Path.Combine (path, name); - } - - void InitializeModuleReferences () - { - if (metadata.ModuleReferences != null) - return; - - int length = MoveTo (Table.ModuleRef); - var references = metadata.ModuleReferences = new ModuleReference [length]; - - for (uint i = 0; i < length; i++) { - var reference = new ModuleReference (ReadString ()); - reference.token = new MetadataToken (TokenType.ModuleRef, i + 1); - - references [i] = reference; - } - } - - public Collection ReadModuleReferences () - { - InitializeModuleReferences (); - - return new Collection (metadata.ModuleReferences); - } - - 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 ReadResources () - { - int length = MoveTo (Table.ManifestResource); - var resources = new Collection (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 - continue; - - resources.Add (resource); - } - - return resources; - } - - Row ReadFileRecord (uint rid) - { - var position = this.position; - - if (!MoveTo (Table.File, rid)) - throw new ArgumentException (); - - var record = new Row ( - (FileAttributes) ReadUInt32 (), - ReadString (), - ReadBlobIndex ()); - - this.position = position; - - return record; - } - - public byte [] GetManagedResource (uint offset) - { - return image.GetReaderAt (image.Resources.VirtualAddress, offset, (o, reader) => { - reader.Advance ((int) o); - return reader.ReadBytes (reader.ReadInt32 ()); - }) ?? Empty.Array; - } - - 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); - } - - if (image.HasTable (Table.MethodPtr) || image.HasTable (Table.FieldPtr)) - CompleteTypes (); - - return types; - } - - void CompleteTypes () - { - var types = metadata.Types; - - for (int i = 0; i < types.Length; i++) { - var type = types [i]; - - Mixin.Read (type.Fields); - Mixin.Read (type.Methods); - } - } - - 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) - { - Collection mapping; - InitializeNestedTypes (); - - if (!metadata.TryGetNestedTypeMapping (type, out mapping)) - return false; - - return mapping.Count > 0; - } - - public Collection ReadNestedTypes (TypeDefinition type) - { - InitializeNestedTypes (); - Collection mapping; - if (!metadata.TryGetNestedTypeMapping (type, out mapping)) - return new MemberDefinitionCollection (type); - - var nested_types = new MemberDefinitionCollection (type, mapping.Count); - - for (int i = 0; i < mapping.Count; i++) { - var nested_type = GetTypeDefinition (mapping [i]); - - if (nested_type != null) - nested_types.Add (nested_type); - } - - metadata.RemoveNestedTypeMapping (type); - - return nested_types; - } - - void InitializeNestedTypes () - { - if (metadata.NestedTypes != null) - return; - - var length = MoveTo (Table.NestedClass); - - metadata.NestedTypes = new Dictionary> (length); - metadata.ReverseNestedTypes = new Dictionary (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 Collection AddMapping (Dictionary> cache, TKey key, TValue value) - { - Collection mapped; - if (!cache.TryGetValue (key, out mapped)) { - mapped = new Collection (); - } - mapped.Add (value); - return 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 = ReadListRange (rid, Table.TypeDef, Table.Field); - type.methods_range = ReadListRange (rid, Table.TypeDef, Table.Method); - - if (IsNested (attributes)) - type.DeclaringType = GetNestedTypeDeclaringType (type); - - if (module.IsWindowsMetadata ()) - WindowsRuntimeProjections.Project (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 ReadListRange (uint current_index, Table current, Table target) - { - var list = new Range (); - - var start = ReadTableIndex (target); - if (start == 0) - return list; - - 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 = this.position; - this.position += (int) (current_table.RowSize - image.GetTableIndexSize (target)); - next_index = ReadTableIndex (target); - this.position = position; - } - - list.Start = start; - list.Length = next_index - start; - - return list; - } - - public Row ReadTypeLayout (TypeDefinition type) - { - InitializeTypeLayouts (); - Row class_layout; - var rid = type.token.RID; - if (!metadata.ClassLayouts.TryGetValue (rid, out class_layout)) - return new Row (Mixin.NoDataMarker, Mixin.NoDataMarker); - - type.PackingSize = (short) class_layout.Col1; - type.ClassSize = (int) class_layout.Col2; - - metadata.ClassLayouts.Remove (rid); - - return new Row ((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> (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 (packing_size, class_size)); - } - } - - public TypeReference GetTypeDefOrRef (MetadataToken token) - { - return (TypeReference) LookupToken (token); - } - - public 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; - - return ReadTypeReference (rid); - } - - TypeReference ReadTypeReference (uint rid) - { - if (!MoveTo (Table.TypeRef, rid)) - return null; - - TypeReference declaring_type = null; - IMetadataScope scope; - - var scope_token = ReadMetadataToken (CodedIndex.ResolutionScope); - - var name = ReadString (); - var @namespace = ReadString (); - - var type = new TypeReference ( - @namespace, - name, - module, - null); - - type.token = new MetadataToken (TokenType.TypeRef, rid); - - metadata.AddTypeReference (type); - - if (scope_token.TokenType == TokenType.TypeRef) { - declaring_type = GetTypeDefOrRef (scope_token); - - scope = declaring_type != null - ? declaring_type.Scope - : module; - } else - scope = GetTypeReferenceScope (scope_token); - - type.scope = scope; - type.DeclaringType = declaring_type; - - MetadataSystem.TryProcessPrimitiveTypeReference (type); - - if (type.Module.IsWindowsMetadata ()) - WindowsRuntimeProjections.Project (type); - - return type; - } - - IMetadataScope GetTypeReferenceScope (MetadataToken scope) - { - if (scope.TokenType == TokenType.Module) - return module; - - IMetadataScope[] scopes; - - switch (scope.TokenType) { - case TokenType.AssemblyRef: - InitializeAssemblyReferences (); - scopes = metadata.AssemblyReferences; - break; - case TokenType.ModuleRef: - InitializeModuleReferences (); - scopes = metadata.ModuleReferences; - break; - default: - throw new NotSupportedException (); - } - - var index = scope.RID - 1; - if (index < 0 || index >= scopes.Length) - return null; - - return scopes [index]; - } - - public IEnumerable 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 ()); - var type = reader.ReadTypeSignature (); - if (type.token.RID == 0) - type.token = new MetadataToken (TokenType.TypeSpec, rid); - - return type; - } - - SignatureReader ReadSignature (uint signature) - { - return new SignatureReader (signature, this); - } - - public bool HasInterfaces (TypeDefinition type) - { - InitializeInterfaces (); - Collection> mapping; - - return metadata.TryGetInterfaceMapping (type, out mapping); - } - - public InterfaceImplementationCollection ReadInterfaces (TypeDefinition type) - { - InitializeInterfaces (); - Collection> mapping; - - if (!metadata.TryGetInterfaceMapping (type, out mapping)) - return new InterfaceImplementationCollection (type); - - var interfaces = new InterfaceImplementationCollection (type, mapping.Count); - - this.context = type; - - for (int i = 0; i < mapping.Count; i++) { - interfaces.Add ( - new InterfaceImplementation ( - GetTypeDefOrRef (mapping [i].Col2), - new MetadataToken(TokenType.InterfaceImpl, mapping [i].Col1))); - } - - metadata.RemoveInterfaceMapping (type); - - return interfaces; - } - - void InitializeInterfaces () - { - if (metadata.Interfaces != null) - return; - - int length = MoveTo (Table.InterfaceImpl); - - metadata.Interfaces = new Dictionary>> (length); - - for (uint i = 1; i <= length; i++) { - var type = ReadTableIndex (Table.TypeDef); - var @interface = ReadMetadataToken (CodedIndex.TypeDefOrRef); - - AddInterfaceMapping (type, new Row (i, @interface)); - } - } - - void AddInterfaceMapping (uint type, Row @interface) - { - metadata.SetInterfaceMapping (type, AddMapping (metadata.Interfaces, type, @interface)); - } - - public Collection ReadFields (TypeDefinition type) - { - var fields_range = type.fields_range; - if (fields_range.Length == 0) - return new MemberDefinitionCollection (type); - - var fields = new MemberDefinitionCollection (type, (int) fields_range.Length); - this.context = type; - - if (!MoveTo (Table.FieldPtr, fields_range.Start)) { - if (!MoveTo (Table.Field, fields_range.Start)) - return fields; - - for (uint i = 0; i < fields_range.Length; i++) - ReadField (fields_range.Start + i, fields); - } else - ReadPointers (Table.FieldPtr, Table.Field, fields_range, fields, ReadField); - - return fields; - } - - void ReadField (uint field_rid, Collection fields) - { - 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); - - if (IsDeleted (field)) - return; - - fields.Add (field); - - if (module.IsWindowsMetadata ()) - WindowsRuntimeProjections.Project (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) - { - return image.GetReaderAt (rva, size, (s, reader) => reader.ReadBytes (s)) ?? Empty.Array; - } - - 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.Resolve (); - if (field_type != null && 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 (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 (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 ReadEvents (TypeDefinition type) - { - InitializeEvents (); - Range range; - - if (!metadata.TryGetEventsRange (type, out range)) - return new MemberDefinitionCollection (type); - - var events = new MemberDefinitionCollection (type, (int) range.Length); - - metadata.RemoveEventsRange (type); - - if (range.Length == 0) - return events; - - this.context = type; - - if (!MoveTo (Table.EventPtr, range.Start)) { - if (!MoveTo (Table.Event, range.Start)) - return events; - - for (uint i = 0; i < range.Length; i++) - ReadEvent (range.Start + i, events); - } else - ReadPointers (Table.EventPtr, Table.Event, range, events, ReadEvent); - - return events; - } - - void ReadEvent (uint event_rid, Collection events) - { - 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); - - if (IsDeleted (@event)) - return; - - events.Add (@event); - } - - void InitializeEvents () - { - if (metadata.Events != null) - return; - - int length = MoveTo (Table.EventMap); - - metadata.Events = new Dictionary (length); - - for (uint i = 1; i <= length; i++) { - var type_rid = ReadTableIndex (Table.TypeDef); - Range events_range = ReadListRange (i, Table.EventMap, Table.Event); - metadata.AddEventsRange (type_rid, events_range); - } - } - - public bool HasProperties (TypeDefinition type) - { - InitializeProperties (); - - Range range; - if (!metadata.TryGetPropertiesRange (type, out range)) - return false; - - return range.Length > 0; - } - - public Collection ReadProperties (TypeDefinition type) - { - InitializeProperties (); - - Range range; - - if (!metadata.TryGetPropertiesRange (type, out range)) - return new MemberDefinitionCollection (type); - - metadata.RemovePropertiesRange (type); - - var properties = new MemberDefinitionCollection (type, (int) range.Length); - - if (range.Length == 0) - return properties; - - this.context = type; - - if (!MoveTo (Table.PropertyPtr, range.Start)) { - if (!MoveTo (Table.Property, range.Start)) - return properties; - for (uint i = 0; i < range.Length; i++) - ReadProperty (range.Start + i, properties); - } else - ReadPointers (Table.PropertyPtr, Table.Property, range, properties, ReadProperty); - - return properties; - } - - void ReadProperty (uint property_rid, Collection properties) - { - 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); - - if (IsDeleted (property)) - return; - - properties.Add (property); - } - - void InitializeProperties () - { - if (metadata.Properties != null) - return; - - int length = MoveTo (Table.PropertyMap); - - metadata.Properties = new Dictionary (length); - - for (uint i = 1; i <= length; i++) { - var type_rid = ReadTableIndex (Table.TypeDef); - var properties_range = ReadListRange (i, Table.PropertyMap, Table.Property); - metadata.AddPropertiesRange (type_rid, properties_range); - } - } - - MethodSemanticsAttributes ReadMethodSemantics (MethodDefinition method) - { - InitializeMethodSemantics (); - Row row; - if (!metadata.Semantics.TryGetValue (method.token.RID, out row)) - return MethodSemanticsAttributes.None; - - 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 (); - - @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 (); - - 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 (Collection 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> (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 (attributes, association); - } - } - - public void ReadMethods (PropertyDefinition property) - { - ReadAllSemantics (property.DeclaringType); - } - - public void ReadMethods (EventDefinition @event) - { - ReadAllSemantics (@event.DeclaringType); - } - - public void ReadAllSemantics (MethodDefinition method) - { - ReadAllSemantics (method.DeclaringType); - } - - void ReadAllSemantics (TypeDefinition type) - { - var methods = type.Methods; - for (int i = 0; i < methods.Count; i++) { - var method = methods [i]; - if (method.sem_attrs_ready) - continue; - - method.sem_attrs = ReadMethodSemantics (method); - method.sem_attrs_ready = true; - } - } - - public Collection ReadMethods (TypeDefinition type) - { - var methods_range = type.methods_range; - if (methods_range.Length == 0) - return new MemberDefinitionCollection (type); - - var methods = new MemberDefinitionCollection (type, (int) methods_range.Length); - if (!MoveTo (Table.MethodPtr, methods_range.Start)) { - if (!MoveTo (Table.Method, methods_range.Start)) - return methods; - - for (uint i = 0; i < methods_range.Length; i++) - ReadMethod (methods_range.Start + i, methods); - } else - ReadPointers (Table.MethodPtr, Table.Method, methods_range, methods, ReadMethod); - - return methods; - } - - void ReadPointers (Table ptr, Table table, Range range, Collection members, Action> reader) - where TMember : IMemberDefinition - { - for (uint i = 0; i < range.Length; i++) { - MoveTo (ptr, range.Start + i); - - var rid = ReadTableIndex (table); - MoveTo (table, rid); - - reader (rid, members); - } - } - - static bool IsDeleted (IMemberDefinition member) - { - return member.IsSpecialName && member.Name == "_Deleted"; - } - - void InitializeMethods () - { - if (metadata.Methods != null) - return; - - metadata.Methods = new MethodDefinition [image.GetTableLength (Table.Method)]; - } - - void ReadMethod (uint method_rid, Collection 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); - - if (IsDeleted (method)) - return; - - methods.Add (method); // attach method - - var signature = ReadBlobIndex (); - var param_range = ReadListRange (method_rid, Table.Method, Table.Param); - - this.context = method; - - ReadMethodSignature (signature, method); - metadata.AddMethodDefinition (method); - - if (param_range.Length != 0) { - var position = base.position; - ReadParameters (method, param_range); - base.position = position; - } - - if (module.IsWindowsMetadata ()) - WindowsRuntimeProjections.Project (method); - } - - void ReadParameters (MethodDefinition method, Range param_range) - { - if (!MoveTo (Table.ParamPtr, param_range.Start)) { - if (!MoveTo (Table.Param, param_range.Start)) - return; - - for (uint i = 0; i < param_range.Length; i++) - ReadParameter (param_range.Start + i, method); - } else - ReadParameterPointers (method, param_range); - } - - void ReadParameterPointers (MethodDefinition method, Range range) - { - for (uint i = 0; i < range.Length; i++) { - MoveTo (Table.ParamPtr, range.Start + i); - - var rid = ReadTableIndex (Table.Param); - - MoveTo (Table.Param, rid); - - ReadParameter (rid, method); - } - } - - void ReadParameter (uint param_rid, MethodDefinition method) - { - var attributes = (ParameterAttributes) ReadUInt16 (); - var sequence = ReadUInt16 (); - var name = ReadString (); - - var parameter = sequence == 0 - ? method.MethodReturnType.Parameter - : method.Parameters [sequence - 1]; - - parameter.token = new MetadataToken (TokenType.Param, param_rid); - parameter.Name = name; - parameter.Attributes = attributes; - } - - void ReadMethodSignature (uint signature, IMethodSignature method) - { - var reader = ReadSignature (signature); - reader.ReadMethodSignature (method); - } - - public PInvokeInfo ReadPInvokeInfo (MethodDefinition method) - { - InitializePInvokes (); - Row 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> (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 (attributes, name, scope)); - } - } - - public bool HasGenericParameters (IGenericParameterProvider provider) - { - InitializeGenericParameters (); - - Range [] ranges; - if (!metadata.TryGetGenericParameterRanges (provider, out ranges)) - return false; - - return RangesSize (ranges) > 0; - } - - public Collection ReadGenericParameters (IGenericParameterProvider provider) - { - InitializeGenericParameters (); - - Range [] ranges; - if (!metadata.TryGetGenericParameterRanges (provider, out ranges)) - return new GenericParameterCollection (provider); - - metadata.RemoveGenericParameterRange (provider); - - var generic_parameters = new GenericParameterCollection (provider, RangesSize (ranges)); - - for (int i = 0; i < ranges.Length; i++) - ReadGenericParametersRange (ranges [i], provider, generic_parameters); - - return generic_parameters; - } - - void ReadGenericParametersRange (Range range, IGenericParameterProvider provider, GenericParameterCollection generic_parameters) - { - if (!MoveTo (Table.GenericParam, range.Start)) - return; - - 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); - } - } - - void InitializeGenericParameters () - { - if (metadata.GenericParameters != null) - return; - - metadata.GenericParameters = InitializeRanges ( - Table.GenericParam, () => { - Advance (4); - var next = ReadMetadataToken (CodedIndex.TypeOrMethodDef); - ReadStringIndex (); - return next; - }); - } - - Dictionary InitializeRanges (Table table, Func get_next) - { - int length = MoveTo (table); - var ranges = new Dictionary (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) { - AddRange (ranges, owner, range); - range = new Range (i, 1); - owner = next; - } else - range.Length++; - } - - AddRange (ranges, owner, range); - - return ranges; - } - - static void AddRange (Dictionary ranges, MetadataToken owner, Range range) - { - if (owner.RID == 0) - return; - - Range [] slots; - if (!ranges.TryGetValue (owner, out slots)) { - ranges.Add (owner, new [] { range }); - return; - } - - ranges [owner] = slots.Add(range); - } - - public bool HasGenericConstraints (GenericParameter generic_parameter) - { - InitializeGenericConstraints (); - - Collection mapping; - if (!metadata.TryGetGenericConstraintMapping (generic_parameter, out mapping)) - return false; - - return mapping.Count > 0; - } - - public Collection ReadGenericConstraints (GenericParameter generic_parameter) - { - InitializeGenericConstraints (); - - Collection mapping; - if (!metadata.TryGetGenericConstraintMapping (generic_parameter, out mapping)) - return new Collection (); - - var constraints = new Collection (mapping.Count); - - this.context = (IGenericContext) generic_parameter.Owner; - - for (int i = 0; i < mapping.Count; 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> (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 (); - Collection mapping; - - if (!metadata.TryGetOverrideMapping (method, out mapping)) - return false; - - return mapping.Count > 0; - } - - public Collection ReadOverrides (MethodDefinition method) - { - InitializeOverrides (); - - Collection mapping; - if (!metadata.TryGetOverrideMapping (method, out mapping)) - return new Collection (); - - var overrides = new Collection (mapping.Count); - - this.context = method; - - for (int i = 0; i < mapping.Count; 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> (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 int ReadCodeSize (MethodDefinition method) - { - return code.ReadCodeSize (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); - - call_site.MetadataToken = token; - - 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; - - if (metadata_reader != null) - return metadata_reader.LookupToken (token); - - 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: - return null; - } - - 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) - return null; - - Mixin.Read (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) - return null; - - Mixin.Read (type.Methods); - - return metadata.GetMethodDefinition (rid); - } - - MethodSpecification GetMethodSpecification (uint rid) - { - if (!MoveTo (Table.MethodSpec, rid)) - return null; - - var element_method = (MethodReference) LookupToken ( - ReadMetadataToken (CodedIndex.MethodDefOrRef)); - var signature = ReadBlobIndex (); - - var method_spec = ReadMethodSpecSignature (signature, element_method); - method_spec.token = new MetadataToken (TokenType.MethodSpec, rid); - return method_spec; - } - - 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 != null && !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); - - if (module.IsWindowsMetadata ()) - WindowsRuntimeProjections.Project (member); - - return member; - } - - MemberReference ReadTypeMemberReference (MetadataToken type, string name, uint signature) - { - var declaring_type = GetTypeDefOrRef (type); - - if (!declaring_type.IsArray) - 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 GetMemberReferences () - { - InitializeMemberReferences (); - - var length = image.GetTableLength (Table.MemberRef); - - var type_system = module.TypeSystem; - - var context = new MethodDefinition (string.Empty, MethodAttributes.Static, type_system.Void); - context.DeclaringType = new TypeDefinition (string.Empty, string.Empty, TypeAttributes.Public); - - 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> (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 (type, signature)); - } - } - - public TypeReference ReadConstantSignature (MetadataToken token) - { - if (token.TokenType != TokenType.Signature) - throw new NotSupportedException (); - - if (!MoveTo (Table.StandAloneSig, token.RID)) - return null; - - return ReadFieldType (ReadBlobIndex ()); - } - - public object ReadConstant (IConstantProvider owner) - { - InitializeConstants (); - - Row row; - if (!metadata.Constants.TryGetValue (owner.MetadataToken, out row)) - return Mixin.NoValue; - - metadata.Constants.Remove (owner.MetadataToken); - - return ReadConstantValue (row.Col1, row.Col2); - } - - object ReadConstantValue (ElementType etype, uint signature) - { - switch (etype) { - case ElementType.Class: - case ElementType.Object: - return null; - case ElementType.String: - return ReadConstantString (signature); - default: - return ReadConstantPrimitive (etype, signature); - } - } - - string ReadConstantString (uint signature) - { - byte [] blob; - int index, count; - - GetBlobView (signature, out blob, out index, out count); - if (count == 0) - return string.Empty; - - if ((count & 1) == 1) - count--; - - return Encoding.Unicode.GetString (blob, index, count); - } - - object ReadConstantPrimitive (ElementType type, uint signature) - { - var reader = ReadSignature (signature); - return reader.ReadConstantSignature (type); - } - - internal 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 [] ranges; - if (!metadata.TryGetCustomAttributeRanges (owner, out ranges)) - return false; - - return RangesSize (ranges) > 0; - } - - public Collection ReadCustomAttributes (ICustomAttributeProvider owner) - { - InitializeCustomAttributes (); - - Range [] ranges; - if (!metadata.TryGetCustomAttributeRanges (owner, out ranges)) - return new Collection (); - - var custom_attributes = new Collection (RangesSize (ranges)); - - for (int i = 0; i < ranges.Length; i++) - ReadCustomAttributeRange (ranges [i], custom_attributes); - - metadata.RemoveCustomAttributeRange (owner); - - if (module.IsWindowsMetadata ()) - foreach (var custom_attribute in custom_attributes) - WindowsRuntimeProjections.Project (owner, custom_attribute); - - return custom_attributes; - } - - void ReadCustomAttributeRange (Range range, Collection custom_attributes) - { - if (!MoveTo (Table.CustomAttribute, range.Start)) - return; - - for (var 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)); - } - } - - static int RangesSize (Range [] ranges) - { - uint size = 0; - for (int i = 0; i < ranges.Length; i++) - size += ranges [i].Length; - - return (int) size; - } - - public IEnumerable GetCustomAttributes () - { - InitializeTypeDefinitions (); - - var length = image.TableHeap [Table.CustomAttribute].Length; - var custom_attributes = new Collection ((int) length); - ReadCustomAttributeRange (new Range (1, length), custom_attributes); - - return custom_attributes; - } - - public byte [] ReadCustomAttributeBlob (uint signature) - { - return ReadBlob (signature); - } - - public void ReadCustomAttributeSignature (CustomAttribute attribute) - { - var reader = ReadSignature (attribute.signature); - - if (!reader.CanReadMore ()) - return; - - 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 (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 [] ranges; - if (!metadata.TryGetSecurityDeclarationRanges (owner, out ranges)) - return false; - - return RangesSize (ranges) > 0; - } - - public Collection ReadSecurityDeclarations (ISecurityDeclarationProvider owner) - { - InitializeSecurityDeclarations (); - - Range [] ranges; - if (!metadata.TryGetSecurityDeclarationRanges (owner, out ranges)) - return new Collection (); - - var security_declarations = new Collection (RangesSize (ranges)); - - for (int i = 0; i < ranges.Length; i++) - ReadSecurityDeclarationRange (ranges [i], security_declarations); - - metadata.RemoveSecurityDeclarationRange (owner); - - return security_declarations; - } - - void ReadSecurityDeclarationRange (Range range, Collection security_declarations) - { - if (!MoveTo (Table.DeclSecurity, range.Start)) - return; - - 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)); - } - } - - 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.position++; - var count = reader.ReadCompressedUInt32 (); - var attributes = new Collection ((int) count); - - for (int i = 0; i < count; i++) - attributes.Add (reader.ReadSecurityAttribute ()); - - declaration.security_attributes = attributes; - } - - void ReadXmlSecurityDeclaration (uint signature, SecurityDeclaration declaration) - { - var attributes = new Collection (1); - - var attribute = new SecurityAttribute ( - module.TypeSystem.LookupType ("System.Security.Permissions", "PermissionSetAttribute")); - - attribute.properties = new Collection (1); - attribute.properties.Add ( - new CustomAttributeNamedArgument ( - "XML", - new CustomAttributeArgument ( - module.TypeSystem.String, - ReadUnicodeStringBlob (signature)))); - - attributes.Add (attribute); - - declaration.security_attributes = attributes; - } - - public Collection ReadExportedTypes () - { - var length = MoveTo (Table.ExportedType); - if (length == 0) - return new Collection (); - - var exported_types = new Collection (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, module, 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) - { - var position = this.position; - IMetadataScope scope; - - switch (token.TokenType) { - case TokenType.AssemblyRef: - InitializeAssemblyReferences (); - scope = metadata.GetAssemblyNameReference (token.RID); - break; - case TokenType.File: - InitializeModuleReferences (); - scope = GetModuleReferenceFromFile (token); - break; - default: - throw new NotSupportedException (); - } - - this.position = position; - return scope; - } - - ModuleReference GetModuleReferenceFromFile (MetadataToken token) - { - if (!MoveTo (Table.File, token.RID)) - return null; - - ReadUInt32 (); - var file_name = ReadString (); - var modules = module.ModuleReferences; - - ModuleReference reference; - for (int i = 0; i < modules.Count; i++) { - reference = modules [i]; - if (reference.Name == file_name) - return reference; - } - - reference = new ModuleReference (file_name); - modules.Add (reference); - return reference; - } - - void InitializeDocuments () - { - if (metadata.Documents != null) - return; - - int length = MoveTo (Table.Document); - - var documents = metadata.Documents = new Document [length]; - - for (uint i = 1; i <= length; i++) { - var name_index = ReadBlobIndex (); - var hash_algorithm = ReadGuid (); - var hash = ReadBlob (); - var language = ReadGuid (); - - var signature = ReadSignature (name_index); - var name = signature.ReadDocumentName (); - - documents [i - 1] = new Document (name) { - HashAlgorithm = hash_algorithm.ToHashAlgorithm (), - Hash = hash, - Language = language.ToLanguage (), - token = new MetadataToken (TokenType.Document, i), - }; - } - } - - public Collection ReadSequencePoints (MethodDefinition method) - { - InitializeDocuments (); - - if (!MoveTo (Table.MethodDebugInformation, method.MetadataToken.RID)) - return new Collection (0); - - var document_index = ReadTableIndex (Table.Document); - var signature = ReadBlobIndex (); - if (signature == 0) - return new Collection (0); - - var document = GetDocument (document_index); - var reader = ReadSignature (signature); - - return reader.ReadSequencePoints (document); - } - - public Document GetDocument (uint rid) - { - var document = metadata.GetDocument (rid); - if (document == null) - return null; - - document.custom_infos = GetCustomDebugInformation (document); - return document; - } - - void InitializeLocalScopes () - { - if (metadata.LocalScopes != null) - return; - - InitializeMethods (); - - int length = MoveTo (Table.LocalScope); - - metadata.LocalScopes = new Dictionary>> (); - - for (uint i = 1; i <= length; i++) { - var method = ReadTableIndex (Table.Method); - var import = ReadTableIndex (Table.ImportScope); - var variables = ReadListRange (i, Table.LocalScope, Table.LocalVariable); - var constants = ReadListRange (i, Table.LocalScope, Table.LocalConstant); - var scope_start = ReadUInt32 (); - var scope_length = ReadUInt32 (); - - metadata.SetLocalScopes (method, AddMapping (metadata.LocalScopes, method, new Row (import, variables, constants, scope_start, scope_length, i))); - } - } - - public ScopeDebugInformation ReadScope (MethodDefinition method) - { - InitializeLocalScopes (); - InitializeImportScopes (); - - Collection> records; - if (!metadata.TryGetLocalScopes (method, out records)) - return null; - - var method_scope = null as ScopeDebugInformation; - - for (int i = 0; i < records.Count; i++) { - var scope = ReadLocalScope (records [i]); - - if (i == 0) { - method_scope = scope; - continue; - } - - if (!AddScope (method_scope.scopes, scope)) - method_scope.Scopes.Add (scope); - } - - return method_scope; - } - - static bool AddScope (Collection scopes, ScopeDebugInformation scope) - { - if (scopes.IsNullOrEmpty ()) - return false; - - foreach (var sub_scope in scopes) { - if (sub_scope.HasScopes && AddScope (sub_scope.Scopes, scope)) - return true; - - if (scope.Start.Offset >= sub_scope.Start.Offset && scope.End.Offset <= sub_scope.End.Offset) { - sub_scope.Scopes.Add (scope); - return true; - } - } - - return false; - } - - ScopeDebugInformation ReadLocalScope (Row record) - { - var scope = new ScopeDebugInformation - { - start = new InstructionOffset ((int) record.Col4), - end = new InstructionOffset ((int) (record.Col4 + record.Col5)), - token = new MetadataToken (TokenType.LocalScope, record.Col6), - }; - - if (record.Col1 > 0) - scope.import = metadata.GetImportScope (record.Col1); - - if (record.Col2.Length > 0) { - scope.variables = new Collection ((int) record.Col2.Length); - for (uint i = 0; i < record.Col2.Length; i++) { - var variable = ReadLocalVariable (record.Col2.Start + i); - if (variable != null) - scope.variables.Add (variable); - } - } - - if (record.Col3.Length > 0) { - scope.constants = new Collection ((int) record.Col3.Length); - for (uint i = 0; i < record.Col3.Length; i++) { - var constant = ReadLocalConstant (record.Col3.Start + i); - if (constant != null) - scope.constants.Add (constant); - } - } - - return scope; - } - - VariableDebugInformation ReadLocalVariable (uint rid) - { - if (!MoveTo (Table.LocalVariable, rid)) - return null; - - var attributes = (VariableAttributes) ReadUInt16 (); - var index = ReadUInt16 (); - var name = ReadString (); - - var variable = new VariableDebugInformation (index, name) { Attributes = attributes, token = new MetadataToken (TokenType.LocalVariable, rid) }; - variable.custom_infos = GetCustomDebugInformation (variable); - return variable; - } - - ConstantDebugInformation ReadLocalConstant (uint rid) - { - if (!MoveTo (Table.LocalConstant, rid)) - return null; - - var name = ReadString (); - var signature = ReadSignature (ReadBlobIndex ()); - var type = signature.ReadTypeSignature (); - - object value; - if (type.etype == ElementType.String) { - if (signature.buffer [signature.position] != 0xff) { - var bytes = signature.ReadBytes ((int) (signature.sig_length - (signature.position - signature.start))); - value = Encoding.Unicode.GetString (bytes, 0, bytes.Length); - } else - value = null; - } else if (type.IsTypeOf ("System", "Decimal")) { - var b = signature.ReadByte (); - value = new decimal (signature.ReadInt32 (), signature.ReadInt32 (), signature.ReadInt32 (), (b & 0x80) != 0, (byte) (b & 0x7f)); - } else if (type.IsTypeOf ("System", "DateTime")) { - value = new DateTime (signature.ReadInt64()); - } else if (type.etype == ElementType.Object || type.etype == ElementType.None || type.etype == ElementType.Class) { - value = null; - } else - value = signature.ReadConstantSignature (type.etype); - - var constant = new ConstantDebugInformation (name, type, value) { token = new MetadataToken (TokenType.LocalConstant, rid) }; - constant.custom_infos = GetCustomDebugInformation (constant); - return constant; - } - - void InitializeImportScopes () - { - if (metadata.ImportScopes != null) - return; - - var length = MoveTo (Table.ImportScope); - - metadata.ImportScopes = new ImportDebugInformation [length]; - - for (int i = 1; i <= length; i++) { - ReadTableIndex (Table.ImportScope); - - var import = new ImportDebugInformation (); - import.token = new MetadataToken (TokenType.ImportScope, i); - - var signature = ReadSignature (ReadBlobIndex ()); - while (signature.CanReadMore ()) - import.Targets.Add (ReadImportTarget (signature)); - - metadata.ImportScopes [i - 1] = import; - } - - MoveTo (Table.ImportScope); - - for (int i = 0; i < length; i++) { - var parent = ReadTableIndex (Table.ImportScope); - - ReadBlobIndex (); - - if (parent != 0) - metadata.ImportScopes [i].Parent = metadata.GetImportScope (parent); - } - } - - public string ReadUTF8StringBlob (uint signature) - { - return ReadStringBlob (signature, Encoding.UTF8); - } - - string ReadUnicodeStringBlob (uint signature) - { - return ReadStringBlob (signature, Encoding.Unicode); - } - - string ReadStringBlob (uint signature, Encoding encoding) - { - byte [] blob; - int index, count; - - GetBlobView (signature, out blob, out index, out count); - if (count == 0) - return string.Empty; - - return encoding.GetString (blob, index, count); - } - - ImportTarget ReadImportTarget (SignatureReader signature) - { - AssemblyNameReference reference = null; - string @namespace = null; - string alias = null; - TypeReference type = null; - - var kind = (ImportTargetKind) signature.ReadCompressedUInt32 (); - switch (kind) { - case ImportTargetKind.ImportNamespace: - @namespace = ReadUTF8StringBlob (signature.ReadCompressedUInt32 ()); - break; - case ImportTargetKind.ImportNamespaceInAssembly: - reference = metadata.GetAssemblyNameReference (signature.ReadCompressedUInt32 ()); - @namespace = ReadUTF8StringBlob (signature.ReadCompressedUInt32 ()); - break; - case ImportTargetKind.ImportType: - type = signature.ReadTypeToken (); - break; - case ImportTargetKind.ImportXmlNamespaceWithAlias: - alias = ReadUTF8StringBlob (signature.ReadCompressedUInt32 ()); - @namespace = ReadUTF8StringBlob (signature.ReadCompressedUInt32 ()); - break; - case ImportTargetKind.ImportAlias: - alias = ReadUTF8StringBlob (signature.ReadCompressedUInt32 ()); - break; - case ImportTargetKind.DefineAssemblyAlias: - alias = ReadUTF8StringBlob (signature.ReadCompressedUInt32 ()); - reference = metadata.GetAssemblyNameReference (signature.ReadCompressedUInt32 ()); - break; - case ImportTargetKind.DefineNamespaceAlias: - alias = ReadUTF8StringBlob (signature.ReadCompressedUInt32 ()); - @namespace = ReadUTF8StringBlob (signature.ReadCompressedUInt32 ()); - break; - case ImportTargetKind.DefineNamespaceInAssemblyAlias: - alias = ReadUTF8StringBlob (signature.ReadCompressedUInt32 ()); - reference = metadata.GetAssemblyNameReference (signature.ReadCompressedUInt32 ()); - @namespace = ReadUTF8StringBlob (signature.ReadCompressedUInt32 ()); - break; - case ImportTargetKind.DefineTypeAlias: - alias = ReadUTF8StringBlob (signature.ReadCompressedUInt32 ()); - type = signature.ReadTypeToken (); - break; - } - - return new ImportTarget (kind) { - alias = alias, - type = type, - @namespace = @namespace, - reference = reference, - }; - } - - void InitializeStateMachineMethods () - { - if (metadata.StateMachineMethods != null) - return; - - var length = MoveTo (Table.StateMachineMethod); - - metadata.StateMachineMethods = new Dictionary (length); - - for (int i = 0; i < length; i++) - metadata.StateMachineMethods.Add (ReadTableIndex (Table.Method), ReadTableIndex (Table.Method)); - } - - public MethodDefinition ReadStateMachineKickoffMethod (MethodDefinition method) - { - InitializeStateMachineMethods (); - - uint rid; - if (!metadata.TryGetStateMachineKickOffMethod (method, out rid)) - return null; - - return GetMethodDefinition (rid); - } - - void InitializeCustomDebugInformations () - { - if (metadata.CustomDebugInformations != null) - return; - - var length = MoveTo (Table.CustomDebugInformation); - - metadata.CustomDebugInformations = new Dictionary []> (); - - for (uint i = 1; i <= length; i++) { - var token = ReadMetadataToken (CodedIndex.HasCustomDebugInformation); - var info = new Row (ReadGuid (), ReadBlobIndex (), i); - - Row [] infos; - metadata.CustomDebugInformations.TryGetValue (token, out infos); - metadata.CustomDebugInformations [token] = infos.Add (info); - } - } - - public Collection GetCustomDebugInformation (ICustomDebugInformationProvider provider) - { - InitializeCustomDebugInformations (); - - Row [] rows; - if (!metadata.CustomDebugInformations.TryGetValue (provider.MetadataToken, out rows)) - return null; - - var infos = new Collection (rows.Length); - - for (int i = 0; i < rows.Length; i++) { - if (rows [i].Col1 == StateMachineScopeDebugInformation.KindIdentifier) { - var signature = ReadSignature (rows [i].Col2); - var scopes = new Collection (); - - while (signature.CanReadMore ()) { - var start = signature.ReadInt32 (); - var end = start + signature.ReadInt32 (); - scopes.Add (new StateMachineScope (start, end)); - } - - var state_machine = new StateMachineScopeDebugInformation (); - state_machine.scopes = scopes; - - infos.Add (state_machine); - } else if (rows [i].Col1 == AsyncMethodBodyDebugInformation.KindIdentifier) { - var signature = ReadSignature (rows [i].Col2); - - var catch_offset = signature.ReadInt32 () - 1; - var yields = new Collection (); - var resumes = new Collection (); - var resume_methods = new Collection (); - - while (signature.CanReadMore ()) { - yields.Add (new InstructionOffset (signature.ReadInt32 ())); - resumes.Add (new InstructionOffset (signature.ReadInt32 ())); - resume_methods.Add (GetMethodDefinition (signature.ReadCompressedUInt32 ())); - } - - var async_body = new AsyncMethodBodyDebugInformation (catch_offset); - async_body.yields = yields; - async_body.resumes = resumes; - async_body.resume_methods = resume_methods; - - infos.Add (async_body); - } else if (rows [i].Col1 == EmbeddedSourceDebugInformation.KindIdentifier) { - var signature = ReadSignature (rows [i].Col2); - var format = signature.ReadInt32 (); - var length = signature.sig_length - 4; - - var info = null as CustomDebugInformation; - - if (format == 0) { - info = new EmbeddedSourceDebugInformation (signature.ReadBytes ((int) length), compress: false); - } else if (format > 0) { - var compressed_stream = new MemoryStream (signature.ReadBytes ((int) length)); - var decompressed_document = new byte [format]; // if positive, format is the decompressed length of the document - var decompressed_stream = new MemoryStream (decompressed_document); - - using (var deflate_stream = new DeflateStream (compressed_stream, CompressionMode.Decompress, leaveOpen: true)) - deflate_stream.CopyTo (decompressed_stream); - - info = new EmbeddedSourceDebugInformation (decompressed_document, compress: true); - } else if (format < 0) { - info = new BinaryCustomDebugInformation (rows [i].Col1, ReadBlob (rows [i].Col2)); - } - - infos.Add (info); - } else if (rows [i].Col1 == SourceLinkDebugInformation.KindIdentifier) { - infos.Add (new SourceLinkDebugInformation (Encoding.UTF8.GetString (ReadBlob (rows [i].Col2)))); - } else { - infos.Add (new BinaryCustomDebugInformation (rows [i].Col1, ReadBlob (rows [i].Col2))); - } - - infos [i].token = new MetadataToken (TokenType.CustomDebugInformation, rows [i].Col3); - } - - return infos; - } - } - - sealed class SignatureReader : ByteBuffer { - - readonly MetadataReader reader; - readonly internal uint start, sig_length; - - TypeSystem TypeSystem { - get { return reader.module.TypeSystem; } - } - - public SignatureReader (uint blob, MetadataReader reader) - : base (reader.image.BlobHeap.data) - { - this.reader = reader; - this.position = (int) blob; - this.sig_length = ReadCompressedUInt32(); - this.start = (uint) this.position; - } - - MetadataToken ReadTypeTokenSignature () - { - return CodedIndex.TypeDefOrRef.GetMetadataToken (ReadCompressedUInt32 ()); - } - - GenericParameter GetGenericParameter (GenericParameterType type, uint var) - { - var context = reader.context; - int index = (int) var; - - if (context == null) - return GetUnboundGenericParameter (type, index); - - IGenericParameterProvider provider; - - switch (type) { - case GenericParameterType.Type: - provider = context.Type; - break; - case GenericParameterType.Method: - provider = context.Method; - break; - default: - throw new NotSupportedException (); - } - - if (!context.IsDefinition) - CheckGenericContext (provider, index); - - if (index >= provider.GenericParameters.Count) - return GetUnboundGenericParameter (type, index); - - return provider.GenericParameters [index]; - } - - GenericParameter GetUnboundGenericParameter (GenericParameterType type, int index) - { - return new GenericParameter (index, type, reader.module); - } - - 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 ()); - } - - public TypeReference ReadTypeToken () - { - return GetTypeDefOrRef (ReadTypeTokenSignature ()); - } - - TypeReference ReadTypeSignature (ElementType etype) - { - switch (etype) { - case ElementType.ValueType: { - var value_type = GetTypeDefOrRef (ReadTypeTokenSignature ()); - value_type.KnownValueType (); - 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.KnownValueType (); - element_type.GetElementType ().KnownValueType (); - } - - 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 (); - - const byte has_this = 0x20; - const byte explicit_this = 0x40; - - if ((calling_convention & has_this) != 0) { - method.HasThis = true; - calling_convention = (byte) (calling_convention & ~has_this); - } - - if ((calling_convention & explicit_this) != 0) { - method.ExplicitThis = true; - calling_convention = (byte) (calling_convention & ~explicit_this); - } - - method.CallingConvention = (MethodCallingConvention) calling_convention; - - var generic_context = method as MethodReference; - if (generic_context != null && !generic_context.DeclaringType.IsArray) - 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 ); - } - - var param_count = ReadCompressedUInt32 (); - - method.MethodReturnType.ReturnType = ReadTypeSignature (); - - if (param_count == 0) - return; - - Collection 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 parameters) - { - var count = parameters.Count; - if (count == 0) - return; - - attribute.arguments = new Collection (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 fields, ref Collection properties) - { - for (int i = 0; i < count; i++) { - if (!CanReadMore ()) - return; - ReadCustomAttributeNamedArgument (ref fields, ref properties); - } - } - - void ReadCustomAttributeNamedArgument (ref Collection fields, ref Collection properties) - { - var kind = ReadByte (); - var type = ReadCustomAttributeFieldOrPropType (); - var name = ReadUTF8String (); - - Collection 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 GetCustomAttributeNamedArgumentCollection (ref Collection collection) - { - if (collection != null) - return collection; - - return collection = new Collection (); - } - - CustomAttributeArgument ReadCustomAttributeFixedArrayArgument (ArrayType type) - { - var length = ReadUInt32 (); - - if (length == 0xffffffff) - return new CustomAttributeArgument (type, null); - - if (length == 0) - return new CustomAttributeArgument (type, Empty.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); - - return new CustomAttributeArgument ( - type, - type.etype == ElementType.Object - ? ReadCustomAttributeElement (ReadCustomAttributeFieldOrPropType ()) - : 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 string ReadDocumentName () - { - var separator = (char) buffer [position]; - position++; - - var builder = new StringBuilder (); - for (int i = 0; CanReadMore (); i++) { - if (i > 0 && separator != 0) - builder.Append (separator); - - uint part = ReadCompressedUInt32 (); - if (part != 0) - builder.Append (reader.ReadUTF8StringBlob (part)); - } - - return builder.ToString (); - } - - public Collection ReadSequencePoints (Document document) - { - var sequence_points = new Collection (); - - ReadCompressedUInt32 (); // local_sig_token - - if (document == null) - document = reader.GetDocument (ReadCompressedUInt32 ()); - - var offset = 0; - var start_line = 0; - var start_column = 0; - var first_non_hidden = true; - - for (var i = 0; CanReadMore (); i++) { - var delta_il = (int) ReadCompressedUInt32 (); - if (i > 0 && delta_il == 0) { - document = reader.GetDocument (ReadCompressedUInt32 ()); - continue; - } - - offset += delta_il; - - var delta_lines = (int) ReadCompressedUInt32 (); - var delta_columns = delta_lines == 0 - ? (int) ReadCompressedUInt32 () - : ReadCompressedInt32 (); - - if (delta_lines == 0 && delta_columns == 0) { - sequence_points.Add (new SequencePoint (offset, document) { - StartLine = 0xfeefee, - EndLine = 0xfeefee, - StartColumn = 0, - EndColumn = 0, - }); - continue; - } - - if (first_non_hidden) { - start_line = (int) ReadCompressedUInt32 (); - start_column = (int) ReadCompressedUInt32 (); - } else { - start_line += ReadCompressedInt32 (); - start_column += ReadCompressedInt32 (); - } - - sequence_points.Add (new SequencePoint (offset, document) { - StartLine = start_line, - StartColumn = start_column, - EndLine = start_line + delta_lines, - EndColumn = start_column + delta_columns, - }); - first_non_hidden = false; - } - - return sequence_points; - } - - public bool CanReadMore () - { - return position - start < sig_length; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/AssemblyWriter.cs b/external/linker/cecil/Mono.Cecil/AssemblyWriter.cs deleted file mode 100644 index 7b3710e2fd..0000000000 --- a/external/linker/cecil/Mono.Cecil/AssemblyWriter.cs +++ /dev/null @@ -1,3300 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Text; - -using Mono; -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; -using GuidIndex = System.UInt32; - -namespace Mono.Cecil { - -#if !READ_ONLY - - using ModuleRow = Row; - using TypeRefRow = Row; - using TypeDefRow = Row; - using FieldRow = Row; - using MethodRow = Row; - using ParamRow = Row; - using InterfaceImplRow = Row; - using MemberRefRow = Row; - using ConstantRow = Row; - using CustomAttributeRow = Row; - using FieldMarshalRow = Row; - using DeclSecurityRow = Row; - using ClassLayoutRow = Row; - using FieldLayoutRow = Row; - using EventMapRow = Row; - using EventRow = Row; - using PropertyMapRow = Row; - using PropertyRow = Row; - using MethodSemanticsRow = Row; - using MethodImplRow = Row; - using ImplMapRow = Row; - using FieldRVARow = Row; - using AssemblyRow = Row; - using AssemblyRefRow = Row; - using FileRow = Row; - using ExportedTypeRow = Row; - using ManifestResourceRow = Row; - using NestedClassRow = Row; - using GenericParamRow = Row; - using MethodSpecRow = Row; - using GenericParamConstraintRow = Row; - using DocumentRow = Row; - using MethodDebugInformationRow = Row; - using LocalScopeRow = Row; - using LocalVariableRow = Row; - using LocalConstantRow = Row; - using ImportScopeRow = Row; - using StateMachineMethodRow = Row; - using CustomDebugInformationRow = Row; - - static class ModuleWriter { - - public static void WriteModule (ModuleDefinition module, Disposable stream, WriterParameters parameters) - { - using (stream) - Write (module, stream, parameters); - } - - static void Write (ModuleDefinition module, Disposable stream, WriterParameters parameters) - { - if ((module.Attributes & ModuleAttributes.ILOnly) == 0) - throw new NotSupportedException ("Writing mixed-mode assemblies is not supported"); - - if (module.HasImage && module.ReadingMode == ReadingMode.Deferred) { - var immediate_reader = new ImmediateModuleReader (module.Image); - immediate_reader.ReadModule (module, resolve_attributes: false); - immediate_reader.ReadSymbols (module); - } - - module.MetadataSystem.Clear (); - - if (module.symbol_reader != null) - module.symbol_reader.Dispose (); - - var name = module.assembly != null ? module.assembly.Name : null; - var fq_name = stream.value.GetFileName (); - var timestamp = parameters.Timestamp ?? module.timestamp; - var symbol_writer_provider = parameters.SymbolWriterProvider; - - if (symbol_writer_provider == null && parameters.WriteSymbols) - symbol_writer_provider = new DefaultSymbolWriterProvider (); - -#if !NET_CORE - if (parameters.StrongNameKeyPair != null && name != null) { - name.PublicKey = parameters.StrongNameKeyPair.PublicKey; - module.Attributes |= ModuleAttributes.StrongNameSigned; - } -#endif - - using (var symbol_writer = GetSymbolWriter (module, fq_name, symbol_writer_provider, parameters)) { - var metadata = new MetadataBuilder (module, fq_name, timestamp, symbol_writer_provider, symbol_writer); - BuildMetadata (module, metadata); - - var writer = ImageWriter.CreateWriter (module, metadata, stream); - stream.value.SetLength (0); - writer.WriteImage (); - -#if !NET_CORE - if (parameters.StrongNameKeyPair != null) - CryptoService.StrongName (stream.value, writer, parameters.StrongNameKeyPair); -#endif - } - } - - 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, WriterParameters parameters) - { - if (symbol_writer_provider == null) - return null; - - if (parameters.SymbolStream != null) - return symbol_writer_provider.GetSymbolWriter (module, parameters.SymbolStream); - - return symbol_writer_provider.GetSymbolWriter (module, fq_name); - } - } - - abstract class MetadataTable { - - public abstract int Length { get; } - - public bool IsLarge { - get { return Length > ushort.MaxValue; } - } - - public abstract void Write (TableHeapBuffer buffer); - public abstract void Sort (); - } - - abstract class OneRowTable : MetadataTable where TRow : struct { - - internal TRow row; - - public sealed override int Length { - get { return 1; } - } - - public sealed override void Sort () - { - } - } - - abstract class MetadataTable : 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 : MetadataTable, IComparer 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 { - - public override void Write (TableHeapBuffer buffer) - { - buffer.WriteUInt16 (0); // Generation - buffer.WriteString (row.Col1); // Name - buffer.WriteGuid (row.Col2); // Mvid - buffer.WriteUInt16 (0); // EncId - buffer.WriteUInt16 (0); // EncBaseId - } - } - - sealed class TypeRefTable : MetadataTable { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - public override void Write (TableHeapBuffer buffer) - { - for (int i = 0; i < length; i++) - buffer.WriteBlob (rows [i]); - } - } - - sealed class EventMapTable : MetadataTable { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - public override void Write (TableHeapBuffer buffer) - { - for (int i = 0; i < length; i++) - buffer.WriteString (rows [i]); // Name - } - } - - sealed class TypeSpecTable : MetadataTable { - - public override void Write (TableHeapBuffer buffer) - { - for (int i = 0; i < length; i++) - buffer.WriteBlob (rows [i]); // Signature - } - } - - sealed class ImplMapTable : SortedTable { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 { - - 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 DocumentTable : MetadataTable { - - public override void Write (TableHeapBuffer buffer) - { - for (int i = 0; i < length; i++) { - buffer.WriteBlob (rows [i].Col1); // Name - buffer.WriteGuid (rows [i].Col2); // HashAlgorithm - buffer.WriteBlob (rows [i].Col3); // Hash - buffer.WriteGuid (rows [i].Col4); // Language - } - } - } - - sealed class MethodDebugInformationTable : MetadataTable { - - public override void Write (TableHeapBuffer buffer) - { - for (int i = 0; i < length; i++) { - buffer.WriteRID (rows [i].Col1, Table.Document); // Document - buffer.WriteBlob (rows [i].Col2); // SequencePoints - } - } - } - - sealed class LocalScopeTable : MetadataTable { - - public override void Write (TableHeapBuffer buffer) - { - for (int i = 0; i < length; i++) { - buffer.WriteRID (rows [i].Col1, Table.Method); // Method - buffer.WriteRID (rows [i].Col2, Table.ImportScope); // ImportScope - buffer.WriteRID (rows [i].Col3, Table.LocalVariable); // VariableList - buffer.WriteRID (rows [i].Col4, Table.LocalConstant); // ConstantList - buffer.WriteUInt32 (rows [i].Col5); // StartOffset - buffer.WriteUInt32 (rows [i].Col6); // Length - } - } - } - - sealed class LocalVariableTable : MetadataTable { - - 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); // Index - buffer.WriteString (rows [i].Col3); // Name - } - } - } - - sealed class LocalConstantTable : MetadataTable { - - public override void Write (TableHeapBuffer buffer) - { - for (int i = 0; i < length; i++) { - buffer.WriteString (rows [i].Col1); // Name - buffer.WriteBlob (rows [i].Col2); // Signature - } - } - } - - sealed class ImportScopeTable : MetadataTable { - - public override void Write (TableHeapBuffer buffer) - { - for (int i = 0; i < length; i++) { - buffer.WriteRID (rows [i].Col1, Table.ImportScope); // Parent - buffer.WriteBlob (rows [i].Col2); // Imports - } - } - } - - sealed class StateMachineMethodTable : MetadataTable { - - public override void Write (TableHeapBuffer buffer) - { - for (int i = 0; i < length; i++) { - buffer.WriteRID (rows [i].Col1, Table.Method); // MoveNextMethod - buffer.WriteRID (rows [i].Col2, Table.Method); // KickoffMethod - } - } - } - - sealed class CustomDebugInformationTable : SortedTable { - - public override void Write (TableHeapBuffer buffer) - { - for (int i = 0; i < length; i++) { - buffer.WriteCodedRID (rows [i].Col1, CodedIndex.HasCustomDebugInformation); // Parent - buffer.WriteGuid (rows [i].Col2); // Kind - buffer.WriteBlob (rows [i].Col3); // Value - } - } - - public override int Compare (CustomDebugInformationRow x, CustomDebugInformationRow y) - { - return Compare(x.Col1, y.Col1); - } - } - - 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 internal uint timestamp; - - readonly Dictionary type_ref_map; - readonly Dictionary type_spec_map; - readonly Dictionary member_ref_map; - readonly Dictionary method_spec_map; - readonly Collection generic_parameters; - - readonly internal CodeWriter code; - readonly internal DataBuffer data; - readonly internal ResourceBuffer resources; - readonly internal StringHeapBuffer string_heap; - readonly internal GuidHeapBuffer guid_heap; - readonly internal UserStringHeapBuffer user_string_heap; - readonly internal BlobHeapBuffer blob_heap; - readonly internal TableHeapBuffer table_heap; - readonly internal PdbHeapBuffer pdb_heap; - - internal MetadataToken entry_point; - - internal RID type_rid = 1; - internal RID field_rid = 1; - internal RID method_rid = 1; - internal RID param_rid = 1; - internal RID property_rid = 1; - internal RID event_rid = 1; - internal RID local_variable_rid = 1; - internal RID local_constant_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 bool portable_pdb; - - internal MetadataBuilder metadata_builder; - - readonly DocumentTable document_table; - readonly MethodDebugInformationTable method_debug_information_table; - readonly LocalScopeTable local_scope_table; - readonly LocalVariableTable local_variable_table; - readonly LocalConstantTable local_constant_table; - readonly ImportScopeTable import_scope_table; - readonly StateMachineMethodTable state_machine_method_table; - readonly CustomDebugInformationTable custom_debug_information_table; - - readonly Dictionary import_scope_map; - readonly Dictionary document_map; - - public MetadataBuilder (ModuleDefinition module, string fq_name, uint timestamp, ISymbolWriterProvider symbol_writer_provider, ISymbolWriter symbol_writer) - { - this.module = module; - this.text_map = CreateTextMap (); - this.fq_name = fq_name; - this.timestamp = timestamp; - this.symbol_writer_provider = symbol_writer_provider; - - if (symbol_writer == null && module.HasImage && module.Image.HasDebugTables ()) { - symbol_writer = new PortablePdbWriter (this, module); - } - - this.symbol_writer = symbol_writer; - - var pdb_writer = symbol_writer as IMetadataSymbolWriter; - if (pdb_writer != null) { - portable_pdb = true; - pdb_writer.SetMetadata (this); - } - - this.code = new CodeWriter (this); - this.data = new DataBuffer (); - this.resources = new ResourceBuffer (); - this.string_heap = new StringHeapBuffer (); - this.guid_heap = new GuidHeapBuffer (); - this.user_string_heap = new UserStringHeapBuffer (); - this.blob_heap = new BlobHeapBuffer (); - this.table_heap = new TableHeapBuffer (module, this); - - this.type_ref_table = GetTable (Table.TypeRef); - this.type_def_table = GetTable (Table.TypeDef); - this.field_table = GetTable (Table.Field); - this.method_table = GetTable (Table.Method); - this.param_table = GetTable (Table.Param); - this.iface_impl_table = GetTable (Table.InterfaceImpl); - this.member_ref_table = GetTable (Table.MemberRef); - this.constant_table = GetTable (Table.Constant); - this.custom_attribute_table = GetTable (Table.CustomAttribute); - this.declsec_table = GetTable (Table.DeclSecurity); - this.standalone_sig_table = GetTable (Table.StandAloneSig); - this.event_map_table = GetTable (Table.EventMap); - this.event_table = GetTable (Table.Event); - this.property_map_table = GetTable (Table.PropertyMap); - this.property_table = GetTable (Table.Property); - this.typespec_table = GetTable (Table.TypeSpec); - this.method_spec_table = GetTable (Table.MethodSpec); - - var row_equality_comparer = new RowEqualityComparer (); - type_ref_map = new Dictionary (row_equality_comparer); - type_spec_map = new Dictionary (); - member_ref_map = new Dictionary (row_equality_comparer); - method_spec_map = new Dictionary (row_equality_comparer); - generic_parameters = new Collection (); - - if (!portable_pdb) - return; - - this.document_table = GetTable (Table.Document); - this.method_debug_information_table = GetTable (Table.MethodDebugInformation); - this.local_scope_table = GetTable (Table.LocalScope); - this.local_variable_table = GetTable (Table.LocalVariable); - this.local_constant_table = GetTable (Table.LocalConstant); - this.import_scope_table = GetTable (Table.ImportScope); - this.state_machine_method_table = GetTable (Table.StateMachineMethod); - this.custom_debug_information_table = GetTable (Table.CustomDebugInformation); - - this.document_map = new Dictionary (StringComparer.Ordinal); - this.import_scope_map = new Dictionary (row_equality_comparer); - } - - public MetadataBuilder (ModuleDefinition module, PortablePdbWriterProvider writer_provider) - { - this.module = module; - this.text_map = new TextMap (); - this.symbol_writer_provider = writer_provider; - this.portable_pdb = true; - - this.string_heap = new StringHeapBuffer (); - this.guid_heap = new GuidHeapBuffer (); - this.user_string_heap = new UserStringHeapBuffer (); - this.blob_heap = new BlobHeapBuffer (); - this.table_heap = new TableHeapBuffer (module, this); - this.pdb_heap = new PdbHeapBuffer(); - - this.document_table = GetTable (Table.Document); - this.method_debug_information_table = GetTable (Table.MethodDebugInformation); - this.local_scope_table = GetTable (Table.LocalScope); - this.local_variable_table = GetTable (Table.LocalVariable); - this.local_constant_table = GetTable (Table.LocalConstant); - this.import_scope_table = GetTable (Table.ImportScope); - this.state_machine_method_table = GetTable (Table.StateMachineMethod); - this.custom_debug_information_table = GetTable (Table.CustomDebugInformation); - - var row_equality_comparer = new RowEqualityComparer (); - - this.document_map = new Dictionary (); - this.import_scope_map = new Dictionary (row_equality_comparer); - } - - TextMap CreateTextMap () - { - var map = new TextMap (); - map.AddMap (TextSegment.ImportAddressTable, module.Architecture == TargetArchitecture.I386 ? 8 : 0); - map.AddMap (TextSegment.CLIHeader, 0x48, 8); - return map; - } - - TTable GetTable (Table table) where TTable : MetadataTable, new () - { - return table_heap.GetTable (table); - } - - uint GetStringIndex (string @string) - { - if (string.IsNullOrEmpty (@string)) - return 0; - - return string_heap.GetStringIndex (@string); - } - - uint GetGuidIndex (Guid guid) - { - return guid_heap.GetGuidIndex (guid); - } - - 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.string_offsets = string_heap.WriteStrings (); - table_heap.ComputeTableInformations (); - table_heap.WriteTableHeap (); - } - - void BuildModule () - { - var table = GetTable (Table.Module); - table.row.Col1 = GetStringIndex (module.Name); - table.row.Col2 = GetGuidIndex (module.Mvid); - - 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); - - var pdb_writer = symbol_writer as IMetadataSymbolWriter; - if (pdb_writer != null) - pdb_writer.WriteModule (); - } - - void BuildAssembly () - { - var assembly = module.Assembly; - var name = assembly.Name; - - var table = GetTable (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 (Table.File); - - for (int i = 0; i < modules.Count; i++) { - var module = modules [i]; - if (module.IsMain) - continue; - -#if NET_CORE - throw new NotSupportedException (); -#else - 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))); -#endif - } - } - -#if !NET_CORE - string GetModuleFileName (string name) - { - if (string.IsNullOrEmpty (name)) - throw new NotSupportedException (); - - var path = Path.GetDirectoryName (fq_name); - return Path.Combine (path, name); - } -#endif - - void AddAssemblyReferences () - { - var references = module.AssemblyReferences; - var table = GetTable (Table.AssemblyRef); - - if (module.IsWindowsMetadata ()) - module.Projections.RemoveVirtualReferences (references); - - for (int i = 0; i < references.Count; i++) { - var reference = references [i]; - - var key_or_token = reference.PublicKey.IsNullOrEmpty () - ? reference.PublicKeyToken - : reference.PublicKey; - - var version = reference.Version; - - var rid = table.AddRow (new AssemblyRefRow ( - (ushort) version.Major, - (ushort) version.Minor, - (ushort) version.Build, - (ushort) version.Revision, - reference.Attributes, - GetBlobIndex (key_or_token), - GetStringIndex (reference.Name), - GetStringIndex (reference.Culture), - GetBlobIndex (reference.Hash))); - - reference.token = new MetadataToken (TokenType.AssemblyRef, rid); - } - - if (module.IsWindowsMetadata ()) - module.Projections.AddVirtualReferences (references); - } - - void AddModuleReferences () - { - var references = module.ModuleReferences; - var table = GetTable (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 (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 (Table.File); - var hash = resource.Hash; - -#if !NET_CORE - if (hash.IsNullOrEmpty ()) - hash = CryptoService.ComputeHash (resource.File); -#endif - - 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 (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 (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 (); - AddTypes (); - AddGenericParameters (); - } - - void AttachTokens () - { - var types = module.Types; - - for (int i = 0; i < types.Count; i++) - AttachTypeToken (types [i]); - } - - void AttachTypeToken (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) - AttachFieldsToken (type); - - if (type.HasMethods) - AttachMethodsToken (type); - - if (type.HasNestedTypes) - AttachNestedTypesToken (type); - } - - void AttachNestedTypesToken (TypeDefinition type) - { - var nested_types = type.NestedTypes; - for (int i = 0; i < nested_types.Count; i++) - AttachTypeToken (nested_types [i]); - } - - void AttachFieldsToken (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 AttachMethodsToken (TypeDefinition type) - { - var methods = type.Methods; - type.methods_range.Length = (uint) methods.Count; - for (int i = 0; i < methods.Count; i++) - methods [i].token = new MetadataToken (TokenType.Method, method_rid++); - } - - 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) - { - MetadataToken ctoken; - if (module.CustomMetadataWriter != null) { - if (module.CustomMetadataWriter.CreateTypeRefToken (ref type, out ctoken)) - return ctoken; - } - - var projection = WindowsRuntimeProjections.RemoveProjection (type); - - var row = CreateTypeRefRow (type); - - MetadataToken token; - if (!type_ref_map.TryGetValue (row, out token)) - token = AddTypeReference (type, row); - - WindowsRuntimeProjections.ApplyProjection (type, projection); - - return token; - } - - TypeRefRow CreateTypeRefRow (TypeReference type) - { - var scope_token = GetScopeToken (type); - - return new TypeRefRow ( - MakeCodedRID (scope_token, CodedIndex.ResolutionScope), - GetStringIndex (type.Name), - GetStringIndex (type.Namespace)); - } - - MetadataToken GetScopeToken (TypeReference type) - { - if (type.IsNested) - return GetTypeRefToken (type.DeclaringType); - - var scope = type.Scope; - - if (scope == null) - return MetadataToken.Zero; - - return scope.MetadataToken; - } - - 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 AddTypes () - { - var types = module.Types; - - for (int i = 0; i < types.Count; i++) - AddType (types [i]); - } - - void AddType (TypeDefinition type) - { - var treatment = WindowsRuntimeProjections.RemoveProjection (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); - - WindowsRuntimeProjections.ApplyProjection (type, treatment); - } - - 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 { - - 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 (Table.GenericParam); - var generic_param_constraint_table = GetTable (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++) { - var iface_impl = interfaces [i]; - - var rid = iface_impl_table.AddRow (new InterfaceImplRow ( - type_rid, - MakeCodedRID (GetTypeToken (iface_impl.InterfaceType), CodedIndex.TypeDefOrRef))); - - iface_impl.token = new MetadataToken (TokenType.InterfaceImpl, rid); - - if (iface_impl.HasCustomAttributes) - AddCustomAttributes (iface_impl); - } - } - - void AddLayoutInfo (TypeDefinition type) - { - var table = GetTable (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 (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) - { - var projection = WindowsRuntimeProjections.RemoveProjection (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); - - WindowsRuntimeProjections.ApplyProjection (field, projection); - } - - void AddFieldRVA (FieldDefinition field) - { - var table = GetTable (Table.FieldRVA); - table.AddRow (new FieldRVARow ( - data.AddData (field.InitialValue), - field.token.RID)); - } - - void AddFieldLayout (FieldDefinition field) - { - var table = GetTable (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) - { - var projection = WindowsRuntimeProjections.RemoveProjection (method); - - method_table.AddRow (new MethodRow ( - method.HasBody ? code.WriteMethodBody (method) : 0, - method.ImplAttributes, - method.Attributes, - GetStringIndex (method.Name), - GetBlobIndex (GetMethodSignature (method)), - param_rid)); - - 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); - - WindowsRuntimeProjections.ApplyProjection (method, projection); - } - - void AddParameters (MethodDefinition method) - { - var return_parameter = method.MethodReturnType.parameter; - - if (return_parameter != null && RequiresParameterRow (return_parameter)) - AddParameter (0, return_parameter, param_table); - - if (!method.HasParameters) - return; - - var parameters = method.Parameters; - - 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) - return; - - var table = GetTable (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 (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 (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 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 (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: - var generic_instance = (GenericInstanceType) constant_type; - if (generic_instance.ElementType.IsTypeOf ("System", "Nullable`1")) - return GetConstantType (generic_instance.GenericArguments [0], constant); - - return GetConstantType (((TypeSpecification) constant_type).ElementType, constant); - 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 ()) { - 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]; - - var projection = WindowsRuntimeProjections.RemoveProjection (attribute); - - custom_attribute_table.AddRow (new CustomAttributeRow ( - MakeCodedRID (owner, CodedIndex.HasCustomAttribute), - MakeCodedRID (LookupToken (attribute.Constructor), CodedIndex.CustomAttributeType), - GetBlobIndex (GetCustomAttributeSignature (attribute)))); - - WindowsRuntimeProjections.ApplyProjection (attribute, projection); - } - } - - 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 projection = WindowsRuntimeProjections.RemoveProjection (member); - - var row = CreateMemberRefRow (member); - - MetadataToken token; - if (!member_ref_map.TryGetValue (row, out token)) - token = AddMemberReference (member, row); - - WindowsRuntimeProjections.ApplyProjection (member, projection); - - return token; - } - - MemberRefRow CreateMemberRefRow (MemberReference member) - { - return new MemberRefRow ( - MakeCodedRID (GetTypeToken (member.DeclaringType), CodedIndex.MemberRefParent), - GetStringIndex (member.Name), - GetBlobIndex (GetMemberRefSignature (member))); - } - - MetadataToken AddMemberReference (MemberReference member, MemberRefRow row) - { - member.token = new MetadataToken (TokenType.MemberRef, member_ref_table.AddRow (row)); - - var token = member.token; - member_ref_map.Add (row, token); - return 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 variables) - { - return GetBlobIndex (GetVariablesSignature (variables)); - } - - public uint GetCallSiteBlobIndex (CallSite call_site) - { - return GetBlobIndex (GetMethodSignature (call_site)); - } - - public uint GetConstantTypeBlobIndex (TypeReference constant_type) - { - return GetBlobIndex (GetConstantTypeSignature (constant_type)); - } - - SignatureWriter GetVariablesSignature (Collection 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 GetConstantTypeSignature (TypeReference constant_type) - { - var signature = CreateSignatureWriter (); - signature.WriteByte (0x6); - signature.WriteTypeSignature (constant_type); - 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 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.None: - 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 ()); - else if (module.Runtime < TargetRuntime.Net_2_0) - signature.WriteXmlSecurityDeclaration (declaration); - else - signature.WriteSecurityDeclaration (declaration); - - return signature; - } - - SignatureWriter GetMarshalInfoSignature (IMarshalInfoProvider owner) - { - var signature = CreateSignatureWriter (); - - signature.WriteMarshalInfo (owner.MarshalInfo); - - return signature; - } - - static Exception CreateForeignMemberException (MemberReference member) - { - return new ArgumentException (string.Format ("Member '{0}' is declared in another module and needs to be imported", member)); - } - - public MetadataToken LookupToken (IMetadataTokenProvider provider) - { - if (provider == null) - throw new ArgumentNullException (); - - if (metadata_builder != null) - return metadata_builder.LookupToken (provider); - - var member = provider as MemberReference; - if (member == null || member.Module != module) - throw CreateForeignMemberException (member); - - 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 (member); - default: - throw new NotSupportedException (); - } - } - - public void AddMethodDebugInformation (MethodDebugInformation method_info) - { - if (method_info.HasSequencePoints) - AddSequencePoints (method_info); - - if (method_info.Scope != null) - AddLocalScope (method_info, method_info.Scope); - - if (method_info.StateMachineKickOffMethod != null) - AddStateMachineMethod (method_info); - - AddCustomDebugInformations (method_info.Method); - } - - void AddStateMachineMethod (MethodDebugInformation method_info) - { - state_machine_method_table.AddRow (new StateMachineMethodRow (method_info.Method.MetadataToken.RID, method_info.StateMachineKickOffMethod.MetadataToken.RID)); - } - - void AddLocalScope (MethodDebugInformation method_info, ScopeDebugInformation scope) - { - var rid = local_scope_table.AddRow (new LocalScopeRow ( - method_info.Method.MetadataToken.RID, - scope.import != null ? AddImportScope (scope.import) : 0, - local_variable_rid, - local_constant_rid, - (uint) scope.Start.Offset, - (uint) ((scope.End.IsEndOfMethod ? method_info.code_size : scope.End.Offset) - scope.Start.Offset))); - - scope.token = new MetadataToken (TokenType.LocalScope, rid); - - AddCustomDebugInformations (scope); - - if (scope.HasVariables) - AddLocalVariables (scope); - - if (scope.HasConstants) - AddLocalConstants (scope); - - for (int i = 0; i < scope.Scopes.Count; i++) - AddLocalScope (method_info, scope.Scopes [i]); - } - - void AddLocalVariables (ScopeDebugInformation scope) - { - for (int i = 0; i < scope.Variables.Count; i++) { - var variable = scope.Variables [i]; - local_variable_table.AddRow (new LocalVariableRow (variable.Attributes, (ushort) variable.Index, GetStringIndex (variable.Name))); - variable.token = new MetadataToken (TokenType.LocalVariable, local_variable_rid); - local_variable_rid++; - - AddCustomDebugInformations (variable); - } - } - - void AddLocalConstants (ScopeDebugInformation scope) - { - for (int i = 0; i < scope.Constants.Count; i++) { - var constant = scope.Constants [i]; - local_constant_table.AddRow (new LocalConstantRow (GetStringIndex (constant.Name), GetBlobIndex (GetConstantSignature(constant)))); - constant.token = new MetadataToken (TokenType.LocalConstant, local_constant_rid); - local_constant_rid++; - } - } - - SignatureWriter GetConstantSignature (ConstantDebugInformation constant) - { - var type = constant.ConstantType; - - var signature = CreateSignatureWriter (); - signature.WriteTypeSignature (type); - - if (type.IsTypeOf ("System", "Decimal")) { - var bits = decimal.GetBits ((decimal) constant.Value); - - var low = (uint) bits [0]; - var mid = (uint) bits [1]; - var high = (uint) bits [2]; - - var scale = (byte) (bits [3] >> 16); - var negative = (bits [3] & 0x80000000) != 0; - - signature.WriteByte ((byte) (scale | (negative ? 0x80 : 0x00))); - signature.WriteUInt32 (low); - signature.WriteUInt32 (mid); - signature.WriteUInt32 (high); - - return signature; - } - - if (type.IsTypeOf ("System", "DateTime")) { - var date = (DateTime) constant.Value; - signature.WriteInt64 (date.Ticks); - return signature; - } - - signature.WriteBytes (GetConstantSignature (type.etype, constant.Value)); - - return signature; - } - - public void AddCustomDebugInformations (ICustomDebugInformationProvider provider) - { - if (!provider.HasCustomDebugInformations) - return; - - var custom_infos = provider.CustomDebugInformations; - - for (int i = 0; i < custom_infos.Count; i++) { - var custom_info = custom_infos [i]; - switch (custom_info.Kind) { - case CustomDebugInformationKind.Binary: - var binary_info = (BinaryCustomDebugInformation) custom_info; - AddCustomDebugInformation (provider, binary_info, GetBlobIndex (binary_info.Data)); - break; - case CustomDebugInformationKind.AsyncMethodBody: - AddAsyncMethodBodyDebugInformation (provider, (AsyncMethodBodyDebugInformation) custom_info); - break; - case CustomDebugInformationKind.StateMachineScope: - AddStateMachineScopeDebugInformation (provider, (StateMachineScopeDebugInformation) custom_info); - break; - case CustomDebugInformationKind.EmbeddedSource: - AddEmbeddedSourceDebugInformation (provider, (EmbeddedSourceDebugInformation) custom_info); - break; - case CustomDebugInformationKind.SourceLink: - AddSourceLinkDebugInformation (provider, (SourceLinkDebugInformation) custom_info); - break; - default: - throw new NotImplementedException (); - } - } - } - - void AddStateMachineScopeDebugInformation (ICustomDebugInformationProvider provider, StateMachineScopeDebugInformation state_machine_scope) - { - var method_info = ((MethodDefinition) provider).DebugInformation; - - var signature = CreateSignatureWriter (); - - var scopes = state_machine_scope.Scopes; - - for (int i = 0; i < scopes.Count; i++) { - var scope = scopes [i]; - signature.WriteUInt32 ((uint) scope.Start.Offset); - - var end_offset = scope.End.IsEndOfMethod - ? method_info.code_size - : scope.End.Offset; - - signature.WriteUInt32 ((uint) (end_offset - scope.Start.Offset)); - } - - AddCustomDebugInformation (provider, state_machine_scope, signature); - } - - void AddAsyncMethodBodyDebugInformation (ICustomDebugInformationProvider provider, AsyncMethodBodyDebugInformation async_method) - { - var signature = CreateSignatureWriter (); - signature.WriteUInt32 ((uint) async_method.catch_handler.Offset + 1); - - if (!async_method.yields.IsNullOrEmpty ()) { - for (int i = 0; i < async_method.yields.Count; i++) { - signature.WriteUInt32 ((uint) async_method.yields [i].Offset); - signature.WriteUInt32 ((uint) async_method.resumes [i].Offset); - signature.WriteCompressedUInt32 (async_method.resume_methods [i].MetadataToken.RID); - } - } - - AddCustomDebugInformation (provider, async_method, signature); - } - - void AddEmbeddedSourceDebugInformation (ICustomDebugInformationProvider provider, EmbeddedSourceDebugInformation embedded_source) - { - var signature = CreateSignatureWriter (); - var content = embedded_source.content ?? Empty.Array; - if (embedded_source.compress) { - signature.WriteInt32 (content.Length); - - var decompressed_stream = new MemoryStream (content); - var content_stream = new MemoryStream (); - - using (var compress_stream = new DeflateStream (content_stream, CompressionMode.Compress, leaveOpen: true)) - decompressed_stream.CopyTo (compress_stream); - - signature.WriteBytes (content_stream.ToArray ()); - } else { - signature.WriteInt32 (0); - signature.WriteBytes (content); - } - - AddCustomDebugInformation (provider, embedded_source, signature); - } - - void AddSourceLinkDebugInformation (ICustomDebugInformationProvider provider, SourceLinkDebugInformation source_link) - { - var signature = CreateSignatureWriter (); - signature.WriteBytes (Encoding.UTF8.GetBytes (source_link.content)); - - AddCustomDebugInformation (provider, source_link, signature); - } - - void AddCustomDebugInformation (ICustomDebugInformationProvider provider, CustomDebugInformation custom_info, SignatureWriter signature) - { - AddCustomDebugInformation (provider, custom_info, GetBlobIndex (signature)); - } - - void AddCustomDebugInformation (ICustomDebugInformationProvider provider, CustomDebugInformation custom_info, uint blob_index) - { - var rid = custom_debug_information_table.AddRow (new CustomDebugInformationRow ( - MakeCodedRID (provider.MetadataToken, CodedIndex.HasCustomDebugInformation), - GetGuidIndex (custom_info.Identifier), - blob_index)); - - custom_info.token = new MetadataToken (TokenType.CustomDebugInformation, rid); - } - - uint AddImportScope (ImportDebugInformation import) - { - uint parent = 0; - if (import.Parent != null) - parent = AddImportScope (import.Parent); - - uint targets_index = 0; - if (import.HasTargets) { - var signature = CreateSignatureWriter (); - - for (int i = 0; i < import.Targets.Count; i++) - AddImportTarget (import.Targets [i], signature); - - targets_index = GetBlobIndex (signature); - } - - var row = new ImportScopeRow (parent, targets_index); - - MetadataToken import_token; - if (import_scope_map.TryGetValue (row, out import_token)) - return import_token.RID; - - import_token = new MetadataToken (TokenType.ImportScope, import_scope_table.AddRow (row)); - import_scope_map.Add (row, import_token); - - return import_token.RID; - } - - void AddImportTarget (ImportTarget target, SignatureWriter signature) - { - signature.WriteCompressedUInt32 ((uint)target.kind); - - switch (target.kind) { - case ImportTargetKind.ImportNamespace: - signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (target.@namespace)); - break; - case ImportTargetKind.ImportNamespaceInAssembly: - signature.WriteCompressedUInt32 (target.reference.MetadataToken.RID); - signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (target.@namespace)); - break; - case ImportTargetKind.ImportType: - signature.WriteTypeToken (target.type); - break; - case ImportTargetKind.ImportXmlNamespaceWithAlias: - signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (target.alias)); - signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (target.@namespace)); - break; - case ImportTargetKind.ImportAlias: - signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (target.alias)); - break; - case ImportTargetKind.DefineAssemblyAlias: - signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (target.alias)); - signature.WriteCompressedUInt32 (target.reference.MetadataToken.RID); - break; - case ImportTargetKind.DefineNamespaceAlias: - signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (target.alias)); - signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (target.@namespace)); - break; - case ImportTargetKind.DefineNamespaceInAssemblyAlias: - signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (target.alias)); - signature.WriteCompressedUInt32 (target.reference.MetadataToken.RID); - signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (target.@namespace)); - break; - case ImportTargetKind.DefineTypeAlias: - signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (target.alias)); - signature.WriteTypeToken (target.type); - break; - } - } - - uint GetUTF8StringBlobIndex (string s) - { - return GetBlobIndex (Encoding.UTF8.GetBytes (s)); - } - - public MetadataToken GetDocumentToken (Document document) - { - MetadataToken token; - if (document_map.TryGetValue (document.Url, out token)) - return token; - - token = new MetadataToken (TokenType.Document, document_table.AddRow ( - new DocumentRow (GetBlobIndex (GetDocumentNameSignature (document)), - GetGuidIndex (document.HashAlgorithm.ToGuid ()), - GetBlobIndex (document.Hash), - GetGuidIndex (document.Language.ToGuid ())))); - - document.token = token; - - AddCustomDebugInformations (document); - - document_map.Add (document.Url, token); - - return token; - } - - SignatureWriter GetDocumentNameSignature (Document document) - { - var name = document.Url; - var signature = CreateSignatureWriter (); - - char separator; - if (!TryGetDocumentNameSeparator (name, out separator)) { - signature.WriteByte (0); - signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (name)); - return signature; - } - - signature.WriteByte ((byte) separator); - var parts = name.Split (new [] { separator }); - for (int i = 0; i < parts.Length; i++) { - if (parts [i] == String.Empty) - signature.WriteCompressedUInt32 (0); - else - signature.WriteCompressedUInt32 (GetUTF8StringBlobIndex (parts [i])); - } - - return signature; - } - - static bool TryGetDocumentNameSeparator (string path, out char separator) - { - const char unix = '/'; - const char win = '\\'; - const char zero = (char) 0; - - separator = zero; - if (string.IsNullOrEmpty (path)) - return false; - - int unix_count = 0; - int win_count = 0; - - for (int i = 0; i < path.Length; i++) { - if (path [i] == unix) - unix_count++; - else if (path [i] == win) - win_count++; - } - - if (unix_count == 0 && win_count == 0) - return false; - - if (unix_count >= win_count) { - separator = unix; - return true; - } - - separator = win; - return true; - } - - void AddSequencePoints (MethodDebugInformation info) - { - var rid = info.Method.MetadataToken.RID; - - Document document; - if (info.TryGetUniqueDocument (out document)) - method_debug_information_table.rows [rid - 1].Col1 = GetDocumentToken (document).RID; - - var signature = CreateSignatureWriter (); - signature.WriteSequencePoints (info); - - method_debug_information_table.rows [rid - 1].Col2 = GetBlobIndex (signature); - } - } - - 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 WriteTypeToken (TypeReference type) - { - WriteCompressedUInt32 (MakeTypeDefOrRefCodedRID (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) - { - if (value != null) - WriteBytes (Encoding.Unicode.GetBytes (value)); - else - WriteByte (0xff); - } - - 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) { - argument = (CustomAttributeArgument) argument.Value; - type = argument.Type; - - WriteCustomAttributeFieldOrPropType (type); - WriteCustomAttributeElement (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 (value.GetType ().GetTypeCode ()) { - 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 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); - } - - void WriteSecurityAttribute (SecurityAttribute attribute) - { - WriteTypeReference (attribute.AttributeType); - - var count = GetNamedArgumentCount (attribute); - - if (count == 0) { - WriteCompressedUInt32 (1); // length - WriteCompressedUInt32 (0); // count - return; - } - - var buffer = new SignatureWriter (metadata); - buffer.WriteCompressedUInt32 ((uint) count); - buffer.WriteICustomAttributeNamedArguments (attribute); - - WriteCompressedUInt32 ((uint) buffer.length); - WriteBytes (buffer); - } - - public void WriteSecurityDeclaration (SecurityDeclaration declaration) - { - WriteByte ((byte) '.'); - - var attributes = declaration.security_attributes; - if (attributes == null) - throw new NotSupportedException (); - - WriteCompressedUInt32 ((uint) attributes.Count); - - for (int i = 0; i < attributes.Count; i++) - WriteSecurityAttribute (attributes [i]); - } - - public void WriteXmlSecurityDeclaration (SecurityDeclaration declaration) - { - var xml = GetXmlSecurityDeclaration (declaration); - if (xml == null) - throw new NotSupportedException (); - - WriteBytes (Encoding.Unicode.GetBytes (xml)); - } - - static string GetXmlSecurityDeclaration (SecurityDeclaration declaration) - { - if (declaration.security_attributes == null || declaration.security_attributes.Count != 1) - return null; - - var attribute = declaration.security_attributes [0]; - - if (!attribute.AttributeType.IsTypeOf ("System.Security.Permissions", "PermissionSetAttribute")) - return null; - - if (attribute.properties == null || attribute.properties.Count != 1) - return null; - - var property = attribute.properties [0]; - if (property.Name != "XML") - return null; - - return (string) property.Argument.Value; - } - - void WriteTypeReference (TypeReference type) - { - WriteUTF8String (TypeParser.ToParseable (type)); - } - - 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); - } - - public void WriteSequencePoints (MethodDebugInformation info) - { - var start_line = -1; - var start_column = -1; - - WriteCompressedUInt32 (info.local_var_token.RID); - - Document previous_document; - if (!info.TryGetUniqueDocument (out previous_document)) - previous_document = null; - - for (int i = 0; i < info.SequencePoints.Count; i++) { - var sequence_point = info.SequencePoints [i]; - - var document = sequence_point.Document; - if (previous_document != document) { - var document_token = metadata.GetDocumentToken (document); - - if (previous_document != null) - WriteCompressedUInt32 (0); - - WriteCompressedUInt32 (document_token.RID); - previous_document = document; - } - - if (i > 0) - WriteCompressedUInt32 ((uint) (sequence_point.Offset - info.SequencePoints [i - 1].Offset)); - else - WriteCompressedUInt32 ((uint) sequence_point.Offset); - - if (sequence_point.IsHidden) { - WriteInt16 (0); - continue; - } - - var delta_lines = sequence_point.EndLine - sequence_point.StartLine; - var delta_columns = sequence_point.EndColumn - sequence_point.StartColumn; - - WriteCompressedUInt32 ((uint) delta_lines); - - if (delta_lines == 0) - WriteCompressedUInt32((uint) delta_columns); - else - WriteCompressedInt32 (delta_columns); - - if (start_line < 0) { - WriteCompressedUInt32 ((uint) sequence_point.StartLine); - WriteCompressedUInt32 ((uint) sequence_point.StartColumn); - } else { - WriteCompressedInt32 (sequence_point.StartLine - start_line); - WriteCompressedInt32 (sequence_point.StartColumn - start_column); - } - - start_line = sequence_point.StartLine; - start_column = sequence_point.StartColumn; - } - } - } - -#endif - - static partial class Mixin { - - public static bool TryGetUniqueDocument (this MethodDebugInformation info, out Document document) - { - document = info.SequencePoints [0].Document; - - for (int i = 1; i < info.SequencePoints.Count; i++) { - var sequence_point = info.SequencePoints [i]; - if (sequence_point.Document != document) - return false; - } - - return true; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/BaseAssemblyResolver.cs b/external/linker/cecil/Mono.Cecil/BaseAssemblyResolver.cs deleted file mode 100644 index cf6a3a3451..0000000000 --- a/external/linker/cecil/Mono.Cecil/BaseAssemblyResolver.cs +++ /dev/null @@ -1,404 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Text; - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - 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; - } - } - -#if !NET_CORE - [Serializable] -#endif - public sealed class AssemblyResolutionException : FileNotFoundException { - - readonly AssemblyNameReference reference; - - public AssemblyNameReference AssemblyReference { - get { return reference; } - } - - public AssemblyResolutionException (AssemblyNameReference reference) - : this (reference, null) - { - } - - public AssemblyResolutionException (AssemblyNameReference reference, Exception innerException) - : base (string.Format ("Failed to resolve assembly: '{0}'", reference), innerException) - { - this.reference = reference; - } - -#if !NET_CORE - AssemblyResolutionException ( - System.Runtime.Serialization.SerializationInfo info, - System.Runtime.Serialization.StreamingContext context) - : base (info, context) - { - } -#endif - } - - public abstract class BaseAssemblyResolver : IAssemblyResolver { - - static readonly bool on_mono = Type.GetType ("Mono.Runtime") != null; - - readonly Collection directories; - -#if NET_CORE - // Maps file names of available trusted platform assemblies to their full paths. - // Internal for testing. - internal static readonly Lazy> TrustedPlatformAssemblies = new Lazy> (CreateTrustedPlatformAssemblyMap); -#else - Collection gac_paths; -#endif - - public void AddSearchDirectory (string directory) - { - directories.Add (directory); - } - - public void RemoveSearchDirectory (string directory) - { - directories.Remove (directory); - } - - public string [] GetSearchDirectories () - { - var directories = new string [this.directories.size]; - Array.Copy (this.directories.items, directories, directories.Length); - return directories; - } - - public event AssemblyResolveEventHandler ResolveFailure; - - protected BaseAssemblyResolver () - { - directories = new Collection (2) { ".", "bin" }; - } - - AssemblyDefinition GetAssembly (string file, ReaderParameters parameters) - { - if (parameters.AssemblyResolver == null) - parameters.AssemblyResolver = this; - - return ModuleDefinition.ReadModule (file, parameters).Assembly; - } - - public virtual AssemblyDefinition Resolve (AssemblyNameReference name) - { - return Resolve (name, new ReaderParameters ()); - } - - public virtual AssemblyDefinition Resolve (AssemblyNameReference name, ReaderParameters parameters) - { - Mixin.CheckName (name); - Mixin.CheckParameters (parameters); - - var assembly = SearchDirectory (name, directories, parameters); - if (assembly != null) - return assembly; - - if (name.IsRetargetable) { - // if the reference is retargetable, zero it - name = new AssemblyNameReference (name.Name, Mixin.ZeroVersion) { - PublicKeyToken = Empty.Array, - }; - } - -#if NET_CORE - assembly = SearchTrustedPlatformAssemblies (name, parameters); - if (assembly != null) - return assembly; -#else - var framework_dir = Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName); - var framework_dirs = on_mono - ? new [] { framework_dir, Path.Combine (framework_dir, "Facades") } - : new [] { framework_dir }; - - if (IsZero (name.Version)) { - assembly = SearchDirectory (name, framework_dirs, parameters); - if (assembly != null) - return assembly; - } - - if (name.Name == "mscorlib") { - assembly = GetCorlib (name, parameters); - if (assembly != null) - return assembly; - } - - assembly = GetAssemblyInGac (name, parameters); - if (assembly != null) - return assembly; - - assembly = SearchDirectory (name, framework_dirs, parameters); - if (assembly != null) - return assembly; -#endif - if (ResolveFailure != null) { - assembly = ResolveFailure (this, name); - if (assembly != null) - return assembly; - } - - throw new AssemblyResolutionException (name); - } - -#if NET_CORE - AssemblyDefinition SearchTrustedPlatformAssemblies (AssemblyNameReference name, ReaderParameters parameters) - { - if (name.IsWindowsRuntime) - return null; - - if (TrustedPlatformAssemblies.Value.TryGetValue (name.Name, out string path)) - return GetAssembly (path, parameters); - - return null; - } - - static Dictionary CreateTrustedPlatformAssemblyMap () - { - var result = new Dictionary (StringComparer.OrdinalIgnoreCase); - - string paths; - - try { - // AppContext is only available on platforms that implement .NET Standard 1.6 - var appContextType = Type.GetType ("System.AppContext, System.AppContext, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", throwOnError: false); - var getData = appContextType?.GetTypeInfo ().GetDeclaredMethod ("GetData"); - paths = (string) getData?.Invoke (null, new [] { "TRUSTED_PLATFORM_ASSEMBLIES" }); - } catch { - paths = null; - } - - if (paths == null) - return result; - - foreach (var path in paths.Split (Path.PathSeparator)) - if (string.Equals (Path.GetExtension (path), ".dll", StringComparison.OrdinalIgnoreCase)) - result [Path.GetFileNameWithoutExtension (path)] = path; - - return result; - } -#endif - - protected virtual AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable directories, ReaderParameters parameters) - { - var extensions = name.IsWindowsRuntime ? new [] { ".winmd", ".dll" } : 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)) - continue; - try { - return GetAssembly (file, parameters); - } catch (System.BadImageFormatException) { - continue; - } - } - } - - return null; - } - - static bool IsZero (Version version) - { - return version.Major == 0 && version.Minor == 0 && version.Build == 0 && version.Revision == 0; - } - -#if !NET_CORE - AssemblyDefinition GetCorlib (AssemblyNameReference reference, ReaderParameters parameters) - { - var version = reference.Version; - var corlib = typeof (object).Assembly.GetName (); - if (corlib.Version == version || IsZero (version)) - return GetAssembly (typeof (object).Module.FullyQualifiedName, parameters); - - var path = Directory.GetParent ( - Directory.GetParent ( - typeof (object).Module.FullyQualifiedName).FullName - ).FullName; - - if (on_mono) { - if (version.Major == 1) - path = Path.Combine (path, "1.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: " + version); - } else { - 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"); - break; - case 4: - path = Path.Combine (path, "v4.0.30319"); - break; - default: - throw new NotSupportedException ("Version not supported: " + version); - } - } - - var file = Path.Combine (path, "mscorlib.dll"); - if (File.Exists (file)) - return GetAssembly (file, parameters); - - return null; - } - - static Collection GetGacPaths () - { - if (on_mono) - return GetDefaultMonoGacPaths (); - - var paths = new Collection (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 GetDefaultMonoGacPaths () - { - var paths = new Collection (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 Path.Combine ( - Directory.GetParent ( - Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName)).FullName, - "gac"); - } - - AssemblyDefinition GetAssemblyInGac (AssemblyNameReference reference, ReaderParameters parameters) - { - if (reference.PublicKeyToken == null || reference.PublicKeyToken.Length == 0) - return null; - - if (gac_paths == null) - gac_paths = GetGacPaths (); - - if (on_mono) - return GetAssemblyInMonoGac (reference, parameters); - - return GetAssemblyInNetGac (reference, parameters); - } - - AssemblyDefinition GetAssemblyInMonoGac (AssemblyNameReference reference, ReaderParameters parameters) - { - 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, parameters); - } - - return null; - } - - AssemblyDefinition GetAssemblyInNetGac (AssemblyNameReference reference, ReaderParameters parameters) - { - var gacs = new [] { "GAC_MSIL", "GAC_32", "GAC_64", "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, parameters); - } - } - - return null; - } -#endif - static string GetAssemblyFile (AssemblyNameReference reference, string prefix, string gac) - { - var gac_folder = new StringBuilder () - .Append (prefix) - .Append (reference.Version) - .Append ("__"); - - for (int i = 0; i < reference.PublicKeyToken.Length; i++) - gac_folder.Append (reference.PublicKeyToken [i].ToString ("x2")); - - return Path.Combine ( - Path.Combine ( - Path.Combine (gac, reference.Name), gac_folder.ToString ()), - reference.Name + ".dll"); - } - - public void Dispose () - { - Dispose (true); - GC.SuppressFinalize (this); - } - - protected virtual void Dispose (bool disposing) - { - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/CallSite.cs b/external/linker/cecil/Mono.Cecil/CallSite.cs deleted file mode 100644 index ebb108f298..0000000000 --- a/external/linker/cecil/Mono.Cecil/CallSite.cs +++ /dev/null @@ -1,106 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Text; - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public sealed class CallSite : IMethodSignature { - - readonly MethodReference signature; - - public bool HasThis { - get { return signature.HasThis; } - set { signature.HasThis = value; } - } - - public bool ExplicitThis { - get { return signature.ExplicitThis; } - set { signature.ExplicitThis = value; } - } - - public MethodCallingConvention CallingConvention { - get { return signature.CallingConvention; } - set { signature.CallingConvention = value; } - } - - public bool HasParameters { - get { return signature.HasParameters; } - } - - public Collection Parameters { - get { return signature.Parameters; } - } - - public TypeReference ReturnType { - get { return signature.MethodReturnType.ReturnType; } - set { signature.MethodReturnType.ReturnType = value; } - } - - public MethodReturnType MethodReturnType { - get { return signature.MethodReturnType; } - } - - public string Name { - get { return string.Empty; } - set { throw new InvalidOperationException (); } - } - - public string Namespace { - get { return string.Empty; } - set { throw new InvalidOperationException (); } - } - - public ModuleDefinition Module { - get { return ReturnType.Module; } - } - - public IMetadataScope Scope { - get { return signature.ReturnType.Scope; } - } - - public MetadataToken MetadataToken { - get { return signature.token; } - set { signature.token = value; } - } - - public string FullName { - get { - var signature = new StringBuilder (); - signature.Append (ReturnType.FullName); - this.MethodSignatureFullName (signature); - return signature.ToString (); - } - } - - internal CallSite () - { - this.signature = new MethodReference (); - this.signature.token = new MetadataToken (TokenType.Signature, 0); - } - - public CallSite (TypeReference returnType) - : this () - { - if (returnType == null) - throw new ArgumentNullException ("returnType"); - - this.signature.ReturnType = returnType; - } - - public override string ToString () - { - return FullName; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/Consts.cs b/external/linker/cecil/Mono.Cecil/Consts.cs deleted file mode 100644 index 3b80461c50..0000000000 --- a/external/linker/cecil/Mono.Cecil/Consts.cs +++ /dev/null @@ -1,5 +0,0 @@ -static class Consts -{ - public const string AssemblyName = "Mono.Cecil"; - public const string PublicKey = "00240000048000009400000006020000002400005253413100040000010001002b5c9f7f04346c324a3176f8d3ee823bbf2d60efdbc35f86fd9e65ea3e6cd11bcdcba3a353e55133c8ac5c4caaba581b2c6dfff2cc2d0edc43959ddb86b973300a479a82419ef489c3225f1fe429a708507bd515835160e10bc743d20ca33ab9570cfd68d479fcf0bc797a763bec5d1000f0159ef619e709d915975e87beebaf"; -} \ No newline at end of file diff --git a/external/linker/cecil/Mono.Cecil/CustomAttribute.cs b/external/linker/cecil/Mono.Cecil/CustomAttribute.cs deleted file mode 100644 index d64411fc22..0000000000 --- a/external/linker/cecil/Mono.Cecil/CustomAttribute.cs +++ /dev/null @@ -1,205 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Diagnostics; -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - 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 string Name { - get { return name; } - } - - public CustomAttributeArgument Argument { - get { return argument; } - } - - 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; } - bool HasConstructorArguments { get; } - Collection Fields { get; } - Collection Properties { get; } - Collection ConstructorArguments { get; } - } - - [DebuggerDisplay ("{AttributeType}")] - public sealed class CustomAttribute : ICustomAttribute { - - internal CustomAttributeValueProjection projection; - readonly internal uint signature; - internal bool resolved; - MethodReference constructor; - byte [] blob; - internal Collection arguments; - internal Collection fields; - internal Collection properties; - - public MethodReference Constructor { - get { return constructor; } - set { constructor = value; } - } - - public TypeReference AttributeType { - get { return constructor.DeclaringType; } - } - - public bool IsResolved { - get { return resolved; } - } - - public bool HasConstructorArguments { - get { - Resolve (); - - return !arguments.IsNullOrEmpty (); - } - } - - public Collection ConstructorArguments { - get { - Resolve (); - - return arguments ?? (arguments = new Collection ()); - } - } - - public bool HasFields { - get { - Resolve (); - - return !fields.IsNullOrEmpty (); - } - } - - public Collection Fields { - get { - Resolve (); - - return fields ?? (fields = new Collection ()); - } - } - - public bool HasProperties { - get { - Resolve (); - - return !properties.IsNullOrEmpty (); - } - } - - public Collection Properties { - get { - Resolve (); - - return properties ?? (properties = new Collection ()); - } - } - - internal bool HasImage { - get { return constructor != null && constructor.HasImage; } - } - - internal ModuleDefinition Module { - get { return constructor.Module; } - } - - internal CustomAttribute (uint signature, MethodReference constructor) - { - this.signature = signature; - this.constructor = constructor; - this.resolved = false; - } - - public CustomAttribute (MethodReference constructor) - { - this.constructor = constructor; - this.resolved = true; - } - - public CustomAttribute (MethodReference constructor, byte [] blob) - { - this.constructor = constructor; - this.resolved = false; - this.blob = blob; - } - - public byte [] GetBlob () - { - if (blob != null) - return blob; - - if (!HasImage) - throw new NotSupportedException (); - - return Module.Read (ref blob, this, (attribute, reader) => reader.ReadCustomAttributeBlob (attribute.signature)); - } - - void Resolve () - { - if (resolved || !HasImage) - return; - - Module.Read (this, (attribute, reader) => { - try { - reader.ReadCustomAttributeSignature (attribute); - resolved = true; - } catch (ResolutionException) { - if (arguments != null) - arguments.Clear (); - if (fields != null) - fields.Clear (); - if (properties != null) - properties.Clear (); - - resolved = false; - } - }); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/DefaultAssemblyResolver.cs b/external/linker/cecil/Mono.Cecil/DefaultAssemblyResolver.cs deleted file mode 100644 index 755071ea4c..0000000000 --- a/external/linker/cecil/Mono.Cecil/DefaultAssemblyResolver.cs +++ /dev/null @@ -1,61 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; - -namespace Mono.Cecil { - - public class DefaultAssemblyResolver : BaseAssemblyResolver { - - readonly IDictionary cache; - - public DefaultAssemblyResolver () - { - cache = new Dictionary (StringComparer.Ordinal); - } - - public override AssemblyDefinition Resolve (AssemblyNameReference name) - { - Mixin.CheckName (name); - - 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) - { - if (assembly == null) - throw new ArgumentNullException ("assembly"); - - var name = assembly.Name.FullName; - if (cache.ContainsKey (name)) - return; - - cache [name] = assembly; - } - - protected override void Dispose (bool disposing) - { - foreach (var assembly in cache.Values) - assembly.Dispose (); - - cache.Clear (); - - base.Dispose (disposing); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/EmbeddedResource.cs b/external/linker/cecil/Mono.Cecil/EmbeddedResource.cs deleted file mode 100644 index 6b5f86a12e..0000000000 --- a/external/linker/cecil/Mono.Cecil/EmbeddedResource.cs +++ /dev/null @@ -1,98 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.IO; - -namespace Mono.Cecil { - - public sealed class EmbeddedResource : Resource { - - readonly MetadataReader reader; - - uint? offset; - byte [] data; - Stream stream; - - public override ResourceType ResourceType { - get { return ResourceType.Embedded; } - } - - public EmbeddedResource (string name, ManifestResourceAttributes attributes, byte [] data) : - base (name, attributes) - { - this.data = data; - } - - public EmbeddedResource (string name, ManifestResourceAttributes attributes, Stream stream) : - base (name, attributes) - { - this.stream = stream; - } - - internal EmbeddedResource (string name, ManifestResourceAttributes attributes, uint offset, MetadataReader reader) - : base (name, attributes) - { - 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 new MemoryStream (reader.GetManagedResource (offset.Value)); - - throw new InvalidOperationException (); - } - - public byte [] GetResourceData () - { - if (stream != null) - return ReadStream (stream); - - if (data != null) - return data; - - if (offset.HasValue) - return reader.GetManagedResource (offset.Value); - - throw new InvalidOperationException (); - } - - static byte [] ReadStream (Stream stream) - { - int read; - - if (stream.CanSeek) { - var length = (int) stream.Length; - var data = new byte [length]; - int offset = 0; - - while ((read = stream.Read (data, offset, length - offset)) > 0) - offset += read; - - return data; - } - - var buffer = new byte [1024 * 8]; - var memory = new MemoryStream (); - while ((read = stream.Read (buffer, 0, buffer.Length)) > 0) - memory.Write (buffer, 0, read); - - return memory.ToArray (); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/EventAttributes.cs b/external/linker/cecil/Mono.Cecil/EventAttributes.cs deleted file mode 100644 index 9f823fd1e6..0000000000 --- a/external/linker/cecil/Mono.Cecil/EventAttributes.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -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/external/linker/cecil/Mono.Cecil/EventDefinition.cs b/external/linker/cecil/Mono.Cecil/EventDefinition.cs deleted file mode 100644 index 33bc341adb..0000000000 --- a/external/linker/cecil/Mono.Cecil/EventDefinition.cs +++ /dev/null @@ -1,155 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public sealed class EventDefinition : EventReference, IMemberDefinition { - - ushort attributes; - - Collection custom_attributes; - - internal MethodDefinition add_method; - internal MethodDefinition invoke_method; - internal MethodDefinition remove_method; - internal Collection other_methods; - - public EventAttributes Attributes { - get { return (EventAttributes) attributes; } - set { attributes = (ushort) value; } - } - - public MethodDefinition AddMethod { - get { - if (add_method != null) - return add_method; - - InitializeMethods (); - return add_method; - } - set { add_method = value; } - } - - public MethodDefinition InvokeMethod { - get { - if (invoke_method != null) - return invoke_method; - - InitializeMethods (); - return invoke_method; - } - set { invoke_method = value; } - } - - public MethodDefinition RemoveMethod { - get { - if (remove_method != null) - return remove_method; - - InitializeMethods (); - return remove_method; - } - set { remove_method = value; } - } - - public bool HasOtherMethods { - get { - if (other_methods != null) - return other_methods.Count > 0; - - InitializeMethods (); - return !other_methods.IsNullOrEmpty (); - } - } - - public Collection OtherMethods { - get { - if (other_methods != null) - return other_methods; - - InitializeMethods (); - - if (other_methods != null) - return other_methods; - - return other_methods = new Collection (); - } - } - - public bool HasCustomAttributes { - get { - if (custom_attributes != null) - return custom_attributes.Count > 0; - - return this.GetHasCustomAttributes (Module); - } - } - - public Collection CustomAttributes { - get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, Module)); } - } - - #region EventAttributes - - public bool IsSpecialName { - get { return attributes.GetAttributes ((ushort) EventAttributes.SpecialName); } - set { attributes = attributes.SetAttributes ((ushort) EventAttributes.SpecialName, value); } - } - - public bool IsRuntimeSpecialName { - get { return attributes.GetAttributes ((ushort) EventAttributes.RTSpecialName); } - set { attributes = attributes.SetAttributes ((ushort) EventAttributes.RTSpecialName, value); } - } - - #endregion - - public new TypeDefinition DeclaringType { - get { return (TypeDefinition) base.DeclaringType; } - set { base.DeclaringType = value; } - } - - public override bool IsDefinition { - get { return true; } - } - - public EventDefinition (string name, EventAttributes attributes, TypeReference eventType) - : base (name, eventType) - { - this.attributes = (ushort) attributes; - this.token = new MetadataToken (TokenType.Event); - } - - void InitializeMethods () - { - var module = this.Module; - if (module == null) - return; - - lock (module.SyncRoot) { - if (add_method != null - || invoke_method != null - || remove_method != null) - return; - - if (!module.HasImage ()) - return; - - module.Read (this, (@event, reader) => reader.ReadMethods (@event)); - } - } - - public override EventDefinition Resolve () - { - return this; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/EventReference.cs b/external/linker/cecil/Mono.Cecil/EventReference.cs deleted file mode 100644 index d4df72b4d2..0000000000 --- a/external/linker/cecil/Mono.Cecil/EventReference.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - public abstract class EventReference : MemberReference { - - TypeReference event_type; - - public TypeReference EventType { - get { return event_type; } - set { event_type = value; } - } - - public override string FullName { - get { return event_type.FullName + " " + MemberFullName (); } - } - - protected EventReference (string name, TypeReference eventType) - : base (name) - { - Mixin.CheckType (eventType, Mixin.Argument.eventType); - event_type = eventType; - } - - protected override IMemberDefinition ResolveDefinition () - { - return this.Resolve (); - } - - public new abstract EventDefinition Resolve (); - } -} diff --git a/external/linker/cecil/Mono.Cecil/ExportedType.cs b/external/linker/cecil/Mono.Cecil/ExportedType.cs deleted file mode 100644 index 8238a0c6d9..0000000000 --- a/external/linker/cecil/Mono.Cecil/ExportedType.cs +++ /dev/null @@ -1,240 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - public sealed class ExportedType : IMetadataTokenProvider { - - string @namespace; - string name; - uint attributes; - IMetadataScope scope; - ModuleDefinition module; - 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; - } - set { - if (declaring_type != null) { - declaring_type.Scope = value; - return; - } - - scope = value; - } - } - - 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 { - var fullname = string.IsNullOrEmpty (@namespace) - ? name - : @namespace + '.' + name; - - if (declaring_type != null) - return declaring_type.FullName + "/" + fullname; - - return fullname; - } - } - - public ExportedType (string @namespace, string name, ModuleDefinition module, IMetadataScope scope) - { - this.@namespace = @namespace; - this.name = name; - this.scope = scope; - this.module = module; - } - - public override string ToString () - { - return FullName; - } - - public TypeDefinition Resolve () - { - return module.Resolve (CreateReference ()); - } - - internal TypeReference CreateReference () - { - return new TypeReference (@namespace, name, module, scope) { - DeclaringType = declaring_type != null ? declaring_type.CreateReference () : null, - }; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/FieldAttributes.cs b/external/linker/cecil/Mono.Cecil/FieldAttributes.cs deleted file mode 100644 index 7d5bb544a3..0000000000 --- a/external/linker/cecil/Mono.Cecil/FieldAttributes.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - [Flags] - public enum FieldAttributes : ushort { - FieldAccessMask = 0x0007, - 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 - Family = 0x0004, // Accessible only by type and sub-types - FamORAssem = 0x0005, // Accessible by sub-types anywhere, plus anyone in the assembly - Public = 0x0006, // Accessible by anyone who has visibility to this scope field contract attributes - - Static = 0x0010, // Defined on type, else per instance - InitOnly = 0x0020, // Field may only be initialized, not written after init - Literal = 0x0040, // Value is compile time constant - NotSerialized = 0x0080, // Field does not have to be serialized when type is remoted - SpecialName = 0x0200, // Field is special - - // Interop Attributes - PInvokeImpl = 0x2000, // Implementation is forwarded through PInvoke - - // Additional flags - RTSpecialName = 0x0400, // CLI provides 'special' behavior, depending upon the name of the field - HasFieldMarshal = 0x1000, // Field has marshalling information - HasDefault = 0x8000, // Field has default - HasFieldRVA = 0x0100 // Field has RVA - } -} diff --git a/external/linker/cecil/Mono.Cecil/FieldDefinition.cs b/external/linker/cecil/Mono.Cecil/FieldDefinition.cs deleted file mode 100644 index 593b77e592..0000000000 --- a/external/linker/cecil/Mono.Cecil/FieldDefinition.cs +++ /dev/null @@ -1,267 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public sealed class FieldDefinition : FieldReference, IMemberDefinition, IConstantProvider, IMarshalInfoProvider { - - ushort attributes; - Collection custom_attributes; - - int offset = Mixin.NotResolvedMarker; - - internal int rva = Mixin.NotResolvedMarker; - byte [] initial_value; - - object constant = Mixin.NotResolved; - - MarshalInfo marshal_info; - - void ResolveLayout () - { - if (offset != Mixin.NotResolvedMarker) - return; - - if (!HasImage) { - offset = Mixin.NoDataMarker; - return; - } - - offset = Module.Read (this, (field, reader) => reader.ReadFieldLayout (field)); - } - - public bool HasLayoutInfo { - get { - if (offset >= 0) - return true; - - ResolveLayout (); - - return offset >= 0; - } - } - - public int Offset { - get { - if (offset >= 0) - return offset; - - ResolveLayout (); - - return offset >= 0 ? offset : -1; - } - set { offset = value; } - } - - internal new FieldDefinitionProjection WindowsRuntimeProjection { - get { return (FieldDefinitionProjection) projection; } - set { projection = value; } - } - - void ResolveRVA () - { - if (rva != Mixin.NotResolvedMarker) - return; - - if (!HasImage) - return; - - rva = Module.Read (this, (field, reader) => reader.ReadFieldRVA (field)); - } - - public int RVA { - get { - if (rva > 0) - return rva; - - ResolveRVA (); - - return rva > 0 ? rva : 0; - } - } - - public byte [] InitialValue { - get { - if (initial_value != null) - return initial_value; - - ResolveRVA (); - - if (initial_value == null) - initial_value = Empty.Array; - - return initial_value; - } - set { - initial_value = value; - rva = 0; - } - } - - public FieldAttributes Attributes { - get { return (FieldAttributes) attributes; } - set { - if (IsWindowsRuntimeProjection && (ushort) value != attributes) - throw new InvalidOperationException (); - - attributes = (ushort) value; - } - } - - public bool HasConstant { - get { - this.ResolveConstant (ref constant, Module); - - return constant != Mixin.NoValue; - } - set { if (!value) constant = Mixin.NoValue; } - } - - public object Constant { - get { return HasConstant ? constant : null; } - set { constant = value; } - } - - public bool HasCustomAttributes { - get { - if (custom_attributes != null) - return custom_attributes.Count > 0; - - return this.GetHasCustomAttributes (Module); - } - } - - public Collection CustomAttributes { - get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, Module)); } - } - - public bool HasMarshalInfo { - get { - if (marshal_info != null) - return true; - - return this.GetHasMarshalInfo (Module); - } - } - - public MarshalInfo MarshalInfo { - get { return marshal_info ?? (this.GetMarshalInfo (ref marshal_info, Module)); } - set { marshal_info = value; } - } - - #region FieldAttributes - - public bool IsCompilerControlled { - 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 attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Private); } - set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Private, value); } - } - - public bool IsFamilyAndAssembly { - 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 attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Assembly); } - set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.Assembly, value); } - } - - public bool IsFamily { - 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 attributes.GetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.FamORAssem); } - set { attributes = attributes.SetMaskedAttributes ((ushort) FieldAttributes.FieldAccessMask, (ushort) FieldAttributes.FamORAssem, value); } - } - - public bool IsPublic { - 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 attributes.GetAttributes ((ushort) FieldAttributes.Static); } - set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.Static, value); } - } - - public bool IsInitOnly { - get { return attributes.GetAttributes ((ushort) FieldAttributes.InitOnly); } - set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.InitOnly, value); } - } - - public bool IsLiteral { - get { return attributes.GetAttributes ((ushort) FieldAttributes.Literal); } - set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.Literal, value); } - } - - public bool IsNotSerialized { - get { return attributes.GetAttributes ((ushort) FieldAttributes.NotSerialized); } - set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.NotSerialized, value); } - } - - public bool IsSpecialName { - get { return attributes.GetAttributes ((ushort) FieldAttributes.SpecialName); } - set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.SpecialName, value); } - } - - public bool IsPInvokeImpl { - get { return attributes.GetAttributes ((ushort) FieldAttributes.PInvokeImpl); } - set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.PInvokeImpl, value); } - } - - public bool IsRuntimeSpecialName { - get { return attributes.GetAttributes ((ushort) FieldAttributes.RTSpecialName); } - set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.RTSpecialName, value); } - } - - public bool HasDefault { - get { return attributes.GetAttributes ((ushort) FieldAttributes.HasDefault); } - set { attributes = attributes.SetAttributes ((ushort) FieldAttributes.HasDefault, value); } - } - - #endregion - - public override bool IsDefinition { - get { return true; } - } - - public new TypeDefinition DeclaringType { - get { return (TypeDefinition) base.DeclaringType; } - set { base.DeclaringType = value; } - } - - public FieldDefinition (string name, FieldAttributes attributes, TypeReference fieldType) - : base (name, fieldType) - { - this.attributes = (ushort) attributes; - } - - public override FieldDefinition Resolve () - { - return this; - } - } - - static partial class Mixin { - - public const int NotResolvedMarker = -2; - public const int NoDataMarker = -1; - } -} diff --git a/external/linker/cecil/Mono.Cecil/FieldReference.cs b/external/linker/cecil/Mono.Cecil/FieldReference.cs deleted file mode 100644 index 944c22595c..0000000000 --- a/external/linker/cecil/Mono.Cecil/FieldReference.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - public class FieldReference : MemberReference { - - TypeReference field_type; - - public TypeReference FieldType { - get { return field_type; } - set { field_type = value; } - } - - public override string FullName { - get { return field_type.FullName + " " + MemberFullName (); } - } - - public override bool ContainsGenericParameter { - get { return field_type.ContainsGenericParameter || base.ContainsGenericParameter; } - } - - internal FieldReference () - { - this.token = new MetadataToken (TokenType.MemberRef); - } - - public FieldReference (string name, TypeReference fieldType) - : base (name) - { - Mixin.CheckType (fieldType, Mixin.Argument.fieldType); - - this.field_type = fieldType; - this.token = new MetadataToken (TokenType.MemberRef); - } - - public FieldReference (string name, TypeReference fieldType, TypeReference declaringType) - : this (name, fieldType) - { - Mixin.CheckType (declaringType, Mixin.Argument.declaringType); - - this.DeclaringType = declaringType; - } - - protected override IMemberDefinition ResolveDefinition () - { - return this.Resolve (); - } - - public new virtual FieldDefinition Resolve () - { - var module = this.Module; - if (module == null) - throw new NotSupportedException (); - - return module.Resolve (this); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/FileAttributes.cs b/external/linker/cecil/Mono.Cecil/FileAttributes.cs deleted file mode 100644 index 171f174b0b..0000000000 --- a/external/linker/cecil/Mono.Cecil/FileAttributes.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil { - - 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/external/linker/cecil/Mono.Cecil/FunctionPointerType.cs b/external/linker/cecil/Mono.Cecil/FunctionPointerType.cs deleted file mode 100644 index 0602fcbe8a..0000000000 --- a/external/linker/cecil/Mono.Cecil/FunctionPointerType.cs +++ /dev/null @@ -1,111 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Text; -using Mono.Collections.Generic; -using MD = Mono.Cecil.Metadata; - -namespace Mono.Cecil { - - public sealed class FunctionPointerType : TypeSpecification, IMethodSignature { - - readonly MethodReference function; - - public bool HasThis { - get { return function.HasThis; } - set { function.HasThis = value; } - } - - public bool ExplicitThis { - get { return function.ExplicitThis; } - set { function.ExplicitThis = value; } - } - - public MethodCallingConvention CallingConvention { - get { return function.CallingConvention; } - set { function.CallingConvention = value; } - } - - public bool HasParameters { - get { return function.HasParameters; } - } - - public Collection Parameters { - get { return function.Parameters; } - } - - 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 function.Name; } - set { throw new InvalidOperationException (); } - } - - public override string Namespace { - get { return string.Empty; } - set { throw new InvalidOperationException (); } - } - - public override ModuleDefinition Module { - get { return ReturnType.Module; } - } - - public override IMetadataScope Scope { - get { return function.ReturnType.Scope; } - set { throw new InvalidOperationException (); } - } - - public override bool IsFunctionPointer { - get { return true; } - } - - public override bool ContainsGenericParameter { - get { return function.ContainsGenericParameter; } - } - - public override string FullName { - get { - 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 () - : base (null) - { - this.function = new MethodReference (); - this.function.Name = "method"; - this.etype = MD.ElementType.FnPtr; - } - - public override TypeDefinition Resolve () - { - return null; - } - - public override TypeReference GetElementType () - { - return this; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/GenericInstanceMethod.cs b/external/linker/cecil/Mono.Cecil/GenericInstanceMethod.cs deleted file mode 100644 index 00de03a3bd..0000000000 --- a/external/linker/cecil/Mono.Cecil/GenericInstanceMethod.cs +++ /dev/null @@ -1,67 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Text; - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public sealed class GenericInstanceMethod : MethodSpecification, IGenericInstance, IGenericContext { - - Collection arguments; - - public bool HasGenericArguments { - get { return !arguments.IsNullOrEmpty (); } - } - - public Collection GenericArguments { - get { return arguments ?? (arguments = new Collection ()); } - } - - public override bool IsGenericInstance { - get { return true; } - } - - IGenericParameterProvider IGenericContext.Method { - get { return ElementMethod; } - } - - IGenericParameterProvider IGenericContext.Type { - get { return ElementMethod.DeclaringType; } - } - - public 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) - .Append (" ") - .Append (method.DeclaringType.FullName) - .Append ("::") - .Append (method.Name); - this.GenericInstanceFullName (signature); - this.MethodSignatureFullName (signature); - return signature.ToString (); - - } - } - - public GenericInstanceMethod (MethodReference method) - : base (method) - { - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/GenericInstanceType.cs b/external/linker/cecil/Mono.Cecil/GenericInstanceType.cs deleted file mode 100644 index 0e683e7134..0000000000 --- a/external/linker/cecil/Mono.Cecil/GenericInstanceType.cs +++ /dev/null @@ -1,65 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Text; - -using Mono.Collections.Generic; - -using MD = Mono.Cecil.Metadata; - -namespace Mono.Cecil { - - public sealed class GenericInstanceType : TypeSpecification, IGenericInstance, IGenericContext { - - Collection arguments; - - public bool HasGenericArguments { - get { return !arguments.IsNullOrEmpty (); } - } - - public Collection GenericArguments { - get { return arguments ?? (arguments = new Collection ()); } - } - - public override TypeReference DeclaringType { - get { return ElementType.DeclaringType; } - set { throw new NotSupportedException (); } - } - - public override string FullName { - get { - var name = new StringBuilder (); - name.Append (base.FullName); - this.GenericInstanceFullName (name); - return name.ToString (); - } - } - - public override bool IsGenericInstance { - get { return true; } - } - - public override bool ContainsGenericParameter { - get { return this.ContainsGenericParameter () || base.ContainsGenericParameter; } - } - - IGenericParameterProvider IGenericContext.Type { - get { return ElementType; } - } - - public GenericInstanceType (TypeReference type) - : base (type) - { - base.IsValueType = type.IsValueType; - this.etype = MD.ElementType.GenericInst; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/GenericParameter.cs b/external/linker/cecil/Mono.Cecil/GenericParameter.cs deleted file mode 100644 index f2997da6d2..0000000000 --- a/external/linker/cecil/Mono.Cecil/GenericParameter.cs +++ /dev/null @@ -1,268 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using Mono.Collections.Generic; - -using Mono.Cecil.Metadata; - -namespace Mono.Cecil { - - public sealed class GenericParameter : TypeReference, ICustomAttributeProvider { - - internal int position; - internal GenericParameterType type; - internal IGenericParameterProvider owner; - - ushort attributes; - Collection constraints; - Collection custom_attributes; - - public GenericParameterAttributes Attributes { - get { return (GenericParameterAttributes) attributes; } - set { attributes = (ushort) value; } - } - - public int Position { - get { return position; } - } - - public GenericParameterType Type { - get { return type; } - } - - public IGenericParameterProvider Owner { - get { return owner; } - } - - public bool HasConstraints { - get { - if (constraints != null) - return constraints.Count > 0; - - return HasImage && Module.Read (this, (generic_parameter, reader) => reader.HasGenericConstraints (generic_parameter)); - } - } - - public Collection Constraints { - get { - if (constraints != null) - return constraints; - - if (HasImage) - return Module.Read (ref constraints, this, (generic_parameter, reader) => reader.ReadGenericConstraints (generic_parameter)); - - return constraints = new Collection (); - } - } - - public bool HasCustomAttributes { - get { - if (custom_attributes != null) - return custom_attributes.Count > 0; - - return this.GetHasCustomAttributes (Module); - } - } - - public Collection CustomAttributes { - get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, Module)); } - } - - public override IMetadataScope Scope { - get { - if (owner == null) - return null; - - return owner.GenericParameterType == GenericParameterType.Method - ? ((MethodReference) owner).DeclaringType.Scope - : ((TypeReference) owner).Scope; - } - set { throw new InvalidOperationException (); } - } - - public override TypeReference DeclaringType { - get { return owner as TypeReference; } - set { throw new InvalidOperationException (); } - } - - public MethodReference DeclaringMethod { - get { return owner as MethodReference; } - } - - public override ModuleDefinition Module { - get { return module ?? owner.Module; } - } - - public override string Name { - get { - if (!string.IsNullOrEmpty (base.Name)) - return base.Name; - - return base.Name = (type == GenericParameterType.Method ? "!!" : "!") + position; - } - } - - public override string Namespace { - get { return string.Empty; } - set { throw new InvalidOperationException (); } - } - - public override string FullName { - get { return Name; } - } - - public override bool IsGenericParameter { - get { return true; } - } - - public override bool ContainsGenericParameter { - get { return true; } - } - - public override MetadataType MetadataType { - get { return (MetadataType) etype; } - } - - #region GenericParameterAttributes - - public bool IsNonVariant { - 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 attributes.GetMaskedAttributes ((ushort) GenericParameterAttributes.VarianceMask, (ushort) GenericParameterAttributes.Covariant); } - set { attributes = attributes.SetMaskedAttributes ((ushort) GenericParameterAttributes.VarianceMask, (ushort) GenericParameterAttributes.Covariant, value); } - } - - public bool IsContravariant { - 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 attributes.GetAttributes ((ushort) GenericParameterAttributes.ReferenceTypeConstraint); } - set { attributes = attributes.SetAttributes ((ushort) GenericParameterAttributes.ReferenceTypeConstraint, value); } - } - - public bool HasNotNullableValueTypeConstraint { - get { return attributes.GetAttributes ((ushort) GenericParameterAttributes.NotNullableValueTypeConstraint); } - set { attributes = attributes.SetAttributes ((ushort) GenericParameterAttributes.NotNullableValueTypeConstraint, value); } - } - - public bool HasDefaultConstructorConstraint { - get { return attributes.GetAttributes ((ushort) GenericParameterAttributes.DefaultConstructorConstraint); } - set { attributes = attributes.SetAttributes ((ushort) GenericParameterAttributes.DefaultConstructorConstraint, value); } - } - - #endregion - - public GenericParameter (IGenericParameterProvider owner) - : this (string.Empty, owner) - { - } - - public GenericParameter (string name, IGenericParameterProvider owner) - : base (string.Empty, name) - { - if (owner == null) - throw new ArgumentNullException (); - - this.position = -1; - this.owner = owner; - this.type = owner.GenericParameterType; - this.etype = ConvertGenericParameterType (this.type); - this.token = new MetadataToken (TokenType.GenericParam); - - } - - internal GenericParameter (int position, GenericParameterType type, ModuleDefinition module) - : base (string.Empty, string.Empty) - { - Mixin.CheckModule (module); - - this.position = position; - this.type = type; - this.etype = ConvertGenericParameterType (type); - this.module = module; - this.token = new MetadataToken (TokenType.GenericParam); - } - - static ElementType ConvertGenericParameterType (GenericParameterType type) - { - switch (type) { - case GenericParameterType.Type: - return ElementType.Var; - case GenericParameterType.Method: - return ElementType.MVar; - } - - throw new ArgumentOutOfRangeException (); - } - - public override TypeDefinition Resolve () - { - return null; - } - } - - sealed class GenericParameterCollection : Collection { - - readonly IGenericParameterProvider owner; - - internal GenericParameterCollection (IGenericParameterProvider owner) - { - this.owner = owner; - } - - internal GenericParameterCollection (IGenericParameterProvider owner, int capacity) - : base (capacity) - { - this.owner = owner; - } - - protected override void OnAdd (GenericParameter item, int index) - { - UpdateGenericParameter (item, index); - } - - protected override void OnInsert (GenericParameter item, int index) - { - UpdateGenericParameter (item, index); - - for (int i = index; i < size; i++) - items[i].position = i + 1; - } - - protected override void OnSet (GenericParameter item, int index) - { - UpdateGenericParameter (item, index); - } - - void UpdateGenericParameter (GenericParameter item, int index) - { - item.owner = owner; - item.position = index; - item.type = owner.GenericParameterType; - } - - protected override void OnRemove (GenericParameter item, int index) - { - item.owner = null; - item.position = -1; - item.type = GenericParameterType.Type; - - for (int i = index + 1; i < size; i++) - items[i].position = i - 1; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/GenericParameterAttributes.cs b/external/linker/cecil/Mono.Cecil/GenericParameterAttributes.cs deleted file mode 100644 index 149582cdba..0000000000 --- a/external/linker/cecil/Mono.Cecil/GenericParameterAttributes.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - [Flags] - public enum GenericParameterAttributes : ushort { - VarianceMask = 0x0003, - NonVariant = 0x0000, - Covariant = 0x0001, - Contravariant = 0x0002, - - SpecialConstraintMask = 0x001c, - ReferenceTypeConstraint = 0x0004, - NotNullableValueTypeConstraint = 0x0008, - DefaultConstructorConstraint = 0x0010 - } -} diff --git a/external/linker/cecil/Mono.Cecil/IConstantProvider.cs b/external/linker/cecil/Mono.Cecil/IConstantProvider.cs deleted file mode 100644 index 178b66511b..0000000000 --- a/external/linker/cecil/Mono.Cecil/IConstantProvider.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil { - - public interface IConstantProvider : IMetadataTokenProvider { - - bool HasConstant { get; set; } - 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) - { - if (module == null) { - constant = Mixin.NoValue; - return; - } - - lock (module.SyncRoot) { - if (constant != Mixin.NotResolved) - return; - if (module.HasImage ()) - constant = module.Read (self, (provider, reader) => reader.ReadConstant (provider)); - else - constant = Mixin.NoValue; - } - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/ICustomAttributeProvider.cs b/external/linker/cecil/Mono.Cecil/ICustomAttributeProvider.cs deleted file mode 100644 index 36d7ed018f..0000000000 --- a/external/linker/cecil/Mono.Cecil/ICustomAttributeProvider.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public interface ICustomAttributeProvider : IMetadataTokenProvider { - - Collection CustomAttributes { get; } - - bool HasCustomAttributes { get; } - } - - static partial class Mixin { - - public static bool GetHasCustomAttributes ( - this ICustomAttributeProvider self, - ModuleDefinition module) - { - return module.HasImage () && module.Read (self, (provider, reader) => reader.HasCustomAttributes (provider)); - } - - public static Collection GetCustomAttributes ( - this ICustomAttributeProvider self, - ref Collection variable, - ModuleDefinition module) - { - return module.HasImage () - ? module.Read (ref variable, self, (provider, reader) => reader.ReadCustomAttributes (provider)) - : variable = new Collection(); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/IGenericInstance.cs b/external/linker/cecil/Mono.Cecil/IGenericInstance.cs deleted file mode 100644 index e98d8189b0..0000000000 --- a/external/linker/cecil/Mono.Cecil/IGenericInstance.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System.Text; - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public interface IGenericInstance : IMetadataTokenProvider { - - bool HasGenericArguments { get; } - Collection 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/external/linker/cecil/Mono.Cecil/IGenericParameterProvider.cs b/external/linker/cecil/Mono.Cecil/IGenericParameterProvider.cs deleted file mode 100644 index 4c8dfc4da7..0000000000 --- a/external/linker/cecil/Mono.Cecil/IGenericParameterProvider.cs +++ /dev/null @@ -1,56 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public interface IGenericParameterProvider : IMetadataTokenProvider { - - bool HasGenericParameters { get; } - bool IsDefinition { get; } - ModuleDefinition Module { get; } - Collection 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)); - } - - public static Collection GetGenericParameters ( - this IGenericParameterProvider self, - ref Collection collection, - ModuleDefinition module) - { - return module.HasImage () - ? module.Read (ref collection, self, (provider, reader) => reader.ReadGenericParameters (provider)) - : collection = new GenericParameterCollection (self); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/IMarshalInfoProvider.cs b/external/linker/cecil/Mono.Cecil/IMarshalInfoProvider.cs deleted file mode 100644 index a1b9e88344..0000000000 --- a/external/linker/cecil/Mono.Cecil/IMarshalInfoProvider.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil { - - public interface IMarshalInfoProvider : IMetadataTokenProvider { - - bool HasMarshalInfo { get; } - MarshalInfo MarshalInfo { get; set; } - } - - static partial class Mixin { - - public static bool GetHasMarshalInfo ( - this IMarshalInfoProvider self, - ModuleDefinition module) - { - return module.HasImage () && module.Read (self, (provider, reader) => reader.HasMarshalInfo (provider)); - } - - public static MarshalInfo GetMarshalInfo ( - this IMarshalInfoProvider self, - ref MarshalInfo variable, - ModuleDefinition module) - { - return module.HasImage () - ? module.Read (ref variable, self, (provider, reader) => reader.ReadMarshalInfo (provider)) - : null; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/IMemberDefinition.cs b/external/linker/cecil/Mono.Cecil/IMemberDefinition.cs deleted file mode 100644 index ad747002b9..0000000000 --- a/external/linker/cecil/Mono.Cecil/IMemberDefinition.cs +++ /dev/null @@ -1,82 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil { - - 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/external/linker/cecil/Mono.Cecil/IMetadataScope.cs b/external/linker/cecil/Mono.Cecil/IMetadataScope.cs deleted file mode 100644 index 2e56e758c8..0000000000 --- a/external/linker/cecil/Mono.Cecil/IMetadataScope.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil { - - public enum MetadataScopeType { - AssemblyNameReference, - ModuleReference, - ModuleDefinition, - } - - public interface IMetadataScope : IMetadataTokenProvider { - MetadataScopeType MetadataScopeType { get; } - string Name { get; set; } - } -} diff --git a/external/linker/cecil/Mono.Cecil/IMetadataTokenProvider.cs b/external/linker/cecil/Mono.Cecil/IMetadataTokenProvider.cs deleted file mode 100644 index dcd678b03f..0000000000 --- a/external/linker/cecil/Mono.Cecil/IMetadataTokenProvider.cs +++ /dev/null @@ -1,17 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil { - - public interface IMetadataTokenProvider { - - MetadataToken MetadataToken { get; set; } - } -} diff --git a/external/linker/cecil/Mono.Cecil/IMethodSignature.cs b/external/linker/cecil/Mono.Cecil/IMethodSignature.cs deleted file mode 100644 index 4d7766e456..0000000000 --- a/external/linker/cecil/Mono.Cecil/IMethodSignature.cs +++ /dev/null @@ -1,57 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System.Text; - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public interface IMethodSignature : IMetadataTokenProvider { - - bool HasThis { get; set; } - bool ExplicitThis { get; set; } - MethodCallingConvention CallingConvention { get; set; } - - bool HasParameters { get; } - Collection Parameters { get; } - TypeReference ReturnType { get; set; } - MethodReturnType MethodReturnType { get; } - } - - static partial class Mixin { - - public static bool HasImplicitThis (this IMethodSignature self) - { - return self.HasThis && !self.ExplicitThis; - } - - 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); - } - } - - builder.Append (")"); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/Import.cs b/external/linker/cecil/Mono.Cecil/Import.cs deleted file mode 100644 index 3d4d5bb126..0000000000 --- a/external/linker/cecil/Mono.Cecil/Import.cs +++ /dev/null @@ -1,819 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using Mono.Collections.Generic; -using SR = System.Reflection; - -using Mono.Cecil.Metadata; - -namespace Mono.Cecil { - -#if !READ_ONLY - - public interface IMetadataImporterProvider { - IMetadataImporter GetMetadataImporter (ModuleDefinition module); - } - - public interface IMetadataImporter { - AssemblyNameReference ImportReference (AssemblyNameReference reference); - TypeReference ImportReference (TypeReference type, IGenericParameterProvider context); - FieldReference ImportReference (FieldReference field, IGenericParameterProvider context); - MethodReference ImportReference (MethodReference method, IGenericParameterProvider context); - } - - public interface IReflectionImporterProvider { - IReflectionImporter GetReflectionImporter (ModuleDefinition module); - } - - public interface IReflectionImporter { - AssemblyNameReference ImportReference (SR.AssemblyName reference); - TypeReference ImportReference (Type type, IGenericParameterProvider context); - FieldReference ImportReference (SR.FieldInfo field, IGenericParameterProvider context); - MethodReference ImportReference (SR.MethodBase method, IGenericParameterProvider context); - } - - struct ImportGenericContext { - - Collection stack; - - public bool IsEmpty { get { return stack == null; } } - - public ImportGenericContext (IGenericParameterProvider provider) - { - if (provider == null) - throw new ArgumentNullException ("provider"); - - stack = null; - - Push (provider); - } - - public void Push (IGenericParameterProvider provider) - { - if (stack == null) - stack = new Collection (1) { provider }; - else - stack.Add (provider); - } - - public void Pop () - { - stack.RemoveAt (stack.Count - 1); - } - - public TypeReference MethodParameter (string method, int position) - { - for (int i = stack.Count - 1; i >= 0; i--) { - var candidate = stack [i] as MethodReference; - if (candidate == null) - continue; - - if (method != NormalizeMethodName (candidate)) - continue; - - return candidate.GenericParameters [position]; - } - - throw new InvalidOperationException (); - } - - public string NormalizeMethodName (MethodReference method) - { - return method.DeclaringType.GetElementType ().FullName + "." + method.Name; - } - - public TypeReference TypeParameter (string type, int position) - { - for (int i = stack.Count - 1; i >= 0; i--) { - var candidate = GenericTypeFor (stack [i]); - - if (candidate.FullName != type) - continue; - - return candidate.GenericParameters [position]; - } - - throw new InvalidOperationException (); - } - - static TypeReference GenericTypeFor (IGenericParameterProvider context) - { - var type = context as TypeReference; - if (type != null) - return type.GetElementType (); - - var method = context as MethodReference; - if (method != null) - return method.DeclaringType.GetElementType (); - - throw new InvalidOperationException (); - } - - public static ImportGenericContext For (IGenericParameterProvider context) - { - return context != null ? new ImportGenericContext (context) : default (ImportGenericContext); - } - } - - public class DefaultReflectionImporter : IReflectionImporter { - - readonly protected ModuleDefinition module; - - public DefaultReflectionImporter (ModuleDefinition module) - { - Mixin.CheckModule (module); - - this.module = module; - } - - enum ImportGenericKind { - Definition, - Open, - } - - static readonly Dictionary type_etype_mapping = new Dictionary (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 }, -#if !NET_CORE - { typeof (TypedReference), ElementType.TypedByRef }, -#endif - { typeof (IntPtr), ElementType.I }, - { typeof (UIntPtr), ElementType.U }, - { typeof (object), ElementType.Object }, - }; - - TypeReference ImportType (Type type, ImportGenericContext context) - { - return ImportType (type, context, ImportGenericKind.Open); - } - - TypeReference ImportType (Type type, ImportGenericContext context, ImportGenericKind import_kind) - { - if (IsTypeSpecification (type) || ImportOpenGenericType (type, import_kind)) - return ImportTypeSpecification (type, context); - - var reference = new TypeReference ( - string.Empty, - type.Name, - module, - ImportScope (type.Assembly ()), - type.IsValueType ()); - - reference.etype = ImportElementType (type); - - if (IsNestedType (type)) - reference.DeclaringType = ImportType (type.DeclaringType, context, import_kind); - else - reference.Namespace = type.Namespace ?? string.Empty; - - 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) - { - return type.IsNested; - } - - TypeReference ImportTypeSpecification (Type type, ImportGenericContext 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, ImportGenericContext context) - { - if (context.IsEmpty) - throw new InvalidOperationException (); - - if (type.DeclaringMethod () != null) - return context.MethodParameter (NormalizeMethodName (type.DeclaringMethod ()), type.GenericParameterPosition); - - if (type.DeclaringType != null) - return context.TypeParameter (NormalizeTypeFullName (type.DeclaringType), type.GenericParameterPosition); - - throw new InvalidOperationException(); - } - - static string NormalizeMethodName (SR.MethodBase method) - { - return NormalizeTypeFullName (method.DeclaringType) + "." + method.Name; - } - - static string NormalizeTypeFullName (Type type) - { - if (IsNestedType (type)) - return NormalizeTypeFullName (type.DeclaringType) + "/" + type.Name; - - return type.FullName; - } - - TypeReference ImportGenericInstance (Type type, ImportGenericContext 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; - - context.Push (element_type); - try { - for (int i = 0; i < arguments.Length; i++) - instance_arguments.Add (ImportType (arguments [i], context)); - - return instance; - } finally { - context.Pop (); - } - } - - 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) - { - return ImportReference (assembly.GetName ()); - } - - public virtual AssemblyNameReference ImportReference (SR.AssemblyName name) - { - Mixin.CheckName (name); - - AssemblyNameReference reference; - if (TryGetAssemblyNameReference (name, out reference)) - return reference; - - reference = new AssemblyNameReference (name.Name, name.Version) - { - PublicKeyToken = name.GetPublicKeyToken (), -#if !NET_CORE - Culture = name.CultureInfo.Name, - HashAlgorithm = (AssemblyHashAlgorithm) name.HashAlgorithm, -#endif - }; - - module.AssemblyReferences.Add (reference); - - return reference; - } - - 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; - } - - FieldReference ImportField (SR.FieldInfo field, ImportGenericContext context) - { - var declaring_type = ImportType (field.DeclaringType, context); - - if (IsGenericInstance (field.DeclaringType)) - field = ResolveFieldDefinition (field); - - context.Push (declaring_type); - try { - return new FieldReference { - Name = field.Name, - DeclaringType = declaring_type, - FieldType = ImportType (field.FieldType, context), - }; - } finally { - context.Pop (); - } - } - - static SR.FieldInfo ResolveFieldDefinition (SR.FieldInfo field) - { -#if NET_CORE - throw new NotImplementedException (); -#else - return field.Module.ResolveField (field.MetadataToken); -#endif - } - - static SR.MethodBase ResolveMethodDefinition (SR.MethodBase method) - { -#if NET_CORE - throw new NotImplementedException (); -#else - return method.Module.ResolveMethod (method.MetadataToken); -#endif - } - - MethodReference ImportMethod (SR.MethodBase method, ImportGenericContext 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 = ResolveMethodDefinition (method); - - 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 ()); - - context.Push (reference); - try { - var method_info = method as SR.MethodInfo; - reference.ReturnType = method_info != null - ? ImportType (method_info.ReturnType, context) - : ImportType (typeof (void), default (ImportGenericContext)); - - 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.DeclaringType = declaring_type; - - return reference; - } finally { - context.Pop (); - } - } - - 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, ImportGenericContext 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; - - context.Push (element_method); - try { - for (int i = 0; i < arguments.Length; i++) - instance_arguments.Add (ImportType (arguments [i], context)); - - return instance; - } finally { - context.Pop (); - } - } - - static bool HasCallingConvention (SR.MethodBase method, SR.CallingConventions conventions) - { - return (method.CallingConvention & conventions) != 0; - } - - public virtual TypeReference ImportReference (Type type, IGenericParameterProvider context) - { - Mixin.CheckType (type); - return ImportType ( - type, - ImportGenericContext.For (context), - context != null ? ImportGenericKind.Open : ImportGenericKind.Definition); - } - - public virtual FieldReference ImportReference (SR.FieldInfo field, IGenericParameterProvider context) - { - Mixin.CheckField (field); - return ImportField (field, ImportGenericContext.For (context)); - } - - public virtual MethodReference ImportReference (SR.MethodBase method, IGenericParameterProvider context) - { - Mixin.CheckMethod (method); - return ImportMethod (method, - ImportGenericContext.For (context), - context != null ? ImportGenericKind.Open : ImportGenericKind.Definition); - } - } - - public class DefaultMetadataImporter : IMetadataImporter { - - readonly protected ModuleDefinition module; - - public DefaultMetadataImporter (ModuleDefinition module) - { - Mixin.CheckModule (module); - - this.module = module; - } - - internal virtual TypeReference ImportType (TypeReference type, ImportGenericContext context) - { - if (type.IsTypeSpecification ()) - return ImportTypeSpecification (type, context); - - var reference = new TypeReference ( - type.Namespace, - type.Name, - module, - ImportScope (type.Scope), - type.IsValueType); - - MetadataSystem.TryProcessPrimitiveTypeReference (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 ImportReference ((AssemblyNameReference) scope); - case MetadataScopeType.ModuleDefinition: - if (scope == module) return scope; - return ImportReference (((ModuleDefinition) scope).Assembly.Name); - case MetadataScopeType.ModuleReference: - throw new NotImplementedException (); - } - - throw new NotSupportedException (); - } - - public virtual AssemblyNameReference ImportReference (AssemblyNameReference name) - { - Mixin.CheckName (name); - - AssemblyNameReference reference; - if (module.TryGetAssemblyNameReference (name, out reference)) - return reference; - - reference = new AssemblyNameReference (name.Name, name.Version) { - Culture = name.Culture, - HashAlgorithm = name.HashAlgorithm, - IsRetargetable = name.IsRetargetable, - IsWindowsRuntime = name.IsWindowsRuntime, - }; - - var pk_token = !name.PublicKeyToken.IsNullOrEmpty () - ? new byte [name.PublicKeyToken.Length] - : Empty.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; - } - - 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, ImportGenericContext 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.FnPtr: - var fnptr = (FunctionPointerType) type; - var imported_fnptr = new FunctionPointerType () { - HasThis = fnptr.HasThis, - ExplicitThis = fnptr.ExplicitThis, - CallingConvention = fnptr.CallingConvention, - ReturnType = ImportType (fnptr.ReturnType, context), - }; - - if (!fnptr.HasParameters) - return imported_fnptr; - - for (int i = 0; i < fnptr.Parameters.Count; i++) - imported_fnptr.Parameters.Add (new ParameterDefinition ( - ImportType (fnptr.Parameters [i].ParameterType, context))); - - return imported_fnptr; - 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: - var var_parameter = (GenericParameter) type; - if (var_parameter.DeclaringType == null) - throw new InvalidOperationException (); - return context.TypeParameter (var_parameter.DeclaringType.FullName, var_parameter.Position); - case ElementType.MVar: - var mvar_parameter = (GenericParameter) type; - if (mvar_parameter.DeclaringMethod == null) - throw new InvalidOperationException (); - return context.MethodParameter (context.NormalizeMethodName (mvar_parameter.DeclaringMethod), mvar_parameter.Position); - } - - throw new NotSupportedException (type.etype.ToString ()); - } - - FieldReference ImportField (FieldReference field, ImportGenericContext context) - { - var declaring_type = ImportType (field.DeclaringType, context); - - context.Push (declaring_type); - try { - return new FieldReference { - Name = field.Name, - DeclaringType = declaring_type, - FieldType = ImportType (field.FieldType, context), - }; - } finally { - context.Pop (); - } - } - - MethodReference ImportMethod (MethodReference method, ImportGenericContext 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, - CallingConvention = method.CallingConvention, - }; - - if (method.HasGenericParameters) - ImportGenericParameters (reference, method); - - context.Push (reference); - try { - reference.ReturnType = ImportType (method.ReturnType, context); - - if (!method.HasParameters) - return reference; - - var parameters = method.Parameters; - var reference_parameters = reference.parameters = new ParameterDefinitionCollection (reference, parameters.Count); - for (int i = 0; i < parameters.Count; i++) - reference_parameters.Add ( - new ParameterDefinition (ImportType (parameters [i].ParameterType, context))); - - return reference; - } finally { - context.Pop(); - } - } - - MethodSpecification ImportMethodSpecification (MethodReference method, ImportGenericContext 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; - } - - public virtual TypeReference ImportReference (TypeReference type, IGenericParameterProvider context) - { - Mixin.CheckType (type); - return ImportType (type, ImportGenericContext.For (context)); - } - - public virtual FieldReference ImportReference (FieldReference field, IGenericParameterProvider context) - { - Mixin.CheckField (field); - return ImportField (field, ImportGenericContext.For (context)); - } - - public virtual MethodReference ImportReference (MethodReference method, IGenericParameterProvider context) - { - Mixin.CheckMethod (method); - return ImportMethod (method, ImportGenericContext.For (context)); - } - } - -#endif - - static partial class Mixin { - - public static void CheckModule (ModuleDefinition module) - { - if (module == null) - throw new ArgumentNullException (Argument.module.ToString ()); - } - - public static bool TryGetAssemblyNameReference (this ModuleDefinition module, AssemblyNameReference name_reference, out AssemblyNameReference assembly_reference) - { - var references = module.AssemblyReferences; - - for (int i = 0; i < references.Count; i++) { - var reference = references [i]; - if (!Equals (name_reference, reference)) - continue; - - assembly_reference = reference; - return true; - } - - assembly_reference = null; - return false; - } - - static bool Equals (byte [] a, byte [] b) - { - if (ReferenceEquals (a, b)) - return true; - if (a == null) - return false; - if (a.Length != b.Length) - return false; - for (int i = 0; i < a.Length; i++) - if (a [i] != b [i]) - return false; - return true; - } - - static bool Equals (T a, T b) where T : class, IEquatable - { - if (ReferenceEquals (a, b)) - return true; - if (a == null) - return false; - return a.Equals (b); - } - - static bool Equals (AssemblyNameReference a, AssemblyNameReference b) - { - if (ReferenceEquals (a, b)) - return true; - if (a.Name != b.Name) - return false; - if (!Equals (a.Version, b.Version)) - return false; - if (a.Culture != b.Culture) - return false; - if (!Equals (a.PublicKeyToken, b.PublicKeyToken)) - return false; - return true; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/LinkedResource.cs b/external/linker/cecil/Mono.Cecil/LinkedResource.cs deleted file mode 100644 index e53430eca4..0000000000 --- a/external/linker/cecil/Mono.Cecil/LinkedResource.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil { - - public sealed class LinkedResource : Resource { - - internal byte [] hash; - string file; - - public byte [] Hash { - get { return hash; } - } - - public string File { - get { return file; } - set { file = value; } - } - - public override ResourceType ResourceType { - get { return ResourceType.Linked; } - } - - public LinkedResource (string name, ManifestResourceAttributes flags) - : base (name, flags) - { - } - - public LinkedResource (string name, ManifestResourceAttributes flags, string file) - : base (name, flags) - { - this.file = file; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/ManifestResourceAttributes.cs b/external/linker/cecil/Mono.Cecil/ManifestResourceAttributes.cs deleted file mode 100644 index 03ccb6b4c9..0000000000 --- a/external/linker/cecil/Mono.Cecil/ManifestResourceAttributes.cs +++ /dev/null @@ -1,21 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - [Flags] - 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/external/linker/cecil/Mono.Cecil/MarshalInfo.cs b/external/linker/cecil/Mono.Cecil/MarshalInfo.cs deleted file mode 100644 index 47d935e2cc..0000000000 --- a/external/linker/cecil/Mono.Cecil/MarshalInfo.cs +++ /dev/null @@ -1,153 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -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/external/linker/cecil/Mono.Cecil/MemberDefinitionCollection.cs b/external/linker/cecil/Mono.Cecil/MemberDefinitionCollection.cs deleted file mode 100644 index 3872b2a974..0000000000 --- a/external/linker/cecil/Mono.Cecil/MemberDefinitionCollection.cs +++ /dev/null @@ -1,74 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - sealed class MemberDefinitionCollection : Collection where T : IMemberDefinition { - - TypeDefinition container; - - internal MemberDefinitionCollection (TypeDefinition container) - { - this.container = container; - } - - internal MemberDefinitionCollection (TypeDefinition container, int capacity) - : base (capacity) - { - this.container = container; - } - - protected override void OnAdd (T item, int index) - { - Attach (item); - } - - protected sealed override void OnSet (T item, int index) - { - Attach (item); - } - - protected sealed override void OnInsert (T item, int index) - { - Attach (item); - } - - protected sealed override void OnRemove (T item, int index) - { - Detach (item); - } - - protected sealed override void OnClear () - { - foreach (var definition in this) - Detach (definition); - } - - void Attach (T element) - { - if (element.DeclaringType == container) - return; - - if (element.DeclaringType != null) - throw new ArgumentException ("Member already attached"); - - element.DeclaringType = this.container; - } - - static void Detach (T element) - { - element.DeclaringType = null; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/MemberReference.cs b/external/linker/cecil/Mono.Cecil/MemberReference.cs deleted file mode 100644 index 84fd38c546..0000000000 --- a/external/linker/cecil/Mono.Cecil/MemberReference.cs +++ /dev/null @@ -1,107 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - public abstract class MemberReference : IMetadataTokenProvider { - - string name; - TypeReference declaring_type; - - internal MetadataToken token; - internal object projection; - - public virtual string Name { - get { return name; } - set { - if (IsWindowsRuntimeProjection && value != name) - throw new InvalidOperationException (); - - name = value; - } - } - - public abstract string FullName { - get; - } - - public virtual TypeReference DeclaringType { - get { return declaring_type; } - set { declaring_type = value; } - } - - public MetadataToken MetadataToken { - get { return token; } - set { token = value; } - } - - public bool IsWindowsRuntimeProjection { - get { return projection != null; } - } - - internal MemberReferenceProjection WindowsRuntimeProjection { - get { return (MemberReferenceProjection) projection; } - set { projection = value; } - } - - internal bool HasImage { - get { - var module = Module; - if (module == null) - return false; - - return module.HasImage; - } - } - - public virtual ModuleDefinition Module { - get { return declaring_type != null ? declaring_type.Module : null; } - } - - public virtual bool IsDefinition { - get { return false; } - } - - public virtual bool ContainsGenericParameter { - get { return declaring_type != null && declaring_type.ContainsGenericParameter; } - } - - internal MemberReference () - { - } - - internal MemberReference (string name) - { - this.name = name ?? string.Empty; - } - - internal string MemberFullName () - { - if (declaring_type == null) - return name; - - return declaring_type.FullName + "::" + name; - } - - public IMemberDefinition Resolve () - { - return ResolveDefinition (); - } - - protected abstract IMemberDefinition ResolveDefinition (); - - public override string ToString () - { - return FullName; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/MetadataResolver.cs b/external/linker/cecil/Mono.Cecil/MetadataResolver.cs deleted file mode 100644 index 26c4e16d79..0000000000 --- a/external/linker/cecil/Mono.Cecil/MetadataResolver.cs +++ /dev/null @@ -1,382 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public interface IAssemblyResolver : IDisposable { - AssemblyDefinition Resolve (AssemblyNameReference name); - AssemblyDefinition Resolve (AssemblyNameReference name, ReaderParameters parameters); - } - - public interface IMetadataResolver { - TypeDefinition Resolve (TypeReference type); - FieldDefinition Resolve (FieldReference field); - MethodDefinition Resolve (MethodReference method); - } - -#if !NET_CORE - [Serializable] -#endif - public sealed class ResolutionException : Exception { - - readonly MemberReference member; - - public MemberReference Member { - get { return member; } - } - - public IMetadataScope Scope { - get { - var type = member as TypeReference; - if (type != null) - return type.Scope; - - var declaring_type = member.DeclaringType; - if (declaring_type != null) - return declaring_type.Scope; - - throw new NotSupportedException (); - } - } - - public ResolutionException (MemberReference member) - : base ("Failed to resolve " + member.FullName) - { - if (member == null) - throw new ArgumentNullException ("member"); - - this.member = member; - } - -#if !NET_CORE - ResolutionException ( - System.Runtime.Serialization.SerializationInfo info, - System.Runtime.Serialization.StreamingContext context) - : base (info, context) - { - } -#endif - } - - public class MetadataResolver : IMetadataResolver { - - readonly IAssemblyResolver assembly_resolver; - - public IAssemblyResolver AssemblyResolver { - get { return assembly_resolver; } - } - - public MetadataResolver (IAssemblyResolver assemblyResolver) - { - if (assemblyResolver == null) - throw new ArgumentNullException ("assemblyResolver"); - - assembly_resolver = assemblyResolver; - } - - public virtual TypeDefinition Resolve (TypeReference type) - { - Mixin.CheckType (type); - - type = type.GetElementType (); - - var scope = type.Scope; - - if (scope == null) - return null; - - switch (scope.MetadataScopeType) { - case MetadataScopeType.AssemblyNameReference: - var assembly = 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 reference) - { - var type = GetTypeDefinition (module, reference); - if (type != null) - return type; - - if (!module.HasExportedTypes) - return null; - - var exported_types = module.ExportedTypes; - - for (int i = 0; i < exported_types.Count; i++) { - var exported_type = exported_types [i]; - if (exported_type.Name != reference.Name) - continue; - - if (exported_type.Namespace != reference.Namespace) - continue; - - return exported_type.Resolve (); - } - - return null; - } - - static TypeDefinition GetTypeDefinition (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.TypeFullName ()); - } - - public virtual FieldDefinition Resolve (FieldReference field) - { - Mixin.CheckField (field); - - var type = Resolve (field.DeclaringType); - if (type == null) - return null; - - if (!type.HasFields) - return null; - - return GetField (type, field); - } - - FieldDefinition GetField (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 (type.BaseType); - } - - return null; - } - - static FieldDefinition GetField (Collection 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 virtual MethodDefinition Resolve (MethodReference method) - { - Mixin.CheckMethod (method); - - var type = Resolve (method.DeclaringType); - if (type == null) - return null; - - method = method.GetElementMethod (); - - if (!type.HasMethods) - return null; - - return GetMethod (type, method); - } - - MethodDefinition GetMethod (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 (type.BaseType); - } - - return null; - } - - public static MethodDefinition GetMethod (Collection methods, MethodReference reference) - { - for (int i = 0; i < methods.Count; i++) { - var method = methods [i]; - - if (method.Name != reference.Name) - continue; - - if (method.HasGenericParameters != reference.HasGenericParameters) - continue; - - if (method.HasGenericParameters && method.GenericParameters.Count != reference.GenericParameters.Count) - continue; - - if (!AreSame (method.ReturnType, reference.ReturnType)) - continue; - - if (method.IsVarArg () != reference.IsVarArg ()) - continue; - - if (method.IsVarArg () && IsVarArgCallTo (method, reference)) - return method; - - 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 a, Collection 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 IsVarArgCallTo (MethodDefinition method, MethodReference reference) - { - if (method.Parameters.Count >= reference.Parameters.Count) - return false; - - if (reference.GetSentinelPosition () != method.Parameters.Count) - return false; - - for (int i = 0; i < method.Parameters.Count; i++) - if (!AreSame (method.Parameters [i].ParameterType, reference.Parameters [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.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 (ReferenceEquals (a, b)) - return true; - - if (a == null || b == null) - return false; - - 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); - - if (a.Name != b.Name || a.Namespace != b.Namespace) - return false; - - //TODO: check scope - - return AreSame (a.DeclaringType, b.DeclaringType); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/MetadataSystem.cs b/external/linker/cecil/Mono.Cecil/MetadataSystem.cs deleted file mode 100644 index 6a2dd3459b..0000000000 --- a/external/linker/cecil/Mono.Cecil/MetadataSystem.cs +++ /dev/null @@ -1,429 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; - -using Mono.Cecil.Cil; -using Mono.Cecil.Metadata; -using Mono.Collections.Generic; - -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 AssemblyNameReference [] AssemblyReferences; - internal ModuleReference [] ModuleReferences; - - internal TypeDefinition [] Types; - internal TypeReference [] TypeReferences; - - internal FieldDefinition [] Fields; - internal MethodDefinition [] Methods; - internal MemberReference [] MemberReferences; - - internal Dictionary> NestedTypes; - internal Dictionary ReverseNestedTypes; - internal Dictionary>> Interfaces; - internal Dictionary> ClassLayouts; - internal Dictionary FieldLayouts; - internal Dictionary FieldRVAs; - internal Dictionary FieldMarshals; - internal Dictionary> Constants; - internal Dictionary> Overrides; - internal Dictionary CustomAttributes; - internal Dictionary SecurityDeclarations; - internal Dictionary Events; - internal Dictionary Properties; - internal Dictionary> Semantics; - internal Dictionary> PInvokes; - internal Dictionary GenericParameters; - internal Dictionary> GenericConstraints; - - internal Document [] Documents; - internal Dictionary>> LocalScopes; - internal ImportDebugInformation [] ImportScopes; - internal Dictionary StateMachineMethods; - internal Dictionary []> CustomDebugInformations; - - static Dictionary> primitive_value_types; - - static void InitializePrimitives () - { - primitive_value_types = new Dictionary> (18, StringComparer.Ordinal) { - { "Void", new Row (ElementType.Void, false) }, - { "Boolean", new Row (ElementType.Boolean, true) }, - { "Char", new Row (ElementType.Char, true) }, - { "SByte", new Row (ElementType.I1, true) }, - { "Byte", new Row (ElementType.U1, true) }, - { "Int16", new Row (ElementType.I2, true) }, - { "UInt16", new Row (ElementType.U2, true) }, - { "Int32", new Row (ElementType.I4, true) }, - { "UInt32", new Row (ElementType.U4, true) }, - { "Int64", new Row (ElementType.I8, true) }, - { "UInt64", new Row (ElementType.U8, true) }, - { "Single", new Row (ElementType.R4, true) }, - { "Double", new Row (ElementType.R8, true) }, - { "String", new Row (ElementType.String, false) }, - { "TypedReference", new Row (ElementType.TypedByRef, false) }, - { "IntPtr", new Row (ElementType.I, true) }, - { "UIntPtr", new Row (ElementType.U, true) }, - { "Object", new Row (ElementType.Object, false) }, - }; - } - - public static void TryProcessPrimitiveTypeReference (TypeReference type) - { - if (type.Namespace != "System") - return; - - var scope = type.scope; - if (scope == null || scope.MetadataScopeType != MetadataScopeType.AssemblyNameReference) - return; - - Row primitive_data; - if (!TryGetPrimitiveData (type, out primitive_data)) - return; - - type.etype = primitive_data.Col1; - type.IsValueType = primitive_data.Col2; - } - - public static bool TryGetPrimitiveElementType (TypeDefinition type, out ElementType etype) - { - etype = ElementType.None; - - if (type.Namespace != "System") - return false; - - Row primitive_data; - if (TryGetPrimitiveData (type, out primitive_data)) { - etype = primitive_data.Col1; - return true; - } - - return false; - } - - static bool TryGetPrimitiveData (TypeReference type, out Row primitive_data) - { - if (primitive_value_types == null) - InitializePrimitives (); - - return primitive_value_types.TryGetValue (type.Name, out primitive_data); - } - - public void Clear () - { - if (NestedTypes != null) NestedTypes = new Dictionary> (capacity: 0); - if (ReverseNestedTypes != null) ReverseNestedTypes = new Dictionary (capacity: 0); - if (Interfaces != null) Interfaces = new Dictionary>> (capacity: 0); - if (ClassLayouts != null) ClassLayouts = new Dictionary> (capacity: 0); - if (FieldLayouts != null) FieldLayouts = new Dictionary (capacity: 0); - if (FieldRVAs != null) FieldRVAs = new Dictionary (capacity: 0); - if (FieldMarshals != null) FieldMarshals = new Dictionary (capacity: 0); - if (Constants != null) Constants = new Dictionary> (capacity: 0); - if (Overrides != null) Overrides = new Dictionary> (capacity: 0); - if (CustomAttributes != null) CustomAttributes = new Dictionary (capacity: 0); - if (SecurityDeclarations != null) SecurityDeclarations = new Dictionary (capacity: 0); - if (Events != null) Events = new Dictionary (capacity: 0); - if (Properties != null) Properties = new Dictionary (capacity: 0); - if (Semantics != null) Semantics = new Dictionary> (capacity: 0); - if (PInvokes != null) PInvokes = new Dictionary> (capacity: 0); - if (GenericParameters != null) GenericParameters = new Dictionary (capacity: 0); - if (GenericConstraints != null) GenericConstraints = new Dictionary> (capacity: 0); - - Documents = Empty.Array; - ImportScopes = Empty.Array; - if (LocalScopes != null) LocalScopes = new Dictionary>> (capacity: 0); - if (StateMachineMethods != null) StateMachineMethods = new Dictionary (capacity: 0); - } - - public AssemblyNameReference GetAssemblyNameReference (uint rid) - { - if (rid < 1 || rid > AssemblyReferences.Length) - return null; - - return AssemblyReferences [rid - 1]; - } - - 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 Collection mapping) - { - return NestedTypes.TryGetValue (type.token.RID, out mapping); - } - - public void SetNestedTypeMapping (uint type_rid, Collection 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 [nested] = declaring; - } - - public void RemoveReverseNestedTypeMapping (TypeDefinition type) - { - ReverseNestedTypes.Remove (type.token.RID); - } - - public bool TryGetInterfaceMapping (TypeDefinition type, out Collection> mapping) - { - return Interfaces.TryGetValue (type.token.RID, out mapping); - } - - public void SetInterfaceMapping (uint type_rid, Collection> 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 TryGetGenericParameterRanges (IGenericParameterProvider owner, out Range [] ranges) - { - return GenericParameters.TryGetValue (owner.MetadataToken, out ranges); - } - - public void RemoveGenericParameterRange (IGenericParameterProvider owner) - { - GenericParameters.Remove (owner.MetadataToken); - } - - public bool TryGetCustomAttributeRanges (ICustomAttributeProvider owner, out Range [] ranges) - { - return CustomAttributes.TryGetValue (owner.MetadataToken, out ranges); - } - - public void RemoveCustomAttributeRange (ICustomAttributeProvider owner) - { - CustomAttributes.Remove (owner.MetadataToken); - } - - public bool TryGetSecurityDeclarationRanges (ISecurityDeclarationProvider owner, out Range [] ranges) - { - return SecurityDeclarations.TryGetValue (owner.MetadataToken, out ranges); - } - - public void RemoveSecurityDeclarationRange (ISecurityDeclarationProvider owner) - { - SecurityDeclarations.Remove (owner.MetadataToken); - } - - public bool TryGetGenericConstraintMapping (GenericParameter generic_parameter, out Collection mapping) - { - return GenericConstraints.TryGetValue (generic_parameter.token.RID, out mapping); - } - - public void SetGenericConstraintMapping (uint gp_rid, Collection mapping) - { - GenericConstraints [gp_rid] = mapping; - } - - public void RemoveGenericConstraintMapping (GenericParameter generic_parameter) - { - GenericConstraints.Remove (generic_parameter.token.RID); - } - - public bool TryGetOverrideMapping (MethodDefinition method, out Collection mapping) - { - return Overrides.TryGetValue (method.token.RID, out mapping); - } - - public void SetOverrideMapping (uint rid, Collection mapping) - { - Overrides [rid] = mapping; - } - - public void RemoveOverrideMapping (MethodDefinition method) - { - Overrides.Remove (method.token.RID); - } - - public Document GetDocument (uint rid) - { - if (rid < 1 || rid > Documents.Length) - return null; - - return Documents [rid - 1]; - } - - public bool TryGetLocalScopes (MethodDefinition method, out Collection> scopes) - { - return LocalScopes.TryGetValue (method.MetadataToken.RID, out scopes); - } - - public void SetLocalScopes (uint method_rid, Collection> records) - { - LocalScopes [method_rid] = records; - } - - public ImportDebugInformation GetImportScope (uint rid) - { - if (rid < 1 || rid > ImportScopes.Length) - return null; - - return ImportScopes [rid - 1]; - } - - public bool TryGetStateMachineKickOffMethod (MethodDefinition method, out uint rid) - { - return StateMachineMethods.TryGetValue (method.MetadataToken.RID, out 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; - } - - return null; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/MethodAttributes.cs b/external/linker/cecil/Mono.Cecil/MethodAttributes.cs deleted file mode 100644 index 1bd7d1288d..0000000000 --- a/external/linker/cecil/Mono.Cecil/MethodAttributes.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - [Flags] - public enum MethodAttributes : ushort { - MemberAccessMask = 0x0007, - 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, // 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 - - Static = 0x0010, // Defined on type, else per instance - Final = 0x0020, // Method may not be overridden - Virtual = 0x0040, // Method is virtual - HideBySig = 0x0080, // Method hides by name+sig, else just by name - - VtableLayoutMask = 0x0100, // Use this mask to retrieve vtable attributes - 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 - - // Interop Attributes - PInvokeImpl = 0x2000, // Implementation is forwarded through PInvoke - UnmanagedExport = 0x0008, // Reserved: shall be zero for conforming implementations - - // Additional flags - RTSpecialName = 0x1000, // CLI provides 'special' behavior, depending upon the name of the method - HasSecurity = 0x4000, // Method has security associate with it - RequireSecObject = 0x8000 // Method calls another method containing security code - } -} diff --git a/external/linker/cecil/Mono.Cecil/MethodCallingConvention.cs b/external/linker/cecil/Mono.Cecil/MethodCallingConvention.cs deleted file mode 100644 index f9c0e0c951..0000000000 --- a/external/linker/cecil/Mono.Cecil/MethodCallingConvention.cs +++ /dev/null @@ -1,22 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil { - - public enum MethodCallingConvention : byte { - Default = 0x0, - C = 0x1, - StdCall = 0x2, - ThisCall = 0x3, - FastCall = 0x4, - VarArg = 0x5, - Generic = 0x10, - } -} diff --git a/external/linker/cecil/Mono.Cecil/MethodDefinition.cs b/external/linker/cecil/Mono.Cecil/MethodDefinition.cs deleted file mode 100644 index 5dda999ce0..0000000000 --- a/external/linker/cecil/Mono.Cecil/MethodDefinition.cs +++ /dev/null @@ -1,540 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using Mono.Cecil.Cil; -using Mono.Collections.Generic; - -using RVA = System.UInt32; - -namespace Mono.Cecil { - - public sealed class MethodDefinition : MethodReference, IMemberDefinition, ISecurityDeclarationProvider, ICustomDebugInformationProvider { - - ushort attributes; - ushort impl_attributes; - internal volatile bool sem_attrs_ready; - internal MethodSemanticsAttributes sem_attrs; - Collection custom_attributes; - Collection security_declarations; - - internal RVA rva; - internal PInvokeInfo pinvoke; - Collection overrides; - - internal MethodBody body; - internal MethodDebugInformation debug_info; - internal Collection custom_infos; - - public override string Name { - get { return base.Name; } - set { - if (IsWindowsRuntimeProjection && value != base.Name) - throw new InvalidOperationException (); - - base.Name = value; - } - } - - public MethodAttributes Attributes { - get { return (MethodAttributes) attributes; } - set { - if (IsWindowsRuntimeProjection && (ushort) value != attributes) - throw new InvalidOperationException (); - - attributes = (ushort) value; - } - } - - public MethodImplAttributes ImplAttributes { - get { return (MethodImplAttributes) impl_attributes; } - set { - if (IsWindowsRuntimeProjection && (ushort) value != impl_attributes) - throw new InvalidOperationException (); - - impl_attributes = (ushort) value; - } - } - - public MethodSemanticsAttributes SemanticsAttributes { - get { - if (sem_attrs_ready) - return sem_attrs; - - if (HasImage) { - ReadSemantics (); - return sem_attrs; - } - - sem_attrs = MethodSemanticsAttributes.None; - sem_attrs_ready = true; - return sem_attrs; - } - set { sem_attrs = value; } - } - - internal new MethodDefinitionProjection WindowsRuntimeProjection { - get { return (MethodDefinitionProjection) projection; } - set { projection = value; } - } - - internal void ReadSemantics () - { - if (sem_attrs_ready) - return; - - var module = this.Module; - if (module == null) - return; - - if (!module.HasImage) - return; - - module.Read (this, (method, reader) => reader.ReadAllSemantics (method)); - } - - public bool HasSecurityDeclarations { - get { - if (security_declarations != null) - return security_declarations.Count > 0; - - return this.GetHasSecurityDeclarations (Module); - } - } - - public Collection SecurityDeclarations { - get { return security_declarations ?? (this.GetSecurityDeclarations (ref security_declarations, Module)); } - } - - public bool HasCustomAttributes { - get { - if (custom_attributes != null) - return custom_attributes.Count > 0; - - return this.GetHasCustomAttributes (Module); - } - } - - public Collection CustomAttributes { - get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, 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 { - var local = this.body; - if (local != null) - return local; - - if (!HasBody) - return null; - - if (HasImage && rva != 0) - return Module.Read (ref body, this, (method, reader) => reader.ReadMethodBody (method)); - - return body = new MethodBody (this); - } - set { - var module = this.Module; - if (module == null) { - body = value; - return; - } - - // we reset Body to null in ILSpy to save memory; so we need that operation to be thread-safe - lock (module.SyncRoot) { - body = value; - } - } - } - - public MethodDebugInformation DebugInformation { - get { - Mixin.Read (Body); - - if (debug_info != null) - return debug_info; - - return debug_info ?? (debug_info = new MethodDebugInformation (this)); - } - } - - public bool HasPInvokeInfo { - get { - if (pinvoke != null) - return true; - - return IsPInvokeImpl; - } - } - - public PInvokeInfo PInvokeInfo { - get { - if (pinvoke != null) - return pinvoke; - - if (HasImage && IsPInvokeImpl) - return Module.Read (ref pinvoke, this, (method, reader) => reader.ReadPInvokeInfo (method)); - - return null; - } - set { - IsPInvokeImpl = true; - pinvoke = value; - } - } - - public bool HasOverrides { - get { - if (overrides != null) - return overrides.Count > 0; - - return HasImage && Module.Read (this, (method, reader) => reader.HasOverrides (method)); - } - } - - public Collection Overrides { - get { - if (overrides != null) - return overrides; - - if (HasImage) - return Module.Read (ref overrides, this, (method, reader) => reader.ReadOverrides (method)); - - return overrides = new Collection (); - } - } - - public override bool HasGenericParameters { - get { - if (generic_parameters != null) - return generic_parameters.Count > 0; - - return this.GetHasGenericParameters (Module); - } - } - - public override Collection GenericParameters { - get { return generic_parameters ?? (this.GetGenericParameters (ref generic_parameters, Module)); } - } - - public bool HasCustomDebugInformations { - get { - Mixin.Read (Body); - - return !custom_infos.IsNullOrEmpty (); - } - } - - public Collection CustomDebugInformations { - get { - Mixin.Read (Body); - - return custom_infos ?? (custom_infos = new Collection ()); - } - } - - #region MethodAttributes - - public bool IsCompilerControlled { - 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 attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Private); } - set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Private, value); } - } - - public bool IsFamilyAndAssembly { - 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 attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Assembly); } - set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.Assembly, value); } - } - - public bool IsFamily { - 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 attributes.GetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.FamORAssem); } - set { attributes = attributes.SetMaskedAttributes ((ushort) MethodAttributes.MemberAccessMask, (ushort) MethodAttributes.FamORAssem, value); } - } - - public bool IsPublic { - 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 attributes.GetAttributes ((ushort) MethodAttributes.Static); } - set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.Static, value); } - } - - public bool IsFinal { - get { return attributes.GetAttributes ((ushort) MethodAttributes.Final); } - set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.Final, value); } - } - - public bool IsVirtual { - get { return attributes.GetAttributes ((ushort) MethodAttributes.Virtual); } - set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.Virtual, value); } - } - - public bool IsHideBySig { - get { return attributes.GetAttributes ((ushort) MethodAttributes.HideBySig); } - set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.HideBySig, value); } - } - - public bool IsReuseSlot { - 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 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 attributes.GetAttributes ((ushort) MethodAttributes.Abstract); } - set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.Abstract, value); } - } - - public bool IsSpecialName { - get { return attributes.GetAttributes ((ushort) MethodAttributes.SpecialName); } - set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.SpecialName, value); } - } - - public bool IsPInvokeImpl { - get { return attributes.GetAttributes ((ushort) MethodAttributes.PInvokeImpl); } - set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.PInvokeImpl, value); } - } - - public bool IsUnmanagedExport { - get { return attributes.GetAttributes ((ushort) MethodAttributes.UnmanagedExport); } - set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.UnmanagedExport, value); } - } - - public bool IsRuntimeSpecialName { - get { return attributes.GetAttributes ((ushort) MethodAttributes.RTSpecialName); } - set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.RTSpecialName, value); } - } - - public bool HasSecurity { - get { return attributes.GetAttributes ((ushort) MethodAttributes.HasSecurity); } - set { attributes = attributes.SetAttributes ((ushort) MethodAttributes.HasSecurity, value); } - } - - #endregion - - #region MethodImplAttributes - - public bool IsIL { - 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 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 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 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 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 impl_attributes.GetAttributes ((ushort) MethodImplAttributes.ForwardRef); } - set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.ForwardRef, value); } - } - - public bool IsPreserveSig { - get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.PreserveSig); } - set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.PreserveSig, value); } - } - - public bool IsInternalCall { - get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.InternalCall); } - set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.InternalCall, value); } - } - - public bool IsSynchronized { - get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.Synchronized); } - set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.Synchronized, value); } - } - - public bool 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); } - } - - public bool AggressiveInlining { - get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.AggressiveInlining); } - set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.AggressiveInlining, value); } - } - - #endregion - - #region MethodSemanticsAttributes - - public bool IsSetter { - get { return this.GetSemantics (MethodSemanticsAttributes.Setter); } - set { this.SetSemantics (MethodSemanticsAttributes.Setter, value); } - } - - public bool IsGetter { - get { return this.GetSemantics (MethodSemanticsAttributes.Getter); } - set { this.SetSemantics (MethodSemanticsAttributes.Getter, value); } - } - - public bool IsOther { - get { return this.GetSemantics (MethodSemanticsAttributes.Other); } - set { this.SetSemantics (MethodSemanticsAttributes.Other, value); } - } - - public bool IsAddOn { - get { return this.GetSemantics (MethodSemanticsAttributes.AddOn); } - set { this.SetSemantics (MethodSemanticsAttributes.AddOn, value); } - } - - public bool IsRemoveOn { - get { return this.GetSemantics (MethodSemanticsAttributes.RemoveOn); } - set { this.SetSemantics (MethodSemanticsAttributes.RemoveOn, value); } - } - - public bool IsFire { - get { return this.GetSemantics (MethodSemanticsAttributes.Fire); } - set { this.SetSemantics (MethodSemanticsAttributes.Fire, value); } - } - - #endregion - - public new TypeDefinition DeclaringType { - get { return (TypeDefinition) base.DeclaringType; } - set { base.DeclaringType = value; } - } - - public bool IsConstructor { - get { - return this.IsRuntimeSpecialName - && this.IsSpecialName - && (this.Name == ".cctor" || this.Name == ".ctor"); - } - } - - public override bool IsDefinition { - get { return true; } - } - - internal MethodDefinition () - { - this.token = new MetadataToken (TokenType.Method); - } - - 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); - } - - public override MethodDefinition Resolve () - { - return this; - } - } - - static partial class Mixin { - - public static ParameterDefinition GetParameter (this MethodBody self, int index) - { - var method = self.method; - - if (method.HasThis) { - if (index == 0) - return self.ThisParameter; - - index--; - } - - var parameters = method.Parameters; - - if (index < 0 || index >= parameters.size) - return null; - - return parameters [index]; - } - - public static VariableDefinition GetVariable (this MethodBody self, int index) - { - var variables = self.Variables; - - if (index < 0 || index >= variables.size) - return null; - - return variables [index]; - } - - public static bool GetSemantics (this MethodDefinition self, MethodSemanticsAttributes semantics) - { - return (self.SemanticsAttributes & semantics) != 0; - } - - public static void SetSemantics (this MethodDefinition self, MethodSemanticsAttributes semantics, bool value) - { - if (value) - self.SemanticsAttributes |= semantics; - else - self.SemanticsAttributes &= ~semantics; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/MethodImplAttributes.cs b/external/linker/cecil/Mono.Cecil/MethodImplAttributes.cs deleted file mode 100644 index 2f1f018324..0000000000 --- a/external/linker/cecil/Mono.Cecil/MethodImplAttributes.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - [Flags] - public enum MethodImplAttributes : ushort { - CodeTypeMask = 0x0003, - IL = 0x0000, // Method impl is CIL - Native = 0x0001, // Method impl is native - OPTIL = 0x0002, // Reserved: shall be zero in conforming implementations - Runtime = 0x0003, // Method impl is provided by the runtime - - ManagedMask = 0x0004, // Flags specifying whether the code is managed or unmanaged - Unmanaged = 0x0004, // Method impl is unmanaged, otherwise managed - Managed = 0x0000, // Method impl is managed - - // Implementation info and interop - ForwardRef = 0x0010, // Indicates method is defined; used primarily in merge scenarios - 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 - AggressiveInlining = 0x0100, // Method should be inlined, if possible. - } -} diff --git a/external/linker/cecil/Mono.Cecil/MethodReference.cs b/external/linker/cecil/Mono.Cecil/MethodReference.cs deleted file mode 100644 index 89ee6a7719..0000000000 --- a/external/linker/cecil/Mono.Cecil/MethodReference.cs +++ /dev/null @@ -1,202 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Text; - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public class MethodReference : MemberReference, IMethodSignature, IGenericParameterProvider, IGenericContext { - - internal ParameterDefinitionCollection parameters; - MethodReturnType return_type; - - bool has_this; - bool explicit_this; - MethodCallingConvention calling_convention; - internal Collection generic_parameters; - - public virtual bool HasThis { - get { return has_this; } - set { has_this = value; } - } - - public virtual bool ExplicitThis { - get { return explicit_this; } - set { explicit_this = value; } - } - - public virtual MethodCallingConvention CallingConvention { - get { return calling_convention; } - set { calling_convention = value; } - } - - public virtual bool HasParameters { - get { return !parameters.IsNullOrEmpty (); } - } - - public virtual Collection 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 Collection GenericParameters { - get { - if (generic_parameters != null) - return generic_parameters; - - return generic_parameters = new GenericParameterCollection (this); - } - } - - public TypeReference ReturnType { - get { - 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 MethodReturnType { - get { return return_type; } - set { return_type = value; } - } - - public override string FullName { - get { - var builder = new StringBuilder (); - builder.Append (ReturnType.FullName) - .Append (" ") - .Append (MemberFullName ()); - this.MethodSignatureFullName (builder); - return builder.ToString (); - } - } - - public virtual bool IsGenericInstance { - get { return false; } - } - - public override bool ContainsGenericParameter { - get { - if (this.ReturnType.ContainsGenericParameter || base.ContainsGenericParameter) - return true; - - if (!HasParameters) - return false; - - var parameters = this.Parameters; - - for (int i = 0; i < parameters.Count; i++) - if (parameters [i].ParameterType.ContainsGenericParameter) - return true; - - return false; - } - } - - internal MethodReference () - { - this.return_type = new MethodReturnType (this); - this.token = new MetadataToken (TokenType.MemberRef); - } - - public MethodReference (string name, TypeReference returnType) - : base (name) - { - Mixin.CheckType (returnType, Mixin.Argument.returnType); - - this.return_type = new MethodReturnType (this); - this.return_type.ReturnType = returnType; - this.token = new MetadataToken (TokenType.MemberRef); - } - - public MethodReference (string name, TypeReference returnType, TypeReference declaringType) - : this (name, returnType) - { - Mixin.CheckType (declaringType, Mixin.Argument.declaringType); - - this.DeclaringType = declaringType; - } - - public virtual MethodReference GetElementMethod () - { - return this; - } - - protected override IMemberDefinition ResolveDefinition () - { - return this.Resolve (); - } - - public new virtual MethodDefinition Resolve () - { - var module = this.Module; - if (module == null) - throw new NotSupportedException (); - - return module.Resolve (this); - } - } - - static partial class Mixin { - - public static bool IsVarArg (this IMethodSignature self) - { - return (self.CallingConvention & MethodCallingConvention.VarArg) != 0; - } - - public static int GetSentinelPosition (this IMethodSignature self) - { - if (!self.HasParameters) - return -1; - - var parameters = self.Parameters; - for (int i = 0; i < parameters.Count; i++) - if (parameters [i].ParameterType.IsSentinel) - return i; - - return -1; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/MethodReturnType.cs b/external/linker/cecil/Mono.Cecil/MethodReturnType.cs deleted file mode 100644 index 71a78de1b0..0000000000 --- a/external/linker/cecil/Mono.Cecil/MethodReturnType.cs +++ /dev/null @@ -1,98 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System.Threading; - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public sealed class MethodReturnType : IConstantProvider, ICustomAttributeProvider, IMarshalInfoProvider { - - internal IMethodSignature method; - internal ParameterDefinition parameter; - TypeReference return_type; - - public IMethodSignature Method { - get { return method; } - } - - public TypeReference ReturnType { - get { return return_type; } - set { return_type = value; } - } - - internal ParameterDefinition Parameter { - get { - if (parameter == null) - Interlocked.CompareExchange (ref parameter, new ParameterDefinition (return_type, method), null); - - return parameter; - } - } - - public MetadataToken MetadataToken { - get { return Parameter.MetadataToken; } - set { Parameter.MetadataToken = value; } - } - - public ParameterAttributes Attributes { - get { return Parameter.Attributes; } - set { Parameter.Attributes = value; } - } - - public string Name { - get { return Parameter.Name; } - set { Parameter.Name = value; } - } - - public bool HasCustomAttributes { - get { return parameter != null && parameter.HasCustomAttributes; } - } - - public Collection CustomAttributes { - get { return Parameter.CustomAttributes; } - } - - public bool HasDefault { - get { return parameter != null && parameter.HasDefault; } - set { Parameter.HasDefault = value; } - } - - public bool HasConstant { - get { return parameter != null && parameter.HasConstant; } - set { Parameter.HasConstant = value; } - } - - public object Constant { - get { return Parameter.Constant; } - set { Parameter.Constant = value; } - } - - public bool HasFieldMarshal { - get { return parameter != null && parameter.HasFieldMarshal; } - set { Parameter.HasFieldMarshal = value; } - } - - public bool HasMarshalInfo { - get { return parameter != null && parameter.HasMarshalInfo; } - } - - public MarshalInfo MarshalInfo { - get { return Parameter.MarshalInfo; } - set { Parameter.MarshalInfo = value; } - } - - public MethodReturnType (IMethodSignature method) - { - this.method = method; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/MethodSemanticsAttributes.cs b/external/linker/cecil/Mono.Cecil/MethodSemanticsAttributes.cs deleted file mode 100644 index 274dfd0449..0000000000 --- a/external/linker/cecil/Mono.Cecil/MethodSemanticsAttributes.cs +++ /dev/null @@ -1,25 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -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 - AddOn = 0x0008, // AddOn method for event - RemoveOn = 0x0010, // RemoveOn method for event - Fire = 0x0020 // Fire method for event - } -} diff --git a/external/linker/cecil/Mono.Cecil/MethodSpecification.cs b/external/linker/cecil/Mono.Cecil/MethodSpecification.cs deleted file mode 100644 index 040be6ed58..0000000000 --- a/external/linker/cecil/Mono.Cecil/MethodSpecification.cs +++ /dev/null @@ -1,84 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public abstract class MethodSpecification : MethodReference { - - readonly MethodReference method; - - public MethodReference ElementMethod { - get { return method; } - } - - public override string Name { - get { return method.Name; } - set { throw new InvalidOperationException (); } - } - - public override MethodCallingConvention CallingConvention { - get { return method.CallingConvention; } - set { throw new InvalidOperationException (); } - } - - public override bool HasThis { - get { return method.HasThis; } - set { throw new InvalidOperationException (); } - } - - public override bool ExplicitThis { - get { return method.ExplicitThis; } - set { throw new InvalidOperationException (); } - } - - public override MethodReturnType MethodReturnType { - get { return method.MethodReturnType; } - set { throw new InvalidOperationException (); } - } - - public override TypeReference DeclaringType { - get { return method.DeclaringType; } - set { throw new InvalidOperationException (); } - } - - public override ModuleDefinition Module { - get { return method.Module; } - } - - public override bool HasParameters { - get { return method.HasParameters; } - } - - public override Collection Parameters { - get { return method.Parameters; } - } - - public override bool ContainsGenericParameter { - get { return method.ContainsGenericParameter; } - } - - internal MethodSpecification (MethodReference method) - { - Mixin.CheckMethod (method); - - this.method = method; - this.token = new MetadataToken (TokenType.MethodSpec); - } - - public sealed override MethodReference GetElementMethod () - { - return method.GetElementMethod (); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/Modifiers.cs b/external/linker/cecil/Mono.Cecil/Modifiers.cs deleted file mode 100644 index 9c50f0e4e9..0000000000 --- a/external/linker/cecil/Mono.Cecil/Modifiers.cs +++ /dev/null @@ -1,112 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using MD = Mono.Cecil.Metadata; - -namespace Mono.Cecil { - - public interface IModifierType { - TypeReference ModifierType { get; } - TypeReference ElementType { get; } - } - - public sealed class OptionalModifierType : TypeSpecification, IModifierType { - - TypeReference modifier_type; - - public TypeReference ModifierType { - get { return modifier_type; } - set { modifier_type = value; } - } - - public override string Name { - get { return base.Name + Suffix; } - } - - public override string FullName { - get { return base.FullName + Suffix; } - } - - string Suffix { - get { return " modopt(" + modifier_type + ")"; } - } - - public override bool IsValueType { - get { return false; } - set { throw new InvalidOperationException (); } - } - - public override bool IsOptionalModifier { - get { return true; } - } - - public override bool ContainsGenericParameter { - get { return modifier_type.ContainsGenericParameter || base.ContainsGenericParameter; } - } - - public OptionalModifierType (TypeReference modifierType, TypeReference type) - : base (type) - { - if (modifierType == null) - throw new ArgumentNullException (Mixin.Argument.modifierType.ToString ()); - Mixin.CheckType (type); - this.modifier_type = modifierType; - this.etype = MD.ElementType.CModOpt; - } - } - - public sealed class RequiredModifierType : TypeSpecification, IModifierType { - - TypeReference modifier_type; - - public TypeReference ModifierType { - get { return modifier_type; } - set { modifier_type = value; } - } - - 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 override bool IsValueType { - get { return false; } - set { throw new InvalidOperationException (); } - } - - public override bool IsRequiredModifier { - get { return true; } - } - - public override bool ContainsGenericParameter { - get { return modifier_type.ContainsGenericParameter || base.ContainsGenericParameter; } - } - - public RequiredModifierType (TypeReference modifierType, TypeReference type) - : base (type) - { - if (modifierType == null) - throw new ArgumentNullException (Mixin.Argument.modifierType.ToString ()); - Mixin.CheckType (type); - this.modifier_type = modifierType; - this.etype = MD.ElementType.CModReqD; - } - - } -} diff --git a/external/linker/cecil/Mono.Cecil/ModuleDefinition.cs b/external/linker/cecil/Mono.Cecil/ModuleDefinition.cs deleted file mode 100644 index 85381c0bbd..0000000000 --- a/external/linker/cecil/Mono.Cecil/ModuleDefinition.cs +++ /dev/null @@ -1,1377 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading; -using SR = System.Reflection; - -using Mono.Cecil.Cil; -using Mono.Cecil.Metadata; -using Mono.Cecil.PE; -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public enum ReadingMode { - Immediate = 1, - Deferred = 2, - } - - public sealed class ReaderParameters { - - ReadingMode reading_mode; - internal IAssemblyResolver assembly_resolver; - internal IMetadataResolver metadata_resolver; -#if !READ_ONLY - internal IMetadataImporterProvider metadata_importer_provider; - internal IReflectionImporterProvider reflection_importer_provider; -#endif - Stream symbol_stream; - ISymbolReaderProvider symbol_reader_provider; - bool read_symbols; - bool projections; - bool in_memory; - bool read_write; - - public ReadingMode ReadingMode { - get { return reading_mode; } - set { reading_mode = value; } - } - - public bool InMemory { - get { return in_memory; } - set { in_memory = value; } - } - - public IAssemblyResolver AssemblyResolver { - get { return assembly_resolver; } - set { assembly_resolver = value; } - } - - public IMetadataResolver MetadataResolver { - get { return metadata_resolver; } - set { metadata_resolver = value; } - } - -#if !READ_ONLY - public IMetadataImporterProvider MetadataImporterProvider { - get { return metadata_importer_provider; } - set { metadata_importer_provider = value; } - } - - public IReflectionImporterProvider ReflectionImporterProvider { - get { return reflection_importer_provider; } - set { reflection_importer_provider = value; } - } -#endif - - 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 bool ReadWrite { - get { return read_write; } - set { read_write = value; } - } - - public bool ApplyWindowsRuntimeProjections { - get { return projections; } - set { projections = 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; - uint? timestamp; - TargetArchitecture architecture; - IAssemblyResolver assembly_resolver; - IMetadataResolver metadata_resolver; -#if !READ_ONLY - IMetadataImporterProvider metadata_importer_provider; - IReflectionImporterProvider reflection_importer_provider; -#endif - - public ModuleKind Kind { - get { return kind; } - set { kind = value; } - } - - public TargetRuntime Runtime { - get { return runtime; } - set { runtime = value; } - } - - public uint? Timestamp { - get { return timestamp; } - set { timestamp = value; } - } - - public TargetArchitecture Architecture { - get { return architecture; } - set { architecture = value; } - } - - public IAssemblyResolver AssemblyResolver { - get { return assembly_resolver; } - set { assembly_resolver = value; } - } - - public IMetadataResolver MetadataResolver { - get { return metadata_resolver; } - set { metadata_resolver = value; } - } - -#if !READ_ONLY - public IMetadataImporterProvider MetadataImporterProvider { - get { return metadata_importer_provider; } - set { metadata_importer_provider = value; } - } - - public IReflectionImporterProvider ReflectionImporterProvider { - get { return reflection_importer_provider; } - set { reflection_importer_provider = value; } - } -#endif - - public ModuleParameters () - { - this.kind = ModuleKind.Dll; - this.Runtime = GetCurrentRuntime (); - this.architecture = TargetArchitecture.I386; - } - - static TargetRuntime GetCurrentRuntime () - { -#if !NET_CORE - return typeof (object).Assembly.ImageRuntimeVersion.ParseRuntime (); -#else - var corlib_name = AssemblyNameReference.Parse (typeof (object).Assembly ().FullName); - var corlib_version = corlib_name.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 - } - } - - interface ICustomMetadataWriter - { - /* - * Remap TypeReference or create custom TypeRef token. - * - * Return true to use the returned custom 'token'. - * - * Return false to create a TypeRef token for 'type' - * (which may have been replaced with a different TypeReference). - * - * This is necessary when types are moved from one assembly to another - * to either adjust the scope or replace a TypeRef with a TypeDef token. - */ - bool CreateTypeRefToken (ref TypeReference type, out MetadataToken token); - } - - public sealed class WriterParameters { - - uint? timestamp; - Stream symbol_stream; - ISymbolWriterProvider symbol_writer_provider; - bool write_symbols; -#if !NET_CORE - SR.StrongNameKeyPair key_pair; -#endif - - public uint? Timestamp { - get { return timestamp; } - set { timestamp = value; } - } - - public Stream SymbolStream { - get { return symbol_stream; } - set { symbol_stream = value; } - } - - public ISymbolWriterProvider SymbolWriterProvider { - get { return symbol_writer_provider; } - set { symbol_writer_provider = value; } - } - - public bool WriteSymbols { - get { return write_symbols; } - set { write_symbols = value; } - } - -#if !NET_CORE - public SR.StrongNameKeyPair StrongNameKeyPair { - get { return key_pair; } - set { key_pair = value; } - } -#endif - } - -#endif - - public sealed class ModuleDefinition : ModuleReference, ICustomAttributeProvider, ICustomDebugInformationProvider, IDisposable { - - internal Image Image; - internal MetadataSystem MetadataSystem; - internal ReadingMode ReadingMode; - internal ISymbolReaderProvider SymbolReaderProvider; - - internal ISymbolReader symbol_reader; - internal Disposable assembly_resolver; - internal IMetadataResolver metadata_resolver; - internal TypeSystem type_system; - internal readonly MetadataReader reader; - readonly string file_name; - - internal string runtime_version; - internal ModuleKind kind; - WindowsRuntimeProjections projections; - MetadataKind metadata_kind; - TargetRuntime runtime; - TargetArchitecture architecture; - ModuleAttributes attributes; - ModuleCharacteristics characteristics; - internal ushort linker_version = 8; - Guid mvid; - internal uint timestamp; - - internal AssemblyDefinition assembly; - MethodDefinition entry_point; - -#if !READ_ONLY - internal IReflectionImporter reflection_importer; - internal IMetadataImporter metadata_importer; - ICustomMetadataWriter custom_writer; -#endif - Collection custom_attributes; - Collection references; - Collection modules; - Collection resources; - Collection exported_types; - TypeDefinitionCollection types; - - internal Collection custom_infos; - - public bool IsMain { - get { return kind != ModuleKind.NetModule; } - } - - public ModuleKind Kind { - get { return kind; } - set { kind = value; } - } - - public MetadataKind MetadataKind { - get { return metadata_kind; } - set { metadata_kind = value; } - } - - internal WindowsRuntimeProjections Projections { - get { - if (projections == null) - Interlocked.CompareExchange (ref projections, new WindowsRuntimeProjections (this), null); - - return projections; - } - } - - public TargetRuntime Runtime { - get { return runtime; } - set { - runtime = value; - runtime_version = runtime.RuntimeVersionString (); - } - } - - public string RuntimeVersion { - get { return runtime_version; } - set { - runtime_version = value; - runtime = runtime_version.ParseRuntime (); - } - } - - public TargetArchitecture Architecture { - get { return architecture; } - set { architecture = value; } - } - - public ModuleAttributes Attributes { - get { return attributes; } - set { attributes = value; } - } - - public ModuleCharacteristics Characteristics { - get { return characteristics; } - set { characteristics = value; } - } - - [Obsolete ("Use FileName")] - public string FullyQualifiedName { - get { return file_name; } - } - - public string FileName { - get { return file_name; } - } - - public Guid Mvid { - get { return mvid; } - set { mvid = value; } - } - - internal bool HasImage { - get { return Image != null; } - } - - public bool HasSymbols { - get { return symbol_reader != null; } - } - - public ISymbolReader SymbolReader { - get { return symbol_reader; } - } - - public override MetadataScopeType MetadataScopeType { - get { return MetadataScopeType.ModuleDefinition; } - } - - public AssemblyDefinition Assembly { - get { return assembly; } - } - -#if !READ_ONLY - internal IReflectionImporter ReflectionImporter { - get { - if (reflection_importer == null) - Interlocked.CompareExchange (ref reflection_importer, new DefaultReflectionImporter (this), null); - - return reflection_importer; - } - } - - internal IMetadataImporter MetadataImporter { - get { - if (metadata_importer == null) - Interlocked.CompareExchange (ref metadata_importer, new DefaultMetadataImporter (this), null); - - return metadata_importer; - } - } - - internal void SetMetadataImporter (IMetadataImporter importer) - { - if (this.metadata_importer != null) - throw new InvalidOperationException (); - this.metadata_importer = importer; - } - - internal ICustomMetadataWriter CustomMetadataWriter { - get { return custom_writer; } - set { custom_writer = value; } - } -#endif - - public IAssemblyResolver AssemblyResolver { - get { - if (assembly_resolver.value == null) { - lock (module_lock) { - assembly_resolver = Disposable.Owned (new DefaultAssemblyResolver () as IAssemblyResolver); - } - } - - return assembly_resolver.value; - } - } - - public IMetadataResolver MetadataResolver { - get { - if (metadata_resolver == null) - Interlocked.CompareExchange (ref metadata_resolver, new MetadataResolver (this.AssemblyResolver), null); - - return metadata_resolver; - } - } - - public TypeSystem TypeSystem { - get { - if (type_system == null) - Interlocked.CompareExchange (ref type_system, TypeSystem.CreateTypeSystem (this), null); - - return type_system; - } - } - - public bool HasAssemblyReferences { - get { - if (references != null) - return references.Count > 0; - - return HasImage && Image.HasTable (Table.AssemblyRef); - } - } - - public Collection AssemblyReferences { - get { - if (references != null) - return references; - - if (HasImage) - return Read (ref references, this, (_, reader) => reader.ReadAssemblyReferences ()); - - return references = new Collection (); - } - } - - public bool HasModuleReferences { - get { - if (modules != null) - return modules.Count > 0; - - return HasImage && Image.HasTable (Table.ModuleRef); - } - } - - public Collection ModuleReferences { - get { - if (modules != null) - return modules; - - if (HasImage) - return Read (ref modules, this, (_, reader) => reader.ReadModuleReferences ()); - - return modules = new Collection (); - } - } - - 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; - } - } - - public Collection Resources { - get { - if (resources != null) - return resources; - - if (HasImage) - return Read (ref resources, this, (_, reader) => reader.ReadResources ()); - - return resources = new Collection (); - } - } - - public bool HasCustomAttributes { - get { - if (custom_attributes != null) - return custom_attributes.Count > 0; - - return this.GetHasCustomAttributes (this); - } - } - - public Collection CustomAttributes { - get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, this)); } - } - - public bool HasTypes { - get { - if (types != null) - return types.Count > 0; - - return HasImage && Image.HasTable (Table.TypeDef); - } - } - - public Collection Types { - get { - if (types != null) - return types; - - if (HasImage) - return Read (ref types, 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 ExportedTypes { - get { - if (exported_types != null) - return exported_types; - - if (HasImage) - return Read (ref exported_types, this, (_, reader) => reader.ReadExportedTypes ()); - - return exported_types = new Collection (); - } - } - - public MethodDefinition EntryPoint { - get { - if (entry_point != null) - return entry_point; - - if (HasImage) - return Read (ref entry_point, this, (_, reader) => reader.ReadEntryPoint ()); - - return entry_point = null; - } - set { entry_point = value; } - } - - public bool HasCustomDebugInformations { - get { - return custom_infos != null && custom_infos.Count > 0; - } - } - - public Collection CustomDebugInformations { - get { - return custom_infos ?? (custom_infos = new Collection ()); - } - } - - internal ModuleDefinition () - { - this.MetadataSystem = new MetadataSystem (); - this.token = new MetadataToken (TokenType.Module, 1); - } - - internal ModuleDefinition (Image image) - : this () - { - this.Image = image; - this.kind = image.Kind; - this.RuntimeVersion = image.RuntimeVersion; - this.architecture = image.Architecture; - this.attributes = image.Attributes; - this.characteristics = image.Characteristics; - this.linker_version = image.LinkerVersion; - this.file_name = image.FileName; - this.timestamp = image.Timestamp; - - this.reader = new MetadataReader (this); - } - - public void Dispose () - { - if (Image != null) - Image.Dispose (); - - if (symbol_reader != null) - symbol_reader.Dispose (); - - if (assembly_resolver.value != null) - assembly_resolver.Dispose (); - } - - public bool HasTypeReference (string fullName) - { - return HasTypeReference (string.Empty, fullName); - } - - public bool HasTypeReference (string scope, string fullName) - { - Mixin.CheckFullName (fullName); - - if (!HasImage) - return false; - - return GetTypeReference (scope, fullName) != null; - } - - 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) - { - Mixin.CheckFullName (fullName); - - if (!HasImage) { - type = null; - return false; - } - - return (type = GetTypeReference (scope, fullName)) != null; - } - - TypeReference GetTypeReference (string scope, string fullname) - { - return Read (new Row (scope, fullname), (row, reader) => reader.GetTypeReference (row.Col1, row.Col2)); - } - - public IEnumerable GetTypeReferences () - { - if (!HasImage) - return Empty.Array; - - return Read (this, (_, reader) => reader.GetTypeReferences ()); - } - - public IEnumerable GetMemberReferences () - { - if (!HasImage) - return Empty.Array; - - return Read (this, (_, reader) => reader.GetMemberReferences ()); - } - - public IEnumerable GetCustomAttributes () - { - if (!HasImage) - return Empty.Array; - - return Read (this, (_, reader) => reader.GetCustomAttributes ()); - } - - public TypeReference GetType (string fullName, bool runtimeName) - { - return runtimeName - ? TypeParser.ParseType (this, fullName) - : GetType (fullName); - } - - public TypeDefinition GetType (string fullName) - { - Mixin.CheckFullName (fullName); - - var position = fullName.IndexOf ('/'); - if (position > 0) - return GetNestedType (fullName); - - return ((TypeDefinitionCollection) this.Types).GetType (fullName); - } - - public TypeDefinition GetType (string @namespace, string name) - { - Mixin.CheckName (name); - - return ((TypeDefinitionCollection) this.Types).GetType (@namespace ?? string.Empty, name); - } - - public IEnumerable GetTypes () - { - return GetTypes (Types); - } - - static IEnumerable GetTypes (Collection types) - { - for (int i = 0; i < types.Count; i++) { - var type = types [i]; - - yield return type; - - if (!type.HasNestedTypes) - continue; - - foreach (var nested in GetTypes (type.NestedTypes)) - yield return nested; - } - } - - TypeDefinition GetNestedType (string fullname) - { - 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; - } - - internal FieldDefinition Resolve (FieldReference field) - { - return MetadataResolver.Resolve (field); - } - - internal MethodDefinition Resolve (MethodReference method) - { - return MetadataResolver.Resolve (method); - } - - internal TypeDefinition Resolve (TypeReference type) - { - return MetadataResolver.Resolve (type); - } - -#if !READ_ONLY - - static void CheckContext (IGenericParameterProvider context, ModuleDefinition module) - { - if (context == null) - return; - - if (context.Module != module) - throw new ArgumentException (); - } - - [Obsolete ("Use ImportReference", error: false)] - public TypeReference Import (Type type) - { - return ImportReference (type, null); - } - - public TypeReference ImportReference (Type type) - { - return ImportReference (type, null); - } - - [Obsolete ("Use ImportReference", error: false)] - public TypeReference Import (Type type, IGenericParameterProvider context) - { - return ImportReference (type, context); - } - - public TypeReference ImportReference (Type type, IGenericParameterProvider context) - { - Mixin.CheckType (type); - CheckContext (context, this); - - return ReflectionImporter.ImportReference (type, context); - } - - [Obsolete ("Use ImportReference", error: false)] - public FieldReference Import (SR.FieldInfo field) - { - return ImportReference (field, null); - } - - [Obsolete ("Use ImportReference", error: false)] - public FieldReference Import (SR.FieldInfo field, IGenericParameterProvider context) - { - return ImportReference (field, context); - } - - public FieldReference ImportReference (SR.FieldInfo field) - { - return ImportReference (field, null); - } - - public FieldReference ImportReference (SR.FieldInfo field, IGenericParameterProvider context) - { - Mixin.CheckField (field); - CheckContext (context, this); - - return ReflectionImporter.ImportReference (field, context); - } - - [Obsolete ("Use ImportReference", error: false)] - public MethodReference Import (SR.MethodBase method) - { - return ImportReference (method, null); - } - - [Obsolete ("Use ImportReference", error: false)] - public MethodReference Import (SR.MethodBase method, IGenericParameterProvider context) - { - return ImportReference (method, context); - } - - public MethodReference ImportReference (SR.MethodBase method) - { - return ImportReference (method, null); - } - - public MethodReference ImportReference (SR.MethodBase method, IGenericParameterProvider context) - { - Mixin.CheckMethod (method); - CheckContext (context, this); - - return ReflectionImporter.ImportReference (method, context); - } - - [Obsolete ("Use ImportReference", error: false)] - public TypeReference Import (TypeReference type) - { - return ImportReference (type, null); - } - - [Obsolete ("Use ImportReference", error: false)] - public TypeReference Import (TypeReference type, IGenericParameterProvider context) - { - return ImportReference (type, context); - } - - public TypeReference ImportReference (TypeReference type) - { - return ImportReference (type, null); - } - - public TypeReference ImportReference (TypeReference type, IGenericParameterProvider context) - { - Mixin.CheckType (type); - - if (type.Module == this) - return type; - - CheckContext (context, this); - - return MetadataImporter.ImportReference (type, context); - } - - [Obsolete ("Use ImportReference", error: false)] - public FieldReference Import (FieldReference field) - { - return ImportReference (field, null); - } - - [Obsolete ("Use ImportReference", error: false)] - public FieldReference Import (FieldReference field, IGenericParameterProvider context) - { - return ImportReference (field, context); - } - - public FieldReference ImportReference (FieldReference field) - { - return ImportReference (field, null); - } - - public FieldReference ImportReference (FieldReference field, IGenericParameterProvider context) - { - Mixin.CheckField (field); - - if (field.Module == this) - return field; - - CheckContext (context, this); - - return MetadataImporter.ImportReference (field, context); - } - - [Obsolete ("Use ImportReference", error: false)] - public MethodReference Import (MethodReference method) - { - return ImportReference (method, null); - } - - [Obsolete ("Use ImportReference", error: false)] - public MethodReference Import (MethodReference method, IGenericParameterProvider context) - { - return ImportReference (method, context); - } - - public MethodReference ImportReference (MethodReference method) - { - return ImportReference (method, null); - } - - public MethodReference ImportReference (MethodReference method, IGenericParameterProvider context) - { - Mixin.CheckMethod (method); - - if (method.Module == this) - return method; - - CheckContext (context, this); - - return MetadataImporter.ImportReference (method, context); - } - -#endif - - public IMetadataTokenProvider LookupToken (int token) - { - return LookupToken (new MetadataToken ((uint) token)); - } - - public IMetadataTokenProvider LookupToken (MetadataToken token) - { - return Read (token, (t, reader) => reader.LookupToken (t)); - } - - readonly object module_lock = new object(); - - internal object SyncRoot { - get { return module_lock; } - } - - internal void Read (TItem item, Action read) - { - lock (module_lock) { - var position = reader.position; - var context = reader.context; - - read (item, reader); - - reader.position = position; - reader.context = context; - } - } - - internal TRet Read (TItem item, Func read) - { - lock (module_lock) { - var position = reader.position; - var context = reader.context; - - var ret = read (item, reader); - - reader.position = position; - reader.context = context; - - return ret; - } - } - - internal TRet Read (ref TRet variable, TItem item, Func read) where TRet : class - { - lock (module_lock) { - if (variable != null) - return variable; - - var position = reader.position; - var context = reader.context; - - var ret = read (item, reader); - - reader.position = position; - reader.context = context; - - return variable = ret; - } - } - - public bool HasDebugHeader { - get { return Image != null && Image.DebugHeader != null; } - } - - public ImageDebugHeader GetDebugHeader () - { - return Image.DebugHeader ?? new ImageDebugHeader (); - } - -#if !READ_ONLY - - public static ModuleDefinition CreateModule (string name, ModuleKind kind) - { - return CreateModule (name, new ModuleParameters { Kind = kind }); - } - - public static ModuleDefinition CreateModule (string name, ModuleParameters parameters) - { - Mixin.CheckName (name); - Mixin.CheckParameters (parameters); - - var module = new ModuleDefinition { - Name = name, - kind = parameters.Kind, - timestamp = parameters.Timestamp ?? Mixin.GetTimestamp (), - Runtime = parameters.Runtime, - architecture = parameters.Architecture, - mvid = Guid.NewGuid (), - Attributes = ModuleAttributes.ILOnly, - Characteristics = (ModuleCharacteristics) 0x8540, - }; - - if (parameters.AssemblyResolver != null) - module.assembly_resolver = Disposable.NotOwned (parameters.AssemblyResolver); - - if (parameters.MetadataResolver != null) - module.metadata_resolver = parameters.MetadataResolver; - -#if !READ_ONLY - if (parameters.MetadataImporterProvider != null) - module.metadata_importer = parameters.MetadataImporterProvider.GetMetadataImporter (module); - if (parameters.ReflectionImporterProvider != null) - module.reflection_importer = parameters.ReflectionImporterProvider.GetReflectionImporter (module); -#endif - - if (parameters.Kind != ModuleKind.NetModule) { - var assembly = new AssemblyDefinition (); - module.assembly = assembly; - module.assembly.Name = CreateAssemblyName (name); - assembly.main_module = module; - } - - module.Types.Add (new TypeDefinition (string.Empty, "", TypeAttributes.NotPublic)); - - return module; - } - - static AssemblyNameDefinition CreateAssemblyName (string name) - { - if (name.EndsWith (".dll") || name.EndsWith (".exe")) - name = name.Substring (0, name.Length - 4); - - return new AssemblyNameDefinition (name, Mixin.ZeroVersion); - } - -#endif - - public void ReadSymbols () - { - if (string.IsNullOrEmpty (file_name)) - throw new InvalidOperationException (); - - var provider = new DefaultSymbolReaderProvider (throwIfNoSymbol: true); - ReadSymbols (provider.GetSymbolReader (this, file_name)); - } - - public void ReadSymbols (ISymbolReader reader) - { - if (reader == null) - throw new ArgumentNullException ("reader"); - - symbol_reader = reader; - - if (!symbol_reader.ProcessDebugHeader (GetDebugHeader ())) { - symbol_reader = null; - throw new InvalidOperationException (); - } - - if (HasImage && ReadingMode == ReadingMode.Immediate) { - var immediate_reader = new ImmediateModuleReader (Image); - immediate_reader.ReadSymbols (this); - } - } - - public static ModuleDefinition ReadModule (string fileName) - { - return ReadModule (fileName, new ReaderParameters (ReadingMode.Deferred)); - } - - public static ModuleDefinition ReadModule (string fileName, ReaderParameters parameters) - { - var stream = GetFileStream (fileName, FileMode.Open, parameters.ReadWrite ? FileAccess.ReadWrite : FileAccess.Read, FileShare.Read); - - if (parameters.InMemory) { - var memory = new MemoryStream (stream.CanSeek ? (int) stream.Length : 0); - using (stream) - stream.CopyTo (memory); - - memory.Position = 0; - stream = memory; - } - - try { - return ReadModule (Disposable.Owned (stream), fileName, parameters); - } catch (Exception) { - stream.Dispose (); - throw; - } - } - - static Stream GetFileStream (string fileName, FileMode mode, FileAccess access, FileShare share) - { - Mixin.CheckFileName (fileName); - - return new FileStream (fileName, mode, access, share); - } - - public static ModuleDefinition ReadModule (Stream stream) - { - return ReadModule (stream, new ReaderParameters (ReadingMode.Deferred)); - } - - public static ModuleDefinition ReadModule (Stream stream, ReaderParameters parameters) - { - Mixin.CheckStream (stream); - Mixin.CheckReadSeek (stream); - - return ReadModule (Disposable.NotOwned (stream), stream.GetFileName (), parameters); - } - - static ModuleDefinition ReadModule (Disposable stream, string fileName, ReaderParameters parameters) - { - Mixin.CheckParameters (parameters); - - return ModuleReader.CreateModule ( - ImageReader.ReadImage (stream, fileName), - parameters); - } - -#if !READ_ONLY - - public void Write (string fileName) - { - Write (fileName, new WriterParameters ()); - } - - public void Write (string fileName, WriterParameters parameters) - { - Mixin.CheckParameters (parameters); - var file = GetFileStream (fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.Read); - ModuleWriter.WriteModule (this, Disposable.Owned (file), parameters); - } - - public void Write () - { - Write (new WriterParameters ()); - } - - public void Write (WriterParameters parameters) - { - if (!HasImage) - throw new InvalidOperationException (); - - Write (Image.Stream.value, parameters); - } - - public void Write (Stream stream) - { - Write (stream, new WriterParameters ()); - } - - public void Write (Stream stream, WriterParameters parameters) - { - Mixin.CheckStream (stream); - Mixin.CheckWriteSeek (stream); - Mixin.CheckParameters (parameters); - - ModuleWriter.WriteModule (this, Disposable.NotOwned (stream), parameters); - } - -#endif - - } - - static partial class Mixin { - - public enum Argument { - name, - fileName, - fullName, - stream, - type, - method, - field, - parameters, - module, - modifierType, - eventType, - fieldType, - declaringType, - returnType, - propertyType, - interfaceType, - } - - public static void CheckName (object name) - { - if (name == null) - throw new ArgumentNullException (Argument.name.ToString ()); - } - - public static void CheckName (string name) - { - if (string.IsNullOrEmpty (name)) - throw new ArgumentNullOrEmptyException (Argument.name.ToString ()); - } - - public static void CheckFileName (string fileName) - { - if (string.IsNullOrEmpty (fileName)) - throw new ArgumentNullOrEmptyException (Argument.fileName.ToString ()); - } - - public static void CheckFullName (string fullName) - { - if (string.IsNullOrEmpty (fullName)) - throw new ArgumentNullOrEmptyException (Argument.fullName.ToString ()); - } - - public static void CheckStream (object stream) - { - if (stream == null) - throw new ArgumentNullException (Argument.stream.ToString ()); - } - - public static void CheckWriteSeek (Stream stream) - { - if (!stream.CanWrite || !stream.CanSeek) - throw new ArgumentException ("Stream must be writable and seekable."); - } - - public static void CheckReadSeek (Stream stream) - { - if (!stream.CanRead || !stream.CanSeek) - throw new ArgumentException ("Stream must be readable and seekable."); - } - - public static void CheckType (object type) - { - if (type == null) - throw new ArgumentNullException (Argument.type.ToString ()); - } - - public static void CheckType (object type, Argument argument) - { - if (type == null) - throw new ArgumentNullException (argument.ToString ()); - } - - public static void CheckField (object field) - { - if (field == null) - throw new ArgumentNullException (Argument.field.ToString ()); - } - - public static void CheckMethod (object method) - { - if (method == null) - throw new ArgumentNullException (Argument.method.ToString ()); - } - - public static void CheckParameters (object parameters) - { - if (parameters == null) - throw new ArgumentNullException (Argument.parameters.ToString ()); - } - - public static uint GetTimestamp () - { - return (uint) DateTime.UtcNow.Subtract (new DateTime (1970, 1, 1)).TotalSeconds; - } - - public static bool HasImage (this ModuleDefinition self) - { - return self != null && self.HasImage; - } - - public static string GetFileName (this Stream self) - { - var file_stream = self as FileStream; - if (file_stream == null) - return string.Empty; - - return Path.GetFullPath (file_stream.Name); - } - -#if !NET_4_0 - public static void CopyTo (this Stream self, Stream target) - { - var buffer = new byte [1024 * 8]; - int read; - while ((read = self.Read (buffer, 0, buffer.Length)) > 0) - target.Write (buffer, 0, read); - } -#endif - - public static TargetRuntime ParseRuntime (this string self) - { - if (string.IsNullOrEmpty (self)) - return TargetRuntime.Net_4_0; - - 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; - } - } - - public static string RuntimeVersionString (this TargetRuntime runtime) - { - switch (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"; - } - } - - public static bool IsWindowsMetadata (this ModuleDefinition module) - { - return module.MetadataKind != MetadataKind.Ecma335; - } - - public static byte [] ReadAll (this Stream self) - { - int read; - var memory = new MemoryStream ((int) self.Length); - var buffer = new byte [1024]; - - while ((read = self.Read (buffer, 0, buffer.Length)) != 0) - memory.Write (buffer, 0, read); - - return memory.ToArray (); - } - - public static void Read (object o) - { - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/ModuleKind.cs b/external/linker/cecil/Mono.Cecil/ModuleKind.cs deleted file mode 100644 index 2cd084db5a..0000000000 --- a/external/linker/cecil/Mono.Cecil/ModuleKind.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - public enum ModuleKind { - Dll, - Console, - Windows, - NetModule, - } - - public enum MetadataKind { - Ecma335, - WindowsMetadata, - ManagedWindowsMetadata, - } - - public enum TargetArchitecture { - I386 = 0x014c, - AMD64 = 0x8664, - IA64 = 0x0200, - ARM = 0x01c0, - ARMv7 = 0x01c4, - ARM64 = 0xaa64, - } - - [Flags] - public enum ModuleAttributes { - ILOnly = 1, - Required32Bit = 2, - ILLibrary = 4, - StrongNameSigned = 8, - Preferred32Bit = 0x00020000, - } - - [Flags] - public enum ModuleCharacteristics { - HighEntropyVA = 0x0020, - DynamicBase = 0x0040, - NoSEH = 0x0400, - NXCompat = 0x0100, - AppContainer = 0x1000, - TerminalServerAware = 0x8000, - } -} diff --git a/external/linker/cecil/Mono.Cecil/ModuleReference.cs b/external/linker/cecil/Mono.Cecil/ModuleReference.cs deleted file mode 100644 index 43c618f4c1..0000000000 --- a/external/linker/cecil/Mono.Cecil/ModuleReference.cs +++ /dev/null @@ -1,49 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil { - - public class ModuleReference : IMetadataScope { - - string name; - - internal MetadataToken token; - - public string Name { - get { return name; } - set { name = value; } - } - - public virtual MetadataScopeType MetadataScopeType { - get { return MetadataScopeType.ModuleReference; } - } - - public MetadataToken MetadataToken { - get { return token; } - set { token = value; } - } - - internal ModuleReference () - { - this.token = new MetadataToken (TokenType.ModuleRef); - } - - public ModuleReference (string name) - : this () - { - this.name = name; - } - - public override string ToString () - { - return name; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/NativeType.cs b/external/linker/cecil/Mono.Cecil/NativeType.cs deleted file mode 100644 index 02174db6ff..0000000000 --- a/external/linker/cecil/Mono.Cecil/NativeType.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil { - - public enum NativeType { - None = 0x66, - - Boolean = 0x02, - I1 = 0x03, - U1 = 0x04, - I2 = 0x05, - U2 = 0x06, - I4 = 0x07, - U4 = 0x08, - I8 = 0x09, - U8 = 0x0a, - R4 = 0x0b, - R8 = 0x0c, - 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 - } -} diff --git a/external/linker/cecil/Mono.Cecil/PInvokeAttributes.cs b/external/linker/cecil/Mono.Cecil/PInvokeAttributes.cs deleted file mode 100644 index 11e96d20d4..0000000000 --- a/external/linker/cecil/Mono.Cecil/PInvokeAttributes.cs +++ /dev/null @@ -1,44 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - [Flags] - public enum PInvokeAttributes : ushort { - NoMangle = 0x0001, // PInvoke is to use the member name as specified - - // Character set - CharSetMask = 0x0006, - CharSetNotSpec = 0x0000, - CharSetAnsi = 0x0002, - CharSetUnicode = 0x0004, - CharSetAuto = 0x0006, - - SupportsLastError = 0x0040, // Information about target function. Not relevant for fields - - // Calling convetion - CallConvMask = 0x0700, - CallConvWinapi = 0x0100, - CallConvCdecl = 0x0200, - CallConvStdCall = 0x0300, - CallConvThiscall = 0x0400, - CallConvFastcall = 0x0500, - - BestFitMask = 0x0030, - BestFitEnabled = 0x0010, - BestFitDisabled = 0x0020, - - ThrowOnUnmappableCharMask = 0x3000, - ThrowOnUnmappableCharEnabled = 0x1000, - ThrowOnUnmappableCharDisabled = 0x2000, - } -} diff --git a/external/linker/cecil/Mono.Cecil/PInvokeInfo.cs b/external/linker/cecil/Mono.Cecil/PInvokeInfo.cs deleted file mode 100644 index 8efc010819..0000000000 --- a/external/linker/cecil/Mono.Cecil/PInvokeInfo.cs +++ /dev/null @@ -1,120 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil { - - public sealed class PInvokeInfo { - - ushort attributes; - string entry_point; - ModuleReference module; - - public PInvokeAttributes Attributes { - get { return (PInvokeAttributes) attributes; } - set { attributes = (ushort) value; } - } - - public string EntryPoint { - get { return entry_point; } - set { entry_point = value; } - } - - public ModuleReference Module { - get { return module; } - set { module = value; } - } - - #region PInvokeAttributes - - public bool IsNoMangle { - get { return attributes.GetAttributes ((ushort) PInvokeAttributes.NoMangle); } - set { attributes = attributes.SetAttributes ((ushort) PInvokeAttributes.NoMangle, value); } - } - - public bool IsCharSetNotSpec { - 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 attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAnsi); } - set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAnsi, value); } - } - - public bool IsCharSetUnicode { - 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 attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAuto); } - set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CharSetMask, (ushort) PInvokeAttributes.CharSetAuto, value); } - } - - public bool SupportsLastError { - get { return attributes.GetAttributes ((ushort) PInvokeAttributes.SupportsLastError); } - set { attributes = attributes.SetAttributes ((ushort) PInvokeAttributes.SupportsLastError, value); } - } - - public bool IsCallConvWinapi { - 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 attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvCdecl); } - set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvCdecl, value); } - } - - public bool IsCallConvStdCall { - 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 attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvThiscall); } - set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvThiscall, value); } - } - - public bool IsCallConvFastcall { - get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvFastcall); } - set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.CallConvMask, (ushort) PInvokeAttributes.CallConvFastcall, value); } - } - - public bool IsBestFitEnabled { - get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitEnabled); } - set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitEnabled, value); } - } - - public bool IsBestFitDisabled { - get { return attributes.GetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitDisabled); } - set { attributes = attributes.SetMaskedAttributes ((ushort) PInvokeAttributes.BestFitMask, (ushort) PInvokeAttributes.BestFitDisabled, value); } - } - - public bool IsThrowOnUnmappableCharEnabled { - 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); } - } - - #endregion - - public PInvokeInfo (PInvokeAttributes attributes, string entryPoint, ModuleReference module) - { - this.attributes = (ushort) attributes; - this.entry_point = entryPoint; - this.module = module; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/ParameterAttributes.cs b/external/linker/cecil/Mono.Cecil/ParameterAttributes.cs deleted file mode 100644 index 9a0e35e07e..0000000000 --- a/external/linker/cecil/Mono.Cecil/ParameterAttributes.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - [Flags] - public enum ParameterAttributes : ushort { - None = 0x0000, - In = 0x0001, // Param is [In] - Out = 0x0002, // Param is [Out] - Lcid = 0x0004, - Retval = 0x0008, - Optional = 0x0010, // Param is optional - HasDefault = 0x1000, // Param has default value - HasFieldMarshal = 0x2000, // Param has field marshal - Unused = 0xcfe0 // Reserved: shall be zero in a conforming implementation - } -} diff --git a/external/linker/cecil/Mono.Cecil/ParameterDefinition.cs b/external/linker/cecil/Mono.Cecil/ParameterDefinition.cs deleted file mode 100644 index 59bafe2c8f..0000000000 --- a/external/linker/cecil/Mono.Cecil/ParameterDefinition.cs +++ /dev/null @@ -1,146 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public sealed class ParameterDefinition : ParameterReference, ICustomAttributeProvider, IConstantProvider, IMarshalInfoProvider { - - ushort attributes; - - internal IMethodSignature method; - - object constant = Mixin.NotResolved; - Collection custom_attributes; - MarshalInfo marshal_info; - - public ParameterAttributes Attributes { - get { return (ParameterAttributes) attributes; } - set { attributes = (ushort) value; } - } - - public IMethodSignature Method { - get { return method; } - } - - public int Sequence { - get { - if (method == null) - return -1; - - return method.HasImplicitThis () ? index + 1 : index; - } - } - - public bool HasConstant { - get { - this.ResolveConstant (ref constant, parameter_type.Module); - - return constant != Mixin.NoValue; - } - set { if (!value) constant = Mixin.NoValue; } - } - - public object Constant { - get { return HasConstant ? constant : null; } - set { constant = value; } - } - - public bool HasCustomAttributes { - get { - if (custom_attributes != null) - return custom_attributes.Count > 0; - - return this.GetHasCustomAttributes (parameter_type.Module); - } - } - - public Collection CustomAttributes { - get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, 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 ?? (this.GetMarshalInfo (ref marshal_info, parameter_type.Module)); } - set { marshal_info = value; } - } - - #region ParameterAttributes - - public bool IsIn { - get { return attributes.GetAttributes ((ushort) ParameterAttributes.In); } - set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.In, value); } - } - - public bool IsOut { - get { return attributes.GetAttributes ((ushort) ParameterAttributes.Out); } - set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.Out, value); } - } - - public bool IsLcid { - get { return attributes.GetAttributes ((ushort) ParameterAttributes.Lcid); } - set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.Lcid, value); } - } - - public bool IsReturnValue { - get { return attributes.GetAttributes ((ushort) ParameterAttributes.Retval); } - set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.Retval, value); } - } - - public bool IsOptional { - get { return attributes.GetAttributes ((ushort) ParameterAttributes.Optional); } - set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.Optional, value); } - } - - public bool HasDefault { - get { return attributes.GetAttributes ((ushort) ParameterAttributes.HasDefault); } - set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.HasDefault, value); } - } - - public bool HasFieldMarshal { - get { return attributes.GetAttributes ((ushort) ParameterAttributes.HasFieldMarshal); } - set { attributes = attributes.SetAttributes ((ushort) ParameterAttributes.HasFieldMarshal, value); } - } - - #endregion - - internal ParameterDefinition (TypeReference parameterType, IMethodSignature method) - : this (string.Empty, ParameterAttributes.None, parameterType) - { - this.method = method; - } - - public ParameterDefinition (TypeReference parameterType) - : this (string.Empty, ParameterAttributes.None, parameterType) - { - } - - public ParameterDefinition (string name, ParameterAttributes attributes, TypeReference parameterType) - : base (name, parameterType) - { - this.attributes = (ushort) attributes; - this.token = new MetadataToken (TokenType.Param); - } - - public override ParameterDefinition Resolve () - { - return this; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/ParameterDefinitionCollection.cs b/external/linker/cecil/Mono.Cecil/ParameterDefinitionCollection.cs deleted file mode 100644 index 1a9764c50e..0000000000 --- a/external/linker/cecil/Mono.Cecil/ParameterDefinitionCollection.cs +++ /dev/null @@ -1,62 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - sealed class ParameterDefinitionCollection : Collection { - - readonly IMethodSignature method; - - internal ParameterDefinitionCollection (IMethodSignature method) - { - this.method = method; - } - - internal ParameterDefinitionCollection (IMethodSignature method, int capacity) - : base (capacity) - { - this.method = method; - } - - protected override void OnAdd (ParameterDefinition item, int index) - { - item.method = method; - item.index = index; - } - - protected override void OnInsert (ParameterDefinition item, int index) - { - item.method = method; - item.index = index; - - for (int i = index; i < size; i++) - items [i].index = i + 1; - } - - protected override void OnSet (ParameterDefinition item, int index) - { - item.method = method; - item.index = index; - } - - protected override void OnRemove (ParameterDefinition item, int index) - { - item.method = null; - item.index = -1; - - for (int i = index + 1; i < size; i++) - items [i].index = i - 1; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/ParameterReference.cs b/external/linker/cecil/Mono.Cecil/ParameterReference.cs deleted file mode 100644 index 4670a562be..0000000000 --- a/external/linker/cecil/Mono.Cecil/ParameterReference.cs +++ /dev/null @@ -1,57 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - public abstract class ParameterReference : IMetadataTokenProvider { - - string name; - internal int index = -1; - protected TypeReference parameter_type; - internal MetadataToken token; - - public string Name { - get { return name; } - set { name = value; } - } - - public int Index { - get { return index; } - } - - public TypeReference ParameterType { - get { return parameter_type; } - set { parameter_type = value; } - } - - public MetadataToken MetadataToken { - get { return token; } - set { token = value; } - } - - internal ParameterReference (string name, TypeReference parameterType) - { - if (parameterType == null) - throw new ArgumentNullException ("parameterType"); - - this.name = name ?? string.Empty; - this.parameter_type = parameterType; - } - - public override string ToString () - { - return name; - } - - public abstract ParameterDefinition Resolve (); - } -} diff --git a/external/linker/cecil/Mono.Cecil/PinnedType.cs b/external/linker/cecil/Mono.Cecil/PinnedType.cs deleted file mode 100644 index fa89af514b..0000000000 --- a/external/linker/cecil/Mono.Cecil/PinnedType.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using MD = Mono.Cecil.Metadata; - -namespace Mono.Cecil { - - public sealed class PinnedType : TypeSpecification { - - 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/external/linker/cecil/Mono.Cecil/PointerType.cs b/external/linker/cecil/Mono.Cecil/PointerType.cs deleted file mode 100644 index 4b21164a32..0000000000 --- a/external/linker/cecil/Mono.Cecil/PointerType.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using MD = Mono.Cecil.Metadata; - -namespace Mono.Cecil { - - public sealed class PointerType : TypeSpecification { - - public override string Name { - get { return base.Name + "*"; } - } - - public override string 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 type) - : base (type) - { - Mixin.CheckType (type); - this.etype = MD.ElementType.Ptr; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/PropertyAttributes.cs b/external/linker/cecil/Mono.Cecil/PropertyAttributes.cs deleted file mode 100644 index 4d1ce8c8b3..0000000000 --- a/external/linker/cecil/Mono.Cecil/PropertyAttributes.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -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 - Unused = 0xe9ff // Reserved: shall be zero in a conforming implementation - } -} diff --git a/external/linker/cecil/Mono.Cecil/PropertyDefinition.cs b/external/linker/cecil/Mono.Cecil/PropertyDefinition.cs deleted file mode 100644 index 87f29475ef..0000000000 --- a/external/linker/cecil/Mono.Cecil/PropertyDefinition.cs +++ /dev/null @@ -1,244 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System.Text; - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public sealed class PropertyDefinition : PropertyReference, IMemberDefinition, IConstantProvider { - - bool? has_this; - ushort attributes; - - Collection custom_attributes; - - internal MethodDefinition get_method; - internal MethodDefinition set_method; - internal Collection other_methods; - - object constant = Mixin.NotResolved; - - public PropertyAttributes Attributes { - get { return (PropertyAttributes) attributes; } - set { attributes = (ushort) value; } - } - - public bool HasThis { - get { - if (has_this.HasValue) - return has_this.Value; - - if (GetMethod != null) - return get_method.HasThis; - - if (SetMethod != null) - return set_method.HasThis; - - return false; - } - set { has_this = value; } - } - - public bool HasCustomAttributes { - get { - if (custom_attributes != null) - return custom_attributes.Count > 0; - - return this.GetHasCustomAttributes (Module); - } - } - - public Collection CustomAttributes { - get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, Module)); } - } - - public MethodDefinition GetMethod { - get { - if (get_method != null) - return get_method; - - InitializeMethods (); - return get_method; - } - set { get_method = value; } - } - - public MethodDefinition SetMethod { - get { - if (set_method != null) - return set_method; - - InitializeMethods (); - return set_method; - } - set { set_method = value; } - } - - public bool HasOtherMethods { - get { - if (other_methods != null) - return other_methods.Count > 0; - - InitializeMethods (); - return !other_methods.IsNullOrEmpty (); - } - } - - public Collection OtherMethods { - get { - if (other_methods != null) - return other_methods; - - InitializeMethods (); - - if (other_methods != null) - return other_methods; - - return other_methods = new Collection (); - } - } - - public bool HasParameters { - get { - InitializeMethods (); - - if (get_method != null) - return get_method.HasParameters; - - if (set_method != null) - return set_method.HasParameters && set_method.Parameters.Count > 1; - - return false; - } - } - - public override Collection Parameters { - get { - InitializeMethods (); - - if (get_method != null) - return MirrorParameters (get_method, 0); - - if (set_method != null) - return MirrorParameters (set_method, 1); - - return new Collection (); - } - } - - static Collection MirrorParameters (MethodDefinition method, int bound) - { - var parameters = new Collection (); - 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 bool HasConstant { - get { - this.ResolveConstant (ref constant, Module); - - return constant != Mixin.NoValue; - } - set { if (!value) constant = Mixin.NoValue; } - } - - public object Constant { - get { return HasConstant ? constant : null; } - set { constant = value; } - } - - #region PropertyAttributes - - public bool IsSpecialName { - get { return attributes.GetAttributes ((ushort) PropertyAttributes.SpecialName); } - set { attributes = attributes.SetAttributes ((ushort) PropertyAttributes.SpecialName, value); } - } - - public bool IsRuntimeSpecialName { - get { return attributes.GetAttributes ((ushort) PropertyAttributes.RTSpecialName); } - set { attributes = attributes.SetAttributes ((ushort) PropertyAttributes.RTSpecialName, value); } - } - - public bool HasDefault { - get { return attributes.GetAttributes ((ushort) PropertyAttributes.HasDefault); } - set { attributes = attributes.SetAttributes ((ushort) PropertyAttributes.HasDefault, value); } - } - - #endregion - - public new TypeDefinition DeclaringType { - get { return (TypeDefinition) base.DeclaringType; } - set { base.DeclaringType = value; } - } - - 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 (); - } - } - - public PropertyDefinition (string name, PropertyAttributes attributes, TypeReference propertyType) - : base (name, propertyType) - { - this.attributes = (ushort) attributes; - this.token = new MetadataToken (TokenType.Property); - } - - void InitializeMethods () - { - var module = this.Module; - if (module == null) - return; - - lock (module.SyncRoot) { - if (get_method != null || set_method != null) - return; - - if (!module.HasImage ()) - return; - - module.Read (this, (property, reader) => reader.ReadMethods (property)); - } - } - - public override PropertyDefinition Resolve () - { - return this; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/PropertyReference.cs b/external/linker/cecil/Mono.Cecil/PropertyReference.cs deleted file mode 100644 index 2434d0f8ca..0000000000 --- a/external/linker/cecil/Mono.Cecil/PropertyReference.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public abstract class PropertyReference : MemberReference { - - TypeReference property_type; - - public TypeReference PropertyType { - get { return property_type; } - set { property_type = value; } - } - - public abstract Collection Parameters { - get; - } - - internal PropertyReference (string name, TypeReference propertyType) - : base (name) - { - Mixin.CheckType (propertyType, Mixin.Argument.propertyType); - - property_type = propertyType; - } - - protected override IMemberDefinition ResolveDefinition () - { - return this.Resolve (); - } - - public new abstract PropertyDefinition Resolve (); - } -} diff --git a/external/linker/cecil/Mono.Cecil/ReferenceType.cs b/external/linker/cecil/Mono.Cecil/ReferenceType.cs deleted file mode 100644 index 67686fbffd..0000000000 --- a/external/linker/cecil/Mono.Cecil/ReferenceType.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using MD = Mono.Cecil.Metadata; - -namespace Mono.Cecil { - - public sealed class ByReferenceType : TypeSpecification { - - public override string Name { - get { return base.Name + "&"; } - } - - public override string FullName { - get { return base.FullName + "&"; } - } - - public override bool IsValueType { - get { return false; } - set { throw new InvalidOperationException (); } - } - - public override bool IsByReference { - get { return true; } - } - - public ByReferenceType (TypeReference type) - : base (type) - { - Mixin.CheckType (type); - this.etype = MD.ElementType.ByRef; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/Resource.cs b/external/linker/cecil/Mono.Cecil/Resource.cs deleted file mode 100644 index cee75f9e49..0000000000 --- a/external/linker/cecil/Mono.Cecil/Resource.cs +++ /dev/null @@ -1,58 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil { - - public enum ResourceType { - Linked, - Embedded, - AssemblyLinked, - } - - public abstract class Resource { - - string name; - uint attributes; - - public string Name { - get { return name; } - set { name = value; } - } - - public ManifestResourceAttributes Attributes { - get { return (ManifestResourceAttributes) attributes; } - set { attributes = (uint) value; } - } - - public abstract ResourceType ResourceType { - get; - } - - #region ManifestResourceAttributes - - public bool IsPublic { - 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 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) - { - this.name = name; - this.attributes = (uint) attributes; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/SecurityDeclaration.cs b/external/linker/cecil/Mono.Cecil/SecurityDeclaration.cs deleted file mode 100644 index a18d14f25a..0000000000 --- a/external/linker/cecil/Mono.Cecil/SecurityDeclaration.cs +++ /dev/null @@ -1,179 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Diagnostics; -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - 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 interface ISecurityDeclarationProvider : IMetadataTokenProvider { - - bool HasSecurityDeclarations { get; } - Collection SecurityDeclarations { get; } - } - - [DebuggerDisplay ("{AttributeType}")] - public sealed class SecurityAttribute : ICustomAttribute { - - TypeReference attribute_type; - - internal Collection fields; - internal Collection properties; - - public TypeReference AttributeType { - get { return attribute_type; } - set { attribute_type = value; } - } - - public bool HasFields { - get { return !fields.IsNullOrEmpty (); } - } - - public Collection Fields { - get { return fields ?? (fields = new Collection ()); } - } - - public bool HasProperties { - get { return !properties.IsNullOrEmpty (); } - } - - public Collection Properties { - get { return properties ?? (properties = new Collection ()); } - } - - public SecurityAttribute (TypeReference attributeType) - { - this.attribute_type = attributeType; - } - - bool ICustomAttribute.HasConstructorArguments { - get { return false; } - } - - Collection ICustomAttribute.ConstructorArguments { - get { throw new NotSupportedException (); } - } - } - - public sealed class SecurityDeclaration { - - readonly internal uint signature; - byte [] blob; - readonly ModuleDefinition module; - - internal bool resolved; - SecurityAction action; - internal Collection security_attributes; - - public SecurityAction Action { - get { return action; } - set { action = value; } - } - - public bool HasSecurityAttributes { - get { - Resolve (); - - return !security_attributes.IsNullOrEmpty (); - } - } - - public Collection SecurityAttributes { - get { - Resolve (); - - return security_attributes ?? (security_attributes = new Collection ()); - } - } - - 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) - { - this.action = action; - this.resolved = true; - } - - public SecurityDeclaration (SecurityAction action, byte [] blob) - { - this.action = action; - this.resolved = false; - this.blob = blob; - } - - public byte [] GetBlob () - { - if (blob != null) - return blob; - - if (!HasImage || signature == 0) - throw new NotSupportedException (); - - return blob = module.Read (this, (declaration, reader) => reader.ReadSecurityDeclarationBlob (declaration.signature)); - } - - void Resolve () - { - if (resolved || !HasImage) - return; - - module.Read (this, (declaration, reader) => reader.ReadSecurityDeclarationSignature (declaration)); - resolved = true; - } - } - - static partial class Mixin { - - public static bool GetHasSecurityDeclarations ( - this ISecurityDeclarationProvider self, - ModuleDefinition module) - { - return module.HasImage () && module.Read (self, (provider, reader) => reader.HasSecurityDeclarations (provider)); - } - - public static Collection GetSecurityDeclarations ( - this ISecurityDeclarationProvider self, - ref Collection variable, - ModuleDefinition module) - { - return module.HasImage () - ? module.Read (ref variable, self, (provider, reader) => reader.ReadSecurityDeclarations (provider)) - : variable = new Collection(); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/SentinelType.cs b/external/linker/cecil/Mono.Cecil/SentinelType.cs deleted file mode 100644 index b603cc3c0b..0000000000 --- a/external/linker/cecil/Mono.Cecil/SentinelType.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using MD = Mono.Cecil.Metadata; - -namespace Mono.Cecil { - - public sealed class SentinelType : TypeSpecification { - - 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/external/linker/cecil/Mono.Cecil/TargetRuntime.cs b/external/linker/cecil/Mono.Cecil/TargetRuntime.cs deleted file mode 100644 index c1cd0269f7..0000000000 --- a/external/linker/cecil/Mono.Cecil/TargetRuntime.cs +++ /dev/null @@ -1,19 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -namespace Mono.Cecil { - - public enum TargetRuntime { - Net_1_0, - Net_1_1, - Net_2_0, - Net_4_0, - } -} diff --git a/external/linker/cecil/Mono.Cecil/Treatments.cs b/external/linker/cecil/Mono.Cecil/Treatments.cs deleted file mode 100644 index 4ceaebf7ce..0000000000 --- a/external/linker/cecil/Mono.Cecil/Treatments.cs +++ /dev/null @@ -1,66 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - [Flags] - enum TypeDefinitionTreatment { - None = 0x0, - - KindMask = 0xf, - NormalType = 0x1, - NormalAttribute = 0x2, - UnmangleWindowsRuntimeName = 0x3, - PrefixWindowsRuntimeName = 0x4, - RedirectToClrType = 0x5, - RedirectToClrAttribute = 0x6, - - Abstract = 0x10, - Internal = 0x20, - } - - enum TypeReferenceTreatment { - None = 0x0, - SystemDelegate = 0x1, - SystemAttribute = 0x2, - UseProjectionInfo = 0x3, - } - - [Flags] - enum MethodDefinitionTreatment { - None = 0x0, - Dispose = 0x1, - Abstract = 0x2, - Private = 0x4, - Public = 0x8, - Runtime = 0x10, - InternalCall = 0x20, - } - - enum FieldDefinitionTreatment { - None = 0x0, - Public = 0x1, - } - - enum MemberReferenceTreatment { - None = 0x0, - Dispose = 0x1, - } - - enum CustomAttributeValueTreatment { - None = 0x0, - AllowSingle = 0x1, - AllowMultiple = 0x2, - VersionAttribute = 0x3, - DeprecatedAttribute = 0x4, - } -} diff --git a/external/linker/cecil/Mono.Cecil/TypeAttributes.cs b/external/linker/cecil/Mono.Cecil/TypeAttributes.cs deleted file mode 100644 index 92a71aca4f..0000000000 --- a/external/linker/cecil/Mono.Cecil/TypeAttributes.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil { - - [Flags] - public enum TypeAttributes : uint { - // Visibility attributes - VisibilityMask = 0x00000007, // Use this mask to retrieve visibility information - NotPublic = 0x00000000, // Class has no public scope - Public = 0x00000001, // Class has public scope - NestedPublic = 0x00000002, // Class is nested with public visibility - NestedPrivate = 0x00000003, // Class is nested with private visibility - NestedFamily = 0x00000004, // Class is nested with family visibility - NestedAssembly = 0x00000005, // Class is nested with assembly visibility - NestedFamANDAssem = 0x00000006, // Class is nested with family and assembly visibility - NestedFamORAssem = 0x00000007, // Class is nested with family or assembly visibility - - // Class layout attributes - LayoutMask = 0x00000018, // Use this mask to retrieve class layout information - AutoLayout = 0x00000000, // Class fields are auto-laid out - SequentialLayout = 0x00000008, // Class fields are laid out sequentially - ExplicitLayout = 0x00000010, // Layout is supplied explicitly - - // Class semantics attributes - ClassSemanticMask = 0x00000020, // Use this mask to retrieve class semantics information - Class = 0x00000000, // Type is a class - Interface = 0x00000020, // Type is an interface - - // Special semantics in addition to class semantics - Abstract = 0x00000080, // Class is abstract - Sealed = 0x00000100, // Class cannot be extended - SpecialName = 0x00000400, // Class name is special - - // Implementation attributes - Import = 0x00001000, // Class/Interface is imported - Serializable = 0x00002000, // Class is serializable - WindowsRuntime = 0x00004000, // Windows Runtime type - - // String formatting attributes - StringFormatMask = 0x00030000, // Use this mask to retrieve string information for native interop - AnsiClass = 0x00000000, // LPSTR is interpreted as ANSI - UnicodeClass = 0x00010000, // LPSTR is interpreted as Unicode - AutoClass = 0x00020000, // LPSTR is interpreted automatically - - // Class initialization attributes - BeforeFieldInit = 0x00100000, // Initialize the class before first static field access - - // Additional flags - RTSpecialName = 0x00000800, // CLI provides 'special' behavior, depending upon the name of the Type - HasSecurity = 0x00040000, // Type has security associate with it - Forwarder = 0x00200000, // Exported type is a type forwarder - } -} diff --git a/external/linker/cecil/Mono.Cecil/TypeDefinition.cs b/external/linker/cecil/Mono.Cecil/TypeDefinition.cs deleted file mode 100644 index 6b6558c413..0000000000 --- a/external/linker/cecil/Mono.Cecil/TypeDefinition.cs +++ /dev/null @@ -1,609 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using Mono.Cecil.Metadata; -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public sealed class TypeDefinition : TypeReference, IMemberDefinition, ISecurityDeclarationProvider { - - uint attributes; - TypeReference base_type; - internal Range fields_range; - internal Range methods_range; - - short packing_size = Mixin.NotResolvedMarker; - int class_size = Mixin.NotResolvedMarker; - - InterfaceImplementationCollection interfaces; - Collection nested_types; - Collection methods; - Collection fields; - Collection events; - Collection properties; - Collection custom_attributes; - Collection security_declarations; - - public TypeAttributes Attributes { - get { return (TypeAttributes) attributes; } - set { - if (IsWindowsRuntimeProjection && (ushort) value != attributes) - throw new InvalidOperationException (); - - attributes = (uint) value; - } - } - - public TypeReference BaseType { - get { return base_type; } - set { base_type = value; } - } - - public override string Name { - get { return base.Name; } - set { - if (IsWindowsRuntimeProjection && value != base.Name) - throw new InvalidOperationException (); - - base.Name = 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 { - 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; - - return HasImage && Module.Read (this, (type, reader) => reader.HasInterfaces (type)); - } - } - - public Collection Interfaces { - get { - if (interfaces != null) - return interfaces; - - if (HasImage) - return Module.Read (ref interfaces, this, (type, reader) => reader.ReadInterfaces (type)); - - return interfaces = new InterfaceImplementationCollection (this); - } - } - - public bool HasNestedTypes { - get { - if (nested_types != null) - return nested_types.Count > 0; - - return HasImage && Module.Read (this, (type, reader) => reader.HasNestedTypes (type)); - } - } - - public Collection NestedTypes { - get { - if (nested_types != null) - return nested_types; - - if (HasImage) - return Module.Read (ref nested_types, this, (type, reader) => reader.ReadNestedTypes (type)); - - return nested_types = new MemberDefinitionCollection (this); - } - } - - public bool HasMethods { - get { - if (methods != null) - return methods.Count > 0; - - return HasImage && methods_range.Length > 0; - } - } - - public Collection Methods { - get { - if (methods != null) - return methods; - - if (HasImage) - return Module.Read (ref methods, this, (type, reader) => reader.ReadMethods (type)); - - return methods = new MemberDefinitionCollection (this); - } - } - - public bool HasFields { - get { - if (fields != null) - return fields.Count > 0; - - return HasImage && fields_range.Length > 0; - } - } - - public Collection Fields { - get { - if (fields != null) - return fields; - - if (HasImage) - return Module.Read (ref fields, this, (type, reader) => reader.ReadFields (type)); - - return fields = new MemberDefinitionCollection (this); - } - } - - public bool HasEvents { - get { - if (events != null) - return events.Count > 0; - - return HasImage && Module.Read (this, (type, reader) => reader.HasEvents (type)); - } - } - - public Collection Events { - get { - if (events != null) - return events; - - if (HasImage) - return Module.Read (ref events, this, (type, reader) => reader.ReadEvents (type)); - - return events = new MemberDefinitionCollection (this); - } - } - - public bool HasProperties { - get { - if (properties != null) - return properties.Count > 0; - - return HasImage && Module.Read (this, (type, reader) => reader.HasProperties (type)); - } - } - - public Collection Properties { - get { - if (properties != null) - return properties; - - if (HasImage) - return Module.Read (ref properties, this, (type, reader) => reader.ReadProperties (type)); - - return properties = new MemberDefinitionCollection (this); - } - } - - public bool HasSecurityDeclarations { - get { - if (security_declarations != null) - return security_declarations.Count > 0; - - return this.GetHasSecurityDeclarations (Module); - } - } - - public Collection SecurityDeclarations { - get { return security_declarations ?? (this.GetSecurityDeclarations (ref security_declarations, Module)); } - } - - public bool HasCustomAttributes { - get { - if (custom_attributes != null) - return custom_attributes.Count > 0; - - return this.GetHasCustomAttributes (Module); - } - } - - public Collection CustomAttributes { - get { return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, Module)); } - } - - public override bool HasGenericParameters { - get { - if (generic_parameters != null) - return generic_parameters.Count > 0; - - return this.GetHasGenericParameters (Module); - } - } - - public override Collection GenericParameters { - get { return generic_parameters ?? (this.GetGenericParameters (ref generic_parameters, Module)); } - } - - #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 IsWindowsRuntime { - get { return attributes.GetAttributes ((uint) TypeAttributes.WindowsRuntime); } - set { attributes = attributes.SetAttributes ((uint) TypeAttributes.WindowsRuntime, 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 IsEnum { - get { return base_type != null && base_type.IsTypeOf ("System", "Enum"); } - } - - public override bool IsValueType { - get { - if (base_type == null) - return false; - - return base_type.IsTypeOf ("System", "Enum") || (base_type.IsTypeOf ("System", "ValueType") && !this.IsTypeOf ("System", "Enum")); - } - set { - throw new NotSupportedException (); - } - } - - public override bool IsPrimitive { - get { - ElementType primitive_etype; - return MetadataSystem.TryGetPrimitiveElementType (this, out primitive_etype) && primitive_etype.IsPrimitive (); - } - } - - public override MetadataType MetadataType { - get { - ElementType primitive_etype; - if (MetadataSystem.TryGetPrimitiveElementType (this, out primitive_etype)) - return (MetadataType) primitive_etype; - - return base.MetadataType; - } - } - - public override bool IsDefinition { - get { return true; } - } - - public new TypeDefinition DeclaringType { - get { return (TypeDefinition) base.DeclaringType; } - set { base.DeclaringType = value; } - } - - internal new TypeDefinitionProjection WindowsRuntimeProjection { - get { return (TypeDefinitionProjection) projection; } - set { projection = value; } - } - - public TypeDefinition (string @namespace, string name, TypeAttributes attributes) - : base (@namespace, name) - { - this.attributes = (uint) attributes; - this.token = new MetadataToken (TokenType.TypeDef); - } - - public TypeDefinition (string @namespace, string name, TypeAttributes attributes, TypeReference baseType) : - this (@namespace, name, attributes) - { - this.BaseType = baseType; - } - - protected override void ClearFullName () - { - base.ClearFullName (); - - if (!HasNestedTypes) - return; - - var nested_types = this.NestedTypes; - - for (int i = 0; i < nested_types.Count; i++) - nested_types [i].ClearFullName (); - } - - public override TypeDefinition Resolve () - { - return this; - } - } - - public sealed class InterfaceImplementation : ICustomAttributeProvider - { - internal TypeDefinition type; - internal MetadataToken token; - - TypeReference interface_type; - Collection custom_attributes; - - public TypeReference InterfaceType { - get { return interface_type; } - set { interface_type = value; } - } - - public bool HasCustomAttributes { - get { - if (custom_attributes != null) - return custom_attributes.Count > 0; - - if (type == null) - return false; - - return this.GetHasCustomAttributes (type.Module); - } - } - - public Collection CustomAttributes { - get { - if (type == null) - return custom_attributes = new Collection (); - - return custom_attributes ?? (this.GetCustomAttributes (ref custom_attributes, type.Module)); - } - } - - public MetadataToken MetadataToken { - get { return token; } - set { token = value; } - } - - internal InterfaceImplementation (TypeReference interfaceType, MetadataToken token) - { - this.interface_type = interfaceType; - this.token = token; - } - - public InterfaceImplementation (TypeReference interfaceType) - { - Mixin.CheckType (interfaceType, Mixin.Argument.interfaceType); - - this.interface_type = interfaceType; - this.token = new MetadataToken (TokenType.InterfaceImpl); - } - } - - class InterfaceImplementationCollection : Collection - { - readonly TypeDefinition type; - - internal InterfaceImplementationCollection (TypeDefinition type) - { - this.type = type; - } - - internal InterfaceImplementationCollection (TypeDefinition type, int length) - : base (length) - { - this.type = type; - } - - protected override void OnAdd (InterfaceImplementation item, int index) - { - item.type = type; - } - - protected override void OnInsert (InterfaceImplementation item, int index) - { - item.type = type; - } - - protected override void OnSet (InterfaceImplementation item, int index) - { - item.type = type; - } - - protected override void OnRemove (InterfaceImplementation item, int index) - { - item.type = null; - } - } - - static partial class Mixin { - - public static TypeReference GetEnumUnderlyingType (this TypeDefinition self) - { - var fields = self.Fields; - - for (int i = 0; i < fields.Count; i++) { - var field = fields [i]; - if (!field.IsStatic) - return field.FieldType; - } - - throw new ArgumentException (); - } - - public static TypeDefinition GetNestedType (this TypeDefinition self, string fullname) - { - if (!self.HasNestedTypes) - return null; - - var nested_types = self.NestedTypes; - - for (int i = 0; i < nested_types.Count; i++) { - var nested_type = nested_types [i]; - - if (nested_type.TypeFullName () == fullname) - return nested_type; - } - - return null; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/TypeDefinitionCollection.cs b/external/linker/cecil/Mono.Cecil/TypeDefinitionCollection.cs deleted file mode 100644 index 95e39b9a6e..0000000000 --- a/external/linker/cecil/Mono.Cecil/TypeDefinitionCollection.cs +++ /dev/null @@ -1,100 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; - -using Mono.Cecil.Metadata; - -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - using Slot = Row; - - sealed class TypeDefinitionCollection : Collection { - - readonly ModuleDefinition container; - readonly Dictionary name_cache; - - internal TypeDefinitionCollection (ModuleDefinition container) - { - this.container = container; - this.name_cache = new Dictionary (new RowEqualityComparer ()); - } - - internal TypeDefinitionCollection (ModuleDefinition container, int capacity) - : base (capacity) - { - this.container = container; - this.name_cache = new Dictionary (capacity, new RowEqualityComparer ()); - } - - protected override void OnAdd (TypeDefinition item, int index) - { - Attach (item); - } - - protected override void OnSet (TypeDefinition item, int index) - { - Attach (item); - } - - protected override void OnInsert (TypeDefinition item, int index) - { - Attach (item); - } - - protected override void OnRemove (TypeDefinition item, int index) - { - Detach (item); - } - - protected override void OnClear () - { - foreach (var type in this) - Detach (type); - } - - void Attach (TypeDefinition type) - { - if (type.Module != null && type.Module != container) - throw new ArgumentException ("Type already attached"); - - type.module = container; - type.scope = container; - name_cache [new Slot (type.Namespace, type.Name)] = type; - } - - void Detach (TypeDefinition type) - { - type.module = null; - type.scope = null; - name_cache.Remove (new Slot (type.Namespace, type.Name)); - } - - public TypeDefinition GetType (string fullname) - { - string @namespace, name; - TypeParser.SplitFullName (fullname, out @namespace, out name); - - return GetType (@namespace, name); - } - - public TypeDefinition GetType (string @namespace, string name) - { - TypeDefinition type; - if (name_cache.TryGetValue (new Slot (@namespace, name), out type)) - return type; - - return null; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/TypeParser.cs b/external/linker/cecil/Mono.Cecil/TypeParser.cs deleted file mode 100644 index 02f3036f37..0000000000 --- a/external/linker/cecil/Mono.Cecil/TypeParser.cs +++ /dev/null @@ -1,528 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -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) - { - return int.TryParse (value, out result); - } - - static void TryAddArity (string name, ref int arity) - { - int type_arity; - if (!TryGetArity (name, out type_arity)) - return; - - arity += type_arity; - } - - string ParsePart () - { - var part = new StringBuilder (); - while (position < length && !IsDelimiter (fullname [position])) { - if (fullname [position] == '\\') - position++; - - part.Append (fullname [position++]); - } - - return part.ToString (); - } - - 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 (ref T [] array, T item) - { - array = array.Add (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 (string.IsNullOrEmpty (fullname)) - 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, module, scope); - MetadataSystem.TryProcessPrimitiveTypeReference (type); - - 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], module, null) { - DeclaringType = type, - }; - - 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.CoreLibrary; - - AssemblyNameReference match; - var reference = AssemblyNameReference.Parse (type_info.assembly); - - return module.TryGetAssemblyNameReference (reference, out match) - ? match - : reference; - } - - 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++) { - var nested_type = typedef.GetNestedType (nested_names [i]); - if (nested_type == null) - return false; - - typedef = nested_type; - } - } - - 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 AppendNamePart (string part, StringBuilder name) - { - foreach (var c in part) { - if (IsDelimiter (c)) - name.Append ('\\'); - - name.Append (c); - } - } - - static void AppendType (TypeReference type, StringBuilder name, bool fq_name, bool top_level) - { - var element_type = type.GetElementType (); - - var declaring_type = element_type.DeclaringType; - if (declaring_type != null) { - AppendType (declaring_type, name, false, top_level); - name.Append ('+'); - } - - var @namespace = type.Namespace; - if (!string.IsNullOrEmpty (@namespace)) { - AppendNamePart (@namespace, name); - name.Append ('.'); - } - - AppendNamePart (element_type.Name, 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/external/linker/cecil/Mono.Cecil/TypeReference.cs b/external/linker/cecil/Mono.Cecil/TypeReference.cs deleted file mode 100644 index c2643b6710..0000000000 --- a/external/linker/cecil/Mono.Cecil/TypeReference.cs +++ /dev/null @@ -1,352 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using Mono.Cecil.Metadata; -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - public enum MetadataType : byte { - Void = ElementType.Void, - Boolean = ElementType.Boolean, - Char = ElementType.Char, - SByte = ElementType.I1, - Byte = ElementType.U1, - Int16 = ElementType.I2, - UInt16 = ElementType.U2, - Int32 = ElementType.I4, - UInt32 = ElementType.U4, - Int64 = ElementType.I8, - UInt64 = ElementType.U8, - Single = ElementType.R4, - Double = ElementType.R8, - String = ElementType.String, - Pointer = ElementType.Ptr, - ByReference = ElementType.ByRef, - ValueType = ElementType.ValueType, - Class = ElementType.Class, - Var = ElementType.Var, - Array = ElementType.Array, - GenericInstance = ElementType.GenericInst, - TypedByReference = ElementType.TypedByRef, - IntPtr = ElementType.I, - UIntPtr = ElementType.U, - FunctionPointer = ElementType.FnPtr, - Object = ElementType.Object, - MVar = ElementType.MVar, - RequiredModifier = ElementType.CModReqD, - OptionalModifier = ElementType.CModOpt, - Sentinel = ElementType.Sentinel, - Pinned = ElementType.Pinned, - } - - public class TypeReference : MemberReference, IGenericParameterProvider, IGenericContext { - - string @namespace; - bool value_type; - internal IMetadataScope scope; - internal ModuleDefinition module; - - internal ElementType etype = ElementType.None; - - string fullname; - - protected Collection generic_parameters; - - public override string Name { - get { return base.Name; } - set { - if (IsWindowsRuntimeProjection && value != base.Name) - throw new InvalidOperationException ("Projected type reference name can't be changed."); - base.Name = value; - ClearFullName (); - } - } - - public virtual string Namespace { - get { return @namespace; } - set { - if (IsWindowsRuntimeProjection && value != @namespace) - throw new InvalidOperationException ("Projected type reference namespace can't be changed."); - @namespace = value; - ClearFullName (); - } - } - - public virtual bool IsValueType { - get { return value_type; } - set { value_type = value; } - } - - public override ModuleDefinition Module { - get { - if (module != null) - return module; - - var declaring_type = this.DeclaringType; - if (declaring_type != null) - return declaring_type.Module; - - return null; - } - } - - internal new TypeReferenceProjection WindowsRuntimeProjection { - get { return (TypeReferenceProjection) projection; } - set { projection = value; } - } - - 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 GenericParameters { - get { - if (generic_parameters != null) - return generic_parameters; - - return generic_parameters = new GenericParameterCollection (this); - } - } - - public virtual IMetadataScope Scope { - get { - var declaring_type = this.DeclaringType; - if (declaring_type != null) - return declaring_type.Scope; - - return scope; - } - set { - var declaring_type = this.DeclaringType; - if (declaring_type != null) { - if (IsWindowsRuntimeProjection && value != declaring_type.Scope) - throw new InvalidOperationException ("Projected type scope can't be changed."); - declaring_type.Scope = value; - return; - } - - if (IsWindowsRuntimeProjection && value != scope) - throw new InvalidOperationException ("Projected type scope can't be changed."); - scope = value; - } - } - - public bool IsNested { - get { return this.DeclaringType != null; } - } - - public override TypeReference DeclaringType { - get { return base.DeclaringType; } - set { - if (IsWindowsRuntimeProjection && value != base.DeclaringType) - throw new InvalidOperationException ("Projected type declaring type can't be changed."); - base.DeclaringType = value; - ClearFullName (); - } - } - - public override string FullName { - get { - if (fullname != null) - return fullname; - - fullname = this.TypeFullName (); - - if (IsNested) - fullname = DeclaringType.FullName + "/" + fullname; - - return fullname; - } - } - - 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 virtual bool IsPrimitive { - get { return etype.IsPrimitive (); } - } - - 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) - { - this.@namespace = @namespace ?? string.Empty; - this.token = new MetadataToken (TokenType.TypeRef, 0); - } - - public TypeReference (string @namespace, string name, ModuleDefinition module, IMetadataScope scope) - : this (@namespace, name) - { - this.module = module; - this.scope = scope; - } - - public TypeReference (string @namespace, string name, ModuleDefinition module, IMetadataScope scope, bool valueType) : - this (@namespace, name, module, scope) - { - value_type = valueType; - } - - protected virtual void ClearFullName () - { - this.fullname = null; - } - - public virtual TypeReference GetElementType () - { - return this; - } - - protected override IMemberDefinition ResolveDefinition () - { - return this.Resolve (); - } - - public new virtual TypeDefinition Resolve () - { - var module = this.Module; - if (module == null) - throw new NotSupportedException (); - - return module.Resolve (this); - } - } - - static partial class Mixin { - - public static bool IsPrimitive (this ElementType self) - { - switch (self) { - 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 static string TypeFullName (this TypeReference self) - { - return string.IsNullOrEmpty (self.Namespace) - ? self.Name - : self.Namespace + '.' + self.Name; - } - - public static bool IsTypeOf (this TypeReference self, string @namespace, string name) - { - return self.Name == name - && self.Namespace == @namespace; - } - - public static bool IsTypeSpecification (this TypeReference type) - { - 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.Sentinel: - case ElementType.Var: - return true; - } - - return false; - } - - public static TypeDefinition CheckedResolve (this TypeReference self) - { - var type = self.Resolve (); - if (type == null) - throw new ResolutionException (self); - - return type; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/TypeSpecification.cs b/external/linker/cecil/Mono.Cecil/TypeSpecification.cs deleted file mode 100644 index 16e0cab813..0000000000 --- a/external/linker/cecil/Mono.Cecil/TypeSpecification.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using Mono.Cecil.Metadata; - -namespace Mono.Cecil { - - public abstract class TypeSpecification : TypeReference { - - readonly TypeReference element_type; - - public TypeReference ElementType { - get { return element_type; } - } - - public override string Name { - get { return element_type.Name; } - set { throw new InvalidOperationException (); } - } - - public override string Namespace { - get { return element_type.Namespace; } - set { throw new InvalidOperationException (); } - } - - public override IMetadataScope Scope { - get { return element_type.Scope; } - set { throw new InvalidOperationException (); } - } - - public override ModuleDefinition Module { - get { return element_type.Module; } - } - - public override string FullName { - get { return element_type.FullName; } - } - - public override bool ContainsGenericParameter { - get { return element_type.ContainsGenericParameter; } - } - - public override MetadataType MetadataType { - get { return (MetadataType) etype; } - } - - internal TypeSpecification (TypeReference type) - : base (null, null) - { - this.element_type = type; - this.token = new MetadataToken (TokenType.TypeSpec); - } - - public override TypeReference GetElementType () - { - return element_type.GetElementType (); - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/TypeSystem.cs b/external/linker/cecil/Mono.Cecil/TypeSystem.cs deleted file mode 100644 index e16ec6f3b6..0000000000 --- a/external/linker/cecil/Mono.Cecil/TypeSystem.cs +++ /dev/null @@ -1,331 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using Mono.Cecil.Metadata; - -namespace Mono.Cecil { - - public abstract class TypeSystem { - - sealed class CoreTypeSystem : TypeSystem { - - public CoreTypeSystem (ModuleDefinition module) - : base (module) - { - } - - internal override TypeReference LookupType (string @namespace, string name) - { - var type = LookupTypeDefinition (@namespace, name) ?? LookupTypeForwarded (@namespace, name); - if (type != null) - return type; - - throw new NotSupportedException (); - } - - TypeReference LookupTypeDefinition (string @namespace, string name) - { - var metadata = module.MetadataSystem; - if (metadata.Types == null) - Initialize (module.Types); - - return module.Read (new Row (@namespace, name), (row, reader) => { - var types = reader.metadata.Types; - - for (int i = 0; i < types.Length; i++) { - if (types [i] == null) - types [i] = reader.GetTypeDefinition ((uint) i + 1); - - var type = types [i]; - - if (type.Name == row.Col2 && type.Namespace == row.Col1) - return type; - } - - return null; - }); - } - - TypeReference LookupTypeForwarded (string @namespace, string name) - { - if (!module.HasExportedTypes) - return null; - - var exported_types = module.ExportedTypes; - for (int i = 0; i < exported_types.Count; i++) { - var exported_type = exported_types [i]; - - if (exported_type.Name == name && exported_type.Namespace == @namespace) - return exported_type.CreateReference (); - } - - return null; - } - - static void Initialize (object obj) - { - } - } - - sealed class CommonTypeSystem : TypeSystem { - - AssemblyNameReference core_library; - - public CommonTypeSystem (ModuleDefinition module) - : base (module) - { - } - - internal override TypeReference LookupType (string @namespace, string name) - { - return CreateTypeReference (@namespace, name); - } - - public AssemblyNameReference GetCoreLibraryReference () - { - if (core_library != null) - return core_library; - - if (module.TryGetCoreLibraryReference (out core_library)) - return core_library; - - core_library = new AssemblyNameReference { - Name = Mixin.mscorlib, - Version = GetCorlibVersion (), - PublicKeyToken = new byte [] { 0xb7, 0x7a, 0x5c, 0x56, 0x19, 0x34, 0xe0, 0x89 }, - }; - - module.AssemblyReferences.Add (core_library); - - return core_library; - } - - 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) - { - return new TypeReference (@namespace, name, module, GetCoreLibraryReference ()); - } - } - - 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 (module.IsCoreLibrary ()) - return new CoreTypeSystem (module); - - return new CommonTypeSystem (module); - } - - internal abstract TypeReference LookupType (string @namespace, string name); - - TypeReference LookupSystemType (ref TypeReference reference, string name, ElementType element_type) - { - lock (module.SyncRoot) { - if (reference != null) - return reference; - var type = LookupType ("System", name); - type.etype = element_type; - return reference = type; - } - } - - TypeReference LookupSystemValueType (ref TypeReference typeRef, string name, ElementType element_type) - { - lock (module.SyncRoot) { - if (typeRef != null) - return typeRef; - var type = LookupType ("System", name); - type.etype = element_type; - type.KnownValueType (); - return typeRef = type; - } - } - - [Obsolete ("Use CoreLibrary")] - public IMetadataScope Corlib { - get { return CoreLibrary; } - } - - public IMetadataScope CoreLibrary { - get { - var common = this as CommonTypeSystem; - if (common == null) - return module; - - return common.GetCoreLibraryReference (); - } - } - - public TypeReference Object { - get { return type_object ?? (LookupSystemType (ref type_object, "Object", ElementType.Object)); } - } - - public TypeReference Void { - get { return type_void ?? (LookupSystemType (ref type_void, "Void", ElementType.Void)); } - } - - public TypeReference Boolean { - get { return type_bool ?? (LookupSystemValueType (ref type_bool, "Boolean", ElementType.Boolean)); } - } - - public TypeReference Char { - get { return type_char ?? (LookupSystemValueType (ref type_char, "Char", ElementType.Char)); } - } - - public TypeReference SByte { - get { return type_sbyte ?? (LookupSystemValueType (ref type_sbyte, "SByte", ElementType.I1)); } - } - - public TypeReference Byte { - get { return type_byte ?? (LookupSystemValueType (ref type_byte, "Byte", ElementType.U1)); } - } - - public TypeReference Int16 { - get { return type_int16 ?? (LookupSystemValueType (ref type_int16, "Int16", ElementType.I2)); } - } - - public TypeReference UInt16 { - get { return type_uint16 ?? (LookupSystemValueType (ref type_uint16, "UInt16", ElementType.U2)); } - } - - public TypeReference Int32 { - get { return type_int32 ?? (LookupSystemValueType (ref type_int32, "Int32", ElementType.I4)); } - } - - public TypeReference UInt32 { - get { return type_uint32 ?? (LookupSystemValueType (ref type_uint32, "UInt32", ElementType.U4)); } - } - - public TypeReference Int64 { - get { return type_int64 ?? (LookupSystemValueType (ref type_int64, "Int64", ElementType.I8)); } - } - - public TypeReference UInt64 { - get { return type_uint64 ?? (LookupSystemValueType (ref type_uint64, "UInt64", ElementType.U8)); } - } - - public TypeReference Single { - get { return type_single ?? (LookupSystemValueType (ref type_single, "Single", ElementType.R4)); } - } - - public TypeReference Double { - get { return type_double ?? (LookupSystemValueType (ref type_double, "Double", ElementType.R8)); } - } - - public TypeReference IntPtr { - get { return type_intptr ?? (LookupSystemValueType (ref type_intptr, "IntPtr", ElementType.I)); } - } - - public TypeReference UIntPtr { - get { return type_uintptr ?? (LookupSystemValueType (ref type_uintptr, "UIntPtr", ElementType.U)); } - } - - public TypeReference String { - get { return type_string ?? (LookupSystemType (ref type_string, "String", ElementType.String)); } - } - - public TypeReference TypedReference { - get { return type_typedref ?? (LookupSystemValueType (ref type_typedref, "TypedReference", ElementType.TypedByRef)); } - } - } - - static partial class Mixin { - - public const string mscorlib = "mscorlib"; - public const string system_runtime = "System.Runtime"; - public const string system_private_corelib = "System.Private.CoreLib"; - public const string netstandard = "netstandard"; - - public static bool TryGetCoreLibraryReference (this ModuleDefinition module, out AssemblyNameReference reference) - { - var references = module.AssemblyReferences; - - for (int i = 0; i < references.Count; i++) { - reference = references [i]; - if (IsCoreLibrary (reference)) - return true; - } - - reference = null; - return false; - - } - - public static bool IsCoreLibrary (this ModuleDefinition module) - { - if (module.Assembly == null) - return false; - - if (!IsCoreLibrary (module.Assembly.Name)) - return false; - - if (module.HasImage && module.Read (module, (m, reader) => reader.image.GetTableLength (Table.AssemblyRef) > 0)) - return false; - - return true; - } - - public static void KnownValueType (this TypeReference type) - { - if (!type.IsDefinition) - type.IsValueType = true; - } - - static bool IsCoreLibrary (AssemblyNameReference reference) - { - var name = reference.Name; - return name == mscorlib - || name == system_runtime - || name == system_private_corelib - || name == netstandard; - } - } -} diff --git a/external/linker/cecil/Mono.Cecil/VariantType.cs b/external/linker/cecil/Mono.Cecil/VariantType.cs deleted file mode 100644 index 81aa7fa4a3..0000000000 --- a/external/linker/cecil/Mono.Cecil/VariantType.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -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, - I1 = 16, - UI1 = 17, - UI2 = 18, - UI4 = 19, - Int = 22, - UInt = 23 - } -} diff --git a/external/linker/cecil/Mono.Cecil/WindowsRuntimeProjections.cs b/external/linker/cecil/Mono.Cecil/WindowsRuntimeProjections.cs deleted file mode 100644 index 04ba8c609b..0000000000 --- a/external/linker/cecil/Mono.Cecil/WindowsRuntimeProjections.cs +++ /dev/null @@ -1,875 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.Threading; -using Mono.Collections.Generic; - -namespace Mono.Cecil { - - sealed class MemberReferenceProjection { - - public readonly string Name; - public readonly MemberReferenceTreatment Treatment; - - public MemberReferenceProjection (MemberReference member, MemberReferenceTreatment treatment) - { - Name = member.Name; - Treatment = treatment; - } - } - - sealed class TypeDefinitionProjection { - - public readonly TypeAttributes Attributes; - public readonly string Name; - public readonly TypeDefinitionTreatment Treatment; - - public TypeDefinitionProjection (TypeDefinition type, TypeDefinitionTreatment treatment) - { - Attributes = type.Attributes; - Name = type.Name; - Treatment = treatment; - } - } - - sealed class TypeReferenceProjection { - - public readonly string Name; - public readonly string Namespace; - public readonly IMetadataScope Scope; - public readonly TypeReferenceTreatment Treatment; - - public TypeReferenceProjection (TypeReference type, TypeReferenceTreatment treatment) - { - Name = type.Name; - Namespace = type.Namespace; - Scope = type.Scope; - Treatment = treatment; - } - } - - sealed class MethodDefinitionProjection { - - public readonly MethodAttributes Attributes; - public readonly MethodImplAttributes ImplAttributes; - public readonly string Name; - public readonly MethodDefinitionTreatment Treatment; - - public MethodDefinitionProjection (MethodDefinition method, MethodDefinitionTreatment treatment) - { - Attributes = method.Attributes; - ImplAttributes = method.ImplAttributes; - Name = method.Name; - Treatment = treatment; - } - } - - sealed class FieldDefinitionProjection { - - public readonly FieldAttributes Attributes; - public readonly FieldDefinitionTreatment Treatment; - - public FieldDefinitionProjection (FieldDefinition field, FieldDefinitionTreatment treatment) - { - Attributes = field.Attributes; - Treatment = treatment; - } - } - - sealed class CustomAttributeValueProjection { - - public readonly AttributeTargets Targets; - public readonly CustomAttributeValueTreatment Treatment; - - public CustomAttributeValueProjection (AttributeTargets targets, CustomAttributeValueTreatment treatment) - { - Targets = targets; - Treatment = treatment; - } - } - - sealed class WindowsRuntimeProjections { - - struct ProjectionInfo { - - public readonly string WinRTNamespace; - public readonly string ClrNamespace; - public readonly string ClrName; - public readonly string ClrAssembly; - public readonly bool Attribute; - public readonly bool Disposable; - - public ProjectionInfo (string winrt_namespace, string clr_namespace, string clr_name, string clr_assembly, bool attribute = false, bool disposable = false) - { - WinRTNamespace = winrt_namespace; - ClrNamespace = clr_namespace; - ClrName = clr_name; - ClrAssembly = clr_assembly; - Attribute = attribute; - Disposable = disposable; - } - } - - static readonly Version version = new Version (4, 0, 0, 0); - - static readonly byte[] contract_pk_token = { - 0xB0, 0x3F, 0x5F, 0x7F, 0x11, 0xD5, 0x0A, 0x3A - }; - - static readonly byte[] contract_pk = { - 0x00, 0x24, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x06, 0x02, 0x00, 0x00, - 0x00, 0x24, 0x00, 0x00, 0x52, 0x53, 0x41, 0x31, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, - 0x07, 0xD1, 0xFA, 0x57, 0xC4, 0xAE, 0xD9, 0xF0, 0xA3, 0x2E, 0x84, 0xAA, 0x0F, 0xAE, 0xFD, 0x0D, - 0xE9, 0xE8, 0xFD, 0x6A, 0xEC, 0x8F, 0x87, 0xFB, 0x03, 0x76, 0x6C, 0x83, 0x4C, 0x99, 0x92, 0x1E, - 0xB2, 0x3B, 0xE7, 0x9A, 0xD9, 0xD5, 0xDC, 0xC1, 0xDD, 0x9A, 0xD2, 0x36, 0x13, 0x21, 0x02, 0x90, - 0x0B, 0x72, 0x3C, 0xF9, 0x80, 0x95, 0x7F, 0xC4, 0xE1, 0x77, 0x10, 0x8F, 0xC6, 0x07, 0x77, 0x4F, - 0x29, 0xE8, 0x32, 0x0E, 0x92, 0xEA, 0x05, 0xEC, 0xE4, 0xE8, 0x21, 0xC0, 0xA5, 0xEF, 0xE8, 0xF1, - 0x64, 0x5C, 0x4C, 0x0C, 0x93, 0xC1, 0xAB, 0x99, 0x28, 0x5D, 0x62, 0x2C, 0xAA, 0x65, 0x2C, 0x1D, - 0xFA, 0xD6, 0x3D, 0x74, 0x5D, 0x6F, 0x2D, 0xE5, 0xF1, 0x7E, 0x5E, 0xAF, 0x0F, 0xC4, 0x96, 0x3D, - 0x26, 0x1C, 0x8A, 0x12, 0x43, 0x65, 0x18, 0x20, 0x6D, 0xC0, 0x93, 0x34, 0x4D, 0x5A, 0xD2, 0x93 - }; - - static Dictionary projections; - - static Dictionary Projections - { - get { - if (projections != null) - return projections; - - return projections = new Dictionary { - { "AttributeTargets", new ProjectionInfo ("Windows.Foundation.Metadata", "System", "AttributeTargets", "System.Runtime") }, - { "AttributeUsageAttribute", new ProjectionInfo ("Windows.Foundation.Metadata", "System", "AttributeUsageAttribute", "System.Runtime", attribute: true) }, - { "Color", new ProjectionInfo ("Windows.UI", "Windows.UI", "Color", "System.Runtime.WindowsRuntime") }, - { "CornerRadius", new ProjectionInfo ("Windows.UI.Xaml", "Windows.UI.Xaml", "CornerRadius", "System.Runtime.WindowsRuntime.UI.Xaml") }, - { "DateTime", new ProjectionInfo ("Windows.Foundation", "System", "DateTimeOffset", "System.Runtime") }, - { "Duration", new ProjectionInfo ("Windows.UI.Xaml", "Windows.UI.Xaml", "Duration", "System.Runtime.WindowsRuntime.UI.Xaml") }, - { "DurationType", new ProjectionInfo ("Windows.UI.Xaml", "Windows.UI.Xaml", "DurationType", "System.Runtime.WindowsRuntime.UI.Xaml") }, - { "EventHandler`1", new ProjectionInfo ("Windows.Foundation", "System", "EventHandler`1", "System.Runtime") }, - { "EventRegistrationToken", new ProjectionInfo ("Windows.Foundation", "System.Runtime.InteropServices.WindowsRuntime", "EventRegistrationToken", "System.Runtime.InteropServices.WindowsRuntime") }, - { "GeneratorPosition", new ProjectionInfo ("Windows.UI.Xaml.Controls.Primitives", "Windows.UI.Xaml.Controls.Primitives", "GeneratorPosition", "System.Runtime.WindowsRuntime.UI.Xaml") }, - { "GridLength", new ProjectionInfo ("Windows.UI.Xaml", "Windows.UI.Xaml", "GridLength", "System.Runtime.WindowsRuntime.UI.Xaml") }, - { "GridUnitType", new ProjectionInfo ("Windows.UI.Xaml", "Windows.UI.Xaml", "GridUnitType", "System.Runtime.WindowsRuntime.UI.Xaml") }, - { "HResult", new ProjectionInfo ("Windows.Foundation", "System", "Exception", "System.Runtime") }, - { "IBindableIterable", new ProjectionInfo ("Windows.UI.Xaml.Interop", "System.Collections", "IEnumerable", "System.Runtime") }, - { "IBindableVector", new ProjectionInfo ("Windows.UI.Xaml.Interop", "System.Collections", "IList", "System.Runtime") }, - { "IClosable", new ProjectionInfo ("Windows.Foundation", "System", "IDisposable", "System.Runtime", disposable: true) }, - { "ICommand", new ProjectionInfo ("Windows.UI.Xaml.Input", "System.Windows.Input", "ICommand", "System.ObjectModel") }, - { "IIterable`1", new ProjectionInfo ("Windows.Foundation.Collections", "System.Collections.Generic", "IEnumerable`1", "System.Runtime") }, - { "IKeyValuePair`2", new ProjectionInfo ("Windows.Foundation.Collections", "System.Collections.Generic", "KeyValuePair`2", "System.Runtime") }, - { "IMapView`2", new ProjectionInfo ("Windows.Foundation.Collections", "System.Collections.Generic", "IReadOnlyDictionary`2", "System.Runtime") }, - { "IMap`2", new ProjectionInfo ("Windows.Foundation.Collections", "System.Collections.Generic", "IDictionary`2", "System.Runtime") }, - { "INotifyCollectionChanged", new ProjectionInfo ("Windows.UI.Xaml.Interop", "System.Collections.Specialized", "INotifyCollectionChanged", "System.ObjectModel") }, - { "INotifyPropertyChanged", new ProjectionInfo ("Windows.UI.Xaml.Data", "System.ComponentModel", "INotifyPropertyChanged", "System.ObjectModel") }, - { "IReference`1", new ProjectionInfo ("Windows.Foundation", "System", "Nullable`1", "System.Runtime") }, - { "IVectorView`1", new ProjectionInfo ("Windows.Foundation.Collections", "System.Collections.Generic", "IReadOnlyList`1", "System.Runtime") }, - { "IVector`1", new ProjectionInfo ("Windows.Foundation.Collections", "System.Collections.Generic", "IList`1", "System.Runtime") }, - { "KeyTime", new ProjectionInfo ("Windows.UI.Xaml.Media.Animation", "Windows.UI.Xaml.Media.Animation", "KeyTime", "System.Runtime.WindowsRuntime.UI.Xaml") }, - { "Matrix", new ProjectionInfo ("Windows.UI.Xaml.Media", "Windows.UI.Xaml.Media", "Matrix", "System.Runtime.WindowsRuntime.UI.Xaml") }, - { "Matrix3D", new ProjectionInfo ("Windows.UI.Xaml.Media.Media3D", "Windows.UI.Xaml.Media.Media3D", "Matrix3D", "System.Runtime.WindowsRuntime.UI.Xaml") }, - { "Matrix3x2", new ProjectionInfo ("Windows.Foundation.Numerics", "System.Numerics", "Matrix3x2", "System.Numerics.Vectors") }, - { "Matrix4x4", new ProjectionInfo ("Windows.Foundation.Numerics", "System.Numerics", "Matrix4x4", "System.Numerics.Vectors") }, - { "NotifyCollectionChangedAction", new ProjectionInfo ("Windows.UI.Xaml.Interop", "System.Collections.Specialized", "NotifyCollectionChangedAction", "System.ObjectModel") }, - { "NotifyCollectionChangedEventArgs", new ProjectionInfo ("Windows.UI.Xaml.Interop", "System.Collections.Specialized", "NotifyCollectionChangedEventArgs", "System.ObjectModel") }, - { "NotifyCollectionChangedEventHandler", new ProjectionInfo ("Windows.UI.Xaml.Interop", "System.Collections.Specialized", "NotifyCollectionChangedEventHandler", "System.ObjectModel") }, - { "Plane", new ProjectionInfo ("Windows.Foundation.Numerics", "System.Numerics", "Plane", "System.Numerics.Vectors") }, - { "Point", new ProjectionInfo ("Windows.Foundation", "Windows.Foundation", "Point", "System.Runtime.WindowsRuntime") }, - { "PropertyChangedEventArgs", new ProjectionInfo ("Windows.UI.Xaml.Data", "System.ComponentModel", "PropertyChangedEventArgs", "System.ObjectModel") }, - { "PropertyChangedEventHandler", new ProjectionInfo ("Windows.UI.Xaml.Data", "System.ComponentModel", "PropertyChangedEventHandler", "System.ObjectModel") }, - { "Quaternion", new ProjectionInfo ("Windows.Foundation.Numerics", "System.Numerics", "Quaternion", "System.Numerics.Vectors") }, - { "Rect", new ProjectionInfo ("Windows.Foundation", "Windows.Foundation", "Rect", "System.Runtime.WindowsRuntime") }, - { "RepeatBehavior", new ProjectionInfo ("Windows.UI.Xaml.Media.Animation", "Windows.UI.Xaml.Media.Animation", "RepeatBehavior", "System.Runtime.WindowsRuntime.UI.Xaml") }, - { "RepeatBehaviorType", new ProjectionInfo ("Windows.UI.Xaml.Media.Animation", "Windows.UI.Xaml.Media.Animation", "RepeatBehaviorType", "System.Runtime.WindowsRuntime.UI.Xaml") }, - { "Size", new ProjectionInfo ("Windows.Foundation", "Windows.Foundation", "Size", "System.Runtime.WindowsRuntime") }, - { "Thickness", new ProjectionInfo ("Windows.UI.Xaml", "Windows.UI.Xaml", "Thickness", "System.Runtime.WindowsRuntime.UI.Xaml") }, - { "TimeSpan", new ProjectionInfo ("Windows.Foundation", "System", "TimeSpan", "System.Runtime") }, - { "TypeName", new ProjectionInfo ("Windows.UI.Xaml.Interop", "System", "Type", "System.Runtime") }, - { "Uri", new ProjectionInfo ("Windows.Foundation", "System", "Uri", "System.Runtime") }, - { "Vector2", new ProjectionInfo ("Windows.Foundation.Numerics", "System.Numerics", "Vector2", "System.Numerics.Vectors") }, - { "Vector3", new ProjectionInfo ("Windows.Foundation.Numerics", "System.Numerics", "Vector3", "System.Numerics.Vectors") }, - { "Vector4", new ProjectionInfo ("Windows.Foundation.Numerics", "System.Numerics", "Vector4", "System.Numerics.Vectors") }, - }; - } - } - - readonly ModuleDefinition module; - Version corlib_version = new Version (255, 255, 255, 255); - AssemblyNameReference[] virtual_references; - - AssemblyNameReference[] VirtualReferences { - get { - if (virtual_references == null) { - // force module to read its assembly references. that will in turn initialize virtual_references - Mixin.Read (module.AssemblyReferences); - } - - return virtual_references; - } - } - - public WindowsRuntimeProjections (ModuleDefinition module) - { - this.module = module; - } - - public static void Project (TypeDefinition type) - { - var treatment = TypeDefinitionTreatment.None; - var metadata_kind = type.Module.MetadataKind; - - if (type.IsWindowsRuntime) { - if (metadata_kind == MetadataKind.WindowsMetadata) { - treatment = GetWellKnownTypeDefinitionTreatment (type); - if (treatment != TypeDefinitionTreatment.None) { - ApplyProjection (type, new TypeDefinitionProjection (type, treatment)); - return; - } - - var base_type = type.BaseType; - if (base_type != null && IsAttribute (base_type)) - treatment = TypeDefinitionTreatment.NormalAttribute; - else - treatment = TypeDefinitionTreatment.NormalType; - } - else if (metadata_kind == MetadataKind.ManagedWindowsMetadata && NeedsWindowsRuntimePrefix (type)) - treatment = TypeDefinitionTreatment.PrefixWindowsRuntimeName; - - if (treatment == TypeDefinitionTreatment.PrefixWindowsRuntimeName || treatment == TypeDefinitionTreatment.NormalType) - if (!type.IsInterface && HasAttribute (type, "Windows.UI.Xaml", "TreatAsAbstractComposableClassAttribute")) - treatment |= TypeDefinitionTreatment.Abstract; - } - else if (metadata_kind == MetadataKind.ManagedWindowsMetadata && IsClrImplementationType (type)) - treatment = TypeDefinitionTreatment.UnmangleWindowsRuntimeName; - - if (treatment != TypeDefinitionTreatment.None) - ApplyProjection (type, new TypeDefinitionProjection (type, treatment)); - } - - static TypeDefinitionTreatment GetWellKnownTypeDefinitionTreatment (TypeDefinition type) - { - ProjectionInfo info; - if (!Projections.TryGetValue (type.Name, out info)) - return TypeDefinitionTreatment.None; - - var treatment = info.Attribute ? TypeDefinitionTreatment.RedirectToClrAttribute : TypeDefinitionTreatment.RedirectToClrType; - - if (type.Namespace == info.ClrNamespace) - return treatment; - - if (type.Namespace == info.WinRTNamespace) - return treatment | TypeDefinitionTreatment.Internal; - - return TypeDefinitionTreatment.None; - } - - static bool NeedsWindowsRuntimePrefix (TypeDefinition type) - { - if ((type.Attributes & (TypeAttributes.VisibilityMask | TypeAttributes.Interface)) != TypeAttributes.Public) - return false; - - var base_type = type.BaseType; - if (base_type == null || base_type.MetadataToken.TokenType != TokenType.TypeRef) - return false; - - if (base_type.Namespace == "System") - switch (base_type.Name) - { - case "Attribute": - case "MulticastDelegate": - case "ValueType": - return false; - } - - return true; - } - - static bool IsClrImplementationType (TypeDefinition type) - { - if ((type.Attributes & (TypeAttributes.VisibilityMask | TypeAttributes.SpecialName)) != TypeAttributes.SpecialName) - return false; - return type.Name.StartsWith (""); - } - - public static void ApplyProjection (TypeDefinition type, TypeDefinitionProjection projection) - { - if (projection == null) - return; - - var treatment = projection.Treatment; - - switch (treatment & TypeDefinitionTreatment.KindMask) { - case TypeDefinitionTreatment.NormalType: - type.Attributes |= TypeAttributes.WindowsRuntime | TypeAttributes.Import; - break; - - case TypeDefinitionTreatment.NormalAttribute: - type.Attributes |= TypeAttributes.WindowsRuntime | TypeAttributes.Sealed; - break; - - case TypeDefinitionTreatment.UnmangleWindowsRuntimeName: - type.Attributes = type.Attributes & ~TypeAttributes.SpecialName | TypeAttributes.Public; - type.Name = type.Name.Substring ("".Length); - break; - - case TypeDefinitionTreatment.PrefixWindowsRuntimeName: - type.Attributes = type.Attributes & ~TypeAttributes.Public | TypeAttributes.Import; - type.Name = "" + type.Name; - break; - - case TypeDefinitionTreatment.RedirectToClrType: - type.Attributes = type.Attributes & ~TypeAttributes.Public | TypeAttributes.Import; - break; - - case TypeDefinitionTreatment.RedirectToClrAttribute: - type.Attributes = type.Attributes & ~TypeAttributes.Public; - break; - } - - if ((treatment & TypeDefinitionTreatment.Abstract) != 0) - type.Attributes |= TypeAttributes.Abstract; - - if ((treatment & TypeDefinitionTreatment.Internal) != 0) - type.Attributes &= ~TypeAttributes.Public; - - type.WindowsRuntimeProjection = projection; - } - - public static TypeDefinitionProjection RemoveProjection (TypeDefinition type) - { - if (!type.IsWindowsRuntimeProjection) - return null; - - var projection = type.WindowsRuntimeProjection; - type.WindowsRuntimeProjection = null; - - type.Attributes = projection.Attributes; - type.Name = projection.Name; - - return projection; - } - - public static void Project (TypeReference type) - { - TypeReferenceTreatment treatment; - - ProjectionInfo info; - if (Projections.TryGetValue (type.Name, out info) && info.WinRTNamespace == type.Namespace) - treatment = TypeReferenceTreatment.UseProjectionInfo; - else - treatment = GetSpecialTypeReferenceTreatment (type); - - if (treatment != TypeReferenceTreatment.None) - ApplyProjection (type, new TypeReferenceProjection (type, treatment)); - } - - static TypeReferenceTreatment GetSpecialTypeReferenceTreatment (TypeReference type) - { - if (type.Namespace == "System") { - if (type.Name == "MulticastDelegate") - return TypeReferenceTreatment.SystemDelegate; - if (type.Name == "Attribute") - return TypeReferenceTreatment.SystemAttribute; - } - - return TypeReferenceTreatment.None; - } - - static bool IsAttribute (TypeReference type) - { - if (type.MetadataToken.TokenType != TokenType.TypeRef) - return false; - return type.Name == "Attribute" && type.Namespace == "System"; - } - - static bool IsEnum (TypeReference type) - { - if (type.MetadataToken.TokenType != TokenType.TypeRef) - return false; - return type.Name == "Enum" && type.Namespace == "System"; - } - - public static void ApplyProjection (TypeReference type, TypeReferenceProjection projection) - { - if (projection == null) - return; - - switch (projection.Treatment) - { - case TypeReferenceTreatment.SystemDelegate: - case TypeReferenceTreatment.SystemAttribute: - type.Scope = type.Module.Projections.GetAssemblyReference ("System.Runtime"); - break; - - case TypeReferenceTreatment.UseProjectionInfo: - var info = Projections [type.Name]; - type.Name = info.ClrName; - type.Namespace = info.ClrNamespace; - type.Scope = type.Module.Projections.GetAssemblyReference (info.ClrAssembly); - break; - } - - type.WindowsRuntimeProjection = projection; - } - - public static TypeReferenceProjection RemoveProjection (TypeReference type) - { - if (!type.IsWindowsRuntimeProjection) - return null; - - var projection = type.WindowsRuntimeProjection; - type.WindowsRuntimeProjection = null; - - type.Name = projection.Name; - type.Namespace = projection.Namespace; - type.Scope = projection.Scope; - - return projection; - } - - public static void Project (MethodDefinition method) - { - var treatment = MethodDefinitionTreatment.None; - var other = false; - var declaring_type = method.DeclaringType; - - if (declaring_type.IsWindowsRuntime) - { - if (IsClrImplementationType (declaring_type)) - treatment = MethodDefinitionTreatment.None; - else if (declaring_type.IsNested) - treatment = MethodDefinitionTreatment.None; - else if (declaring_type.IsInterface) - treatment = MethodDefinitionTreatment.Runtime | MethodDefinitionTreatment.InternalCall; - else if (declaring_type.Module.MetadataKind == MetadataKind.ManagedWindowsMetadata && !method.IsPublic) - treatment = MethodDefinitionTreatment.None; - else - { - other = true; - - var base_type = declaring_type.BaseType; - if (base_type != null && base_type.MetadataToken.TokenType == TokenType.TypeRef) - { - switch (GetSpecialTypeReferenceTreatment(base_type)) - { - case TypeReferenceTreatment.SystemDelegate: - treatment = MethodDefinitionTreatment.Runtime | MethodDefinitionTreatment.Public; - other = false; - break; - - case TypeReferenceTreatment.SystemAttribute: - treatment = MethodDefinitionTreatment.Runtime | MethodDefinitionTreatment.InternalCall; - other = false; - break; - } - } - } - } - - if (other) - { - var seen_redirected = false; - var seen_non_redirected = false; - var disposable = false; - - foreach (var @override in method.Overrides) - { - if (@override.MetadataToken.TokenType == TokenType.MemberRef && ImplementsRedirectedInterface (@override, out disposable)) - { - seen_redirected = true; - if (disposable) - break; - } - else - seen_non_redirected = true; - } - - if (disposable) - { - treatment = MethodDefinitionTreatment.Dispose; - other = false; - } - else if (seen_redirected && !seen_non_redirected) - { - treatment = MethodDefinitionTreatment.Runtime | MethodDefinitionTreatment.InternalCall | MethodDefinitionTreatment.Private; - other = false; - } - } - - if (other) - treatment |= GetMethodDefinitionTreatmentFromCustomAttributes(method); - - if (treatment != MethodDefinitionTreatment.None) - ApplyProjection (method, new MethodDefinitionProjection (method, treatment)); - } - - static MethodDefinitionTreatment GetMethodDefinitionTreatmentFromCustomAttributes(MethodDefinition method) - { - var treatment = MethodDefinitionTreatment.None; - - foreach (var attribute in method.CustomAttributes) - { - var type = attribute.AttributeType; - if (type.Namespace != "Windows.UI.Xaml") - continue; - if (type.Name == "TreatAsPublicMethodAttribute") - treatment |= MethodDefinitionTreatment.Public; - else if (type.Name == "TreatAsAbstractMethodAttribute") - treatment |= MethodDefinitionTreatment.Abstract; - } - - return treatment; - } - - public static void ApplyProjection (MethodDefinition method, MethodDefinitionProjection projection) - { - if (projection == null) - return; - - var treatment = projection.Treatment; - - if ((treatment & MethodDefinitionTreatment.Dispose) != 0) - method.Name = "Dispose"; - - if ((treatment & MethodDefinitionTreatment.Abstract) != 0) - method.Attributes |= MethodAttributes.Abstract; - - if ((treatment & MethodDefinitionTreatment.Private) != 0) - method.Attributes = (method.Attributes & ~MethodAttributes.MemberAccessMask) | MethodAttributes.Private; - - if ((treatment & MethodDefinitionTreatment.Public) != 0) - method.Attributes = (method.Attributes & ~MethodAttributes.MemberAccessMask) | MethodAttributes.Public; - - if ((treatment & MethodDefinitionTreatment.Runtime) != 0) - method.ImplAttributes |= MethodImplAttributes.Runtime; - - if ((treatment & MethodDefinitionTreatment.InternalCall) != 0) - method.ImplAttributes |= MethodImplAttributes.InternalCall; - - method.WindowsRuntimeProjection = projection; - } - - public static MethodDefinitionProjection RemoveProjection (MethodDefinition method) - { - if (!method.IsWindowsRuntimeProjection) - return null; - - var projection = method.WindowsRuntimeProjection; - method.WindowsRuntimeProjection = null; - - method.Attributes = projection.Attributes; - method.ImplAttributes = projection.ImplAttributes; - method.Name = projection.Name; - - return projection; - } - - public static void Project (FieldDefinition field) - { - var treatment = FieldDefinitionTreatment.None; - var declaring_type = field.DeclaringType; - - if (declaring_type.Module.MetadataKind == MetadataKind.WindowsMetadata && field.IsRuntimeSpecialName && field.Name == "value__") { - var base_type = declaring_type.BaseType; - if (base_type != null && IsEnum (base_type)) - treatment = FieldDefinitionTreatment.Public; - } - - if (treatment != FieldDefinitionTreatment.None) - ApplyProjection (field, new FieldDefinitionProjection (field, treatment)); - } - - public static void ApplyProjection (FieldDefinition field, FieldDefinitionProjection projection) - { - if (projection == null) - return; - - if (projection.Treatment == FieldDefinitionTreatment.Public) - field.Attributes = (field.Attributes & ~FieldAttributes.FieldAccessMask) | FieldAttributes.Public; - - field.WindowsRuntimeProjection = projection; - } - - public static FieldDefinitionProjection RemoveProjection (FieldDefinition field) - { - if (!field.IsWindowsRuntimeProjection) - return null; - - var projection = field.WindowsRuntimeProjection; - field.WindowsRuntimeProjection = null; - - field.Attributes = projection.Attributes; - - return projection; - } - - public static void Project (MemberReference member) - { - bool disposable; - if (!ImplementsRedirectedInterface (member, out disposable) || !disposable) - return; - - ApplyProjection (member, new MemberReferenceProjection (member, MemberReferenceTreatment.Dispose)); - } - - static bool ImplementsRedirectedInterface (MemberReference member, out bool disposable) - { - disposable = false; - - var declaring_type = member.DeclaringType; - TypeReference type; - switch (declaring_type.MetadataToken.TokenType) { - case TokenType.TypeRef: - type = declaring_type; - break; - - case TokenType.TypeSpec: - if (!declaring_type.IsGenericInstance) - return false; - - type = ((TypeSpecification) declaring_type).ElementType; - if (type.MetadataType != MetadataType.Class || type.MetadataToken.TokenType != TokenType.TypeRef) - return false; - - break; - - default: - return false; - } - - var projection = RemoveProjection (type); - - var found = false; - - ProjectionInfo info; - if (Projections.TryGetValue (type.Name, out info) && type.Namespace == info.WinRTNamespace) { - disposable = info.Disposable; - found = true; - } - - ApplyProjection (type, projection); - - return found; - } - - public static void ApplyProjection (MemberReference member, MemberReferenceProjection projection) - { - if (projection == null) - return; - - if (projection.Treatment == MemberReferenceTreatment.Dispose) - member.Name = "Dispose"; - - member.WindowsRuntimeProjection = projection; - } - - public static MemberReferenceProjection RemoveProjection (MemberReference member) - { - if (!member.IsWindowsRuntimeProjection) - return null; - - var projection = member.WindowsRuntimeProjection; - member.WindowsRuntimeProjection = null; - - member.Name = projection.Name; - - return projection; - } - - public void AddVirtualReferences (Collection references) - { - var corlib = GetCoreLibrary (references); - corlib_version = corlib.Version; - corlib.Version = version; - - if (virtual_references == null) { - var winrt_references = GetAssemblyReferences (corlib); - Interlocked.CompareExchange (ref virtual_references, winrt_references, null); - } - - foreach (var reference in virtual_references) - references.Add (reference); - } - - public void RemoveVirtualReferences (Collection references) - { - var corlib = GetCoreLibrary (references); - corlib.Version = corlib_version; - - foreach (var reference in VirtualReferences) - references.Remove (reference); - } - - static AssemblyNameReference[] GetAssemblyReferences (AssemblyNameReference corlib) - { - var system_runtime = new AssemblyNameReference ("System.Runtime", version); - var system_runtime_interopservices_windowsruntime = new AssemblyNameReference ("System.Runtime.InteropServices.WindowsRuntime", version); - var system_objectmodel = new AssemblyNameReference ("System.ObjectModel", version); - var system_runtime_windowsruntime = new AssemblyNameReference ("System.Runtime.WindowsRuntime", version); - var system_runtime_windowsruntime_ui_xaml = new AssemblyNameReference ("System.Runtime.WindowsRuntime.UI.Xaml", version); - var system_numerics_vectors = new AssemblyNameReference ("System.Numerics.Vectors", version); - - if (corlib.HasPublicKey) { - system_runtime_windowsruntime.PublicKey = - system_runtime_windowsruntime_ui_xaml.PublicKey = corlib.PublicKey; - - system_runtime.PublicKey = - system_runtime_interopservices_windowsruntime.PublicKey = - system_objectmodel.PublicKey = - system_numerics_vectors.PublicKey = contract_pk; - } - else { - system_runtime_windowsruntime.PublicKeyToken = - system_runtime_windowsruntime_ui_xaml.PublicKeyToken = corlib.PublicKeyToken; - - system_runtime.PublicKeyToken = - system_runtime_interopservices_windowsruntime.PublicKeyToken = - system_objectmodel.PublicKeyToken = - system_numerics_vectors.PublicKeyToken = contract_pk_token; - } - - return new[] { - system_runtime, - system_runtime_interopservices_windowsruntime, - system_objectmodel, - system_runtime_windowsruntime, - system_runtime_windowsruntime_ui_xaml, - system_numerics_vectors, - }; - } - - static AssemblyNameReference GetCoreLibrary (Collection references) - { - foreach (var reference in references) - if (reference.Name == "mscorlib") - return reference; - - throw new BadImageFormatException ("Missing mscorlib reference in AssemblyRef table."); - } - - AssemblyNameReference GetAssemblyReference (string name) - { - foreach (var assembly in VirtualReferences) - if (assembly.Name == name) - return assembly; - - throw new Exception (); - } - - public static void Project (ICustomAttributeProvider owner, CustomAttribute attribute) - { - if (!IsWindowsAttributeUsageAttribute (owner, attribute)) - return; - - var treatment = CustomAttributeValueTreatment.None; - var type = (TypeDefinition) owner; - - if (type.Namespace == "Windows.Foundation.Metadata") { - if (type.Name == "VersionAttribute") - treatment = CustomAttributeValueTreatment.VersionAttribute; - else if (type.Name == "DeprecatedAttribute") - treatment = CustomAttributeValueTreatment.DeprecatedAttribute; - } - - if (treatment == CustomAttributeValueTreatment.None) { - var multiple = HasAttribute (type, "Windows.Foundation.Metadata", "AllowMultipleAttribute"); - treatment = multiple ? CustomAttributeValueTreatment.AllowMultiple : CustomAttributeValueTreatment.AllowSingle; - } - - if (treatment != CustomAttributeValueTreatment.None) { - var attribute_targets = (AttributeTargets) attribute.ConstructorArguments [0].Value; - ApplyProjection (attribute, new CustomAttributeValueProjection (attribute_targets, treatment)); - } - } - - static bool IsWindowsAttributeUsageAttribute (ICustomAttributeProvider owner, CustomAttribute attribute) - { - if (owner.MetadataToken.TokenType != TokenType.TypeDef) - return false; - - var constructor = attribute.Constructor; - - if (constructor.MetadataToken.TokenType != TokenType.MemberRef) - return false; - - var declaring_type = constructor.DeclaringType; - - if (declaring_type.MetadataToken.TokenType != TokenType.TypeRef) - return false; - - // declaring type is already projected - return declaring_type.Name == "AttributeUsageAttribute" && declaring_type.Namespace == /*"Windows.Foundation.Metadata"*/"System"; - } - - static bool HasAttribute (TypeDefinition type, string @namespace, string name) - { - foreach (var attribute in type.CustomAttributes) { - var attribute_type = attribute.AttributeType; - if (attribute_type.Name == name && attribute_type.Namespace == @namespace) - return true; - } - return false; - } - - public static void ApplyProjection (CustomAttribute attribute, CustomAttributeValueProjection projection) - { - if (projection == null) - return; - - bool version_or_deprecated; - bool multiple; - - switch (projection.Treatment) { - case CustomAttributeValueTreatment.AllowSingle: - version_or_deprecated = false; - multiple = false; - break; - - case CustomAttributeValueTreatment.AllowMultiple: - version_or_deprecated = false; - multiple = true; - break; - - case CustomAttributeValueTreatment.VersionAttribute: - case CustomAttributeValueTreatment.DeprecatedAttribute: - version_or_deprecated = true; - multiple = true; - break; - - default: - throw new ArgumentException (); - } - - var attribute_targets = (AttributeTargets) attribute.ConstructorArguments [0].Value; - if (version_or_deprecated) - attribute_targets |= AttributeTargets.Constructor | AttributeTargets.Property; - attribute.ConstructorArguments [0] = new CustomAttributeArgument (attribute.ConstructorArguments [0].Type, attribute_targets); - - attribute.Properties.Add (new CustomAttributeNamedArgument ("AllowMultiple", new CustomAttributeArgument (attribute.Module.TypeSystem.Boolean, multiple))); - - attribute.projection = projection; - } - - public static CustomAttributeValueProjection RemoveProjection (CustomAttribute attribute) - { - if (attribute.projection == null) - return null; - - var projection = attribute.projection; - attribute.projection = null; - - attribute.ConstructorArguments [0] = new CustomAttributeArgument (attribute.ConstructorArguments [0].Type, projection.Targets); - attribute.Properties.Clear (); - - return projection; - } - } -} diff --git a/external/linker/cecil/Mono.Collections.Generic/Collection.cs b/external/linker/cecil/Mono.Collections.Generic/Collection.cs deleted file mode 100644 index 015d271b47..0000000000 --- a/external/linker/cecil/Mono.Collections.Generic/Collection.cs +++ /dev/null @@ -1,416 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections; -using System.Collections.Generic; - -using Mono.Cecil; - -namespace Mono.Collections.Generic { - - public class Collection : IList, 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; - } - } - - public int Capacity { - get { return items.Length; } - set { - if (value < 0 || value < size) - throw new ArgumentOutOfRangeException (); - - Resize (value); - } - } - - bool ICollection.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.Array; - } - - public Collection (int capacity) - { - if (capacity < 0) - throw new ArgumentOutOfRangeException (); - - items = new T [capacity]; - } - - public Collection (ICollection items) - { - if (items == null) - throw new ArgumentNullException ("items"); - - this.items = new T [items.Count]; - items.CopyTo (this.items, 0); - this.size = this.items.Length; - } - - 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); - version++; - } - - public bool Remove (T item) - { - var index = IndexOf (item); - if (index == -1) - return false; - - OnRemove (item, index); - - Shift (index, -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); - - Resize (new_size); - } - - protected void Resize (int new_size) - { - if (new_size == size) - return; - if (new_size < size) - throw new ArgumentOutOfRangeException (); - - items = items.Resize (new_size); - } - - 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 IEnumerable.GetEnumerator () - { - return new Enumerator (this); - } - - public struct Enumerator : IEnumerator, IDisposable { - - Collection 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 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/external/linker/cecil/Mono.Collections.Generic/ReadOnlyCollection.cs b/external/linker/cecil/Mono.Collections.Generic/ReadOnlyCollection.cs deleted file mode 100644 index fe784149fd..0000000000 --- a/external/linker/cecil/Mono.Collections.Generic/ReadOnlyCollection.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections; -using System.Collections.Generic; - -namespace Mono.Collections.Generic { - - public sealed class ReadOnlyCollection : Collection, ICollection, IList { - - static ReadOnlyCollection empty; - - public static ReadOnlyCollection Empty { - get { return empty ?? (empty = new ReadOnlyCollection ()); } - } - - bool ICollection.IsReadOnly { - get { return true; } - } - - bool IList.IsFixedSize { - get { return true; } - } - - bool IList.IsReadOnly { - get { return true; } - } - - ReadOnlyCollection () - { - } - - public ReadOnlyCollection (T [] array) - { - if (array == null) - throw new ArgumentNullException (); - - Initialize (array, array.Length); - } - - public ReadOnlyCollection (Collection collection) - { - if (collection == null) - throw new ArgumentNullException (); - - Initialize (collection.items, collection.size); - } - - void Initialize (T [] items, int size) - { - this.items = new T [size]; - Array.Copy (items, 0, this.items, 0, size); - this.size = size; - } - - internal override void Grow (int desired) - { - 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/external/linker/cecil/Mono.Security.Cryptography/CryptoConvert.cs b/external/linker/cecil/Mono.Security.Cryptography/CryptoConvert.cs deleted file mode 100644 index 51f4ca1359..0000000000 --- a/external/linker/cecil/Mono.Security.Cryptography/CryptoConvert.cs +++ /dev/null @@ -1,253 +0,0 @@ -// -// CryptoConvert.cs - Crypto Convertion Routines -// -// Author: -// Sebastien Pouliot -// -// (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. -// - -#if !READ_ONLY - -#if !NET_CORE - -using System; -using System.Security.Cryptography; - -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) { - // 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 - bool throws = false; - try { - CspParameters csp = new CspParameters (); - csp.Flags = CspProviderFlags.UseMachineKeyStore; - rsa = new RSACryptoServiceProvider (csp); - rsa.ImportParameters (rsap); - } - catch { - throws = true; - } - - if (throws) { - // rethrow original, not the latter, exception if this fails - throw; - } - } - 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 - -#endif - diff --git a/external/linker/cecil/Mono.Security.Cryptography/CryptoService.cs b/external/linker/cecil/Mono.Security.Cryptography/CryptoService.cs deleted file mode 100644 index 840276d290..0000000000 --- a/external/linker/cecil/Mono.Security.Cryptography/CryptoService.cs +++ /dev/null @@ -1,158 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -#if !READ_ONLY - -#if !NET_CORE - -using System; -using System.IO; -using System.Reflection; -using System.Security.Cryptography; -using System.Runtime.Serialization; - -using Mono.Security.Cryptography; - -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 { - - 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; - } - - 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.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; - } - } - - 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/external/linker/cecil/Mono/Disposable.cs b/external/linker/cecil/Mono/Disposable.cs deleted file mode 100644 index dc2b1a3d10..0000000000 --- a/external/linker/cecil/Mono/Disposable.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono { - - static class Disposable { - - public static Disposable Owned (T value) where T : class, IDisposable - { - return new Disposable (value, owned: true); - } - - public static Disposable NotOwned (T value) where T : class, IDisposable - { - return new Disposable (value, owned: false); - } - } - - struct Disposable : IDisposable where T : class, IDisposable { - - internal readonly T value; - readonly bool owned; - - public Disposable (T value, bool owned) - { - this.value = value; - this.owned = owned; - } - - public void Dispose () - { - if (value != null && owned) - value.Dispose (); - } - } -} diff --git a/external/linker/cecil/Mono/Empty.cs b/external/linker/cecil/Mono/Empty.cs deleted file mode 100644 index de28e65614..0000000000 --- a/external/linker/cecil/Mono/Empty.cs +++ /dev/null @@ -1,62 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using Mono.Collections.Generic; - -namespace Mono { - - static class Empty { - - public static readonly T [] Array = new T [0]; - } - - class ArgumentNullOrEmptyException : ArgumentException { - - public ArgumentNullOrEmptyException (string paramName) - : base ("Argument null or empty", paramName) - { - } - } -} - -namespace Mono.Cecil { - - static partial class Mixin { - - public static bool IsNullOrEmpty (this T [] self) - { - return self == null || self.Length == 0; - } - - public static bool IsNullOrEmpty (this Collection self) - { - return self == null || self.size == 0; - } - - public static T [] Resize (this T [] self, int length) - { - Array.Resize (ref self, length); - return self; - } - - public static T [] Add (this T [] self, T item) - { - if (self == null) { - self = new [] { item }; - return self; - } - - self = self.Resize (self.Length + 1); - self [self.Length - 1] = item; - return self; - } - } -} diff --git a/external/linker/cecil/Mono/Type.cs b/external/linker/cecil/Mono/Type.cs deleted file mode 100644 index fd53f81b4a..0000000000 --- a/external/linker/cecil/Mono/Type.cs +++ /dev/null @@ -1,137 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Reflection; - -#if NET_CORE -using System.Collections.Generic; -#endif - -namespace Mono { - -#if NET_CORE - enum TypeCode { - Empty = 0, - Object = 1, - DBNull = 2, - Boolean = 3, - Char = 4, - SByte = 5, - Byte = 6, - Int16 = 7, - UInt16 = 8, - Int32 = 9, - UInt32 = 10, - Int64 = 11, - UInt64 = 12, - Single = 13, - Double = 14, - Decimal = 15, - DateTime = 16, - String = 18 - } -#endif - - static class TypeExtensions { - -#if NET_CORE - private static readonly Dictionary TypeCodeMap = new Dictionary - { - { typeof (bool), TypeCode.Boolean }, - { typeof (char), TypeCode.Char }, - { typeof (sbyte), TypeCode.SByte }, - { typeof (byte), TypeCode.Byte }, - { typeof (short), TypeCode.Int16 }, - { typeof (ushort), TypeCode.UInt16 }, - { typeof (int), TypeCode.Int32 }, - { typeof (uint), TypeCode.UInt32 }, - { typeof (long), TypeCode.Int64 }, - { typeof (ulong), TypeCode.UInt64 }, - { typeof (float), TypeCode.Single }, - { typeof (double), TypeCode.Double }, - { typeof (decimal), TypeCode.Decimal }, - { typeof (DateTime), TypeCode.DateTime }, - { typeof (string), TypeCode.String }, - }; -#endif - - public static TypeCode GetTypeCode (this Type type) - { -#if NET_CORE - if (type == null) - return TypeCode.Empty; - - TypeCode code; - if (!TypeCodeMap.TryGetValue (type, out code)) - return TypeCode.Object; - - return code; -#else - return Type.GetTypeCode (type); -#endif - } - - public static Assembly Assembly (this Type type) - { -#if NET_CORE - return type.GetTypeInfo ().Assembly; -#else - return type.Assembly; -#endif - } - - public static MethodBase DeclaringMethod (this Type type) - { -#if NET_CORE - return type.GetTypeInfo ().DeclaringMethod; -#else - return type.DeclaringMethod; -#endif - } - - public static Type [] GetGenericArguments (this Type type) - { -#if NET_CORE - var info = type.GetTypeInfo (); - return info.IsGenericTypeDefinition ? info.GenericTypeParameters : info.GenericTypeArguments; -#else - return type.GetGenericArguments (); -#endif - } - - public static bool IsGenericType (this Type type) - { -#if NET_CORE - return type.GetTypeInfo ().IsGenericType; -#else - return type.IsGenericType; -#endif - } - - public static bool IsGenericTypeDefinition (this Type type) - { -#if NET_CORE - return type.GetTypeInfo ().IsGenericTypeDefinition; -#else - return type.IsGenericTypeDefinition; -#endif - } - - public static bool IsValueType (this Type type) - { -#if NET_CORE - return type.GetTypeInfo ().IsValueType; -#else - return type.IsValueType; -#endif - } - } -} diff --git a/external/linker/cecil/NetStandard.props b/external/linker/cecil/NetStandard.props deleted file mode 100644 index bc0bacc6ef..0000000000 --- a/external/linker/cecil/NetStandard.props +++ /dev/null @@ -1,9 +0,0 @@ - - - - $(DefineConstants);NET_CORE; - false - false - true - - diff --git a/external/linker/cecil/ProjectInfo.cs b/external/linker/cecil/ProjectInfo.cs deleted file mode 100644 index 0b94141540..0000000000 --- a/external/linker/cecil/ProjectInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// -// Licensed under the MIT/X11 license. -// - -using System.Reflection; -using System.Runtime.InteropServices; - -[assembly: AssemblyProduct (Consts.AssemblyName)] -[assembly: AssemblyCopyright ("Copyright © 2008 - 2015 Jb Evain")] - -[assembly: ComVisible (false)] - -[assembly: AssemblyVersion ("0.10.0.0")] -[assembly: AssemblyFileVersion ("0.10.0.0")] -[assembly: AssemblyInformationalVersion ("0.10.0.0-beta7")] diff --git a/external/linker/cecil/README.md b/external/linker/cecil/README.md deleted file mode 100644 index 7c8707230c..0000000000 --- a/external/linker/cecil/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Cecil -===== - -This is a fork of [Cecil](https://github.com/jbevain/cecil) library. Please do any pull requests in the original repository before they are merged into Mono fork. diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests.csproj b/external/linker/cecil/Test/Mono.Cecil.Tests.csproj deleted file mode 100644 index 45856234a3..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests.csproj +++ /dev/null @@ -1,54 +0,0 @@ - - - - - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055} - Mono.Cecil.Tests - Mono.Cecil.Tests - - - - 4.3.0 - - - 4.3.0 - - - 4.3.0 - - - 4.3.0 - - - 4.3.0 - - - 2.3.2 - - - 2.3.2 - - - - - {D68133BD-1E63-496E-9EDE-4FBDBF77B486} - Mono.Cecil - - - {8559dd7f-a16f-46d0-a05a-9139faeba8fd} - Mono.Cecil.Mdb - - - {63e6915c-7ea4-4d76-ab28-0d7191eea626} - Mono.Cecil.Pdb - - - - - - - - - - - \ No newline at end of file diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/AssemblyInfo.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/AssemblyInfo.cs deleted file mode 100644 index f4a938ac48..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle ("Mono.Cecil.Tests")] - -[assembly: Guid ("da96c202-696a-457e-89af-5fa74e6bda0d")] diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/AssemblyTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/AssemblyTests.cs deleted file mode 100644 index 0b7c7c1f3b..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/AssemblyTests.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; - -using Mono.Cecil; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class AssemblyTests : BaseTestFixture { - - [Test] - public void Name () - { - TestModule ("hello.exe", module => { - var name = module.Assembly.Name; - - Assert.IsNotNull (name); - - Assert.AreEqual ("hello", name.Name); - Assert.AreEqual ("", name.Culture); - Assert.AreEqual (new Version (0, 0, 0, 0), name.Version); - Assert.AreEqual (AssemblyHashAlgorithm.SHA1, name.HashAlgorithm); - }); - } - - [Test] - public void ParseLowerCaseNameParts () - { - var name = AssemblyNameReference.Parse ("Foo, version=2.0.0.0, culture=fr-FR"); - Assert.AreEqual ("Foo", name.Name); - Assert.AreEqual (2, name.Version.Major); - Assert.AreEqual (0, name.Version.Minor); - Assert.AreEqual ("fr-FR", name.Culture); - } - - [Test] - public void ZeroVersion () - { - var name = new AssemblyNameReference ("Foo", null); - Assert.AreEqual ("0.0.0.0", name.Version.ToString (fieldCount: 4)); - Assert.AreEqual ("Foo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", name.FullName); - - name = new AssemblyNameReference ("Foo", new Version (0, 0, 0, 0)); - Assert.AreEqual ("0.0.0.0", name.Version.ToString (fieldCount: 4)); - Assert.AreEqual ("Foo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", name.FullName); - } - - [Test] - public void NoBuildOrMajor () - { - var name = new AssemblyNameReference ("Foo", new Version (0, 0)); - Assert.AreEqual ("Foo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", name.FullName); - - name = new AssemblyNameReference ("Foo", new Version (0, 0, 0)); - Assert.AreEqual ("Foo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", name.FullName); - } - - [Test] - public void Retargetable () - { - if (Platform.OnCoreClr) - return; - - TestModule ("RetargetableExample.dll", module => { - var type = module.Types [1]; - var property = type.Properties [0]; - var attribute = property.CustomAttributes [0]; - - var argumentType = ((CustomAttributeArgument) attribute.ConstructorArguments [0].Value).Type; - var reference = (AssemblyNameReference) argumentType.Scope; - - Assert.AreEqual ( - "System.Data, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac, Retargetable=Yes", - reference.FullName); - }, verify: !Platform.OnMono); - } - - [Test] - public void SystemRuntime () - { - if (Platform.OnCoreClr) - return; - - TestModule ("System.Runtime.dll", module => { - Assert.AreEqual ("System.Runtime", module.Assembly.Name.Name); - Assert.AreEqual (1, module.AssemblyReferences.Count); - Assert.AreNotEqual (module, module.TypeSystem.CoreLibrary); - Assert.AreEqual (module.AssemblyReferences [0], module.TypeSystem.CoreLibrary); - }, verify: !Platform.OnMono); - } - - [Test] - public void MismatchedLibraryAndSymbols_DoNotThrow () - { - // SQLite-net.dll (from nuget) shiped with mismatched symbol files, but throwIfNoSymbol did not prevent it from throwing - var readerParms = new ReaderParameters { - ReadSymbols = true, - SymbolReaderProvider = new Cil.DefaultSymbolReaderProvider (throwIfNoSymbol: false) - }; - - using (var module = GetResourceModule ("SQLite-net.dll", readerParms)) { - Assert.Null (module.SymbolReader); - } - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/BaseTestFixture.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/BaseTestFixture.cs deleted file mode 100644 index c49880edae..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/BaseTestFixture.cs +++ /dev/null @@ -1,336 +0,0 @@ -using System; -using System.IO; -using System.Reflection; -using Mono.Cecil.Cil; -using NUnit.Framework; - -using Mono.Cecil.PE; - -namespace Mono.Cecil.Tests { - - public abstract class BaseTestFixture { - - protected static void IgnoreOnMono () - { - if (Platform.OnMono) - Assert.Ignore (); - } - - public static string GetResourcePath (string name, Assembly assembly) - { - return Path.Combine (FindResourcesDirectory (assembly), name); - } - - public static string GetAssemblyResourcePath (string name, Assembly assembly) - { - return GetResourcePath (Path.Combine ("assemblies", name), assembly); - } - - public static string GetCSharpResourcePath (string name, Assembly assembly) - { - return GetResourcePath (Path.Combine ("cs", name), assembly); - } - - public static string GetILResourcePath (string name, Assembly assembly) - { - return GetResourcePath (Path.Combine ("il", name), assembly); - } - - public ModuleDefinition GetResourceModule (string name) - { - return ModuleDefinition.ReadModule (GetAssemblyResourcePath (name, GetType ().Assembly)); - } - - public ModuleDefinition GetResourceModule (string name, ReaderParameters parameters) - { - return ModuleDefinition.ReadModule (GetAssemblyResourcePath (name, GetType ().Assembly), parameters); - } - - public ModuleDefinition GetResourceModule (string name, ReadingMode mode) - { - return ModuleDefinition.ReadModule (GetAssemblyResourcePath (name, GetType ().Assembly), new ReaderParameters (mode)); - } - - internal Image GetResourceImage (string name) - { - var file = new FileStream (GetAssemblyResourcePath (name, GetType ().Assembly), FileMode.Open, FileAccess.Read); - return ImageReader.ReadImage (Disposable.Owned (file as Stream), file.Name); - } - - public ModuleDefinition GetCurrentModule () - { - return ModuleDefinition.ReadModule (GetType ().Module.FullyQualifiedName); - } - - public ModuleDefinition GetCurrentModule (ReaderParameters parameters) - { - return ModuleDefinition.ReadModule (GetType ().Module.FullyQualifiedName, parameters); - } - - public static string FindResourcesDirectory (Assembly assembly) - { - var path = Path.GetDirectoryName (new Uri (assembly.CodeBase).LocalPath); - while (!Directory.Exists (Path.Combine (path, "Resources"))) { - var old = path; - path = Path.GetDirectoryName (path); - Assert.AreNotEqual (old, path); - } - - return Path.Combine (path, "Resources"); - } - - public static void AssertCode (string expected, MethodDefinition method) - { - Assert.IsTrue (method.HasBody); - Assert.IsNotNull (method.Body); - - Assert.AreEqual (Normalize (expected), Normalize (Formatter.FormatMethodBody (method))); - } - - public static string Normalize (string str) - { - return str.Trim ().Replace ("\r\n", "\n"); - } - - public static void TestModule (string file, Action test, bool verify = true, bool readOnly = false, Type symbolReaderProvider = null, Type symbolWriterProvider = null, IAssemblyResolver assemblyResolver = null, bool applyWindowsRuntimeProjections = false) - { - Run (new ModuleTestCase (file, test, verify, readOnly, symbolReaderProvider, symbolWriterProvider, assemblyResolver, applyWindowsRuntimeProjections)); - } - - public static void TestCSharp (string file, Action test, bool verify = true, bool readOnly = false, Type symbolReaderProvider = null, Type symbolWriterProvider = null, IAssemblyResolver assemblyResolver = null, bool applyWindowsRuntimeProjections = false) - { - Run (new CSharpTestCase (file, test, verify, readOnly, symbolReaderProvider, symbolWriterProvider, assemblyResolver, applyWindowsRuntimeProjections)); - } - - public static void TestIL (string file, Action test, bool verify = true, bool readOnly = false, Type symbolReaderProvider = null, Type symbolWriterProvider = null, IAssemblyResolver assemblyResolver = null, bool applyWindowsRuntimeProjections = false) - { - Run (new ILTestCase (file, test, verify, readOnly, symbolReaderProvider, symbolWriterProvider, assemblyResolver, applyWindowsRuntimeProjections)); - } - - static void Run (TestCase testCase) - { - using (var runner = new TestRunner (testCase, TestCaseType.ReadDeferred)) - runner.RunTest (); - - using (var runner = new TestRunner (testCase, TestCaseType.ReadImmediate)) - runner.RunTest (); - - if (testCase.ReadOnly) - return; - -#if !READ_ONLY - using (var runner = new TestRunner (testCase, TestCaseType.WriteFromDeferred)) - runner.RunTest (); - - using (var runner = new TestRunner (testCase, TestCaseType.WriteFromImmediate)) - runner.RunTest (); -#endif - } - } - - abstract class TestCase { - - public readonly bool Verify; - public readonly bool ReadOnly; - public readonly Type SymbolReaderProvider; - public readonly Type SymbolWriterProvider; - public readonly IAssemblyResolver AssemblyResolver; - public readonly Action Test; - public readonly bool ApplyWindowsRuntimeProjections; - - public abstract string ModuleLocation { get; } - - protected Assembly Assembly { get { return Test.Method.Module.Assembly; } } - - protected TestCase (Action test, bool verify, bool readOnly, Type symbolReaderProvider, Type symbolWriterProvider, IAssemblyResolver assemblyResolver, bool applyWindowsRuntimeProjections) - { - Test = test; - Verify = verify; - ReadOnly = readOnly; - SymbolReaderProvider = symbolReaderProvider; - SymbolWriterProvider = symbolWriterProvider; - AssemblyResolver = assemblyResolver; - ApplyWindowsRuntimeProjections = applyWindowsRuntimeProjections; - } - } - - class ModuleTestCase : TestCase { - - public readonly string Module; - - public ModuleTestCase (string module, Action test, bool verify, bool readOnly, Type symbolReaderProvider, Type symbolWriterProvider, IAssemblyResolver assemblyResolver, bool applyWindowsRuntimeProjections) - : base (test, verify, readOnly, symbolReaderProvider, symbolWriterProvider, assemblyResolver, applyWindowsRuntimeProjections) - { - Module = module; - } - - public override string ModuleLocation - { - get { return BaseTestFixture.GetAssemblyResourcePath (Module, Assembly); } - } - } - - class CSharpTestCase : TestCase { - - public readonly string File; - - public CSharpTestCase (string file, Action test, bool verify, bool readOnly, Type symbolReaderProvider, Type symbolWriterProvider, IAssemblyResolver assemblyResolver, bool applyWindowsRuntimeProjections) - : base (test, verify, readOnly, symbolReaderProvider, symbolWriterProvider, assemblyResolver, applyWindowsRuntimeProjections) - { - File = file; - } - - public override string ModuleLocation - { - get - { - return CompilationService.CompileResource (BaseTestFixture.GetCSharpResourcePath (File, Assembly)); - } - } - } - - class ILTestCase : TestCase { - - public readonly string File; - - public ILTestCase (string file, Action test, bool verify, bool readOnly, Type symbolReaderProvider, Type symbolWriterProvider, IAssemblyResolver assemblyResolver, bool applyWindowsRuntimeProjections) - : base (test, verify, readOnly, symbolReaderProvider, symbolWriterProvider, assemblyResolver, applyWindowsRuntimeProjections) - { - File = file; - } - - public override string ModuleLocation - { - get - { - return CompilationService.CompileResource (BaseTestFixture.GetILResourcePath (File, Assembly)); ; - } - } - } - - class TestRunner : IDisposable { - - readonly TestCase test_case; - readonly TestCaseType type; - - ModuleDefinition test_module; - DefaultAssemblyResolver test_resolver; - - public TestRunner (TestCase testCase, TestCaseType type) - { - this.test_case = testCase; - this.type = type; - } - - ModuleDefinition GetModule () - { - var location = test_case.ModuleLocation; - - var parameters = new ReaderParameters { - SymbolReaderProvider = GetSymbolReaderProvider (), - AssemblyResolver = GetAssemblyResolver (), - ApplyWindowsRuntimeProjections = test_case.ApplyWindowsRuntimeProjections - }; - - switch (type) { - case TestCaseType.ReadImmediate: - parameters.ReadingMode = ReadingMode.Immediate; - return ModuleDefinition.ReadModule (location, parameters); - case TestCaseType.ReadDeferred: - parameters.ReadingMode = ReadingMode.Deferred; - return ModuleDefinition.ReadModule (location, parameters); -#if !READ_ONLY - case TestCaseType.WriteFromImmediate: - parameters.ReadingMode = ReadingMode.Immediate; - return RoundTrip (location, parameters, "cecil-irt"); - case TestCaseType.WriteFromDeferred: - parameters.ReadingMode = ReadingMode.Deferred; - return RoundTrip (location, parameters, "cecil-drt"); -#endif - default: - return null; - } - } - - ISymbolReaderProvider GetSymbolReaderProvider () - { - if (test_case.SymbolReaderProvider == null) - return null; - - return (ISymbolReaderProvider) Activator.CreateInstance (test_case.SymbolReaderProvider); - } - -#if !READ_ONLY - ISymbolWriterProvider GetSymbolWriterProvider () - { - if (test_case.SymbolReaderProvider == null) - return null; - - return (ISymbolWriterProvider) Activator.CreateInstance (test_case.SymbolWriterProvider); - } -#endif - - IAssemblyResolver GetAssemblyResolver () - { - if (test_case.AssemblyResolver != null) - return test_case.AssemblyResolver; - - test_resolver = new DefaultAssemblyResolver (); - var directory = Path.GetDirectoryName (test_case.ModuleLocation); - test_resolver.AddSearchDirectory (directory); - return test_resolver; - } - -#if !READ_ONLY - ModuleDefinition RoundTrip (string location, ReaderParameters reader_parameters, string folder) - { - var rt_folder = Path.Combine (Path.GetTempPath (), folder); - if (!Directory.Exists (rt_folder)) - Directory.CreateDirectory (rt_folder); - var rt_module = Path.Combine (rt_folder, Path.GetFileName (location)); - - using (var module = ModuleDefinition.ReadModule (location, reader_parameters)) { - var writer_parameters = new WriterParameters { - SymbolWriterProvider = GetSymbolWriterProvider (), - }; - - test_case.Test (module); - - module.Write (rt_module, writer_parameters); - } - - if (test_case.Verify) - CompilationService.Verify (rt_module); - - return ModuleDefinition.ReadModule (rt_module, reader_parameters); - } -#endif - public void RunTest () - { - var module = GetModule (); - if (module == null) - return; - - test_module = module; - test_case.Test (module); - } - - public void Dispose () - { - if (test_module != null) - test_module.Dispose (); - - if (test_resolver != null) - test_resolver.Dispose (); - } - } - - enum TestCaseType { - ReadImmediate, - ReadDeferred, -#if !READ_ONLY - WriteFromImmediate, - WriteFromDeferred, -#endif - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/CallerMemberNameAttribute.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/CallerMemberNameAttribute.cs deleted file mode 100644 index 63bd9b8acb..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/CallerMemberNameAttribute.cs +++ /dev/null @@ -1,10 +0,0 @@ -#if NET_3_5 || NET_4_0 -namespace System.Runtime.CompilerServices { - [AttributeUsage (AttributeTargets.Parameter, Inherited = false)] - public sealed class CallerMemberNameAttribute : Attribute { - public CallerMemberNameAttribute () - { - } - } -} -#endif \ No newline at end of file diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/CompilationService.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/CompilationService.cs deleted file mode 100644 index 5501d571d0..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/CompilationService.cs +++ /dev/null @@ -1,383 +0,0 @@ -using System; -using System.CodeDom.Compiler; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Text; -using System.Reflection; -using NUnit.Framework; - -#if NET_CORE -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Emit; -using CS = Microsoft.CodeAnalysis.CSharp; -using VB = Microsoft.CodeAnalysis.VisualBasic; -#endif - -namespace Mono.Cecil.Tests { - - struct CompilationResult { - internal DateTime source_write_time; - internal string result_file; - - public CompilationResult (DateTime write_time, string result_file) - { - this.source_write_time = write_time; - this.result_file = result_file; - } - } - - public static class Platform { - - public static bool OnMono { - get { return TryGetType ("Mono.Runtime") != null; } - } - - public static bool OnCoreClr { - get { return TryGetType ("System.Runtime.Loader.AssemblyLoadContext, System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") != null; } - } - - static Type TryGetType (string assemblyQualifiedName) - { - try { - // Note that throwOnError=false only suppresses some exceptions, not all. - return Type.GetType(assemblyQualifiedName, throwOnError: false); - } catch { - return null; - } - } - } - - abstract class CompilationService { - - Dictionary files = new Dictionary (); - - bool TryGetResult (string name, out string file_result) - { - file_result = null; - CompilationResult result; - if (!files.TryGetValue (name, out result)) - return false; - - if (result.source_write_time != File.GetLastWriteTime (name)) - return false; - - file_result = result.result_file; - return true; - } - - public string Compile (string name) - { - string result_file; - if (TryGetResult (name, out result_file)) - return result_file; - - result_file = CompileFile (name); - RegisterFile (name, result_file); - return result_file; - } - - void RegisterFile (string name, string result_file) - { - files [name] = new CompilationResult (File.GetLastWriteTime (name), result_file); - } - - protected abstract string CompileFile (string name); - - public static string CompileResource (string name) - { - var extension = Path.GetExtension (name); - if (extension == ".il") - return IlasmCompilationService.Instance.Compile (name); - - if (extension == ".cs" || extension == ".vb") -#if NET_CORE - return RoslynCompilationService.Instance.Compile (name); -#else - return CodeDomCompilationService.Instance.Compile (name); -#endif - throw new NotSupportedException (extension); - } - - protected static string GetCompiledFilePath (string file_name) - { - var tmp_cecil = Path.Combine (Path.GetTempPath (), "cecil"); - if (!Directory.Exists (tmp_cecil)) - Directory.CreateDirectory (tmp_cecil); - - return Path.Combine (tmp_cecil, Path.GetFileName (file_name) + ".dll"); - } - - public static void Verify (string name) - { -#if !NET_CORE - var output = Platform.OnMono ? ShellService.PEDump (name) : ShellService.PEVerify (name); - if (output.ExitCode != 0) - Assert.Fail (output.ToString ()); -#endif - } - } - - class IlasmCompilationService : CompilationService { - - public static readonly IlasmCompilationService Instance = new IlasmCompilationService (); - - protected override string CompileFile (string name) - { - string file = GetCompiledFilePath (name); - - var output = ShellService.ILAsm (name, file); - - AssertAssemblerResult (output); - - return file; - } - - static void AssertAssemblerResult (ShellService.ProcessOutput output) - { - if (output.ExitCode != 0) - Assert.Fail (output.ToString ()); - } - } - -#if NET_CORE - - class RoslynCompilationService : CompilationService { - - public static readonly RoslynCompilationService Instance = new RoslynCompilationService (); - - protected override string CompileFile (string name) - { - var compilation = GetCompilation (name); - var outputName = GetCompiledFilePath (name); - - var result = compilation.Emit (outputName); - Assert.IsTrue (result.Success, GetErrorMessage (result)); - - return outputName; - } - - static Compilation GetCompilation (string name) - { - var assemblyName = Path.GetFileNameWithoutExtension (name); - var source = File.ReadAllText (name); - - var tpa = BaseAssemblyResolver.TrustedPlatformAssemblies.Value; - - var references = new [] - { - MetadataReference.CreateFromFile (tpa ["netstandard"]), - MetadataReference.CreateFromFile (tpa ["mscorlib"]), - MetadataReference.CreateFromFile (tpa ["System.Private.CoreLib"]), - MetadataReference.CreateFromFile (tpa ["System.Runtime"]), - MetadataReference.CreateFromFile (tpa ["System.Console"]), - MetadataReference.CreateFromFile (tpa ["System.Security.AccessControl"]), - }; - - var extension = Path.GetExtension (name); - switch (extension) { - case ".cs": - return CS.CSharpCompilation.Create ( - assemblyName, - new [] { CS.SyntaxFactory.ParseSyntaxTree (source) }, - references, - new CS.CSharpCompilationOptions (OutputKind.DynamicallyLinkedLibrary, optimizationLevel: OptimizationLevel.Release)); - - case ".vb": - return VB.VisualBasicCompilation.Create ( - assemblyName, - new [] { VB.SyntaxFactory.ParseSyntaxTree (source) }, - references, - new VB.VisualBasicCompilationOptions (OutputKind.DynamicallyLinkedLibrary, optimizationLevel: OptimizationLevel.Release)); - - default: - throw new NotSupportedException (); - } - } - - static string GetErrorMessage (EmitResult result) - { - if (result.Success) - return string.Empty; - - var builder = new StringBuilder (); - foreach (var diagnostic in result.Diagnostics) - builder.AppendLine (diagnostic.ToString ()); - - return builder.ToString (); - } - } - -#else - - class CodeDomCompilationService : CompilationService { - - public static readonly CodeDomCompilationService Instance = new CodeDomCompilationService (); - - protected override string CompileFile (string name) - { - string file = GetCompiledFilePath (name); - - using (var provider = GetProvider (name)) { - var parameters = GetDefaultParameters (name); - parameters.IncludeDebugInformation = false; - parameters.GenerateExecutable = false; - parameters.OutputAssembly = file; - - var results = provider.CompileAssemblyFromFile (parameters, name); - AssertCompilerResults (results); - } - - return file; - } - - static void AssertCompilerResults (CompilerResults results) - { - Assert.IsFalse (results.Errors.HasErrors, GetErrorMessage (results)); - } - - static string GetErrorMessage (CompilerResults results) - { - if (!results.Errors.HasErrors) - return string.Empty; - - var builder = new StringBuilder (); - foreach (CompilerError error in results.Errors) - builder.AppendLine (error.ToString ()); - return builder.ToString (); - } - - static CompilerParameters GetDefaultParameters (string name) - { - return GetCompilerInfo (name).CreateDefaultCompilerParameters (); - } - - static CodeDomProvider GetProvider (string name) - { - return GetCompilerInfo (name).CreateProvider (); - } - - static CompilerInfo GetCompilerInfo (string name) - { - return CodeDomProvider.GetCompilerInfo ( - CodeDomProvider.GetLanguageFromExtension (Path.GetExtension (name))); - } - } - -#endif - - class ShellService { - - public class ProcessOutput { - - public int ExitCode; - public string StdOut; - public string StdErr; - - public ProcessOutput (int exitCode, string stdout, string stderr) - { - ExitCode = exitCode; - StdOut = stdout; - StdErr = stderr; - } - - public override string ToString () - { - return StdOut + StdErr; - } - } - - static ProcessOutput RunProcess (string target, params string [] arguments) - { - var stdout = new StringWriter (); - var stderr = new StringWriter (); - - var process = new Process { - StartInfo = new ProcessStartInfo { - FileName = target, - Arguments = string.Join (" ", arguments), - CreateNoWindow = true, - UseShellExecute = false, - RedirectStandardError = true, - RedirectStandardInput = true, - RedirectStandardOutput = true, - }, - }; - - process.Start (); - - process.OutputDataReceived += (_, args) => stdout.Write (args.Data); - process.ErrorDataReceived += (_, args) => stderr.Write (args.Data); - - process.BeginOutputReadLine (); - process.BeginErrorReadLine (); - - process.WaitForExit (); - - return new ProcessOutput (process.ExitCode, stdout.ToString (), stderr.ToString ()); - } - - public static ProcessOutput ILAsm (string source, string output) - { - var ilasm = "ilasm"; - if (!Platform.OnMono) - ilasm = NetFrameworkTool ("ilasm"); - - return RunProcess (ilasm, "/nologo", "/dll", "/out:" + Quote (output), Quote (source)); - } - - static string Quote (string file) - { - return "\"" + file + "\""; - } - - public static ProcessOutput PEVerify (string source) - { - return RunProcess (WinSdkTool ("peverify"), "/nologo", Quote (source)); - } - - public static ProcessOutput PEDump (string source) - { - return RunProcess ("pedump", "--verify code,metadata", Quote (source)); - } - - static string NetFrameworkTool (string tool) - { -#if NET_CORE - return Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Windows), "Microsoft.NET", "Framework", "v4.0.30319", tool + ".exe"); -#else - return Path.Combine ( - Path.GetDirectoryName (typeof (object).Assembly.Location), - tool + ".exe"); -#endif - } - - static string WinSdkTool (string tool) - { - var sdks = new [] { - @"Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7 Tools", - @"Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools", - @"Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools", - @"Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools", - @"Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools", - @"Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools", - @"Microsoft SDKs\Windows\v7.0A\Bin", - }; - - foreach (var sdk in sdks) { - var pgf = IntPtr.Size == 8 - ? Environment.GetEnvironmentVariable("ProgramFiles(x86)") - : Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); - - var exe = Path.Combine ( - Path.Combine (pgf, sdk), - tool + ".exe"); - - if (File.Exists(exe)) - return exe; - } - - return tool; - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/CustomAttributesTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/CustomAttributesTests.cs deleted file mode 100644 index 8ec02705a3..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/CustomAttributesTests.cs +++ /dev/null @@ -1,621 +0,0 @@ -using System; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; - -using Mono.Cecil; -using Mono.Cecil.Metadata; -using Mono.Cecil.PE; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class CustomAttributesTests : BaseTestFixture { - - [Test] - public void StringArgumentOnType () - { - TestCSharp ("CustomAttributes.cs", module => { - var hamster = module.GetType ("Hamster"); - - Assert.IsTrue (hamster.HasCustomAttributes); - Assert.AreEqual (1, hamster.CustomAttributes.Count); - - var attribute = hamster.CustomAttributes [0]; - Assert.AreEqual ("System.Void FooAttribute::.ctor(System.String)", - attribute.Constructor.FullName); - - Assert.IsTrue (attribute.HasConstructorArguments); - Assert.AreEqual (1, attribute.ConstructorArguments.Count); - - AssertArgument ("bar", attribute.ConstructorArguments [0]); - }); - } - - [Test] - public void NullString () - { - TestCSharp ("CustomAttributes.cs", module => { - var dentist = module.GetType ("Dentist"); - - var attribute = GetAttribute (dentist, "Foo"); - Assert.IsNotNull (attribute); - - AssertArgument (null, attribute.ConstructorArguments [0]); - }); - } - - [Test] - public void Primitives1 () - { - TestCSharp ("CustomAttributes.cs", module => { - var steven = module.GetType ("Steven"); - - var attribute = GetAttribute (steven, "Foo"); - Assert.IsNotNull (attribute); - - AssertArgument (-12, attribute.ConstructorArguments [0]); - AssertArgument (242, attribute.ConstructorArguments [1]); - AssertArgument (true, attribute.ConstructorArguments [2]); - AssertArgument (false, attribute.ConstructorArguments [3]); - AssertArgument (4242, attribute.ConstructorArguments [4]); - AssertArgument (-1983, attribute.ConstructorArguments [5]); - AssertArgument ('c', attribute.ConstructorArguments [6]); - }); - } - - [Test] - public void Primitives2 () - { - TestCSharp ("CustomAttributes.cs", module => { - var seagull = module.GetType ("Seagull"); - - var attribute = GetAttribute (seagull, "Foo"); - Assert.IsNotNull (attribute); - - AssertArgument (-100000, attribute.ConstructorArguments [0]); - AssertArgument (200000, attribute.ConstructorArguments [1]); - AssertArgument (12.12f, attribute.ConstructorArguments [2]); - AssertArgument (long.MaxValue, attribute.ConstructorArguments [3]); - AssertArgument (ulong.MaxValue, attribute.ConstructorArguments [4]); - AssertArgument (64.646464, attribute.ConstructorArguments [5]); - }); - } - - [Test] - public void StringArgumentOnAssembly () - { - TestCSharp ("CustomAttributes.cs", module => { - var assembly = module.Assembly; - - var attribute = GetAttribute (assembly, "Foo"); - Assert.IsNotNull (attribute); - - AssertArgument ("bingo", attribute.ConstructorArguments [0]); - }); - } - - [Test] - public void CharArray () - { - TestCSharp ("CustomAttributes.cs", module => { - var rifle = module.GetType ("Rifle"); - - var attribute = GetAttribute (rifle, "Foo"); - Assert.IsNotNull (attribute); - - var argument = attribute.ConstructorArguments [0]; - - Assert.AreEqual ("System.Char[]", argument.Type.FullName); - - var array = argument.Value as CustomAttributeArgument []; - Assert.IsNotNull (array); - - var str = "cecil"; - - Assert.AreEqual (array.Length, str.Length); - - for (int i = 0; i < str.Length; i++) - AssertArgument (str [i], array [i]); - }); - } - - [Test] - public void BoxedArguments () - { - TestCSharp ("CustomAttributes.cs", module => { - var worm = module.GetType ("Worm"); - - var attribute = GetAttribute (worm, "Foo"); - Assert.IsNotNull (attribute); - - Assert.AreEqual (".ctor ((Object:(String:\"2\")), (Object:(I4:2)))", PrettyPrint (attribute)); - }); - } - - [Test] - public void BoxedArraysArguments () - { - TestCSharp ("CustomAttributes.cs", module => { - var sheep = module.GetType ("Sheep"); - - var attribute = GetAttribute (sheep, "Foo"); - Assert.IsNotNull (attribute); - - // [Foo (new object [] { "2", 2, 'c' }, new object [] { new object [] { 1, 2, 3}, null })] - AssertCustomAttribute (".ctor ((Object:(Object[]:{(Object:(String:\"2\")), (Object:(I4:2)), (Object:(Char:'c'))})), (Object:(Object[]:{(Object:(Object[]:{(Object:(I4:1)), (Object:(I4:2)), (Object:(I4:3))})), (Object:(String:null))})))", attribute); - }); - } - - [Test] - public void FieldsAndProperties () - { - TestCSharp ("CustomAttributes.cs", module => { - var angola = module.GetType ("Angola"); - - var attribute = GetAttribute (angola, "Foo"); - Assert.IsNotNull (attribute); - - Assert.AreEqual (2, attribute.Fields.Count); - - var argument = attribute.Fields.Where (a => a.Name == "Pan").First (); - AssertCustomAttributeArgument ("(Object:(Object[]:{(Object:(I4:1)), (Object:(String:\"2\")), (Object:(Char:'3'))}))", argument); - - argument = attribute.Fields.Where (a => a.Name == "PanPan").First (); - AssertCustomAttributeArgument ("(String[]:{(String:\"yo\"), (String:\"yo\")})", argument); - - Assert.AreEqual (2, attribute.Properties.Count); - - argument = attribute.Properties.Where (a => a.Name == "Bang").First (); - AssertArgument (42, argument); - - argument = attribute.Properties.Where (a => a.Name == "Fiou").First (); - AssertArgument (null, argument); - }); - } - - [Test] - public void BoxedStringField () - { - TestCSharp ("CustomAttributes.cs", module => { - var type = module.GetType ("BoxedStringField"); - - var attribute = GetAttribute (type, "Foo"); - Assert.IsNotNull (attribute); - - Assert.AreEqual (1, attribute.Fields.Count); - - var argument = attribute.Fields.Where (a => a.Name == "Pan").First (); - AssertCustomAttributeArgument ("(Object:(String:\"fiouuu\"))", argument); - }); - } - - [Test] - public void TypeDefinitionEnum () - { - TestCSharp ("CustomAttributes.cs", module => { - var zero = module.GetType ("Zero"); - - var attribute = GetAttribute (zero, "Foo"); - Assert.IsNotNull (attribute); - - Assert.AreEqual (1, attribute.ConstructorArguments.Count); - - Assert.AreEqual ((short) 2, attribute.ConstructorArguments [0].Value); - Assert.AreEqual ("Bingo", attribute.ConstructorArguments [0].Type.FullName); - }); - } - - [Test] - public void TypeReferenceEnum () - { - TestCSharp ("CustomAttributes.cs", module => { - var ace = module.GetType ("Ace"); - - var attribute = GetAttribute (ace, "Foo"); - Assert.IsNotNull (attribute); - - Assert.AreEqual (1, attribute.ConstructorArguments.Count); - - Assert.AreEqual ((byte) 0x04, attribute.ConstructorArguments [0].Value); - Assert.AreEqual ("System.Security.AccessControl.AceFlags", attribute.ConstructorArguments [0].Type.FullName); - Assert.AreEqual (module, attribute.ConstructorArguments [0].Type.Module); - }); - } - - [Test] - public void BoxedEnumReference () - { - TestCSharp ("CustomAttributes.cs", module => { - var bzzz = module.GetType ("Bzzz"); - - var attribute = GetAttribute (bzzz, "Foo"); - Assert.IsNotNull (attribute); - - // [Foo (new object [] { Bingo.Fuel, Bingo.Binga }, null, Pan = System.Security.AccessControl.AceFlags.NoPropagateInherit)] - - Assert.AreEqual (2, attribute.ConstructorArguments.Count); - - var argument = attribute.ConstructorArguments [0]; - - AssertCustomAttributeArgument ("(Object:(Object[]:{(Object:(Bingo:2)), (Object:(Bingo:4))}))", argument); - - argument = attribute.ConstructorArguments [1]; - - AssertCustomAttributeArgument ("(Object:(String:null))", argument); - - argument = attribute.Fields.Where (a => a.Name == "Pan").First ().Argument; - - AssertCustomAttributeArgument ("(Object:(System.Security.AccessControl.AceFlags:4))", argument); - }); - } - - [Test] - public void TypeOfTypeDefinition () - { - TestCSharp ("CustomAttributes.cs", module => { - var typed = module.GetType ("Typed"); - - var attribute = GetAttribute (typed, "Foo"); - Assert.IsNotNull (attribute); - - Assert.AreEqual (1, attribute.ConstructorArguments.Count); - - var argument = attribute.ConstructorArguments [0]; - - Assert.AreEqual ("System.Type", argument.Type.FullName); - - var type = argument.Value as TypeDefinition; - Assert.IsNotNull (type); - - Assert.AreEqual ("Bingo", type.FullName); - }); - } - - [Test] - public void TypeOfNestedTypeDefinition () - { - TestCSharp ("CustomAttributes.cs", module => { - var typed = module.GetType ("NestedTyped"); - - var attribute = GetAttribute (typed, "Foo"); - Assert.IsNotNull (attribute); - - Assert.AreEqual (1, attribute.ConstructorArguments.Count); - - var argument = attribute.ConstructorArguments [0]; - - Assert.AreEqual ("System.Type", argument.Type.FullName); - - var type = argument.Value as TypeDefinition; - Assert.IsNotNull (type); - - Assert.AreEqual ("FooAttribute/Token", type.FullName); - }); - } - - [Test] - public void FieldTypeOf () - { - TestCSharp ("CustomAttributes.cs", module => { - var truc = module.GetType ("Truc"); - - var attribute = GetAttribute (truc, "Foo"); - Assert.IsNotNull (attribute); - - var argument = attribute.Fields.Where (a => a.Name == "Chose").First ().Argument; - - Assert.AreEqual ("System.Type", argument.Type.FullName); - - var type = argument.Value as TypeDefinition; - Assert.IsNotNull (type); - - Assert.AreEqual ("Typed", type.FullName); - }); - } - - [Test] - public void EscapedTypeName () - { - TestModule ("bug-185.dll", module => { - var foo = module.GetType ("Foo"); - var foo_do = foo.Methods.Where (m => !m.IsConstructor).First (); - - var attribute = foo_do.CustomAttributes.Where (ca => ca.AttributeType.Name == "AsyncStateMachineAttribute").First (); - - Assert.AreEqual (foo.NestedTypes [0], attribute.ConstructorArguments [0].Value); - - var function = module.GetType ("Function`1"); - - var apply = function.Methods.Where(m => !m.IsConstructor).First (); - - attribute = apply.CustomAttributes.Where (ca => ca.AttributeType.Name == "AsyncStateMachineAttribute").First (); - - Assert.AreEqual (function.NestedTypes [0], attribute.ConstructorArguments [0].Value); - }); - } - - [Test] - public void FieldNullTypeOf () - { - TestCSharp ("CustomAttributes.cs", module => { - var truc = module.GetType ("Machin"); - - var attribute = GetAttribute (truc, "Foo"); - Assert.IsNotNull (attribute); - - var argument = attribute.Fields.Where (a => a.Name == "Chose").First ().Argument; - - Assert.AreEqual ("System.Type", argument.Type.FullName); - - Assert.IsNull (argument.Value); - }); - } - - [Test] - public void OpenGenericTypeOf () - { - TestCSharp ("CustomAttributes.cs", module => { - var open_generic = module.GetType ("OpenGeneric`2"); - Assert.IsNotNull (open_generic); - - var attribute = GetAttribute (open_generic, "Foo"); - Assert.IsNotNull (attribute); - - Assert.AreEqual (1, attribute.ConstructorArguments.Count); - - var argument = attribute.ConstructorArguments [0]; - - Assert.AreEqual ("System.Type", argument.Type.FullName); - - var type = argument.Value as TypeReference; - Assert.IsNotNull (type); - - Assert.AreEqual ("System.Collections.Generic.Dictionary`2", type.FullName); - }); - } - - [Test] - public void ClosedGenericTypeOf () - { - TestCSharp ("CustomAttributes.cs", module => { - var closed_generic = module.GetType ("ClosedGeneric"); - Assert.IsNotNull (closed_generic); - - var attribute = GetAttribute (closed_generic, "Foo"); - Assert.IsNotNull (attribute); - - Assert.AreEqual (1, attribute.ConstructorArguments.Count); - - var argument = attribute.ConstructorArguments [0]; - - Assert.AreEqual ("System.Type", argument.Type.FullName); - - var type = argument.Value as TypeReference; - Assert.IsNotNull (type); - - Assert.AreEqual ("System.Collections.Generic.Dictionary`2[,]>", type.FullName); - }); - } - - [Test] - public void TypeOfArrayOfNestedClass () - { - TestCSharp ("CustomAttributes.cs", module => { - var parent = module.GetType ("Parent"); - Assert.IsNotNull (parent); - - var attribute = GetAttribute (parent, "Foo"); - Assert.IsNotNull (attribute); - - Assert.AreEqual (1, attribute.ConstructorArguments.Count); - - var argument = attribute.ConstructorArguments [0]; - - Assert.AreEqual ("System.Type", argument.Type.FullName); - - var type = argument.Value as TypeReference; - Assert.IsNotNull (type); - - Assert.AreEqual ("Parent/Child[]", type.FullName); - }); - } - - [Test] - public void EmptyBlob () - { - TestIL ("ca-empty-blob.il", module => { - var attribute = module.GetType ("CustomAttribute"); - Assert.AreEqual (1, attribute.CustomAttributes.Count); - Assert.AreEqual (0, attribute.CustomAttributes [0].ConstructorArguments.Count); - }, verify: !Platform.OnMono); - } - - [Test] - public void InterfaceImplementation () - { - IgnoreOnMono(); - - TestIL ("ca-iface-impl.il", module => { - var type = module.GetType ("FooType"); - var iface = type.Interfaces.Single (i => i.InterfaceType.FullName == "IFoo"); - Assert.IsTrue (iface.HasCustomAttributes); - var attributes = iface.CustomAttributes; - Assert.AreEqual (1, attributes.Count); - Assert.AreEqual ("FooAttribute", attributes [0].AttributeType.FullName); - }); - } - -#if !READ_ONLY - [Test] - public void DefineCustomAttributeFromBlob () - { - var file = Path.Combine (Path.GetTempPath (), "CaBlob.dll"); - - var module = ModuleDefinition.CreateModule ("CaBlob.dll", new ModuleParameters { Kind = ModuleKind.Dll, Runtime = TargetRuntime.Net_2_0 }); - var assembly_title_ctor = module.ImportReference (typeof (System.Reflection.AssemblyTitleAttribute).GetConstructor (new [] {typeof (string)})); - - Assert.IsNotNull (assembly_title_ctor); - - var buffer = new ByteBuffer (); - buffer.WriteUInt16 (1); // ca signature - - var title = Encoding.UTF8.GetBytes ("CaBlob"); - - buffer.WriteCompressedUInt32 ((uint) title.Length); - buffer.WriteBytes (title); - - buffer.WriteUInt16 (0); // named arguments - - var blob = new byte [buffer.length]; - Buffer.BlockCopy (buffer.buffer, 0, blob, 0, buffer.length); - - var attribute = new CustomAttribute (assembly_title_ctor, blob); - module.Assembly.CustomAttributes.Add (attribute); - - module.Write (file); - - module = ModuleDefinition.ReadModule (file); - - attribute = GetAttribute (module.Assembly, "AssemblyTitle"); - - Assert.IsNotNull (attribute); - Assert.AreEqual ("CaBlob", (string) attribute.ConstructorArguments [0].Value); - - module.Dispose (); - } -#endif - static void AssertCustomAttribute (string expected, CustomAttribute attribute) - { - Assert.AreEqual (expected, PrettyPrint (attribute)); - } - - static void AssertCustomAttributeArgument (string expected, CustomAttributeNamedArgument named_argument) - { - AssertCustomAttributeArgument (expected, named_argument.Argument); - } - - static void AssertCustomAttributeArgument (string expected, CustomAttributeArgument argument) - { - var result = new StringBuilder (); - PrettyPrint (argument, result); - - Assert.AreEqual (expected, result.ToString ()); - } - - static string PrettyPrint (CustomAttribute attribute) - { - var signature = new StringBuilder (); - signature.Append (".ctor ("); - - for (int i = 0; i < attribute.ConstructorArguments.Count; i++) { - if (i > 0) - signature.Append (", "); - - PrettyPrint (attribute.ConstructorArguments [i], signature); - } - - signature.Append (")"); - return signature.ToString (); - } - - static void PrettyPrint (CustomAttributeArgument argument, StringBuilder signature) - { - var value = argument.Value; - - signature.Append ("("); - - PrettyPrint (argument.Type, signature); - - signature.Append (":"); - - PrettyPrintValue (argument.Value, signature); - - signature.Append (")"); - } - - static void PrettyPrintValue (object value, StringBuilder signature) - { - if (value == null) { - signature.Append ("null"); - return; - } - - var arguments = value as CustomAttributeArgument []; - if (arguments != null) { - signature.Append ("{"); - for (int i = 0; i < arguments.Length; i++) { - if (i > 0) - signature.Append (", "); - - PrettyPrint (arguments [i], signature); - } - signature.Append ("}"); - - return; - } - - switch (Type.GetTypeCode (value.GetType ())) { - case System.TypeCode.String: - signature.AppendFormat ("\"{0}\"", value); - break; - case System.TypeCode.Char: - signature.AppendFormat ("'{0}'", (char) value); - break; - default: - var formattable = value as IFormattable; - if (formattable != null) { - signature.Append (formattable.ToString (null, CultureInfo.InvariantCulture)); - return; - } - - if (value is CustomAttributeArgument) { - PrettyPrint ((CustomAttributeArgument) value, signature); - return; - } - break; - } - } - - static void PrettyPrint (TypeReference type, StringBuilder signature) - { - if (type.IsArray) { - ArrayType array = (ArrayType) type; - signature.AppendFormat ("{0}[]", array.ElementType.etype.ToString ()); - } else if (type.etype == ElementType.None) { - signature.Append (type.FullName); - } else - signature.Append (type.etype.ToString ()); - } - - static void AssertArgument (T value, CustomAttributeNamedArgument named_argument) - { - AssertArgument (value, named_argument.Argument); - } - - static void AssertArgument (T value, CustomAttributeArgument argument) - { - AssertArgument (typeof (T).FullName, (object) value, argument); - } - - static void AssertArgument (string type, object value, CustomAttributeArgument argument) - { - Assert.AreEqual (type, argument.Type.FullName); - Assert.AreEqual (value, argument.Value); - } - - static CustomAttribute GetAttribute (ICustomAttributeProvider owner, string type) - { - Assert.IsTrue (owner.HasCustomAttributes); - - foreach (var attribute in owner.CustomAttributes) - if (attribute.Constructor.DeclaringType.Name.StartsWith (type)) - return attribute; - - return null; - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/EventTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/EventTests.cs deleted file mode 100644 index cb9064b795..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/EventTests.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; - -using Mono.Cecil; -using Mono.Cecil.Metadata; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class EventTests : BaseTestFixture { - - [Test] - public void AbstractMethod () - { - TestCSharp ("Events.cs", module => { - var type = module.GetType ("Foo"); - - Assert.IsTrue (type.HasEvents); - - var events = type.Events; - - Assert.AreEqual (1, events.Count); - - var @event = events [0]; - - Assert.IsNotNull (@event); - Assert.AreEqual ("Bar", @event.Name); - Assert.IsNotNull (@event.EventType); - Assert.AreEqual ("Pan", @event.EventType.FullName); - - Assert.IsNotNull (@event.AddMethod); - Assert.AreEqual (MethodSemanticsAttributes.AddOn, @event.AddMethod.SemanticsAttributes); - Assert.IsNotNull (@event.RemoveMethod); - Assert.AreEqual (MethodSemanticsAttributes.RemoveOn, @event.RemoveMethod.SemanticsAttributes); - }); - } - - [Test] - public void OtherMethod () - { - TestIL ("others.il", module => { - var type = module.GetType ("Others"); - - Assert.IsTrue (type.HasEvents); - - var events = type.Events; - - Assert.AreEqual (1, events.Count); - - var @event = events [0]; - - Assert.IsNotNull (@event); - Assert.AreEqual ("Handler", @event.Name); - Assert.IsNotNull (@event.EventType); - Assert.AreEqual ("System.EventHandler", @event.EventType.FullName); - - Assert.IsTrue (@event.HasOtherMethods); - - Assert.AreEqual (2, @event.OtherMethods.Count); - - var other = @event.OtherMethods [0]; - Assert.AreEqual ("dang_Handler", other.Name); - - other = @event.OtherMethods [1]; - Assert.AreEqual ("fang_Handler", other.Name); - }); - } - - [Test] - public void UnattachedEvent () - { - var int32 = typeof (int).ToDefinition (); - var evt = new EventDefinition ("Event", EventAttributes.None, int32); - - Assert.AreEqual (null, evt.AddMethod); - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/Extensions.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/Extensions.cs deleted file mode 100644 index ab27e9b028..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/Extensions.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using SR = System.Reflection; - -using Mono.Cecil; - -namespace Mono.Cecil.Tests { - - public static class Extensions { - - public static MethodDefinition GetMethod (this TypeDefinition self, string name) - { - return self.Methods.Where (m => m.Name == name).First (); - } - - public static FieldDefinition GetField (this TypeDefinition self, string name) - { - return self.Fields.Where (f => f.Name == name).First (); - } - - public static TypeDefinition ToDefinition (this Type self) - { - var module = ModuleDefinition.ReadModule (new MemoryStream (File.ReadAllBytes (self.Module.FullyQualifiedName))); - return (TypeDefinition) module.LookupToken (self.MetadataToken); - } - - public static MethodDefinition ToDefinition (this SR.MethodBase method) - { - var declaring_type = method.DeclaringType.ToDefinition (); - return (MethodDefinition) declaring_type.Module.LookupToken (method.MetadataToken); - } - - public static FieldDefinition ToDefinition (this SR.FieldInfo field) - { - var declaring_type = field.DeclaringType.ToDefinition (); - return (FieldDefinition) declaring_type.Module.LookupToken (field.MetadataToken); - } - - public static TypeReference MakeGenericType (this TypeReference self, params TypeReference [] arguments) - { - if (self.GenericParameters.Count != arguments.Length) - throw new ArgumentException (); - - var instance = new GenericInstanceType (self); - foreach (var argument in arguments) - instance.GenericArguments.Add (argument); - - return instance; - } - - public static MethodReference MakeGenericMethod (this MethodReference self, params TypeReference [] arguments) - { - if (self.GenericParameters.Count != arguments.Length) - throw new ArgumentException (); - - var instance = new GenericInstanceMethod (self); - foreach (var argument in arguments) - instance.GenericArguments.Add (argument); - - return instance; - } - - public static MethodReference MakeGeneric (this MethodReference self, params TypeReference [] arguments) - { - var reference = new MethodReference { - Name = self.Name, - DeclaringType = self.DeclaringType.MakeGenericType (arguments), - HasThis = self.HasThis, - ExplicitThis = self.ExplicitThis, - ReturnType = self.ReturnType, - CallingConvention = self.CallingConvention, - }; - - foreach (var parameter in self.Parameters) - reference.Parameters.Add (new ParameterDefinition (parameter.ParameterType)); - - foreach (var generic_parameter in self.GenericParameters) - reference.GenericParameters.Add (new GenericParameter (generic_parameter.Name, reference)); - - return reference; - } - - public static FieldReference MakeGeneric (this FieldReference self, params TypeReference [] arguments) - { - return new FieldReference { - Name = self.Name, - DeclaringType = self.DeclaringType.MakeGenericType (arguments), - FieldType = self.FieldType, - }; - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/FieldTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/FieldTests.cs deleted file mode 100644 index 05165d692a..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/FieldTests.cs +++ /dev/null @@ -1,372 +0,0 @@ -using System; - -using Mono.Cecil.PE; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class FieldTests : BaseTestFixture { - - [Test] - public void TypeDefField () - { - TestCSharp ("Fields.cs", module => { - var type = module.Types [1]; - Assert.AreEqual ("Foo", type.Name); - Assert.AreEqual (1, type.Fields.Count); - - var field = type.Fields [0]; - Assert.AreEqual ("bar", field.Name); - Assert.AreEqual (1, field.MetadataToken.RID); - Assert.IsNotNull (field.FieldType); - Assert.AreEqual ("Bar", field.FieldType.FullName); - Assert.AreEqual (TokenType.Field, field.MetadataToken.TokenType); - Assert.IsFalse (field.HasConstant); - Assert.IsNull (field.Constant); - }); - } - - [Test] - public void PrimitiveTypes () - { - TestCSharp ("Fields.cs", module => { - var type = module.GetType ("Baz"); - - AssertField (type, "char", typeof (char)); - AssertField (type, "bool", typeof (bool)); - AssertField (type, "sbyte", typeof (sbyte)); - AssertField (type, "byte", typeof (byte)); - AssertField (type, "int16", typeof (short)); - AssertField (type, "uint16", typeof (ushort)); - AssertField (type, "int32", typeof (int)); - AssertField (type, "uint32", typeof (uint)); - AssertField (type, "int64", typeof (long)); - AssertField (type, "uint64", typeof (ulong)); - AssertField (type, "single", typeof (float)); - AssertField (type, "double", typeof (double)); - AssertField (type, "string", typeof (string)); - AssertField (type, "object", typeof (object)); - }); - } - - [Test] - public void VolatileField () - { - TestCSharp ("Fields.cs", module => { - var type = module.GetType ("Bar"); - - Assert.IsTrue (type.HasFields); - Assert.AreEqual (1, type.Fields.Count); - - var field = type.Fields [0]; - - Assert.AreEqual ("oiseau", field.Name); - Assert.AreEqual ("System.Int32 modreq(System.Runtime.CompilerServices.IsVolatile)", field.FieldType.FullName); - - Assert.IsFalse (field.HasConstant); - }); - } - - [Test] - public void FieldLayout () - { - TestCSharp ("Layouts.cs", module => { - var foo = module.GetType ("Foo"); - Assert.IsNotNull (foo); - - Assert.IsTrue (foo.HasFields); - - var fields = foo.Fields; - - var field = fields [0]; - - Assert.AreEqual ("Bar", field.Name); - Assert.IsTrue (field.HasLayoutInfo); - Assert.AreEqual (0, field.Offset); - - field = fields [1]; - - Assert.AreEqual ("Baz", field.Name); - Assert.IsTrue (field.HasLayoutInfo); - Assert.AreEqual (2, field.Offset); - - field = fields [2]; - - Assert.AreEqual ("Gazonk", field.Name); - Assert.IsTrue (field.HasLayoutInfo); - Assert.AreEqual (4, field.Offset); - }); - } - - [Test] - public void FieldRVA () - { - TestCSharp ("Layouts.cs", module => { - var priv_impl = GetPrivateImplementationType (module); - Assert.IsNotNull (priv_impl); - - Assert.AreEqual (1, priv_impl.Fields.Count); - - var field = priv_impl.Fields [0]; - - Assert.IsNotNull (field); - Assert.AreNotEqual (0, field.RVA); - Assert.IsNotNull (field.InitialValue); - Assert.AreEqual (16, field.InitialValue.Length); - - var buffer = new ByteBuffer (field.InitialValue); - - Assert.AreEqual (1, buffer.ReadUInt32 ()); - Assert.AreEqual (2, buffer.ReadUInt32 ()); - Assert.AreEqual (3, buffer.ReadUInt32 ()); - Assert.AreEqual (4, buffer.ReadUInt32 ()); - }); - } - - [Test] - public void GenericFieldDefinition () - { - TestCSharp ("Generics.cs", module => { - var bar = module.GetType ("Bar`1"); - Assert.IsNotNull (bar); - - Assert.IsTrue (bar.HasGenericParameters); - var t = bar.GenericParameters [0]; - - Assert.AreEqual ("T", t.Name); - Assert.AreEqual (t.Owner, bar); - - var bang = bar.GetField ("bang"); - - Assert.IsNotNull (bang); - - Assert.AreEqual (t, bang.FieldType); - }); - } - - [Test] - public void ArrayFields () - { - TestIL ("types.il", module => { - var types = module.GetType ("Types"); - Assert.IsNotNull (types); - - var rank_two = types.GetField ("rank_two"); - - var array = rank_two.FieldType as ArrayType; - Assert.IsNotNull (array); - - Assert.AreEqual (2, array.Rank); - Assert.IsFalse (array.Dimensions [0].IsSized); - Assert.IsFalse (array.Dimensions [1].IsSized); - - var rank_two_low_bound_zero = types.GetField ("rank_two_low_bound_zero"); - - array = rank_two_low_bound_zero.FieldType as ArrayType; - Assert.IsNotNull (array); - - Assert.AreEqual (2, array.Rank); - Assert.IsTrue (array.Dimensions [0].IsSized); - Assert.AreEqual (0, array.Dimensions [0].LowerBound); - Assert.AreEqual (null, array.Dimensions [0].UpperBound); - Assert.IsTrue (array.Dimensions [1].IsSized); - Assert.AreEqual (0, array.Dimensions [1].LowerBound); - Assert.AreEqual (null, array.Dimensions [1].UpperBound); - - var rank_one_low_bound_m1 = types.GetField ("rank_one_low_bound_m1"); - array = rank_one_low_bound_m1.FieldType as ArrayType; - Assert.IsNotNull (array); - - Assert.AreEqual (1, array.Rank); - Assert.IsTrue (array.Dimensions [0].IsSized); - Assert.AreEqual (-1, array.Dimensions [0].LowerBound); - Assert.AreEqual (4, array.Dimensions [0].UpperBound); - }); - } - - [Test] - public void EnumFieldsConstant () - { - TestCSharp ("Fields.cs", module => { - var pim = module.GetType ("Pim"); - Assert.IsNotNull (pim); - - var field = pim.GetField ("Pam"); - Assert.IsTrue (field.HasConstant); - Assert.AreEqual (1, (int) field.Constant); - - field = pim.GetField ("Poum"); - Assert.AreEqual (2, (int) field.Constant); - }); - } - - [Test] - public void StringAndClassConstant () - { - TestCSharp ("Fields.cs", module => { - var panpan = module.GetType ("PanPan"); - Assert.IsNotNull (panpan); - - var field = panpan.GetField ("Peter"); - Assert.IsTrue (field.HasConstant); - Assert.IsNull (field.Constant); - - field = panpan.GetField ("QQ"); - Assert.AreEqual ("qq", (string) field.Constant); - - field = panpan.GetField ("nil"); - Assert.AreEqual (null, (string) field.Constant); - }); - } - - [Test] - public void ObjectConstant () - { - TestCSharp ("Fields.cs", module => { - var panpan = module.GetType ("PanPan"); - Assert.IsNotNull (panpan); - - var field = panpan.GetField ("obj"); - Assert.IsTrue (field.HasConstant); - Assert.IsNull (field.Constant); - }); - } - - [Test] - public void NullPrimitiveConstant () - { - TestIL ("types.il", module => { - var fields = module.GetType ("Fields"); - - var field = fields.GetField ("int32_nullref"); - Assert.IsTrue (field.HasConstant); - Assert.AreEqual (null, field.Constant); - }); - } - - [Test] - public void ArrayConstant () - { - TestCSharp ("Fields.cs", module => { - var panpan = module.GetType ("PanPan"); - Assert.IsNotNull (panpan); - - var field = panpan.GetField ("ints"); - Assert.IsTrue (field.HasConstant); - Assert.IsNull (field.Constant); - }); - } - - [Test] - public void ConstantCoalescing () - { - TestIL ("types.il", module => { - var fields = module.GetType ("Fields"); - - var field = fields.GetField ("int32_int16"); - Assert.AreEqual ("System.Int32", field.FieldType.FullName); - Assert.IsTrue (field.HasConstant); - Assert.IsInstanceOf (typeof (short), field.Constant); - Assert.AreEqual ((short) 1, field.Constant); - - field = fields.GetField ("int16_int32"); - Assert.AreEqual ("System.Int16", field.FieldType.FullName); - Assert.IsTrue (field.HasConstant); - Assert.IsInstanceOf (typeof (int), field.Constant); - Assert.AreEqual (1, field.Constant); - - field = fields.GetField ("char_int16"); - Assert.AreEqual ("System.Char", field.FieldType.FullName); - Assert.IsTrue (field.HasConstant); - Assert.IsInstanceOf (typeof (short), field.Constant); - Assert.AreEqual ((short) 1, field.Constant); - - field = fields.GetField ("int16_char"); - Assert.AreEqual ("System.Int16", field.FieldType.FullName); - Assert.IsTrue (field.HasConstant); - Assert.IsInstanceOf (typeof (char), field.Constant); - Assert.AreEqual ('s', field.Constant); - }); - } - - [Test] - public void NestedEnumOfGenericTypeDefinition () - { - TestCSharp ("Generics.cs", module => { - var dang = module.GetType ("Bongo`1/Dang"); - Assert.IsNotNull (dang); - - var field = dang.GetField ("Ding"); - Assert.IsNotNull (field); - Assert.AreEqual (2, field.Constant); - - field = dang.GetField ("Dong"); - Assert.IsNotNull (field); - Assert.AreEqual (12, field.Constant); - }); - } - - [Test] - public void MarshalAsFixedStr () - { - TestModule ("marshal.dll", module => { - var boc = module.GetType ("Boc"); - var field = boc.GetField ("a"); - - Assert.IsNotNull (field); - - Assert.IsTrue (field.HasMarshalInfo); - - var info = (FixedSysStringMarshalInfo) field.MarshalInfo; - - Assert.AreEqual (42, info.Size); - }); - } - - [Test] - public void MarshalAsFixedArray () - { - TestModule ("marshal.dll", module => { - var boc = module.GetType ("Boc"); - var field = boc.GetField ("b"); - - Assert.IsNotNull (field); - - Assert.IsTrue (field.HasMarshalInfo); - - var info = (FixedArrayMarshalInfo) field.MarshalInfo; - - Assert.AreEqual (12, info.Size); - Assert.AreEqual (NativeType.Boolean, info.ElementType); - }); - } - - [Test] - public void UnattachedField () - { - var field = new FieldDefinition ("Field", FieldAttributes.Public, typeof (int).ToDefinition ()); - - Assert.IsFalse (field.HasConstant); - Assert.IsNull (field.Constant); - } - - static TypeDefinition GetPrivateImplementationType (ModuleDefinition module) - { - foreach (var type in module.Types) - if (type.FullName.Contains ("")) - return type; - - return null; - } - - static void AssertField (TypeDefinition type, string name, Type expected) - { - var field = type.GetField (name); - Assert.IsNotNull (field, name); - - Assert.AreEqual (expected.FullName, field.FieldType.FullName); - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/Formatter.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/Formatter.cs deleted file mode 100644 index 8b85f2b57b..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/Formatter.cs +++ /dev/null @@ -1,193 +0,0 @@ -using System; -using System.IO; -using Mono.Cecil; -using Mono.Cecil.Cil; - -namespace Mono.Cecil.Tests { - - public static class Formatter { - - public static string FormatInstruction (Instruction instruction) - { - var writer = new StringWriter (); - WriteInstruction (writer, instruction); - return writer.ToString (); - } - - public static string FormatMethodBody (MethodDefinition method) - { - var writer = new StringWriter (); - WriteMethodBody (writer, method); - return writer.ToString (); - } - - public static void WriteMethodBody (TextWriter writer, MethodDefinition method) - { - var body = method.Body; - - WriteVariables (writer, body); - - foreach (Instruction instruction in body.Instructions) { - var sequence_point = body.Method.DebugInformation.GetSequencePoint (instruction); - if (sequence_point != null) { - writer.Write ('\t'); - WriteSequencePoint (writer, sequence_point); - writer.WriteLine (); - } - - writer.Write ('\t'); - WriteInstruction (writer, instruction); - writer.WriteLine (); - } - - WriteExceptionHandlers (writer, body); - } - - static void WriteVariables (TextWriter writer, MethodBody body) - { - var variables = body.Variables; - - writer.Write ('\t'); - writer.Write (".locals {0}(", body.InitLocals ? "init " : string.Empty); - - for (int i = 0; i < variables.Count; i++) { - if (i > 0) - writer.Write (", "); - - var variable = variables [i]; - - writer.Write ("{0} {1}", variable.VariableType, GetVariableName (variable, body)); - } - writer.WriteLine (")"); - } - - static string GetVariableName (VariableDefinition variable, MethodBody body) - { - string name; - if (body.Method.DebugInformation.TryGetName (variable, out name)) - return name; - - return variable.ToString (); - } - - static void WriteInstruction (TextWriter writer, Instruction instruction) - { - writer.Write (FormatLabel (instruction.Offset)); - writer.Write (": "); - writer.Write (instruction.OpCode.Name); - if (null != instruction.Operand) { - writer.Write (' '); - WriteOperand (writer, instruction.Operand); - } - } - - static void WriteSequencePoint (TextWriter writer, SequencePoint sequence_point) - { - if (sequence_point.IsHidden) { - writer.Write (".line hidden '{0}'", sequence_point.Document.Url); - return; - } - - writer.Write (".line {0},{1}:{2},{3} '{4}'", - sequence_point.StartLine, - sequence_point.EndLine, - sequence_point.StartColumn, - sequence_point.EndColumn, - sequence_point.Document.Url); - } - - static string FormatLabel (int offset) - { - string label = "000" + offset.ToString ("x"); - return "IL_" + label.Substring (label.Length - 4); - } - - static string FormatLabel (Instruction instruction) - { - return FormatLabel (instruction.Offset); - } - - static void WriteOperand (TextWriter writer, object operand) - { - if (null == operand) throw new ArgumentNullException ("operand"); - - var target = operand as Instruction; - if (null != target) { - writer.Write (FormatLabel (target.Offset)); - return; - } - - var targets = operand as Instruction []; - if (null != targets) { - WriteLabelList (writer, targets); - return; - } - - string s = operand as string; - if (null != s) { - writer.Write ("\"" + s + "\""); - return; - } - - var parameter = operand as ParameterDefinition; - if (parameter != null) { - writer.Write (ToInvariantCultureString (parameter.Sequence)); - return; - } - - s = ToInvariantCultureString (operand); - writer.Write (s); - } - - static void WriteLabelList (TextWriter writer, Instruction [] instructions) - { - writer.Write ("("); - - for (int i = 0; i < instructions.Length; i++) { - if (i != 0) writer.Write (", "); - writer.Write (FormatLabel (instructions [i].Offset)); - } - - writer.Write (")"); - } - - static void WriteExceptionHandlers (TextWriter writer, MethodBody body) - { - if (!body.HasExceptionHandlers) - return; - - foreach (var handler in body.ExceptionHandlers) { - writer.Write ("\t"); - writer.WriteLine (".try {0} to {1} {2} handler {3} to {4}", - FormatLabel (handler.TryStart), - FormatLabel (handler.TryEnd), - FormatHandlerType (handler), - FormatLabel (handler.HandlerStart), - FormatLabel (handler.HandlerEnd)); - } - } - - static string FormatHandlerType (ExceptionHandler handler) - { - var handler_type = handler.HandlerType; - var type = handler_type.ToString ().ToLowerInvariant (); - - switch (handler_type) { - case ExceptionHandlerType.Catch: - return string.Format ("{0} {1}", type, handler.CatchType.FullName); - case ExceptionHandlerType.Filter: - throw new NotImplementedException (); - default: - return type; - } - } - - public static string ToInvariantCultureString (object value) - { - var convertible = value as IConvertible; - return (null != convertible) - ? convertible.ToString (System.Globalization.CultureInfo.InvariantCulture) - : value.ToString (); - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/ILProcessorTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/ILProcessorTests.cs deleted file mode 100644 index 3d9d1751b2..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/ILProcessorTests.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Linq; - -using Mono.Cecil; -using Mono.Cecil.Cil; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class ILProcessorTests : BaseTestFixture { - - [Test] - public void Append () - { - var method = CreateTestMethod (); - var il = method.GetILProcessor (); - - var ret = il.Create (OpCodes.Ret); - il.Append (ret); - - AssertOpCodeSequence (new [] { OpCodes.Ret }, method); - } - - [Test] - public void InsertBefore () - { - var method = CreateTestMethod (OpCodes.Ldloc_0, OpCodes.Ldloc_2, OpCodes.Ldloc_3); - var il = method.GetILProcessor (); - - var ldloc_2 = method.Instructions.Where (i => i.OpCode == OpCodes.Ldloc_2).First (); - - il.InsertBefore ( - ldloc_2, - il.Create (OpCodes.Ldloc_1)); - - AssertOpCodeSequence (new [] { OpCodes.Ldloc_0, OpCodes.Ldloc_1, OpCodes.Ldloc_2, OpCodes.Ldloc_3 }, method); - } - - [Test] - public void InsertAfter () - { - var method = CreateTestMethod (OpCodes.Ldloc_0, OpCodes.Ldloc_2, OpCodes.Ldloc_3); - var il = method.GetILProcessor (); - - var ldloc_0 = method.Instructions.First (); - - il.InsertAfter ( - ldloc_0, - il.Create (OpCodes.Ldloc_1)); - - AssertOpCodeSequence (new [] { OpCodes.Ldloc_0, OpCodes.Ldloc_1, OpCodes.Ldloc_2, OpCodes.Ldloc_3 }, method); - } - - static void AssertOpCodeSequence (OpCode [] expected, MethodBody body) - { - var opcodes = body.Instructions.Select (i => i.OpCode).ToArray (); - Assert.AreEqual (expected.Length, opcodes.Length); - - for (int i = 0; i < opcodes.Length; i++) - Assert.AreEqual (expected [i], opcodes [i]); - } - - static MethodBody CreateTestMethod (params OpCode [] opcodes) - { - var method = new MethodDefinition { - Name = "function", - }; - - var il = method.Body.GetILProcessor (); - - foreach (var opcode in opcodes) - il.Emit (opcode); - - return method.Body; - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/ImageReadTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/ImageReadTests.cs deleted file mode 100644 index 16b8a7b3f1..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/ImageReadTests.cs +++ /dev/null @@ -1,230 +0,0 @@ -using System; -using System.IO; -using System.Linq; - -using Mono.Cecil; -using Mono.Cecil.Cil; -using Mono.Cecil.PE; -using Mono.Cecil.Metadata; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class ImageReadTests : BaseTestFixture { - - [Test] - public void ImageSections () - { - using (var image = GetResourceImage ("hello.exe")) { - Assert.AreEqual (3, image.Sections.Length); - Assert.AreEqual (".text", image.Sections [0].Name); - Assert.AreEqual (".rsrc", image.Sections [1].Name); - Assert.AreEqual (".reloc", image.Sections [2].Name); - } - } - - [Test] - public void ImageMetadataVersion () - { - using (var image = GetResourceImage ("hello.exe")) - Assert.AreEqual (TargetRuntime.Net_2_0, image.RuntimeVersion.ParseRuntime ()); - - using (var image = GetResourceImage ("hello1.exe")) - Assert.AreEqual (TargetRuntime.Net_1_1, image.RuntimeVersion.ParseRuntime ()); - } - - [Test] - public void ImageModuleKind () - { - using (var image = GetResourceImage ("hello.exe")) - Assert.AreEqual (ModuleKind.Console, image.Kind); - - using (var image = GetResourceImage ("libhello.dll")) - Assert.AreEqual (ModuleKind.Dll, image.Kind); - - using (var image = GetResourceImage ("hellow.exe")) - Assert.AreEqual (ModuleKind.Windows, image.Kind); - } - - [Test] - public void MetadataHeaps () - { - using (var image = GetResourceImage ("hello.exe")) { - Assert.IsNotNull (image.TableHeap); - - Assert.IsNotNull (image.StringHeap); - Assert.AreEqual (string.Empty, image.StringHeap.Read (0)); - Assert.AreEqual ("", image.StringHeap.Read (1)); - - Assert.IsNotNull (image.UserStringHeap); - Assert.AreEqual (string.Empty, image.UserStringHeap.Read (0)); - Assert.AreEqual ("Hello Cecil World !", image.UserStringHeap.Read (1)); - - Assert.IsNotNull (image.GuidHeap); - Assert.AreEqual (new Guid (), image.GuidHeap.Read (0)); - Assert.AreEqual (new Guid ("C3BC2BD3-2576-4D00-A80E-465B5632415F"), image.GuidHeap.Read (1)); - - Assert.IsNotNull (image.BlobHeap); - Assert.AreEqual (new byte [0], image.BlobHeap.Read (0)); - } - } - - [Test] - public void TablesHeap () - { - using (var image = GetResourceImage ("hello.exe")) { - var heap = image.TableHeap; - - Assert.IsNotNull (heap); - - Assert.AreEqual (1, heap [Table.Module].Length); - Assert.AreEqual (4, heap [Table.TypeRef].Length); - Assert.AreEqual (2, heap [Table.TypeDef].Length); - Assert.AreEqual (0, heap [Table.Field].Length); - Assert.AreEqual (2, heap [Table.Method].Length); - Assert.AreEqual (4, heap [Table.MemberRef].Length); - Assert.AreEqual (2, heap [Table.CustomAttribute].Length); - Assert.AreEqual (1, heap [Table.Assembly].Length); - Assert.AreEqual (1, heap [Table.AssemblyRef].Length); - } - } - - [Test] - public void X64Module () - { - TestModule ("hello.x64.exe", module => { - Assert.AreEqual (TargetArchitecture.AMD64, module.Image.Architecture); - Assert.AreEqual (ModuleAttributes.ILOnly, module.Image.Attributes); - }, verify: !Platform.OnMono); - } - - [Test] - public void X64ModuleTextOnlySection () - { - TestModule ("hello.textonly.x64.exe", module => { - Assert.AreEqual (TargetArchitecture.AMD64, module.Image.Architecture); - Assert.AreEqual (ModuleAttributes.ILOnly, module.Image.Attributes); - }, verify: !Platform.OnMono); - } - - [Test] - public void IA64Module () - { - TestModule ("hello.ia64.exe", module => { - Assert.AreEqual (TargetArchitecture.IA64, module.Image.Architecture); - Assert.AreEqual (ModuleAttributes.ILOnly, module.Image.Attributes); - }, verify: !Platform.OnMono); - } - - [Test] - public void X86Module () - { - TestModule ("hello.x86.exe", module => { - Assert.AreEqual (TargetArchitecture.I386, module.Image.Architecture); - Assert.AreEqual (ModuleAttributes.ILOnly | ModuleAttributes.Required32Bit, module.Image.Attributes); - }); - } - - [Test] - public void AnyCpuModule () - { - TestModule ("hello.anycpu.exe", module => { - Assert.AreEqual (TargetArchitecture.I386, module.Image.Architecture); - Assert.AreEqual (ModuleAttributes.ILOnly, module.Image.Attributes); - }); - } - - [Test] - public void DelaySignedAssembly () - { - TestModule ("delay-signed.dll", module => { - Assert.IsNotNull (module.Assembly.Name.PublicKey); - Assert.AreNotEqual (0, module.Assembly.Name.PublicKey.Length); - Assert.AreNotEqual (ModuleAttributes.StrongNameSigned, module.Attributes & ModuleAttributes.StrongNameSigned); - Assert.AreNotEqual (0, module.Image.StrongName.VirtualAddress); - Assert.AreNotEqual (0, module.Image.StrongName.Size); - }); - } - - [Test] - public void WindowsPhoneNonSignedAssembly () - { - TestModule ("wp7.dll", module => { - Assert.AreEqual (0, module.Assembly.Name.PublicKey.Length); - Assert.AreNotEqual (ModuleAttributes.StrongNameSigned, module.Attributes & ModuleAttributes.StrongNameSigned); - Assert.AreEqual (0, module.Image.StrongName.VirtualAddress); - Assert.AreEqual (0, module.Image.StrongName.Size); - }, verify: false); - } - - [Test] - public void MetroAssembly () - { - if (Platform.OnMono) - return; - - TestModule ("metro.exe", module => { - Assert.AreEqual (ModuleCharacteristics.AppContainer, module.Characteristics & ModuleCharacteristics.AppContainer); - }, verify: false); - } - -#if !NET_CORE - [Test] - public void WindowsRuntimeComponentAssembly () - { - var resolver = WindowsRuntimeAssemblyResolver.CreateInstance (); - if (resolver == null) - return; - - TestModule("winrtcomp.winmd", module => { - Assert.IsTrue (module.Assembly.Name.IsWindowsRuntime); - }, verify: false, assemblyResolver: resolver); - } -#endif - [Test] - public void DeterministicAssembly () - { - TestModule ("Deterministic.dll", module => { - Assert.IsTrue (module.HasDebugHeader); - - var header = module.GetDebugHeader (); - - Assert.AreEqual (1, header.Entries.Length); - Assert.IsTrue (header.Entries.Any (e => e.Directory.Type == ImageDebugType.Deterministic)); - }); - } - -#if !READ_ONLY - [Test] - public void ExternalPdbDeterministicAssembly () - { - TestModule ("ExternalPdbDeterministic.dll", module => { - Assert.IsTrue (module.HasDebugHeader); - - var header = module.GetDebugHeader (); - - Assert.AreEqual (2, header.Entries.Length); - Assert.IsTrue (header.Entries.Any (e => e.Directory.Type == ImageDebugType.CodeView)); - Assert.IsTrue (header.Entries.Any (e => e.Directory.Type == ImageDebugType.Deterministic)); - }, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider)); - } - - [Test] - public void EmbeddedPdbDeterministicAssembly () - { - TestModule ("EmbeddedPdbDeterministic.dll", module => { - Assert.IsTrue (module.HasDebugHeader); - - var header = module.GetDebugHeader (); - - Assert.AreEqual (3, header.Entries.Length); - Assert.IsTrue (header.Entries.Any (e => e.Directory.Type == ImageDebugType.CodeView)); - Assert.IsTrue (header.Entries.Any (e => e.Directory.Type == ImageDebugType.Deterministic)); - Assert.IsTrue (header.Entries.Any (e => e.Directory.Type == ImageDebugType.EmbeddedPortablePdb)); - }, symbolReaderProvider: typeof (EmbeddedPortablePdbReaderProvider), symbolWriterProvider: typeof (EmbeddedPortablePdbWriterProvider)); - } -#endif - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/ImportCecilTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/ImportCecilTests.cs deleted file mode 100644 index bc12f5e0db..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/ImportCecilTests.cs +++ /dev/null @@ -1,368 +0,0 @@ -#if !READ_ONLY -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using SR = System.Reflection; -using System.Runtime.CompilerServices; - -using Mono.Cecil.Cil; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class ImportCecilTests : BaseTestFixture { - - [Test] - public void ImportStringByRef () - { - var get_string = Compile> ((module, body) => { - var type = module.Types [1]; - - var method_by_ref = new MethodDefinition { - Name = "ModifyString", - IsPrivate = true, - IsStatic = true, - }; - - type.Methods.Add (method_by_ref); - - method_by_ref.MethodReturnType.ReturnType = module.ImportReference (typeof (void).ToDefinition ()); - - method_by_ref.Parameters.Add (new ParameterDefinition (module.ImportReference (typeof (string).ToDefinition ()))); - method_by_ref.Parameters.Add (new ParameterDefinition (module.ImportReference (new ByReferenceType (typeof (string).ToDefinition ())))); - - var m_il = method_by_ref.Body.GetILProcessor (); - m_il.Emit (OpCodes.Ldarg_1); - m_il.Emit (OpCodes.Ldarg_0); - m_il.Emit (OpCodes.Stind_Ref); - m_il.Emit (OpCodes.Ret); - - var v_0 = new VariableDefinition (module.ImportReference (typeof (string).ToDefinition ())); - body.Variables.Add (v_0); - - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldnull); - il.Emit (OpCodes.Stloc, v_0); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ldloca, v_0); - il.Emit (OpCodes.Call, method_by_ref); - il.Emit (OpCodes.Ldloc_0); - il.Emit (OpCodes.Ret); - }); - - Assert.AreEqual ("foo", get_string ("foo")); - } - - [Test] - public void ImportStringArray () - { - var identity = Compile> ((module, body) => { - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ret); - }); - - var array = new string [2, 2]; - - Assert.AreEqual (array, identity (array)); - } - - [Test] - public void ImportFieldStringEmpty () - { - var get_empty = Compile> ((module, body) => { - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldsfld, module.ImportReference (typeof (string).GetField ("Empty").ToDefinition ())); - il.Emit (OpCodes.Ret); - }); - - Assert.AreEqual ("", get_empty ()); - } - - [Test] - public void ImportStringConcat () - { - var concat = Compile> ((module, body) => { - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ldarg_1); - il.Emit (OpCodes.Call, module.ImportReference (typeof (string).GetMethod ("Concat", new [] { typeof (string), typeof (string) }).ToDefinition ())); - il.Emit (OpCodes.Ret); - }); - - Assert.AreEqual ("FooBar", concat ("Foo", "Bar")); - } - - public class Generic { - public T Field; - - public T Method (T t) - { - return t; - } - - public TS GenericMethod (T t, TS s) - { - return s; - } - - public Generic ComplexGenericMethod (T t, TS s) - { - return new Generic { Field = s }; - } - } - - [Test] - public void ImportGenericField () - { - var get_field = Compile, string>> ((module, body) => { - var generic_def = module.ImportReference (typeof (Generic<>)).Resolve (); - var field_def = generic_def.Fields.Where (f => f.Name == "Field").First (); - - var field_string = field_def.MakeGeneric (module.ImportReference (typeof (string))); - - var field_ref = module.ImportReference (field_string); - - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ldfld, field_ref); - il.Emit (OpCodes.Ret); - }); - - var generic = new Generic { - Field = "foo", - }; - - Assert.AreEqual ("foo", get_field (generic)); - } - - [Test] - public void ImportGenericMethod () - { - var generic_identity = Compile, int, int>> ((module, body) => { - var generic_def = module.ImportReference (typeof (Generic<>)).Resolve (); - var method_def = generic_def.Methods.Where (m => m.Name == "Method").First (); - - var method_int = method_def.MakeGeneric (module.ImportReference (typeof (int))); - var method_ref = module.ImportReference (method_int); - - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ldarg_1); - il.Emit (OpCodes.Callvirt, method_ref); - il.Emit (OpCodes.Ret); - }); - - Assert.AreEqual (42, generic_identity (new Generic (), 42)); - } - - [Test] - public void ImportGenericMethodSpec () - { - var gen_spec_id = Compile, int, int>> ((module, body) => { - var generic_def = module.ImportReference (typeof (Generic<>)).Resolve (); - var method_def = generic_def.Methods.Where (m => m.Name == "GenericMethod").First (); - - var method_string = method_def.MakeGeneric (module.ImportReference (typeof (string))); - - var method_instance = method_string.MakeGenericMethod (module.ImportReference (typeof (int))); - - var method_ref = module.ImportReference (method_instance); - - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ldnull); - il.Emit (OpCodes.Ldarg_1); - il.Emit (OpCodes.Callvirt, method_ref); - il.Emit (OpCodes.Ret); - }); - - Assert.AreEqual (42, gen_spec_id (new Generic (), 42)); - } - - [Test] - public void ImportComplexGenericMethodSpec () - { - var gen_spec_id = Compile, int, int>> ((module, body) => { - var generic_def = module.ImportReference (typeof (Generic<>)).Resolve (); - var method_def = generic_def.Methods.Where (m => m.Name == "ComplexGenericMethod").First (); - - var method_string = method_def.MakeGeneric (module.ImportReference (typeof (string))); - var method_instance = method_string.MakeGenericMethod (module.ImportReference (typeof (int))); - var method_ref = module.ImportReference (method_instance); - - var field_def = generic_def.Fields.Where (f => f.Name == "Field").First (); - var field_int = field_def.MakeGeneric (module.ImportReference (typeof (int))); - var field_ref = module.ImportReference (field_int); - - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ldnull); - il.Emit (OpCodes.Ldarg_1); - il.Emit (OpCodes.Callvirt, method_ref); - il.Emit (OpCodes.Ldfld, field_ref); - il.Emit (OpCodes.Ret); - }); - - Assert.AreEqual (42, gen_spec_id (new Generic (), 42)); - } - - [Test] - public void ImportMethodOnOpenGeneric () - { - var generic = typeof (Generic<>).ToDefinition (); - - using (var module = ModuleDefinition.CreateModule ("foo", ModuleKind.Dll)) { - var method = module.ImportReference (generic.GetMethod ("Method")); - Assert.AreEqual ("T Mono.Cecil.Tests.ImportCecilTests/Generic`1::Method(T)", method.FullName); - } - } - - public class ContextGeneric1Method2 - { - public G1 GenericMethod (R1 r, S1 s) - { - return default (G1); - } - } - - public class ContextGeneric2Method1 - { - public R2 GenericMethod (G2 g, H2 h) - { - return default (R2); - } - } - - public class NestedGenericsA - { - public class NestedGenericsB - { - public class NestedGenericsC - { - public A GenericMethod (B b, C c) - { - return default (A); - } - } - } - } - - [Test] - public void ContextGenericTest () - { - if (Platform.OnCoreClr) - return; - - var module = ModuleDefinition.ReadModule (typeof (ContextGeneric1Method2<>).Module.FullyQualifiedName); - // by mixing open generics with 2 & 1 parameters, we make sure the right context is used (because otherwise, an exception will be thrown) - var type = typeof (ContextGeneric1Method2<>).MakeGenericType (typeof (ContextGeneric2Method1<,>)); - var meth = type.GetMethod ("GenericMethod"); - var imported_type = module.ImportReference (type); - var method = module.ImportReference (meth, imported_type); - Assert.AreEqual ("G1 Mono.Cecil.Tests.ImportCecilTests/ContextGeneric1Method2`1>::GenericMethod(R1,S1)", method.FullName); - - // and the other way around - type = typeof (ContextGeneric2Method1<,>).MakeGenericType (typeof (ContextGeneric1Method2<>), typeof (IList<>)); - meth = type.GetMethod ("GenericMethod"); - imported_type = module.ImportReference (type); - method = module.ImportReference (meth, imported_type); - Assert.AreEqual ("R2 Mono.Cecil.Tests.ImportCecilTests/ContextGeneric2Method1`2,System.Collections.Generic.IList`1>::GenericMethod(G2,H2)", method.FullName); - - // not sure about this one - type = typeof (NestedGenericsA.NestedGenericsB.NestedGenericsC); - meth = type.GetMethod ("GenericMethod"); - imported_type = module.ImportReference (type); - method = module.ImportReference (meth, imported_type); - Assert.AreEqual ("A Mono.Cecil.Tests.ImportCecilTests/NestedGenericsA`1/NestedGenericsB`1/NestedGenericsC`1::GenericMethod(B,C)", method.FullName); - - // We need both the method & type ! - type = typeof (Generic<>).MakeGenericType (typeof (string)); - meth = type.GetMethod ("ComplexGenericMethod"); - imported_type = module.ImportReference (type); - method = module.ImportReference (meth, imported_type); - Assert.AreEqual ("Mono.Cecil.Tests.ImportCecilTests/Generic`1 Mono.Cecil.Tests.ImportCecilTests/Generic`1::ComplexGenericMethod(T,TS)", method.FullName); - } - - delegate void Emitter (ModuleDefinition module, MethodBody body); - - static TDelegate Compile (Emitter emitter, [CallerMemberName] string testMethodName = null) - where TDelegate : class - { - var name = "ImportCecil_" + testMethodName; - - var module = CreateTestModule (name, emitter); - var assembly = LoadTestModule (module); - - return CreateRunDelegate (GetTestCase (name, assembly)); - } - - static TDelegate CreateRunDelegate (Type type) - where TDelegate : class - { - return (TDelegate) (object) Delegate.CreateDelegate (typeof (TDelegate), type.GetMethod ("Run")); - } - - static Type GetTestCase (string name, SR.Assembly assembly) - { - return assembly.GetType (name); - } - - static SR.Assembly LoadTestModule (ModuleDefinition module) - { - using (var stream = new MemoryStream ()) { - module.Write (stream); - File.WriteAllBytes (Path.Combine (Path.Combine (Path.GetTempPath (), "cecil"), module.Name + ".dll"), stream.ToArray ()); - return SR.Assembly.Load (stream.ToArray ()); - } - } - - static ModuleDefinition CreateTestModule (string name, Emitter emitter) - { - var module = CreateModule (name); - - var type = new TypeDefinition ( - "", - name, - TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.Abstract, - module.ImportReference (typeof (object))); - - module.Types.Add (type); - - var method = CreateMethod (type, typeof (TDelegate).GetMethod ("Invoke")); - - emitter (module, method.Body); - - return module; - } - - static MethodDefinition CreateMethod (TypeDefinition type, SR.MethodInfo pattern) - { - var module = type.Module; - - var method = new MethodDefinition { - Name = "Run", - IsPublic = true, - IsStatic = true, - }; - - type.Methods.Add (method); - - method.MethodReturnType.ReturnType = module.ImportReference (pattern.ReturnType); - - foreach (var parameter_pattern in pattern.GetParameters ()) - method.Parameters.Add (new ParameterDefinition (module.ImportReference (parameter_pattern.ParameterType))); - - return method; - } - - static ModuleDefinition CreateModule (string name) - { - return ModuleDefinition.CreateModule (name, ModuleKind.Dll); - } - } -} -#endif diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/ImportReflectionTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/ImportReflectionTests.cs deleted file mode 100644 index c99ca4fc44..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/ImportReflectionTests.cs +++ /dev/null @@ -1,430 +0,0 @@ -#if !READ_ONLY -using System; -using System.Collections.Generic; -using System.IO; -using SR = System.Reflection; -using System.Runtime.CompilerServices; - -using Mono.Cecil.Cil; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class ImportReflectionTests : BaseTestFixture { - - [Test] - public void ImportString () - { - var get_string = Compile> ((_, body) => { - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldstr, "yo dawg!"); - il.Emit (OpCodes.Ret); - }); - - Assert.AreEqual ("yo dawg!", get_string ()); - } - - [Test] - public void ImportInt () - { - var add = Compile> ((_, body) => { - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ldarg_1); - il.Emit (OpCodes.Add); - il.Emit (OpCodes.Ret); - }); - - Assert.AreEqual (42, add (40, 2)); - } - - [Test] - public void ImportStringByRef () - { - var get_string = Compile> ((module, body) => { - var type = module.Types [1]; - - var method_by_ref = new MethodDefinition { - Name = "ModifyString", - IsPrivate = true, - IsStatic = true, - }; - - type.Methods.Add (method_by_ref); - - method_by_ref.MethodReturnType.ReturnType = module.ImportReference (typeof (void)); - - method_by_ref.Parameters.Add (new ParameterDefinition (module.ImportReference (typeof (string)))); - method_by_ref.Parameters.Add (new ParameterDefinition (module.ImportReference (typeof (string).MakeByRefType ()))); - - var m_il = method_by_ref.Body.GetILProcessor (); - m_il.Emit (OpCodes.Ldarg_1); - m_il.Emit (OpCodes.Ldarg_0); - m_il.Emit (OpCodes.Stind_Ref); - m_il.Emit (OpCodes.Ret); - - var v_0 = new VariableDefinition (module.ImportReference (typeof (string))); - body.Variables.Add (v_0); - - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldnull); - il.Emit (OpCodes.Stloc, v_0); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ldloca, v_0); - il.Emit (OpCodes.Call, method_by_ref); - il.Emit (OpCodes.Ldloc_0); - il.Emit (OpCodes.Ret); - }); - - Assert.AreEqual ("foo", get_string ("foo")); - } - - [Test] - public void ImportStringArray () - { - var identity = Compile> ((module, body) => { - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ret); - }); - - var array = new string [2, 2]; - - Assert.AreEqual (array, identity (array)); - } - - [Test] - public void ImportFieldStringEmpty () - { - var get_empty = Compile> ((module, body) => { - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldsfld, module.ImportReference (typeof (string).GetField ("Empty"))); - il.Emit (OpCodes.Ret); - }); - - Assert.AreEqual ("", get_empty ()); - } - - [Test] - public void ImportStringConcat () - { - var concat = Compile> ((module, body) => { - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ldarg_1); - il.Emit (OpCodes.Call, module.ImportReference (typeof (string).GetMethod ("Concat", new [] { typeof (string), typeof (string) }))); - il.Emit (OpCodes.Ret); - }); - - Assert.AreEqual ("FooBar", concat ("Foo", "Bar")); - } - - [Test] - public void GeneratedAssemblyCulture () - { - var id = Compile> ((module, body) => { - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ret); - }); - - Assert.AreEqual ("", id.Method.DeclaringType.Assembly.GetName ().CultureInfo.Name); - } - - public class Generic { - public T Field; - - public T Method (T t) - { - return t; - } - - public TS GenericMethod (T t, TS s) - { - return s; - } - - public Generic ComplexGenericMethod (T t, TS s) - { - return new Generic { Field = s }; - } - } - - [Test] - public void ImportGenericField () - { - if (Platform.OnCoreClr) - return; - - var get_field = Compile, string>> ((module, body) => { - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ldfld, module.ImportReference (typeof (Generic).GetField ("Field"))); - il.Emit (OpCodes.Ret); - }); - - var generic = new Generic { - Field = "foo", - }; - - Assert.AreEqual ("foo", get_field (generic)); - } - - [Test] - public void ImportGenericMethod () - { - if (Platform.OnCoreClr) - return; - - var generic_identity = Compile, int, int>> ((module, body) => { - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ldarg_1); - il.Emit (OpCodes.Callvirt, module.ImportReference (typeof (Generic).GetMethod ("Method"))); - il.Emit (OpCodes.Ret); - }); - - Assert.AreEqual (42, generic_identity (new Generic (), 42)); - } - - [Test] - public void ImportGenericMethodSpec () - { - if (Platform.OnCoreClr) - return; - - var gen_spec_id = Compile, int, int>> ((module, body) => { - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ldnull); - il.Emit (OpCodes.Ldarg_1); - il.Emit (OpCodes.Callvirt, module.ImportReference (typeof (Generic).GetMethod ("GenericMethod").MakeGenericMethod (typeof (int)))); - il.Emit (OpCodes.Ret); - }); - - Assert.AreEqual (42, gen_spec_id (new Generic (), 42)); - } - - [Test] - public void ImportComplexGenericMethodSpec () - { - if (Platform.OnCoreClr) - return; - - var gen_spec_id = Compile, int, int>> ((module, body) => { - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ldarg_0); - il.Emit (OpCodes.Ldnull); - il.Emit (OpCodes.Ldarg_1); - il.Emit (OpCodes.Callvirt, module.ImportReference (typeof (Generic).GetMethod ("ComplexGenericMethod").MakeGenericMethod (typeof (int)))); - il.Emit (OpCodes.Ldfld, module.ImportReference (typeof (Generic).GetField ("Field"))); - il.Emit (OpCodes.Ret); - }); - - Assert.AreEqual (42, gen_spec_id (new Generic (), 42)); - } - - public class Foo { - public List list; - } - - [Test] - public void ImportGenericTypeDefOrOpen () - { - using (var module = typeof (Foo<>).ToDefinition ().Module) { - var foo_def = module.ImportReference (typeof (Foo<>)); - var foo_open = module.ImportReference (typeof (Foo<>), foo_def); - - Assert.AreEqual ("Mono.Cecil.Tests.ImportReflectionTests/Foo`1", foo_def.FullName); - Assert.AreEqual ("Mono.Cecil.Tests.ImportReflectionTests/Foo`1", foo_open.FullName); - } - } - - [Test] - public void ImportGenericTypeFromContext () - { - var list_foo = typeof (Foo<>).GetField ("list").FieldType; - var generic_list_foo_open = typeof (Generic<>).MakeGenericType (list_foo); - - var foo_def = typeof (Foo<>).ToDefinition (); - using (var module = foo_def.Module) { - var generic_foo = module.ImportReference (generic_list_foo_open, foo_def); - - Assert.AreEqual ("Mono.Cecil.Tests.ImportReflectionTests/Generic`1>", - generic_foo.FullName); - } - } - - [Test] - public void ImportGenericTypeDefFromContext () - { - var foo_open = typeof (Foo<>).MakeGenericType (typeof (Foo<>).GetGenericArguments () [0]); - var generic_foo_open = typeof (Generic<>).MakeGenericType (foo_open); - - var foo_def = typeof (Foo<>).ToDefinition (); - using (var module = foo_def.Module) { - var generic_foo = module.ImportReference (generic_foo_open, foo_def); - - Assert.AreEqual ("Mono.Cecil.Tests.ImportReflectionTests/Generic`1>", - generic_foo.FullName); - } - } - - [Test] - public void ImportArrayTypeDefFromContext () - { - var foo_open = typeof (Foo<>).MakeGenericType (typeof (Foo<>).GetGenericArguments () [0]); - var foo_open_array = foo_open.MakeArrayType (); - - var foo_def = typeof (Foo<>).ToDefinition (); - using (var module = foo_def.Module) { - var array_foo = module.ImportReference (foo_open_array, foo_def); - - Assert.AreEqual ("Mono.Cecil.Tests.ImportReflectionTests/Foo`1[]", - array_foo.FullName); - } - } - - [Test] - public void ImportGenericFieldFromContext () - { - if (Platform.OnCoreClr) - return; - - var list_foo = typeof (Foo<>).GetField ("list").FieldType; - var generic_list_foo_open = typeof (Generic<>).MakeGenericType (list_foo); - var generic_list_foo_open_field = generic_list_foo_open.GetField ("Field"); - - var foo_def = typeof (Foo<>).ToDefinition (); - using (var module = foo_def.Module) { - var generic_field = module.ImportReference (generic_list_foo_open_field, foo_def); - - Assert.AreEqual ("T Mono.Cecil.Tests.ImportReflectionTests/Generic`1>::Field", - generic_field.FullName); - } - } - - [Test] - public void ImportGenericMethodFromContext () - { - if (Platform.OnCoreClr) - return; - - var list_foo = typeof (Foo<>).GetField ("list").FieldType; - var generic_list_foo_open = typeof (Generic<>).MakeGenericType (list_foo); - var generic_list_foo_open_method = generic_list_foo_open.GetMethod ("Method"); - - var foo_def = typeof (Foo<>).ToDefinition (); - using (var module = foo_def.Module) { - var generic_method = module.ImportReference (generic_list_foo_open_method, foo_def); - - Assert.AreEqual ("T Mono.Cecil.Tests.ImportReflectionTests/Generic`1>::Method(T)", - generic_method.FullName); - } - } - - [Test] - public void ImportMethodOnOpenGenericType () - { - using (var module = typeof (Generic<>).ToDefinition ().Module) { - var method = module.ImportReference (typeof (Generic<>).GetMethod ("Method")); - - Assert.AreEqual ("T Mono.Cecil.Tests.ImportReflectionTests/Generic`1::Method(T)", method.FullName); - } - } - - [Test] - public void ImportGenericMethodOnOpenGenericType () - { - using (var module = typeof (Generic<>).ToDefinition ().Module) { - var generic_method = module.ImportReference (typeof (Generic<>).GetMethod ("GenericMethod")); - - Assert.AreEqual ("TS Mono.Cecil.Tests.ImportReflectionTests/Generic`1::GenericMethod(T,TS)", generic_method.FullName); - - generic_method = module.ImportReference (typeof (Generic<>).GetMethod ("GenericMethod"), generic_method); - - Assert.AreEqual ("TS Mono.Cecil.Tests.ImportReflectionTests/Generic`1::GenericMethod(T,TS)", generic_method.FullName); - } - } - - delegate void Emitter (ModuleDefinition module, MethodBody body); - - static TDelegate Compile (Emitter emitter, [CallerMemberName] string testMethodName = null) - where TDelegate : class - { - var name = "ImportReflection_" + testMethodName; - - var module = CreateTestModule (name, emitter); - var assembly = LoadTestModule (module); - - return CreateRunDelegate (GetTestCase (name, assembly)); - } - - static TDelegate CreateRunDelegate (Type type) - where TDelegate : class - { - return (TDelegate) (object) Delegate.CreateDelegate (typeof (TDelegate), type.GetMethod ("Run")); - } - - static Type GetTestCase (string name, SR.Assembly assembly) - { - return assembly.GetType (name); - } - - static SR.Assembly LoadTestModule (ModuleDefinition module) - { - using (var stream = new MemoryStream ()) { - module.Write (stream); - File.WriteAllBytes (Path.Combine (Path.Combine (Path.GetTempPath (), "cecil"), module.Name + ".dll"), stream.ToArray ()); - return SR.Assembly.Load (stream.ToArray ()); - } - } - - static ModuleDefinition CreateTestModule (string name, Emitter emitter) - { - var module = CreateModule (name); - - var type = new TypeDefinition ( - "", - name, - TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.Abstract, - module.ImportReference (typeof (object))); - - module.Types.Add (type); - - var method = CreateMethod (type, typeof (TDelegate).GetMethod ("Invoke")); - - emitter (module, method.Body); - - return module; - } - - static MethodDefinition CreateMethod (TypeDefinition type, SR.MethodInfo pattern) - { - var module = type.Module; - - var method = new MethodDefinition { - Name = "Run", - IsPublic = true, - IsStatic = true, - }; - - type.Methods.Add (method); - - method.MethodReturnType.ReturnType = module.ImportReference (pattern.ReturnType); - - foreach (var parameter_pattern in pattern.GetParameters ()) - method.Parameters.Add (new ParameterDefinition (module.ImportReference (parameter_pattern.ParameterType))); - - return method; - } - - static ModuleDefinition CreateModule (string name) - { - return ModuleDefinition.CreateModule (name, ModuleKind.Dll); - } - } -} -#endif diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/MethodBodyTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/MethodBodyTests.cs deleted file mode 100644 index 15fd5fb42a..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/MethodBodyTests.cs +++ /dev/null @@ -1,453 +0,0 @@ -using System; -using System.Linq; - -using Mono.Cecil; -using Mono.Cecil.Cil; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class MethodBodyTests : BaseTestFixture { - - [Test] - public void MultiplyMethod () - { - TestIL ("hello.il", module => { - var foo = module.GetType ("Foo"); - Assert.IsNotNull (foo); - - var bar = foo.GetMethod ("Bar"); - Assert.IsNotNull (bar); - Assert.IsTrue (bar.IsIL); - - AssertCode (@" - .locals init (System.Int32 V_0) - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: mul - IL_0003: stloc.0 - IL_0004: ldloc.0 - IL_0005: call System.Void Foo::Baz(System.Int32) - IL_000a: ret -", bar); - }); - } - - [Test] - public void PrintStringEmpty () - { - TestIL ("hello.il", module => { - var foo = module.GetType ("Foo"); - Assert.IsNotNull (foo); - - var print_empty = foo.GetMethod ("PrintEmpty"); - Assert.IsNotNull (print_empty); - - AssertCode (@" - .locals () - IL_0000: ldsfld System.String System.String::Empty - IL_0005: call System.Void System.Console::WriteLine(System.String) - IL_000a: ret -", print_empty); - }); - } - - [Test] - public void Branch () - { - TestModule ("libhello.dll", module => { - var lib = module.GetType ("Library"); - Assert.IsNotNull (lib); - - var method = lib.GetMethod ("GetHelloString"); - Assert.IsNotNull (method); - - AssertCode (@" - .locals init (System.String V_0) - IL_0000: nop - IL_0001: ldstr ""hello world of tomorrow"" - IL_0006: stloc.0 - IL_0007: br.s IL_0009 - IL_0009: ldloc.0 - IL_000a: ret -", method); - }); - } - - [Test] - public void Switch () - { - TestModule ("switch.exe", module => { - var program = module.GetType ("Program"); - Assert.IsNotNull (program); - - var method = program.GetMethod ("Main"); - Assert.IsNotNull (method); - - AssertCode (@" - .locals init (System.Int32 V_0) - IL_0000: ldarg.0 - IL_0001: ldlen - IL_0002: conv.i4 - IL_0003: stloc.0 - IL_0004: ldloc.0 - IL_0005: ldc.i4.8 - IL_0006: bgt.s IL_0026 - IL_0008: ldloc.0 - IL_0009: ldc.i4.1 - IL_000a: sub - IL_000b: switch (IL_0032, IL_0034, IL_0038, IL_0034) - IL_0020: ldloc.0 - IL_0021: ldc.i4.8 - IL_0022: beq.s IL_0036 - IL_0024: br.s IL_0038 - IL_0026: ldloc.0 - IL_0027: ldc.i4.s 16 - IL_0029: beq.s IL_0036 - IL_002b: ldloc.0 - IL_002c: ldc.i4.s 32 - IL_002e: beq.s IL_0036 - IL_0030: br.s IL_0038 - IL_0032: ldc.i4.0 - IL_0033: ret - IL_0034: ldc.i4.1 - IL_0035: ret - IL_0036: ldc.i4.2 - IL_0037: ret - IL_0038: ldc.i4.s 42 - IL_003a: ret -", method); - }); - } - - [Test] - public void MethodSpec () - { - TestIL ("methodspecs.il", module => { - var tamtam = module.GetType ("Tamtam"); - - var bar = tamtam.GetMethod ("Bar"); - Assert.IsNotNull (bar); - - AssertCode (@" - .locals () - IL_0000: ldc.i4.2 - IL_0001: call System.Void Tamtam::Foo(TFoo) - IL_0006: ret -", bar); - }); - } - - [Test] - public void NestedTryCatchFinally () - { - TestModule ("catch.exe", module => { - var program = module.GetType ("Program"); - var main = program.GetMethod ("Main"); - Assert.IsNotNull (main); - - AssertCode (@" - .locals () - IL_0000: call System.Void Program::Foo() - IL_0005: leave.s IL_000d - IL_0007: call System.Void Program::Baz() - IL_000c: endfinally - IL_000d: leave.s IL_001f - IL_000f: pop - IL_0010: call System.Void Program::Bar() - IL_0015: leave.s IL_001f - IL_0017: pop - IL_0018: call System.Void Program::Bar() - IL_001d: leave.s IL_001f - IL_001f: leave.s IL_0027 - IL_0021: call System.Void Program::Baz() - IL_0026: endfinally - IL_0027: ret - .try IL_0000 to IL_0007 finally handler IL_0007 to IL_000d - .try IL_0000 to IL_000f catch System.ArgumentException handler IL_000f to IL_0017 - .try IL_0000 to IL_000f catch System.Exception handler IL_0017 to IL_001f - .try IL_0000 to IL_0021 finally handler IL_0021 to IL_0027 -", main); - }); - } - - [Test] - public void FunctionPointersAndCallSites () - { - TestModule ("fptr.exe", module => { - var type = module.Types [0]; - var start = type.GetMethod ("Start"); - Assert.IsNotNull (start); - - AssertCode (@" - .locals init () - IL_0000: ldc.i4.1 - IL_0001: call method System.Int32 *(System.Int32) MakeDecision::Decide() - IL_0006: calli System.Int32(System.Int32) - IL_000b: call System.Void System.Console::WriteLine(System.Int32) - IL_0010: ldc.i4.1 - IL_0011: call method System.Int32 *(System.Int32) MakeDecision::Decide() - IL_0016: calli System.Int32(System.Int32) - IL_001b: call System.Void System.Console::WriteLine(System.Int32) - IL_0020: ldc.i4.1 - IL_0021: call method System.Int32 *(System.Int32) MakeDecision::Decide() - IL_0026: calli System.Int32(System.Int32) - IL_002b: call System.Void System.Console::WriteLine(System.Int32) - IL_0030: ret -", start); - }, verify: false); - } - - [Test] - public void ThisParameter () - { - TestIL ("hello.il", module => { - var type = module.GetType ("Foo"); - var method = type.GetMethod ("Gazonk"); - - Assert.IsNotNull (method); - - AssertCode (@" - .locals () - IL_0000: ldarg 0 - IL_0004: pop - IL_0005: ret -", method); - - Assert.AreEqual (method.Body.ThisParameter.ParameterType, type); - Assert.AreEqual (method.Body.ThisParameter, method.Body.Instructions [0].Operand); - }); - } - - [Test] - public void ThisParameterStaticMethod () - { - var static_method = typeof (ModuleDefinition).ToDefinition ().Methods.Where (m => m.IsStatic).First (); - Assert.IsNull (static_method.Body.ThisParameter); - } - - [Test] - public void ThisParameterPrimitive () - { - var int32 = typeof (int).ToDefinition (); - var int_to_string = int32.Methods.Where (m => m.Name == "ToString" && m.Parameters.Count == 0).First(); - Assert.IsNotNull (int_to_string); - - var this_parameter_type = int_to_string.Body.ThisParameter.ParameterType; - Assert.IsTrue (this_parameter_type.IsByReference); - - var element_type = ((ByReferenceType) this_parameter_type).ElementType; - Assert.AreEqual (int32, element_type); - } - - [Test] - public void ThisParameterValueType () - { - var token = typeof (MetadataToken).ToDefinition (); - var token_to_string = token.Methods.Where (m => m.Name == "ToString" && m.Parameters.Count == 0).First (); - Assert.IsNotNull (token_to_string); - - var this_parameter_type = token_to_string.Body.ThisParameter.ParameterType; - Assert.IsTrue (this_parameter_type.IsByReference); - - var element_type = ((ByReferenceType) this_parameter_type).ElementType; - Assert.AreEqual (token, element_type); - } - - [Test] - public void ThisParameterObject () - { - var module = typeof (MethodBodyTests).ToDefinition ().Module; - var @object = module.TypeSystem.Object.Resolve (); - var method = @object.Methods.Where (m => m.HasBody).First (); - - var type = method.Body.ThisParameter.ParameterType; - Assert.IsFalse (type.IsValueType); - Assert.IsFalse (type.IsPrimitive); - Assert.IsFalse (type.IsPointer); - } - - [Test] - public void FilterMaxStack () - { - TestIL ("hello.il", module => { - var type = module.GetType ("Foo"); - var method = type.GetMethod ("TestFilter"); - - Assert.IsNotNull (method); - Assert.AreEqual (2, method.Body.MaxStackSize); - }); - } - - [Test] - public void BranchOutsideMethod () - { - IgnoreOnMono (); - - TestIL ("branch-out.il", module => { - var type = module.GetType ("Foo"); - var method = type.GetMethod ("BranchOutside"); - - Assert.IsNotNull (method); - Assert.IsNotNull (method.Body); - - var leave = method.Body.Instructions [0]; - Assert.AreEqual (OpCodes.Leave, leave.OpCode); - Assert.IsNull (leave.Operand); - Assert.AreEqual ("IL_0000: leave", leave.ToString ()); - }, verify: false); - } - - [Test] - public void Iterator () - { - TestModule ("iterator.exe", module => { - var method = module.GetType ("Program").GetMethod ("GetLittleArgs"); - Assert.IsNotNull (method.Body); - }); - } - - [Test] - public void LoadString () - { - TestCSharp ("CustomAttributes.cs", module => { - var type = module.GetType ("FooAttribute"); - var get_fiou = type.GetMethod ("get_Fiou"); - Assert.IsNotNull (get_fiou); - - var ldstr = get_fiou.Body.Instructions.Where (i => i.OpCode == OpCodes.Ldstr).First (); - Assert.AreEqual ("fiou", ldstr.Operand); - }); - } - - [Test] - public void UnattachedMethodBody () - { - var system_void = typeof (void).ToDefinition (); - var method = new MethodDefinition ("NewMethod", MethodAttributes.Assembly | MethodAttributes.Static, system_void); - var body = new MethodBody (method); - var il = body.GetILProcessor (); - il.Emit (OpCodes.Ret); - method.Body = body; - - Assert.AreEqual (body, method.Body); - } - - [Test] - public void AddInstruction () - { - var object_ref = new TypeReference ("System", "Object", null, null, false); - var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref); - var body = new MethodBody (method); - - var il = body.GetILProcessor (); - - var first = il.Create (OpCodes.Nop); - var second = il.Create (OpCodes.Nop); - - body.Instructions.Add (first); - body.Instructions.Add (second); - - Assert.IsNull (first.Previous); - Assert.AreEqual (second, first.Next); - Assert.AreEqual (first, second.Previous); - Assert.IsNull (second.Next); - } - - [Test] - public void InsertInstruction () - { - var object_ref = new TypeReference ("System", "Object", null, null, false); - var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref); - var body = new MethodBody (method); - - var il = body.GetILProcessor (); - - var first = il.Create (OpCodes.Nop); - var second = il.Create (OpCodes.Nop); - var third = il.Create (OpCodes.Nop); - - body.Instructions.Add (first); - body.Instructions.Add (third); - - Assert.IsNull (first.Previous); - Assert.AreEqual (third, first.Next); - Assert.AreEqual (first, third.Previous); - Assert.IsNull (third.Next); - - body.Instructions.Insert (1, second); - - Assert.IsNull (first.Previous); - Assert.AreEqual (second, first.Next); - Assert.AreEqual (first, second.Previous); - Assert.AreEqual (third, second.Next); - Assert.AreEqual (second, third.Previous); - Assert.IsNull (third.Next); - } - - [Test] - public void InsertAfterLastInstruction () - { - var object_ref = new TypeReference ("System", "Object", null, null, false); - var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref); - var body = new MethodBody (method); - - var il = body.GetILProcessor (); - - var first = il.Create (OpCodes.Nop); - var second = il.Create (OpCodes.Nop); - var third = il.Create (OpCodes.Nop); - - body.Instructions.Add (first); - body.Instructions.Add (second); - - Assert.IsNull (first.Previous); - Assert.AreEqual (second, first.Next); - Assert.AreEqual (first, second.Previous); - Assert.IsNull (second.Next); - - body.Instructions.Insert (2, third); - - Assert.IsNull (first.Previous); - Assert.AreEqual (second, first.Next); - Assert.AreEqual (first, second.Previous); - Assert.AreEqual (third, second.Next); - Assert.AreEqual (second, third.Previous); - Assert.IsNull (third.Next); - } - - [Test] - public void RemoveInstruction () - { - var object_ref = new TypeReference ("System", "Object", null, null, false); - var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref); - var body = new MethodBody (method); - - var il = body.GetILProcessor (); - - var first = il.Create (OpCodes.Nop); - var second = il.Create (OpCodes.Nop); - var third = il.Create (OpCodes.Nop); - - body.Instructions.Add (first); - body.Instructions.Add (second); - body.Instructions.Add (third); - - Assert.IsNull (first.Previous); - Assert.AreEqual (second, first.Next); - Assert.AreEqual (first, second.Previous); - Assert.AreEqual (third, second.Next); - Assert.AreEqual (second, third.Previous); - Assert.IsNull (third.Next); - - body.Instructions.Remove (second); - - Assert.IsNull (first.Previous); - Assert.AreEqual (third, first.Next); - Assert.AreEqual (first, third.Previous); - Assert.IsNull (third.Next); - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/MethodTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/MethodTests.cs deleted file mode 100644 index b878613c06..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/MethodTests.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System; -using System.Linq; - -using Mono.Cecil; -using Mono.Cecil.Metadata; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class MethodTests : BaseTestFixture { - - [Test] - public void AbstractMethod () - { - TestCSharp ("Methods.cs", module => { - var type = module.Types [1]; - Assert.AreEqual ("Foo", type.Name); - Assert.AreEqual (2, type.Methods.Count); - - var method = type.GetMethod ("Bar"); - Assert.AreEqual ("Bar", method.Name); - Assert.IsTrue (method.IsAbstract); - Assert.IsNotNull (method.ReturnType); - - Assert.AreEqual (1, method.Parameters.Count); - - var parameter = method.Parameters [0]; - - Assert.AreEqual ("a", parameter.Name); - Assert.AreEqual ("System.Int32", parameter.ParameterType.FullName); - }); - } - - [Test] - public void SimplePInvoke () - { - TestCSharp ("Methods.cs", module => { - var bar = module.GetType ("Bar"); - var pan = bar.GetMethod ("Pan"); - - Assert.IsTrue (pan.IsPInvokeImpl); - Assert.IsNotNull (pan.PInvokeInfo); - - Assert.AreEqual ("Pan", pan.PInvokeInfo.EntryPoint); - Assert.IsNotNull (pan.PInvokeInfo.Module); - Assert.AreEqual ("foo.dll", pan.PInvokeInfo.Module.Name); - }); - } - - [Test] - public void GenericMethodDefinition () - { - TestCSharp ("Generics.cs", module => { - var baz = module.GetType ("Baz"); - - var gazonk = baz.GetMethod ("Gazonk"); - - Assert.IsNotNull (gazonk); - - Assert.IsTrue (gazonk.HasGenericParameters); - Assert.AreEqual (1, gazonk.GenericParameters.Count); - Assert.AreEqual ("TBang", gazonk.GenericParameters [0].Name); - }); - } - - [Test] - public void ReturnGenericInstance () - { - TestCSharp ("Generics.cs", module => { - var bar = module.GetType ("Bar`1"); - - var self = bar.GetMethod ("Self"); - Assert.IsNotNull (self); - - var bar_t = self.ReturnType; - - Assert.IsTrue (bar_t.IsGenericInstance); - - var bar_t_instance = (GenericInstanceType) bar_t; - - Assert.AreEqual (bar.GenericParameters [0], bar_t_instance.GenericArguments [0]); - - var self_str = bar.GetMethod ("SelfString"); - Assert.IsNotNull (self_str); - - var bar_str = self_str.ReturnType; - Assert.IsTrue (bar_str.IsGenericInstance); - - var bar_str_instance = (GenericInstanceType) bar_str; - - Assert.AreEqual ("System.String", bar_str_instance.GenericArguments [0].FullName); - }); - } - - [Test] - public void ReturnGenericInstanceWithMethodParameter () - { - TestCSharp ("Generics.cs", module => { - var baz = module.GetType ("Baz"); - - var gazoo = baz.GetMethod ("Gazoo"); - Assert.IsNotNull (gazoo); - - var bar_bingo = gazoo.ReturnType; - - Assert.IsTrue (bar_bingo.IsGenericInstance); - - var bar_bingo_instance = (GenericInstanceType) bar_bingo; - - Assert.AreEqual (gazoo.GenericParameters [0], bar_bingo_instance.GenericArguments [0]); - }); - } - - [Test] - public void SimpleOverrides () - { - TestCSharp ("Interfaces.cs", module => { - var ibingo = module.GetType ("IBingo"); - var ibingo_foo = ibingo.GetMethod ("Foo"); - Assert.IsNotNull (ibingo_foo); - - var ibingo_bar = ibingo.GetMethod ("Bar"); - Assert.IsNotNull (ibingo_bar); - - var bingo = module.GetType ("Bingo"); - - var foo = bingo.GetMethod ("IBingo.Foo"); - Assert.IsNotNull (foo); - - Assert.IsTrue (foo.HasOverrides); - Assert.AreEqual (ibingo_foo, foo.Overrides [0]); - - var bar = bingo.GetMethod ("IBingo.Bar"); - Assert.IsNotNull (bar); - - Assert.IsTrue (bar.HasOverrides); - Assert.AreEqual (ibingo_bar, bar.Overrides [0]); - }); - } - - [Test] - public void VarArgs () - { - TestModule ("varargs.exe", module => { - var module_type = module.Types [0]; - - Assert.AreEqual (3, module_type.Methods.Count); - - var bar = module_type.GetMethod ("Bar"); - var baz = module_type.GetMethod ("Baz"); - var foo = module_type.GetMethod ("Foo"); - - Assert.IsTrue (bar.IsVarArg ()); - Assert.IsFalse (baz.IsVarArg ()); - - Assert.IsTrue (foo.IsVarArg ()); - - var foo_reference = (MethodReference) baz.Body.Instructions.First (i => i.Offset == 0x000a).Operand; - - Assert.IsTrue (foo_reference.IsVarArg ()); - Assert.AreEqual (0, foo_reference.GetSentinelPosition ()); - - Assert.AreEqual (foo, foo_reference.Resolve ()); - - var bar_reference = (MethodReference) baz.Body.Instructions.First (i => i.Offset == 0x0023).Operand; - - Assert.IsTrue (bar_reference.IsVarArg ()); - - Assert.AreEqual (1, bar_reference.GetSentinelPosition ()); - - Assert.AreEqual (bar, bar_reference.Resolve ()); - }); - } - - [Test] - public void GenericInstanceMethod () - { - TestCSharp ("Generics.cs", module => { - var type = module.GetType ("It"); - var method = type.GetMethod ("ReadPwow"); - - GenericInstanceMethod instance = null; - - foreach (var instruction in method.Body.Instructions) { - instance = instruction.Operand as GenericInstanceMethod; - if (instance != null) - break; - } - - Assert.IsNotNull (instance); - - Assert.AreEqual (TokenType.MethodSpec, instance.MetadataToken.TokenType); - Assert.AreNotEqual (0, instance.MetadataToken.RID); - }); - } - - [Test] - public void MethodRefDeclaredOnGenerics () - { - TestCSharp ("Generics.cs", module => { - var type = module.GetType ("Tamtam"); - var beta = type.GetMethod ("Beta"); - var charlie = type.GetMethod ("Charlie"); - - // Note that the test depends on the C# compiler emitting the constructor call instruction as - // the first instruction of the method body. This requires optimizations to be enabled. - var new_list_beta = (MethodReference) beta.Body.Instructions [0].Operand; - var new_list_charlie = (MethodReference) charlie.Body.Instructions [0].Operand; - - Assert.AreEqual ("System.Collections.Generic.List`1", new_list_beta.DeclaringType.FullName); - Assert.AreEqual ("System.Collections.Generic.List`1", new_list_charlie.DeclaringType.FullName); - }); - } - - [Test] - public void ReturnParameterMethod () - { - var method = typeof (MethodTests).ToDefinition ().GetMethod ("ReturnParameterMethod"); - Assert.IsNotNull (method); - Assert.AreEqual (method, method.MethodReturnType.Parameter.Method); - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/ModuleTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/ModuleTests.cs deleted file mode 100644 index 2b8eda19cd..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/ModuleTests.cs +++ /dev/null @@ -1,323 +0,0 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; - -using Mono.Cecil; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class ModuleTests : BaseTestFixture { - -#if !READ_ONLY - [Test] - public void CreateModuleEscapesAssemblyName () - { - var module = ModuleDefinition.CreateModule ("Test.dll", ModuleKind.Dll); - Assert.AreEqual ("Test", module.Assembly.Name.Name); - - module = ModuleDefinition.CreateModule ("Test.exe", ModuleKind.Console); - Assert.AreEqual ("Test", module.Assembly.Name.Name); - } -#endif - - [Test] - public void SingleModule () - { - TestModule ("hello.exe", module => { - var assembly = module.Assembly; - - Assert.AreEqual (1, assembly.Modules.Count); - Assert.IsNotNull (assembly.MainModule); - }); - } - - [Test] - public void EntryPoint () - { - TestModule ("hello.exe", module => { - var entry_point = module.EntryPoint; - Assert.IsNotNull (entry_point); - - Assert.AreEqual ("System.Void Program::Main()", entry_point.ToString ()); - }); - } - - [Test] - public void MultiModules () - { - if (Platform.OnCoreClr) - return; - - TestModule("mma.exe", module => { - var assembly = module.Assembly; - - Assert.AreEqual (3, assembly.Modules.Count); - - Assert.AreEqual ("mma.exe", assembly.Modules [0].Name); - Assert.AreEqual (ModuleKind.Console, assembly.Modules [0].Kind); - - Assert.AreEqual ("moda.netmodule", assembly.Modules [1].Name); - Assert.AreEqual ("eedb4721-6c3e-4d9a-be30-49021121dd92", assembly.Modules [1].Mvid.ToString ()); - Assert.AreEqual (ModuleKind.NetModule, assembly.Modules [1].Kind); - - Assert.AreEqual ("modb.netmodule", assembly.Modules [2].Name); - Assert.AreEqual ("46c5c577-11b2-4ea0-bb3c-3c71f1331dd0", assembly.Modules [2].Mvid.ToString ()); - Assert.AreEqual (ModuleKind.NetModule, assembly.Modules [2].Kind); - }); - } - - [Test] - public void ModuleInformation () - { - TestModule ("hello.exe", module => { - Assert.IsNotNull (module); - - Assert.AreEqual ("hello.exe", module.Name); - Assert.AreEqual (new Guid ("C3BC2BD3-2576-4D00-A80E-465B5632415F"), module.Mvid); - }); - } - - [Test] - public void AssemblyReferences () - { - TestModule ("hello.exe", module => { - Assert.AreEqual (1, module.AssemblyReferences.Count); - - var reference = module.AssemblyReferences [0]; - - Assert.AreEqual ("mscorlib", reference.Name); - Assert.AreEqual (new Version (2, 0, 0, 0), reference.Version); - Assert.AreEqual (new byte [] { 0xB7, 0x7A, 0x5C, 0x56, 0x19, 0x34, 0xE0, 0x89 }, reference.PublicKeyToken); - }); - } - - [Test] - public void ModuleReferences () - { - TestModule ("pinvoke.exe", module => { - Assert.AreEqual (2, module.ModuleReferences.Count); - Assert.AreEqual ("kernel32.dll", module.ModuleReferences [0].Name); - Assert.AreEqual ("shell32.dll", module.ModuleReferences [1].Name); - }); - } - - [Test] - public void Types () - { - TestModule ("hello.exe", module => { - Assert.AreEqual (2, module.Types.Count); - Assert.AreEqual ("", module.Types [0].FullName); - Assert.AreEqual ("", module.GetType ("").FullName); - Assert.AreEqual ("Program", module.Types [1].FullName); - Assert.AreEqual ("Program", module.GetType ("Program").FullName); - }); - } - - [Test] - public void LinkedResource () - { - TestModule ("libres.dll", module => { - var resource = module.Resources.Where (res => res.Name == "linked.txt").First () as LinkedResource; - Assert.IsNotNull (resource); - - Assert.AreEqual ("linked.txt", resource.Name); - Assert.AreEqual ("linked.txt", resource.File); - Assert.AreEqual (ResourceType.Linked, resource.ResourceType); - Assert.IsTrue (resource.IsPublic); - }); - } - - [Test] - public void EmbeddedResource () - { - TestModule ("libres.dll", module => { - var resource = module.Resources.Where (res => res.Name == "embedded1.txt").First () as EmbeddedResource; - Assert.IsNotNull (resource); - - Assert.AreEqual ("embedded1.txt", resource.Name); - Assert.AreEqual (ResourceType.Embedded, resource.ResourceType); - Assert.IsTrue (resource.IsPublic); - - using (var reader = new StreamReader (resource.GetResourceStream ())) - Assert.AreEqual ("Hello", reader.ReadToEnd ()); - - resource = module.Resources.Where (res => res.Name == "embedded2.txt").First () as EmbeddedResource; - Assert.IsNotNull (resource); - - Assert.AreEqual ("embedded2.txt", resource.Name); - Assert.AreEqual (ResourceType.Embedded, resource.ResourceType); - Assert.IsTrue (resource.IsPublic); - - using (var reader = new StreamReader (resource.GetResourceStream ())) - Assert.AreEqual ("World", reader.ReadToEnd ()); - }); - } - - [Test] - public void ExportedTypeFromNetModule () - { - if (Platform.OnCoreClr) - return; - - TestModule ("mma.exe", module => { - Assert.IsTrue (module.HasExportedTypes); - Assert.AreEqual (2, module.ExportedTypes.Count); - - var exported_type = module.ExportedTypes [0]; - - Assert.AreEqual ("Module.A.Foo", exported_type.FullName); - Assert.AreEqual ("moda.netmodule", exported_type.Scope.Name); - - exported_type = module.ExportedTypes [1]; - - Assert.AreEqual ("Module.B.Baz", exported_type.FullName); - Assert.AreEqual ("modb.netmodule", exported_type.Scope.Name); - }); - } - - [Test] - public void NestedTypeForwarder () - { - TestCSharp ("CustomAttributes.cs", module => { - Assert.IsTrue (module.HasExportedTypes); - Assert.AreEqual (2, module.ExportedTypes.Count); - - var exported_type = module.ExportedTypes [0]; - - Assert.AreEqual ("System.Diagnostics.DebuggableAttribute", exported_type.FullName); - Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", exported_type.Scope.Name); - Assert.IsTrue (exported_type.IsForwarder); - - var nested_exported_type = module.ExportedTypes [1]; - - Assert.AreEqual ("System.Diagnostics.DebuggableAttribute/DebuggingModes", nested_exported_type.FullName); - Assert.AreEqual (exported_type, nested_exported_type.DeclaringType); - Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", nested_exported_type.Scope.Name); - }); - } - - [Test] - public void HasTypeReference () - { - TestCSharp ("CustomAttributes.cs", module => { - Assert.IsTrue (module.HasTypeReference ("System.Attribute")); - Assert.IsTrue (module.HasTypeReference (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", "System.Attribute")); - - Assert.IsFalse (module.HasTypeReference ("System.Core", "System.Attribute")); - Assert.IsFalse (module.HasTypeReference ("System.Linq.Enumerable")); - }); - } - - [Test] - public void Win32FileVersion () - { - TestModule ("libhello.dll", module => { - var version = FileVersionInfo.GetVersionInfo (module.FileName); - - Assert.AreEqual ("0.0.0.0", version.FileVersion); - }); - } - - [Test] - public void ModuleWithoutBlob () - { - TestModule ("noblob.dll", module => { - Assert.IsNull (module.Image.BlobHeap); - }); - } - - [Test] - public void MixedModeModule () - { - using (var module = GetResourceModule ("cppcli.dll")) { - Assert.AreEqual (1, module.ModuleReferences.Count); - Assert.AreEqual (string.Empty, module.ModuleReferences [0].Name); - } - } - - [Test] - public void OpenIrrelevantFile () - { - Assert.Throws (() => GetResourceModule ("text_file.txt")); - } - - [Test] - public void GetTypeNamespacePlusName () - { - using (var module = GetResourceModule ("moda.netmodule")) { - var type = module.GetType ("Module.A", "Foo"); - Assert.IsNotNull (type); - } - } - - [Test] - public void OpenModuleImmediate () - { - using (var module = GetResourceModule ("hello.exe", ReadingMode.Immediate)) { - Assert.AreEqual (ReadingMode.Immediate, module.ReadingMode); - } - } - - [Test] - public void OpenModuleDeferred () - { - using (var module = GetResourceModule ("hello.exe", ReadingMode.Deferred)) { - Assert.AreEqual (ReadingMode.Deferred, module.ReadingMode); - } - } - - [Test] - public void OwnedStreamModuleFileName () - { - var path = GetAssemblyResourcePath ("hello.exe", GetType ().Assembly); - using (var file = File.Open (path, FileMode.Open)) - { - using (var module = ModuleDefinition.ReadModule (file)) - { - Assert.IsNotNull (module.FileName); - Assert.IsNotEmpty (module.FileName); - Assert.AreEqual (path, module.FileName); - } - } - } - -#if !READ_ONLY - [Test] - public void ReadAndWriteFile () - { - var path = Path.GetTempFileName (); - - var original = ModuleDefinition.CreateModule ("FooFoo", ModuleKind.Dll); - var type = new TypeDefinition ("Foo", "Foo", TypeAttributes.Abstract | TypeAttributes.Sealed); - original.Types.Add (type); - original.Write (path); - - using (var module = ModuleDefinition.ReadModule (path, new ReaderParameters { ReadWrite = true })) { - module.Write (); - } - - using (var module = ModuleDefinition.ReadModule (path)) - Assert.AreEqual ("Foo.Foo", module.Types [1].FullName); - } - - [Test] - public void ExceptionInWriteDoesNotKeepLockOnFile () - { - var path = Path.GetTempFileName (); - - var module = ModuleDefinition.CreateModule ("FooFoo", ModuleKind.Dll); - // Mixed mode module that Cecil can not write - module.Attributes = (ModuleAttributes) 0; - - Assert.Throws(() => module.Write (path)); - - // Ensure you can still delete the file - File.Delete (path); - } -#endif - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/NestedTypesTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/NestedTypesTests.cs deleted file mode 100644 index 38ae146688..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/NestedTypesTests.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; - -using Mono.Cecil; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class NestedTypesTests : BaseTestFixture { - - [Test] - public void NestedTypes () - { - TestCSharp ("NestedTypes.cs", module => { - var foo = module.GetType ("Foo"); - - Assert.AreEqual ("Foo", foo.Name); - Assert.AreEqual ("Foo", foo.FullName); - Assert.AreEqual (module, foo.Module); - Assert.AreEqual (1, foo.NestedTypes.Count); - - var bar = foo.NestedTypes [0]; - - Assert.AreEqual ("Bar", bar.Name); - Assert.AreEqual ("Foo/Bar", bar.FullName); - Assert.AreEqual (module, bar.Module); - Assert.AreEqual (1, bar.NestedTypes.Count); - - var baz = bar.NestedTypes [0]; - - Assert.AreEqual ("Baz", baz.Name); - Assert.AreEqual ("Foo/Bar/Baz", baz.FullName); - Assert.AreEqual (module, baz.Module); - }); - } - - [Test] - public void DirectNestedType () - { - TestCSharp ("NestedTypes.cs", module => { - var bingo = module.GetType ("Bingo"); - var get_fuel = bingo.GetMethod ("GetFuel"); - - Assert.AreEqual ("Bingo/Fuel", get_fuel.ReturnType.FullName); - }); - } - - [Test] - public void NestedTypeWithOwnNamespace () - { - TestModule ("bug-185.dll", module => { - var foo = module.GetType ("Foo"); - var foo_child = foo.NestedTypes [0]; - - Assert.AreEqual ("", foo_child.Namespace); - Assert.AreEqual ("Do>d__0", foo_child.Name); - - Assert.AreEqual ("Foo/.Do>d__0", foo_child.FullName); - }); - } - - [Test] - public void NestedTypeFullName () - { - var foo = new TypeDefinition (null, "Foo", TypeAttributes.Class); - var bar = new TypeDefinition (null, "Bar", TypeAttributes.Class); - var baz = new TypeDefinition (null, "Baz", TypeAttributes.Class); - - foo.NestedTypes.Add (bar); - bar.NestedTypes.Add (baz); - - Assert.AreEqual ("Foo/Bar/Baz", baz.FullName); - - foo.Namespace = "Change"; - - Assert.AreEqual ("Change.Foo/Bar", bar.FullName); - Assert.AreEqual ("Change.Foo/Bar/Baz", baz.FullName); - - bar.Namespace = "AnotherChange"; - - Assert.AreEqual ("Change.Foo/AnotherChange.Bar", bar.FullName); - Assert.AreEqual ("Change.Foo/AnotherChange.Bar/Baz", baz.FullName); - - foo.Name = "FooFoo"; - - Assert.AreEqual ("Change.FooFoo/AnotherChange.Bar", bar.FullName); - Assert.AreEqual ("Change.FooFoo/AnotherChange.Bar/Baz", baz.FullName); - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/ParameterTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/ParameterTests.cs deleted file mode 100644 index 5ec3e06372..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/ParameterTests.cs +++ /dev/null @@ -1,274 +0,0 @@ -using System; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class ParameterTests : BaseTestFixture { - - [Test] - public void MarshalAsI4 () - { - TestModule ("marshal.dll", module => { - var bar = module.GetType ("Bar"); - var pan = bar.GetMethod ("Pan"); - - Assert.AreEqual (1, pan.Parameters.Count); - - var parameter = pan.Parameters [0]; - - Assert.IsTrue (parameter.HasMarshalInfo); - var info = parameter.MarshalInfo; - - Assert.AreEqual (typeof (MarshalInfo), info.GetType ()); - Assert.AreEqual (NativeType.I4, info.NativeType); - }); - } - - [Test] - public void CustomMarshaler () - { - TestModule ("marshal.dll", module => { - var bar = module.GetType ("Bar"); - var pan = bar.GetMethod ("PanPan"); - - var parameter = pan.Parameters [0]; - - Assert.IsTrue (parameter.HasMarshalInfo); - - var info = (CustomMarshalInfo) parameter.MarshalInfo; - - Assert.AreEqual (Guid.Empty, info.Guid); - Assert.AreEqual (string.Empty, info.UnmanagedType); - Assert.AreEqual (NativeType.CustomMarshaler, info.NativeType); - Assert.AreEqual ("nomnom", info.Cookie); - - Assert.AreEqual ("Boc", info.ManagedType.FullName); - Assert.AreEqual (module, info.ManagedType.Scope); - }); - } - - [Test] - public void SafeArrayMarshaler () - { - TestModule ("marshal.dll", module => { - var bar = module.GetType ("Bar"); - var pan = bar.GetMethod ("PanPan"); - - Assert.IsTrue (pan.MethodReturnType.HasMarshalInfo); - - var info = (SafeArrayMarshalInfo) pan.MethodReturnType.MarshalInfo; - - Assert.AreEqual (VariantType.Dispatch, info.ElementType); - }); - } - - [Test] - public void ArrayMarshaler () - { - TestModule ("marshal.dll", module => { - var bar = module.GetType ("Bar"); - var pan = bar.GetMethod ("PanPan"); - - var parameter = pan.Parameters [1]; - - Assert.IsTrue (parameter.HasMarshalInfo); - - var info = (ArrayMarshalInfo) parameter.MarshalInfo; - - Assert.AreEqual (NativeType.I8, info.ElementType); - Assert.AreEqual (66, info.Size); - Assert.AreEqual (2, info.SizeParameterIndex); - - parameter = pan.Parameters [3]; - - Assert.IsTrue (parameter.HasMarshalInfo); - - info = (ArrayMarshalInfo) parameter.MarshalInfo; - - Assert.AreEqual (NativeType.I2, info.ElementType); - Assert.AreEqual (-1, info.Size); - Assert.AreEqual (-1, info.SizeParameterIndex); - }); - } - - [Test] - public void ArrayMarshalerSized () - { - TestModule ("marshal.dll", module => { - var delegate_type = module.GetType ("SomeMethod"); - var parameter = delegate_type.GetMethod ("Invoke").Parameters [1]; - - Assert.IsTrue (parameter.HasMarshalInfo); - var array_info = (ArrayMarshalInfo) parameter.MarshalInfo; - - Assert.IsNotNull (array_info); - - Assert.AreEqual (0, array_info.SizeParameterMultiplier); - }); - } - - [Test] - public void NullableConstant () - { - TestModule ("nullable-constant.exe", module => { - var type = module.GetType ("Program"); - var method = type.GetMethod ("Foo"); - - Assert.IsTrue (method.Parameters [0].HasConstant); - Assert.IsTrue (method.Parameters [1].HasConstant); - Assert.IsTrue (method.Parameters [2].HasConstant); - - Assert.AreEqual (1234, method.Parameters [0].Constant); - Assert.AreEqual (null, method.Parameters [1].Constant); - Assert.AreEqual (12, method.Parameters [2].Constant); - }); - } - - [Test] - public void BoxedDefaultArgumentValue () - { - TestModule ("boxedoptarg.dll", module => { - var foo = module.GetType ("Foo"); - var bar = foo.GetMethod ("Bar"); - var baz = bar.Parameters [0]; - - Assert.IsTrue (baz.HasConstant); - Assert.AreEqual (-1, baz.Constant); - }); - } - - [Test] - public void AddParameterIndex () - { - var object_ref = new TypeReference ("System", "Object", null, null, false); - var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref); - - var x = new ParameterDefinition ("x", ParameterAttributes.None, object_ref); - var y = new ParameterDefinition ("y", ParameterAttributes.None, object_ref); - - method.Parameters.Add (x); - method.Parameters.Add (y); - - Assert.AreEqual (0, x.Index); - Assert.AreEqual (1, y.Index); - - Assert.AreEqual (method, x.Method); - Assert.AreEqual (method, y.Method); - } - - [Test] - public void RemoveAtParameterIndex () - { - var object_ref = new TypeReference ("System", "Object", null, null, false); - var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref); - - var x = new ParameterDefinition ("x", ParameterAttributes.None, object_ref); - var y = new ParameterDefinition ("y", ParameterAttributes.None, object_ref); - var z = new ParameterDefinition ("y", ParameterAttributes.None, object_ref); - - method.Parameters.Add (x); - method.Parameters.Add (y); - method.Parameters.Add (z); - - Assert.AreEqual (0, x.Index); - Assert.AreEqual (1, y.Index); - Assert.AreEqual (2, z.Index); - - method.Parameters.RemoveAt (1); - - Assert.AreEqual (0, x.Index); - Assert.AreEqual (-1, y.Index); - Assert.AreEqual (1, z.Index); - } - - [Test] - public void RemoveParameterIndex () - { - var object_ref = new TypeReference ("System", "Object", null, null, false); - var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref); - - var x = new ParameterDefinition ("x", ParameterAttributes.None, object_ref); - var y = new ParameterDefinition ("y", ParameterAttributes.None, object_ref); - var z = new ParameterDefinition ("y", ParameterAttributes.None, object_ref); - - method.Parameters.Add (x); - method.Parameters.Add (y); - method.Parameters.Add (z); - - Assert.AreEqual (0, x.Index); - Assert.AreEqual (1, y.Index); - Assert.AreEqual (2, z.Index); - - method.Parameters.Remove (y); - - Assert.AreEqual (0, x.Index); - Assert.AreEqual (-1, y.Index); - Assert.AreEqual (1, z.Index); - } - - [Test] - public void InsertParameterIndex () - { - var object_ref = new TypeReference ("System", "Object", null, null, false); - var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref); - - var x = new ParameterDefinition ("x", ParameterAttributes.None, object_ref); - var y = new ParameterDefinition ("y", ParameterAttributes.None, object_ref); - var z = new ParameterDefinition ("y", ParameterAttributes.None, object_ref); - - method.Parameters.Add (x); - method.Parameters.Add (z); - - Assert.AreEqual (0, x.Index); - Assert.AreEqual (-1, y.Index); - Assert.AreEqual (1, z.Index); - - method.Parameters.Insert (1, y); - - Assert.AreEqual (0, x.Index); - Assert.AreEqual (1, y.Index); - Assert.AreEqual (2, z.Index); - } - - [Test] - public void GenericParameterConstant () - { - TestIL ("hello.il", module => { - var foo = module.GetType ("Foo"); - var method = foo.GetMethod ("GetState"); - - Assert.IsNotNull (method); - - var parameter = method.Parameters [1]; - - Assert.IsTrue (parameter.HasConstant); - Assert.IsNull (parameter.Constant); - }); - } - - [Test] - public void NullablePrimitiveParameterConstant () - { - TestModule ("nullable-parameter.dll", module => { - var test = module.GetType ("Test"); - var method = test.GetMethod ("Foo"); - - Assert.IsNotNull (method); - - var param = method.Parameters [0]; - Assert.IsTrue (param.HasConstant); - Assert.AreEqual (1234, param.Constant); - - param = method.Parameters [1]; - Assert.IsTrue (param.HasConstant); - Assert.AreEqual (null, param.Constant); - - param = method.Parameters [2]; - Assert.IsTrue (param.HasConstant); - Assert.AreEqual (12, param.Constant); - }); - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/PortablePdbTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/PortablePdbTests.cs deleted file mode 100644 index 25ee2d1994..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/PortablePdbTests.cs +++ /dev/null @@ -1,557 +0,0 @@ -#if !READ_ONLY -using System; -using System.IO; -using System.Linq; -using System.Text; -using NUnit.Framework; - -using Mono.Cecil.Cil; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class PortablePdbTests : BaseTestFixture { - - [Test] - public void SequencePoints () - { - TestPortablePdbModule (module => { - var type = module.GetType ("PdbTarget.Program"); - var main = type.GetMethod ("Main"); - - AssertCode (@" - .locals init (System.Int32 a, System.String[] V_1, System.Int32 V_2, System.String arg) - .line 21,21:3,4 'C:\sources\PdbTarget\Program.cs' - IL_0000: nop - .line 22,22:4,11 'C:\sources\PdbTarget\Program.cs' - IL_0001: nop - .line 22,22:24,28 'C:\sources\PdbTarget\Program.cs' - IL_0002: ldarg.0 - IL_0003: stloc.1 - IL_0004: ldc.i4.0 - IL_0005: stloc.2 - .line hidden 'C:\sources\PdbTarget\Program.cs' - IL_0006: br.s IL_0017 - .line 22,22:13,20 'C:\sources\PdbTarget\Program.cs' - IL_0008: ldloc.1 - IL_0009: ldloc.2 - IL_000a: ldelem.ref - IL_000b: stloc.3 - .line 23,23:5,20 'C:\sources\PdbTarget\Program.cs' - IL_000c: ldloc.3 - IL_000d: call System.Void System.Console::WriteLine(System.String) - IL_0012: nop - .line hidden 'C:\sources\PdbTarget\Program.cs' - IL_0013: ldloc.2 - IL_0014: ldc.i4.1 - IL_0015: add - IL_0016: stloc.2 - .line 22,22:21,23 'C:\sources\PdbTarget\Program.cs' - IL_0017: ldloc.2 - IL_0018: ldloc.1 - IL_0019: ldlen - IL_001a: conv.i4 - IL_001b: blt.s IL_0008 - .line 25,25:4,22 'C:\sources\PdbTarget\Program.cs' - IL_001d: ldc.i4.1 - IL_001e: ldc.i4.2 - IL_001f: call System.Int32 System.Math::Min(System.Int32,System.Int32) - IL_0024: stloc.0 - .line 26,26:3,4 'C:\sources\PdbTarget\Program.cs' - IL_0025: ret -", main); - }); - } - - [Test] - public void SequencePointsMultipleDocument () - { - TestPortablePdbModule (module => { - var type = module.GetType ("PdbTarget.B"); - var main = type.GetMethod (".ctor"); - - AssertCode (@" - .locals () - .line 7,7:3,25 'C:\sources\PdbTarget\B.cs' - IL_0000: ldarg.0 - IL_0001: ldstr """" - IL_0006: stfld System.String PdbTarget.B::s - .line 110,110:3,21 'C:\sources\PdbTarget\Program.cs' - IL_000b: ldarg.0 - IL_000c: ldc.i4.2 - IL_000d: stfld System.Int32 PdbTarget.B::a - .line 111,111:3,21 'C:\sources\PdbTarget\Program.cs' - IL_0012: ldarg.0 - IL_0013: ldc.i4.3 - IL_0014: stfld System.Int32 PdbTarget.B::b - .line 9,9:3,13 'C:\sources\PdbTarget\B.cs' - IL_0019: ldarg.0 - IL_001a: call System.Void System.Object::.ctor() - IL_001f: nop - .line 10,10:3,4 'C:\sources\PdbTarget\B.cs' - IL_0020: nop - .line 11,11:4,19 'C:\sources\PdbTarget\B.cs' - IL_0021: ldstr ""B"" - IL_0026: call System.Void System.Console::WriteLine(System.String) - IL_002b: nop - .line 12,12:3,4 'C:\sources\PdbTarget\B.cs' - IL_002c: ret -", main); - }); - } - - [Test] - public void LocalVariables () - { - TestPortablePdbModule (module => { - var type = module.GetType ("PdbTarget.Program"); - var method = type.GetMethod ("Bar"); - var debug_info = method.DebugInformation; - - Assert.IsNotNull (debug_info.Scope); - Assert.IsTrue (debug_info.Scope.HasScopes); - Assert.AreEqual (2, debug_info.Scope.Scopes.Count); - - var scope = debug_info.Scope.Scopes [0]; - - Assert.IsNotNull (scope); - Assert.IsTrue (scope.HasVariables); - Assert.AreEqual (1, scope.Variables.Count); - - var variable = scope.Variables [0]; - - Assert.AreEqual ("s", variable.Name); - Assert.IsFalse (variable.IsDebuggerHidden); - Assert.AreEqual (2, variable.Index); - - scope = debug_info.Scope.Scopes [1]; - - Assert.IsNotNull (scope); - Assert.IsTrue (scope.HasVariables); - Assert.AreEqual (1, scope.Variables.Count); - - variable = scope.Variables [0]; - - Assert.AreEqual ("s", variable.Name); - Assert.IsFalse (variable.IsDebuggerHidden); - Assert.AreEqual (3, variable.Index); - - Assert.IsTrue (scope.HasScopes); - Assert.AreEqual (1, scope.Scopes.Count); - - scope = scope.Scopes [0]; - - Assert.IsNotNull (scope); - Assert.IsTrue (scope.HasVariables); - Assert.AreEqual (1, scope.Variables.Count); - - variable = scope.Variables [0]; - - Assert.AreEqual ("u", variable.Name); - Assert.IsFalse (variable.IsDebuggerHidden); - Assert.AreEqual (5, variable.Index); - }); - } - - [Test] - public void LocalConstants () - { - TestPortablePdbModule (module => { - var type = module.GetType ("PdbTarget.Program"); - var method = type.GetMethod ("Bar"); - var debug_info = method.DebugInformation; - - Assert.IsNotNull (debug_info.Scope); - Assert.IsTrue (debug_info.Scope.HasScopes); - Assert.AreEqual (2, debug_info.Scope.Scopes.Count); - - var scope = debug_info.Scope.Scopes [1]; - - Assert.IsNotNull (scope); - Assert.IsTrue (scope.HasConstants); - Assert.AreEqual (2, scope.Constants.Count); - - var constant = scope.Constants [0]; - - Assert.AreEqual ("b", constant.Name); - Assert.AreEqual (12, constant.Value); - Assert.AreEqual (MetadataType.Int32, constant.ConstantType.MetadataType); - - constant = scope.Constants [1]; - Assert.AreEqual ("c", constant.Name); - Assert.AreEqual ((decimal) 74, constant.Value); - Assert.AreEqual (MetadataType.ValueType, constant.ConstantType.MetadataType); - - method = type.GetMethod ("Foo"); - debug_info = method.DebugInformation; - - Assert.IsNotNull (debug_info.Scope); - Assert.IsTrue (debug_info.Scope.HasConstants); - Assert.AreEqual (4, debug_info.Scope.Constants.Count); - - constant = debug_info.Scope.Constants [0]; - Assert.AreEqual ("s", constant.Name); - Assert.AreEqual ("const string", constant.Value); - Assert.AreEqual (MetadataType.String, constant.ConstantType.MetadataType); - - constant = debug_info.Scope.Constants [1]; - Assert.AreEqual ("f", constant.Name); - Assert.AreEqual (1, constant.Value); - Assert.AreEqual (MetadataType.Int32, constant.ConstantType.MetadataType); - - constant = debug_info.Scope.Constants [2]; - Assert.AreEqual ("o", constant.Name); - Assert.AreEqual (null, constant.Value); - Assert.AreEqual (MetadataType.Object, constant.ConstantType.MetadataType); - - constant = debug_info.Scope.Constants [3]; - Assert.AreEqual ("u", constant.Name); - Assert.AreEqual (null, constant.Value); - Assert.AreEqual (MetadataType.String, constant.ConstantType.MetadataType); - }); - } - - [Test] - public void ImportScope () - { - TestPortablePdbModule (module => { - var type = module.GetType ("PdbTarget.Program"); - var method = type.GetMethod ("Bar"); - var debug_info = method.DebugInformation; - - Assert.IsNotNull (debug_info.Scope); - - var import = debug_info.Scope.Import; - Assert.IsNotNull (import); - - Assert.IsFalse (import.HasTargets); - Assert.IsNotNull (import.Parent); - - import = import.Parent; - - Assert.IsTrue (import.HasTargets); - Assert.AreEqual (9, import.Targets.Count); - var target = import.Targets [0]; - - Assert.AreEqual (ImportTargetKind.ImportAlias, target.Kind); - Assert.AreEqual ("XML", target.Alias); - - target = import.Targets [1]; - - Assert.AreEqual (ImportTargetKind.ImportNamespace, target.Kind); - Assert.AreEqual ("System", target.Namespace); - - target = import.Targets [2]; - - Assert.AreEqual (ImportTargetKind.ImportNamespace, target.Kind); - Assert.AreEqual ("System.Collections.Generic", target.Namespace); - - target = import.Targets [3]; - - Assert.AreEqual (ImportTargetKind.ImportNamespace, target.Kind); - Assert.AreEqual ("System.IO", target.Namespace); - - target = import.Targets [4]; - - Assert.AreEqual (ImportTargetKind.ImportNamespace, target.Kind); - Assert.AreEqual ("System.Threading.Tasks", target.Namespace); - - target = import.Targets [5]; - - Assert.AreEqual (ImportTargetKind.ImportNamespaceInAssembly, target.Kind); - Assert.AreEqual ("System.Xml.Resolvers", target.Namespace); - Assert.AreEqual ("System.Xml", target.AssemblyReference.Name); - - - target = import.Targets [6]; - - Assert.AreEqual (ImportTargetKind.ImportType, target.Kind); - Assert.AreEqual ("System.Console", target.Type.FullName); - - target = import.Targets [7]; - - Assert.AreEqual (ImportTargetKind.ImportType, target.Kind); - Assert.AreEqual ("System.Math", target.Type.FullName); - - target = import.Targets [8]; - - Assert.AreEqual (ImportTargetKind.DefineTypeAlias, target.Kind); - Assert.AreEqual ("Foo", target.Alias); - Assert.AreEqual ("System.Xml.XmlDocumentType", target.Type.FullName); - - Assert.IsNotNull (import.Parent); - - import = import.Parent; - - Assert.IsTrue (import.HasTargets); - Assert.AreEqual (1, import.Targets.Count); - Assert.IsNull (import.Parent); - - target = import.Targets [0]; - - Assert.AreEqual (ImportTargetKind.DefineAssemblyAlias, target.Kind); - Assert.AreEqual ("XML", target.Alias); - Assert.AreEqual ("System.Xml", target.AssemblyReference.Name); - }); - } - - [Test] - public void StateMachineKickOff () - { - TestPortablePdbModule (module => { - var state_machine = module.GetType ("PdbTarget.Program/d__7"); - var main = state_machine.GetMethod ("MoveNext"); - var symbol = main.DebugInformation; - - Assert.IsNotNull (symbol); - Assert.IsNotNull (symbol.StateMachineKickOffMethod); - Assert.AreEqual ("System.Threading.Tasks.Task PdbTarget.Program::Baz(System.IO.StreamReader)", symbol.StateMachineKickOffMethod.FullName); - }); - } - - [Test] - public void StateMachineCustomDebugInformation () - { - TestPortablePdbModule (module => { - var state_machine = module.GetType ("PdbTarget.Program/d__7"); - var move_next = state_machine.GetMethod ("MoveNext"); - - Assert.IsTrue (move_next.HasCustomDebugInformations); - - var state_machine_scope = move_next.CustomDebugInformations.OfType ().FirstOrDefault (); - Assert.IsNotNull (state_machine_scope); - Assert.AreEqual (3, state_machine_scope.Scopes.Count); - Assert.AreEqual (0, state_machine_scope.Scopes [0].Start.Offset); - Assert.IsTrue (state_machine_scope.Scopes [0].End.IsEndOfMethod); - - Assert.AreEqual (0, state_machine_scope.Scopes [1].Start.Offset); - Assert.AreEqual (0, state_machine_scope.Scopes [1].End.Offset); - - Assert.AreEqual (184, state_machine_scope.Scopes [2].Start.Offset); - Assert.AreEqual (343, state_machine_scope.Scopes [2].End.Offset); - - var async_body = move_next.CustomDebugInformations.OfType ().FirstOrDefault (); - Assert.IsNotNull (async_body); - Assert.AreEqual (-1, async_body.CatchHandler.Offset); - - Assert.AreEqual (2, async_body.Yields.Count); - Assert.AreEqual (61, async_body.Yields [0].Offset); - Assert.AreEqual (221, async_body.Yields [1].Offset); - - Assert.AreEqual (2, async_body.Resumes.Count); - Assert.AreEqual (91, async_body.Resumes [0].Offset); - Assert.AreEqual (252, async_body.Resumes [1].Offset); - - Assert.AreEqual (move_next, async_body.ResumeMethods [0]); - Assert.AreEqual (move_next, async_body.ResumeMethods [1]); - }); - } - -#if !READ_ONLY - [Test] - public void EmbeddedCompressedPortablePdb () - { - TestModule("EmbeddedCompressedPdbTarget.exe", module => { - Assert.IsTrue (module.HasDebugHeader); - - var header = module.GetDebugHeader (); - - Assert.IsNotNull (header); - Assert.AreEqual (2, header.Entries.Length); - - var cv = header.Entries [0]; - Assert.AreEqual (ImageDebugType.CodeView, cv.Directory.Type); - - var eppdb = header.Entries [1]; - Assert.AreEqual (ImageDebugType.EmbeddedPortablePdb, eppdb.Directory.Type); - }, symbolReaderProvider: typeof (EmbeddedPortablePdbReaderProvider), symbolWriterProvider: typeof (EmbeddedPortablePdbWriterProvider)); - } - - void TestPortablePdbModule (Action test) - { - TestModule ("PdbTarget.exe", test, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider)); - TestModule ("EmbeddedPdbTarget.exe", test, verify: !Platform.OnMono); - TestModule("EmbeddedCompressedPdbTarget.exe", test, symbolReaderProvider: typeof(EmbeddedPortablePdbReaderProvider), symbolWriterProvider: typeof(EmbeddedPortablePdbWriterProvider)); - } - - [Test] - public void RoundTripCecilPortablePdb () - { - TestModule ("cecil.dll", module => { - Assert.IsTrue (module.HasSymbols); - }, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider)); - } - - [Test] - public void RoundTripLargePortablePdb () - { - TestModule ("Mono.Android.dll", module => { - Assert.IsTrue (module.HasSymbols); - }, verify: false, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider)); - } - - [Test] - public void EmptyPortablePdb () - { - TestModule ("EmptyPdb.dll", module => { - Assert.IsTrue (module.HasSymbols); - }, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider)); - } - - [Test] - public void NullClassConstant () - { - TestModule ("xattr.dll", module => { - var type = module.GetType ("Library"); - var method = type.GetMethod ("NullXAttributeConstant"); - var symbol = method.DebugInformation; - - Assert.IsNotNull (symbol); - Assert.AreEqual (1, symbol.Scope.Constants.Count); - - var a = symbol.Scope.Constants [0]; - Assert.AreEqual ("a", a.Name); - }, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider)); - } - - [Test] - public void InvalidConstantRecord () - { - using (var module = GetResourceModule ("mylib.dll", new ReaderParameters { SymbolReaderProvider = new PortablePdbReaderProvider () })) { - var type = module.GetType ("mylib.Say"); - var method = type.GetMethod ("hello"); - var symbol = method.DebugInformation; - - Assert.IsNotNull (symbol); - Assert.AreEqual (0, symbol.Scope.Constants.Count); - } - } - - [Test] - public void SourceLink () - { - TestModule ("TargetLib.dll", module => { - Assert.IsTrue (module.HasCustomDebugInformations); - Assert.AreEqual (1, module.CustomDebugInformations.Count); - - var source_link = module.CustomDebugInformations [0] as SourceLinkDebugInformation; - Assert.IsNotNull (source_link); - Assert.AreEqual ("{\"documents\":{\"C:\\\\tmp\\\\SourceLinkProblem\\\\*\":\"https://raw.githubusercontent.com/bording/SourceLinkProblem/197d965ee7f1e7f8bd3cea55b5f904aeeb8cd51e/*\"}}", source_link.Content); - }, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider)); - } - - [Test] - public void EmbeddedSource () - { - TestModule ("embedcs.exe", module => { - var program = GetDocument (module.GetType ("Program")); - var program_src = GetSourceDebugInfo (program); - Assert.IsTrue (program_src.compress); - var program_src_content = Encoding.UTF8.GetString (program_src.Content); - Assert.AreEqual (Normalize (@"using System; - -class Program -{ - static void Main() - { - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - // Hello hello hello hello hello hello - Console.WriteLine(B.Do()); - Console.WriteLine(A.Do()); - } -} -"), Normalize (program_src_content)); - - var a = GetDocument (module.GetType ("A")); - var a_src = GetSourceDebugInfo (a); - Assert.IsFalse (a_src.compress); - var a_src_content = Encoding.UTF8.GetString (a_src.Content); - Assert.AreEqual (Normalize (@"class A -{ - public static string Do() - { - return ""A::Do""; - } -}"), Normalize (a_src_content)); - - var b = GetDocument(module.GetType ("B")); - var b_src = GetSourceDebugInfo (b); - Assert.IsFalse (b_src.compress); - var b_src_content = Encoding.UTF8.GetString (b_src.Content); - Assert.AreEqual (Normalize (@"class B -{ - public static string Do() - { - return ""B::Do""; - } -}"), Normalize (b_src_content)); - }, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider)); - } - - static Document GetDocument (TypeDefinition type) - { - foreach (var method in type.Methods) { - if (!method.HasBody) - continue; - - foreach (var instruction in method.Body.Instructions) { - var sp = method.DebugInformation.GetSequencePoint (instruction); - if (sp != null && sp.Document != null) - return sp.Document; - } - } - - return null; - } - - static EmbeddedSourceDebugInformation GetSourceDebugInfo (Document document) - { - Assert.IsTrue (document.HasCustomDebugInformations); - Assert.AreEqual (1, document.CustomDebugInformations.Count); - - var source = document.CustomDebugInformations [0] as EmbeddedSourceDebugInformation; - Assert.IsNotNull (source); - return source; - } - - [Test] - public void PortablePdbLineInfo () - { - TestModule ("line.exe", module => { - var type = module.GetType ("Tests"); - var main = type.GetMethod ("Main"); - - AssertCode (@" - .locals () - .line 4,4:42,43 '/foo/bar.cs' - IL_0000: nop - .line 5,5:2,3 '/foo/bar.cs' - IL_0001: ret", main); - }, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider)); - } -#endif - } -} -#endif \ No newline at end of file diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/PropertyTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/PropertyTests.cs deleted file mode 100644 index 587868ff78..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/PropertyTests.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System.Linq; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class PropertyTests : BaseTestFixture { - - [Test] - public void AbstractMethod () - { - TestCSharp ("Properties.cs", module => { - var type = module.GetType ("Foo"); - - Assert.IsTrue (type.HasProperties); - - var properties = type.Properties; - - Assert.AreEqual (3, properties.Count); - - var property = properties [0]; - - Assert.IsNotNull (property); - Assert.AreEqual ("Bar", property.Name); - Assert.IsNotNull (property.PropertyType); - Assert.AreEqual ("System.Int32", property.PropertyType.FullName); - - Assert.IsNotNull (property.GetMethod); - Assert.AreEqual (MethodSemanticsAttributes.Getter, property.GetMethod.SemanticsAttributes); - Assert.IsNull (property.SetMethod); - - property = properties [1]; - - Assert.IsNotNull (property); - Assert.AreEqual ("Baz", property.Name); - Assert.IsNotNull (property.PropertyType); - Assert.AreEqual ("System.String", property.PropertyType.FullName); - - Assert.IsNotNull (property.GetMethod); - Assert.AreEqual (MethodSemanticsAttributes.Getter, property.GetMethod.SemanticsAttributes); - Assert.IsNotNull (property.SetMethod); - Assert.AreEqual (MethodSemanticsAttributes.Setter, property.SetMethod.SemanticsAttributes); - - property = properties [2]; - - Assert.IsNotNull (property); - Assert.AreEqual ("Gazonk", property.Name); - Assert.IsNotNull (property.PropertyType); - Assert.AreEqual ("System.String", property.PropertyType.FullName); - - Assert.IsNull (property.GetMethod); - Assert.IsNotNull (property.SetMethod); - Assert.AreEqual (MethodSemanticsAttributes.Setter, property.SetMethod.SemanticsAttributes); - }); - } - - [Test] - public void OtherMethod () - { - TestIL ("others.il", module => { - var type = module.GetType ("Others"); - - Assert.IsTrue (type.HasProperties); - - var properties = type.Properties; - - Assert.AreEqual (1, properties.Count); - - var property = properties [0]; - - Assert.IsNotNull (property); - Assert.AreEqual ("Context", property.Name); - Assert.IsNotNull (property.PropertyType); - Assert.AreEqual ("System.String", property.PropertyType.FullName); - - Assert.IsTrue (property.HasOtherMethods); - - Assert.AreEqual (2, property.OtherMethods.Count); - - var other = property.OtherMethods [0]; - Assert.AreEqual ("let_Context", other.Name); - - other = property.OtherMethods [1]; - Assert.AreEqual ("bet_Context", other.Name); - }); - } - - [Test] - public void SetOnlyIndexer () - { - TestCSharp ("Properties.cs", module => { - var type = module.GetType ("Bar"); - var indexer = type.Properties.Where (property => property.Name == "Item").First (); - - var parameters = indexer.Parameters; - - Assert.AreEqual (2, parameters.Count); - Assert.AreEqual ("System.Int32", parameters [0].ParameterType.FullName); - Assert.AreEqual ("System.String", parameters [1].ParameterType.FullName); - }); - } - - [Test] - public void ReadSemanticsFirst () - { - TestCSharp ("Properties.cs", module => { - var type = module.GetType ("Baz"); - var setter = type.GetMethod ("set_Bingo"); - - Assert.AreEqual (MethodSemanticsAttributes.Setter, setter.SemanticsAttributes); - - var property = type.Properties.Where (p => p.Name == "Bingo").First (); - - Assert.AreEqual (setter, property.SetMethod); - Assert.AreEqual (type.GetMethod ("get_Bingo"), property.GetMethod); - }); - } - - [Test] - public void UnattachedProperty () - { - var property = new PropertyDefinition ("Property", PropertyAttributes.None, typeof (int).ToDefinition ()); - - Assert.IsNull (property.GetMethod); - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/ResolveTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/ResolveTests.cs deleted file mode 100644 index f65b889b60..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/ResolveTests.cs +++ /dev/null @@ -1,298 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -using Mono.Cecil; -using Mono.Cecil.Cil; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class ResolveTests : BaseTestFixture { - - [Test] - public void StringEmpty () - { - var string_empty = GetReference, FieldReference> ( - () => string.Empty); - - Assert.AreEqual ("System.String System.String::Empty", string_empty.FullName); - - var definition = string_empty.Resolve (); - - Assert.IsNotNull (definition); - - Assert.AreEqual ("System.String System.String::Empty", definition.FullName); - Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", - definition.Module.Assembly.Name.Name); - } - - delegate string GetSubstring (string str, int start, int length); - - [Test] - public void StringSubstring () - { - var string_substring = GetReference ( - (s, start, length) => s.Substring (start, length)); - - var definition = string_substring.Resolve (); - - Assert.IsNotNull (definition); - - Assert.AreEqual ("System.String System.String::Substring(System.Int32,System.Int32)", definition.FullName); - Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", - definition.Module.Assembly.Name.Name); - } - - [Test] - public void StringLength () - { - var string_length = GetReference, MethodReference> (s => s.Length); - - var definition = string_length.Resolve (); - - Assert.IsNotNull (definition); - - Assert.AreEqual ("get_Length", definition.Name); - Assert.AreEqual ("System.String", definition.DeclaringType.FullName); - Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", - definition.Module.Assembly.Name.Name); - } - - [Test] - public void ListOfStringAdd () - { - var list_add = GetReference>, MethodReference> ( - list => list.Add ("coucou")); - - Assert.AreEqual ("System.Void System.Collections.Generic.List`1::Add(!0)", list_add.FullName); - - var definition = list_add.Resolve (); - - Assert.IsNotNull (definition); - - Assert.AreEqual ("System.Void System.Collections.Generic.List`1::Add(T)", definition.FullName); - Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", - definition.Module.Assembly.Name.Name); - } - - [Test] - public void DictionaryOfStringTypeDefinitionTryGetValue () - { - var try_get_value = GetReference, string, bool>, MethodReference> ( - (d, s) => { - TypeDefinition type; - return d.TryGetValue (s, out type); - }); - - Assert.AreEqual ("System.Boolean System.Collections.Generic.Dictionary`2::TryGetValue(!0,!1&)", - try_get_value.FullName); - - var definition = try_get_value.Resolve (); - - Assert.IsNotNull (definition); - - Assert.AreEqual ("System.Boolean System.Collections.Generic.Dictionary`2::TryGetValue(TKey,TValue&)", definition.FullName); - Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", - definition.Module.Assembly.Name.Name); - } - - class CustomResolver : DefaultAssemblyResolver { - - public void Register (AssemblyDefinition assembly) - { - this.RegisterAssembly (assembly); - this.AddSearchDirectory (Path.GetDirectoryName (assembly.MainModule.FileName)); - } - } - - [Test] - public void ExportedTypeFromModule () - { - var resolver = new CustomResolver (); - var parameters = new ReaderParameters { AssemblyResolver = resolver }; - var mma = GetResourceModule ("mma.exe", parameters); - - resolver.Register (mma.Assembly); - - using (var current_module = GetCurrentModule (parameters)) { - var reference = new TypeReference ("Module.A", "Foo", current_module, AssemblyNameReference.Parse (mma.Assembly.FullName), false); - - var definition = reference.Resolve (); - Assert.IsNotNull (definition); - Assert.AreEqual ("Module.A.Foo", definition.FullName); - } - } - - [Test] - public void TypeForwarder () - { - var resolver = new CustomResolver (); - var parameters = new ReaderParameters { AssemblyResolver = resolver }; - - var types = ModuleDefinition.ReadModule ( - CompilationService.CompileResource (GetCSharpResourcePath ("CustomAttributes.cs", typeof (ResolveTests).Assembly)), - parameters); - - resolver.Register (types.Assembly); - - var current_module = GetCurrentModule (parameters); - var reference = new TypeReference ("System.Diagnostics", "DebuggableAttribute", current_module, AssemblyNameReference.Parse (types.Assembly.FullName), false); - - var definition = reference.Resolve (); - Assert.IsNotNull (definition); - Assert.AreEqual ("System.Diagnostics.DebuggableAttribute", definition.FullName); - Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", definition.Module.Assembly.Name.Name); - } - - [Test] - public void NestedTypeForwarder () - { - var resolver = new CustomResolver (); - var parameters = new ReaderParameters { AssemblyResolver = resolver }; - - var types = ModuleDefinition.ReadModule ( - CompilationService.CompileResource (GetCSharpResourcePath ("CustomAttributes.cs", typeof (ResolveTests).Assembly)), - parameters); - - resolver.Register (types.Assembly); - - var current_module = GetCurrentModule (parameters); - var reference = new TypeReference ("", "DebuggingModes", current_module, null, true); - reference.DeclaringType = new TypeReference ("System.Diagnostics", "DebuggableAttribute", current_module, AssemblyNameReference.Parse (types.Assembly.FullName), false); - - var definition = reference.Resolve (); - Assert.IsNotNull (definition); - Assert.AreEqual ("System.Diagnostics.DebuggableAttribute/DebuggingModes", definition.FullName); - Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", definition.Module.Assembly.Name.Name); - } - - [Test] - public void RectangularArrayResolveGetMethod () - { - var get_a_b = GetReference, MethodReference> (matrix => matrix [2, 2]); - - Assert.AreEqual ("Get", get_a_b.Name); - Assert.IsNotNull (get_a_b.Module); - Assert.IsNull (get_a_b.Resolve ()); - } - - [Test] - public void GenericRectangularArrayGetMethodInMemberReferences () - { - using (var module = GetResourceModule ("FSharp.Core.dll")) { - foreach (var member in module.GetMemberReferences ()) { - if (!member.DeclaringType.IsArray) - continue; - - Assert.IsNull (member.Resolve ()); - } - } - } - - [Test] - public void ResolveFunctionPointer () - { - var module = GetResourceModule ("cppcli.dll"); - var global = module.GetType (""); - var field = global.GetField ("__onexitbegin_app_domain"); - - var type = field.FieldType as PointerType; - Assert.IsNotNull(type); - - var fnptr = type.ElementType as FunctionPointerType; - Assert.IsNotNull (fnptr); - - Assert.IsNull (fnptr.Resolve ()); - } - - [Test] - public void ResolveGenericParameter () - { - var collection = typeof (Mono.Collections.Generic.Collection<>).ToDefinition (); - var parameter = collection.GenericParameters [0]; - - Assert.IsNotNull (parameter); - - Assert.IsNull (parameter.Resolve ()); - } - - [Test] - public void ResolveNullVersionAssembly () - { - var reference = AssemblyNameReference.Parse ("System.Core"); - reference.Version = null; - - var resolver = new DefaultAssemblyResolver (); - Assert.IsNotNull (resolver.Resolve (reference)); - } - - [Test] - public void ResolvePortableClassLibraryReference () - { - var resolver = new DefaultAssemblyResolver (); - var parameters = new ReaderParameters { AssemblyResolver = resolver }; - var pcl = GetResourceModule ("PortableClassLibrary.dll", parameters); - - foreach (var reference in pcl.AssemblyReferences) { - Assert.IsTrue (reference.IsRetargetable); - var assembly = resolver.Resolve (reference); - Assert.IsNotNull (assembly); - - if (!Platform.OnCoreClr) - Assert.AreEqual (typeof (object).Assembly.GetName ().Version, assembly.Name.Version); - } - } - - TRet GetReference (TDel code) - { - var @delegate = code as Delegate; - if (@delegate == null) - throw new InvalidOperationException (); - - var reference = (TRet) GetReturnee (GetMethodFromDelegate (@delegate)); - - Assert.IsNotNull (reference); - - return reference; - } - - static object GetReturnee (MethodDefinition method) - { - Assert.IsTrue (method.HasBody); - - var instruction = method.Body.Instructions [method.Body.Instructions.Count - 1]; - - Assert.IsNotNull (instruction); - - while (instruction != null) { - var opcode = instruction.OpCode; - switch (opcode.OperandType) { - case OperandType.InlineField: - case OperandType.InlineTok: - case OperandType.InlineType: - case OperandType.InlineMethod: - return instruction.Operand; - default: - instruction = instruction.Previous; - break; - } - } - - throw new InvalidOperationException (); - } - - MethodDefinition GetMethodFromDelegate (Delegate @delegate) - { - var method = @delegate.Method; - var type = (TypeDefinition) TypeParser.ParseType (GetCurrentModule (), method.DeclaringType.FullName); - - Assert.IsNotNull (type); - - return type.Methods.Where (m => m.Name == method.Name).First (); - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/SecurityDeclarationTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/SecurityDeclarationTests.cs deleted file mode 100644 index c3106f424c..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/SecurityDeclarationTests.cs +++ /dev/null @@ -1,300 +0,0 @@ -using System; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; - -using Mono.Cecil; -using Mono.Cecil.Metadata; -using Mono.Cecil.PE; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class SecurityDeclarationTests : BaseTestFixture { - - [Test] - public void XmlSecurityDeclaration () - { - TestModule ("decsec-xml.dll", module => { - var type = module.GetType ("SubLibrary"); - - Assert.IsTrue (type.HasSecurityDeclarations); - - Assert.AreEqual (1, type.SecurityDeclarations.Count); - - var declaration = type.SecurityDeclarations [0]; - Assert.AreEqual (SecurityAction.Deny, declaration.Action); - - Assert.AreEqual (1, declaration.SecurityAttributes.Count); - - var attribute = declaration.SecurityAttributes [0]; - - Assert.AreEqual ("System.Security.Permissions.PermissionSetAttribute", attribute.AttributeType.FullName); - - Assert.AreEqual (1, attribute.Properties.Count); - - var named_argument = attribute.Properties [0]; - - Assert.AreEqual ("XML", named_argument.Name); - - var argument = named_argument.Argument; - - Assert.AreEqual ("System.String", argument.Type.FullName); - - const string permission_set = "\r\n\r\n\r\n"; - - Assert.AreEqual (permission_set, argument.Value); - }); - } - - [Test] - public void XmlNet_1_1SecurityDeclaration () - { - TestModule ("decsec1-xml.dll", module => { - var type = module.GetType ("SubLibrary"); - - Assert.IsTrue (type.HasSecurityDeclarations); - - Assert.AreEqual (1, type.SecurityDeclarations.Count); - - var declaration = type.SecurityDeclarations [0]; - Assert.AreEqual (SecurityAction.Deny, declaration.Action); - - Assert.AreEqual (1, declaration.SecurityAttributes.Count); - - var attribute = declaration.SecurityAttributes [0]; - - Assert.AreEqual ("System.Security.Permissions.PermissionSetAttribute", attribute.AttributeType.FullName); - - Assert.AreEqual (1, attribute.Properties.Count); - - var named_argument = attribute.Properties [0]; - - Assert.AreEqual ("XML", named_argument.Name); - - var argument = named_argument.Argument; - - Assert.AreEqual ("System.String", argument.Type.FullName); - - const string permission_set = "\r\n\r\n\r\n"; - - Assert.AreEqual (permission_set, argument.Value); - }); - } - -#if !READ_ONLY - [Test] - public void DefineSecurityDeclarationByBlob () - { - var file = Path.Combine(Path.GetTempPath(), "SecDecBlob.dll"); - var module = ModuleDefinition.CreateModule ("SecDecBlob.dll", new ModuleParameters { Kind = ModuleKind.Dll, Runtime = TargetRuntime.Net_2_0 }); - - const string permission_set = "\r\n\r\n\r\n"; - - var declaration = new SecurityDeclaration (SecurityAction.Deny, Encoding.Unicode.GetBytes (permission_set)); - module.Assembly.SecurityDeclarations.Add (declaration); - - module.Write (file); - module = ModuleDefinition.ReadModule (file); - - declaration = module.Assembly.SecurityDeclarations [0]; - Assert.AreEqual (SecurityAction.Deny, declaration.Action); - Assert.AreEqual (1, declaration.SecurityAttributes.Count); - - var attribute = declaration.SecurityAttributes [0]; - Assert.AreEqual ("System.Security.Permissions.PermissionSetAttribute", attribute.AttributeType.FullName); - Assert.AreEqual (1, attribute.Properties.Count); - - var named_argument = attribute.Properties [0]; - Assert.AreEqual ("XML", named_argument.Name); - var argument = named_argument.Argument; - Assert.AreEqual ("System.String", argument.Type.FullName); - Assert.AreEqual (permission_set, argument.Value); - } -#endif - - [Test] - public void SecurityDeclarationWithoutAttributes () - { - TestModule ("empty-decsec-att.dll", module => { - var type = module.GetType ("TestSecurityAction.ModalUITypeEditor"); - var method = type.GetMethod ("GetEditStyle"); - - Assert.IsNotNull (method); - - Assert.AreEqual (1, method.SecurityDeclarations.Count); - - var declaration = method.SecurityDeclarations [0]; - Assert.AreEqual (SecurityAction.LinkDemand, declaration.Action); - Assert.AreEqual (1, declaration.SecurityAttributes.Count); - - var attribute = declaration.SecurityAttributes [0]; - Assert.AreEqual ("System.Security.Permissions.SecurityPermissionAttribute", attribute.AttributeType.FullName); - Assert.AreEqual (0, attribute.Fields.Count); - Assert.AreEqual (0, attribute.Properties.Count); - }); - } - - [Test] - public void AttributeSecurityDeclaration () - { - TestModule ("decsec-att.dll", module => { - var type = module.GetType ("SubLibrary"); - - Assert.IsTrue (type.HasSecurityDeclarations); - - Assert.AreEqual (1, type.SecurityDeclarations.Count); - - var declaration = type.SecurityDeclarations [0]; - Assert.AreEqual (SecurityAction.Deny, declaration.Action); - - Assert.AreEqual (1, declaration.SecurityAttributes.Count); - - var attribute = declaration.SecurityAttributes [0]; - - Assert.AreEqual ("System.Security.Permissions.SecurityPermissionAttribute", attribute.AttributeType.FullName); - - Assert.AreEqual (1, attribute.Properties.Count); - - var named_argument = attribute.Properties [0]; - - Assert.AreEqual ("UnmanagedCode", named_argument.Name); - - var argument = named_argument.Argument; - - Assert.AreEqual ("System.Boolean", argument.Type.FullName); - - Assert.AreEqual (true, argument.Value); - }); - } - - static void AssertCustomAttributeArgument (string expected, CustomAttributeNamedArgument named_argument) - { - AssertCustomAttributeArgument (expected, named_argument.Argument); - } - - static void AssertCustomAttributeArgument (string expected, CustomAttributeArgument argument) - { - var result = new StringBuilder (); - PrettyPrint (argument, result); - - Assert.AreEqual (expected, result.ToString ()); - } - - static string PrettyPrint (CustomAttribute attribute) - { - var signature = new StringBuilder (); - signature.Append (".ctor ("); - - for (int i = 0; i < attribute.ConstructorArguments.Count; i++) { - if (i > 0) - signature.Append (", "); - - PrettyPrint (attribute.ConstructorArguments [i], signature); - } - - signature.Append (")"); - return signature.ToString (); - } - - static void PrettyPrint (CustomAttributeArgument argument, StringBuilder signature) - { - var value = argument.Value; - - signature.Append ("("); - - PrettyPrint (argument.Type, signature); - - signature.Append (":"); - - PrettyPrintValue (argument.Value, signature); - - signature.Append (")"); - } - - static void PrettyPrintValue (object value, StringBuilder signature) - { - if (value == null) { - signature.Append ("null"); - return; - } - - var arguments = value as CustomAttributeArgument []; - if (arguments != null) { - signature.Append ("{"); - for (int i = 0; i < arguments.Length; i++) { - if (i > 0) - signature.Append (", "); - - PrettyPrint (arguments [i], signature); - } - signature.Append ("}"); - - return; - } - - switch (Type.GetTypeCode (value.GetType ())) { - case System.TypeCode.String: - signature.AppendFormat ("\"{0}\"", value); - break; - case System.TypeCode.Char: - signature.AppendFormat ("'{0}'", (char) value); - break; - default: - var formattable = value as IFormattable; - if (formattable != null) { - signature.Append (formattable.ToString (null, CultureInfo.InvariantCulture)); - return; - } - - if (value is CustomAttributeArgument) { - PrettyPrint ((CustomAttributeArgument) value, signature); - return; - } - break; - } - } - - static void PrettyPrint (TypeReference type, StringBuilder signature) - { - if (type.IsArray) { - ArrayType array = (ArrayType) type; - signature.AppendFormat ("{0}[]", array.ElementType.etype.ToString ()); - } else if (type.etype == ElementType.None) { - signature.Append (type.FullName); - } else - signature.Append (type.etype.ToString ()); - } - - static void AssertArgument (T value, CustomAttributeNamedArgument named_argument) - { - AssertArgument (value, named_argument.Argument); - } - - static void AssertArgument (T value, CustomAttributeArgument argument) - { - AssertArgument (typeof (T).FullName, (object) value, argument); - } - - static void AssertArgument (string type, object value, CustomAttributeArgument argument) - { - Assert.AreEqual (type, argument.Type.FullName); - Assert.AreEqual (value, argument.Value); - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/SymbolTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/SymbolTests.cs deleted file mode 100644 index e2bb51ca34..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/SymbolTests.cs +++ /dev/null @@ -1,55 +0,0 @@ -#if !READ_ONLY -using System; -using System.IO; - -using NUnit.Framework; - -using Mono.Cecil.Cil; -using Mono.Cecil.Mdb; -using Mono.Cecil.Pdb; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class SymbolTests : BaseTestFixture { - - [Test] - public void DefaultPdb () - { - IgnoreOnMono (); - - TestModule ("libpdb.dll", module => { - Assert.IsTrue (module.HasSymbols); - Assert.AreEqual (typeof (NativePdbReader), module.SymbolReader.GetType ()); - }, symbolReaderProvider: typeof (DefaultSymbolReaderProvider), symbolWriterProvider: typeof (DefaultSymbolWriterProvider)); - } - - [Test] - public void DefaultMdb () - { - TestModule ("libmdb.dll", module => { - Assert.IsTrue (module.HasSymbols); - Assert.AreEqual (typeof (MdbReader), module.SymbolReader.GetType ()); - }, symbolReaderProvider: typeof (DefaultSymbolReaderProvider), symbolWriterProvider: typeof (DefaultSymbolWriterProvider)); - } - - [Test] - public void DefaultPortablePdb () - { - TestModule ("PdbTarget.exe", module => { - Assert.IsTrue (module.HasSymbols); - Assert.AreEqual (typeof (PortablePdbReader), module.SymbolReader.GetType ()); - }, symbolReaderProvider: typeof (DefaultSymbolReaderProvider), symbolWriterProvider: typeof (DefaultSymbolWriterProvider)); - } - - [Test] - public void DefaultEmbeddedPortablePdb () - { - TestModule ("EmbeddedPdbTarget.exe", module => { - Assert.IsTrue (module.HasSymbols); - Assert.AreEqual (typeof (PortablePdbReader), module.SymbolReader.GetType ()); - }, symbolReaderProvider: typeof (DefaultSymbolReaderProvider), symbolWriterProvider: typeof (DefaultSymbolWriterProvider), verify: !Platform.OnMono); - } - } -} -#endif \ No newline at end of file diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/TypeParserTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/TypeParserTests.cs deleted file mode 100644 index a838c07e97..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/TypeParserTests.cs +++ /dev/null @@ -1,397 +0,0 @@ -using System; -using System.Linq; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class TypeParserTests : BaseTestFixture { - - [Test] - public void SimpleStringReference () - { - var module = GetCurrentModule (); - var corlib = module.TypeSystem.CoreLibrary; - - const string fullname = "System.String"; - - var type = TypeParser.ParseType (module, fullname); - Assert.IsNotNull (type); - Assert.AreEqual (corlib, type.Scope); - Assert.AreEqual (module, type.Module); - Assert.AreEqual ("System", type.Namespace); - Assert.AreEqual ("String", type.Name); - Assert.AreEqual (MetadataType.String, type.MetadataType); - Assert.IsFalse (type.IsValueType); - Assert.IsInstanceOf (typeof (TypeReference), type); - } - - [Test] - public void SimpleInt32Reference () - { - var module = GetCurrentModule (); - var corlib = module.TypeSystem.CoreLibrary; - - const string fullname = "System.Int32"; - - var type = TypeParser.ParseType (module, fullname); - Assert.IsNotNull (type); - Assert.AreEqual (corlib, type.Scope); - Assert.AreEqual (module, type.Module); - Assert.AreEqual ("System", type.Namespace); - Assert.AreEqual ("Int32", type.Name); - Assert.AreEqual (MetadataType.Int32, type.MetadataType); - Assert.IsTrue (type.IsValueType); - Assert.IsInstanceOf (typeof (TypeReference), type); - } - - [Test] - public void SimpleTypeDefinition () - { - var module = GetCurrentModule (); - - const string fullname = "Mono.Cecil.Tests.TypeParserTests"; - - var type = TypeParser.ParseType (module, fullname); - Assert.IsNotNull (type); - Assert.AreEqual (module, type.Scope); - Assert.AreEqual (module, type.Module); - Assert.AreEqual ("Mono.Cecil.Tests", type.Namespace); - Assert.AreEqual ("TypeParserTests", type.Name); - Assert.IsInstanceOf (typeof (TypeDefinition), type); - } - - [Test] - public void ByRefTypeReference () - { - var module = GetCurrentModule (); - var corlib = module.TypeSystem.CoreLibrary; - - const string fullname = "System.String&"; - - var type = TypeParser.ParseType (module, fullname); - - Assert.IsInstanceOf (typeof (ByReferenceType), type); - - type = ((ByReferenceType) type).ElementType; - - Assert.IsNotNull (type); - Assert.AreEqual (corlib, type.Scope); - Assert.AreEqual (module, type.Module); - Assert.AreEqual ("System", type.Namespace); - Assert.AreEqual ("String", type.Name); - Assert.IsInstanceOf (typeof (TypeReference), type); - } - - [Test] - public void FullyQualifiedTypeReference () - { - var module = GetCurrentModule (); - var cecil = module.AssemblyReferences.Where (reference => reference.Name == "Mono.Cecil").First (); - - var fullname = "Mono.Cecil.TypeDefinition, " + cecil.FullName; - - var type = TypeParser.ParseType (module, fullname); - Assert.IsNotNull (type); - Assert.AreEqual (cecil, type.Scope); - Assert.AreEqual (module, type.Module); - Assert.AreEqual ("Mono.Cecil", type.Namespace); - Assert.AreEqual ("TypeDefinition", type.Name); - Assert.IsInstanceOf (typeof (TypeReference), type); - } - - [Test] - public void OpenGenericType () - { - var module = GetCurrentModule (); - var corlib = module.TypeSystem.CoreLibrary; - - const string fullname = "System.Collections.Generic.Dictionary`2"; - - var type = TypeParser.ParseType (module, fullname); - Assert.IsNotNull (type); - Assert.AreEqual (corlib, type.Scope); - Assert.AreEqual (module, type.Module); - Assert.AreEqual ("System.Collections.Generic", type.Namespace); - Assert.AreEqual ("Dictionary`2", type.Name); - Assert.IsInstanceOf (typeof (TypeReference), type); - Assert.AreEqual (2, type.GenericParameters.Count); - } - - public class ID {} - - [Test] - public void SimpleNestedType () - { - var module = GetCurrentModule (); - - const string fullname = "Mono.Cecil.Tests.TypeParserTests+ID"; - - var type = TypeParser.ParseType (module, fullname); - - Assert.IsNotNull (type); - Assert.AreEqual (module, type.Module); - Assert.AreEqual (module, type.Scope); - Assert.AreEqual ("", type.Namespace); - Assert.AreEqual ("ID", type.Name); - - Assert.AreEqual ("Mono.Cecil.Tests.TypeParserTests/ID", type.FullName); - Assert.AreEqual (fullname, TypeParser.ToParseable (type)); - } - - [Test] - public void TripleNestedTypeWithScope () - { - var module = GetCurrentModule (); - - const string fullname = "Bingo.Foo`1+Bar`1+Baz`1, Bingo"; - - var type = TypeParser.ParseType (module, fullname); - - Assert.AreEqual ("Bingo.Foo`1+Bar`1+Baz`1, Bingo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", TypeParser.ToParseable (type)); - - Assert.IsNotNull (type); - Assert.AreEqual ("Bingo", type.Scope.Name); - Assert.AreEqual (module, type.Module); - Assert.AreEqual ("", type.Namespace); - Assert.AreEqual ("Baz`1", type.Name); - Assert.IsInstanceOf (typeof (TypeReference), type); - Assert.AreEqual (1, type.GenericParameters.Count); - - type = type.DeclaringType; - - Assert.IsNotNull (type); - Assert.AreEqual ("Bingo", type.Scope.Name); - Assert.AreEqual (module, type.Module); - Assert.AreEqual ("", type.Namespace); - Assert.AreEqual ("Bar`1", type.Name); - Assert.IsInstanceOf (typeof (TypeReference), type); - Assert.AreEqual (1, type.GenericParameters.Count); - - type = type.DeclaringType; - - Assert.IsNotNull (type); - Assert.AreEqual ("Bingo", type.Scope.Name); - Assert.AreEqual (module, type.Module); - Assert.AreEqual ("Bingo", type.Namespace); - Assert.AreEqual ("Foo`1", type.Name); - Assert.IsInstanceOf (typeof (TypeReference), type); - Assert.AreEqual (1, type.GenericParameters.Count); - } - - [Test] - public void Vector () - { - var module = GetCurrentModule (); - - const string fullname = "Bingo.Gazonk[], Bingo"; - - var type = TypeParser.ParseType (module, fullname); - - Assert.AreEqual ("Bingo.Gazonk[], Bingo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", TypeParser.ToParseable (type)); - - var array = type as ArrayType; - Assert.IsNotNull (array); - Assert.AreEqual (1, array.Rank); - Assert.IsTrue (array.IsVector); - - type = array.ElementType; - - Assert.IsNotNull (type); - Assert.AreEqual ("Bingo", type.Scope.Name); - Assert.AreEqual (module, type.Module); - Assert.AreEqual ("Bingo", type.Namespace); - Assert.AreEqual ("Gazonk", type.Name); - Assert.IsInstanceOf (typeof (TypeReference), type); - } - - [Test] - public void ThreeDimensionalArray () - { - var module = GetCurrentModule (); - - const string fullname = "Bingo.Gazonk[,,], Bingo"; - - var type = TypeParser.ParseType (module, fullname); - - var array = type as ArrayType; - Assert.IsNotNull (array); - Assert.AreEqual (3, array.Rank); - Assert.IsFalse (array.IsVector); - - type = array.ElementType; - - Assert.IsNotNull (type); - Assert.AreEqual ("Bingo", type.Scope.Name); - Assert.AreEqual (module, type.Module); - Assert.AreEqual ("Bingo", type.Namespace); - Assert.AreEqual ("Gazonk", type.Name); - Assert.IsInstanceOf (typeof (TypeReference), type); - } - - [Test] - public void GenericInstanceExternArguments () - { - if (Platform.OnCoreClr) - return; - - var module = GetCurrentModule (); - - var fullname = string.Format ("System.Collections.Generic.Dictionary`2[[System.Int32, {0}],[System.String, {0}]]", - typeof (object).Assembly.FullName); - - var type = TypeParser.ParseType (module, fullname); - - Assert.AreEqual (fullname, TypeParser.ToParseable (type)); - - var instance = type as GenericInstanceType; - Assert.IsNotNull (instance); - Assert.AreEqual (2, instance.GenericArguments.Count); - Assert.AreEqual ("mscorlib", type.Scope.Name); - Assert.AreEqual (module, type.Module); - Assert.AreEqual ("System.Collections.Generic", type.Namespace); - Assert.AreEqual ("Dictionary`2", type.Name); - - type = instance.ElementType; - - Assert.AreEqual (2, type.GenericParameters.Count); - - var argument = instance.GenericArguments [0]; - Assert.AreEqual ("mscorlib", argument.Scope.Name); - Assert.AreEqual (module, argument.Module); - Assert.AreEqual ("System", argument.Namespace); - Assert.AreEqual ("Int32", argument.Name); - - argument = instance.GenericArguments [1]; - Assert.AreEqual ("mscorlib", argument.Scope.Name); - Assert.AreEqual (module, argument.Module); - Assert.AreEqual ("System", argument.Namespace); - Assert.AreEqual ("String", argument.Name); - } - - [Test] - public void GenericInstanceMixedArguments () - { - var module = GetCurrentModule (); - - var fullname = string.Format ("System.Collections.Generic.Dictionary`2[Mono.Cecil.Tests.TypeParserTests,[System.String, {0}]]", - typeof (object).Assembly.FullName); - - var type = TypeParser.ParseType (module, fullname); - - var instance = type as GenericInstanceType; - Assert.IsNotNull (instance); - Assert.AreEqual (2, instance.GenericArguments.Count); - Assert.AreEqual (Platform.OnCoreClr ? "System.Runtime" : "mscorlib", type.Scope.Name); - Assert.AreEqual (module, type.Module); - Assert.AreEqual ("System.Collections.Generic", type.Namespace); - Assert.AreEqual ("Dictionary`2", type.Name); - - type = instance.ElementType; - - Assert.AreEqual (2, type.GenericParameters.Count); - - var argument = instance.GenericArguments [0]; - Assert.IsInstanceOf (typeof (TypeDefinition), argument); - Assert.AreEqual (module, argument.Module); - Assert.AreEqual ("Mono.Cecil.Tests", argument.Namespace); - Assert.AreEqual ("TypeParserTests", argument.Name); - - argument = instance.GenericArguments [1]; - Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", argument.Scope.Name); - Assert.AreEqual (module, argument.Module); - Assert.AreEqual ("System", argument.Namespace); - Assert.AreEqual ("String", argument.Name); - } - - public class Foo { - } - - public class Bar {} - - [Test] - public void GenericInstanceTwoNonFqArguments () - { - var module = GetCurrentModule (); - - var fullname = string.Format ("System.Collections.Generic.Dictionary`2[Mono.Cecil.Tests.TypeParserTests+Bar,Mono.Cecil.Tests.TypeParserTests+Bar], {0}", typeof (object).Assembly.FullName); - - var type = TypeParser.ParseType (module, fullname); - - var instance = type as GenericInstanceType; - Assert.IsNotNull (instance); - Assert.AreEqual (2, instance.GenericArguments.Count); - Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", type.Scope.Name); - Assert.AreEqual (module, type.Module); - Assert.AreEqual ("System.Collections.Generic", type.Namespace); - Assert.AreEqual ("Dictionary`2", type.Name); - - type = instance.ElementType; - - Assert.AreEqual (2, type.GenericParameters.Count); - - var argument = instance.GenericArguments [0]; - Assert.AreEqual (module, argument.Module); - Assert.AreEqual ("", argument.Namespace); - Assert.AreEqual ("Bar", argument.Name); - Assert.IsInstanceOf (typeof (TypeDefinition), argument); - - argument = instance.GenericArguments [1]; - Assert.AreEqual (module, argument.Module); - Assert.AreEqual ("", argument.Namespace); - Assert.AreEqual ("Bar", argument.Name); - Assert.IsInstanceOf (typeof (TypeDefinition), argument); - } - - [Test] - public void ComplexGenericInstanceMixedArguments () - { - var module = GetCurrentModule (); - - var fullname = string.Format ("System.Collections.Generic.Dictionary`2[[System.String, {0}],Mono.Cecil.Tests.TypeParserTests+Foo`2[Mono.Cecil.Tests.TypeParserTests,[System.Int32, {0}]]]", - typeof (object).Assembly.FullName); - - var type = TypeParser.ParseType (module, fullname); - - var instance = type as GenericInstanceType; - Assert.IsNotNull (instance); - Assert.AreEqual (2, instance.GenericArguments.Count); - Assert.AreEqual (Platform.OnCoreClr ? "System.Runtime" : "mscorlib", type.Scope.Name); - Assert.AreEqual (module, type.Module); - Assert.AreEqual ("System.Collections.Generic", type.Namespace); - Assert.AreEqual ("Dictionary`2", type.Name); - - type = instance.ElementType; - - Assert.AreEqual (2, type.GenericParameters.Count); - - var argument = instance.GenericArguments [0]; - Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", argument.Scope.Name); - Assert.AreEqual (module, argument.Module); - Assert.AreEqual ("System", argument.Namespace); - Assert.AreEqual ("String", argument.Name); - - argument = instance.GenericArguments [1]; - - instance = argument as GenericInstanceType; - Assert.IsNotNull (instance); - Assert.AreEqual (2, instance.GenericArguments.Count); - Assert.AreEqual (module, instance.Module); - Assert.AreEqual ("Mono.Cecil.Tests.TypeParserTests/Foo`2", instance.ElementType.FullName); - Assert.IsInstanceOf (typeof (TypeDefinition), instance.ElementType); - - argument = instance.GenericArguments [0]; - Assert.AreEqual (module, argument.Module); - Assert.AreEqual ("Mono.Cecil.Tests", argument.Namespace); - Assert.AreEqual ("TypeParserTests", argument.Name); - Assert.IsInstanceOf (typeof (TypeDefinition), argument); - - argument = instance.GenericArguments [1]; - Assert.AreEqual (Platform.OnCoreClr ? "System.Private.CoreLib" : "mscorlib", argument.Scope.Name); - Assert.AreEqual (module, argument.Module); - Assert.AreEqual ("System", argument.Namespace); - Assert.AreEqual ("Int32", argument.Name); - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/TypeTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/TypeTests.cs deleted file mode 100644 index d378042095..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/TypeTests.cs +++ /dev/null @@ -1,278 +0,0 @@ -using System; -using System.Linq; - -using Mono.Cecil; -using Mono.Cecil.Cil; -using Mono.Cecil.Metadata; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class TypeTests : BaseTestFixture { - - [Test] - public void TypeLayout () - { - TestCSharp ("Layouts.cs", module => { - var foo = module.GetType ("Foo"); - Assert.IsNotNull (foo); - Assert.IsTrue (foo.IsValueType); - - Assert.IsTrue (foo.HasLayoutInfo); - Assert.AreEqual (16, foo.ClassSize); - - var babar = module.GetType ("Babar"); - Assert.IsNotNull (babar); - Assert.IsFalse (babar.IsValueType); - Assert.IsFalse (babar.HasLayoutInfo); - }); - } - - [Test] - public void SimpleInterfaces () - { - TestIL ("types.il", module => { - var ibaz = module.GetType ("IBaz"); - Assert.IsNotNull (ibaz); - - Assert.IsTrue (ibaz.HasInterfaces); - - var interfaces = ibaz.Interfaces; - - Assert.AreEqual (2, interfaces.Count); - - // Mono's ilasm and .NET's are ordering interfaces differently - Assert.IsNotNull (interfaces.Single (i => i.InterfaceType.FullName == "IBar")); - Assert.IsNotNull (interfaces.Single (i => i.InterfaceType.FullName == "IFoo")); - }); - } - - [Test] - public void GenericTypeDefinition () - { - TestCSharp ("Generics.cs", module => { - var foo = module.GetType ("Foo`2"); - Assert.IsNotNull (foo); - - Assert.IsTrue (foo.HasGenericParameters); - Assert.AreEqual (2, foo.GenericParameters.Count); - - var tbar = foo.GenericParameters [0]; - - Assert.AreEqual ("TBar", tbar.Name); - Assert.AreEqual (foo, tbar.Owner); - - var tbaz = foo.GenericParameters [1]; - - Assert.AreEqual ("TBaz", tbaz.Name); - Assert.AreEqual (foo, tbaz.Owner); - }); - } - - [Test] - public void ConstrainedGenericType () - { - TestCSharp ("Generics.cs", module => { - var bongo_t = module.GetType ("Bongo`1"); - Assert.IsNotNull (bongo_t); - - var t = bongo_t.GenericParameters [0]; - Assert.IsNotNull (t); - Assert.AreEqual ("T", t.Name); - - Assert.IsTrue (t.HasConstraints); - Assert.AreEqual (2, t.Constraints.Count); - - Assert.AreEqual ("Zap", t.Constraints [0].FullName); - Assert.AreEqual ("IZoom", t.Constraints [1].FullName); - }); - } - - [Test] - public void GenericBaseType () - { - TestCSharp ("Generics.cs", module => { - var child = module.GetType ("Child`1"); - - var child_t = child.GenericParameters [0]; - Assert.IsNotNull (child_t); - - var instance = child.BaseType as GenericInstanceType; - Assert.IsNotNull (instance); - Assert.AreNotEqual (0, instance.MetadataToken.RID); - - Assert.AreEqual (child_t, instance.GenericArguments [0]); - }); - } - - [Test] - public void GenericConstraintOnGenericParameter () - { - TestCSharp ("Generics.cs", module => { - var duel = module.GetType ("Duel`3"); - - Assert.AreEqual (3, duel.GenericParameters.Count); - - var t1 = duel.GenericParameters [0]; - var t2 = duel.GenericParameters [1]; - var t3 = duel.GenericParameters [2]; - - Assert.AreEqual (t1, t2.Constraints [0]); - Assert.AreEqual (t2, t3.Constraints [0]); - }); - } - - [Test] - public void GenericForwardBaseType () - { - TestCSharp ("Generics.cs", module => { - var tamchild = module.GetType ("TamChild"); - - Assert.IsNotNull (tamchild); - Assert.IsNotNull (tamchild.BaseType); - - var generic_instance = tamchild.BaseType as GenericInstanceType; - - Assert.IsNotNull (generic_instance); - - Assert.AreEqual (1, generic_instance.GenericArguments.Count); - Assert.AreEqual (module.GetType ("Tamtam"), generic_instance.GenericArguments [0]); - }); - } - - [Test] - public void TypeExtentingGenericOfSelf () - { - TestCSharp ("Generics.cs", module => { - var rec_child = module.GetType ("RecChild"); - - Assert.IsNotNull (rec_child); - Assert.IsNotNull (rec_child.BaseType); - - var generic_instance = rec_child.BaseType as GenericInstanceType; - - Assert.IsNotNull (generic_instance); - - Assert.AreEqual (1, generic_instance.GenericArguments.Count); - Assert.AreEqual (rec_child, generic_instance.GenericArguments [0]); - }); - } - - [Test] - public void TypeReferenceValueType () - { - TestCSharp ("Methods.cs", module => { - var baz = module.GetType ("Baz"); - var method = baz.GetMethod ("PrintAnswer"); - - var box = method.Body.Instructions.Where (i => i.OpCode == OpCodes.Box).First (); - var int32 = (TypeReference) box.Operand; - - Assert.IsTrue (int32.IsValueType); - }); - } - - [Test] - public void GenericInterfaceReference () - { - TestModule ("gifaceref.exe", module => { - var type = module.GetType ("Program"); - var iface = type.Interfaces [0]; - - var instance = (GenericInstanceType) iface.InterfaceType; - var owner = instance.ElementType; - - Assert.AreEqual (1, instance.GenericArguments.Count); - Assert.AreEqual (1, owner.GenericParameters.Count); - }); - } - - [Test] - public void UnboundGenericParameter () - { - TestModule ("cscgpbug.dll", module => { - var type = module.GetType ("ListViewModel"); - var method = type.GetMethod ("<>n__FabricatedMethod1"); - - var parameter = method.ReturnType as GenericParameter; - - Assert.IsNotNull (parameter); - Assert.AreEqual (0, parameter.Position); - Assert.IsNull (parameter.Owner); - }, verify: false); - } - - [Test] - public void GenericMultidimensionalArray () - { - TestCSharp ("Generics.cs", module => { - var type = module.GetType ("LaMatrix"); - var method = type.GetMethod ("At"); - - var call = method.Body.Instructions.Where (i => i.Operand is MethodReference).First (); - var get = (MethodReference) call.Operand; - - Assert.IsNotNull (get); - Assert.AreEqual (0, get.GenericParameters.Count); - Assert.AreEqual (MethodCallingConvention.Default, get.CallingConvention); - Assert.AreEqual (method.GenericParameters [0], get.ReturnType); - }); - } - - [Test] - public void CorlibPrimitive () - { - var module = typeof (TypeTests).ToDefinition ().Module; - - var int32 = module.TypeSystem.Int32; - Assert.IsTrue (int32.IsPrimitive); - Assert.AreEqual (MetadataType.Int32, int32.MetadataType); - - var int32_def = int32.Resolve (); - Assert.IsTrue (int32_def.IsPrimitive); - Assert.AreEqual (MetadataType.Int32, int32_def.MetadataType); - } - - [Test] - public void ExplicitThis () - { - TestIL ("explicitthis.il", module => { - var type = module.GetType ("MakeDecision"); - var method = type.GetMethod ("Decide"); - var fptr = method.ReturnType as FunctionPointerType; - - Assert.IsNotNull (fptr); - Assert.IsTrue (fptr.HasThis); - Assert.IsTrue (fptr.ExplicitThis); - - Assert.AreEqual (0, fptr.Parameters [0].Sequence); - Assert.AreEqual (1, fptr.Parameters [1].Sequence); - }, verify: false); - } - - [Test] - public void DeferredCorlibTypeDef () - { - using (var module = ModuleDefinition.ReadModule (typeof (object).Assembly.Location, new ReaderParameters (ReadingMode.Deferred))) { - var object_type = module.TypeSystem.Object; - Assert.IsInstanceOf (object_type); - } - } - - [Test] - public void CorlibTypesMetadataType () - { - using (var module = ModuleDefinition.ReadModule (typeof (object).Assembly.Location)) { - var type = module.GetType ("System.String"); - Assert.IsNotNull (type); - Assert.IsNotNull (type.BaseType); - Assert.AreEqual ("System.Object", type.BaseType.FullName); - Assert.IsInstanceOf (type.BaseType); - Assert.AreEqual (MetadataType.String, type.MetadataType); - Assert.AreEqual (MetadataType.Object, type.BaseType.MetadataType); - } - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/VariableTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/VariableTests.cs deleted file mode 100644 index 577e56f5a7..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/VariableTests.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System; -using System.Linq; - -using Mono.Cecil; -using Mono.Cecil.Cil; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class VariableTests : BaseTestFixture { - - [Test] - public void AddVariableIndex () - { - var object_ref = new TypeReference ("System", "Object", null, null, false); - var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref); - var body = new MethodBody (method); - - var x = new VariableDefinition (object_ref); - var y = new VariableDefinition (object_ref); - - body.Variables.Add (x); - body.Variables.Add (y); - - Assert.AreEqual (0, x.Index); - Assert.AreEqual (1, y.Index); - } - - [Test] - public void RemoveAtVariableIndex () - { - var object_ref = new TypeReference ("System", "Object", null, null, false); - var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref); - var body = new MethodBody (method); - - var x = new VariableDefinition (object_ref); - var y = new VariableDefinition (object_ref); - var z = new VariableDefinition (object_ref); - - body.Variables.Add (x); - body.Variables.Add (y); - body.Variables.Add (z); - - Assert.AreEqual (0, x.Index); - Assert.AreEqual (1, y.Index); - Assert.AreEqual (2, z.Index); - - body.Variables.RemoveAt (1); - - Assert.AreEqual (0, x.Index); - Assert.AreEqual (-1, y.Index); - Assert.AreEqual (1, z.Index); - } - - [Test] - public void RemoveVariableIndex () - { - var object_ref = new TypeReference ("System", "Object", null, null, false); - var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref); - var body = new MethodBody (method); - - var x = new VariableDefinition (object_ref); - var y = new VariableDefinition (object_ref); - var z = new VariableDefinition (object_ref); - - body.Variables.Add (x); - body.Variables.Add (y); - body.Variables.Add (z); - - Assert.AreEqual (0, x.Index); - Assert.AreEqual (1, y.Index); - Assert.AreEqual (2, z.Index); - - body.Variables.Remove (y); - - Assert.AreEqual (0, x.Index); - Assert.AreEqual (-1, y.Index); - Assert.AreEqual (1, z.Index); - } - - [Test] - public void InsertVariableIndex () - { - var object_ref = new TypeReference ("System", "Object", null, null, false); - var method = new MethodDefinition ("foo", MethodAttributes.Static, object_ref); - var body = new MethodBody (method); - - var x = new VariableDefinition (object_ref); - var y = new VariableDefinition (object_ref); - var z = new VariableDefinition (object_ref); - - body.Variables.Add (x); - body.Variables.Add (z); - - Assert.AreEqual (0, x.Index); - Assert.AreEqual (-1, y.Index); - Assert.AreEqual (1, z.Index); - - body.Variables.Insert (1, y); - - Assert.AreEqual (0, x.Index); - Assert.AreEqual (1, y.Index); - Assert.AreEqual (2, z.Index); - } - } -} diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/WindowsRuntimeAssemblyResolver.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/WindowsRuntimeAssemblyResolver.cs deleted file mode 100644 index fb39e33428..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/WindowsRuntimeAssemblyResolver.cs +++ /dev/null @@ -1,96 +0,0 @@ -#if !NET_CORE - -using System; -using System.Collections.Generic; -using System.IO; -using Microsoft.Win32; - -namespace Mono.Cecil.Tests { - public class WindowsRuntimeAssemblyResolver : DefaultAssemblyResolver { - - readonly Dictionary assemblies = new Dictionary (); - - public static WindowsRuntimeAssemblyResolver CreateInstance () - { - if (Platform.OnMono) - return null; - try { - return new WindowsRuntimeAssemblyResolver (); - } catch { - return null; - } - } - - public override AssemblyDefinition Resolve (AssemblyNameReference name) - { - AssemblyDefinition assembly; - if (assemblies.TryGetValue(name.Name, out assembly)) - return assembly; - - return base.Resolve (name); - } - - private WindowsRuntimeAssemblyResolver () - { - LoadWindowsSdk ("v8.1", "8.1", (installationFolder) => { - var fileName = Path.Combine (installationFolder, @"References\CommonConfiguration\Neutral\Annotated\Windows.winmd"); - var assembly = AssemblyDefinition.ReadAssembly (fileName); - Register (assembly); - }); - - LoadWindowsSdk ("v10.0", "10", (installationFolder) => { - var referencesFolder = Path.Combine (installationFolder, "References"); - var assemblies = Directory.GetFiles (referencesFolder, "*.winmd", SearchOption.AllDirectories); - - foreach (var assemblyPath in assemblies) { - var assembly = AssemblyDefinition.ReadAssembly (assemblyPath); - Register (assembly); - } - }); - } - - void Register (AssemblyDefinition assembly) - { - assemblies [assembly.Name.Name] = assembly; - RegisterAssembly (assembly); - } - - protected override void Dispose (bool disposing) - { - if (!disposing) - return; - - foreach (var assembly in assemblies.Values) - assembly.Dispose (); - - base.Dispose (true); - } - - void LoadWindowsSdk (string registryVersion, string windowsKitsVersion, Action registerAssembliesCallback) - { -#if NET_4_0 - using (var localMachine32Key = RegistryKey.OpenBaseKey (RegistryHive.LocalMachine, RegistryView.Registry32)) { - using (var sdkKey = localMachine32Key.OpenSubKey (@"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v" + registryVersion)) { -#else - { - // this will fail on 64-bit process as there's no way (other than pinoke) to read from 32-bit registry view - using (var sdkKey = Registry.LocalMachine.OpenSubKey (@"SOFTWARE\Microsoft\Microsoft SDKs\Windows\" + registryVersion)) { -#endif - string installationFolder = null; - if (sdkKey != null) - installationFolder = (string)sdkKey.GetValue ("InstallationFolder"); - if (string.IsNullOrEmpty (installationFolder)) { -#if NET_4_0 - var programFilesX86 = Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86); -#else - var programFilesX86 = Environment.GetEnvironmentVariable ("ProgramFiles(x86)"); -#endif - installationFolder = Path.Combine (programFilesX86, @"Windows Kits\" + windowsKitsVersion); - } - registerAssembliesCallback (installationFolder); - } - } - } - } -} -#endif \ No newline at end of file diff --git a/external/linker/cecil/Test/Mono.Cecil.Tests/WindowsRuntimeProjectionsTests.cs b/external/linker/cecil/Test/Mono.Cecil.Tests/WindowsRuntimeProjectionsTests.cs deleted file mode 100644 index d5ed3b0b33..0000000000 --- a/external/linker/cecil/Test/Mono.Cecil.Tests/WindowsRuntimeProjectionsTests.cs +++ /dev/null @@ -1,146 +0,0 @@ -#if !NET_CORE - -using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; - -namespace Mono.Cecil.Tests { - [TestFixture] - public abstract class BaseWindowsRuntimeProjectionsTests : BaseTestFixture { - protected abstract string ModuleName { get; } - protected abstract MetadataKind ExpectedMetadataKind { get; } - protected abstract string [] ManagedClassTypeNames { get; } - protected abstract string [] CustomListTypeNames { get; } - - [Test] - public void CanReadMetadataType () - { - if (Platform.OnMono) - return; - - TestModule (ModuleName, (module) => { - Assert.AreEqual (ExpectedMetadataKind, module.MetadataKind); - }, verify: false, assemblyResolver: WindowsRuntimeAssemblyResolver.CreateInstance (), applyWindowsRuntimeProjections: true); - } - - [Test] - public void CanProjectParametersAndReturnTypes () - { - if (Platform.OnMono) - return; - - TestModule (ModuleName, (module) => { - var types = ManagedClassTypeNames.Select (typeName => module.Types.Single (t => t.Name == typeName)); - - foreach (var type in types) { - var listGetter = type.Properties.Single (p => p.Name == "List").GetMethod; - var listSetter = type.Properties.Single (p => p.Name == "List").SetMethod; - - Assert.IsNotNull (listGetter); - Assert.IsNotNull (listSetter); - - Assert.AreEqual (listGetter.ReturnType.FullName, "System.Collections.Generic.IList`1"); - Assert.AreEqual (listSetter.Parameters.Count, 1); - Assert.AreEqual (listSetter.Parameters [0].ParameterType.FullName, "System.Collections.Generic.IList`1"); - } - }, verify: false, assemblyResolver: WindowsRuntimeAssemblyResolver.CreateInstance (), applyWindowsRuntimeProjections: true); - } - - [Test] - public void CanProjectInterfaces () - { - if (Platform.OnMono) - return; - - TestModule (ModuleName, (module) => { - var types = CustomListTypeNames.Select (typeName => module.Types.Single (t => t.Name == typeName)); - - foreach (var type in types) { - Assert.IsNotNull (type.Interfaces.SingleOrDefault (i => i.InterfaceType.FullName == "System.Collections.Generic.IList`1")); - Assert.IsNotNull (type.Interfaces.SingleOrDefault (i => i.InterfaceType.FullName == "System.Collections.Generic.IEnumerable`1")); - } - }, verify: false, assemblyResolver: WindowsRuntimeAssemblyResolver.CreateInstance (), applyWindowsRuntimeProjections: true); - } - -#if !READ_ONLY - [Test] - public void CanStripType () - { - if (Platform.OnMono) - return; - - var assemblyResolver = WindowsRuntimeAssemblyResolver.CreateInstance (); - - TestModule (ModuleName, (originalModule) => { - var types = CustomListTypeNames.Select (typeName => originalModule.Types.Single (t => t.Name == typeName)).ToArray (); - - foreach (var type in types) - originalModule.Types.Remove (type); - - var tmpPath = Path.GetTempFileName (); - originalModule.Write (tmpPath); - - try { - TestModule (tmpPath, (modifiedModule) => { - foreach (var type in types) - Assert.IsTrue (!modifiedModule.Types.Any (t => t.FullName == type.FullName)); - }, verify: false, assemblyResolver: assemblyResolver, applyWindowsRuntimeProjections: true); - } finally { - File.Delete (tmpPath); - } - }, readOnly: true, verify: false, assemblyResolver: assemblyResolver, applyWindowsRuntimeProjections: true); - } -#endif - } - - [TestFixture] - public class ManagedWindowsRuntimeProjectionsTests : BaseWindowsRuntimeProjectionsTests { - protected override string ModuleName { get { return "ManagedWinmd.winmd"; } } - - protected override MetadataKind ExpectedMetadataKind { get { return MetadataKind.ManagedWindowsMetadata; } } - - protected override string [] ManagedClassTypeNames { get { return new [] { "ManagedClass", "ManagedClass" }; } } - - protected override string [] CustomListTypeNames { get { return new [] { "CustomList", "CustomList" }; } } - - [Test] - public void CanProjectClasses () - { - if (Platform.OnMono) - return; - - TestModule (ModuleName, (module) => { - var managedClassType = module.Types.Single (t => t.Name == "ManagedClass"); - Assert.AreEqual ("ManagedClass", managedClassType.WindowsRuntimeProjection.Name); - Assert.AreEqual (TypeDefinitionTreatment.UnmangleWindowsRuntimeName, managedClassType.WindowsRuntimeProjection.Treatment); - - var someOtherClassType = module.Types.Single (t => t.Name == "SomeOtherClass"); - Assert.AreEqual ("SomeOtherClass", someOtherClassType.WindowsRuntimeProjection.Name); - Assert.AreEqual (TypeDefinitionTreatment.UnmangleWindowsRuntimeName, someOtherClassType.WindowsRuntimeProjection.Treatment); - - var winrtManagedClassType = module.Types.Single (t => t.Name == "ManagedClass"); - Assert.AreEqual ("ManagedClass", winrtManagedClassType.WindowsRuntimeProjection.Name); - Assert.AreEqual (TypeDefinitionTreatment.PrefixWindowsRuntimeName, winrtManagedClassType.WindowsRuntimeProjection.Treatment); - - var winrtSomeOtherClassType = module.Types.Single (t => t.Name == "SomeOtherClass"); - Assert.AreEqual ("SomeOtherClass", winrtSomeOtherClassType.WindowsRuntimeProjection.Name); - Assert.AreEqual (TypeDefinitionTreatment.PrefixWindowsRuntimeName, winrtSomeOtherClassType.WindowsRuntimeProjection.Treatment); - }, verify: false, assemblyResolver: WindowsRuntimeAssemblyResolver.CreateInstance (), applyWindowsRuntimeProjections: true); - } - } - - [TestFixture] - public class NativeWindowsRuntimeProjectionsTests : BaseWindowsRuntimeProjectionsTests { - protected override string ModuleName { get { return "NativeWinmd.winmd"; } } - - protected override MetadataKind ExpectedMetadataKind { get { return MetadataKind.WindowsMetadata; } } - - protected override string [] ManagedClassTypeNames { get { return new [] { "ManagedClass" }; } } - - protected override string [] CustomListTypeNames { get { return new [] { "CustomList" }; } } - } -} -#endif diff --git a/external/linker/cecil/Test/Resources/assemblies/EmptyPdb.pdb b/external/linker/cecil/Test/Resources/assemblies/EmptyPdb.pdb deleted file mode 100644 index 46e58d8df0..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/EmptyPdb.pdb and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/assemblies/ExternalPdbDeterministic.pdb b/external/linker/cecil/Test/Resources/assemblies/ExternalPdbDeterministic.pdb deleted file mode 100644 index fa5f7d49ca..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/ExternalPdbDeterministic.pdb and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/assemblies/ManagedWinmd.winmd b/external/linker/cecil/Test/Resources/assemblies/ManagedWinmd.winmd deleted file mode 100644 index 070ba28fe3..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/ManagedWinmd.winmd and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/assemblies/Mono.Android.pdb.REMOVED.git-id b/external/linker/cecil/Test/Resources/assemblies/Mono.Android.pdb.REMOVED.git-id deleted file mode 100644 index 5c5c44827e..0000000000 --- a/external/linker/cecil/Test/Resources/assemblies/Mono.Android.pdb.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -544f15534a571e2b6c9d45e7c4630535290476b5 \ No newline at end of file diff --git a/external/linker/cecil/Test/Resources/assemblies/NativeWinmd.winmd b/external/linker/cecil/Test/Resources/assemblies/NativeWinmd.winmd deleted file mode 100644 index 53fedff797..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/NativeWinmd.winmd and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/assemblies/PdbTarget.pdb b/external/linker/cecil/Test/Resources/assemblies/PdbTarget.pdb deleted file mode 100644 index 3c6fc6beee..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/PdbTarget.pdb and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/assemblies/SQLite-net.dll.mdb b/external/linker/cecil/Test/Resources/assemblies/SQLite-net.dll.mdb deleted file mode 100644 index 8b3583a29d..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/SQLite-net.dll.mdb and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/assemblies/TargetLib.pdb b/external/linker/cecil/Test/Resources/assemblies/TargetLib.pdb deleted file mode 100644 index 730d74cf1d..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/TargetLib.pdb and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/assemblies/cecil.pdb.REMOVED.git-id b/external/linker/cecil/Test/Resources/assemblies/cecil.pdb.REMOVED.git-id deleted file mode 100644 index 7ecbe08d06..0000000000 --- a/external/linker/cecil/Test/Resources/assemblies/cecil.pdb.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -e0938af534eadba5f71dca123cc75e3e9bdf8c63 \ No newline at end of file diff --git a/external/linker/cecil/Test/Resources/assemblies/embedcs.pdb b/external/linker/cecil/Test/Resources/assemblies/embedcs.pdb deleted file mode 100644 index 78294d1c33..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/embedcs.pdb and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/assemblies/libmdb.dll.mdb b/external/linker/cecil/Test/Resources/assemblies/libmdb.dll.mdb deleted file mode 100644 index 76b56d4e69..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/libmdb.dll.mdb and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/assemblies/libpdb.pdb b/external/linker/cecil/Test/Resources/assemblies/libpdb.pdb deleted file mode 100644 index dd35d1b8de..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/libpdb.pdb and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/assemblies/line.pdb b/external/linker/cecil/Test/Resources/assemblies/line.pdb deleted file mode 100644 index 9cb8c5012e..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/line.pdb and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/assemblies/moda.netmodule b/external/linker/cecil/Test/Resources/assemblies/moda.netmodule deleted file mode 100644 index 8cc49983e6..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/moda.netmodule and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/assemblies/modb.netmodule b/external/linker/cecil/Test/Resources/assemblies/modb.netmodule deleted file mode 100644 index 38522b2935..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/modb.netmodule and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/assemblies/mylib.pdb b/external/linker/cecil/Test/Resources/assemblies/mylib.pdb deleted file mode 100644 index 2f0dfdfa87..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/mylib.pdb and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/assemblies/text_file.txt b/external/linker/cecil/Test/Resources/assemblies/text_file.txt deleted file mode 100644 index ea780ea5b4..0000000000 --- a/external/linker/cecil/Test/Resources/assemblies/text_file.txt +++ /dev/null @@ -1 +0,0 @@ -Cecil ftw! diff --git a/external/linker/cecil/Test/Resources/assemblies/winrtcomp.winmd b/external/linker/cecil/Test/Resources/assemblies/winrtcomp.winmd deleted file mode 100644 index efaa4e741d..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/winrtcomp.winmd and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/assemblies/xattr.pdb b/external/linker/cecil/Test/Resources/assemblies/xattr.pdb deleted file mode 100644 index 42d203baa9..0000000000 Binary files a/external/linker/cecil/Test/Resources/assemblies/xattr.pdb and /dev/null differ diff --git a/external/linker/cecil/Test/Resources/cs/CustomAttributes.cs b/external/linker/cecil/Test/Resources/cs/CustomAttributes.cs deleted file mode 100644 index dc2839b77d..0000000000 --- a/external/linker/cecil/Test/Resources/cs/CustomAttributes.cs +++ /dev/null @@ -1,158 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; - -[assembly: Foo ("bingo")] - -[assembly: TypeForwardedTo (typeof (System.Diagnostics.DebuggableAttribute))] - -enum Bingo : short { - Fuel = 2, - Binga = 4, -} - -/* -in System.Security.AccessControl - - [Flags] - public enum AceFlags : byte { - None = 0, - ObjectInherit = 0x01, - ContainerInherit = 0x02, - NoPropagateInherit = 0x04, - InheritOnly = 0x08, - InheritanceFlags = ObjectInherit | ContainerInherit | NoPropagateInherit | InheritOnly, - Inherited = 0x10, - SuccessfulAccess = 0x40, - FailedAccess = 0x80, - AuditFlags = SuccessfulAccess | FailedAccess, - } -*/ - -class FooAttribute : Attribute { - - internal class Token { - } - - public FooAttribute () - { - } - - public FooAttribute (string str) - { - } - - public FooAttribute (sbyte a, byte b, bool c, bool d, ushort e, short f, char g) - { - } - - public FooAttribute (int a, uint b, float c, long d, ulong e, double f) - { - } - - public FooAttribute (char [] chars) - { - } - - public FooAttribute (object a, object b) - { - } - - public FooAttribute (Bingo bingo) - { - } - - public FooAttribute (System.Security.AccessControl.AceFlags flags) - { - } - - public FooAttribute (Type type) - { - } - - public int Bang { get { return 0; } set {} } - public string Fiou { get { return "fiou"; } set {} } - - public object Pan; - public string [] PanPan; - - public Type Chose; -} - -[Foo ("bar")] -class Hamster { -} - -[Foo ((string) null)] -class Dentist { -} - -[Foo (-12, 242, true, false, 4242, -1983, 'c')] -class Steven { -} - -[Foo (-100000, 200000, 12.12f, long.MaxValue, ulong.MaxValue, 64.646464)] -class Seagull { -} - -[Foo (new char [] { 'c', 'e', 'c', 'i', 'l' })] -class Rifle { -} - -[Foo ("2", 2)] -class Worm { -} - -[Foo (new object [] { "2", 2, 'c' }, new object [] { new object [] { 1, 2, 3}, null })] -class Sheep { -} - -[Foo (Bang = 42, PanPan = new string [] { "yo", "yo" }, Pan = new object [] { 1, "2", '3' }, Fiou = null)] -class Angola { -} - -[Foo (Pan = "fiouuu")] -class BoxedStringField { -} - -[Foo (Bingo.Fuel)] -class Zero { -} - -[Foo (System.Security.AccessControl.AceFlags.NoPropagateInherit)] -class Ace { -} - -[Foo (new object [] { Bingo.Fuel, Bingo.Binga }, null, Pan = System.Security.AccessControl.AceFlags.NoPropagateInherit)] -class Bzzz { -} - -[Foo (typeof (Bingo))] -class Typed { -} - -[Foo (typeof (FooAttribute.Token))] -class NestedTyped { -} - -[Foo (Chose = typeof (Typed))] -class Truc { -} - -[Foo (Chose = (Type) null)] -class Machin { -} - -[Foo (typeof (Dictionary<,>))] -class OpenGeneric { -} - -[Foo (typeof (Dictionary[,]>))] -class ClosedGeneric { -} - -[Foo (typeof (Parent.Child[]))] -class Parent { - public class Child { - } -} diff --git a/external/linker/cecil/Test/Resources/cs/Events.cs b/external/linker/cecil/Test/Resources/cs/Events.cs deleted file mode 100644 index 22311060f6..0000000000 --- a/external/linker/cecil/Test/Resources/cs/Events.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -delegate void Pan (object sender, EventArgs args); - -abstract class Foo { - - public abstract event Pan Bar; -} diff --git a/external/linker/cecil/Test/Resources/cs/Fields.cs b/external/linker/cecil/Test/Resources/cs/Fields.cs deleted file mode 100644 index b85a57d1ce..0000000000 --- a/external/linker/cecil/Test/Resources/cs/Fields.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -class Foo { - Bar bar; -} - -class Bar { - volatile int oiseau; -} - -class Baz { - bool @bool; - char @char; - sbyte @sbyte; - byte @byte; - short int16; - ushort uint16; - int int32; - uint uint32; - long int64; - ulong uint64; - float single; - double @double; - string @string; - object @object; -} - -enum Pim { - Pam = 1, - Poum = 2, -} - -class PanPan { - - public const PanPan Peter = null; - public const string QQ = "qq"; - public const string nil = null; - public const object obj = null; - public const int [] ints = null; -} diff --git a/external/linker/cecil/Test/Resources/cs/Generics.cs b/external/linker/cecil/Test/Resources/cs/Generics.cs deleted file mode 100644 index 3f6b1f966c..0000000000 --- a/external/linker/cecil/Test/Resources/cs/Generics.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System; -using System.Collections.Generic; - -class Foo {} - -abstract class Bar { - - T bang; - - public abstract Bar Self (); - - public abstract Bar SelfString (); -} - -abstract class Baz { - - public abstract TBang Gazonk (object o); - - public abstract Bar Gazoo (); -} - -class Zap {} -interface IZoom {} - -class Bongo where T : Zap, IZoom { - - enum Dang { - Ding = 2, - Dong = 12, - } -} - -class Parent {} -class Child : Parent { - public T [] array; -} -class TamChild : Child {} -class RecChild : Child {} - -class Tamtam { - - static void Foo (TFoo tf) - { - } - - static void Bar () - { - Foo (2); - } - - static List Beta () - { - return new List (); - } - - static List Charlie () - { - return new List (); - } -} - -class It { - - public IEnumerable> Pwow () - { - yield return new Foo (); - yield return new Foo (); - yield return new Foo (); - } - - public void ReadPwow () - { - foreach (Foo foo in Pwow ()) - Tac (foo); - } - - public void Tac (T t) - { - } -} - -class Duel where T2 : T1 where T3 : T2 {} - -class ChildReader { - - public int Read (TamChild t) - { - return t.array.Length; - } -} - -struct Nilible where T : struct { - public T t; -} - -class Null { - - public static int Compare (Nilible x, Nilible y) where T : struct - { - return Comparer.Default.Compare (x.t, y.t); - } -} - -public class DoubleFuncClass { - public void Test () { Test (); Test (); } - public void Test () { Test (); Test (); } - public void Test () { Test (); Test (); } -} - -public class DoubleFuncClass { - public void Test () { Test (); Test (); } - public void Test () { Test (); Test (); } - public void Test () { Test (); Test (); } -} - -public class LaMatrix { - public static T At (T[,] m, int i, int j) - { - return m [i, j]; - } -} diff --git a/external/linker/cecil/Test/Resources/cs/Interfaces.cs b/external/linker/cecil/Test/Resources/cs/Interfaces.cs deleted file mode 100644 index 486c268a4b..0000000000 --- a/external/linker/cecil/Test/Resources/cs/Interfaces.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -interface IFoo {} -interface IBar : IFoo {} - -abstract class Bar : IBar {} - -interface IBingo { - void Foo (); - void Bar (); -} - -class Bingo : IBingo { - - void IBingo.Foo () - { - } - - void IBingo.Bar () - { - } -} diff --git a/external/linker/cecil/Test/Resources/cs/Layouts.cs b/external/linker/cecil/Test/Resources/cs/Layouts.cs deleted file mode 100644 index 3a332fd88d..0000000000 --- a/external/linker/cecil/Test/Resources/cs/Layouts.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -[StructLayout (LayoutKind.Explicit, Size = 16)] -public struct Foo { - [FieldOffset (0)] public ushort Bar; - [FieldOffset (2)] public ushort Baz; - [FieldOffset (4)] public uint Gazonk; -} - -class Babar { -} - -class Locke { - public int [] integers = new int [] { 1, 2, 3, 4 }; -} diff --git a/external/linker/cecil/Test/Resources/cs/Methods.cs b/external/linker/cecil/Test/Resources/cs/Methods.cs deleted file mode 100644 index 36c0383a68..0000000000 --- a/external/linker/cecil/Test/Resources/cs/Methods.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -abstract class Foo { - public abstract void Bar (int a); -} - -class Bar { - - [DllImport ("foo.dll")] - public extern static void Pan ([MarshalAs (UnmanagedType.I4)] int i); -} - -public class Baz { - - public void PrintAnswer () - { - Console.WriteLine ("answer: {0}", 42); - } -} - diff --git a/external/linker/cecil/Test/Resources/cs/NestedTypes.cs b/external/linker/cecil/Test/Resources/cs/NestedTypes.cs deleted file mode 100644 index 2129e6b258..0000000000 --- a/external/linker/cecil/Test/Resources/cs/NestedTypes.cs +++ /dev/null @@ -1,16 +0,0 @@ -class Foo { - class Bar { - class Baz { - } - } -} - -class Bingo { - public class Fuel { - } - - public static Fuel GetFuel () - { - return null; - } -} diff --git a/external/linker/cecil/Test/Resources/cs/Properties.cs b/external/linker/cecil/Test/Resources/cs/Properties.cs deleted file mode 100644 index 961a81a92b..0000000000 --- a/external/linker/cecil/Test/Resources/cs/Properties.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -abstract class Foo { - - public abstract int Bar { get; } - public abstract string Baz { get; set; } - public abstract string Gazonk { set; } -} - -abstract class Bar { - - public abstract Foo this [int a, string s] { set; } -} - -class Baz { - - public string Bingo { get; set; } -} diff --git a/external/linker/cecil/Test/Resources/il/branch-out.il b/external/linker/cecil/Test/Resources/il/branch-out.il deleted file mode 100644 index 74b7a2f04c..0000000000 --- a/external/linker/cecil/Test/Resources/il/branch-out.il +++ /dev/null @@ -1,34 +0,0 @@ -.assembly extern mscorlib -{ - .publickeytoken = (B7 7A 5C 56 19 34 E0 89) - .ver 2:0:0:0 -} - -.assembly BranchOut {} - -.module BranchOut.dll - -.class private auto ansi Foo { - - .method public specialname rtspecialname instance void .ctor () cil managed - { - ldarg.0 - call instance void [mscorlib]System.Object::.ctor () - ret - } - - .method public static void BranchOutside () - { - .maxstack 2 - .locals init () - .try - { - leave afterMethod - } - finally - { - endfinally - } - afterMethod: - } -} diff --git a/external/linker/cecil/Test/Resources/il/ca-empty-blob.il b/external/linker/cecil/Test/Resources/il/ca-empty-blob.il deleted file mode 100644 index 2d3d780d4e..0000000000 --- a/external/linker/cecil/Test/Resources/il/ca-empty-blob.il +++ /dev/null @@ -1,21 +0,0 @@ -.assembly extern mscorlib -{ - .publickeytoken = (B7 7A 5C 56 19 34 E0 89) - .ver 2:0:0:0 -} - -.assembly CaEmptyBlob {} - -.module CaEmptyBlob.dll - -.class public auto ansi CustomAttribute extends [mscorlib]System.Attribute -{ - .custom instance void CustomAttribute::.ctor() = () - - .method public hidebysig specialname rtspecialname instance void .ctor() - { - ldarg.0 - call instance void [mscorlib]System.Attribute::.ctor() - ret - } -} diff --git a/external/linker/cecil/Test/Resources/il/ca-iface-impl.il b/external/linker/cecil/Test/Resources/il/ca-iface-impl.il deleted file mode 100644 index 0428909398..0000000000 --- a/external/linker/cecil/Test/Resources/il/ca-iface-impl.il +++ /dev/null @@ -1,35 +0,0 @@ -.assembly extern mscorlib {} - -.assembly CA {} - -.module CA.dll - -.class public auto ansi beforefieldinit FooAttribute - extends [mscorlib]System.Attribute -{ - .method public hidebysig specialname rtspecialname instance void .ctor () - { - ldarg.0 - call instance void [mscorlib]System.Attribute::.ctor () - ret - } -} - -.class interface public auto ansi abstract IFoo -{ -} - -.class public auto ansi beforefieldinit FooType - extends [mscorlib]System.Object - implements IFoo -{ - .interfaceimpl type IFoo - .custom instance void FooAttribute::.ctor () - - .method public hidebysig specialname rtspecialname instance void .ctor () - { - ldarg.0 - call instance void [mscorlib]System.Object::.ctor () - ret - } -} diff --git a/external/linker/cecil/Test/Resources/il/explicitthis.il b/external/linker/cecil/Test/Resources/il/explicitthis.il deleted file mode 100644 index 59b3327694..0000000000 --- a/external/linker/cecil/Test/Resources/il/explicitthis.il +++ /dev/null @@ -1,113 +0,0 @@ -.assembly extern mscorlib -{ - .ver 0:0:0:0 -} - -.assembly fptr -{ - .ver 0:0:0:0 -} -.module fptr.exe - -.method public static void Main() cil managed -{ - .entrypoint - .locals init (class MakeDecision d, method instance explicit int32 *(class MakeDecision, int32) m, int32 i) - - ldc.i4.1 - ldc.i4 42 - newobj instance void MakeDecision::.ctor(bool, int32) - stloc d - - ldc.i4.0 - stloc i - br test - -loop: - ldloc d - call instance method instance explicit int32 *(class MakeDecision, int32) MakeDecision::Decide() - stloc m - - ldloc d - ldc.i4.1 - ldloc m - calli instance int32(int32) - call void [mscorlib]System.Console::WriteLine(int32) - - ldloc i - ldc.i4.1 - add - stloc i - -test: - ldloc i - ldc.i4 10 - blt loop - - ret -} - -.class public auto ansi sealed MakeDecision - extends [mscorlib]System.Object -{ - .field private bool Oscillate - .field private int32 Value - - .method public instance method instance explicit int32 *(class MakeDecision, int32) Decide() cil managed - { - .locals init (bool t) - - ldarg.0 - ldfld bool MakeDecision::Oscillate - stloc t - - ldarg.0 - ldloc t - ldc.i4.0 - ceq - stfld bool MakeDecision::Oscillate - - ldloc t - brfalse subs - - ldftn instance int32 MakeDecision::Add(int32) - ret - - subs: - ldftn instance int32 MakeDecision::Sub(int32) - ret - } - - .method public int32 Add(int32 i) cil managed - { - ldarg.0 - ldfld int32 MakeDecision::Value - ldarg i - add - ret - } - - .method public int32 Sub(int32 i) cil managed - { - ldarg.0 - ldfld int32 MakeDecision::Value - ldarg i - sub - ret - } - - .method public hidebysig specialname rtspecialname instance void .ctor(bool s, int32 val) cil managed - { - ldarg.0 - ldarg s - stfld bool MakeDecision::Oscillate - - ldarg.0 - ldarg val - stfld int32 MakeDecision::Value - - ldarg.0 - call instance void [mscorlib]System.Object::.ctor() - ret - } -} diff --git a/external/linker/cecil/Test/Resources/il/hello.il b/external/linker/cecil/Test/Resources/il/hello.il deleted file mode 100644 index a71b8fb4bc..0000000000 --- a/external/linker/cecil/Test/Resources/il/hello.il +++ /dev/null @@ -1,84 +0,0 @@ -.assembly extern mscorlib -{ - .publickeytoken = (B7 7A 5C 56 19 34 E0 89) - .ver 2:0:0:0 -} - -.assembly Hello {} - -.module Hello.dll - -.class private auto ansi Foo { - - .method public specialname rtspecialname instance void .ctor () cil managed - { - ldarg.0 - call instance void [mscorlib]System.Object::.ctor () - ret - } - - .method public static void Bar (int32 a, int32 b) - { - .locals init (int32 res) - ldarg.0 - ldarg.1 - mul - stloc.0 - ldloc.0 - call void Foo::Baz (int32) - ret - } - - .method public static void Baz (int32 a) - { - ret - } - - .method public void Gazonk () - { - ldarg 0 - pop - ret - } - - .method public static void PrintEmpty () - { - ldsfld string [mscorlib]System.String::Empty - call void [mscorlib]System.Console::WriteLine(string) - ret - } - - .method public static bool TestFilter (bool b) cil managed - { - .maxstack 2 - .locals init (bool flag) - beginTry: - newobj instance void [mscorlib]System.Exception::.ctor () - throw - leave endCatch - startFilter: - pop - ldarg.0 - endfilter - startCatch: - ldc.i4.1 - stloc.0 - leave return - leave endCatch - endCatch: - L_001b: ldc.i4.0 - L_001c: stloc.0 - return: - L_001d: ldloc.0 - L_001e: ret - .try beginTry to startFilter filter startFilter handler startCatch to endCatch - } - - .method public static !!T GetState(string var, [opt] !!T defaultValue) cil managed - { - .param [2] = nullref - - ldarg.1 - ret - } -} diff --git a/external/linker/cecil/Test/Resources/il/methodspecs.il b/external/linker/cecil/Test/Resources/il/methodspecs.il deleted file mode 100644 index b8006f322b..0000000000 --- a/external/linker/cecil/Test/Resources/il/methodspecs.il +++ /dev/null @@ -1,43 +0,0 @@ - -.assembly extern mscorlib -{ - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) - .ver 2:0:0:0 -} - -.assembly MethodSpecs -{ -} - -.module MethodSpecs.dll - -.class private auto ansi beforefieldinit Tamtam - extends [mscorlib]System.Object -{ - .method private hidebysig static void Foo(!!TFoo tf) cil managed - { - // Code size 1 (0x1) - .maxstack 8 - IL_0000: ret - } // end of method Tamtam::Foo - - .method private hidebysig static void Bar() cil managed - { - // Code size 7 (0x7) - .maxstack 8 - IL_0000: ldc.i4.2 - IL_0001: call void Tamtam::Foo(!!0) - IL_0006: ret - } // end of method Tamtam::Bar - - .method public hidebysig specialname rtspecialname - instance void .ctor() cil managed - { - // Code size 7 (0x7) - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void [mscorlib]System.Object::.ctor() - IL_0006: ret - } // end of method Tamtam::.ctor - -} // end of class Tamtam diff --git a/external/linker/cecil/Test/Resources/il/others.il b/external/linker/cecil/Test/Resources/il/others.il deleted file mode 100644 index 60713af30d..0000000000 --- a/external/linker/cecil/Test/Resources/il/others.il +++ /dev/null @@ -1,81 +0,0 @@ -.assembly extern mscorlib -{ - .publickeytoken = (B7 7A 5C 56 19 34 E0 89) - .ver 2:0:0:0 -} - -.assembly Others {} - -.module Others.dll - -.class private auto ansi Others { - - .field private string _context - - .method public specialname instance string get_Context () cil managed - { - ldarg.0 - ldfld string Others::_context - ret - } - - .method public specialname instance void set_Context (string val) cil managed - { - ldarg.0 - ldarg.1 - stfld string Others::_context - ret - } - - .method public specialname instance void let_Context (string val) cil managed - { - ldarg.0 - ldarg.1 - stfld string Others::_context - ret - } - - .method public specialname instance void bet_Context (string val) cil managed - { - ldarg.0 - ldarg.1 - stfld string Others::_context - ret - } - - .property instance string Context () { - .get instance string Others::get_Context () - .set instance void Others::set_Context (string val) - .other instance void Others::let_Context (string val) - .other instance void Others::bet_Context (string val) - } - - .field private class [mscorlib]System.EventHandler _handler - - .method public specialname instance void remove_Handler (class [mscorlib]System.EventHandler) cil managed - { - ret - } - - .method public specialname instance void add_Handler (class [mscorlib]System.EventHandler) cil managed - { - ret - } - - .method public specialname instance void dang_Handler (class [mscorlib]System.EventHandler) cil managed - { - ret - } - - .method public specialname instance void fang_Handler (class [mscorlib]System.EventHandler) cil managed - { - ret - } - - .event [mscorlib]System.EventHandler Handler { - .removeon instance void Others::remove_Handler (class [mscorlib]System.EventHandler) - .addon instance void Others::add_Handler (class [mscorlib]System.EventHandler) - .other instance void Others::dang_Handler (class [mscorlib]System.EventHandler) - .other instance void Others::fang_Handler (class [mscorlib]System.EventHandler) - } -} diff --git a/external/linker/cecil/Test/Resources/il/types.il b/external/linker/cecil/Test/Resources/il/types.il deleted file mode 100644 index 4c9acafb5e..0000000000 --- a/external/linker/cecil/Test/Resources/il/types.il +++ /dev/null @@ -1,46 +0,0 @@ -.assembly extern mscorlib -{ - .publickeytoken = (B7 7A 5C 56 19 34 E0 89) - .ver 2:0:0:0 -} - -.assembly Types {} - -.module Types.dll - -.class private auto ansi Types { - - .field public int32[,] rank_two - .field public int32[0...,0...] rank_two_low_bound_zero - .field public int32[-1...4] rank_one_low_bound_m1 - - .method public specialname rtspecialname instance void .ctor () cil managed - { - ldarg.0 - call instance void [mscorlib]System.Object::.ctor () - ret - } -} - -.class interface private abstract auto ansi IFoo -{ -} - -.class interface private abstract auto ansi IBar - implements IFoo -{ -} - -.class interface private abstract IBaz - implements IBar, IFoo -{ -} - -.class private Fields { - - .field private static literal int32 int32_int16 = int16(0x0001) - .field private static literal int16 int16_int32 = int32(0x00000001) - .field private static literal char char_int16 = int16(0x0001) - .field private static literal int16 int16_char = char(0x0073) - .field private static literal int32 int32_nullref = nullref -} diff --git a/external/linker/cecil/Test/libs/nunit-2.6.2/license.txt b/external/linker/cecil/Test/libs/nunit-2.6.2/license.txt deleted file mode 100644 index 530a6e0036..0000000000 --- a/external/linker/cecil/Test/libs/nunit-2.6.2/license.txt +++ /dev/null @@ -1,15 +0,0 @@ -Copyright © 2002-2012 Charlie Poole -Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov -Copyright © 2000-2002 Philip A. Craig - -This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment (see the following) in the product documentation is required. - -Portions Copyright © 2002-2012 Charlie Poole or Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov or Copyright © 2000-2002 Philip A. Craig - -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source distribution. diff --git a/external/linker/cecil/appveyor.yml b/external/linker/cecil/appveyor.yml deleted file mode 100644 index 9150a13a3a..0000000000 --- a/external/linker/cecil/appveyor.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: 0.9.6.{build} -configuration: net_4_0_Debug -build: - project: Mono.Cecil.sln - verbosity: minimal -test_script: -- nunit-console.exe Mono.Cecil.nunit -notifications: -- provider: Webhook - url: https://webhooks.gitter.im/e/925de8a68a6d8d3ce68e - on_build_success: false - on_build_failure: false - on_build_status_changed: true \ No newline at end of file diff --git a/external/linker/cecil/cecil.snk b/external/linker/cecil/cecil.snk deleted file mode 100644 index c0380d194f..0000000000 Binary files a/external/linker/cecil/cecil.snk and /dev/null differ diff --git a/external/linker/cecil/rocks/Mono.Cecil.Rocks.csproj b/external/linker/cecil/rocks/Mono.Cecil.Rocks.csproj deleted file mode 100644 index 045606b4e0..0000000000 --- a/external/linker/cecil/rocks/Mono.Cecil.Rocks.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC} - Mono.Cecil.Rocks - Mono.Cecil.Rocks - - - - - - - - {D68133BD-1E63-496E-9EDE-4FBDBF77B486} - Mono.Cecil - - - - - - $(DefineConstants);INSIDE_ROCKS - - \ No newline at end of file diff --git a/external/linker/cecil/rocks/Mono.Cecil.Rocks/AssemblyInfo.cs b/external/linker/cecil/rocks/Mono.Cecil.Rocks/AssemblyInfo.cs deleted file mode 100644 index 489ddee631..0000000000 --- a/external/linker/cecil/rocks/Mono.Cecil.Rocks/AssemblyInfo.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Reflection; - -[assembly: AssemblyTitle ("Mono.Cecil.Rocks")] - -[assembly: CLSCompliant (false)] diff --git a/external/linker/cecil/rocks/Mono.Cecil.Rocks/DocCommentId.cs b/external/linker/cecil/rocks/Mono.Cecil.Rocks/DocCommentId.cs deleted file mode 100644 index 30740df673..0000000000 --- a/external/linker/cecil/rocks/Mono.Cecil.Rocks/DocCommentId.cs +++ /dev/null @@ -1,264 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Mono.Cecil.Rocks { - - public class DocCommentId - { - StringBuilder id; - - DocCommentId () - { - id = new StringBuilder (); - } - - void WriteField (FieldDefinition field) - { - WriteDefinition ('F', field); - } - - void WriteEvent (EventDefinition @event) - { - WriteDefinition ('E', @event); - } - - void WriteType (TypeDefinition type) - { - id.Append ('T').Append (':'); - WriteTypeFullName (type); - } - - void WriteMethod (MethodDefinition method) - { - WriteDefinition ('M', method); - - if (method.HasGenericParameters) { - id.Append ('`').Append ('`'); - id.Append (method.GenericParameters.Count); - } - - if (method.HasParameters) - WriteParameters (method.Parameters); - - if (IsConversionOperator (method)) - WriteReturnType (method); - } - - static bool IsConversionOperator (MethodDefinition self) - { - if (self == null) - throw new ArgumentNullException ("self"); - - return self.IsSpecialName - && (self.Name == "op_Explicit" || self.Name == "op_Implicit"); - } - - void WriteReturnType (MethodDefinition method) - { - id.Append ('~'); - WriteTypeSignature (method.ReturnType); - } - - void WriteProperty (PropertyDefinition property) - { - WriteDefinition ('P', property); - - if (property.HasParameters) - WriteParameters (property.Parameters); - } - - void WriteParameters (IList parameters) - { - id.Append ('('); - WriteList (parameters, p => WriteTypeSignature (p.ParameterType)); - id.Append (')'); - } - - void WriteTypeSignature (TypeReference type) - { - switch (type.MetadataType) - { - case MetadataType.Array: - WriteArrayTypeSignature ((ArrayType) type); - break; - case MetadataType.ByReference: - WriteTypeSignature (((ByReferenceType) type).ElementType); - id.Append ('@'); - break; - case MetadataType.FunctionPointer: - WriteFunctionPointerTypeSignature ((FunctionPointerType) type); - break; - case MetadataType.GenericInstance: - WriteGenericInstanceTypeSignature ((GenericInstanceType) type); - break; - case MetadataType.Var: - id.Append ('`'); - id.Append (((GenericParameter) type).Position); - break; - case MetadataType.MVar: - id.Append ('`').Append ('`'); - id.Append (((GenericParameter) type).Position); - break; - case MetadataType.OptionalModifier: - WriteModiferTypeSignature ((OptionalModifierType) type, '!'); - break; - case MetadataType.RequiredModifier: - WriteModiferTypeSignature ((RequiredModifierType) type, '|'); - break; - case MetadataType.Pointer: - WriteTypeSignature (((PointerType) type).ElementType); - id.Append ('*'); - break; - default: - WriteTypeFullName (type); - break; - } - } - - void WriteGenericInstanceTypeSignature (GenericInstanceType type) - { - if (type.ElementType.IsTypeSpecification ()) - throw new NotSupportedException (); - - WriteTypeFullName (type.ElementType, stripGenericArity: true); - id.Append ('{'); - WriteList (type.GenericArguments, WriteTypeSignature); - id.Append ('}'); - } - - void WriteList (IList list, Action action) - { - for (int i = 0; i < list.Count; i++) { - if (i > 0) - id.Append (','); - - action (list [i]); - } - } - - void WriteModiferTypeSignature (IModifierType type, char id) - { - WriteTypeSignature (type.ElementType); - this.id.Append (id); - WriteTypeSignature (type.ModifierType); - } - - void WriteFunctionPointerTypeSignature (FunctionPointerType type) - { - id.Append ("=FUNC:"); - WriteTypeSignature (type.ReturnType); - - if (type.HasParameters) - WriteParameters (type.Parameters); - } - - void WriteArrayTypeSignature (ArrayType type) - { - WriteTypeSignature (type.ElementType); - - if (type.IsVector) { - id.Append ("[]"); - return; - } - - id.Append ("["); - - WriteList (type.Dimensions, dimension => { - if (dimension.LowerBound.HasValue) - id.Append (dimension.LowerBound.Value); - - id.Append (':'); - - if (dimension.UpperBound.HasValue) - id.Append (dimension.UpperBound.Value - (dimension.LowerBound.GetValueOrDefault () + 1)); - }); - - id.Append ("]"); - } - - void WriteDefinition (char id, IMemberDefinition member) - { - this.id.Append (id) - .Append (':'); - - WriteTypeFullName (member.DeclaringType); - this.id.Append ('.'); - WriteItemName (member.Name); - } - - void WriteTypeFullName (TypeReference type, bool stripGenericArity = false) - { - if (type.DeclaringType != null) { - WriteTypeFullName (type.DeclaringType); - id.Append ('.'); - } - - if (!string.IsNullOrEmpty (type.Namespace)) { - id.Append (type.Namespace); - id.Append ('.'); - } - - var name = type.Name; - - if (stripGenericArity) { - var index = name.LastIndexOf ('`'); - if (index > 0) - name = name.Substring (0, index); - } - - id.Append (name); - } - - void WriteItemName (string name) - { - id.Append (name.Replace ('.', '#')); - } - - public override string ToString () - { - return id.ToString (); - } - - public static string GetDocCommentId (IMemberDefinition member) - { - if (member == null) - throw new ArgumentNullException ("member"); - - var documentId = new DocCommentId (); - - switch (member.MetadataToken.TokenType) - { - case TokenType.Field: - documentId.WriteField ((FieldDefinition) member); - break; - case TokenType.Method: - documentId.WriteMethod ((MethodDefinition) member); - break; - case TokenType.TypeDef: - documentId.WriteType ((TypeDefinition) member); - break; - case TokenType.Event: - documentId.WriteEvent ((EventDefinition) member); - break; - case TokenType.Property: - documentId.WriteProperty ((PropertyDefinition) member); - break; - default: - throw new NotSupportedException (member.FullName); - } - - return documentId.ToString (); - } - } -} diff --git a/external/linker/cecil/rocks/Mono.Cecil.Rocks/Functional.cs b/external/linker/cecil/rocks/Mono.Cecil.Rocks/Functional.cs deleted file mode 100644 index bff52e4a29..0000000000 --- a/external/linker/cecil/rocks/Mono.Cecil.Rocks/Functional.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; - -namespace Mono.Cecil.Rocks { - - static class Functional { - - public static System.Func Y (System.Func, System.Func> f) - { - System.Func g = null; - g = f (a => g (a)); - return g; - } - - public static IEnumerable Prepend (this IEnumerable source, TSource element) - { - if (source == null) - throw new ArgumentNullException ("source"); - - return PrependIterator (source, element); - } - - static IEnumerable PrependIterator (IEnumerable source, TSource element) - { - yield return element; - - foreach (var item in source) - yield return item; - } - } -} diff --git a/external/linker/cecil/rocks/Mono.Cecil.Rocks/ILParser.cs b/external/linker/cecil/rocks/Mono.Cecil.Rocks/ILParser.cs deleted file mode 100644 index e05068ff3c..0000000000 --- a/external/linker/cecil/rocks/Mono.Cecil.Rocks/ILParser.cs +++ /dev/null @@ -1,229 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using Mono.Cecil.Cil; -using Mono.Collections.Generic; - -namespace Mono.Cecil.Rocks { - -#if INSIDE_ROCKS - public -#endif - interface IILVisitor { - void OnInlineNone (OpCode opcode); - void OnInlineSByte (OpCode opcode, sbyte value); - void OnInlineByte (OpCode opcode, byte value); - void OnInlineInt32 (OpCode opcode, int value); - void OnInlineInt64 (OpCode opcode, long value); - void OnInlineSingle (OpCode opcode, float value); - void OnInlineDouble (OpCode opcode, double value); - void OnInlineString (OpCode opcode, string value); - void OnInlineBranch (OpCode opcode, int offset); - void OnInlineSwitch (OpCode opcode, int [] offsets); - void OnInlineVariable (OpCode opcode, VariableDefinition variable); - void OnInlineArgument (OpCode opcode, ParameterDefinition parameter); - void OnInlineSignature (OpCode opcode, CallSite callSite); - void OnInlineType (OpCode opcode, TypeReference type); - void OnInlineField (OpCode opcode, FieldReference field); - void OnInlineMethod (OpCode opcode, MethodReference method); - } - -#if INSIDE_ROCKS - public -#endif - static class ILParser { - - class ParseContext { - public CodeReader Code { get; set; } - public int Position { get; set; } - public MetadataReader Metadata { get; set; } - public Collection Variables { get; set; } - public IILVisitor Visitor { get; set; } - } - - public static void Parse (MethodDefinition method, IILVisitor visitor) - { - if (method == null) - throw new ArgumentNullException ("method"); - if (visitor == null) - throw new ArgumentNullException ("visitor"); - if (!method.HasBody || !method.HasImage) - throw new ArgumentException (); - - method.Module.Read (method, (m, _) => { - ParseMethod (m, visitor); - return true; - }); - } - - static void ParseMethod (MethodDefinition method, IILVisitor visitor) - { - var context = CreateContext (method, visitor); - var code = context.Code; - - var flags = code.ReadByte (); - - switch (flags & 0x3) { - case 0x2: // tiny - int code_size = flags >> 2; - ParseCode (code_size, context); - break; - case 0x3: // fat - code.Advance (-1); - ParseFatMethod (context); - break; - default: - throw new NotSupportedException (); - } - - code.MoveBackTo (context.Position); - } - - static ParseContext CreateContext (MethodDefinition method, IILVisitor visitor) - { - var code = method.Module.Read (method, (_, reader) => reader.code); - var position = code.MoveTo (method); - - return new ParseContext { - Code = code, - Position = position, - Metadata = code.reader, - Visitor = visitor, - }; - } - - static void ParseFatMethod (ParseContext context) - { - var code = context.Code; - - code.Advance (4); - var code_size = code.ReadInt32 (); - var local_var_token = code.ReadToken (); - - if (local_var_token != MetadataToken.Zero) - context.Variables = code.ReadVariables (local_var_token); - - ParseCode (code_size, context); - } - - static void ParseCode (int code_size, ParseContext context) - { - var code = context.Code; - var metadata = context.Metadata; - var visitor = context.Visitor; - - var start = code.Position; - var end = start + code_size; - - while (code.Position < end) { - var il_opcode = code.ReadByte (); - var opcode = il_opcode != 0xfe - ? OpCodes.OneByteOpCode [il_opcode] - : OpCodes.TwoBytesOpCode [code.ReadByte ()]; - - switch (opcode.OperandType) { - case OperandType.InlineNone: - visitor.OnInlineNone (opcode); - break; - case OperandType.InlineSwitch: - var length = code.ReadInt32 (); - var branches = new int [length]; - for (int i = 0; i < length; i++) - branches [i] = code.ReadInt32 (); - visitor.OnInlineSwitch (opcode, branches); - break; - case OperandType.ShortInlineBrTarget: - visitor.OnInlineBranch (opcode, code.ReadSByte ()); - break; - case OperandType.InlineBrTarget: - visitor.OnInlineBranch (opcode, code.ReadInt32 ()); - break; - case OperandType.ShortInlineI: - if (opcode == OpCodes.Ldc_I4_S) - visitor.OnInlineSByte (opcode, code.ReadSByte ()); - else - visitor.OnInlineByte (opcode, code.ReadByte ()); - break; - case OperandType.InlineI: - visitor.OnInlineInt32 (opcode, code.ReadInt32 ()); - break; - case OperandType.InlineI8: - visitor.OnInlineInt64 (opcode, code.ReadInt64 ()); - break; - case OperandType.ShortInlineR: - visitor.OnInlineSingle (opcode, code.ReadSingle ()); - break; - case OperandType.InlineR: - visitor.OnInlineDouble (opcode, code.ReadDouble ()); - break; - case OperandType.InlineSig: - visitor.OnInlineSignature (opcode, code.GetCallSite (code.ReadToken ())); - break; - case OperandType.InlineString: - visitor.OnInlineString (opcode, code.GetString (code.ReadToken ())); - break; - case OperandType.ShortInlineArg: - visitor.OnInlineArgument (opcode, code.GetParameter (code.ReadByte ())); - break; - case OperandType.InlineArg: - visitor.OnInlineArgument (opcode, code.GetParameter (code.ReadInt16 ())); - break; - case OperandType.ShortInlineVar: - visitor.OnInlineVariable (opcode, GetVariable (context, code.ReadByte ())); - break; - case OperandType.InlineVar: - visitor.OnInlineVariable (opcode, GetVariable (context, code.ReadInt16 ())); - break; - case OperandType.InlineTok: - case OperandType.InlineField: - case OperandType.InlineMethod: - case OperandType.InlineType: - var member = metadata.LookupToken (code.ReadToken ()); - switch (member.MetadataToken.TokenType) { - case TokenType.TypeDef: - case TokenType.TypeRef: - case TokenType.TypeSpec: - visitor.OnInlineType (opcode, (TypeReference) member); - break; - case TokenType.Method: - case TokenType.MethodSpec: - visitor.OnInlineMethod (opcode, (MethodReference) member); - break; - case TokenType.Field: - visitor.OnInlineField (opcode, (FieldReference) member); - break; - case TokenType.MemberRef: - var field_ref = member as FieldReference; - if (field_ref != null) { - visitor.OnInlineField (opcode, field_ref); - break; - } - - var method_ref = member as MethodReference; - if (method_ref != null) { - visitor.OnInlineMethod (opcode, method_ref); - break; - } - - throw new InvalidOperationException (); - } - break; - } - } - } - - static VariableDefinition GetVariable (ParseContext context, int index) - { - return context.Variables [index]; - } - } -} diff --git a/external/linker/cecil/rocks/Mono.Cecil.Rocks/MethodBodyRocks.cs b/external/linker/cecil/rocks/Mono.Cecil.Rocks/MethodBodyRocks.cs deleted file mode 100644 index c627d2f3e9..0000000000 --- a/external/linker/cecil/rocks/Mono.Cecil.Rocks/MethodBodyRocks.cs +++ /dev/null @@ -1,412 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -using Mono.Cecil.Cil; - -namespace Mono.Cecil.Rocks { - -#if INSIDE_ROCKS - public -#endif - static class MethodBodyRocks { - - public static void SimplifyMacros (this MethodBody self) - { - if (self == null) - throw new ArgumentNullException ("self"); - - foreach (var instruction in self.Instructions) { - if (instruction.OpCode.OpCodeType != OpCodeType.Macro) - continue; - - switch (instruction.OpCode.Code) { - case Code.Ldarg_0: - ExpandMacro (instruction, OpCodes.Ldarg, self.GetParameter (0)); - break; - case Code.Ldarg_1: - ExpandMacro (instruction, OpCodes.Ldarg, self.GetParameter (1)); - break; - case Code.Ldarg_2: - ExpandMacro (instruction, OpCodes.Ldarg, self.GetParameter (2)); - break; - case Code.Ldarg_3: - ExpandMacro (instruction, OpCodes.Ldarg, self.GetParameter (3)); - break; - case Code.Ldloc_0: - ExpandMacro (instruction, OpCodes.Ldloc, self.Variables [0]); - break; - case Code.Ldloc_1: - ExpandMacro (instruction, OpCodes.Ldloc, self.Variables [1]); - break; - case Code.Ldloc_2: - ExpandMacro (instruction, OpCodes.Ldloc, self.Variables [2]); - break; - case Code.Ldloc_3: - ExpandMacro (instruction, OpCodes.Ldloc, self.Variables [3]); - break; - case Code.Stloc_0: - ExpandMacro (instruction, OpCodes.Stloc, self.Variables [0]); - break; - case Code.Stloc_1: - ExpandMacro (instruction, OpCodes.Stloc, self.Variables [1]); - break; - case Code.Stloc_2: - ExpandMacro (instruction, OpCodes.Stloc, self.Variables [2]); - break; - case Code.Stloc_3: - ExpandMacro (instruction, OpCodes.Stloc, self.Variables [3]); - break; - case Code.Ldarg_S: - instruction.OpCode = OpCodes.Ldarg; - break; - case Code.Ldarga_S: - instruction.OpCode = OpCodes.Ldarga; - break; - case Code.Starg_S: - instruction.OpCode = OpCodes.Starg; - break; - case Code.Ldloc_S: - instruction.OpCode = OpCodes.Ldloc; - break; - case Code.Ldloca_S: - instruction.OpCode = OpCodes.Ldloca; - break; - case Code.Stloc_S: - instruction.OpCode = OpCodes.Stloc; - break; - case Code.Ldc_I4_M1: - ExpandMacro (instruction, OpCodes.Ldc_I4, -1); - break; - case Code.Ldc_I4_0: - ExpandMacro (instruction, OpCodes.Ldc_I4, 0); - break; - case Code.Ldc_I4_1: - ExpandMacro (instruction, OpCodes.Ldc_I4, 1); - break; - case Code.Ldc_I4_2: - ExpandMacro (instruction, OpCodes.Ldc_I4, 2); - break; - case Code.Ldc_I4_3: - ExpandMacro (instruction, OpCodes.Ldc_I4, 3); - break; - case Code.Ldc_I4_4: - ExpandMacro (instruction, OpCodes.Ldc_I4, 4); - break; - case Code.Ldc_I4_5: - ExpandMacro (instruction, OpCodes.Ldc_I4, 5); - break; - case Code.Ldc_I4_6: - ExpandMacro (instruction, OpCodes.Ldc_I4, 6); - break; - case Code.Ldc_I4_7: - ExpandMacro (instruction, OpCodes.Ldc_I4, 7); - break; - case Code.Ldc_I4_8: - ExpandMacro (instruction, OpCodes.Ldc_I4, 8); - break; - case Code.Ldc_I4_S: - ExpandMacro (instruction, OpCodes.Ldc_I4, (int) (sbyte) instruction.Operand); - break; - case Code.Br_S: - instruction.OpCode = OpCodes.Br; - break; - case Code.Brfalse_S: - instruction.OpCode = OpCodes.Brfalse; - break; - case Code.Brtrue_S: - instruction.OpCode = OpCodes.Brtrue; - break; - case Code.Beq_S: - instruction.OpCode = OpCodes.Beq; - break; - case Code.Bge_S: - instruction.OpCode = OpCodes.Bge; - break; - case Code.Bgt_S: - instruction.OpCode = OpCodes.Bgt; - break; - case Code.Ble_S: - instruction.OpCode = OpCodes.Ble; - break; - case Code.Blt_S: - instruction.OpCode = OpCodes.Blt; - break; - case Code.Bne_Un_S: - instruction.OpCode = OpCodes.Bne_Un; - break; - case Code.Bge_Un_S: - instruction.OpCode = OpCodes.Bge_Un; - break; - case Code.Bgt_Un_S: - instruction.OpCode = OpCodes.Bgt_Un; - break; - case Code.Ble_Un_S: - instruction.OpCode = OpCodes.Ble_Un; - break; - case Code.Blt_Un_S: - instruction.OpCode = OpCodes.Blt_Un; - break; - case Code.Leave_S: - instruction.OpCode = OpCodes.Leave; - break; - } - } - } - - static void ExpandMacro (Instruction instruction, OpCode opcode, object operand) - { - instruction.OpCode = opcode; - instruction.Operand = operand; - } - - static void MakeMacro (Instruction instruction, OpCode opcode) - { - instruction.OpCode = opcode; - instruction.Operand = null; - } - - public static void Optimize (this MethodBody self) - { - if (self == null) - throw new ArgumentNullException ("self"); - - OptimizeLongs (self); - OptimizeMacros (self); - } - - static void OptimizeLongs (this MethodBody self) - { - for (var i = 0; i < self.Instructions.Count; i++) { - var instruction = self.Instructions [i]; - if (instruction.OpCode.Code != Code.Ldc_I8) - continue; - var l = (long) instruction.Operand; - if (l >= int.MaxValue || l <= int.MinValue) - continue; - ExpandMacro (instruction, OpCodes.Ldc_I4, (int) l); - self.Instructions.Insert (++i, Instruction.Create (OpCodes.Conv_I8)); - } - } - - public static void OptimizeMacros (this MethodBody self) - { - if (self == null) - throw new ArgumentNullException ("self"); - - var method = self.Method; - - foreach (var instruction in self.Instructions) { - int index; - switch (instruction.OpCode.Code) { - case Code.Ldarg: - index = ((ParameterDefinition) instruction.Operand).Index; - if (index == -1 && instruction.Operand == self.ThisParameter) - index = 0; - else if (method.HasThis) - index++; - - switch (index) { - case 0: - MakeMacro (instruction, OpCodes.Ldarg_0); - break; - case 1: - MakeMacro (instruction, OpCodes.Ldarg_1); - break; - case 2: - MakeMacro (instruction, OpCodes.Ldarg_2); - break; - case 3: - MakeMacro (instruction, OpCodes.Ldarg_3); - break; - default: - if (index < 256) - ExpandMacro (instruction, OpCodes.Ldarg_S, instruction.Operand); - break; - } - break; - case Code.Ldloc: - index = ((VariableDefinition) instruction.Operand).Index; - switch (index) { - case 0: - MakeMacro (instruction, OpCodes.Ldloc_0); - break; - case 1: - MakeMacro (instruction, OpCodes.Ldloc_1); - break; - case 2: - MakeMacro (instruction, OpCodes.Ldloc_2); - break; - case 3: - MakeMacro (instruction, OpCodes.Ldloc_3); - break; - default: - if (index < 256) - ExpandMacro (instruction, OpCodes.Ldloc_S, instruction.Operand); - break; - } - break; - case Code.Stloc: - index = ((VariableDefinition) instruction.Operand).Index; - switch (index) { - case 0: - MakeMacro (instruction, OpCodes.Stloc_0); - break; - case 1: - MakeMacro (instruction, OpCodes.Stloc_1); - break; - case 2: - MakeMacro (instruction, OpCodes.Stloc_2); - break; - case 3: - MakeMacro (instruction, OpCodes.Stloc_3); - break; - default: - if (index < 256) - ExpandMacro (instruction, OpCodes.Stloc_S, instruction.Operand); - break; - } - break; - case Code.Ldarga: - index = ((ParameterDefinition) instruction.Operand).Index; - if (index == -1 && instruction.Operand == self.ThisParameter) - index = 0; - else if (method.HasThis) - index++; - if (index < 256) - ExpandMacro (instruction, OpCodes.Ldarga_S, instruction.Operand); - break; - case Code.Ldloca: - if (((VariableDefinition) instruction.Operand).Index < 256) - ExpandMacro (instruction, OpCodes.Ldloca_S, instruction.Operand); - break; - case Code.Ldc_I4: - int i = (int) instruction.Operand; - switch (i) { - case -1: - MakeMacro (instruction, OpCodes.Ldc_I4_M1); - break; - case 0: - MakeMacro (instruction, OpCodes.Ldc_I4_0); - break; - case 1: - MakeMacro (instruction, OpCodes.Ldc_I4_1); - break; - case 2: - MakeMacro (instruction, OpCodes.Ldc_I4_2); - break; - case 3: - MakeMacro (instruction, OpCodes.Ldc_I4_3); - break; - case 4: - MakeMacro (instruction, OpCodes.Ldc_I4_4); - break; - case 5: - MakeMacro (instruction, OpCodes.Ldc_I4_5); - break; - case 6: - MakeMacro (instruction, OpCodes.Ldc_I4_6); - break; - case 7: - MakeMacro (instruction, OpCodes.Ldc_I4_7); - break; - case 8: - MakeMacro (instruction, OpCodes.Ldc_I4_8); - break; - default: - if (i >= -128 && i < 128) - ExpandMacro (instruction, OpCodes.Ldc_I4_S, (sbyte) i); - break; - } - break; - } - } - - OptimizeBranches (self); - } - - static void OptimizeBranches (MethodBody body) - { - ComputeOffsets (body); - - foreach (var instruction in body.Instructions) { - if (instruction.OpCode.OperandType != OperandType.InlineBrTarget) - continue; - - if (OptimizeBranch (instruction)) - ComputeOffsets (body); - } - } - - static bool OptimizeBranch (Instruction instruction) - { - var offset = ((Instruction) instruction.Operand).Offset - (instruction.Offset + instruction.OpCode.Size + 4); - if (!(offset >= -128 && offset <= 127)) - return false; - - switch (instruction.OpCode.Code) { - case Code.Br: - instruction.OpCode = OpCodes.Br_S; - break; - case Code.Brfalse: - instruction.OpCode = OpCodes.Brfalse_S; - break; - case Code.Brtrue: - instruction.OpCode = OpCodes.Brtrue_S; - break; - case Code.Beq: - instruction.OpCode = OpCodes.Beq_S; - break; - case Code.Bge: - instruction.OpCode = OpCodes.Bge_S; - break; - case Code.Bgt: - instruction.OpCode = OpCodes.Bgt_S; - break; - case Code.Ble: - instruction.OpCode = OpCodes.Ble_S; - break; - case Code.Blt: - instruction.OpCode = OpCodes.Blt_S; - break; - case Code.Bne_Un: - instruction.OpCode = OpCodes.Bne_Un_S; - break; - case Code.Bge_Un: - instruction.OpCode = OpCodes.Bge_Un_S; - break; - case Code.Bgt_Un: - instruction.OpCode = OpCodes.Bgt_Un_S; - break; - case Code.Ble_Un: - instruction.OpCode = OpCodes.Ble_Un_S; - break; - case Code.Blt_Un: - instruction.OpCode = OpCodes.Blt_Un_S; - break; - case Code.Leave: - instruction.OpCode = OpCodes.Leave_S; - break; - } - - return true; - } - - static void ComputeOffsets (MethodBody body) - { - var offset = 0; - foreach (var instruction in body.Instructions) { - instruction.Offset = offset; - offset += instruction.GetSize (); - } - } - } -} diff --git a/external/linker/cecil/rocks/Mono.Cecil.Rocks/MethodDefinitionRocks.cs b/external/linker/cecil/rocks/Mono.Cecil.Rocks/MethodDefinitionRocks.cs deleted file mode 100644 index 3ef20a1003..0000000000 --- a/external/linker/cecil/rocks/Mono.Cecil.Rocks/MethodDefinitionRocks.cs +++ /dev/null @@ -1,72 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; - -namespace Mono.Cecil.Rocks { - -#if INSIDE_ROCKS - public -#endif - static class MethodDefinitionRocks { - - public static MethodDefinition GetBaseMethod (this MethodDefinition self) - { - if (self == null) - throw new ArgumentNullException ("self"); - if (!self.IsVirtual) - return self; - if (self.IsNewSlot) - return self; - - var base_type = ResolveBaseType (self.DeclaringType); - while (base_type != null) { - var @base = GetMatchingMethod (base_type, self); - if (@base != null) - return @base; - - base_type = ResolveBaseType (base_type); - } - - return self; - } - - public static MethodDefinition GetOriginalBaseMethod (this MethodDefinition self) - { - if (self == null) - throw new ArgumentNullException ("self"); - - while (true) { - var @base = self.GetBaseMethod (); - if (@base == self) - return self; - - self = @base; - } - } - - static TypeDefinition ResolveBaseType (TypeDefinition type) - { - if (type == null) - return null; - - var base_type = type.BaseType; - if (base_type == null) - return null; - - return base_type.Resolve (); - } - - static MethodDefinition GetMatchingMethod (TypeDefinition type, MethodDefinition method) - { - return MetadataResolver.GetMethod (type.Methods, method); - } - } -} diff --git a/external/linker/cecil/rocks/Mono.Cecil.Rocks/ModuleDefinitionRocks.cs b/external/linker/cecil/rocks/Mono.Cecil.Rocks/ModuleDefinitionRocks.cs deleted file mode 100644 index 756d31f06a..0000000000 --- a/external/linker/cecil/rocks/Mono.Cecil.Rocks/ModuleDefinitionRocks.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Mono.Cecil.Rocks { - -#if INSIDE_ROCKS - public -#endif - static class ModuleDefinitionRocks { - - public static IEnumerable GetAllTypes (this ModuleDefinition self) - { - if (self == null) - throw new ArgumentNullException ("self"); - - // it was fun to write, but we need a somewhat less convoluted implementation - return self.Types.SelectMany ( - Functional.Y> (f => type => type.NestedTypes.SelectMany (f).Prepend (type))); - } - } -} diff --git a/external/linker/cecil/rocks/Mono.Cecil.Rocks/ParameterReferenceRocks.cs b/external/linker/cecil/rocks/Mono.Cecil.Rocks/ParameterReferenceRocks.cs deleted file mode 100644 index 554bdb9099..0000000000 --- a/external/linker/cecil/rocks/Mono.Cecil.Rocks/ParameterReferenceRocks.cs +++ /dev/null @@ -1,11 +0,0 @@ - -namespace Mono.Cecil.Rocks { - - public static class ParameterReferenceRocks { - - public static int GetSequence (this ParameterReference self) - { - return self.Index + 1; - } - } -} diff --git a/external/linker/cecil/rocks/Mono.Cecil.Rocks/SecurityDeclarationRocks.cs b/external/linker/cecil/rocks/Mono.Cecil.Rocks/SecurityDeclarationRocks.cs deleted file mode 100644 index 20808fe715..0000000000 --- a/external/linker/cecil/rocks/Mono.Cecil.Rocks/SecurityDeclarationRocks.cs +++ /dev/null @@ -1,156 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -#if !NET_CORE - -using System; -using System.Security; -using SSP = System.Security.Permissions; - -namespace Mono.Cecil.Rocks { - -#if INSIDE_ROCKS - public -#endif - static class SecurityDeclarationRocks { - - public static PermissionSet ToPermissionSet (this SecurityDeclaration self) - { - if (self == null) - throw new ArgumentNullException ("self"); - - PermissionSet set; - if (TryProcessPermissionSetAttribute (self, out set)) - return set; - - return CreatePermissionSet (self); - } - - static bool TryProcessPermissionSetAttribute (SecurityDeclaration declaration, out PermissionSet set) - { - set = null; - - if (!declaration.HasSecurityAttributes && declaration.SecurityAttributes.Count != 1) - return false; - - var security_attribute = declaration.SecurityAttributes [0]; - if (!security_attribute.AttributeType.IsTypeOf ("System.Security.Permissions", "PermissionSetAttribute")) - return false; - - var attribute = new SSP.PermissionSetAttribute ((SSP.SecurityAction) declaration.Action); - - var named_argument = security_attribute.Properties [0]; - string value = (string) named_argument.Argument.Value; - switch (named_argument.Name) { - case "XML": - attribute.XML = value; - break; - case "Name": - attribute.Name = value; - break; - default: - throw new NotImplementedException (named_argument.Name); - } - - set = attribute.CreatePermissionSet (); - return true; - } - - static PermissionSet CreatePermissionSet (SecurityDeclaration declaration) - { - var set = new PermissionSet (SSP.PermissionState.None); - - foreach (var attribute in declaration.SecurityAttributes) { - var permission = CreatePermission (declaration, attribute); - set.AddPermission (permission); - } - - return set; - } - - static IPermission CreatePermission (SecurityDeclaration declaration, SecurityAttribute attribute) - { - var attribute_type = Type.GetType (attribute.AttributeType.FullName); - if (attribute_type == null) - throw new ArgumentException ("attribute"); - - var security_attribute = CreateSecurityAttribute (attribute_type, declaration); - if (security_attribute == null) - throw new InvalidOperationException (); - - CompleteSecurityAttribute (security_attribute, attribute); - - return security_attribute.CreatePermission (); - } - - static void CompleteSecurityAttribute (SSP.SecurityAttribute security_attribute, SecurityAttribute attribute) - { - if (attribute.HasFields) - CompleteSecurityAttributeFields (security_attribute, attribute); - - if (attribute.HasProperties) - CompleteSecurityAttributeProperties (security_attribute, attribute); - } - - static void CompleteSecurityAttributeFields (SSP.SecurityAttribute security_attribute, SecurityAttribute attribute) - { - var type = security_attribute.GetType (); - - foreach (var named_argument in attribute.Fields) - type.GetField (named_argument.Name).SetValue (security_attribute, named_argument.Argument.Value); - } - - static void CompleteSecurityAttributeProperties (SSP.SecurityAttribute security_attribute, SecurityAttribute attribute) - { - var type = security_attribute.GetType (); - - foreach (var named_argument in attribute.Properties) - type.GetProperty (named_argument.Name).SetValue (security_attribute, named_argument.Argument.Value, null); - } - - static SSP.SecurityAttribute CreateSecurityAttribute (Type attribute_type, SecurityDeclaration declaration) - { - SSP.SecurityAttribute security_attribute; - try { - security_attribute = (SSP.SecurityAttribute) Activator.CreateInstance ( - attribute_type, new object [] { (SSP.SecurityAction) declaration.Action }); - } catch (MissingMethodException) { - security_attribute = (SSP.SecurityAttribute) Activator.CreateInstance (attribute_type, new object [0]); - } - - return security_attribute; - } - - public static SecurityDeclaration ToSecurityDeclaration (this PermissionSet self, SecurityAction action, ModuleDefinition module) - { - if (self == null) - throw new ArgumentNullException ("self"); - if (module == null) - throw new ArgumentNullException ("module"); - - var declaration = new SecurityDeclaration (action); - - var attribute = new SecurityAttribute ( - module.TypeSystem.LookupType ("System.Security.Permissions", "PermissionSetAttribute")); - - attribute.Properties.Add ( - new CustomAttributeNamedArgument ( - "XML", - new CustomAttributeArgument ( - module.TypeSystem.String, self.ToXml ().ToString ()))); - - declaration.SecurityAttributes.Add (attribute); - - return declaration; - } - } -} - -#endif diff --git a/external/linker/cecil/rocks/Mono.Cecil.Rocks/TypeDefinitionRocks.cs b/external/linker/cecil/rocks/Mono.Cecil.Rocks/TypeDefinitionRocks.cs deleted file mode 100644 index baa88e0341..0000000000 --- a/external/linker/cecil/rocks/Mono.Cecil.Rocks/TypeDefinitionRocks.cs +++ /dev/null @@ -1,65 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Mono.Cecil.Rocks { - -#if INSIDE_ROCKS - public -#endif - static class TypeDefinitionRocks { - - public static IEnumerable GetConstructors (this TypeDefinition self) - { - if (self == null) - throw new ArgumentNullException ("self"); - - if (!self.HasMethods) - return Empty.Array; - - return self.Methods.Where (method => method.IsConstructor); - } - - public static MethodDefinition GetStaticConstructor (this TypeDefinition self) - { - if (self == null) - throw new ArgumentNullException ("self"); - - if (!self.HasMethods) - return null; - - return self.GetConstructors ().FirstOrDefault (ctor => ctor.IsStatic); - } - - public static IEnumerable GetMethods (this TypeDefinition self) - { - if (self == null) - throw new ArgumentNullException ("self"); - - if (!self.HasMethods) - return Empty.Array; - - return self.Methods.Where (method => !method.IsConstructor); - } - - public static TypeReference GetEnumUnderlyingType (this TypeDefinition self) - { - if (self == null) - throw new ArgumentNullException ("self"); - if (!self.IsEnum) - throw new ArgumentException (); - - return Mixin.GetEnumUnderlyingType (self); - } - } -} diff --git a/external/linker/cecil/rocks/Mono.Cecil.Rocks/TypeReferenceRocks.cs b/external/linker/cecil/rocks/Mono.Cecil.Rocks/TypeReferenceRocks.cs deleted file mode 100644 index c39523641c..0000000000 --- a/external/linker/cecil/rocks/Mono.Cecil.Rocks/TypeReferenceRocks.cs +++ /dev/null @@ -1,89 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Mono.Cecil.Rocks { - -#if INSIDE_ROCKS - public -#endif - static class TypeReferenceRocks { - - public static ArrayType MakeArrayType (this TypeReference self) - { - return new ArrayType (self); - } - - public static ArrayType MakeArrayType (this TypeReference self, int rank) - { - if (rank == 0) - throw new ArgumentOutOfRangeException ("rank"); - - var array = new ArrayType (self); - - for (int i = 1; i < rank; i++) - array.Dimensions.Add (new ArrayDimension ()); - - return array; - } - - public static PointerType MakePointerType (this TypeReference self) - { - return new PointerType (self); - } - - public static ByReferenceType MakeByReferenceType (this TypeReference self) - { - return new ByReferenceType (self); - } - - public static OptionalModifierType MakeOptionalModifierType (this TypeReference self, TypeReference modifierType) - { - return new OptionalModifierType (modifierType, self); - } - - public static RequiredModifierType MakeRequiredModifierType (this TypeReference self, TypeReference modifierType) - { - return new RequiredModifierType (modifierType, self); - } - - public static GenericInstanceType MakeGenericInstanceType (this TypeReference self, params TypeReference [] arguments) - { - if (self == null) - throw new ArgumentNullException ("self"); - if (arguments == null) - throw new ArgumentNullException ("arguments"); - if (arguments.Length == 0) - throw new ArgumentException (); - if (self.GenericParameters.Count != arguments.Length) - throw new ArgumentException (); - - var instance = new GenericInstanceType (self); - - foreach (var argument in arguments) - instance.GenericArguments.Add (argument); - - return instance; - } - - public static PinnedType MakePinnedType (this TypeReference self) - { - return new PinnedType (self); - } - - public static SentinelType MakeSentinelType (this TypeReference self) - { - return new SentinelType (self); - } - } -} diff --git a/external/linker/cecil/rocks/Test/Mono.Cecil.Rocks.Tests.csproj b/external/linker/cecil/rocks/Test/Mono.Cecil.Rocks.Tests.csproj deleted file mode 100644 index 4019977632..0000000000 --- a/external/linker/cecil/rocks/Test/Mono.Cecil.Rocks.Tests.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - {C6CFD7E1-B855-44DC-B4CE-9CD72984AF52} - Mono.Cecil.Rocks.Tests - Mono.Cecil.Rocks.Tests - - - - {D68133BD-1E63-496E-9EDE-4FBDBF77B486} - Mono.Cecil - - - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055} - Mono.Cecil.Tests - - - {FBC6DD59-D09D-499C-B03C-99C1C78FF2AC} - Mono.Cecil.Rocks - - - - - - - - - - - \ No newline at end of file diff --git a/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/DocCommentIdTests.cs b/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/DocCommentIdTests.cs deleted file mode 100644 index b18824c613..0000000000 --- a/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/DocCommentIdTests.cs +++ /dev/null @@ -1,264 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -using NUnit.Framework; - -using Mono.Cecil.Rocks; - -namespace N -{ - /// - /// ID string generated is "T:N.X". - /// - public class X - { - /// - /// ID string generated is "M:N.X.#ctor". - /// - public X() { } - - - /// - /// ID string generated is "M:N.X.#ctor(System.Int32)". - /// - /// Describe parameter. - public X(int i) { } - - - /// - /// ID string generated is "F:N.X.q". - /// - public string q; - - - /// - /// ID string generated is "F:N.X.PI". - /// - public const double PI = 3.14; - - - /// - /// ID string generated is "M:N.X.f". - /// - public int f() { return 1; } - - - /// - /// ID string generated is "M:N.X.bb(System.String,System.Int32@)". - /// - public int bb(string s, ref int y) { return 1; } - - - /// - /// ID string generated is "M:N.X.gg(System.Int16[],System.Int32[0:,0:])". - /// - public int gg(short[] array1, int[,] array) { return 0; } - - - /// - /// ID string generated is "M:N.X.op_Addition(N.X,N.X)". - /// - public static X operator +(X x, X xx) { return x; } - - - /// - /// ID string generated is "P:N.X.prop". - /// - public int prop { get { return 1; } set { } } - - - /// - /// ID string generated is "E:N.X.d". - /// -#pragma warning disable 67 - public event D d; -#pragma warning restore 67 - - - /// - /// ID string generated is "P:N.X.Item(System.String)". - /// - public int this[string s] { get { return 1; } } - - - /// - /// ID string generated is "T:N.X.Nested". - /// - public class Nested { } - - - /// - /// ID string generated is "T:N.X.D". - /// - public delegate void D(int i); - - - /// - /// ID string generated is "M:N.X.op_Explicit(N.X)~System.Int32". - /// - public static explicit operator int(X x) { return 1; } - - public static void Linq (IEnumerable enumerable, Func selector) - { - } - } -} - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class DocCommentIdTests { - - [Test] - public void TypeDef () - { - AssertDocumentID ("T:N.X", GetTestType ()); - } - - [Test] - public void ParameterlessCtor () - { - var type = GetTestType (); - var ctor = type.GetConstructors ().Single (m => m.Parameters.Count == 0); - - AssertDocumentID ("M:N.X.#ctor", ctor); - } - - [Test] - public void CtorWithParameters () - { - var type = GetTestType (); - var ctor = type.GetConstructors ().Single (m => m.Parameters.Count == 1); - - AssertDocumentID ("M:N.X.#ctor(System.Int32)", ctor); - } - - [Test] - public void Field () - { - var type = GetTestType (); - var field = type.Fields.Single (m => m.Name == "q"); - - AssertDocumentID ("F:N.X.q", field); - } - - [Test] - public void ConstField () - { - var type = GetTestType (); - var field = type.Fields.Single (m => m.Name == "PI"); - - AssertDocumentID ("F:N.X.PI", field); - } - - [Test] - public void ParameterlessMethod () - { - var type = GetTestType (); - var method = type.Methods.Single (m => m.Name == "f"); - - AssertDocumentID ("M:N.X.f", method); - } - - [Test] - public void MethodWithByRefParameters () - { - var type = GetTestType (); - var method = type.Methods.Single (m => m.Name == "bb"); - - AssertDocumentID ("M:N.X.bb(System.String,System.Int32@)", method); - } - - [Test] - public void MethodWithArrayParameters () - { - var type = GetTestType (); - var method = type.Methods.Single (m => m.Name == "gg"); - - AssertDocumentID ("M:N.X.gg(System.Int16[],System.Int32[0:,0:])", method); - } - - [Test] - public void OpAddition () - { - var type = GetTestType (); - var op = type.Methods.Single (m => m.Name == "op_Addition"); - - AssertDocumentID ("M:N.X.op_Addition(N.X,N.X)", op); - } - - [Test] - public void OpExplicit () - { - var type = GetTestType (); - var op = type.Methods.Single (m => m.Name == "op_Explicit"); - - AssertDocumentID ("M:N.X.op_Explicit(N.X)~System.Int32", op); - } - - [Test] - public void Property () - { - var type = GetTestType (); - var property = type.Properties.Single (p => p.Name == "prop"); - - AssertDocumentID ("P:N.X.prop", property); - } - - [Test] - public void Indexer () - { - var type = GetTestType (); - var indexer = type.Properties.Single (p => p.Name == "Item"); - - AssertDocumentID ("P:N.X.Item(System.String)", indexer); - } - - [Test] - public void Event () - { - var type = GetTestType (); - var @event = type.Events.Single (e => e.Name == "d"); - - AssertDocumentID ("E:N.X.d", @event); - } - - [Test] - public void Delegate () - { - var type = GetTestType (); - var @delegate = type.NestedTypes.Single (t => t.Name == "D"); - - AssertDocumentID ("T:N.X.D", @delegate); - } - - [Test] - public void NestedType () - { - var type = GetTestType (); - var nestedType = type.NestedTypes.Single (t => t.Name == "Nested"); - - AssertDocumentID ("T:N.X.Nested", nestedType); - } - - [Test] - public void Linq () - { - var type = GetTestType (); - var method = type.GetMethod ("Linq"); - - AssertDocumentID ("M:N.X.Linq(System.Collections.Generic.IEnumerable{System.String},System.Func{System.String})", method); - } - - TypeDefinition GetTestType () - { - return typeof (N.X).ToDefinition (); - } - - static void AssertDocumentID (string docId, IMemberDefinition member) - { - Assert.AreEqual (docId, DocCommentId.GetDocCommentId (member)); - } - } -} diff --git a/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/MethodDefinitionRocksTests.cs b/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/MethodDefinitionRocksTests.cs deleted file mode 100644 index 4c6e3fb514..0000000000 --- a/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/MethodDefinitionRocksTests.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.Linq; - -using NUnit.Framework; - -using Mono.Cecil.Rocks; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class MethodDefinitionRocksTests : BaseTestFixture { - - abstract class Foo { - public abstract void DoFoo (); - public abstract void DoBar (); - } - - class Bar : Foo { - public override void DoFoo () - { - } - - public override void DoBar () - { - } - } - - class Baz : Bar { - public override void DoFoo () - { - } - - public virtual new void DoBar () - { - } - } - - [Test] - public void GetBaseMethod () - { - var baz = typeof (Baz).ToDefinition (); - var baz_dofoo = baz.GetMethod ("DoFoo"); - - var @base = baz_dofoo.GetBaseMethod (); - Assert.AreEqual ("Bar", @base.DeclaringType.Name); - - @base = @base.GetBaseMethod (); - Assert.AreEqual ("Foo", @base.DeclaringType.Name); - - Assert.AreEqual (@base, @base.GetBaseMethod ()); - - var new_dobar = baz.GetMethod ("DoBar"); - @base = new_dobar.GetBaseMethod(); - Assert.AreEqual("Baz", @base.DeclaringType.Name); - } - - [Test] - public void GetOriginalBaseMethod () - { - var baz = typeof (Baz).ToDefinition (); - var baz_dofoo = baz.GetMethod ("DoFoo"); - - var @base = baz_dofoo.GetOriginalBaseMethod (); - Assert.AreEqual ("Foo", @base.DeclaringType.Name); - } - } -} diff --git a/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/ModuleDefinitionRocksTests.cs b/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/ModuleDefinitionRocksTests.cs deleted file mode 100644 index d0f5d01690..0000000000 --- a/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/ModuleDefinitionRocksTests.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Linq; - -using NUnit.Framework; - -using Mono.Cecil.Rocks; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class ModuleDefinitionRocksTests : BaseTestFixture { - - [Test] - public void GetAllTypesTest () - { - TestCSharp ("Types.cs", module => { - var sequence = new [] { - module.GetType (""), - module.GetType ("Foo"), - module.GetType ("Foo/Bar"), - module.GetType ("Foo/Gazonk"), - module.GetType ("Foo/Gazonk/Baz"), - module.GetType ("Pan"), - }; - - Assert.IsTrue (sequence.SequenceEqual (module.GetAllTypes ())); - }); - } - } -} diff --git a/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/SecurityDeclarationRocksTests.cs b/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/SecurityDeclarationRocksTests.cs deleted file mode 100644 index 0c2c125d42..0000000000 --- a/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/SecurityDeclarationRocksTests.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Security.Permissions; - -using NUnit.Framework; - -using Mono.Cecil.Rocks; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class SecurityDeclarationRocksTests : BaseTestFixture { - - [Test] - public void ToPermissionSetFromPermissionSetAttribute () - { - TestModule ("decsec-xml.dll", module => { - var type = module.GetType ("SubLibrary"); - - Assert.IsTrue (type.HasSecurityDeclarations); - Assert.AreEqual (1, type.SecurityDeclarations.Count); - - var declaration = type.SecurityDeclarations [0]; - - var permission_set = declaration.ToPermissionSet (); - - Assert.IsNotNull (permission_set); - - string permission_set_value = "\r\n\r\n\r\n"; - - permission_set_value = string.Format (permission_set_value, typeof (SecurityPermission).AssemblyQualifiedName); - - Assert.AreEqual (Normalize (permission_set_value), Normalize (permission_set.ToXml ().ToString ())); - }); - } - - [Test] - public void ToPermissionSetFromSecurityAttribute () - { - TestModule ("decsec-att.dll", module => { - var type = module.GetType ("SubLibrary"); - - Assert.IsTrue (type.HasSecurityDeclarations); - Assert.AreEqual (1, type.SecurityDeclarations.Count); - - var declaration = type.SecurityDeclarations [0]; - - var permission_set = declaration.ToPermissionSet (); - - Assert.IsNotNull (permission_set); - - string permission_set_value = "\r\n\r\n\r\n"; - - permission_set_value = string.Format (permission_set_value, typeof (SecurityPermission).AssemblyQualifiedName); - - Assert.AreEqual (Normalize (permission_set_value), Normalize (permission_set.ToXml ().ToString ())); - }); - } - } -} diff --git a/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/TypeDefinitionRocksTests.cs b/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/TypeDefinitionRocksTests.cs deleted file mode 100644 index 7bd43cf7e1..0000000000 --- a/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/TypeDefinitionRocksTests.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Mono.Cecil.Rocks; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class TypeDefinitionRocksTests { - - class Foo { - - static Foo () - { - } - - public Foo (int a) - { - } - - public Foo (int a, string s) - { - } - - public static void Bar () - { - } - - void Baz () - { - } - } - - [Test] - public void GetConstructors () - { - var foo = typeof (Foo).ToDefinition (); - var ctors = foo.GetConstructors ().Select (ctor => ctor.FullName); - - var expected = new [] { - "System.Void Mono.Cecil.Tests.TypeDefinitionRocksTests/Foo::.cctor()", - "System.Void Mono.Cecil.Tests.TypeDefinitionRocksTests/Foo::.ctor(System.Int32)", - "System.Void Mono.Cecil.Tests.TypeDefinitionRocksTests/Foo::.ctor(System.Int32,System.String)", - }; - - AssertSet (expected, ctors); - } - - static void AssertSet (IEnumerable expected, IEnumerable actual) - { - Assert.IsFalse (expected.Except (actual).Any ()); - Assert.IsTrue (expected.Intersect (actual).SequenceEqual (expected)); - } - - [Test] - public void GetStaticConstructor () - { - var foo = typeof (Foo).ToDefinition (); - var cctor = foo.GetStaticConstructor (); - - Assert.IsNotNull (cctor); - Assert.AreEqual ("System.Void Mono.Cecil.Tests.TypeDefinitionRocksTests/Foo::.cctor()", cctor.FullName); - } - - [Test] - public void GetMethods () - { - var foo = typeof (Foo).ToDefinition (); - var methods = foo.GetMethods ().ToArray (); - - Assert.AreEqual (2, methods.Length); - Assert.AreEqual ("System.Void Mono.Cecil.Tests.TypeDefinitionRocksTests/Foo::Bar()", methods [0].FullName); - Assert.AreEqual ("System.Void Mono.Cecil.Tests.TypeDefinitionRocksTests/Foo::Baz()", methods [1].FullName); - } - - enum Pan : byte { - Pin, - Pon, - } - - [Test] - public void GetEnumUnderlyingType () - { - var pan = typeof (Pan).ToDefinition (); - - Assert.IsNotNull (pan); - Assert.IsTrue (pan.IsEnum); - - var underlying_type = pan.GetEnumUnderlyingType (); - Assert.IsNotNull (underlying_type); - - Assert.AreEqual ("System.Byte", underlying_type.FullName); - } - } -} \ No newline at end of file diff --git a/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/TypeReferenceRocksTests.cs b/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/TypeReferenceRocksTests.cs deleted file mode 100644 index bcb9336bc7..0000000000 --- a/external/linker/cecil/rocks/Test/Mono.Cecil.Tests/TypeReferenceRocksTests.cs +++ /dev/null @@ -1,126 +0,0 @@ -#if !READ_ONLY -using System; - -using Mono.Cecil.Rocks; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class TypeReferenceRocksTests { - - [Test] - public void MakeArrayType () - { - var @string = GetTypeReference (typeof (string)); - - var string_array = @string.MakeArrayType (); - - Assert.IsInstanceOf (typeof (ArrayType), string_array); - Assert.AreEqual (1, string_array.Rank); - } - - [Test] - public void MakeArrayTypeRank () - { - var @string = GetTypeReference (typeof (string)); - - var string_array = @string.MakeArrayType (3); - - Assert.IsInstanceOf (typeof (ArrayType), string_array); - Assert.AreEqual (3, string_array.Rank); - } - - [Test] - public void MakePointerType () - { - var @string = GetTypeReference (typeof (string)); - - var string_ptr = @string.MakePointerType (); - - Assert.IsInstanceOf (typeof (PointerType), string_ptr); - } - - [Test] - public void MakeByReferenceType () - { - var @string = GetTypeReference (typeof (string)); - - var string_byref = @string.MakeByReferenceType (); - - Assert.IsInstanceOf (typeof (ByReferenceType), string_byref); - } - - class OptionalModifier {} - - [Test] - public void MakeOptionalModifierType () - { - var @string = GetTypeReference (typeof (string)); - var modopt = GetTypeReference (typeof (OptionalModifier)); - - var string_modopt = @string.MakeOptionalModifierType (modopt); - - Assert.IsInstanceOf (typeof (OptionalModifierType), string_modopt); - Assert.AreEqual (modopt, string_modopt.ModifierType); - } - - class RequiredModifier { } - - [Test] - public void MakeRequiredModifierType () - { - var @string = GetTypeReference (typeof (string)); - var modreq = GetTypeReference (typeof (RequiredModifierType)); - - var string_modreq = @string.MakeRequiredModifierType (modreq); - - Assert.IsInstanceOf (typeof (RequiredModifierType), string_modreq); - Assert.AreEqual (modreq, string_modreq.ModifierType); - } - - [Test] - public void MakePinnedType () - { - var byte_array = GetTypeReference (typeof (byte [])); - - var pinned_byte_array = byte_array.MakePinnedType (); - - Assert.IsInstanceOf (typeof (PinnedType), pinned_byte_array); - } - - [Test] - public void MakeSentinelType () - { - var @string = GetTypeReference (typeof (string)); - - var string_sentinel = @string.MakeSentinelType (); - - Assert.IsInstanceOf (typeof (SentinelType), string_sentinel); - } - - class Foo {} - - [Test] - public void MakeGenericInstanceType () - { - var foo = GetTypeReference (typeof (Foo<,>)); - var @string = GetTypeReference (typeof (string)); - var @int = GetTypeReference (typeof (int)); - - var foo_string_int = foo.MakeGenericInstanceType (@string, @int); - - Assert.IsInstanceOf (typeof (GenericInstanceType), foo_string_int); - Assert.AreEqual (2, foo_string_int.GenericArguments.Count); - Assert.AreEqual (@string, foo_string_int.GenericArguments [0]); - Assert.AreEqual (@int, foo_string_int.GenericArguments [1]); - } - - static TypeReference GetTypeReference (Type type) - { - return ModuleDefinition.ReadModule (typeof (TypeReferenceRocksTests).Module.FullyQualifiedName).ImportReference (type); - } - } -} -#endif \ No newline at end of file diff --git a/external/linker/cecil/rocks/Test/Resources/cs/Types.cs b/external/linker/cecil/rocks/Test/Resources/cs/Types.cs deleted file mode 100644 index ba046554bb..0000000000 --- a/external/linker/cecil/rocks/Test/Resources/cs/Types.cs +++ /dev/null @@ -1,14 +0,0 @@ -public class Foo { - - public class Bar { - } - - public class Gazonk { - - public class Baz { - } - } -} - -public class Pan { -} diff --git a/external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb.csproj b/external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb.csproj deleted file mode 100644 index 310016bb42..0000000000 --- a/external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD} - Mono.Cecil.Mdb - Mono.Cecil.Mdb - - - - {D68133BD-1E63-496E-9EDE-4FBDBF77B486} - Mono.Cecil - - - - - - - - - - - $(DefineConstants);CECIL - - diff --git a/external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb/AssemblyInfo.cs b/external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb/AssemblyInfo.cs deleted file mode 100644 index 12f9bb6346..0000000000 --- a/external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb/AssemblyInfo.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Reflection; - -[assembly: AssemblyTitle ("Mono.Cecil.Mdb")] - -[assembly: CLSCompliant (false)] diff --git a/external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs b/external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs deleted file mode 100644 index 59e933a370..0000000000 --- a/external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs +++ /dev/null @@ -1,217 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.IO; - -using Mono.Cecil.Cil; -using Mono.Collections.Generic; -using Mono.CompilerServices.SymbolWriter; - -namespace Mono.Cecil.Mdb { - - public sealed class MdbReaderProvider : ISymbolReaderProvider { - - public ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName) - { - Mixin.CheckModule (module); - Mixin.CheckFileName (fileName); - - return new MdbReader (module, MonoSymbolFile.ReadSymbolFile (Mixin.GetMdbFileName (fileName), module.Mvid)); - } - - public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream) - { - Mixin.CheckModule (module); - Mixin.CheckStream (symbolStream); - - var file = MonoSymbolFile.ReadSymbolFile (symbolStream); - if (module.Mvid != file.Guid) { - var file_stream = symbolStream as FileStream; - if (file_stream != null) - throw new MonoSymbolFileException ("Symbol file `{0}' does not match assembly", file_stream.Name); - - throw new MonoSymbolFileException ("Symbol file from stream does not match assembly"); - } - return new MdbReader (module, file); - } - } - - public sealed class MdbReader : ISymbolReader { - - readonly ModuleDefinition module; - readonly MonoSymbolFile symbol_file; - readonly Dictionary documents; - - public MdbReader (ModuleDefinition module, MonoSymbolFile symFile) - { - this.module = module; - this.symbol_file = symFile; - this.documents = new Dictionary (); - } - -#if !READ_ONLY - public ISymbolWriterProvider GetWriterProvider () - { - return new MdbWriterProvider (); - } -#endif - - public bool ProcessDebugHeader (ImageDebugHeader header) - { - return symbol_file.Guid == module.Mvid; - } - - public MethodDebugInformation Read (MethodDefinition method) - { - var method_token = method.MetadataToken; - var entry = symbol_file.GetMethodByToken (method_token.ToInt32 ()); - if (entry == null) - return null; - - var info = new MethodDebugInformation (method); - info.code_size = ReadCodeSize (method); - - var scopes = ReadScopes (entry, info); - ReadLineNumbers (entry, info); - ReadLocalVariables (entry, scopes); - - return info; - } - - static int ReadCodeSize (MethodDefinition method) - { - return method.Module.Read (method, (m, reader) => reader.ReadCodeSize (m)); - } - - static void ReadLocalVariables (MethodEntry entry, ScopeDebugInformation [] scopes) - { - var locals = entry.GetLocals (); - - foreach (var local in locals) { - var variable = new VariableDebugInformation (local.Index, local.Name); - - var index = local.BlockIndex; - if (index < 0 || index >= scopes.Length) - continue; - - var scope = scopes [index]; - if (scope == null) - continue; - - scope.Variables.Add (variable); - } - } - - void ReadLineNumbers (MethodEntry entry, MethodDebugInformation info) - { - var table = entry.GetLineNumberTable (); - - info.sequence_points = new Collection (table.LineNumbers.Length); - - for (var i = 0; i < table.LineNumbers.Length; i++) { - var line = table.LineNumbers [i]; - if (i > 0 && table.LineNumbers [i - 1].Offset == line.Offset) - continue; - - info.sequence_points.Add (LineToSequencePoint (line)); - } - } - - Document GetDocument (SourceFileEntry file) - { - var file_name = file.FileName; - - Document document; - if (documents.TryGetValue (file_name, out document)) - return document; - - document = new Document (file_name) { - Hash = file.Checksum, - }; - - documents.Add (file_name, document); - - return document; - } - - static ScopeDebugInformation [] ReadScopes (MethodEntry entry, MethodDebugInformation info) - { - var blocks = entry.GetCodeBlocks (); - var scopes = new ScopeDebugInformation [blocks.Length + 1]; - - info.scope = scopes [0] = new ScopeDebugInformation { - Start = new InstructionOffset (0), - End = new InstructionOffset (info.code_size), - }; - - foreach (var block in blocks) { - if (block.BlockType != CodeBlockEntry.Type.Lexical && block.BlockType != CodeBlockEntry.Type.CompilerGenerated) - continue; - - var scope = new ScopeDebugInformation (); - scope.Start = new InstructionOffset (block.StartOffset); - scope.End = new InstructionOffset (block.EndOffset); - - scopes [block.Index + 1] = scope; - - if (!AddScope (info.scope.Scopes, scope)) - info.scope.Scopes.Add (scope); - } - - return scopes; - } - - static bool AddScope (Collection scopes, ScopeDebugInformation scope) - { - foreach (var sub_scope in scopes) { - if (sub_scope.HasScopes && AddScope (sub_scope.Scopes, scope)) - return true; - - if (scope.Start.Offset >= sub_scope.Start.Offset && scope.End.Offset <= sub_scope.End.Offset) { - sub_scope.Scopes.Add (scope); - return true; - } - } - - return false; - } - - SequencePoint LineToSequencePoint (LineNumberEntry line) - { - var source = symbol_file.GetSourceFile (line.File); - return new SequencePoint (line.Offset, GetDocument (source)) { - StartLine = line.Row, - EndLine = line.EndRow, - StartColumn = line.Column, - EndColumn = line.EndColumn, - }; - } - - public void Dispose () - { - symbol_file.Dispose (); - } - } - - static class MethodEntryExtensions { - - public static bool HasColumnInfo (this MethodEntry entry) - { - return (entry.MethodFlags & MethodEntry.Flags.ColumnsInfoIncluded) != 0; - } - - public static bool HasEndInfo (this MethodEntry entry) - { - return (entry.MethodFlags & MethodEntry.Flags.EndInfoIncluded) != 0; - } - } -} diff --git a/external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs b/external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs deleted file mode 100644 index 8c3dbe3edc..0000000000 --- a/external/linker/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs +++ /dev/null @@ -1,215 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.IO; - -using Mono.Cecil.Cil; -using Mono.Collections.Generic; -using Mono.CompilerServices.SymbolWriter; - -namespace Mono.Cecil.Mdb { - -#if !READ_ONLY - public sealed class MdbWriterProvider : ISymbolWriterProvider { - - public ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName) - { - Mixin.CheckModule (module); - Mixin.CheckFileName (fileName); - - return new MdbWriter (module.Mvid, fileName); - } - - public ISymbolWriter GetSymbolWriter (ModuleDefinition module, Stream symbolStream) - { - throw new NotImplementedException (); - } - } - - public sealed class MdbWriter : ISymbolWriter { - - readonly Guid mvid; - readonly MonoSymbolWriter writer; - readonly Dictionary source_files; - - public MdbWriter (Guid mvid, string assembly) - { - this.mvid = mvid; - this.writer = new MonoSymbolWriter (assembly); - this.source_files = new Dictionary (); - } - - public ISymbolReaderProvider GetReaderProvider () - { - return new MdbReaderProvider (); - } - - SourceFile GetSourceFile (Document document) - { - var url = document.Url; - - SourceFile source_file; - if (source_files.TryGetValue (url, out source_file)) - return source_file; - - var entry = writer.DefineDocument (url, null, document.Hash != null && document.Hash.Length == 16 ? document.Hash : null); - var compile_unit = writer.DefineCompilationUnit (entry); - - source_file = new SourceFile (compile_unit, entry); - source_files.Add (url, source_file); - return source_file; - } - - void Populate (Collection sequencePoints, int [] offsets, - int [] startRows, int [] endRows, int [] startCols, int [] endCols, out SourceFile file) - { - SourceFile source_file = null; - - for (int i = 0; i < sequencePoints.Count; i++) { - var sequence_point = sequencePoints [i]; - offsets [i] = sequence_point.Offset; - - if (source_file == null) - source_file = GetSourceFile (sequence_point.Document); - - startRows [i] = sequence_point.StartLine; - endRows [i] = sequence_point.EndLine; - startCols [i] = sequence_point.StartColumn; - endCols [i] = sequence_point.EndColumn; - } - - file = source_file; - } - - public void Write (MethodDebugInformation info) - { - var method = new SourceMethod (info.method); - - var sequence_points = info.SequencePoints; - int count = sequence_points.Count; - if (count == 0) - return; - - var offsets = new int [count]; - var start_rows = new int [count]; - var end_rows = new int [count]; - var start_cols = new int [count]; - var end_cols = new int [count]; - - SourceFile file; - Populate (sequence_points, offsets, start_rows, end_rows, start_cols, end_cols, out file); - - var builder = writer.OpenMethod (file.CompilationUnit, 0, method); - - for (int i = 0; i < count; i++) { - builder.MarkSequencePoint ( - offsets [i], - file.CompilationUnit.SourceFile, - start_rows [i], - start_cols [i], - end_rows [i], - end_cols [i], - false); - } - - if (info.scope != null) - WriteRootScope (info.scope, info); - - writer.CloseMethod (); - } - - void WriteRootScope (ScopeDebugInformation scope, MethodDebugInformation info) - { - WriteScopeVariables (scope); - - if (scope.HasScopes) - WriteScopes (scope.Scopes, info); - } - - void WriteScope (ScopeDebugInformation scope, MethodDebugInformation info) - { - writer.OpenScope (scope.Start.Offset); - - WriteScopeVariables (scope); - - if (scope.HasScopes) - WriteScopes (scope.Scopes, info); - - writer.CloseScope (scope.End.IsEndOfMethod ? info.code_size : scope.End.Offset); - } - - void WriteScopes (Collection scopes, MethodDebugInformation info) - { - for (int i = 0; i < scopes.Count; i++) - WriteScope (scopes [i], info); - } - - void WriteScopeVariables (ScopeDebugInformation scope) - { - if (!scope.HasVariables) - return; - - foreach (var variable in scope.variables) - if (!string.IsNullOrEmpty (variable.Name)) - writer.DefineLocalVariable (variable.Index, variable.Name); - } - - public ImageDebugHeader GetDebugHeader () - { - return new ImageDebugHeader (); - } - - public void Dispose () - { - writer.WriteSymbolFile (mvid); - } - - class SourceFile : ISourceFile { - - readonly CompileUnitEntry compilation_unit; - readonly SourceFileEntry entry; - - public SourceFileEntry Entry { - get { return entry; } - } - - public CompileUnitEntry CompilationUnit { - get { return compilation_unit; } - } - - public SourceFile (CompileUnitEntry comp_unit, SourceFileEntry entry) - { - this.compilation_unit = comp_unit; - this.entry = entry; - } - } - - class SourceMethod : IMethodDef { - - readonly MethodDefinition method; - - public string Name { - get { return method.Name; } - } - - public int Token { - get { return method.MetadataToken.ToInt32 (); } - } - - public SourceMethod (MethodDefinition method) - { - this.method = method; - } - } - } -#endif -} diff --git a/external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs b/external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs deleted file mode 100644 index 2b6c3a6a10..0000000000 --- a/external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolFile.cs +++ /dev/null @@ -1,643 +0,0 @@ -// -// MonoSymbolFile.cs -// -// Authors: -// Martin Baulig (martin@ximian.com) -// Marek Safar (marek.safar@gmail.com) -// -// (C) 2003 Ximian, Inc. http://www.ximian.com -// Copyright (C) 2012 Xamarin Inc (http://www.xamarin.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.Reflection; -using System.Collections.Generic; -using System.IO; - -namespace Mono.CompilerServices.SymbolWriter -{ - public class MonoSymbolFileException : Exception - { - public MonoSymbolFileException () - : base () - { } - - public MonoSymbolFileException (string message, params object[] args) - : base (String.Format (message, args)) - { - } - - public MonoSymbolFileException (string message, Exception innerException) - : base (message, innerException) - { - } - } - - sealed class MyBinaryWriter : BinaryWriter - { - public MyBinaryWriter (Stream stream) - : base (stream) - { } - - public void WriteLeb128 (int value) - { - base.Write7BitEncodedInt (value); - } - } - - internal class MyBinaryReader : BinaryReader - { - public MyBinaryReader (Stream stream) - : base (stream) - { } - - public int ReadLeb128 () - { - return base.Read7BitEncodedInt (); - } - - public string ReadString (int offset) - { - long old_pos = BaseStream.Position; - BaseStream.Position = offset; - - string text = ReadString (); - - BaseStream.Position = old_pos; - return text; - } - } - - public interface ISourceFile - { - SourceFileEntry Entry { - get; - } - } - - public interface ICompileUnit - { - CompileUnitEntry Entry { - get; - } - } - - public interface IMethodDef - { - string Name { - get; - } - - int Token { - get; - } - } - - public class MonoSymbolFile : IDisposable - { - List methods = new List (); - List sources = new List (); - List comp_units = new List (); - Dictionary anonymous_scopes; - - OffsetTable ot; - int last_type_index; - int last_method_index; - int last_namespace_index; - - public readonly int MajorVersion = OffsetTable.MajorVersion; - public readonly int MinorVersion = OffsetTable.MinorVersion; - - public int NumLineNumbers; - - public MonoSymbolFile () - { - ot = new OffsetTable (); - } - - public int AddSource (SourceFileEntry source) - { - sources.Add (source); - return sources.Count; - } - - public int AddCompileUnit (CompileUnitEntry entry) - { - comp_units.Add (entry); - return comp_units.Count; - } - - public void AddMethod (MethodEntry entry) - { - methods.Add (entry); - } - - public MethodEntry DefineMethod (CompileUnitEntry comp_unit, int token, - ScopeVariable[] scope_vars, LocalVariableEntry[] locals, - LineNumberEntry[] lines, CodeBlockEntry[] code_blocks, - string real_name, MethodEntry.Flags flags, - int namespace_id) - { - if (reader != null) - throw new InvalidOperationException (); - - MethodEntry method = new MethodEntry ( - this, comp_unit, token, scope_vars, locals, lines, code_blocks, - real_name, flags, namespace_id); - AddMethod (method); - return method; - } - - internal void DefineAnonymousScope (int id) - { - if (reader != null) - throw new InvalidOperationException (); - - if (anonymous_scopes == null) - anonymous_scopes = new Dictionary (); - - anonymous_scopes.Add (id, new AnonymousScopeEntry (id)); - } - - internal void DefineCapturedVariable (int scope_id, string name, string captured_name, - CapturedVariable.CapturedKind kind) - { - if (reader != null) - throw new InvalidOperationException (); - - AnonymousScopeEntry scope = anonymous_scopes [scope_id]; - scope.AddCapturedVariable (name, captured_name, kind); - } - - internal void DefineCapturedScope (int scope_id, int id, string captured_name) - { - if (reader != null) - throw new InvalidOperationException (); - - AnonymousScopeEntry scope = anonymous_scopes [scope_id]; - scope.AddCapturedScope (id, captured_name); - } - - internal int GetNextTypeIndex () - { - return ++last_type_index; - } - - internal int GetNextMethodIndex () - { - return ++last_method_index; - } - - internal int GetNextNamespaceIndex () - { - return ++last_namespace_index; - } - - void Write (MyBinaryWriter bw, Guid guid) - { - // Magic number and file version. - bw.Write (OffsetTable.Magic); - bw.Write (MajorVersion); - bw.Write (MinorVersion); - - bw.Write (guid.ToByteArray ()); - - // - // Offsets of file sections; we must write this after we're done - // writing the whole file, so we just reserve the space for it here. - // - long offset_table_offset = bw.BaseStream.Position; - ot.Write (bw, MajorVersion, MinorVersion); - - // - // Sort the methods according to their tokens and update their index. - // - methods.Sort (); - for (int i = 0; i < methods.Count; i++) - methods [i].Index = i + 1; - - // - // Write data sections. - // - ot.DataSectionOffset = (int) bw.BaseStream.Position; - foreach (SourceFileEntry source in sources) - source.WriteData (bw); - foreach (CompileUnitEntry comp_unit in comp_units) - comp_unit.WriteData (bw); - foreach (MethodEntry method in methods) - method.WriteData (this, bw); - ot.DataSectionSize = (int) bw.BaseStream.Position - ot.DataSectionOffset; - - // - // Write the method index table. - // - ot.MethodTableOffset = (int) bw.BaseStream.Position; - for (int i = 0; i < methods.Count; i++) { - MethodEntry entry = methods [i]; - entry.Write (bw); - } - ot.MethodTableSize = (int) bw.BaseStream.Position - ot.MethodTableOffset; - - // - // Write source table. - // - ot.SourceTableOffset = (int) bw.BaseStream.Position; - for (int i = 0; i < sources.Count; i++) { - SourceFileEntry source = sources [i]; - source.Write (bw); - } - ot.SourceTableSize = (int) bw.BaseStream.Position - ot.SourceTableOffset; - - // - // Write compilation unit table. - // - ot.CompileUnitTableOffset = (int) bw.BaseStream.Position; - for (int i = 0; i < comp_units.Count; i++) { - CompileUnitEntry unit = comp_units [i]; - unit.Write (bw); - } - ot.CompileUnitTableSize = (int) bw.BaseStream.Position - ot.CompileUnitTableOffset; - - // - // Write anonymous scope table. - // - ot.AnonymousScopeCount = anonymous_scopes != null ? anonymous_scopes.Count : 0; - ot.AnonymousScopeTableOffset = (int) bw.BaseStream.Position; - if (anonymous_scopes != null) { - foreach (AnonymousScopeEntry scope in anonymous_scopes.Values) - scope.Write (bw); - } - ot.AnonymousScopeTableSize = (int) bw.BaseStream.Position - ot.AnonymousScopeTableOffset; - - // - // Fixup offset table. - // - ot.TypeCount = last_type_index; - ot.MethodCount = methods.Count; - ot.SourceCount = sources.Count; - ot.CompileUnitCount = comp_units.Count; - - // - // Write offset table. - // - ot.TotalFileSize = (int) bw.BaseStream.Position; - bw.Seek ((int) offset_table_offset, SeekOrigin.Begin); - ot.Write (bw, MajorVersion, MinorVersion); - bw.Seek (0, SeekOrigin.End); - -#if false - Console.WriteLine ("TOTAL: {0} line numbes, {1} bytes, extended {2} bytes, " + - "{3} methods.", NumLineNumbers, LineNumberSize, - ExtendedLineNumberSize, methods.Count); -#endif - } - - public void CreateSymbolFile (Guid guid, FileStream fs) - { - if (reader != null) - throw new InvalidOperationException (); - - Write (new MyBinaryWriter (fs), guid); - } - - MyBinaryReader reader; - Dictionary source_file_hash; - Dictionary compile_unit_hash; - - List method_list; - Dictionary method_token_hash; - Dictionary source_name_hash; - - Guid guid; - - MonoSymbolFile (Stream stream) - { - reader = new MyBinaryReader (stream); - - try { - long magic = reader.ReadInt64 (); - int major_version = reader.ReadInt32 (); - int minor_version = reader.ReadInt32 (); - - if (magic != OffsetTable.Magic) - throw new MonoSymbolFileException ("Symbol file is not a valid"); - if (major_version != OffsetTable.MajorVersion) - throw new MonoSymbolFileException ( - "Symbol file has version {0} but expected {1}", major_version, OffsetTable.MajorVersion); - if (minor_version != OffsetTable.MinorVersion) - throw new MonoSymbolFileException ("Symbol file has version {0}.{1} but expected {2}.{3}", - major_version, minor_version, - OffsetTable.MajorVersion, OffsetTable.MinorVersion); - - MajorVersion = major_version; - MinorVersion = minor_version; - guid = new Guid (reader.ReadBytes (16)); - - ot = new OffsetTable (reader, major_version, minor_version); - } catch (Exception e) { - throw new MonoSymbolFileException ("Cannot read symbol file", e); - } - - source_file_hash = new Dictionary (); - compile_unit_hash = new Dictionary (); - } - -#if !NET_CORE - public static MonoSymbolFile ReadSymbolFile (Assembly assembly) - { - string filename = assembly.Location; - string name = filename + ".mdb"; - - Module[] modules = assembly.GetModules (); - Guid assembly_guid = modules[0].ModuleVersionId; - - return ReadSymbolFile (name, assembly_guid); - } -#endif - - public static MonoSymbolFile ReadSymbolFile (string mdbFilename) - { - return ReadSymbolFile (new FileStream (mdbFilename, FileMode.Open, FileAccess.Read)); - } - - public static MonoSymbolFile ReadSymbolFile (string mdbFilename, Guid assemblyGuid) - { - var sf = ReadSymbolFile (mdbFilename); - if (assemblyGuid != sf.guid) - throw new MonoSymbolFileException ("Symbol file `{0}' does not match assembly", mdbFilename); - - return sf; - } - - public static MonoSymbolFile ReadSymbolFile (Stream stream) - { - return new MonoSymbolFile (stream); - } - - public int CompileUnitCount { - get { return ot.CompileUnitCount; } - } - - public int SourceCount { - get { return ot.SourceCount; } - } - - public int MethodCount { - get { return ot.MethodCount; } - } - - public int TypeCount { - get { return ot.TypeCount; } - } - - public int AnonymousScopeCount { - get { return ot.AnonymousScopeCount; } - } - - public int NamespaceCount { - get { return last_namespace_index; } - } - - public Guid Guid { - get { return guid; } - } - - public OffsetTable OffsetTable { - get { return ot; } - } - - internal int LineNumberCount = 0; - internal int LocalCount = 0; - internal int StringSize = 0; - - internal int LineNumberSize = 0; - internal int ExtendedLineNumberSize = 0; - - public SourceFileEntry GetSourceFile (int index) - { - if ((index < 1) || (index > ot.SourceCount)) - throw new ArgumentException (); - if (reader == null) - throw new InvalidOperationException (); - - lock (this) { - SourceFileEntry source; - if (source_file_hash.TryGetValue (index, out source)) - return source; - - long old_pos = reader.BaseStream.Position; - - reader.BaseStream.Position = ot.SourceTableOffset + - SourceFileEntry.Size * (index - 1); - source = new SourceFileEntry (this, reader); - source_file_hash.Add (index, source); - - reader.BaseStream.Position = old_pos; - return source; - } - } - - public SourceFileEntry[] Sources { - get { - if (reader == null) - throw new InvalidOperationException (); - - SourceFileEntry[] retval = new SourceFileEntry [SourceCount]; - for (int i = 0; i < SourceCount; i++) - retval [i] = GetSourceFile (i + 1); - return retval; - } - } - - public CompileUnitEntry GetCompileUnit (int index) - { - if ((index < 1) || (index > ot.CompileUnitCount)) - throw new ArgumentException (); - if (reader == null) - throw new InvalidOperationException (); - - lock (this) { - CompileUnitEntry unit; - if (compile_unit_hash.TryGetValue (index, out unit)) - return unit; - - long old_pos = reader.BaseStream.Position; - - reader.BaseStream.Position = ot.CompileUnitTableOffset + - CompileUnitEntry.Size * (index - 1); - unit = new CompileUnitEntry (this, reader); - compile_unit_hash.Add (index, unit); - - reader.BaseStream.Position = old_pos; - return unit; - } - } - - public CompileUnitEntry[] CompileUnits { - get { - if (reader == null) - throw new InvalidOperationException (); - - CompileUnitEntry[] retval = new CompileUnitEntry [CompileUnitCount]; - for (int i = 0; i < CompileUnitCount; i++) - retval [i] = GetCompileUnit (i + 1); - return retval; - } - } - - void read_methods () - { - lock (this) { - if (method_token_hash != null) - return; - - method_token_hash = new Dictionary (); - method_list = new List (); - - long old_pos = reader.BaseStream.Position; - reader.BaseStream.Position = ot.MethodTableOffset; - - for (int i = 0; i < MethodCount; i++) { - MethodEntry entry = new MethodEntry (this, reader, i + 1); - method_token_hash.Add (entry.Token, entry); - method_list.Add (entry); - } - - reader.BaseStream.Position = old_pos; - } - } - - public MethodEntry GetMethodByToken (int token) - { - if (reader == null) - throw new InvalidOperationException (); - - lock (this) { - read_methods (); - MethodEntry me; - method_token_hash.TryGetValue (token, out me); - return me; - } - } - - public MethodEntry GetMethod (int index) - { - if ((index < 1) || (index > ot.MethodCount)) - throw new ArgumentException (); - if (reader == null) - throw new InvalidOperationException (); - - lock (this) { - read_methods (); - return method_list [index - 1]; - } - } - - public MethodEntry[] Methods { - get { - if (reader == null) - throw new InvalidOperationException (); - - lock (this) { - read_methods (); - MethodEntry[] retval = new MethodEntry [MethodCount]; - method_list.CopyTo (retval, 0); - return retval; - } - } - } - - public int FindSource (string file_name) - { - if (reader == null) - throw new InvalidOperationException (); - - lock (this) { - if (source_name_hash == null) { - source_name_hash = new Dictionary (); - - for (int i = 0; i < ot.SourceCount; i++) { - SourceFileEntry source = GetSourceFile (i + 1); - source_name_hash.Add (source.FileName, i); - } - } - - int value; - if (!source_name_hash.TryGetValue (file_name, out value)) - return -1; - return value; - } - } - - public AnonymousScopeEntry GetAnonymousScope (int id) - { - if (reader == null) - throw new InvalidOperationException (); - - AnonymousScopeEntry scope; - lock (this) { - if (anonymous_scopes != null) { - anonymous_scopes.TryGetValue (id, out scope); - return scope; - } - - anonymous_scopes = new Dictionary (); - reader.BaseStream.Position = ot.AnonymousScopeTableOffset; - for (int i = 0; i < ot.AnonymousScopeCount; i++) { - scope = new AnonymousScopeEntry (reader); - anonymous_scopes.Add (scope.ID, scope); - } - - return anonymous_scopes [id]; - } - } - - internal MyBinaryReader BinaryReader { - get { - if (reader == null) - throw new InvalidOperationException (); - - return reader; - } - } - - public void Dispose () - { - Dispose (true); - } - - protected virtual void Dispose (bool disposing) - { - if (disposing) { - if (reader != null) { -#if NET_CORE - reader.Dispose (); -#else - reader.Close (); -#endif - reader = null; - } - } - } - } -} diff --git a/external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs b/external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs deleted file mode 100644 index e151c756dc..0000000000 --- a/external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs +++ /dev/null @@ -1,1446 +0,0 @@ -// -// Mono.CSharp.Debugger/MonoSymbolTable.cs -// -// Author: -// Martin Baulig (martin@ximian.com) -// -// (C) 2002 Ximian, Inc. http://www.ximian.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; -using System.Collections.Generic; -using System.Text; -using System.IO; - -// -// Parts which are actually written into the symbol file are marked with -// -// #region This is actually written to the symbol file -// #endregion -// -// Please do not modify these regions without previously talking to me. -// -// All changes to the file format must be synchronized in several places: -// -// a) The fields in these regions (and their order) must match the actual -// contents of the symbol file. -// -// This helps people to understand the symbol file format without reading -// too much source code, ie. you look at the appropriate region and then -// you know what's actually in the file. -// -// It is also required to help me enforce b). -// -// b) The regions must be kept in sync with the unmanaged code in -// mono/metadata/debug-mono-symfile.h -// -// When making changes to the file format, you must also increase two version -// numbers: -// -// i) OffsetTable.Version in this file. -// ii) MONO_SYMBOL_FILE_VERSION in mono/metadata/debug-mono-symfile.h -// -// After doing so, recompile everything, including the debugger. Symbol files -// with different versions are incompatible to each other and the debugger and -// the runtime enfore this, so you need to recompile all your assemblies after -// changing the file format. -// - -namespace Mono.CompilerServices.SymbolWriter -{ - public class OffsetTable - { - public const int MajorVersion = 50; - public const int MinorVersion = 0; - public const long Magic = 0x45e82623fd7fa614; - - #region This is actually written to the symbol file - public int TotalFileSize; - public int DataSectionOffset; - public int DataSectionSize; - public int CompileUnitCount; - public int CompileUnitTableOffset; - public int CompileUnitTableSize; - public int SourceCount; - public int SourceTableOffset; - public int SourceTableSize; - public int MethodCount; - public int MethodTableOffset; - public int MethodTableSize; - public int TypeCount; - public int AnonymousScopeCount; - public int AnonymousScopeTableOffset; - public int AnonymousScopeTableSize; - - [Flags] - public enum Flags - { - IsAspxSource = 1, - WindowsFileNames = 2 - } - - public Flags FileFlags; - - public int LineNumberTable_LineBase = LineNumberTable.Default_LineBase; - public int LineNumberTable_LineRange = LineNumberTable.Default_LineRange; - public int LineNumberTable_OpcodeBase = LineNumberTable.Default_OpcodeBase; - #endregion - - internal OffsetTable () - { -#if !NET_CORE - int platform = (int) Environment.OSVersion.Platform; - if ((platform != 4) && (platform != 128)) - FileFlags |= Flags.WindowsFileNames; -#endif - } - - internal OffsetTable (BinaryReader reader, int major_version, int minor_version) - { - TotalFileSize = reader.ReadInt32 (); - DataSectionOffset = reader.ReadInt32 (); - DataSectionSize = reader.ReadInt32 (); - CompileUnitCount = reader.ReadInt32 (); - CompileUnitTableOffset = reader.ReadInt32 (); - CompileUnitTableSize = reader.ReadInt32 (); - SourceCount = reader.ReadInt32 (); - SourceTableOffset = reader.ReadInt32 (); - SourceTableSize = reader.ReadInt32 (); - MethodCount = reader.ReadInt32 (); - MethodTableOffset = reader.ReadInt32 (); - MethodTableSize = reader.ReadInt32 (); - TypeCount = reader.ReadInt32 (); - - AnonymousScopeCount = reader.ReadInt32 (); - AnonymousScopeTableOffset = reader.ReadInt32 (); - AnonymousScopeTableSize = reader.ReadInt32 (); - - LineNumberTable_LineBase = reader.ReadInt32 (); - LineNumberTable_LineRange = reader.ReadInt32 (); - LineNumberTable_OpcodeBase = reader.ReadInt32 (); - - FileFlags = (Flags) reader.ReadInt32 (); - } - - internal void Write (BinaryWriter bw, int major_version, int minor_version) - { - bw.Write (TotalFileSize); - bw.Write (DataSectionOffset); - bw.Write (DataSectionSize); - bw.Write (CompileUnitCount); - bw.Write (CompileUnitTableOffset); - bw.Write (CompileUnitTableSize); - bw.Write (SourceCount); - bw.Write (SourceTableOffset); - bw.Write (SourceTableSize); - bw.Write (MethodCount); - bw.Write (MethodTableOffset); - bw.Write (MethodTableSize); - bw.Write (TypeCount); - - bw.Write (AnonymousScopeCount); - bw.Write (AnonymousScopeTableOffset); - bw.Write (AnonymousScopeTableSize); - - bw.Write (LineNumberTable_LineBase); - bw.Write (LineNumberTable_LineRange); - bw.Write (LineNumberTable_OpcodeBase); - - bw.Write ((int) FileFlags); - } - - public override string ToString () - { - return String.Format ( - "OffsetTable [{0} - {1}:{2} - {3}:{4}:{5} - {6}:{7}:{8} - {9}]", - TotalFileSize, DataSectionOffset, DataSectionSize, SourceCount, - SourceTableOffset, SourceTableSize, MethodCount, MethodTableOffset, - MethodTableSize, TypeCount); - } - } - - public class LineNumberEntry - { - #region This is actually written to the symbol file - public readonly int Row; - public int Column; - public int EndRow, EndColumn; - public readonly int File; - public readonly int Offset; - public readonly bool IsHidden; // Obsolete is never used - #endregion - - public sealed class LocationComparer : IComparer - { - public static readonly LocationComparer Default = new LocationComparer (); - - public int Compare (LineNumberEntry l1, LineNumberEntry l2) - { - return l1.Row == l2.Row ? - l1.Column.CompareTo (l2.Column) : - l1.Row.CompareTo (l2.Row); - } - } - - public static readonly LineNumberEntry Null = new LineNumberEntry (0, 0, 0, 0); - - public LineNumberEntry (int file, int row, int column, int offset) - : this (file, row, column, offset, false) - { - } - - public LineNumberEntry (int file, int row, int offset) - : this (file, row, -1, offset, false) - { - } - - public LineNumberEntry (int file, int row, int column, int offset, bool is_hidden) - : this (file, row, column, -1, -1, offset, is_hidden) - { - } - - public LineNumberEntry (int file, int row, int column, int end_row, int end_column, int offset, bool is_hidden) - { - this.File = file; - this.Row = row; - this.Column = column; - this.EndRow = end_row; - this.EndColumn = end_column; - this.Offset = offset; - this.IsHidden = is_hidden; - } - - public override string ToString () - { - return String.Format ("[Line {0}:{1},{2}-{3},{4}:{5}]", File, Row, Column, EndRow, EndColumn, Offset); - } - } - - public class CodeBlockEntry - { - public int Index; - #region This is actually written to the symbol file - public int Parent; - public Type BlockType; - public int StartOffset; - public int EndOffset; - #endregion - - public enum Type { - Lexical = 1, - CompilerGenerated = 2, - IteratorBody = 3, - IteratorDispatcher = 4 - } - - public CodeBlockEntry (int index, int parent, Type type, int start_offset) - { - this.Index = index; - this.Parent = parent; - this.BlockType = type; - this.StartOffset = start_offset; - } - - internal CodeBlockEntry (int index, MyBinaryReader reader) - { - this.Index = index; - int type_flag = reader.ReadLeb128 (); - BlockType = (Type) (type_flag & 0x3f); - this.Parent = reader.ReadLeb128 (); - this.StartOffset = reader.ReadLeb128 (); - this.EndOffset = reader.ReadLeb128 (); - - /* Reserved for future extensions. */ - if ((type_flag & 0x40) != 0) { - int data_size = reader.ReadInt16 (); - reader.BaseStream.Position += data_size; - } - } - - public void Close (int end_offset) - { - this.EndOffset = end_offset; - } - - internal void Write (MyBinaryWriter bw) - { - bw.WriteLeb128 ((int) BlockType); - bw.WriteLeb128 (Parent); - bw.WriteLeb128 (StartOffset); - bw.WriteLeb128 (EndOffset); - } - - public override string ToString () - { - return String.Format ("[CodeBlock {0}:{1}:{2}:{3}:{4}]", - Index, Parent, BlockType, StartOffset, EndOffset); - } - } - - public struct LocalVariableEntry - { - #region This is actually written to the symbol file - public readonly int Index; - public readonly string Name; - public readonly int BlockIndex; - #endregion - - public LocalVariableEntry (int index, string name, int block) - { - this.Index = index; - this.Name = name; - this.BlockIndex = block; - } - - internal LocalVariableEntry (MonoSymbolFile file, MyBinaryReader reader) - { - Index = reader.ReadLeb128 (); - Name = reader.ReadString (); - BlockIndex = reader.ReadLeb128 (); - } - - internal void Write (MonoSymbolFile file, MyBinaryWriter bw) - { - bw.WriteLeb128 (Index); - bw.Write (Name); - bw.WriteLeb128 (BlockIndex); - } - - public override string ToString () - { - return String.Format ("[LocalVariable {0}:{1}:{2}]", - Name, Index, BlockIndex - 1); - } - } - - public struct CapturedVariable - { - #region This is actually written to the symbol file - public readonly string Name; - public readonly string CapturedName; - public readonly CapturedKind Kind; - #endregion - - public enum CapturedKind : byte - { - Local, - Parameter, - This - } - - public CapturedVariable (string name, string captured_name, - CapturedKind kind) - { - this.Name = name; - this.CapturedName = captured_name; - this.Kind = kind; - } - - internal CapturedVariable (MyBinaryReader reader) - { - Name = reader.ReadString (); - CapturedName = reader.ReadString (); - Kind = (CapturedKind) reader.ReadByte (); - } - - internal void Write (MyBinaryWriter bw) - { - bw.Write (Name); - bw.Write (CapturedName); - bw.Write ((byte) Kind); - } - - public override string ToString () - { - return String.Format ("[CapturedVariable {0}:{1}:{2}]", - Name, CapturedName, Kind); - } - } - - public struct CapturedScope - { - #region This is actually written to the symbol file - public readonly int Scope; - public readonly string CapturedName; - #endregion - - public CapturedScope (int scope, string captured_name) - { - this.Scope = scope; - this.CapturedName = captured_name; - } - - internal CapturedScope (MyBinaryReader reader) - { - Scope = reader.ReadLeb128 (); - CapturedName = reader.ReadString (); - } - - internal void Write (MyBinaryWriter bw) - { - bw.WriteLeb128 (Scope); - bw.Write (CapturedName); - } - - public override string ToString () - { - return String.Format ("[CapturedScope {0}:{1}]", - Scope, CapturedName); - } - } - - public struct ScopeVariable - { - #region This is actually written to the symbol file - public readonly int Scope; - public readonly int Index; - #endregion - - public ScopeVariable (int scope, int index) - { - this.Scope = scope; - this.Index = index; - } - - internal ScopeVariable (MyBinaryReader reader) - { - Scope = reader.ReadLeb128 (); - Index = reader.ReadLeb128 (); - } - - internal void Write (MyBinaryWriter bw) - { - bw.WriteLeb128 (Scope); - bw.WriteLeb128 (Index); - } - - public override string ToString () - { - return String.Format ("[ScopeVariable {0}:{1}]", Scope, Index); - } - } - - public class AnonymousScopeEntry - { - #region This is actually written to the symbol file - public readonly int ID; - #endregion - - List captured_vars = new List (); - List captured_scopes = new List (); - - public AnonymousScopeEntry (int id) - { - this.ID = id; - } - - internal AnonymousScopeEntry (MyBinaryReader reader) - { - ID = reader.ReadLeb128 (); - - int num_captured_vars = reader.ReadLeb128 (); - for (int i = 0; i < num_captured_vars; i++) - captured_vars.Add (new CapturedVariable (reader)); - - int num_captured_scopes = reader.ReadLeb128 (); - for (int i = 0; i < num_captured_scopes; i++) - captured_scopes.Add (new CapturedScope (reader)); - } - - internal void AddCapturedVariable (string name, string captured_name, - CapturedVariable.CapturedKind kind) - { - captured_vars.Add (new CapturedVariable (name, captured_name, kind)); - } - - public CapturedVariable[] CapturedVariables { - get { - CapturedVariable[] retval = new CapturedVariable [captured_vars.Count]; - captured_vars.CopyTo (retval, 0); - return retval; - } - } - - internal void AddCapturedScope (int scope, string captured_name) - { - captured_scopes.Add (new CapturedScope (scope, captured_name)); - } - - public CapturedScope[] CapturedScopes { - get { - CapturedScope[] retval = new CapturedScope [captured_scopes.Count]; - captured_scopes.CopyTo (retval, 0); - return retval; - } - } - - internal void Write (MyBinaryWriter bw) - { - bw.WriteLeb128 (ID); - - bw.WriteLeb128 (captured_vars.Count); - foreach (CapturedVariable cv in captured_vars) - cv.Write (bw); - - bw.WriteLeb128 (captured_scopes.Count); - foreach (CapturedScope cs in captured_scopes) - cs.Write (bw); - } - - public override string ToString () - { - return String.Format ("[AnonymousScope {0}]", ID); - } - } - - public class CompileUnitEntry : ICompileUnit - { - #region This is actually written to the symbol file - public readonly int Index; - int DataOffset; - #endregion - - MonoSymbolFile file; - SourceFileEntry source; - List include_files; - List namespaces; - - bool creating; - - public static int Size { - get { return 8; } - } - - CompileUnitEntry ICompileUnit.Entry { - get { return this; } - } - - public CompileUnitEntry (MonoSymbolFile file, SourceFileEntry source) - { - this.file = file; - this.source = source; - - this.Index = file.AddCompileUnit (this); - - creating = true; - namespaces = new List (); - } - - public void AddFile (SourceFileEntry file) - { - if (!creating) - throw new InvalidOperationException (); - - if (include_files == null) - include_files = new List (); - - include_files.Add (file); - } - - public SourceFileEntry SourceFile { - get { - if (creating) - return source; - - ReadData (); - return source; - } - } - - public int DefineNamespace (string name, string[] using_clauses, int parent) - { - if (!creating) - throw new InvalidOperationException (); - - int index = file.GetNextNamespaceIndex (); - NamespaceEntry ns = new NamespaceEntry (name, index, using_clauses, parent); - namespaces.Add (ns); - return index; - } - - internal void WriteData (MyBinaryWriter bw) - { - DataOffset = (int) bw.BaseStream.Position; - bw.WriteLeb128 (source.Index); - - int count_includes = include_files != null ? include_files.Count : 0; - bw.WriteLeb128 (count_includes); - if (include_files != null) { - foreach (SourceFileEntry entry in include_files) - bw.WriteLeb128 (entry.Index); - } - - bw.WriteLeb128 (namespaces.Count); - foreach (NamespaceEntry ns in namespaces) - ns.Write (file, bw); - } - - internal void Write (BinaryWriter bw) - { - bw.Write (Index); - bw.Write (DataOffset); - } - - internal CompileUnitEntry (MonoSymbolFile file, MyBinaryReader reader) - { - this.file = file; - - Index = reader.ReadInt32 (); - DataOffset = reader.ReadInt32 (); - } - - public void ReadAll () - { - ReadData (); - } - - void ReadData () - { - if (creating) - throw new InvalidOperationException (); - - lock (file) { - if (namespaces != null) - return; - - MyBinaryReader reader = file.BinaryReader; - int old_pos = (int) reader.BaseStream.Position; - - reader.BaseStream.Position = DataOffset; - - int source_idx = reader.ReadLeb128 (); - source = file.GetSourceFile (source_idx); - - int count_includes = reader.ReadLeb128 (); - if (count_includes > 0) { - include_files = new List (); - for (int i = 0; i < count_includes; i++) - include_files.Add (file.GetSourceFile (reader.ReadLeb128 ())); - } - - int count_ns = reader.ReadLeb128 (); - namespaces = new List (); - for (int i = 0; i < count_ns; i ++) - namespaces.Add (new NamespaceEntry (file, reader)); - - reader.BaseStream.Position = old_pos; - } - } - - public NamespaceEntry[] Namespaces { - get { - ReadData (); - NamespaceEntry[] retval = new NamespaceEntry [namespaces.Count]; - namespaces.CopyTo (retval, 0); - return retval; - } - } - - public SourceFileEntry[] IncludeFiles { - get { - ReadData (); - if (include_files == null) - return new SourceFileEntry [0]; - - SourceFileEntry[] retval = new SourceFileEntry [include_files.Count]; - include_files.CopyTo (retval, 0); - return retval; - } - } - } - - public class SourceFileEntry - { - #region This is actually written to the symbol file - public readonly int Index; - int DataOffset; - #endregion - - MonoSymbolFile file; - string file_name; - byte[] guid; - byte[] hash; - bool creating; - bool auto_generated; - readonly string sourceFile; - - public static int Size { - get { return 8; } - } - - public SourceFileEntry (MonoSymbolFile file, string file_name) - { - this.file = file; - this.file_name = file_name; - this.Index = file.AddSource (this); - - creating = true; - } - - public SourceFileEntry (MonoSymbolFile file, string sourceFile, byte [] guid, byte [] checksum) - : this (file, sourceFile, sourceFile, guid, checksum) - { - } - - public SourceFileEntry (MonoSymbolFile file, string fileName, string sourceFile, byte[] guid, byte[] checksum) - : this (file, fileName) - { - this.guid = guid; - this.hash = checksum; - this.sourceFile = sourceFile; - } - - public byte[] Checksum { - get { - return hash; - } - } - - internal void WriteData (MyBinaryWriter bw) - { - DataOffset = (int) bw.BaseStream.Position; - bw.Write (file_name); - - if (guid == null) - guid = new byte[16]; - - if (hash == null) { - try { - using (FileStream fs = new FileStream (sourceFile, FileMode.Open, FileAccess.Read)) { - MD5 md5 = MD5.Create (); - hash = md5.ComputeHash (fs); - } - } catch { - hash = new byte [16]; - } - } - - bw.Write (guid); - bw.Write (hash); - bw.Write ((byte) (auto_generated ? 1 : 0)); - } - - internal void Write (BinaryWriter bw) - { - bw.Write (Index); - bw.Write (DataOffset); - } - - internal SourceFileEntry (MonoSymbolFile file, MyBinaryReader reader) - { - this.file = file; - - Index = reader.ReadInt32 (); - DataOffset = reader.ReadInt32 (); - - int old_pos = (int) reader.BaseStream.Position; - reader.BaseStream.Position = DataOffset; - - sourceFile = file_name = reader.ReadString (); - guid = reader.ReadBytes (16); - hash = reader.ReadBytes (16); - auto_generated = reader.ReadByte () == 1; - - reader.BaseStream.Position = old_pos; - } - - public string FileName { - get { return file_name; } - set { file_name = value; } - } - - public bool AutoGenerated { - get { return auto_generated; } - } - - public void SetAutoGenerated () - { - if (!creating) - throw new InvalidOperationException (); - - auto_generated = true; - file.OffsetTable.FileFlags |= OffsetTable.Flags.IsAspxSource; - } - - public bool CheckChecksum () - { - try { - using (FileStream fs = new FileStream (sourceFile, FileMode.Open)) { - MD5 md5 = MD5.Create (); - byte[] data = md5.ComputeHash (fs); - for (int i = 0; i < 16; i++) - if (data [i] != hash [i]) - return false; - return true; - } - } catch { - return false; - } - } - - public override string ToString () - { - return String.Format ("SourceFileEntry ({0}:{1})", Index, DataOffset); - } - } - - public class LineNumberTable - { - protected LineNumberEntry[] _line_numbers; - public LineNumberEntry[] LineNumbers { - get { return _line_numbers; } - } - - public readonly int LineBase; - public readonly int LineRange; - public readonly byte OpcodeBase; - public readonly int MaxAddressIncrement; - -#region Configurable constants - public const int Default_LineBase = -1; - public const int Default_LineRange = 8; - public const byte Default_OpcodeBase = 9; - -#endregion - - public const byte DW_LNS_copy = 1; - public const byte DW_LNS_advance_pc = 2; - public const byte DW_LNS_advance_line = 3; - public const byte DW_LNS_set_file = 4; - public const byte DW_LNS_const_add_pc = 8; - - public const byte DW_LNE_end_sequence = 1; - - // MONO extensions. - public const byte DW_LNE_MONO_negate_is_hidden = 0x40; - - internal const byte DW_LNE_MONO__extensions_start = 0x40; - internal const byte DW_LNE_MONO__extensions_end = 0x7f; - - protected LineNumberTable (MonoSymbolFile file) - { - this.LineBase = file.OffsetTable.LineNumberTable_LineBase; - this.LineRange = file.OffsetTable.LineNumberTable_LineRange; - this.OpcodeBase = (byte) file.OffsetTable.LineNumberTable_OpcodeBase; - this.MaxAddressIncrement = (255 - OpcodeBase) / LineRange; - } - - internal LineNumberTable (MonoSymbolFile file, LineNumberEntry[] lines) - : this (file) - { - this._line_numbers = lines; - } - - internal void Write (MonoSymbolFile file, MyBinaryWriter bw, bool hasColumnsInfo, bool hasEndInfo) - { - int start = (int) bw.BaseStream.Position; - - bool last_is_hidden = false; - int last_line = 1, last_offset = 0, last_file = 1; - for (int i = 0; i < LineNumbers.Length; i++) { - int line_inc = LineNumbers [i].Row - last_line; - int offset_inc = LineNumbers [i].Offset - last_offset; - - if (LineNumbers [i].File != last_file) { - bw.Write (DW_LNS_set_file); - bw.WriteLeb128 (LineNumbers [i].File); - last_file = LineNumbers [i].File; - } - - if (LineNumbers [i].IsHidden != last_is_hidden) { - bw.Write ((byte) 0); - bw.Write ((byte) 1); - bw.Write (DW_LNE_MONO_negate_is_hidden); - last_is_hidden = LineNumbers [i].IsHidden; - } - - if (offset_inc >= MaxAddressIncrement) { - if (offset_inc < 2 * MaxAddressIncrement) { - bw.Write (DW_LNS_const_add_pc); - offset_inc -= MaxAddressIncrement; - } else { - bw.Write (DW_LNS_advance_pc); - bw.WriteLeb128 (offset_inc); - offset_inc = 0; - } - } - - if ((line_inc < LineBase) || (line_inc >= LineBase + LineRange)) { - bw.Write (DW_LNS_advance_line); - bw.WriteLeb128 (line_inc); - if (offset_inc != 0) { - bw.Write (DW_LNS_advance_pc); - bw.WriteLeb128 (offset_inc); - } - bw.Write (DW_LNS_copy); - } else { - byte opcode; - opcode = (byte) (line_inc - LineBase + (LineRange * offset_inc) + - OpcodeBase); - bw.Write (opcode); - } - - last_line = LineNumbers [i].Row; - last_offset = LineNumbers [i].Offset; - } - - bw.Write ((byte) 0); - bw.Write ((byte) 1); - bw.Write (DW_LNE_end_sequence); - - if (hasColumnsInfo) { - for (int i = 0; i < LineNumbers.Length; i++) { - var ln = LineNumbers [i]; - if (ln.Row >= 0) - bw.WriteLeb128 (ln.Column); - } - } - - if (hasEndInfo) { - for (int i = 0; i < LineNumbers.Length; i++) { - var ln = LineNumbers [i]; - if (ln.EndRow == -1 || ln.EndColumn == -1 || ln.Row > ln.EndRow) { - bw.WriteLeb128 (0xffffff); - } else { - bw.WriteLeb128 (ln.EndRow - ln.Row); - bw.WriteLeb128 (ln.EndColumn); - } - } - } - - file.ExtendedLineNumberSize += (int) bw.BaseStream.Position - start; - } - - internal static LineNumberTable Read (MonoSymbolFile file, MyBinaryReader br, bool readColumnsInfo, bool readEndInfo) - { - LineNumberTable lnt = new LineNumberTable (file); - lnt.DoRead (file, br, readColumnsInfo, readEndInfo); - return lnt; - } - - void DoRead (MonoSymbolFile file, MyBinaryReader br, bool includesColumns, bool includesEnds) - { - var lines = new List (); - - bool is_hidden = false, modified = false; - int stm_line = 1, stm_offset = 0, stm_file = 1; - while (true) { - byte opcode = br.ReadByte (); - - if (opcode == 0) { - byte size = br.ReadByte (); - long end_pos = br.BaseStream.Position + size; - opcode = br.ReadByte (); - - if (opcode == DW_LNE_end_sequence) { - if (modified) - lines.Add (new LineNumberEntry ( - stm_file, stm_line, -1, stm_offset, is_hidden)); - break; - } else if (opcode == DW_LNE_MONO_negate_is_hidden) { - is_hidden = !is_hidden; - modified = true; - } else if ((opcode >= DW_LNE_MONO__extensions_start) && - (opcode <= DW_LNE_MONO__extensions_end)) { - ; // reserved for future extensions - } else { - throw new MonoSymbolFileException ("Unknown extended opcode {0:x}", opcode); - } - - br.BaseStream.Position = end_pos; - continue; - } else if (opcode < OpcodeBase) { - switch (opcode) { - case DW_LNS_copy: - lines.Add (new LineNumberEntry ( - stm_file, stm_line, -1, stm_offset, is_hidden)); - modified = false; - break; - case DW_LNS_advance_pc: - stm_offset += br.ReadLeb128 (); - modified = true; - break; - case DW_LNS_advance_line: - stm_line += br.ReadLeb128 (); - modified = true; - break; - case DW_LNS_set_file: - stm_file = br.ReadLeb128 (); - modified = true; - break; - case DW_LNS_const_add_pc: - stm_offset += MaxAddressIncrement; - modified = true; - break; - default: - throw new MonoSymbolFileException ( - "Unknown standard opcode {0:x} in LNT", - opcode); - } - } else { - opcode -= OpcodeBase; - - stm_offset += opcode / LineRange; - stm_line += LineBase + (opcode % LineRange); - lines.Add (new LineNumberEntry ( - stm_file, stm_line, -1, stm_offset, is_hidden)); - modified = false; - } - } - - _line_numbers = lines.ToArray (); - - if (includesColumns) { - for (int i = 0; i < _line_numbers.Length; ++i) { - var ln = _line_numbers[i]; - if (ln.Row >= 0) - ln.Column = br.ReadLeb128 (); - } - } - if (includesEnds) { - for (int i = 0; i < _line_numbers.Length; ++i) { - var ln = _line_numbers[i]; - - int row = br.ReadLeb128 (); - if (row == 0xffffff) { - ln.EndRow = -1; - ln.EndColumn = -1; - } else { - ln.EndRow = ln.Row + row; - ln.EndColumn = br.ReadLeb128 (); - } - } - } - } - - public bool GetMethodBounds (out LineNumberEntry start, out LineNumberEntry end) - { - if (_line_numbers.Length > 1) { - start = _line_numbers [0]; - end = _line_numbers [_line_numbers.Length - 1]; - return true; - } - - start = LineNumberEntry.Null; - end = LineNumberEntry.Null; - return false; - } - } - - public class MethodEntry : IComparable - { - #region This is actually written to the symbol file - public readonly int CompileUnitIndex; - public readonly int Token; - public readonly int NamespaceID; - - int DataOffset; - int LocalVariableTableOffset; - int LineNumberTableOffset; - int CodeBlockTableOffset; - int ScopeVariableTableOffset; - int RealNameOffset; - Flags flags; - #endregion - - int index; - - public Flags MethodFlags { - get { return flags; } - } - - public readonly CompileUnitEntry CompileUnit; - - LocalVariableEntry[] locals; - CodeBlockEntry[] code_blocks; - ScopeVariable[] scope_vars; - LineNumberTable lnt; - string real_name; - - public readonly MonoSymbolFile SymbolFile; - - public int Index { - get { return index; } - set { index = value; } - } - - [Flags] - public enum Flags - { - LocalNamesAmbiguous = 1, - ColumnsInfoIncluded = 1 << 1, - EndInfoIncluded = 1 << 2 - } - - public const int Size = 12; - - internal MethodEntry (MonoSymbolFile file, MyBinaryReader reader, int index) - { - this.SymbolFile = file; - this.index = index; - - Token = reader.ReadInt32 (); - DataOffset = reader.ReadInt32 (); - LineNumberTableOffset = reader.ReadInt32 (); - - long old_pos = reader.BaseStream.Position; - reader.BaseStream.Position = DataOffset; - - CompileUnitIndex = reader.ReadLeb128 (); - LocalVariableTableOffset = reader.ReadLeb128 (); - NamespaceID = reader.ReadLeb128 (); - - CodeBlockTableOffset = reader.ReadLeb128 (); - ScopeVariableTableOffset = reader.ReadLeb128 (); - - RealNameOffset = reader.ReadLeb128 (); - - flags = (Flags) reader.ReadLeb128 (); - - reader.BaseStream.Position = old_pos; - - CompileUnit = file.GetCompileUnit (CompileUnitIndex); - } - - internal MethodEntry (MonoSymbolFile file, CompileUnitEntry comp_unit, - int token, ScopeVariable[] scope_vars, - LocalVariableEntry[] locals, LineNumberEntry[] lines, - CodeBlockEntry[] code_blocks, string real_name, - Flags flags, int namespace_id) - { - this.SymbolFile = file; - this.real_name = real_name; - this.locals = locals; - this.code_blocks = code_blocks; - this.scope_vars = scope_vars; - this.flags = flags; - - index = -1; - - Token = token; - CompileUnitIndex = comp_unit.Index; - CompileUnit = comp_unit; - NamespaceID = namespace_id; - - CheckLineNumberTable (lines); - lnt = new LineNumberTable (file, lines); - file.NumLineNumbers += lines.Length; - - int num_locals = locals != null ? locals.Length : 0; - - if (num_locals <= 32) { - // Most of the time, the O(n^2) factor is actually - // less than the cost of allocating the hash table, - // 32 is a rough number obtained through some testing. - - for (int i = 0; i < num_locals; i ++) { - string nm = locals [i].Name; - - for (int j = i + 1; j < num_locals; j ++) { - if (locals [j].Name == nm) { - flags |= Flags.LocalNamesAmbiguous; - goto locals_check_done; - } - } - } - locals_check_done : - ; - } else { - var local_names = new Dictionary (); - foreach (LocalVariableEntry local in locals) { - if (local_names.ContainsKey (local.Name)) { - flags |= Flags.LocalNamesAmbiguous; - break; - } - local_names.Add (local.Name, local); - } - } - } - - static void CheckLineNumberTable (LineNumberEntry[] line_numbers) - { - int last_offset = -1; - int last_row = -1; - - if (line_numbers == null) - return; - - for (int i = 0; i < line_numbers.Length; i++) { - LineNumberEntry line = line_numbers [i]; - - if (line.Equals (LineNumberEntry.Null)) - throw new MonoSymbolFileException (); - - if (line.Offset < last_offset) - throw new MonoSymbolFileException (); - - if (line.Offset > last_offset) { - last_row = line.Row; - last_offset = line.Offset; - } else if (line.Row > last_row) { - last_row = line.Row; - } - } - } - - internal void Write (MyBinaryWriter bw) - { - if ((index <= 0) || (DataOffset == 0)) - throw new InvalidOperationException (); - - bw.Write (Token); - bw.Write (DataOffset); - bw.Write (LineNumberTableOffset); - } - - internal void WriteData (MonoSymbolFile file, MyBinaryWriter bw) - { - if (index <= 0) - throw new InvalidOperationException (); - - LocalVariableTableOffset = (int) bw.BaseStream.Position; - int num_locals = locals != null ? locals.Length : 0; - bw.WriteLeb128 (num_locals); - for (int i = 0; i < num_locals; i++) - locals [i].Write (file, bw); - file.LocalCount += num_locals; - - CodeBlockTableOffset = (int) bw.BaseStream.Position; - int num_code_blocks = code_blocks != null ? code_blocks.Length : 0; - bw.WriteLeb128 (num_code_blocks); - for (int i = 0; i < num_code_blocks; i++) - code_blocks [i].Write (bw); - - ScopeVariableTableOffset = (int) bw.BaseStream.Position; - int num_scope_vars = scope_vars != null ? scope_vars.Length : 0; - bw.WriteLeb128 (num_scope_vars); - for (int i = 0; i < num_scope_vars; i++) - scope_vars [i].Write (bw); - - if (real_name != null) { - RealNameOffset = (int) bw.BaseStream.Position; - bw.Write (real_name); - } - - foreach (var lne in lnt.LineNumbers) { - if (lne.EndRow != -1 || lne.EndColumn != -1) - flags |= Flags.EndInfoIncluded; - } - - LineNumberTableOffset = (int) bw.BaseStream.Position; - lnt.Write (file, bw, (flags & Flags.ColumnsInfoIncluded) != 0, (flags & Flags.EndInfoIncluded) != 0); - - DataOffset = (int) bw.BaseStream.Position; - - bw.WriteLeb128 (CompileUnitIndex); - bw.WriteLeb128 (LocalVariableTableOffset); - bw.WriteLeb128 (NamespaceID); - - bw.WriteLeb128 (CodeBlockTableOffset); - bw.WriteLeb128 (ScopeVariableTableOffset); - - bw.WriteLeb128 (RealNameOffset); - bw.WriteLeb128 ((int) flags); - } - - public void ReadAll () - { - GetLineNumberTable (); - GetLocals (); - GetCodeBlocks (); - GetScopeVariables (); - GetRealName (); - } - - public LineNumberTable GetLineNumberTable () - { - lock (SymbolFile) { - if (lnt != null) - return lnt; - - if (LineNumberTableOffset == 0) - return null; - - MyBinaryReader reader = SymbolFile.BinaryReader; - long old_pos = reader.BaseStream.Position; - reader.BaseStream.Position = LineNumberTableOffset; - - lnt = LineNumberTable.Read (SymbolFile, reader, (flags & Flags.ColumnsInfoIncluded) != 0, (flags & Flags.EndInfoIncluded) != 0); - - reader.BaseStream.Position = old_pos; - return lnt; - } - } - - public LocalVariableEntry[] GetLocals () - { - lock (SymbolFile) { - if (locals != null) - return locals; - - if (LocalVariableTableOffset == 0) - return null; - - MyBinaryReader reader = SymbolFile.BinaryReader; - long old_pos = reader.BaseStream.Position; - reader.BaseStream.Position = LocalVariableTableOffset; - - int num_locals = reader.ReadLeb128 (); - locals = new LocalVariableEntry [num_locals]; - - for (int i = 0; i < num_locals; i++) - locals [i] = new LocalVariableEntry (SymbolFile, reader); - - reader.BaseStream.Position = old_pos; - return locals; - } - } - - public CodeBlockEntry[] GetCodeBlocks () - { - lock (SymbolFile) { - if (code_blocks != null) - return code_blocks; - - if (CodeBlockTableOffset == 0) - return null; - - MyBinaryReader reader = SymbolFile.BinaryReader; - long old_pos = reader.BaseStream.Position; - reader.BaseStream.Position = CodeBlockTableOffset; - - int num_code_blocks = reader.ReadLeb128 (); - code_blocks = new CodeBlockEntry [num_code_blocks]; - - for (int i = 0; i < num_code_blocks; i++) - code_blocks [i] = new CodeBlockEntry (i, reader); - - reader.BaseStream.Position = old_pos; - return code_blocks; - } - } - - public ScopeVariable[] GetScopeVariables () - { - lock (SymbolFile) { - if (scope_vars != null) - return scope_vars; - - if (ScopeVariableTableOffset == 0) - return null; - - MyBinaryReader reader = SymbolFile.BinaryReader; - long old_pos = reader.BaseStream.Position; - reader.BaseStream.Position = ScopeVariableTableOffset; - - int num_scope_vars = reader.ReadLeb128 (); - scope_vars = new ScopeVariable [num_scope_vars]; - - for (int i = 0; i < num_scope_vars; i++) - scope_vars [i] = new ScopeVariable (reader); - - reader.BaseStream.Position = old_pos; - return scope_vars; - } - } - - public string GetRealName () - { - lock (SymbolFile) { - if (real_name != null) - return real_name; - - if (RealNameOffset == 0) - return null; - - real_name = SymbolFile.BinaryReader.ReadString (RealNameOffset); - return real_name; - } - } - - public int CompareTo (object obj) - { - MethodEntry method = (MethodEntry) obj; - - if (method.Token < Token) - return 1; - else if (method.Token > Token) - return -1; - else - return 0; - } - - public override string ToString () - { - return String.Format ("[Method {0}:{1:x}:{2}:{3}]", - index, Token, CompileUnitIndex, CompileUnit); - } - } - - public struct NamespaceEntry - { - #region This is actually written to the symbol file - public readonly string Name; - public readonly int Index; - public readonly int Parent; - public readonly string[] UsingClauses; - #endregion - - public NamespaceEntry (string name, int index, string[] using_clauses, int parent) - { - this.Name = name; - this.Index = index; - this.Parent = parent; - this.UsingClauses = using_clauses != null ? using_clauses : new string [0]; - } - - internal NamespaceEntry (MonoSymbolFile file, MyBinaryReader reader) - { - Name = reader.ReadString (); - Index = reader.ReadLeb128 (); - Parent = reader.ReadLeb128 (); - - int count = reader.ReadLeb128 (); - UsingClauses = new string [count]; - for (int i = 0; i < count; i++) - UsingClauses [i] = reader.ReadString (); - } - - internal void Write (MonoSymbolFile file, MyBinaryWriter bw) - { - bw.Write (Name); - bw.WriteLeb128 (Index); - bw.WriteLeb128 (Parent); - bw.WriteLeb128 (UsingClauses.Length); - foreach (string uc in UsingClauses) - bw.Write (uc); - } - - public override string ToString () - { - return String.Format ("[Namespace {0}:{1}:{2}]", Name, Index, Parent); - } - } -} diff --git a/external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs b/external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs deleted file mode 100644 index 19e14c2f6e..0000000000 --- a/external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs +++ /dev/null @@ -1,238 +0,0 @@ -// -// Mono.CSharp.Debugger/MonoSymbolWriter.cs -// -// Author: -// Martin Baulig (martin@ximian.com) -// -// This is the default implementation of the System.Diagnostics.SymbolStore.ISymbolWriter -// interface. -// -// (C) 2002 Ximian, Inc. http://www.ximian.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.Runtime.CompilerServices; -using System.Collections.Generic; -using System.IO; - -namespace Mono.CompilerServices.SymbolWriter -{ - public class MonoSymbolWriter - { - List methods; - List sources; - List comp_units; - protected readonly MonoSymbolFile file; - string filename; - - private SourceMethodBuilder current_method; - Stack current_method_stack = new Stack (); - - public MonoSymbolWriter (string filename) - { - this.methods = new List (); - this.sources = new List (); - this.comp_units = new List (); - this.file = new MonoSymbolFile (); - - this.filename = filename + ".mdb"; - } - - public MonoSymbolFile SymbolFile { - get { return file; } - } - - public void CloseNamespace () - { } - - public void DefineLocalVariable (int index, string name) - { - if (current_method == null) - return; - - current_method.AddLocal (index, name); - } - - public void DefineCapturedLocal (int scope_id, string name, string captured_name) - { - file.DefineCapturedVariable (scope_id, name, captured_name, - CapturedVariable.CapturedKind.Local); - } - - public void DefineCapturedParameter (int scope_id, string name, string captured_name) - { - file.DefineCapturedVariable (scope_id, name, captured_name, - CapturedVariable.CapturedKind.Parameter); - } - - public void DefineCapturedThis (int scope_id, string captured_name) - { - file.DefineCapturedVariable (scope_id, "this", captured_name, - CapturedVariable.CapturedKind.This); - } - - public void DefineCapturedScope (int scope_id, int id, string captured_name) - { - file.DefineCapturedScope (scope_id, id, captured_name); - } - - public void DefineScopeVariable (int scope, int index) - { - if (current_method == null) - return; - - current_method.AddScopeVariable (scope, index); - } - - public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column, - bool is_hidden) - { - if (current_method == null) - return; - - current_method.MarkSequencePoint (offset, file, line, column, is_hidden); - } - - public SourceMethodBuilder OpenMethod (ICompileUnit file, int ns_id, IMethodDef method) - { - SourceMethodBuilder builder = new SourceMethodBuilder (file, ns_id, method); - current_method_stack.Push (current_method); - current_method = builder; - methods.Add (current_method); - return builder; - } - - public void CloseMethod () - { - current_method = (SourceMethodBuilder) current_method_stack.Pop (); - } - - public SourceFileEntry DefineDocument (string url) - { - SourceFileEntry entry = new SourceFileEntry (file, url); - sources.Add (entry); - return entry; - } - - public SourceFileEntry DefineDocument (string url, byte[] guid, byte[] checksum) - { - SourceFileEntry entry = new SourceFileEntry (file, url, guid, checksum); - sources.Add (entry); - return entry; - } - - public CompileUnitEntry DefineCompilationUnit (SourceFileEntry source) - { - CompileUnitEntry entry = new CompileUnitEntry (file, source); - comp_units.Add (entry); - return entry; - } - - public int DefineNamespace (string name, CompileUnitEntry unit, - string[] using_clauses, int parent) - { - if ((unit == null) || (using_clauses == null)) - throw new NullReferenceException (); - - return unit.DefineNamespace (name, using_clauses, parent); - } - - public int OpenScope (int start_offset) - { - if (current_method == null) - return 0; - - current_method.StartBlock (CodeBlockEntry.Type.Lexical, start_offset); - return 0; - } - - public void CloseScope (int end_offset) - { - if (current_method == null) - return; - - current_method.EndBlock (end_offset); - } - - public void OpenCompilerGeneratedBlock (int start_offset) - { - if (current_method == null) - return; - - current_method.StartBlock (CodeBlockEntry.Type.CompilerGenerated, - start_offset); - } - - public void CloseCompilerGeneratedBlock (int end_offset) - { - if (current_method == null) - return; - - current_method.EndBlock (end_offset); - } - - public void StartIteratorBody (int start_offset) - { - current_method.StartBlock (CodeBlockEntry.Type.IteratorBody, - start_offset); - } - - public void EndIteratorBody (int end_offset) - { - current_method.EndBlock (end_offset); - } - - public void StartIteratorDispatcher (int start_offset) - { - current_method.StartBlock (CodeBlockEntry.Type.IteratorDispatcher, - start_offset); - } - - public void EndIteratorDispatcher (int end_offset) - { - current_method.EndBlock (end_offset); - } - - public void DefineAnonymousScope (int id) - { - file.DefineAnonymousScope (id); - } - - public void WriteSymbolFile (Guid guid) - { - foreach (SourceMethodBuilder method in methods) - method.DefineMethod (file); - - try { - // We mmap the file, so unlink the previous version since it may be in use - File.Delete (filename); - } catch { - // We can safely ignore - } - using (FileStream fs = new FileStream (filename, FileMode.Create, FileAccess.Write)) { - file.CreateSymbolFile (guid, fs); - } - } - } -} diff --git a/external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/SourceMethodBuilder.cs b/external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/SourceMethodBuilder.cs deleted file mode 100644 index 094425cfe4..0000000000 --- a/external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/SourceMethodBuilder.cs +++ /dev/null @@ -1,246 +0,0 @@ -// -// SourceMethodBuilder.cs -// -// Authors: -// Martin Baulig (martin@ximian.com) -// Marek Safar (marek.safar@gmail.com) -// -// (C) 2002 Ximian, Inc. http://www.ximian.com -// Copyright (C) 2012 Xamarin Inc (http://www.xamarin.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.Generic; - -namespace Mono.CompilerServices.SymbolWriter -{ - public class SourceMethodBuilder - { - List _locals; - List _blocks; - List _scope_vars; - Stack _block_stack; - readonly List method_lines; - - readonly ICompileUnit _comp_unit; - readonly int ns_id; - readonly IMethodDef method; - - public SourceMethodBuilder (ICompileUnit comp_unit) - { - this._comp_unit = comp_unit; - method_lines = new List (); - } - - public SourceMethodBuilder (ICompileUnit comp_unit, int ns_id, IMethodDef method) - : this (comp_unit) - { - this.ns_id = ns_id; - this.method = method; - } - - public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column, bool is_hidden) - { - MarkSequencePoint (offset, file, line, column, -1, -1, is_hidden); - } - - public void MarkSequencePoint (int offset, SourceFileEntry file, int line, int column, int end_line, int end_column, bool is_hidden) - { - int file_idx = file != null ? file.Index : 0; - var lne = new LineNumberEntry (file_idx, line, column, end_line, end_column, offset, is_hidden); - - if (method_lines.Count > 0) { - var prev = method_lines[method_lines.Count - 1]; - - // - // Same offset cannot be used for multiple lines - // - if (prev.Offset == offset) { - // - // Use the new location because debugger will adjust - // the breakpoint to next line with sequence point - // - if (LineNumberEntry.LocationComparer.Default.Compare (lne, prev) > 0) - method_lines[method_lines.Count - 1] = lne; - - return; - } - } - - method_lines.Add (lne); - } - - public void StartBlock (CodeBlockEntry.Type type, int start_offset) - { - StartBlock (type, start_offset, _blocks == null ? 1 : _blocks.Count + 1); - } - - public void StartBlock (CodeBlockEntry.Type type, int start_offset, int scopeIndex) - { - if (_block_stack == null) { - _block_stack = new Stack (); - } - - if (_blocks == null) - _blocks = new List (); - - int parent = CurrentBlock != null ? CurrentBlock.Index : -1; - - CodeBlockEntry block = new CodeBlockEntry ( - scopeIndex, parent, type, start_offset); - - _block_stack.Push (block); - _blocks.Add (block); - } - - public void EndBlock (int end_offset) - { - CodeBlockEntry block = (CodeBlockEntry) _block_stack.Pop (); - block.Close (end_offset); - } - - public CodeBlockEntry[] Blocks { - get { - if (_blocks == null) - return new CodeBlockEntry [0]; - - CodeBlockEntry[] retval = new CodeBlockEntry [_blocks.Count]; - _blocks.CopyTo (retval, 0); - return retval; - } - } - - public CodeBlockEntry CurrentBlock { - get { - if ((_block_stack != null) && (_block_stack.Count > 0)) - return (CodeBlockEntry) _block_stack.Peek (); - else - return null; - } - } - - public LocalVariableEntry[] Locals { - get { - if (_locals == null) - return new LocalVariableEntry [0]; - else { - return _locals.ToArray (); - } - } - } - - public ICompileUnit SourceFile { - get { - return _comp_unit; - } - } - - public void AddLocal (int index, string name) - { - if (_locals == null) - _locals = new List (); - int block_idx = CurrentBlock != null ? CurrentBlock.Index : 0; - _locals.Add (new LocalVariableEntry (index, name, block_idx)); - } - - public ScopeVariable[] ScopeVariables { - get { - if (_scope_vars == null) - return new ScopeVariable [0]; - - return _scope_vars.ToArray (); - } - } - - public void AddScopeVariable (int scope, int index) - { - if (_scope_vars == null) - _scope_vars = new List (); - _scope_vars.Add ( - new ScopeVariable (scope, index)); - } - - public void DefineMethod (MonoSymbolFile file) - { - DefineMethod (file, method.Token); - } - - public void DefineMethod (MonoSymbolFile file, int token) - { - var blocks = Blocks; - if (blocks.Length > 0) { - // - // When index is provided by user it can be inserted in - // any order but mdb format does not store its value. It - // uses stored order as the index instead. - // - var sorted = new List (blocks.Length); - int max_index = 0; - for (int i = 0; i < blocks.Length; ++i) { - max_index = System.Math.Max (max_index, blocks [i].Index); - } - - for (int i = 0; i < max_index; ++i) { - var scope_index = i + 1; - - // - // Common fast path - // - if (i < blocks.Length && blocks [i].Index == scope_index) { - sorted.Add (blocks [i]); - continue; - } - - bool found = false; - for (int ii = 0; ii < blocks.Length; ++ii) { - if (blocks [ii].Index == scope_index) { - sorted.Add (blocks [ii]); - found = true; - break; - } - } - - if (found) - continue; - - // - // Ideally this should never happen but with current design we can - // generate scope index for unreachable code before reachable code - // - sorted.Add (new CodeBlockEntry (scope_index, -1, CodeBlockEntry.Type.CompilerGenerated, 0)); - } - - blocks = sorted.ToArray (); - //for (int i = 0; i < blocks.Length; ++i) { - // if (blocks [i].Index - 1 != i) - // throw new ArgumentException ("CodeBlocks cannot be converted to mdb format"); - //} - } - - var entry = new MethodEntry ( - file, _comp_unit.Entry, token, ScopeVariables, - Locals, method_lines.ToArray (), blocks, null, MethodEntry.Flags.ColumnsInfoIncluded, ns_id); - - file.AddMethod (entry); - } - } -} diff --git a/external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/SymbolWriterImpl.cs b/external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/SymbolWriterImpl.cs deleted file mode 100644 index 96e5fe191b..0000000000 --- a/external/linker/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/SymbolWriterImpl.cs +++ /dev/null @@ -1,352 +0,0 @@ -// -// SymbolWriterImpl.cs -// -// Author: -// Lluis Sanchez Gual (lluis@novell.com) -// -// (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. -// - -#if !NET_CORE - -using System; -using System.Reflection; -using System.Reflection.Emit; -using System.Runtime.CompilerServices; -using System.Collections; -using System.IO; -using System.Diagnostics.SymbolStore; - -namespace Mono.CompilerServices.SymbolWriter -{ - public class SymbolWriterImpl: ISymbolWriter - { - MonoSymbolWriter msw; - - int nextLocalIndex; - int currentToken; - string methodName; - Stack namespaceStack = new Stack (); - bool methodOpened; - - Hashtable documents = new Hashtable (); - -#if !CECIL - ModuleBuilder mb; - delegate Guid GetGuidFunc (ModuleBuilder mb); - GetGuidFunc get_guid_func; - - public SymbolWriterImpl (ModuleBuilder mb) - { - this.mb = mb; - } - - public void Close () - { - MethodInfo mi = typeof (ModuleBuilder).GetMethod ( - "Mono_GetGuid", - BindingFlags.Static | BindingFlags.NonPublic); - if (mi == null) - return; - - get_guid_func = (GetGuidFunc) System.Delegate.CreateDelegate ( - typeof (GetGuidFunc), mi); - - msw.WriteSymbolFile (get_guid_func (mb)); - } -#else - Guid guid; - - public SymbolWriterImpl (Guid guid) - { - this.guid = guid; - } - - public void Close () - { - msw.WriteSymbolFile (guid); - } -#endif - - public void CloseMethod () - { - if (methodOpened) { - methodOpened = false; - nextLocalIndex = 0; - msw.CloseMethod (); - } - } - - public void CloseNamespace () - { - namespaceStack.Pop (); - msw.CloseNamespace (); - } - - public void CloseScope (int endOffset) - { - msw.CloseScope (endOffset); - } - - public ISymbolDocumentWriter DefineDocument ( - string url, - Guid language, - Guid languageVendor, - Guid documentType) - { - SymbolDocumentWriterImpl doc = (SymbolDocumentWriterImpl) documents [url]; - if (doc == null) { - SourceFileEntry entry = msw.DefineDocument (url); - CompileUnitEntry comp_unit = msw.DefineCompilationUnit (entry); - doc = new SymbolDocumentWriterImpl (comp_unit); - documents [url] = doc; - } - return doc; - } - - public void DefineField ( - SymbolToken parent, - string name, - FieldAttributes attributes, - byte[] signature, - SymAddressKind addrKind, - int addr1, - int addr2, - int addr3) - { - } - - public void DefineGlobalVariable ( - string name, - FieldAttributes attributes, - byte[] signature, - SymAddressKind addrKind, - int addr1, - int addr2, - int addr3) - { - } - - public void DefineLocalVariable ( - string name, - FieldAttributes attributes, - byte[] signature, - SymAddressKind addrKind, - int addr1, - int addr2, - int addr3, - int startOffset, - int endOffset) - { - msw.DefineLocalVariable (nextLocalIndex++, name); - } - - public void DefineParameter ( - string name, - ParameterAttributes attributes, - int sequence, - SymAddressKind addrKind, - int addr1, - int addr2, - int addr3) - { - } - - public void DefineSequencePoints ( - ISymbolDocumentWriter document, - int[] offsets, - int[] lines, - int[] columns, - int[] endLines, - int[] endColumns) - { - SymbolDocumentWriterImpl doc = (SymbolDocumentWriterImpl) document; - SourceFileEntry file = doc != null ? doc.Entry.SourceFile : null; - - for (int n=0; n 0 && offsets[n] == offsets[n-1] && lines[n] == lines[n-1] && columns[n] == columns[n-1]) - continue; - msw.MarkSequencePoint (offsets[n], file, lines[n], columns[n], false); - } - } - - public void Initialize (IntPtr emitter, string filename, bool fFullBuild) - { - msw = new MonoSymbolWriter (filename); - } - - public void OpenMethod (SymbolToken method) - { - currentToken = method.GetToken (); - } - - public void OpenNamespace (string name) - { - NamespaceInfo n = new NamespaceInfo (); - n.NamespaceID = -1; - n.Name = name; - namespaceStack.Push (n); - } - - public int OpenScope (int startOffset) - { - return msw.OpenScope (startOffset); - } - - public void SetMethodSourceRange ( - ISymbolDocumentWriter startDoc, - int startLine, - int startColumn, - ISymbolDocumentWriter endDoc, - int endLine, - int endColumn) - { - int nsId = GetCurrentNamespace (startDoc); - SourceMethodImpl sm = new SourceMethodImpl (methodName, currentToken, nsId); - msw.OpenMethod (((ICompileUnit)startDoc).Entry, nsId, sm); - methodOpened = true; - } - - public void SetScopeRange (int scopeID, int startOffset, int endOffset) - { - } - - public void SetSymAttribute (SymbolToken parent, string name, byte[] data) - { - // This is a hack! but MonoSymbolWriter needs the method name - // and ISymbolWriter does not have any method for providing it - if (name == "__name") - methodName = System.Text.Encoding.UTF8.GetString (data); - } - - public void SetUnderlyingWriter (IntPtr underlyingWriter) - { - } - - public void SetUserEntryPoint (SymbolToken entryMethod) - { - } - - public void UsingNamespace (string fullName) - { - if (namespaceStack.Count == 0) { - OpenNamespace (""); - } - - NamespaceInfo ni = (NamespaceInfo) namespaceStack.Peek (); - if (ni.NamespaceID != -1) { - NamespaceInfo old = ni; - CloseNamespace (); - OpenNamespace (old.Name); - ni = (NamespaceInfo) namespaceStack.Peek (); - ni.UsingClauses = old.UsingClauses; - } - ni.UsingClauses.Add (fullName); - } - - int GetCurrentNamespace (ISymbolDocumentWriter doc) - { - if (namespaceStack.Count == 0) { - OpenNamespace (""); - } - - NamespaceInfo ni = (NamespaceInfo) namespaceStack.Peek (); - if (ni.NamespaceID == -1) - { - string[] usings = (string[]) ni.UsingClauses.ToArray (typeof(string)); - - int parentId = 0; - if (namespaceStack.Count > 1) { - namespaceStack.Pop (); - parentId = ((NamespaceInfo) namespaceStack.Peek ()).NamespaceID; - namespaceStack.Push (ni); - } - - ni.NamespaceID = msw.DefineNamespace (ni.Name, ((ICompileUnit)doc).Entry, usings, parentId); - } - return ni.NamespaceID; - } - - } - - class SymbolDocumentWriterImpl: ISymbolDocumentWriter, ISourceFile, ICompileUnit - { - CompileUnitEntry comp_unit; - - public SymbolDocumentWriterImpl (CompileUnitEntry comp_unit) - { - this.comp_unit = comp_unit; - } - - public void SetCheckSum (Guid algorithmId, byte[] checkSum) - { - } - - public void SetSource (byte[] source) - { - } - - SourceFileEntry ISourceFile.Entry { - get { return comp_unit.SourceFile; } - } - - public CompileUnitEntry Entry { - get { return comp_unit; } - } - } - - class SourceMethodImpl: IMethodDef - { - string name; - int token; - int namespaceID; - - public SourceMethodImpl (string name, int token, int namespaceID) - { - this.name = name; - this.token = token; - this.namespaceID = namespaceID; - } - - public string Name { - get { return name; } - } - - public int NamespaceID { - get { return namespaceID; } - } - - public int Token { - get { return token; } - } - } - - class NamespaceInfo - { - public string Name; - public int NamespaceID; - public ArrayList UsingClauses = new ArrayList (); - } -} - -#endif diff --git a/external/linker/cecil/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj b/external/linker/cecil/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj deleted file mode 100644 index 9b899ed4dc..0000000000 --- a/external/linker/cecil/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - {AC71DF9C-99FA-4A63-990A-66C8010355A6} - Mono.Cecil.Mdb.Tests - Mono.Cecil.Mdb.Tests - - - - {D68133BD-1E63-496E-9EDE-4FBDBF77B486} - Mono.Cecil - - - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055} - Mono.Cecil.Tests - - - {8559DD7F-A16F-46D0-A05A-9139FAEBA8FD} - Mono.Cecil.Mdb - - - - - - - - - - - \ No newline at end of file diff --git a/external/linker/cecil/symbols/mdb/Test/Mono.Cecil.Tests/MdbTests.cs b/external/linker/cecil/symbols/mdb/Test/Mono.Cecil.Tests/MdbTests.cs deleted file mode 100644 index 2b58f7fbab..0000000000 --- a/external/linker/cecil/symbols/mdb/Test/Mono.Cecil.Tests/MdbTests.cs +++ /dev/null @@ -1,86 +0,0 @@ -#if !READ_ONLY -using Mono.Cecil.Mdb; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class MdbTests : BaseTestFixture { - - [Test] - public void MdbWithJustLineInfo () - { - TestModule ("hello.exe", module => { - var type = module.GetType ("Program"); - var main = type.GetMethod ("Main"); - - AssertCode (@" - .locals init (System.Int32 i) - .line 6,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs' - IL_0000: ldc.i4.0 - IL_0001: stloc.0 - .line 7,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs' - IL_0002: br IL_0013 - .line 8,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs' - IL_0007: ldarg.0 - IL_0008: ldloc.0 - IL_0009: ldelem.ref - IL_000a: call System.Void Program::Print(System.String) - .line 7,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs' - IL_000f: ldloc.0 - IL_0010: ldc.i4.1 - IL_0011: add - IL_0012: stloc.0 - IL_0013: ldloc.0 - IL_0014: ldarg.0 - IL_0015: ldlen - IL_0016: conv.i4 - IL_0017: blt IL_0007 - .line 10,-1:-1,-1 'C:\sources\cecil\symbols\Mono.Cecil.Mdb\Test\Resources\assemblies\hello.cs' - IL_001c: ldc.i4.0 - IL_001d: ret -", main); - }, symbolReaderProvider: typeof(MdbReaderProvider), symbolWriterProvider: typeof(MdbWriterProvider)); - } - - [Test] - public void RoundTripCoreLib () - { - TestModule ("mscorlib.dll", module => { - var type = module.GetType ("System.IO.__Error"); - var method = type.GetMethod ("WinIOError"); - - Assert.IsNotNull (method.Body); - }, verify: !Platform.OnMono, symbolReaderProvider: typeof(MdbReaderProvider), symbolWriterProvider: typeof(MdbWriterProvider)); - } - - [Test] - public void PartialClass () - { - TestModule ("BreakpointTest.Portable.dll", module => { - var type = module.GetType ("BreakpointTest.Portable.TestService/c__async3"); - var method = type.GetMethod ("MoveNext"); - - Assert.IsNotNull (method); - - var info = method.DebugInformation; - Assert.AreEqual (5, info.SequencePoints.Count); - foreach (var sp in info.SequencePoints) - Assert.AreEqual(@"C:\tmp\repropartial\BreakpointTest.Portable\TestService.Actions.cs", sp.Document.Url); - - type = module.GetType("BreakpointTest.Portable.TestService/c__async2"); - method = type.GetMethod("MoveNext"); - - Assert.IsNotNull(method); - - info = method.DebugInformation; - Assert.AreEqual(5, info.SequencePoints.Count); - foreach (var sp in info.SequencePoints) - Assert.AreEqual(@"C:\tmp\repropartial\BreakpointTest.Portable\TestService.cs", sp.Document.Url); - - }, symbolReaderProvider: typeof(MdbReaderProvider), symbolWriterProvider: typeof(MdbWriterProvider)); - } - } -} -#endif \ No newline at end of file diff --git a/external/linker/cecil/symbols/mdb/Test/Resources/assemblies/BreakpointTest.Portable.dll.mdb b/external/linker/cecil/symbols/mdb/Test/Resources/assemblies/BreakpointTest.Portable.dll.mdb deleted file mode 100644 index 555f3e8db3..0000000000 Binary files a/external/linker/cecil/symbols/mdb/Test/Resources/assemblies/BreakpointTest.Portable.dll.mdb and /dev/null differ diff --git a/external/linker/cecil/symbols/mdb/Test/Resources/assemblies/hello.exe.mdb b/external/linker/cecil/symbols/mdb/Test/Resources/assemblies/hello.exe.mdb deleted file mode 100644 index f57f165618..0000000000 Binary files a/external/linker/cecil/symbols/mdb/Test/Resources/assemblies/hello.exe.mdb and /dev/null differ diff --git a/external/linker/cecil/symbols/mdb/Test/Resources/assemblies/mscorlib.dll.mdb.REMOVED.git-id b/external/linker/cecil/symbols/mdb/Test/Resources/assemblies/mscorlib.dll.mdb.REMOVED.git-id deleted file mode 100644 index 1c0148ca1c..0000000000 --- a/external/linker/cecil/symbols/mdb/Test/Resources/assemblies/mscorlib.dll.mdb.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -f997a8c39889b310ac6995842263f24ef6d94396 \ No newline at end of file diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/.editorconfig b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/.editorconfig deleted file mode 100644 index d1a80c6d80..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/.editorconfig +++ /dev/null @@ -1,3 +0,0 @@ -[*.cs] -indent_style = space -indent_size = 2 diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs deleted file mode 100644 index d92a5b7491..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitAccess.cs +++ /dev/null @@ -1,255 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; -using System.IO; -using System.Text; - -namespace Microsoft.Cci.Pdb { - internal class BitAccess { - - internal BitAccess(int capacity) { - this.buffer = new byte[capacity]; - } - - internal byte[] Buffer { - get { return buffer; } - } - private byte[] buffer; - - internal void FillBuffer(Stream stream, int capacity) { - MinCapacity(capacity); - stream.Read(buffer, 0, capacity); - offset = 0; - } - - internal void Append(Stream stream, int count) { - int newCapacity = offset + count; - if (buffer.Length < newCapacity) { - byte[] newBuffer = new byte[newCapacity]; - Array.Copy(buffer, newBuffer, buffer.Length); - buffer = newBuffer; - } - stream.Read(buffer, offset, count); - offset += count; - } - - internal int Position { - get { return offset; } - set { offset = value; } - } - private int offset; - - //internal void WriteBuffer(Stream stream, int count) { - // stream.Write(buffer, 0, count); - //} - - internal void MinCapacity(int capacity) { - if (buffer.Length < capacity) { - buffer = new byte[capacity]; - } - offset = 0; - } - - internal void Align(int alignment) { - while ((offset % alignment) != 0) { - offset++; - } - } - - //internal void WriteInt32(int value) { - // buffer[offset + 0] = (byte)value; - // buffer[offset + 1] = (byte)(value >> 8); - // buffer[offset + 2] = (byte)(value >> 16); - // buffer[offset + 3] = (byte)(value >> 24); - // offset += 4; - //} - - //internal void WriteInt32(int[] values) { - // for (int i = 0; i < values.Length; i++) { - // WriteInt32(values[i]); - // } - //} - - //internal void WriteBytes(byte[] bytes) { - // for (int i = 0; i < bytes.Length; i++) { - // buffer[offset++] = bytes[i]; - // } - //} - - internal void ReadInt16(out short value) { - value = (short)((buffer[offset + 0] & 0xFF) | - (buffer[offset + 1] << 8)); - offset += 2; - } - - internal void ReadInt8(out sbyte value) { - value = (sbyte)buffer[offset]; - offset += 1; - } - - internal void ReadInt32(out int value) { - value = (int)((buffer[offset + 0] & 0xFF) | - (buffer[offset + 1] << 8) | - (buffer[offset + 2] << 16) | - (buffer[offset + 3] << 24)); - offset += 4; - } - - internal void ReadInt64(out long value) { - value = (long)(((ulong)buffer[offset + 0] & 0xFF) | - ((ulong)buffer[offset + 1] << 8) | - ((ulong)buffer[offset + 2] << 16) | - ((ulong)buffer[offset + 3] << 24) | - ((ulong)buffer[offset + 4] << 32) | - ((ulong)buffer[offset + 5] << 40) | - ((ulong)buffer[offset + 6] << 48) | - ((ulong)buffer[offset + 7] << 56)); - offset += 8; - } - - internal void ReadUInt16(out ushort value) { - value = (ushort)((buffer[offset + 0] & 0xFF) | - (buffer[offset + 1] << 8)); - offset += 2; - } - - internal void ReadUInt8(out byte value) { - value = (byte)((buffer[offset + 0] & 0xFF)); - offset += 1; - } - - internal void ReadUInt32(out uint value) { - value = (uint)((buffer[offset + 0] & 0xFF) | - (buffer[offset + 1] << 8) | - (buffer[offset + 2] << 16) | - (buffer[offset + 3] << 24)); - offset += 4; - } - - internal void ReadUInt64(out ulong value) { - value = (ulong)(((ulong)buffer[offset + 0] & 0xFF) | - ((ulong)buffer[offset + 1] << 8) | - ((ulong)buffer[offset + 2] << 16) | - ((ulong)buffer[offset + 3] << 24) | - ((ulong)buffer[offset + 4] << 32) | - ((ulong)buffer[offset + 5] << 40) | - ((ulong)buffer[offset + 6] << 48) | - ((ulong)buffer[offset + 7] << 56)); - offset += 8; - } - - internal void ReadInt32(int[] values) { - for (int i = 0; i < values.Length; i++) { - ReadInt32(out values[i]); - } - } - - internal void ReadUInt32(uint[] values) { - for (int i = 0; i < values.Length; i++) { - ReadUInt32(out values[i]); - } - } - - internal void ReadBytes(byte[] bytes) { - for (int i = 0; i < bytes.Length; i++) { - bytes[i] = buffer[offset++]; - } - } - - internal float ReadFloat() { - float result = BitConverter.ToSingle(buffer, offset); - offset += 4; - return result; - } - - internal double ReadDouble() { - double result = BitConverter.ToDouble(buffer, offset); - offset += 8; - return result; - } - - internal decimal ReadDecimal() { - int[] bits = new int[4]; - this.ReadInt32(bits); - return new decimal(bits[2], bits[3], bits[1], bits[0] < 0, (byte)((bits[0] & 0x00FF0000) >> 16)); - } - - internal void ReadBString(out string value) { - ushort len; - this.ReadUInt16(out len); - value = Encoding.UTF8.GetString(buffer, offset, len); - offset += len; - } - - internal string ReadBString(int len) { - var result = Encoding.UTF8.GetString(buffer, offset, len); - offset += len; - return result; - } - - internal void ReadCString(out string value) { - int len = 0; - while (offset + len < buffer.Length && buffer[offset + len] != 0) { - len++; - } - value = Encoding.UTF8.GetString(buffer, offset, len); - offset += len + 1; - } - - internal void SkipCString(out string value) { - int len = 0; - while (offset + len < buffer.Length && buffer[offset + len] != 0) { - len++; - } - offset += len + 1; - value= null; - } - - internal void ReadGuid(out Guid guid) { - uint a; - ushort b; - ushort c; - byte d; - byte e; - byte f; - byte g; - byte h; - byte i; - byte j; - byte k; - - ReadUInt32(out a); - ReadUInt16(out b); - ReadUInt16(out c); - ReadUInt8(out d); - ReadUInt8(out e); - ReadUInt8(out f); - ReadUInt8(out g); - ReadUInt8(out h); - ReadUInt8(out i); - ReadUInt8(out j); - ReadUInt8(out k); - - guid = new Guid(a, b, c, d, e, f, g, h, i, j, k); - } - - internal string ReadString() { - int len = 0; - while (offset + len < buffer.Length && buffer[offset + len] != 0) { - len+=2; - } - string result = Encoding.Unicode.GetString(buffer, offset, len); - offset += len + 2; - return result; - } - - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs deleted file mode 100644 index 6719131719..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs +++ /dev/null @@ -1,74 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; - -namespace Microsoft.Cci.Pdb { - internal struct BitSet { - internal BitSet(BitAccess bits) { - bits.ReadInt32(out size); // 0..3 : Number of words - words = new uint[size]; - bits.ReadUInt32(words); - } - - //internal BitSet(int size) { - // this.size = size; - // words = new uint[size]; - //} - - internal bool IsSet(int index) { - int word = index / 32; - if (word >= this.size) return false; - return ((words[word] & GetBit(index)) != 0); - } - - //internal void Set(int index) { - // int word = index / 32; - // if (word >= this.size) return; - // words[word] |= GetBit(index); - //} - - //internal void Clear(int index) { - // int word = index / 32; - // if (word >= this.size) return; - // words[word] &= ~GetBit(index); - //} - - private static uint GetBit(int index) { - return ((uint)1 << (index % 32)); - } - - //private static uint ReverseBits(uint value) { - // uint o = 0; - // for (int i = 0; i < 32; i++) { - // o = (o << 1) | (value & 1); - // value >>= 1; - // } - // return o; - //} - - internal bool IsEmpty { - get { return size == 0; } - } - - //internal bool GetWord(int index, out uint word) { - // if (index < size) { - // word = ReverseBits(words[index]); - // return true; - // } - // word = 0; - // return false; - //} - - private int size; - private uint[] words; - } - -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs deleted file mode 100644 index 49c51ce1a0..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs +++ /dev/null @@ -1,2435 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -// -// File: CvInfo.cs -// -// Generic CodeView information definitions -// -// Structures, constants, etc. for accessing and interpreting -// CodeView information. -// -// The master copy of this file resides in the langapi project (in C++). -// All Microsoft projects are required to use the master copy without -// modification. Modification of the master version or a copy -// without consultation with all parties concerned is extremely -// risky. -// -// When this file is modified, the corresponding documentation file -// omfdeb.doc in the langapi project must be updated. -// -// This is a read-only copy of the C++ file converted to C#. -// -using System; - -namespace Microsoft.Cci.Pdb { - internal struct FLOAT10 { - internal byte Data_0; - internal byte Data_1; - internal byte Data_2; - internal byte Data_3; - internal byte Data_4; - internal byte Data_5; - internal byte Data_6; - internal byte Data_7; - internal byte Data_8; - internal byte Data_9; - }; - - internal enum CV_SIGNATURE { - C6=0, // Actual signature is >64K - C7=1, // First explicit signature - C11=2, // C11 (vc5.x) 32-bit types - C13=4, // C13 (vc7.x) zero terminated names - RESERVERD=5, // All signatures from 5 to 64K are reserved - }; - - // CodeView Symbol and Type OMF type information is broken up into two - // ranges. Type indices less than 0x1000 describe type information - // that is frequently used. Type indices above 0x1000 are used to - // describe more complex features such as functions, arrays and - // structures. - // - - // Primitive types have predefined meaning that is encoded in the - // values of the various bit fields in the value. - // - // A CodeView primitive type is defined as: - // - // 1 1 - // 1 089 7654 3 210 - // r mode type r sub - // - // Where - // mode is the pointer mode - // type is a type indicator - // sub is a subtype enumeration - // r is a reserved field - // - // See Microsoft Symbol and Type OMF (Version 4.0) for more - // information. - // - - // pointer mode enumeration values - - internal enum CV_prmode { - CV_TM_DIRECT=0, // mode is not a pointer - CV_TM_NPTR32=4, // mode is a 32 bit near pointer - CV_TM_NPTR64=6, // mode is a 64 bit near pointer - CV_TM_NPTR128=7, // mode is a 128 bit near pointer - }; - - // type enumeration values - - internal enum CV_type { - CV_SPECIAL=0x00, // special type size values - CV_SIGNED=0x01, // signed integral size values - CV_UNSIGNED=0x02, // unsigned integral size values - CV_BOOLEAN=0x03, // Boolean size values - CV_REAL=0x04, // real number size values - CV_COMPLEX=0x05, // complex number size values - CV_SPECIAL2=0x06, // second set of special types - CV_INT=0x07, // integral (int) values - CV_CVRESERVED=0x0f, - }; - - // subtype enumeration values for CV_SPECIAL - - internal enum CV_special { - CV_SP_NOTYPE=0x00, - CV_SP_ABS=0x01, - CV_SP_SEGMENT=0x02, - CV_SP_VOID=0x03, - CV_SP_CURRENCY=0x04, - CV_SP_NBASICSTR=0x05, - CV_SP_FBASICSTR=0x06, - CV_SP_NOTTRANS=0x07, - CV_SP_HRESULT=0x08, - }; - - // subtype enumeration values for CV_SPECIAL2 - - internal enum CV_special2 { - CV_S2_BIT=0x00, - CV_S2_PASCHAR=0x01, // Pascal CHAR - }; - - // subtype enumeration values for CV_SIGNED, CV_UNSIGNED and CV_BOOLEAN - - internal enum CV_integral { - CV_IN_1BYTE=0x00, - CV_IN_2BYTE=0x01, - CV_IN_4BYTE=0x02, - CV_IN_8BYTE=0x03, - CV_IN_16BYTE=0x04, - }; - - // subtype enumeration values for CV_REAL and CV_COMPLEX - - internal enum CV_real { - CV_RC_REAL32=0x00, - CV_RC_REAL64=0x01, - CV_RC_REAL80=0x02, - CV_RC_REAL128=0x03, - }; - - // subtype enumeration values for CV_INT (really int) - - internal enum CV_int { - CV_RI_CHAR=0x00, - CV_RI_INT1=0x00, - CV_RI_WCHAR=0x01, - CV_RI_UINT1=0x01, - CV_RI_INT2=0x02, - CV_RI_UINT2=0x03, - CV_RI_INT4=0x04, - CV_RI_UINT4=0x05, - CV_RI_INT8=0x06, - CV_RI_UINT8=0x07, - CV_RI_INT16=0x08, - CV_RI_UINT16=0x09, - }; - - internal struct CV_PRIMITIVE_TYPE { - const uint CV_MMASK = 0x700; // mode mask - const uint CV_TMASK = 0x0f0; // type mask - const uint CV_SMASK = 0x00f; // subtype mask - - const int CV_MSHIFT = 8; // primitive mode right shift count - const int CV_TSHIFT = 4; // primitive type right shift count - const int CV_SSHIFT = 0; // primitive subtype right shift count - - // function to extract primitive mode, type and size - - //internal static CV_prmode CV_MODE(TYPE_ENUM typ) { - // return (CV_prmode)((((uint)typ) & CV_MMASK) >> CV_MSHIFT); - //} - - //internal static CV_type CV_TYPE(TYPE_ENUM typ) { - // return (CV_type)((((uint)typ) & CV_TMASK) >> CV_TSHIFT); - //} - - //internal static uint CV_SUBT(TYPE_ENUM typ) { - // return ((((uint)typ) & CV_SMASK) >> CV_SSHIFT); - //} - - // functions to check the type of a primitive - - //internal static bool CV_TYP_IS_DIRECT(TYPE_ENUM typ) { - // return (CV_MODE(typ) == CV_prmode.CV_TM_DIRECT); - //} - - //internal static bool CV_TYP_IS_PTR(TYPE_ENUM typ) { - // return (CV_MODE(typ) != CV_prmode.CV_TM_DIRECT); - //} - - //internal static bool CV_TYP_IS_SIGNED(TYPE_ENUM typ) { - // return - // (((CV_TYPE(typ) == CV_type.CV_SIGNED) && CV_TYP_IS_DIRECT(typ)) || - // (typ == TYPE_ENUM.T_INT1) || - // (typ == TYPE_ENUM.T_INT2) || - // (typ == TYPE_ENUM.T_INT4) || - // (typ == TYPE_ENUM.T_INT8) || - // (typ == TYPE_ENUM.T_INT16) || - // (typ == TYPE_ENUM.T_RCHAR)); - //} - - //internal static bool CV_TYP_IS_UNSIGNED(TYPE_ENUM typ) { - // return (((CV_TYPE(typ) == CV_type.CV_UNSIGNED) && CV_TYP_IS_DIRECT(typ)) || - // (typ == TYPE_ENUM.T_UINT1) || - // (typ == TYPE_ENUM.T_UINT2) || - // (typ == TYPE_ENUM.T_UINT4) || - // (typ == TYPE_ENUM.T_UINT8) || - // (typ == TYPE_ENUM.T_UINT16)); - //} - - //internal static bool CV_TYP_IS_REAL(TYPE_ENUM typ) { - // return ((CV_TYPE(typ) == CV_type.CV_REAL) && CV_TYP_IS_DIRECT(typ)); - //} - - const uint CV_FIRST_NONPRIM = 0x1000; - - //internal static bool CV_IS_PRIMITIVE(TYPE_ENUM typ) { - // return ((uint)(typ) < CV_FIRST_NONPRIM); - //} - - //internal static bool CV_TYP_IS_COMPLEX(TYPE_ENUM typ) { - // return ((CV_TYPE(typ) == CV_type.CV_COMPLEX) && CV_TYP_IS_DIRECT(typ)); - //} - - //internal static bool CV_IS_INTERNAL_PTR(TYPE_ENUM typ) { - // return (CV_IS_PRIMITIVE(typ) && - // CV_TYPE(typ) == CV_type.CV_CVRESERVED && - // CV_TYP_IS_PTR(typ)); - //} - } - - // selected values for type_index - for a more complete definition, see - // Microsoft Symbol and Type OMF document - - // Special Types - - internal enum TYPE_ENUM { - // Special Types - - T_NOTYPE=0x0000, // uncharacterized type (no type) - T_ABS=0x0001, // absolute symbol - T_SEGMENT=0x0002, // segment type - T_VOID=0x0003, // void - T_HRESULT=0x0008, // OLE/COM HRESULT - T_32PHRESULT=0x0408, // OLE/COM HRESULT __ptr32// - T_64PHRESULT=0x0608, // OLE/COM HRESULT __ptr64// - T_PVOID=0x0103, // near pointer to void - T_PFVOID=0x0203, // far pointer to void - T_PHVOID=0x0303, // huge pointer to void - T_32PVOID=0x0403, // 32 bit pointer to void - T_64PVOID=0x0603, // 64 bit pointer to void - T_CURRENCY=0x0004, // BASIC 8 byte currency value - T_NOTTRANS=0x0007, // type not translated by cvpack - T_BIT=0x0060, // bit - T_PASCHAR=0x0061, // Pascal CHAR - - // Character types - - T_CHAR=0x0010, // 8 bit signed - T_32PCHAR=0x0410, // 32 bit pointer to 8 bit signed - T_64PCHAR=0x0610, // 64 bit pointer to 8 bit signed - - T_UCHAR=0x0020, // 8 bit unsigned - T_32PUCHAR=0x0420, // 32 bit pointer to 8 bit unsigned - T_64PUCHAR=0x0620, // 64 bit pointer to 8 bit unsigned - - // really a character types - - T_RCHAR=0x0070, // really a char - T_32PRCHAR=0x0470, // 32 bit pointer to a real char - T_64PRCHAR=0x0670, // 64 bit pointer to a real char - - // really a wide character types - - T_WCHAR=0x0071, // wide char - T_32PWCHAR=0x0471, // 32 bit pointer to a wide char - T_64PWCHAR=0x0671, // 64 bit pointer to a wide char - - // 8 bit int types - - T_INT1=0x0068, // 8 bit signed int - T_32PINT1=0x0468, // 32 bit pointer to 8 bit signed int - T_64PINT1=0x0668, // 64 bit pointer to 8 bit signed int - - T_UINT1=0x0069, // 8 bit unsigned int - T_32PUINT1=0x0469, // 32 bit pointer to 8 bit unsigned int - T_64PUINT1=0x0669, // 64 bit pointer to 8 bit unsigned int - - // 16 bit short types - - T_SHORT=0x0011, // 16 bit signed - T_32PSHORT=0x0411, // 32 bit pointer to 16 bit signed - T_64PSHORT=0x0611, // 64 bit pointer to 16 bit signed - - T_USHORT=0x0021, // 16 bit unsigned - T_32PUSHORT=0x0421, // 32 bit pointer to 16 bit unsigned - T_64PUSHORT=0x0621, // 64 bit pointer to 16 bit unsigned - - // 16 bit int types - - T_INT2=0x0072, // 16 bit signed int - T_32PINT2=0x0472, // 32 bit pointer to 16 bit signed int - T_64PINT2=0x0672, // 64 bit pointer to 16 bit signed int - - T_UINT2=0x0073, // 16 bit unsigned int - T_32PUINT2=0x0473, // 32 bit pointer to 16 bit unsigned int - T_64PUINT2=0x0673, // 64 bit pointer to 16 bit unsigned int - - // 32 bit long types - - T_LONG=0x0012, // 32 bit signed - T_ULONG=0x0022, // 32 bit unsigned - T_32PLONG=0x0412, // 32 bit pointer to 32 bit signed - T_32PULONG=0x0422, // 32 bit pointer to 32 bit unsigned - T_64PLONG=0x0612, // 64 bit pointer to 32 bit signed - T_64PULONG=0x0622, // 64 bit pointer to 32 bit unsigned - - // 32 bit int types - - T_INT4=0x0074, // 32 bit signed int - T_32PINT4=0x0474, // 32 bit pointer to 32 bit signed int - T_64PINT4=0x0674, // 64 bit pointer to 32 bit signed int - - T_UINT4=0x0075, // 32 bit unsigned int - T_32PUINT4=0x0475, // 32 bit pointer to 32 bit unsigned int - T_64PUINT4=0x0675, // 64 bit pointer to 32 bit unsigned int - - // 64 bit quad types - - T_QUAD=0x0013, // 64 bit signed - T_32PQUAD=0x0413, // 32 bit pointer to 64 bit signed - T_64PQUAD=0x0613, // 64 bit pointer to 64 bit signed - - T_UQUAD=0x0023, // 64 bit unsigned - T_32PUQUAD=0x0423, // 32 bit pointer to 64 bit unsigned - T_64PUQUAD=0x0623, // 64 bit pointer to 64 bit unsigned - - // 64 bit int types - - T_INT8=0x0076, // 64 bit signed int - T_32PINT8=0x0476, // 32 bit pointer to 64 bit signed int - T_64PINT8=0x0676, // 64 bit pointer to 64 bit signed int - - T_UINT8=0x0077, // 64 bit unsigned int - T_32PUINT8=0x0477, // 32 bit pointer to 64 bit unsigned int - T_64PUINT8=0x0677, // 64 bit pointer to 64 bit unsigned int - - // 128 bit octet types - - T_OCT=0x0014, // 128 bit signed - T_32POCT=0x0414, // 32 bit pointer to 128 bit signed - T_64POCT=0x0614, // 64 bit pointer to 128 bit signed - - T_UOCT=0x0024, // 128 bit unsigned - T_32PUOCT=0x0424, // 32 bit pointer to 128 bit unsigned - T_64PUOCT=0x0624, // 64 bit pointer to 128 bit unsigned - - // 128 bit int types - - T_INT16=0x0078, // 128 bit signed int - T_32PINT16=0x0478, // 32 bit pointer to 128 bit signed int - T_64PINT16=0x0678, // 64 bit pointer to 128 bit signed int - - T_UINT16=0x0079, // 128 bit unsigned int - T_32PUINT16=0x0479, // 32 bit pointer to 128 bit unsigned int - T_64PUINT16=0x0679, // 64 bit pointer to 128 bit unsigned int - - // 32 bit real types - - T_REAL32=0x0040, // 32 bit real - T_32PREAL32=0x0440, // 32 bit pointer to 32 bit real - T_64PREAL32=0x0640, // 64 bit pointer to 32 bit real - - // 64 bit real types - - T_REAL64=0x0041, // 64 bit real - T_32PREAL64=0x0441, // 32 bit pointer to 64 bit real - T_64PREAL64=0x0641, // 64 bit pointer to 64 bit real - - // 80 bit real types - - T_REAL80=0x0042, // 80 bit real - T_32PREAL80=0x0442, // 32 bit pointer to 80 bit real - T_64PREAL80=0x0642, // 64 bit pointer to 80 bit real - - // 128 bit real types - - T_REAL128=0x0043, // 128 bit real - T_32PREAL128=0x0443, // 32 bit pointer to 128 bit real - T_64PREAL128=0x0643, // 64 bit pointer to 128 bit real - - // 32 bit complex types - - T_CPLX32=0x0050, // 32 bit complex - T_32PCPLX32=0x0450, // 32 bit pointer to 32 bit complex - T_64PCPLX32=0x0650, // 64 bit pointer to 32 bit complex - - // 64 bit complex types - - T_CPLX64=0x0051, // 64 bit complex - T_32PCPLX64=0x0451, // 32 bit pointer to 64 bit complex - T_64PCPLX64=0x0651, // 64 bit pointer to 64 bit complex - - // 80 bit complex types - - T_CPLX80=0x0052, // 80 bit complex - T_32PCPLX80=0x0452, // 32 bit pointer to 80 bit complex - T_64PCPLX80=0x0652, // 64 bit pointer to 80 bit complex - - // 128 bit complex types - - T_CPLX128=0x0053, // 128 bit complex - T_32PCPLX128=0x0453, // 32 bit pointer to 128 bit complex - T_64PCPLX128=0x0653, // 64 bit pointer to 128 bit complex - - // boolean types - - T_BOOL08=0x0030, // 8 bit boolean - T_32PBOOL08=0x0430, // 32 bit pointer to 8 bit boolean - T_64PBOOL08=0x0630, // 64 bit pointer to 8 bit boolean - - T_BOOL16=0x0031, // 16 bit boolean - T_32PBOOL16=0x0431, // 32 bit pointer to 18 bit boolean - T_64PBOOL16=0x0631, // 64 bit pointer to 18 bit boolean - - T_BOOL32=0x0032, // 32 bit boolean - T_32PBOOL32=0x0432, // 32 bit pointer to 32 bit boolean - T_64PBOOL32=0x0632, // 64 bit pointer to 32 bit boolean - - T_BOOL64=0x0033, // 64 bit boolean - T_32PBOOL64=0x0433, // 32 bit pointer to 64 bit boolean - T_64PBOOL64=0x0633, // 64 bit pointer to 64 bit boolean - }; - - // No leaf index can have a value of 0x0000. The leaf indices are - // separated into ranges depending upon the use of the type record. - // The second range is for the type records that are directly referenced - // in symbols. The first range is for type records that are not - // referenced by symbols but instead are referenced by other type - // records. All type records must have a starting leaf index in these - // first two ranges. The third range of leaf indices are used to build - // up complex lists such as the field list of a class type record. No - // type record can begin with one of the leaf indices. The fourth ranges - // of type indices are used to represent numeric data in a symbol or - // type record. These leaf indices are greater than 0x8000. At the - // point that type or symbol processor is expecting a numeric field, the - // next two bytes in the type record are examined. If the value is less - // than 0x8000, then the two bytes contain the numeric value. If the - // value is greater than 0x8000, then the data follows the leaf index in - // a format specified by the leaf index. The final range of leaf indices - // are used to force alignment of subfields within a complex type record.. - // - - internal enum LEAF { - // leaf indices starting records but referenced from symbol records - - LF_VTSHAPE=0x000a, - LF_COBOL1=0x000c, - LF_LABEL=0x000e, - LF_NULL=0x000f, - LF_NOTTRAN=0x0010, - LF_ENDPRECOMP=0x0014, // not referenced from symbol - LF_TYPESERVER_ST=0x0016, // not referenced from symbol - - // leaf indices starting records but referenced only from type records - - LF_LIST=0x0203, - LF_REFSYM=0x020c, - - LF_ENUMERATE_ST=0x0403, - - // 32-bit type index versions of leaves, all have the 0x1000 bit set - // - LF_TI16_MAX=0x1000, - - LF_MODIFIER=0x1001, - LF_POINTER=0x1002, - LF_ARRAY_ST=0x1003, - LF_CLASS_ST=0x1004, - LF_STRUCTURE_ST=0x1005, - LF_UNION_ST=0x1006, - LF_ENUM_ST=0x1007, - LF_PROCEDURE=0x1008, - LF_MFUNCTION=0x1009, - LF_COBOL0=0x100a, - LF_BARRAY=0x100b, - LF_DIMARRAY_ST=0x100c, - LF_VFTPATH=0x100d, - LF_PRECOMP_ST=0x100e, // not referenced from symbol - LF_OEM=0x100f, // oem definable type string - LF_ALIAS_ST=0x1010, // alias (typedef) type - LF_OEM2=0x1011, // oem definable type string - - // leaf indices starting records but referenced only from type records - - LF_SKIP=0x1200, - LF_ARGLIST=0x1201, - LF_DEFARG_ST=0x1202, - LF_FIELDLIST=0x1203, - LF_DERIVED=0x1204, - LF_BITFIELD=0x1205, - LF_METHODLIST=0x1206, - LF_DIMCONU=0x1207, - LF_DIMCONLU=0x1208, - LF_DIMVARU=0x1209, - LF_DIMVARLU=0x120a, - - LF_BCLASS=0x1400, - LF_VBCLASS=0x1401, - LF_IVBCLASS=0x1402, - LF_FRIENDFCN_ST=0x1403, - LF_INDEX=0x1404, - LF_MEMBER_ST=0x1405, - LF_STMEMBER_ST=0x1406, - LF_METHOD_ST=0x1407, - LF_NESTTYPE_ST=0x1408, - LF_VFUNCTAB=0x1409, - LF_FRIENDCLS=0x140a, - LF_ONEMETHOD_ST=0x140b, - LF_VFUNCOFF=0x140c, - LF_NESTTYPEEX_ST=0x140d, - LF_MEMBERMODIFY_ST=0x140e, - LF_MANAGED_ST=0x140f, - - // Types w/ SZ names - - LF_ST_MAX=0x1500, - - LF_TYPESERVER=0x1501, // not referenced from symbol - LF_ENUMERATE=0x1502, - LF_ARRAY=0x1503, - LF_CLASS=0x1504, - LF_STRUCTURE=0x1505, - LF_UNION=0x1506, - LF_ENUM=0x1507, - LF_DIMARRAY=0x1508, - LF_PRECOMP=0x1509, // not referenced from symbol - LF_ALIAS=0x150a, // alias (typedef) type - LF_DEFARG=0x150b, - LF_FRIENDFCN=0x150c, - LF_MEMBER=0x150d, - LF_STMEMBER=0x150e, - LF_METHOD=0x150f, - LF_NESTTYPE=0x1510, - LF_ONEMETHOD=0x1511, - LF_NESTTYPEEX=0x1512, - LF_MEMBERMODIFY=0x1513, - LF_MANAGED=0x1514, - LF_TYPESERVER2=0x1515, - - LF_NUMERIC=0x8000, - LF_CHAR=0x8000, - LF_SHORT=0x8001, - LF_USHORT=0x8002, - LF_LONG=0x8003, - LF_ULONG=0x8004, - LF_REAL32=0x8005, - LF_REAL64=0x8006, - LF_REAL80=0x8007, - LF_REAL128=0x8008, - LF_QUADWORD=0x8009, - LF_UQUADWORD=0x800a, - LF_COMPLEX32=0x800c, - LF_COMPLEX64=0x800d, - LF_COMPLEX80=0x800e, - LF_COMPLEX128=0x800f, - LF_VARSTRING=0x8010, - - LF_OCTWORD=0x8017, - LF_UOCTWORD=0x8018, - - LF_DECIMAL=0x8019, - LF_DATE=0x801a, - LF_UTF8STRING=0x801b, - - LF_PAD0=0xf0, - LF_PAD1=0xf1, - LF_PAD2=0xf2, - LF_PAD3=0xf3, - LF_PAD4=0xf4, - LF_PAD5=0xf5, - LF_PAD6=0xf6, - LF_PAD7=0xf7, - LF_PAD8=0xf8, - LF_PAD9=0xf9, - LF_PAD10=0xfa, - LF_PAD11=0xfb, - LF_PAD12=0xfc, - LF_PAD13=0xfd, - LF_PAD14=0xfe, - LF_PAD15=0xff, - - }; - - // end of leaf indices - - // Type enum for pointer records - // Pointers can be one of the following types - - internal enum CV_ptrtype { - CV_PTR_BASE_SEG=0x03, // based on segment - CV_PTR_BASE_VAL=0x04, // based on value of base - CV_PTR_BASE_SEGVAL=0x05, // based on segment value of base - CV_PTR_BASE_ADDR=0x06, // based on address of base - CV_PTR_BASE_SEGADDR=0x07, // based on segment address of base - CV_PTR_BASE_TYPE=0x08, // based on type - CV_PTR_BASE_SELF=0x09, // based on self - CV_PTR_NEAR32=0x0a, // 32 bit pointer - CV_PTR_64=0x0c, // 64 bit pointer - CV_PTR_UNUSEDPTR=0x0d // first unused pointer type - }; - - // Mode enum for pointers - // Pointers can have one of the following modes - - internal enum CV_ptrmode { - CV_PTR_MODE_PTR=0x00, // "normal" pointer - CV_PTR_MODE_REF=0x01, // reference - CV_PTR_MODE_PMEM=0x02, // pointer to data member - CV_PTR_MODE_PMFUNC=0x03, // pointer to member function - CV_PTR_MODE_RESERVED=0x04 // first unused pointer mode - }; - - // enumeration for pointer-to-member types - - internal enum CV_pmtype { - CV_PMTYPE_Undef=0x00, // not specified (pre VC8) - CV_PMTYPE_D_Single=0x01, // member data, single inheritance - CV_PMTYPE_D_Multiple=0x02, // member data, multiple inheritance - CV_PMTYPE_D_Virtual=0x03, // member data, virtual inheritance - CV_PMTYPE_D_General=0x04, // member data, most general - CV_PMTYPE_F_Single=0x05, // member function, single inheritance - CV_PMTYPE_F_Multiple=0x06, // member function, multiple inheritance - CV_PMTYPE_F_Virtual=0x07, // member function, virtual inheritance - CV_PMTYPE_F_General=0x08, // member function, most general - }; - - // enumeration for method properties - - internal enum CV_methodprop { - CV_MTvanilla=0x00, - CV_MTvirtual=0x01, - CV_MTstatic=0x02, - CV_MTfriend=0x03, - CV_MTintro=0x04, - CV_MTpurevirt=0x05, - CV_MTpureintro=0x06 - }; - - // enumeration for virtual shape table entries - - internal enum CV_VTS_desc { - CV_VTS_near=0x00, - CV_VTS_far=0x01, - CV_VTS_thin=0x02, - CV_VTS_outer=0x03, - CV_VTS_meta=0x04, - CV_VTS_near32=0x05, - CV_VTS_far32=0x06, - CV_VTS_unused=0x07 - }; - - // enumeration for LF_LABEL address modes - - internal enum CV_LABEL_TYPE { - CV_LABEL_NEAR=0, // near return - CV_LABEL_FAR=4 // far return - }; - - // enumeration for LF_MODIFIER values - - [Flags] - internal enum CV_modifier : ushort { - MOD_const=0x0001, - MOD_volatile=0x0002, - MOD_unaligned=0x0004, - }; - - // bit field structure describing class/struct/union/enum properties - - [Flags] - internal enum CV_prop : ushort { - packed=0x0001, // true if structure is packed - ctor=0x0002, // true if constructors or destructors present - ovlops=0x0004, // true if overloaded operators present - isnested=0x0008, // true if this is a nested class - cnested=0x0010, // true if this class contains nested types - opassign=0x0020, // true if overloaded assignment (=) - opcast=0x0040, // true if casting methods - fwdref=0x0080, // true if forward reference (incomplete defn) - scoped=0x0100, // scoped definition - } - - // class field attribute - - [Flags] - internal enum CV_fldattr { - access=0x0003, // access protection CV_access_t - mprop=0x001c, // method properties CV_methodprop_t - pseudo=0x0020, // compiler generated fcn and does not exist - noinherit=0x0040, // true if class cannot be inherited - noconstruct=0x0080, // true if class cannot be constructed - compgenx=0x0100, // compiler generated fcn and does exist - } - - // Structures to access to the type records - - internal struct TYPTYPE { - internal ushort len; - internal ushort leaf; - // byte data[]; - - // char *NextType (char * pType) { - // return (pType + ((TYPTYPE *)pType)->len + sizeof(ushort)); - // } - }; // general types record - - // memory representation of pointer to member. These representations are - // indexed by the enumeration above in the LF_POINTER record - - // representation of a 32 bit pointer to data for a class with - // or without virtual functions and no virtual bases - - internal struct CV_PDMR32_NVVFCN { - internal int mdisp; // displacement to data (NULL = 0x80000000) - }; - - // representation of a 32 bit pointer to data for a class - // with virtual bases - - internal struct CV_PDMR32_VBASE { - internal int mdisp; // displacement to data - internal int pdisp; // this pointer displacement - internal int vdisp; // vbase table displacement - // NULL = (,,0xffffffff) - }; - - // representation of a 32 bit pointer to member function for a - // class with no virtual bases and a single address point - - internal struct CV_PMFR32_NVSA { - internal uint off; // near address of function (NULL = 0L) - }; - - // representation of a 32 bit pointer to member function for a - // class with no virtual bases and multiple address points - - internal struct CV_PMFR32_NVMA { - internal uint off; // near address of function (NULL = 0L,x) - internal int disp; - }; - - // representation of a 32 bit pointer to member function for a - // class with virtual bases - - internal struct CV_PMFR32_VBASE { - internal uint off; // near address of function (NULL = 0L,x,x,x) - internal int mdisp; // displacement to data - internal int pdisp; // this pointer displacement - internal int vdisp; // vbase table displacement - }; - - ////////////////////////////////////////////////////////////////////////////// - // - // The following type records are basically variant records of the - // above structure. The "ushort leaf" of the above structure and - // the "ushort leaf" of the following type definitions are the same - // symbol. - // - - // Notes on alignment - // Alignment of the fields in most of the type records is done on the - // basis of the TYPTYPE record base. That is why in most of the lf* - // records that the type is located on what appears to - // be a offset mod 4 == 2 boundary. The exception to this rule are those - // records that are in a list (lfFieldList, lfMethodList), which are - // aligned to their own bases since they don't have the length field - // - - // Type record for LF_MODIFIER - - internal struct LeafModifier { - // internal ushort leaf; // LF_MODIFIER [TYPTYPE] - internal uint type; // (type index) modified type - internal CV_modifier attr; // modifier attribute modifier_t - }; - - // type record for LF_POINTER - - [Flags] - internal enum LeafPointerAttr : uint { - ptrtype=0x0000001f, // ordinal specifying pointer type (CV_ptrtype) - ptrmode=0x000000e0, // ordinal specifying pointer mode (CV_ptrmode) - isflat32=0x00000100, // true if 0:32 pointer - isvolatile=0x00000200, // TRUE if volatile pointer - isconst=0x00000400, // TRUE if const pointer - isunaligned=0x00000800, // TRUE if unaligned pointer - isrestrict=0x00001000, // TRUE if restricted pointer (allow agressive opts) - }; - - internal struct LeafPointer { - internal struct LeafPointerBody { - // internal ushort leaf; // LF_POINTER [TYPTYPE] - internal uint utype; // (type index) type index of the underlying type - internal LeafPointerAttr attr; - }; -#if false - union { - internal struct { - uint pmclass; // (type index) index of containing class for pointer to member - ushort pmenum; // enumeration specifying pm format (CV_pmtype) - }; - ushort bseg; // base segment if PTR_BASE_SEG - byte[] Sym; // copy of base symbol record (including length) - internal struct { - uint index; // (type index) type index if CV_PTR_BASE_TYPE - string name; // name of base type - } btype; - } pbase; -#endif - } - - // type record for LF_ARRAY - - internal struct LeafArray { - // internal ushort leaf; // LF_ARRAY [TYPTYPE] - internal uint elemtype; // (type index) type index of element type - internal uint idxtype; // (type index) type index of indexing type - internal byte[] data; // variable length data specifying size in bytes - internal string name; - }; - - // type record for LF_CLASS, LF_STRUCTURE - - internal struct LeafClass { - // internal ushort leaf; // LF_CLASS, LF_STRUCT [TYPTYPE] - internal ushort count; // count of number of elements in class - internal ushort property; // (CV_prop_t) property attribute field (prop_t) - internal uint field; // (type index) type index of LF_FIELD descriptor list - internal uint derived; // (type index) type index of derived from list if not zero - internal uint vshape; // (type index) type index of vshape table for this class - internal byte[] data; // data describing length of structure in bytes - internal string name; - }; - - // type record for LF_UNION - - internal struct LeafUnion { - // internal ushort leaf; // LF_UNION [TYPTYPE] - internal ushort count; // count of number of elements in class - internal ushort property; // (CV_prop_t) property attribute field - internal uint field; // (type index) type index of LF_FIELD descriptor list - internal byte[] data; // variable length data describing length of - internal string name; - }; - - // type record for LF_ALIAS - - internal struct LeafAlias { - // internal ushort leaf; // LF_ALIAS [TYPTYPE] - internal uint utype; // (type index) underlying type - internal string name; // alias name - }; - - // type record for LF_MANAGED - - internal struct LeafManaged { - // internal ushort leaf; // LF_MANAGED [TYPTYPE] - internal string name; // utf8, zero terminated managed type name - }; - - // type record for LF_ENUM - - internal struct LeafEnum { - // internal ushort leaf; // LF_ENUM [TYPTYPE] - internal ushort count; // count of number of elements in class - internal ushort property; // (CV_propt_t) property attribute field - internal uint utype; // (type index) underlying type of the enum - internal uint field; // (type index) type index of LF_FIELD descriptor list - internal string name; // length prefixed name of enum - }; - - // Type record for LF_PROCEDURE - - internal struct LeafProc { - // internal ushort leaf; // LF_PROCEDURE [TYPTYPE] - internal uint rvtype; // (type index) type index of return value - internal byte calltype; // calling convention (CV_call_t) - internal byte reserved; // reserved for future use - internal ushort parmcount; // number of parameters - internal uint arglist; // (type index) type index of argument list - }; - - // Type record for member function - - internal struct LeafMFunc { - // internal ushort leaf; // LF_MFUNCTION [TYPTYPE] - internal uint rvtype; // (type index) type index of return value - internal uint classtype; // (type index) type index of containing class - internal uint thistype; // (type index) type index of this pointer (model specific) - internal byte calltype; // calling convention (call_t) - internal byte reserved; // reserved for future use - internal ushort parmcount; // number of parameters - internal uint arglist; // (type index) type index of argument list - internal int thisadjust; // this adjuster (long because pad required anyway) - }; - - // type record for virtual function table shape - - internal struct LeafVTShape { - // internal ushort leaf; // LF_VTSHAPE [TYPTYPE] - internal ushort count; // number of entries in vfunctable - internal byte[] desc; // 4 bit (CV_VTS_desc) descriptors - }; - - // type record for cobol0 - - internal struct LeafCobol0 { - // internal ushort leaf; // LF_COBOL0 [TYPTYPE] - internal uint type; // (type index) parent type record index - internal byte[] data; - }; - - // type record for cobol1 - - internal struct LeafCobol1 { - // internal ushort leaf; // LF_COBOL1 [TYPTYPE] - internal byte[] data; - }; - - // type record for basic array - - internal struct LeafBArray { - // internal ushort leaf; // LF_BARRAY [TYPTYPE] - internal uint utype; // (type index) type index of underlying type - }; - - // type record for assembler labels - - internal struct LeafLabel { - // internal ushort leaf; // LF_LABEL [TYPTYPE] - internal ushort mode; // addressing mode of label - }; - - // type record for dimensioned arrays - - internal struct LeafDimArray { - // internal ushort leaf; // LF_DIMARRAY [TYPTYPE] - internal uint utype; // (type index) underlying type of the array - internal uint diminfo; // (type index) dimension information - internal string name; // length prefixed name - }; - - // type record describing path to virtual function table - - internal struct LeafVFTPath { - // internal ushort leaf; // LF_VFTPATH [TYPTYPE] - internal uint count; // count of number of bases in path - internal uint[] bases; // (type index) bases from root to leaf - }; - - // type record describing inclusion of precompiled types - - internal struct LeafPreComp { - // internal ushort leaf; // LF_PRECOMP [TYPTYPE] - internal uint start; // starting type index included - internal uint count; // number of types in inclusion - internal uint signature; // signature - internal string name; // length prefixed name of included type file - }; - - // type record describing end of precompiled types that can be - // included by another file - - internal struct LeafEndPreComp { - // internal ushort leaf; // LF_ENDPRECOMP [TYPTYPE] - internal uint signature; // signature - }; - - // type record for OEM definable type strings - - internal struct LeafOEM { - // internal ushort leaf; // LF_OEM [TYPTYPE] - internal ushort cvOEM; // MS assigned OEM identified - internal ushort recOEM; // OEM assigned type identifier - internal uint count; // count of type indices to follow - internal uint[] index; // (type index) array of type indices followed - // by OEM defined data - }; - - internal enum OEM_ID { - OEM_MS_FORTRAN90=0xF090, - OEM_ODI=0x0010, - OEM_THOMSON_SOFTWARE=0x5453, - OEM_ODI_REC_BASELIST=0x0000, - }; - - internal struct LeafOEM2 { - // internal ushort leaf; // LF_OEM2 [TYPTYPE] - internal Guid idOem; // an oem ID (Guid) - internal uint count; // count of type indices to follow - internal uint[] index; // (type index) array of type indices followed - // by OEM defined data - }; - - // type record describing using of a type server - - internal struct LeafTypeServer { - // internal ushort leaf; // LF_TYPESERVER [TYPTYPE] - internal uint signature; // signature - internal uint age; // age of database used by this module - internal string name; // length prefixed name of PDB - }; - - // type record describing using of a type server with v7 (GUID) signatures - - internal struct LeafTypeServer2 { - // internal ushort leaf; // LF_TYPESERVER2 [TYPTYPE] - internal Guid sig70; // guid signature - internal uint age; // age of database used by this module - internal string name; // length prefixed name of PDB - }; - - // description of type records that can be referenced from - // type records referenced by symbols - - // type record for skip record - - internal struct LeafSkip { - // internal ushort leaf; // LF_SKIP [TYPTYPE] - internal uint type; // (type index) next valid index - internal byte[] data; // pad data - }; - - // argument list leaf - - internal struct LeafArgList { - // internal ushort leaf; // LF_ARGLIST [TYPTYPE] - internal uint count; // number of arguments - internal uint[] arg; // (type index) number of arguments - }; - - // derived class list leaf - - internal struct LeafDerived { - // internal ushort leaf; // LF_DERIVED [TYPTYPE] - internal uint count; // number of arguments - internal uint[] drvdcls; // (type index) type indices of derived classes - }; - - // leaf for default arguments - - internal struct LeafDefArg { - // internal ushort leaf; // LF_DEFARG [TYPTYPE] - internal uint type; // (type index) type of resulting expression - internal byte[] expr; // length prefixed expression string - }; - - // list leaf - // This list should no longer be used because the utilities cannot - // verify the contents of the list without knowing what type of list - // it is. New specific leaf indices should be used instead. - - internal struct LeafList { - // internal ushort leaf; // LF_LIST [TYPTYPE] - internal byte[] data; // data format specified by indexing type - }; - - // field list leaf - // This is the header leaf for a complex list of class and structure - // subfields. - - internal struct LeafFieldList { - // internal ushort leaf; // LF_FIELDLIST [TYPTYPE] - internal char[] data; // field list sub lists - }; - - // type record for non-static methods and friends in overloaded method list - - internal struct mlMethod { - internal ushort attr; // (CV_fldattr_t) method attribute - internal ushort pad0; // internal padding, must be 0 - internal uint index; // (type index) index to type record for procedure - internal uint[] vbaseoff; // offset in vfunctable if intro virtual - }; - - internal struct LeafMethodList { - // internal ushort leaf; // LF_METHODLIST [TYPTYPE] - internal byte[] mList; // really a mlMethod type - }; - - // type record for LF_BITFIELD - - internal struct LeafBitfield { - // internal ushort leaf; // LF_BITFIELD [TYPTYPE] - internal uint type; // (type index) type of bitfield - internal byte length; - internal byte position; - }; - - // type record for dimensioned array with constant bounds - - internal struct LeafDimCon { - // internal ushort leaf; // LF_DIMCONU or LF_DIMCONLU [TYPTYPE] - internal uint typ; // (type index) type of index - internal ushort rank; // number of dimensions - internal byte[] dim; // array of dimension information with - // either upper bounds or lower/upper bound - }; - - // type record for dimensioned array with variable bounds - - internal struct LeafDimVar { - // internal ushort leaf; // LF_DIMVARU or LF_DIMVARLU [TYPTYPE] - internal uint rank; // number of dimensions - internal uint typ; // (type index) type of index - internal uint[] dim; // (type index) array of type indices for either - // variable upper bound or variable - // lower/upper bound. The count of type - // indices is rank or rank*2 depending on - // whether it is LFDIMVARU or LF_DIMVARLU. - // The referenced types must be - // LF_REFSYM or T_VOID - }; - - // type record for referenced symbol - - internal struct LeafRefSym { - // internal ushort leaf; // LF_REFSYM [TYPTYPE] - internal byte[] Sym; // copy of referenced symbol record - // (including length) - }; - - // the following are numeric leaves. They are used to indicate the - // size of the following variable length data. When the numeric - // data is a single byte less than 0x8000, then the data is output - // directly. If the data is more the 0x8000 or is a negative value, - // then the data is preceeded by the proper index. - // - - // signed character leaf - - internal struct LeafChar { - // internal ushort leaf; // LF_CHAR [TYPTYPE] - internal sbyte val; // signed 8-bit value - }; - - // signed short leaf - - internal struct LeafShort { - // internal ushort leaf; // LF_SHORT [TYPTYPE] - internal short val; // signed 16-bit value - }; - - // ushort leaf - - internal struct LeafUShort { - // internal ushort leaf; // LF_ushort [TYPTYPE] - internal ushort val; // unsigned 16-bit value - }; - - // signed (32-bit) long leaf - - internal struct LeafLong { - // internal ushort leaf; // LF_LONG [TYPTYPE] - internal int val; // signed 32-bit value - }; - - // uint leaf - - internal struct LeafULong { - // internal ushort leaf; // LF_ULONG [TYPTYPE] - internal uint val; // unsigned 32-bit value - }; - - // signed quad leaf - - internal struct LeafQuad { - // internal ushort leaf; // LF_QUAD [TYPTYPE] - internal long val; // signed 64-bit value - }; - - // unsigned quad leaf - - internal struct LeafUQuad { - // internal ushort leaf; // LF_UQUAD [TYPTYPE] - internal ulong val; // unsigned 64-bit value - }; - - // signed int128 leaf - - internal struct LeafOct { - // internal ushort leaf; // LF_OCT [TYPTYPE] - internal ulong val0; - internal ulong val1; // signed 128-bit value - }; - - // unsigned int128 leaf - - internal struct LeafUOct { - // internal ushort leaf; // LF_UOCT [TYPTYPE] - internal ulong val0; - internal ulong val1; // unsigned 128-bit value - }; - - // real 32-bit leaf - - internal struct LeafReal32 { - // internal ushort leaf; // LF_REAL32 [TYPTYPE] - internal float val; // 32-bit real value - }; - - // real 64-bit leaf - - internal struct LeafReal64 { - // internal ushort leaf; // LF_REAL64 [TYPTYPE] - internal double val; // 64-bit real value - }; - - // real 80-bit leaf - - internal struct LeafReal80 { - // internal ushort leaf; // LF_REAL80 [TYPTYPE] - internal FLOAT10 val; // real 80-bit value - }; - - // real 128-bit leaf - - internal struct LeafReal128 { - // internal ushort leaf; // LF_REAL128 [TYPTYPE] - internal ulong val0; - internal ulong val1; // real 128-bit value - }; - - // complex 32-bit leaf - - internal struct LeafCmplx32 { - // internal ushort leaf; // LF_COMPLEX32 [TYPTYPE] - internal float val_real; // real component - internal float val_imag; // imaginary component - }; - - // complex 64-bit leaf - - internal struct LeafCmplx64 { - // internal ushort leaf; // LF_COMPLEX64 [TYPTYPE] - internal double val_real; // real component - internal double val_imag; // imaginary component - }; - - // complex 80-bit leaf - - internal struct LeafCmplx80 { - // internal ushort leaf; // LF_COMPLEX80 [TYPTYPE] - internal FLOAT10 val_real; // real component - internal FLOAT10 val_imag; // imaginary component - }; - - // complex 128-bit leaf - - internal struct LeafCmplx128 { - // internal ushort leaf; // LF_COMPLEX128 [TYPTYPE] - internal ulong val0_real; - internal ulong val1_real; // real component - internal ulong val0_imag; - internal ulong val1_imag; // imaginary component - }; - - // variable length numeric field - - internal struct LeafVarString { - // internal ushort leaf; // LF_VARSTRING [TYPTYPE] - internal ushort len; // length of value in bytes - internal byte[] value; // value - }; - - // index leaf - contains type index of another leaf - // a major use of this leaf is to allow the compilers to emit a - // long complex list (LF_FIELD) in smaller pieces. - - internal struct LeafIndex { - // internal ushort leaf; // LF_INDEX [TYPTYPE] - internal ushort pad0; // internal padding, must be 0 - internal uint index; // (type index) type index of referenced leaf - }; - - // subfield record for base class field - - internal struct LeafBClass { - // internal ushort leaf; // LF_BCLASS [TYPTYPE] - internal ushort attr; // (CV_fldattr_t) attribute - internal uint index; // (type index) type index of base class - internal byte[] offset; // variable length offset of base within class - }; - - // subfield record for direct and indirect virtual base class field - - internal struct LeafVBClass { - // internal ushort leaf; // LF_VBCLASS | LV_IVBCLASS [TYPTYPE] - internal ushort attr; // (CV_fldattr_t) attribute - internal uint index; // (type index) type index of direct virtual base class - internal uint vbptr; // (type index) type index of virtual base pointer - internal byte[] vbpoff; // virtual base pointer offset from address point - // followed by virtual base offset from vbtable - }; - - // subfield record for friend class - - internal struct LeafFriendCls { - // internal ushort leaf; // LF_FRIENDCLS [TYPTYPE] - internal ushort pad0; // internal padding, must be 0 - internal uint index; // (type index) index to type record of friend class - }; - - // subfield record for friend function - - internal struct LeafFriendFcn { - // internal ushort leaf; // LF_FRIENDFCN [TYPTYPE] - internal ushort pad0; // internal padding, must be 0 - internal uint index; // (type index) index to type record of friend function - internal string name; // name of friend function - }; - - // subfield record for non-static data members - - internal struct LeafMember { - // internal ushort leaf; // LF_MEMBER [TYPTYPE] - internal ushort attr; // (CV_fldattr_t)attribute mask - internal uint index; // (type index) index of type record for field - internal byte[] offset; // variable length offset of field - internal string name; // length prefixed name of field - }; - - // type record for static data members - - internal struct LeafSTMember { - // internal ushort leaf; // LF_STMEMBER [TYPTYPE] - internal ushort attr; // (CV_fldattr_t) attribute mask - internal uint index; // (type index) index of type record for field - internal string name; // length prefixed name of field - }; - - // subfield record for virtual function table pointer - - internal struct LeafVFuncTab { - // internal ushort leaf; // LF_VFUNCTAB [TYPTYPE] - internal ushort pad0; // internal padding, must be 0 - internal uint type; // (type index) type index of pointer - }; - - // subfield record for virtual function table pointer with offset - - internal struct LeafVFuncOff { - // internal ushort leaf; // LF_VFUNCOFF [TYPTYPE] - internal ushort pad0; // internal padding, must be 0. - internal uint type; // (type index) type index of pointer - internal int offset; // offset of virtual function table pointer - }; - - // subfield record for overloaded method list - - internal struct LeafMethod { - // internal ushort leaf; // LF_METHOD [TYPTYPE] - internal ushort count; // number of occurrences of function - internal uint mList; // (type index) index to LF_METHODLIST record - internal string name; // length prefixed name of method - }; - - // subfield record for nonoverloaded method - - internal struct LeafOneMethod { - // internal ushort leaf; // LF_ONEMETHOD [TYPTYPE] - internal ushort attr; // (CV_fldattr_t) method attribute - internal uint index; // (type index) index to type record for procedure - internal uint[] vbaseoff; // offset in vfunctable if intro virtual - internal string name; - }; - - // subfield record for enumerate - - internal struct LeafEnumerate { - // internal ushort leaf; // LF_ENUMERATE [TYPTYPE] - internal ushort attr; // (CV_fldattr_t) access - internal byte[] value; // variable length value field - internal string name; - }; - - // type record for nested (scoped) type definition - - internal struct LeafNestType { - // internal ushort leaf; // LF_NESTTYPE [TYPTYPE] - internal ushort pad0; // internal padding, must be 0 - internal uint index; // (type index) index of nested type definition - internal string name; // length prefixed type name - }; - - // type record for nested (scoped) type definition, with attributes - // new records for vC v5.0, no need to have 16-bit ti versions. - - internal struct LeafNestTypeEx { - // internal ushort leaf; // LF_NESTTYPEEX [TYPTYPE] - internal ushort attr; // (CV_fldattr_t) member access - internal uint index; // (type index) index of nested type definition - internal string name; // length prefixed type name - }; - - // type record for modifications to members - - internal struct LeafMemberModify { - // internal ushort leaf; // LF_MEMBERMODIFY [TYPTYPE] - internal ushort attr; // (CV_fldattr_t) the new attributes - internal uint index; // (type index) index of base class type definition - internal string name; // length prefixed member name - }; - - // type record for pad leaf - - internal struct LeafPad { - internal byte leaf; - }; - - // Symbol definitions - - internal enum SYM { - S_END=0x0006, // Block, procedure, "with" or thunk end - S_OEM=0x0404, // OEM defined symbol - - S_REGISTER_ST=0x1001, // Register variable - S_CONSTANT_ST=0x1002, // constant symbol - S_UDT_ST=0x1003, // User defined type - S_COBOLUDT_ST=0x1004, // special UDT for cobol that does not symbol pack - S_MANYREG_ST=0x1005, // multiple register variable - S_BPREL32_ST=0x1006, // BP-relative - S_LDATA32_ST=0x1007, // Module-local symbol - S_GDATA32_ST=0x1008, // Global data symbol - S_PUB32_ST=0x1009, // a internal symbol (CV internal reserved) - S_LPROC32_ST=0x100a, // Local procedure start - S_GPROC32_ST=0x100b, // Global procedure start - S_VFTABLE32=0x100c, // address of virtual function table - S_REGREL32_ST=0x100d, // register relative address - S_LTHREAD32_ST=0x100e, // local thread storage - S_GTHREAD32_ST=0x100f, // global thread storage - - S_LPROCMIPS_ST=0x1010, // Local procedure start - S_GPROCMIPS_ST=0x1011, // Global procedure start - - // new symbol records for edit and continue information - - S_FRAMEPROC=0x1012, // extra frame and proc information - S_COMPILE2_ST=0x1013, // extended compile flags and info - - // new symbols necessary for 16-bit enumerates of IA64 registers - // and IA64 specific symbols - - S_MANYREG2_ST=0x1014, // multiple register variable - S_LPROCIA64_ST=0x1015, // Local procedure start (IA64) - S_GPROCIA64_ST=0x1016, // Global procedure start (IA64) - - // Local symbols for IL - S_LOCALSLOT_ST=0x1017, // local IL sym with field for local slot index - S_PARAMSLOT_ST=0x1018, // local IL sym with field for parameter slot index - - S_ANNOTATION=0x1019, // Annotation string literals - - // symbols to support managed code debugging - S_GMANPROC_ST=0x101a, // Global proc - S_LMANPROC_ST=0x101b, // Local proc - S_RESERVED1=0x101c, // reserved - S_RESERVED2=0x101d, // reserved - S_RESERVED3=0x101e, // reserved - S_RESERVED4=0x101f, // reserved - S_LMANDATA_ST=0x1020, - S_GMANDATA_ST=0x1021, - S_MANFRAMEREL_ST=0x1022, - S_MANREGISTER_ST=0x1023, - S_MANSLOT_ST=0x1024, - S_MANMANYREG_ST=0x1025, - S_MANREGREL_ST=0x1026, - S_MANMANYREG2_ST=0x1027, - S_MANTYPREF=0x1028, // Index for type referenced by name from metadata - S_UNAMESPACE_ST=0x1029, // Using namespace - - // Symbols w/ SZ name fields. All name fields contain utf8 encoded strings. - S_ST_MAX=0x1100, // starting point for SZ name symbols - - S_OBJNAME=0x1101, // path to object file name - S_THUNK32=0x1102, // Thunk Start - S_BLOCK32=0x1103, // block start - S_WITH32=0x1104, // with start - S_LABEL32=0x1105, // code label - S_REGISTER=0x1106, // Register variable - S_CONSTANT=0x1107, // constant symbol - S_UDT=0x1108, // User defined type - S_COBOLUDT=0x1109, // special UDT for cobol that does not symbol pack - S_MANYREG=0x110a, // multiple register variable - S_BPREL32=0x110b, // BP-relative - S_LDATA32=0x110c, // Module-local symbol - S_GDATA32=0x110d, // Global data symbol - S_PUB32=0x110e, // a internal symbol (CV internal reserved) - S_LPROC32=0x110f, // Local procedure start - S_GPROC32=0x1110, // Global procedure start - S_REGREL32=0x1111, // register relative address - S_LTHREAD32=0x1112, // local thread storage - S_GTHREAD32=0x1113, // global thread storage - - S_LPROCMIPS=0x1114, // Local procedure start - S_GPROCMIPS=0x1115, // Global procedure start - S_COMPILE2=0x1116, // extended compile flags and info - S_MANYREG2=0x1117, // multiple register variable - S_LPROCIA64=0x1118, // Local procedure start (IA64) - S_GPROCIA64=0x1119, // Global procedure start (IA64) - S_LOCALSLOT=0x111a, // local IL sym with field for local slot index - S_SLOT=S_LOCALSLOT, // alias for LOCALSLOT - S_PARAMSLOT=0x111b, // local IL sym with field for parameter slot index - - // symbols to support managed code debugging - S_LMANDATA=0x111c, - S_GMANDATA=0x111d, - S_MANFRAMEREL=0x111e, - S_MANREGISTER=0x111f, - S_MANSLOT=0x1120, - S_MANMANYREG=0x1121, - S_MANREGREL=0x1122, - S_MANMANYREG2=0x1123, - S_UNAMESPACE=0x1124, // Using namespace - - // ref symbols with name fields - S_PROCREF=0x1125, // Reference to a procedure - S_DATAREF=0x1126, // Reference to data - S_LPROCREF=0x1127, // Local Reference to a procedure - S_ANNOTATIONREF=0x1128, // Reference to an S_ANNOTATION symbol - S_TOKENREF=0x1129, // Reference to one of the many MANPROCSYM's - - // continuation of managed symbols - S_GMANPROC=0x112a, // Global proc - S_LMANPROC=0x112b, // Local proc - - // short, light-weight thunks - S_TRAMPOLINE=0x112c, // trampoline thunks - S_MANCONSTANT=0x112d, // constants with metadata type info - - // native attributed local/parms - S_ATTR_FRAMEREL=0x112e, // relative to virtual frame ptr - S_ATTR_REGISTER=0x112f, // stored in a register - S_ATTR_REGREL=0x1130, // relative to register (alternate frame ptr) - S_ATTR_MANYREG=0x1131, // stored in >1 register - - // Separated code (from the compiler) support - S_SEPCODE=0x1132, - - S_LOCAL=0x1133, // defines a local symbol in optimized code - S_DEFRANGE=0x1134, // defines a single range of addresses in which symbol can be evaluated - S_DEFRANGE2=0x1135, // defines ranges of addresses in which symbol can be evaluated - - S_SECTION=0x1136, // A COFF section in a PE executable - S_COFFGROUP=0x1137, // A COFF group - S_EXPORT=0x1138, // A export - - S_CALLSITEINFO=0x1139, // Indirect call site information - S_FRAMECOOKIE=0x113a, // Security cookie information - - S_DISCARDED=0x113b, // Discarded by LINK /OPT:REF (experimental, see richards) - - S_RECTYPE_MAX, // one greater than last - S_RECTYPE_LAST=S_RECTYPE_MAX - 1, - - }; - - // enum describing compile flag ambient data model - - internal enum CV_CFL_DATA { - CV_CFL_DNEAR=0x00, - CV_CFL_DFAR=0x01, - CV_CFL_DHUGE=0x02 - }; - - // enum describing compile flag ambiant code model - - internal enum CV_CFL_CODE { - CV_CFL_CNEAR=0x00, - CV_CFL_CFAR=0x01, - CV_CFL_CHUGE=0x02 - }; - - // enum describing compile flag target floating point package - - internal enum CV_CFL_FPKG { - CV_CFL_NDP=0x00, - CV_CFL_EMU=0x01, - CV_CFL_ALT=0x02 - }; - - // enum describing function return method - - [Flags] - internal enum CV_PROCFLAGS : byte { - CV_PFLAG_NOFPO=0x01, // frame pointer present - CV_PFLAG_INT=0x02, // interrupt return - CV_PFLAG_FAR=0x04, // far return - CV_PFLAG_NEVER=0x08, // function does not return - CV_PFLAG_NOTREACHED=0x10, // label isn't fallen into - CV_PFLAG_CUST_CALL=0x20, // custom calling convention - CV_PFLAG_NOINLINE=0x40, // function marked as noinline - CV_PFLAG_OPTDBGINFO=0x80, // function has debug information for optimized code - }; - - // Extended proc flags - // - internal struct CV_EXPROCFLAGS { - internal byte flags; // (CV_PROCFLAGS) - internal byte reserved; // must be zero - }; - - // local variable flags - [Flags] - internal enum CV_LVARFLAGS : ushort { - fIsParam=0x0001, // variable is a parameter - fAddrTaken=0x0002, // address is taken - fCompGenx=0x0004, // variable is compiler generated - fIsAggregate=0x0008, // the symbol is splitted in temporaries, - // which are treated by compiler as - // independent entities - fIsAggregated=0x0010, // Counterpart of fIsAggregate - tells - // that it is a part of a fIsAggregate symbol - fIsAliased=0x0020, // variable has multiple simultaneous lifetimes - fIsAlias=0x0040, // represents one of the multiple simultaneous lifetimes - }; - - // represents an address range, used for optimized code debug info - internal struct CV_lvar_addr_range { // defines a range of addresses - internal uint offStart; - internal ushort isectStart; - internal uint cbRange; - }; - - // enum describing function data return method - - internal enum CV_GENERIC_STYLE { - CV_GENERIC_VOID=0x00, // void return type - CV_GENERIC_REG=0x01, // return data is in registers - CV_GENERIC_ICAN=0x02, // indirect caller allocated near - CV_GENERIC_ICAF=0x03, // indirect caller allocated far - CV_GENERIC_IRAN=0x04, // indirect returnee allocated near - CV_GENERIC_IRAF=0x05, // indirect returnee allocated far - CV_GENERIC_UNUSED=0x06 // first unused - }; - - [Flags] - internal enum CV_GENERIC_FLAG : ushort { - cstyle=0x0001, // true push varargs right to left - rsclean=0x0002, // true if returnee stack cleanup - }; - - // flag bitfields for separated code attributes - - [Flags] - internal enum CV_SEPCODEFLAGS : uint { - fIsLexicalScope=0x00000001, // S_SEPCODE doubles as lexical scope - fReturnsToParent=0x00000002, // code frag returns to parent - }; - - // Generic layout for symbol records - - internal struct SYMTYPE { - internal ushort reclen; // Record length - internal ushort rectyp; // Record type - // byte data[CV_ZEROLEN]; - // SYMTYPE *NextSym (SYMTYPE * pSym) { - // return (SYMTYPE *) ((char *)pSym + pSym->reclen + sizeof(ushort)); - // } - }; - - // non-model specific symbol types - - internal struct RegSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_REGISTER - internal uint typind; // (type index) Type index or Metadata token - internal ushort reg; // register enumerate - internal string name; // Length-prefixed name - }; - - internal struct AttrRegSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_MANREGISTER | S_ATTR_REGISTER - internal uint typind; // (type index) Type index or Metadata token - internal uint offCod; // first code address where var is live - internal ushort segCod; - internal ushort flags; // (CV_LVARFLAGS)local var flags - internal ushort reg; // register enumerate - internal string name; // Length-prefixed name - }; - - internal struct ManyRegSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_MANYREG - internal uint typind; // (type index) Type index or metadata token - internal byte count; // count of number of registers - internal byte[] reg; // count register enumerates, most-sig first - internal string name; // length-prefixed name. - }; - - internal struct ManyRegSym2 { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_MANYREG2 - internal uint typind; // (type index) Type index or metadata token - internal ushort count; // count of number of registers, - internal ushort[] reg; // count register enumerates, most-sig first - internal string name; // length-prefixed name. - }; - - internal struct AttrManyRegSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_MANMANYREG - internal uint typind; // (type index) Type index or metadata token - internal uint offCod; // first code address where var is live - internal ushort segCod; - internal ushort flags; // (CV_LVARFLAGS)local var flags - internal byte count; // count of number of registers - internal byte[] reg; // count register enumerates, most-sig first - internal string name; // utf-8 encoded zero terminate name - }; - - internal struct AttrManyRegSym2 { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_MANMANYREG2 | S_ATTR_MANYREG - internal uint typind; // (type index) Type index or metadata token - internal uint offCod; // first code address where var is live - internal ushort segCod; - internal ushort flags; // (CV_LVARFLAGS)local var flags - internal ushort count; // count of number of registers - internal ushort[] reg; // count register enumerates, most-sig first - internal string name; // utf-8 encoded zero terminate name - }; - - internal struct ConstSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_CONSTANT or S_MANCONSTANT - internal uint typind; // (type index) Type index (containing enum if enumerate) or metadata token - internal ushort value; // numeric leaf containing value - internal string name; // Length-prefixed name - }; - - internal struct UdtSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_UDT | S_COBOLUDT - internal uint typind; // (type index) Type index - internal string name; // Length-prefixed name - }; - - internal struct ManyTypRef { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_MANTYPREF - internal uint typind; // (type index) Type index - }; - - internal struct SearchSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_SSEARCH - internal uint startsym; // offset of the procedure - internal ushort seg; // segment of symbol - }; - - [Flags] - internal enum CFLAGSYM_FLAGS : ushort { - pcode=0x0001, // true if pcode present - floatprec=0x0006, // floating precision - floatpkg=0x0018, // float package - ambdata=0x00e0, // ambient data model - ambcode=0x0700, // ambient code model - mode32=0x0800, // true if compiled 32 bit mode - }; - - internal struct CFlagSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_COMPILE - internal byte machine; // target processor - internal byte language; // language index - internal ushort flags; // (CFLAGSYM_FLAGS) - internal string ver; // Length-prefixed compiler version string - }; - - [Flags] - internal enum COMPILESYM_FLAGS : uint { - iLanguage=0x000000ff, // language index - fEC=0x00000100, // compiled for E/C - fNoDbgInfo=0x00000200, // not compiled with debug info - fLTCG=0x00000400, // compiled with LTCG - fNoDataAlign=0x00000800, // compiled with -Bzalign - fManagedPresent=0x00001000, // managed code/data present - fSecurityChecks=0x00002000, // compiled with /GS - fHotPatch=0x00004000, // compiled with /hotpatch - fCVTCIL=0x00008000, // converted with CVTCIL - fMSILModule=0x00010000, // MSIL netmodule - }; - - internal struct CompileSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_COMPILE2 - internal uint flags; // (COMPILESYM_FLAGS) - internal ushort machine; // target processor - internal ushort verFEMajor; // front end major version # - internal ushort verFEMinor; // front end minor version # - internal ushort verFEBuild; // front end build version # - internal ushort verMajor; // back end major version # - internal ushort verMinor; // back end minor version # - internal ushort verBuild; // back end build version # - internal string verSt; // Length-prefixed compiler version string, followed - internal string[] verArgs; // block of zero terminated strings, ended by double-zero. - }; - - internal struct ObjNameSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_OBJNAME - internal uint signature; // signature - internal string name; // Length-prefixed name - }; - - internal struct EndArgSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_ENDARG - }; - - internal struct ReturnSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_RETURN - internal CV_GENERIC_FLAG flags; // flags - internal byte style; // CV_GENERIC_STYLE return style - // followed by return method data - }; - - internal struct EntryThisSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_ENTRYTHIS - internal byte thissym; // symbol describing this pointer on entry - }; - - internal struct BpRelSym32 { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_BPREL32 - internal int off; // BP-relative offset - internal uint typind; // (type index) Type index or Metadata token - internal string name; // Length-prefixed name - }; - - internal struct FrameRelSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_MANFRAMEREL | S_ATTR_FRAMEREL - internal int off; // Frame relative offset - internal uint typind; // (type index) Type index or Metadata token - internal uint offCod; // first code address where var is live - internal ushort segCod; - internal ushort flags; // (CV_LVARFLAGS)local var flags - internal string name; // Length-prefixed name - }; - - internal struct SlotSym32 { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_LOCALSLOT or S_PARAMSLOT - internal uint index; // slot index - internal uint typind; // (type index) Type index or Metadata token - internal string name; // Length-prefixed name - }; - - internal struct AttrSlotSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_MANSLOT - internal uint index; // slot index - internal uint typind; // (type index) Type index or Metadata token - internal uint offCod; // first code address where var is live - internal ushort segCod; - internal ushort flags; // (CV_LVARFLAGS)local var flags - internal string name; // Length-prefixed name - - }; - - internal struct AnnotationSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_ANNOTATION - internal uint off; - internal ushort seg; - internal ushort csz; // Count of zero terminated annotation strings - internal string[] rgsz; // Sequence of zero terminated annotation strings - }; - - internal struct DatasSym32 { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_LDATA32, S_GDATA32 or S_PUB32, S_LMANDATA, S_GMANDATA - internal uint typind; // (type index) Type index, or Metadata token if a managed symbol - internal uint off; - internal ushort seg; - internal string name; // Length-prefixed name - }; - - [Flags] - internal enum CV_PUBSYMFLAGS : uint { - fNone=0, - fCode=0x00000001, // set if internal symbol refers to a code address - fFunction=0x00000002, // set if internal symbol is a function - fManaged=0x00000004, // set if managed code (native or IL) - fMSIL=0x00000008, // set if managed IL code - }; - - internal struct PubSym32 { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_PUB32 - internal uint flags; // (CV_PUBSYMFLAGS) - internal uint off; - internal ushort seg; - internal string name; // Length-prefixed name - }; - - internal struct ProcSym32 { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_GPROC32 or S_LPROC32 - internal uint parent; // pointer to the parent - internal uint end; // pointer to this blocks end - internal uint next; // pointer to next symbol - internal uint len; // Proc length - internal uint dbgStart; // Debug start offset - internal uint dbgEnd; // Debug end offset - internal uint typind; // (type index) Type index - internal uint off; - internal ushort seg; - internal byte flags; // (CV_PROCFLAGS) Proc flags - internal string name; // Length-prefixed name - }; - - internal struct ManProcSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_GMANPROC, S_LMANPROC, S_GMANPROCIA64 or S_LMANPROCIA64 - internal uint parent; // pointer to the parent - internal uint end; // pointer to this blocks end - internal uint next; // pointer to next symbol - internal uint len; // Proc length - internal uint dbgStart; // Debug start offset - internal uint dbgEnd; // Debug end offset - internal uint token; // COM+ metadata token for method - internal uint off; - internal ushort seg; - internal byte flags; // (CV_PROCFLAGS) Proc flags - internal ushort retReg; // Register return value is in (may not be used for all archs) - internal string name; // optional name field - }; - - internal struct ManProcSymMips { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_GMANPROCMIPS or S_LMANPROCMIPS - internal uint parent; // pointer to the parent - internal uint end; // pointer to this blocks end - internal uint next; // pointer to next symbol - internal uint len; // Proc length - internal uint dbgStart; // Debug start offset - internal uint dbgEnd; // Debug end offset - internal uint regSave; // int register save mask - internal uint fpSave; // fp register save mask - internal uint intOff; // int register save offset - internal uint fpOff; // fp register save offset - internal uint token; // COM+ token type - internal uint off; - internal ushort seg; - internal byte retReg; // Register return value is in - internal byte frameReg; // Frame pointer register - internal string name; // optional name field - }; - - internal struct ThunkSym32 { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_THUNK32 - internal uint parent; // pointer to the parent - internal uint end; // pointer to this blocks end - internal uint next; // pointer to next symbol - internal uint off; - internal ushort seg; - internal ushort len; // length of thunk - internal byte ord; // THUNK_ORDINAL specifying type of thunk - internal string name; // Length-prefixed name - internal byte[] variant; // variant portion of thunk - }; - - internal enum TRAMP { // Trampoline subtype - trampIncremental, // incremental thunks - trampBranchIsland, // Branch island thunks - }; - - internal struct TrampolineSym { // Trampoline thunk symbol - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_TRAMPOLINE - internal ushort trampType; // trampoline sym subtype - internal ushort cbThunk; // size of the thunk - internal uint offThunk; // offset of the thunk - internal uint offTarget; // offset of the target of the thunk - internal ushort sectThunk; // section index of the thunk - internal ushort sectTarget; // section index of the target of the thunk - }; - - internal struct LabelSym32 { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_LABEL32 - internal uint off; - internal ushort seg; - internal byte flags; // (CV_PROCFLAGS) flags - internal string name; // Length-prefixed name - }; - - internal struct BlockSym32 { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_BLOCK32 - internal uint parent; // pointer to the parent - internal uint end; // pointer to this blocks end - internal uint len; // Block length - internal uint off; // Offset in code segment - internal ushort seg; // segment of label - internal string name; // Length-prefixed name - }; - - internal struct WithSym32 { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_WITH32 - internal uint parent; // pointer to the parent - internal uint end; // pointer to this blocks end - internal uint len; // Block length - internal uint off; // Offset in code segment - internal ushort seg; // segment of label - internal string expr; // Length-prefixed expression string - }; - - internal struct VpathSym32 { - // internal ushort reclen; // record length - // internal ushort rectyp; // S_VFTABLE32 - internal uint root; // (type index) type index of the root of path - internal uint path; // (type index) type index of the path record - internal uint off; // offset of virtual function table - internal ushort seg; // segment of virtual function table - }; - - internal struct RegRel32 { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_REGREL32 - internal uint off; // offset of symbol - internal uint typind; // (type index) Type index or metadata token - internal ushort reg; // register index for symbol - internal string name; // Length-prefixed name - }; - - internal struct AttrRegRel { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_MANREGREL | S_ATTR_REGREL - internal uint off; // offset of symbol - internal uint typind; // (type index) Type index or metadata token - internal ushort reg; // register index for symbol - internal uint offCod; // first code address where var is live - internal ushort segCod; - internal ushort flags; // (CV_LVARFLAGS)local var flags - internal string name; // Length-prefixed name - }; - - internal struct ThreadSym32 { - // internal ushort reclen; // record length - // internal ushort rectyp; // S_LTHREAD32 | S_GTHREAD32 - internal uint typind; // (type index) type index - internal uint off; // offset into thread storage - internal ushort seg; // segment of thread storage - internal string name; // length prefixed name - }; - - internal struct Slink32 { - // internal ushort reclen; // record length - // internal ushort rectyp; // S_SLINK32 - internal uint framesize; // frame size of parent procedure - internal int off; // signed offset where the static link was saved relative to the value of reg - internal ushort reg; - }; - - internal struct ProcSymMips { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_GPROCMIPS or S_LPROCMIPS - internal uint parent; // pointer to the parent - internal uint end; // pointer to this blocks end - internal uint next; // pointer to next symbol - internal uint len; // Proc length - internal uint dbgStart; // Debug start offset - internal uint dbgEnd; // Debug end offset - internal uint regSave; // int register save mask - internal uint fpSave; // fp register save mask - internal uint intOff; // int register save offset - internal uint fpOff; // fp register save offset - internal uint typind; // (type index) Type index - internal uint off; // Symbol offset - internal ushort seg; // Symbol segment - internal byte retReg; // Register return value is in - internal byte frameReg; // Frame pointer register - internal string name; // Length-prefixed name - }; - - internal struct ProcSymIa64 { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_GPROCIA64 or S_LPROCIA64 - internal uint parent; // pointer to the parent - internal uint end; // pointer to this blocks end - internal uint next; // pointer to next symbol - internal uint len; // Proc length - internal uint dbgStart; // Debug start offset - internal uint dbgEnd; // Debug end offset - internal uint typind; // (type index) Type index - internal uint off; // Symbol offset - internal ushort seg; // Symbol segment - internal ushort retReg; // Register return value is in - internal byte flags; // (CV_PROCFLAGS) Proc flags - internal string name; // Length-prefixed name - }; - - internal struct RefSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_PROCREF_ST, S_DATAREF_ST, or S_LPROCREF_ST - internal uint sumName; // SUC of the name - internal uint ibSym; // Offset of actual symbol in $$Symbols - internal ushort imod; // Module containing the actual symbol - internal ushort usFill; // align this record - }; - - internal struct RefSym2 { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_PROCREF, S_DATAREF, or S_LPROCREF - internal uint sumName; // SUC of the name - internal uint ibSym; // Offset of actual symbol in $$Symbols - internal ushort imod; // Module containing the actual symbol - internal string name; // hidden name made a first class member - }; - - internal struct AlignSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_ALIGN - }; - - internal struct OemSymbol { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_OEM - internal Guid idOem; // an oem ID (GUID) - internal uint typind; // (type index) Type index - internal byte[] rgl; // user data, force 4-byte alignment - }; - - [Flags] - internal enum FRAMEPROCSYM_FLAGS : uint { - fHasAlloca=0x00000001, // function uses _alloca() - fHasSetJmp=0x00000002, // function uses setjmp() - fHasLongJmp=0x00000004, // function uses longjmp() - fHasInlAsm=0x00000008, // function uses inline asm - fHasEH=0x00000010, // function has EH states - fInlSpec=0x00000020, // function was speced as inline - fHasSEH=0x00000040, // function has SEH - fNaked=0x00000080, // function is __declspec(naked) - fSecurityChecks=0x00000100, // function has buffer security check introduced by /GS. - fAsyncEH=0x00000200, // function compiled with /EHa - fGSNoStackOrdering=0x00000400, // function has /GS buffer checks, but stack ordering couldn't be done - fWasInlined=0x00000800, // function was inlined within another function - }; - - internal struct FrameProcSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_FRAMEPROC - internal uint cbFrame; // count of bytes of total frame of procedure - internal uint cbPad; // count of bytes of padding in the frame - internal uint offPad; // offset (rel to frame) to where padding starts - internal uint cbSaveRegs; // count of bytes of callee save registers - internal uint offExHdlr; // offset of exception handler - internal ushort secExHdlr; // section id of exception handler - internal uint flags; // (FRAMEPROCSYM_FLAGS) - } - - internal struct UnamespaceSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_UNAMESPACE - internal string name; // name - }; - - internal struct SepCodSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_SEPCODE - internal uint parent; // pointer to the parent - internal uint end; // pointer to this block's end - internal uint length; // count of bytes of this block - internal uint scf; // (CV_SEPCODEFLAGS) flags - internal uint off; // sec:off of the separated code - internal uint offParent; // secParent:offParent of the enclosing scope - internal ushort sec; // (proc, block, or sepcode) - internal ushort secParent; - }; - - internal struct LocalSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_LOCAL - internal uint id; // id of the local - internal uint typind; // (type index) type index - internal ushort flags; // (CV_LVARFLAGS) local var flags - internal uint idParent; // This is is parent variable - fIsAggregated or fIsAlias - internal uint offParent; // Offset in parent variable - fIsAggregated - - internal uint expr; // NI of expression that this temp holds - internal uint pad0; // pad, must be zero - internal uint pad1; // pad, must be zero - - internal string name; // Name of this symbol. - } - - internal struct DefRangeSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_DEFRANGE - - internal uint id; // ID of the local symbol for which this formula holds - internal uint program; // program to evaluate the value of the symbol - - internal CV_lvar_addr_range range; // Range of addresses where this program is valid - }; - - internal struct DefRangeSym2 { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_DEFRANGE2 - - internal uint id; // ID of the local symbol for which this formula holds - internal uint program; // program to evaluate the value of the symbol - - internal ushort count; // count of CV_lvar_addr_range records following - internal CV_lvar_addr_range[] range;// Range of addresses where this program is valid - }; - - internal struct SectionSym { - // internal ushort reclen // Record length - // internal ushort rectyp; // S_SECTION - - internal ushort isec; // Section number - internal byte align; // Alignment of this section (power of 2) - internal byte bReserved; // Reserved. Must be zero. - internal uint rva; - internal uint cb; - internal uint characteristics; - internal string name; // name - }; - - internal struct CoffGroupSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_COFFGROUP - - internal uint cb; - internal uint characteristics; - internal uint off; // Symbol offset - internal ushort seg; // Symbol segment - internal string name; // name - }; - - [Flags] - internal enum EXPORTSYM_FLAGS : ushort { - fConstant=0x0001, // CONSTANT - fData=0x0002, // DATA - fPrivate=0x0004, // PRIVATE - fNoName=0x0008, // NONAME - fOrdinal=0x0010, // Ordinal was explicitly assigned - fForwarder=0x0020, // This is a forwarder - } - - internal struct ExportSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_EXPORT - - internal ushort ordinal; - internal ushort flags; // (EXPORTSYM_FLAGS) - internal string name; // name of - }; - - // - // Symbol for describing indirect calls when they are using - // a function pointer cast on some other type or temporary. - // Typical content will be an LF_POINTER to an LF_PROCEDURE - // type record that should mimic an actual variable with the - // function pointer type in question. - // - // Since the compiler can sometimes tail-merge a function call - // through a function pointer, there may be more than one - // S_CALLSITEINFO record at an address. This is similar to what - // you could do in your own code by: - // - // if (expr) - // pfn = &function1; - // else - // pfn = &function2; - // - // (*pfn)(arg list); - // - - internal struct CallsiteInfo { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_CALLSITEINFO - internal int off; // offset of call site - internal ushort ect; // section index of call site - internal ushort pad0; // alignment padding field, must be zero - internal uint typind; // (type index) type index describing function signature - }; - - // Frame cookie information - - internal enum CV_cookietype { - CV_COOKIETYPE_COPY=0, - CV_COOKIETYPE_XOR_SP, - CV_COOKIETYPE_XOR_BP, - CV_COOKIETYPE_XOR_R13, - }; - - // Symbol for describing security cookie's position and type - // (raw, xor'd with esp, xor'd with ebp). - - internal struct FrameCookie { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_FRAMECOOKIE - internal int off; // Frame relative offset - internal ushort reg; // Register index - internal int cookietype; // (CV_cookietype) Type of the cookie - internal byte flags; // Flags describing this cookie - }; - - internal enum CV_DISCARDED : uint { - CV_DISCARDED_UNKNOWN=0, - CV_DISCARDED_NOT_SELECTED=1, - CV_DISCARDED_NOT_REFERENCED=2, - }; - - internal struct DiscardedSym { - // internal ushort reclen; // Record length [SYMTYPE] - // internal ushort rectyp; // S_DISCARDED - internal CV_DISCARDED iscarded; - internal uint fileid; // First FILEID if line number info present - internal uint linenum; // First line number - internal byte[] data; // Original record(s) with invalid indices - }; - - // - // V7 line number data types - // - - internal enum DEBUG_S_SUBSECTION_TYPE : uint { - DEBUG_S_IGNORE=0x80000000, // if this bit is set in a subsection type then ignore the subsection contents - - DEBUG_S_SYMBOLS=0xf1, - DEBUG_S_LINES=0xf2, - DEBUG_S_STRINGTABLE=0xf3, - DEBUG_S_FILECHKSMS=0xf4, - DEBUG_S_FRAMEDATA=0xf5, - }; - - // - // Line flags (data present) - // - internal enum CV_LINE_SUBSECTION_FLAGS : ushort { - CV_LINES_HAVE_COLUMNS=0x0001, - } - - internal struct CV_LineSection { - internal uint off; - internal ushort sec; - internal ushort flags; - internal uint cod; - } - - internal struct CV_SourceFile { - internal uint index; // Index to file in checksum section. - internal uint count; // Number of CV_Line records. - internal uint linsiz; // Size of CV_Line recods. - } - - [Flags] - internal enum CV_Line_Flags : uint { - linenumStart=0x00ffffff, // line where statement/expression starts - deltaLineEnd=0x7f000000, // delta to line where statement ends (optional) - fStatement=0x80000000, // true if a statement linenumber, else an expression line num - }; - - internal struct CV_Line { - internal uint offset; // Offset to start of code bytes for line number - internal uint flags; // (CV_Line_Flags) - }; - - internal struct CV_Column { - internal ushort offColumnStart; - internal ushort offColumnEnd; - }; - - // File information - - internal enum CV_FILE_CHECKSUM_TYPE : byte { - None=0, - MD5=1, - }; - - internal struct CV_FileCheckSum { - internal uint name; // Index of name in name table. - internal byte len; // Hash length - internal byte type; // Hash type - } - - [Flags] - internal enum FRAMEDATA_FLAGS : uint { - fHasSEH=0x00000001, - fHasEH=0x00000002, - fIsFunctionStart=0x00000004, - }; - - internal struct FrameData { - internal uint ulRvaStart; - internal uint cbBlock; - internal uint cbLocals; - internal uint cbParams; - internal uint cbStkMax; - internal uint frameFunc; - internal ushort cbProlog; - internal ushort cbSavedRegs; - internal uint flags; // (FRAMEDATA_FLAGS) - }; - - internal struct XFixupData { - internal ushort wType; - internal ushort wExtra; - internal uint rva; - internal uint rvaTarget; - }; - - internal enum DEBUG_S_SUBSECTION { - SYMBOLS=0xF1, - LINES=0xF2, - STRINGTABLE=0xF3, - FILECHKSMS=0xF4, - FRAMEDATA=0xF5, - } -} \ No newline at end of file diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DataStream.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DataStream.cs deleted file mode 100644 index 48a1851651..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DataStream.cs +++ /dev/null @@ -1,111 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; -using System.IO; - -namespace Microsoft.Cci.Pdb { - internal class DataStream { - internal DataStream() { - } - - internal DataStream(int contentSize, BitAccess bits, int count) { - this.contentSize = contentSize; - if (count > 0) { - this.pages = new int[count]; - bits.ReadInt32(this.pages); - } - } - - internal void Read(PdbReader reader, BitAccess bits) { - bits.MinCapacity(contentSize); - Read(reader, 0, bits.Buffer, 0, contentSize); - } - - internal void Read(PdbReader reader, int position, - byte[] bytes, int offset, int data) { - if (position + data > contentSize) { - throw new PdbException("DataStream can't read off end of stream. " + - "(pos={0},siz={1})", - position, data); - } - if (position == contentSize) { - return; - } - - int left = data; - int page = position / reader.pageSize; - int rema = position % reader.pageSize; - - // First get remained of first page. - if (rema != 0) { - int todo = reader.pageSize - rema; - if (todo > left) { - todo = left; - } - - reader.Seek(pages[page], rema); - reader.Read(bytes, offset, todo); - - offset += todo; - left -= todo; - page++; - } - - // Now get the remaining pages. - while (left > 0) { - int todo = reader.pageSize; - if (todo > left) { - todo = left; - } - - reader.Seek(pages[page], 0); - reader.Read(bytes, offset, todo); - - offset += todo; - left -= todo; - page++; - } - } - - //private void AddPages(int page0, int count) { - // if (pages == null) { - // pages = new int[count]; - // for (int i = 0; i < count; i++) { - // pages[i] = page0 + i; - // } - // } else { - // int[] old = pages; - // int used = old.Length; - - // pages = new int[used + count]; - // Array.Copy(old, pages, used); - // for (int i = 0; i < count; i++) { - // pages[used + i] = page0 + i; - // } - // } - //} - - //internal int Pages { - // get { return pages == null ? 0 : pages.Length; } - //} - - internal int Length { - get { return contentSize; } - } - - //internal int GetPage(int index) { - // return pages[index]; - //} - - internal int contentSize; - internal int[] pages; - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiDbgHdr.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiDbgHdr.cs deleted file mode 100644 index 588f3c13de..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiDbgHdr.cs +++ /dev/null @@ -1,41 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; - -namespace Microsoft.Cci.Pdb { - internal struct DbiDbgHdr { - internal DbiDbgHdr(BitAccess bits) { - bits.ReadUInt16(out snFPO); - bits.ReadUInt16(out snException); - bits.ReadUInt16(out snFixup); - bits.ReadUInt16(out snOmapToSrc); - bits.ReadUInt16(out snOmapFromSrc); - bits.ReadUInt16(out snSectionHdr); - bits.ReadUInt16(out snTokenRidMap); - bits.ReadUInt16(out snXdata); - bits.ReadUInt16(out snPdata); - bits.ReadUInt16(out snNewFPO); - bits.ReadUInt16(out snSectionHdrOrig); - } - - internal ushort snFPO; // 0..1 - internal ushort snException; // 2..3 (deprecated) - internal ushort snFixup; // 4..5 - internal ushort snOmapToSrc; // 6..7 - internal ushort snOmapFromSrc; // 8..9 - internal ushort snSectionHdr; // 10..11 - internal ushort snTokenRidMap; // 12..13 - internal ushort snXdata; // 14..15 - internal ushort snPdata; // 16..17 - internal ushort snNewFPO; // 18..19 - internal ushort snSectionHdrOrig; // 20..21 - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiHeader.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiHeader.cs deleted file mode 100644 index 0ca7915883..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiHeader.cs +++ /dev/null @@ -1,59 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; - -namespace Microsoft.Cci.Pdb { - internal struct DbiHeader { - internal DbiHeader(BitAccess bits) { - bits.ReadInt32(out sig); - bits.ReadInt32(out ver); - bits.ReadInt32(out age); - bits.ReadInt16(out gssymStream); - bits.ReadUInt16(out vers); - bits.ReadInt16(out pssymStream); - bits.ReadUInt16(out pdbver); - bits.ReadInt16(out symrecStream); - bits.ReadUInt16(out pdbver2); - bits.ReadInt32(out gpmodiSize); - bits.ReadInt32(out secconSize); - bits.ReadInt32(out secmapSize); - bits.ReadInt32(out filinfSize); - bits.ReadInt32(out tsmapSize); - bits.ReadInt32(out mfcIndex); - bits.ReadInt32(out dbghdrSize); - bits.ReadInt32(out ecinfoSize); - bits.ReadUInt16(out flags); - bits.ReadUInt16(out machine); - bits.ReadInt32(out reserved); - } - - internal int sig; // 0..3 - internal int ver; // 4..7 - internal int age; // 8..11 - internal short gssymStream; // 12..13 - internal ushort vers; // 14..15 - internal short pssymStream; // 16..17 - internal ushort pdbver; // 18..19 - internal short symrecStream; // 20..21 - internal ushort pdbver2; // 22..23 - internal int gpmodiSize; // 24..27 - internal int secconSize; // 28..31 - internal int secmapSize; // 32..35 - internal int filinfSize; // 36..39 - internal int tsmapSize; // 40..43 - internal int mfcIndex; // 44..47 - internal int dbghdrSize; // 48..51 - internal int ecinfoSize; // 52..55 - internal ushort flags; // 56..57 - internal ushort machine; // 58..59 - internal int reserved; // 60..63 - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiModuleInfo.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiModuleInfo.cs deleted file mode 100644 index 8ab3717115..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiModuleInfo.cs +++ /dev/null @@ -1,57 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; - -namespace Microsoft.Cci.Pdb { - internal class DbiModuleInfo { - internal DbiModuleInfo(BitAccess bits, bool readStrings) { - bits.ReadInt32(out opened); - new DbiSecCon(bits); - bits.ReadUInt16(out flags); - bits.ReadInt16(out stream); - bits.ReadInt32(out cbSyms); - bits.ReadInt32(out cbOldLines); - bits.ReadInt32(out cbLines); - bits.ReadInt16(out files); - bits.ReadInt16(out pad1); - bits.ReadUInt32(out offsets); - bits.ReadInt32(out niSource); - bits.ReadInt32(out niCompiler); - if (readStrings) { - bits.ReadCString(out moduleName); - bits.ReadCString(out objectName); - } else { - bits.SkipCString(out moduleName); - bits.SkipCString(out objectName); - } - bits.Align(4); - //if (opened != 0 || pad1 != 0) { - // throw new PdbException("Invalid DBI module. "+ - // "(opened={0}, pad={1})", opened, pad1); - //} - } - - internal int opened; // 0..3 - //internal DbiSecCon section; // 4..31 - internal ushort flags; // 32..33 - internal short stream; // 34..35 - internal int cbSyms; // 36..39 - internal int cbOldLines; // 40..43 - internal int cbLines; // 44..57 - internal short files; // 48..49 - internal short pad1; // 50..51 - internal uint offsets; - internal int niSource; - internal int niCompiler; - internal string moduleName; - internal string objectName; - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiSecCon.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiSecCon.cs deleted file mode 100644 index de9fde951d..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/DbiSecCon.cs +++ /dev/null @@ -1,42 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; - -namespace Microsoft.Cci.Pdb { - internal struct DbiSecCon { - internal DbiSecCon(BitAccess bits) { - bits.ReadInt16(out section); - bits.ReadInt16(out pad1); - bits.ReadInt32(out offset); - bits.ReadInt32(out size); - bits.ReadUInt32(out flags); - bits.ReadInt16(out module); - bits.ReadInt16(out pad2); - bits.ReadUInt32(out dataCrc); - bits.ReadUInt32(out relocCrc); - //if (pad1 != 0 || pad2 != 0) { - // throw new PdbException("Invalid DBI section. "+ - // "(pad1={0}, pad2={1})", - // pad1, pad2); - //} - } - - internal short section; // 0..1 - internal short pad1; // 2..3 - internal int offset; // 4..7 - internal int size; // 8..11 - internal uint flags; // 12..15 - internal short module; // 16..17 - internal short pad2; // 18..19 - internal uint dataCrc; // 20..23 - internal uint relocCrc; // 24..27 - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/IntHashTable.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/IntHashTable.cs deleted file mode 100644 index db0e41be00..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/IntHashTable.cs +++ /dev/null @@ -1,583 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; -using System.Collections; - -namespace Microsoft.Cci.Pdb { - // The IntHashTable class represents a dictionary of associated keys and - // values with constant lookup time. - // - // Objects used as keys in a hashtable must implement the GetHashCode - // and Equals methods (or they can rely on the default implementations - // inherited from Object if key equality is simply reference - // equality). Furthermore, the GetHashCode and Equals methods of - // a key object must produce the same results given the same parameters - // for the entire time the key is present in the hashtable. In practical - // terms, this means that key objects should be immutable, at least for - // the time they are used as keys in a hashtable. - // - // When entries are added to a hashtable, they are placed into - // buckets based on the hashcode of their keys. Subsequent lookups of - // keys will use the hashcode of the keys to only search a particular - // bucket, thus substantially reducing the number of key comparisons - // required to find an entry. A hashtable's maximum load factor, which - // can be specified when the hashtable is instantiated, determines the - // maximum ratio of hashtable entries to hashtable buckets. Smaller load - // factors cause faster average lookup times at the cost of increased - // memory consumption. The default maximum load factor of 1.0 generally - // provides the best balance between speed and size. As entries are added - // to a hashtable, the hashtable's actual load factor increases, and when - // the actual load factor reaches the maximum load factor value, the - // number of buckets in the hashtable is automatically increased by - // approximately a factor of two (to be precise, the number of hashtable - // buckets is increased to the smallest prime number that is larger than - // twice the current number of hashtable buckets). - // - // Each object provides their own hash function, accessed by calling - // GetHashCode(). However, one can write their own object - // implementing IHashCodeProvider and pass it to a constructor on - // the IntHashTable. That hash function would be used for all objects in - // the table. - // - // This IntHashTable is implemented to support multiple concurrent readers - // and one concurrent writer without using any synchronization primitives. - // All read methods essentially must protect themselves from a resize - // occuring while they are running. This was done by enforcing an - // ordering on inserts & removes, as well as removing some member variables - // and special casing the expand code to work in a temporary array instead - // of the live bucket array. All inserts must set a bucket's value and - // key before setting the hash code & collision field. - // - // By Brian Grunkemeyer, algorithm by Patrick Dussud. - // Version 1.30 2/20/2000 - //| - internal class IntHashTable {//: IEnumerable { - /* - Implementation Notes: - - This IntHashTable uses double hashing. There are hashsize buckets in - the table, and each bucket can contain 0 or 1 element. We a bit to - mark whether there's been a collision when we inserted multiple - elements (ie, an inserted item was hashed at least a second time and - we probed this bucket, but it was already in use). Using the - collision bit, we can terminate lookups & removes for elements that - aren't in the hash table more quickly. We steal the most - significant bit from the hash code to store the collision bit. - - Our hash function is of the following form: - - h(key, n) = h1(key) + n*h2(key) - - where n is the number of times we've hit a collided bucket and - rehashed (on this particular lookup). Here are our hash functions: - - h1(key) = GetHash(key); // default implementation calls key.GetHashCode(); - h2(key) = 1 + (((h1(key) >> 5) + 1) % (hashsize - 1)); - - The h1 can return any number. h2 must return a number between 1 and - hashsize - 1 that is relatively prime to hashsize (not a problem if - hashsize is prime). (Knuth's Art of Computer Programming, Vol. 3, - p. 528-9) - - If this is true, then we are guaranteed to visit every bucket in - exactly hashsize probes, since the least common multiple of hashsize - and h2(key) will be hashsize * h2(key). (This is the first number - where adding h2 to h1 mod hashsize will be 0 and we will search the - same bucket twice). - - We previously used a different h2(key, n) that was not constant. - That is a horrifically bad idea, unless you can prove that series - will never produce any identical numbers that overlap when you mod - them by hashsize, for all subranges from i to i+hashsize, for all i. - It's not worth investigating, since there was no clear benefit from - using that hash function, and it was broken. - - For efficiency reasons, we've implemented this by storing h1 and h2 - in a temporary, and setting a variable called seed equal to h1. We - do a probe, and if we collided, we simply add h2 to seed each time - through the loop. - - A good test for h2() is to subclass IntHashTable, provide your own - implementation of GetHash() that returns a constant, then add many - items to the hash table. Make sure Count equals the number of items - you inserted. - - -- Brian Grunkemeyer, 10/28/1999 - */ - - // A typical resize algorithm would pick the smallest prime number in this array - // that is larger than twice the previous capacity. - // Suppose our Hashtable currently has capacity x and enough elements are added - // such that a resize needs to occur. Resizing first computes 2x then finds the - // first prime in the table greater than 2x, i.e. if primes are ordered - // p_1, p_2, …, p_i,…, it finds p_n such that p_n-1 < 2x < p_n. - // Doubling is important for preserving the asymptotic complexity of the - // hashtable operations such as add. Having a prime guarantees that double - // hashing does not lead to infinite loops. IE, your hash function will be - // h1(key) + i*h2(key), 0 <= i < size. h2 and the size must be relatively prime. - private static readonly int[] primes = { - 3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, 631, 761, 919, - 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, 10103, 12143, 14591, - 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, 90523, 108631, 130363, 156437, - 187751, 225307, 270371, 324449, 389357, 467237, 560689, 672827, 807403, 968897, 1162687, 1395263, - 1674319, 2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369}; - - private static int GetPrime(int minSize) { - if (minSize < 0) { - throw new ArgumentException("Arg_HTCapacityOverflow"); - } - for (int i = 0; i < primes.Length; i++) { - int size = primes[i]; - if (size >= minSize) { - return size; - } - } - throw new ArgumentException("Arg_HTCapacityOverflow"); - } - - // Deleted entries have their key set to buckets - - // The hash table data. - // This cannot be serialised - private struct bucket { - internal int key; - internal int hash_coll; // Store hash code; sign bit means there was a collision. - internal Object val; - } - - private bucket[] buckets; - - // The total number of entries in the hash table. - private int count; - - // The total number of collision bits set in the hashtable - private int occupancy; - - private int loadsize; - private int loadFactorPerc; // 100 = 1.0 - - private int version; - - // Constructs a new hashtable. The hashtable is created with an initial - // capacity of zero and a load factor of 1.0. - //| - internal IntHashTable() - : this(0, 100) { - } - - //// Constructs a new hashtable with the given initial capacity and a load - //// factor of 1.0. The capacity argument serves as an indication of - //// the number of entries the hashtable will contain. When this number (or - //// an approximation) is known, specifying it in the constructor can - //// eliminate a number of resizing operations that would otherwise be - //// performed when elements are added to the hashtable. - //// - ////| - //internal IntHashTable(int capacity) - // : this(capacity, 100) { - //} - - // Constructs a new hashtable with the given initial capacity and load - // factor. The capacity argument serves as an indication of the - // number of entries the hashtable will contain. When this number (or an - // approximation) is known, specifying it in the constructor can eliminate - // a number of resizing operations that would otherwise be performed when - // elements are added to the hashtable. The loadFactorPerc argument - // indicates the maximum ratio of hashtable entries to hashtable buckets. - // Smaller load factors cause faster average lookup times at the cost of - // increased memory consumption. A load factor of 1.0 generally provides - // the best balance between speed and size. - // - //| - internal IntHashTable(int capacity, int loadFactorPerc) { - if (capacity < 0) - throw new ArgumentOutOfRangeException("capacity", "ArgumentOutOfRange_NeedNonNegNum"); - if (!(loadFactorPerc >= 10 && loadFactorPerc <= 100)) - throw new ArgumentOutOfRangeException("loadFactorPerc", String.Format("ArgumentOutOfRange_IntHashTableLoadFactor", 10, 100)); - - // Based on perf work, .72 is the optimal load factor for this table. - this.loadFactorPerc = (loadFactorPerc * 72) / 100; - - int hashsize = GetPrime((int)(capacity / this.loadFactorPerc)); - buckets = new bucket[hashsize]; - - loadsize = (int)(this.loadFactorPerc * hashsize) / 100; - if (loadsize >= hashsize) - loadsize = hashsize-1; - } - - // Computes the hash function: H(key, i) = h1(key) + i*h2(key, hashSize). - // The out parameter seed is h1(key), while the out parameter - // incr is h2(key, hashSize). Callers of this function should - // add incr each time through a loop. - private static uint InitHash(int key, int hashsize, out uint seed, out uint incr) { - // Hashcode must be positive. Also, we must not use the sign bit, since - // that is used for the collision bit. - uint hashcode = (uint)key & 0x7FFFFFFF; - seed = (uint)hashcode; - // Restriction: incr MUST be between 1 and hashsize - 1, inclusive for - // the modular arithmetic to work correctly. This guarantees you'll - // visit every bucket in the table exactly once within hashsize - // iterations. Violate this and it'll cause obscure bugs forever. - // If you change this calculation for h2(key), update putEntry too! - incr = (uint)(1 + (((seed >> 5) + 1) % ((uint)hashsize - 1))); - return hashcode; - } - - // Adds an entry with the given key and value to this hashtable. An - // ArgumentException is thrown if the key is null or if the key is already - // present in the hashtable. - // - //| - internal void Add(int key, Object value) { - Insert(key, value, true); - } - - //// Removes all entries from this hashtable. - ////| - //internal void Clear() { - // if (count == 0) - // return; - - // for (int i = 0; i < buckets.Length; i++) { - // buckets[i].hash_coll = 0; - // buckets[i].key = -1; - // buckets[i].val = null; - // } - - // count = 0; - // occupancy = 0; - //} - - // Checks if this hashtable contains an entry with the given key. This is - // an O(1) operation. - // - //| - //internal bool Contains(int key) { - // if (key < 0) { - // throw new ArgumentException("Argument_KeyLessThanZero"); - // } - - // uint seed; - // uint incr; - // // Take a snapshot of buckets, in case another thread resizes table - // bucket[] lbuckets = buckets; - // uint hashcode = InitHash(key, lbuckets.Length, out seed, out incr); - // int ntry = 0; - - // bucket b; - // do { - // int bucketNumber = (int)(seed % (uint)lbuckets.Length); - // b = lbuckets[bucketNumber]; - // if (b.val == null) { - // return false; - // } - // if (((b.hash_coll & 0x7FFFFFFF) == hashcode) && b.key == key) { - // return true; - // } - // seed += incr; - // } while (b.hash_coll < 0 && ++ntry < lbuckets.Length); - // return false; - //} - - // Returns the value associated with the given key. If an entry with the - // given key is not found, the returned value is null. - // - //| - internal Object this[int key] { - get { - if (key < 0) { - throw new ArgumentException("Argument_KeyLessThanZero"); - } - uint seed; - uint incr; - // Take a snapshot of buckets, in case another thread does a resize - bucket[] lbuckets = buckets; - uint hashcode = InitHash(key, lbuckets.Length, out seed, out incr); - int ntry = 0; - - bucket b; - do { - int bucketNumber = (int)(seed % (uint)lbuckets.Length); - b = lbuckets[bucketNumber]; - if (b.val == null) { - return null; - } - if (((b.hash_coll & 0x7FFFFFFF) == hashcode) && key == b.key) { - return b.val; - } - seed += incr; - } while (b.hash_coll < 0 && ++ntry < lbuckets.Length); - return null; - } - //set { - // Insert(key, value, false); - //} - } - - // Increases the bucket count of this hashtable. This method is called from - // the Insert method when the actual load factor of the hashtable reaches - // the upper limit specified when the hashtable was constructed. The number - // of buckets in the hashtable is increased to the smallest prime number - // that is larger than twice the current number of buckets, and the entries - // in the hashtable are redistributed into the new buckets using the cached - // hashcodes. - private void expand() { - rehash(GetPrime(1+buckets.Length*2)); - } - - // We occationally need to rehash the table to clean up the collision bits. - private void rehash() { - rehash(buckets.Length); - } - - private void rehash(int newsize) { - - // reset occupancy - occupancy=0; - - // Don't replace any internal state until we've finished adding to the - // new bucket[]. This serves two purposes: - // 1) Allow concurrent readers to see valid hashtable contents - // at all times - // 2) Protect against an OutOfMemoryException while allocating this - // new bucket[]. - bucket[] newBuckets = new bucket[newsize]; - - // rehash table into new buckets - int nb; - for (nb = 0; nb < buckets.Length; nb++) { - bucket oldb = buckets[nb]; - if (oldb.val != null) { - putEntry(newBuckets, oldb.key, oldb.val, oldb.hash_coll & 0x7FFFFFFF); - } - } - - // New bucket[] is good to go - replace buckets and other internal state. - version++; - buckets = newBuckets; - loadsize = (int)(loadFactorPerc * newsize) / 100; - - if (loadsize >= newsize) { - loadsize = newsize-1; - } - - return; - } - - // Returns an enumerator for this hashtable. - // If modifications made to the hashtable while an enumeration is - // in progress, the MoveNext and Current methods of the - // enumerator will throw an exception. - // - //| - //IEnumerator IEnumerable.GetEnumerator() { - // return new IntHashTableEnumerator(this); - //} - - // Internal method to compare two keys. - // - // Inserts an entry into this hashtable. This method is called from the Set - // and Add methods. If the add parameter is true and the given key already - // exists in the hashtable, an exception is thrown. - private void Insert(int key, Object nvalue, bool add) { - if (key < 0) { - throw new ArgumentException("Argument_KeyLessThanZero"); - } - if (nvalue == null) { - throw new ArgumentNullException("nvalue", "ArgumentNull_Value"); - } - if (count >= loadsize) { - expand(); - } else if (occupancy > loadsize && count > 100) { - rehash(); - } - - uint seed; - uint incr; - // Assume we only have one thread writing concurrently. Modify - // buckets to contain new data, as long as we insert in the right order. - uint hashcode = InitHash(key, buckets.Length, out seed, out incr); - int ntry = 0; - int emptySlotNumber = -1; // We use the empty slot number to cache the first empty slot. We chose to reuse slots - // create by remove that have the collision bit set over using up new slots. - - do { - int bucketNumber = (int)(seed % (uint)buckets.Length); - - // Set emptySlot number to current bucket if it is the first available bucket that we have seen - // that once contained an entry and also has had a collision. - // We need to search this entire collision chain because we have to ensure that there are no - // duplicate entries in the table. - - // Insert the key/value pair into this bucket if this bucket is empty and has never contained an entry - // OR - // This bucket once contained an entry but there has never been a collision - if (buckets[bucketNumber].val == null) { - // If we have found an available bucket that has never had a collision, but we've seen an available - // bucket in the past that has the collision bit set, use the previous bucket instead - if (emptySlotNumber != -1) { // Reuse slot - bucketNumber = emptySlotNumber; - } - - // We pretty much have to insert in this order. Don't set hash - // code until the value & key are set appropriately. - buckets[bucketNumber].val = nvalue; - buckets[bucketNumber].key = key; - buckets[bucketNumber].hash_coll |= (int)hashcode; - count++; - version++; - return; - } - - // The current bucket is in use - // OR - // it is available, but has had the collision bit set and we have already found an available bucket - if (((buckets[bucketNumber].hash_coll & 0x7FFFFFFF) == hashcode) && - key == buckets[bucketNumber].key) { - if (add) { - throw new ArgumentException("Argument_AddingDuplicate__" + buckets[bucketNumber].key); - } - buckets[bucketNumber].val = nvalue; - version++; - return; - } - - // The current bucket is full, and we have therefore collided. We need to set the collision bit - // UNLESS - // we have remembered an available slot previously. - if (emptySlotNumber == -1) {// We don't need to set the collision bit here since we already have an empty slot - if (buckets[bucketNumber].hash_coll >= 0) { - buckets[bucketNumber].hash_coll |= unchecked((int)0x80000000); - occupancy++; - } - } - seed += incr; - } while (++ntry < buckets.Length); - - // This code is here if and only if there were no buckets without a collision bit set in the entire table - if (emptySlotNumber != -1) { - // We pretty much have to insert in this order. Don't set hash - // code until the value & key are set appropriately. - buckets[emptySlotNumber].val = nvalue; - buckets[emptySlotNumber].key = key; - buckets[emptySlotNumber].hash_coll |= (int)hashcode; - count++; - version++; - return; - - } - - // If you see this assert, make sure load factor & count are reasonable. - // Then verify that our double hash function (h2, described at top of file) - // meets the requirements described above. You should never see this assert. - throw new InvalidOperationException("InvalidOperation_HashInsertFailed"); - } - - private void putEntry(bucket[] newBuckets, int key, Object nvalue, int hashcode) { - uint seed = (uint)hashcode; - uint incr = (uint)(1 + (((seed >> 5) + 1) % ((uint)newBuckets.Length - 1))); - - do { - int bucketNumber = (int)(seed % (uint)newBuckets.Length); - - if ((newBuckets[bucketNumber].val == null)) { - newBuckets[bucketNumber].val = nvalue; - newBuckets[bucketNumber].key = key; - newBuckets[bucketNumber].hash_coll |= hashcode; - return; - } - - if (newBuckets[bucketNumber].hash_coll >= 0) { - newBuckets[bucketNumber].hash_coll |= unchecked((int)0x80000000); - occupancy++; - } - seed += incr; - } while (true); - } - - // Returns the number of associations in this hashtable. - // - //| - //internal int Count { - // get { return count; } - //} - - // Implements an enumerator for a hashtable. The enumerator uses the - // internal version number of the hashtabke to ensure that no modifications - // are made to the hashtable while an enumeration is in progress. - //private class IntHashTableEnumerator : IEnumerator { - // private IntHashTable hashtable; - // private int bucket; - // private int version; - // private bool current; - // //private int currentKey; - // private Object currentValue; - - // internal IntHashTableEnumerator(IntHashTable hashtable) { - // this.hashtable = hashtable; - // bucket = hashtable.buckets.Length; - // version = hashtable.version; - // } - - // public bool MoveNext() { - // if (version != hashtable.version) - // throw new InvalidOperationException("InvalidOperation_EnumFailedVersion"); - // while (bucket > 0) { - // bucket--; - // Object val = hashtable.buckets[bucket].val; - // if (val != null) { - // //currentKey = hashtable.buckets[bucket].key; - // currentValue = val; - // current = true; - // return true; - // } - // } - // current = false; - // return false; - // } - - // //internal int Key { - // // get { - // // if (current == false) - // // throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen"); - // // return currentKey; - // // } - // //} - - // public Object Current { - // get { - // if (current == false) - // throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen"); - // return currentValue; - // } - // } - - // //public Object Value { - // // get { - // // if (version != hashtable.version) - // // throw new InvalidOperationException("InvalidOperation_EnumFailedVersion"); - // // if (current == false) - // // throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen"); - // // return currentValue; - // // } - // //} - - // public void Reset() { - // if (version != hashtable.version) throw new InvalidOperationException("InvalidOperation_EnumFailedVersion"); - // current = false; - // bucket = hashtable.buckets.Length; - // //currentKey = -1; - // currentValue = null; - // } - //} - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/Interfaces.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/Interfaces.cs deleted file mode 100644 index 82561fbcc0..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/Interfaces.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Microsoft.Cci { - - /// - /// A range of CLR IL operations that comprise a lexical scope, specified as an IL offset and a length. - /// - public interface ILocalScope { - /// - /// The offset of the first operation in the scope. - /// - uint Offset { get; } - - /// - /// The length of the scope. Offset+Length equals the offset of the first operation outside the scope, or equals the method body length. - /// - uint Length { get; } - } - - /// - /// A description of the lexical scope in which a namespace type has been nested. This scope is tied to a particular - /// method body, so that partial types can be accommodated. - /// - public interface INamespaceScope { - - /// - /// Zero or more used namespaces. These correspond to using clauses in C#. - /// - IEnumerable UsedNamespaces { get; } - - } - - - /// - /// A namespace that is used (imported) inside a namespace scope. - /// - public interface IUsedNamespace { - /// - /// An alias for a namespace. For example the "x" of "using x = y.z;" in C#. Empty if no alias is present. - /// - IName Alias { get; } - - /// - /// The name of a namepace that has been aliased. For example the "y.z" of "using x = y.z;" or "using y.z" in C#. - /// - IName NamespaceName { get; } - } - - /// - /// The name of an entity. Typically name instances come from a common pool. Within the pool no two distinct instances will have the same Value or UniqueKey. - /// - public interface IName { - /// - /// An integer that is unique within the pool from which the name instance has been allocated. Useful as a hashtable key. - /// - int UniqueKey { - get; - //^ ensures result > 0; - } - - /// - /// An integer that is unique within the pool from which the name instance has been allocated. Useful as a hashtable key. - /// All name instances in the pool that have the same string value when ignoring the case of the characters in the string - /// will have the same key value. - /// - int UniqueKeyIgnoringCase { - get; - //^ ensures result > 0; - } - - /// - /// The string value corresponding to this name. - /// - string Value { get; } - } -} \ No newline at end of file diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/LICENSE b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/LICENSE deleted file mode 100644 index 7bfc997e59..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Microsoft Public License (Ms-PL) - -This license governs use of the accompanying software. If you use the software, you -accept this license. If you do not accept the license, do not use the software. - -1. Definitions -The terms "reproduce," "reproduction," "derivative works," and "distribution" have the -same meaning here as under U.S. copyright law. -A "contribution" is the original software, or any additions or changes to the software. -A "contributor" is any person that distributes its contribution under this license. -"Licensed patents" are a contributor's patent claims that read directly on its contribution. - -2. Grant of Rights -(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. -(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. - -3. Conditions and Limitations -(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. -(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. -(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. -(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/MsfDirectory.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/MsfDirectory.cs deleted file mode 100644 index a6669b5bb5..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/MsfDirectory.cs +++ /dev/null @@ -1,58 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; - -namespace Microsoft.Cci.Pdb { - internal class MsfDirectory { - internal MsfDirectory(PdbReader reader, PdbFileHeader head, BitAccess bits) { - int pages = reader.PagesFromSize(head.directorySize); - - // 0..n in page of directory pages. - bits.MinCapacity(head.directorySize); - int directoryRootPages = head.directoryRoot.Length; - int pagesPerPage = head.pageSize / 4; - int pagesToGo = pages; - for (int i = 0; i < directoryRootPages; i++) { - int pagesInThisPage = pagesToGo <= pagesPerPage ? pagesToGo : pagesPerPage; - reader.Seek(head.directoryRoot[i], 0); - bits.Append(reader.reader, pagesInThisPage * 4); - pagesToGo -= pagesInThisPage; - } - bits.Position = 0; - - DataStream stream = new DataStream(head.directorySize, bits, pages); - bits.MinCapacity(head.directorySize); - stream.Read(reader, bits); - - // 0..3 in directory pages - int count; - bits.ReadInt32(out count); - - // 4..n - int[] sizes = new int[count]; - bits.ReadInt32(sizes); - - // n..m - streams = new DataStream[count]; - for (int i = 0; i < count; i++) { - if (sizes[i] <= 0) { - streams[i] = new DataStream(); - } else { - streams[i] = new DataStream(sizes[i], bits, - reader.PagesFromSize(sizes[i])); - } - } - } - - internal DataStream[] streams; - } - -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbConstant.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbConstant.cs deleted file mode 100644 index 434841b0cd..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbConstant.cs +++ /dev/null @@ -1,89 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; -using System.Runtime.InteropServices; - -namespace Microsoft.Cci.Pdb { - internal class PdbConstant { - internal string name; - internal uint token; - internal object value; - - internal PdbConstant(BitAccess bits) { - bits.ReadUInt32(out this.token); - byte tag1; - bits.ReadUInt8(out tag1); - byte tag2; - bits.ReadUInt8(out tag2); - if (tag2 == 0) { - this.value = tag1; - } else if (tag2 == 0x80) { - switch (tag1) { - case 0x00: //sbyte - sbyte sb; - bits.ReadInt8(out sb); - this.value = sb; - break; - case 0x01: //short - short s; - bits.ReadInt16(out s); - this.value = s; - break; - case 0x02: //ushort - ushort us; - bits.ReadUInt16(out us); - this.value = us; - break; - case 0x03: //int - int i; - bits.ReadInt32(out i); - this.value = i; - break; - case 0x04: //uint - uint ui; - bits.ReadUInt32(out ui); - this.value = ui; - break; - case 0x05: //float - this.value = bits.ReadFloat(); - break; - case 0x06: //double - this.value = bits.ReadDouble(); - break; - case 0x09: //long - long sl; - bits.ReadInt64(out sl); - this.value = sl; - break; - case 0x0a: //ulong - ulong ul; - bits.ReadUInt64(out ul); - this.value = ul; - break; - case 0x10: //string - string str; - bits.ReadBString(out str); - this.value = str; - break; - case 0x19: //decimal - this.value = bits.ReadDecimal(); - break; - default: - //TODO: error - break; - } - } else { - //TODO: error - } - bits.ReadCString(out name); - } - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbDebugException.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbDebugException.cs deleted file mode 100644 index d7f8f0fdbf..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbDebugException.cs +++ /dev/null @@ -1,20 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; -using System.IO; - -namespace Microsoft.Cci.Pdb { - internal class PdbDebugException : IOException { - internal PdbDebugException(String format, params object[] args) - : base(String.Format(format, args)) { - } - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbException.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbException.cs deleted file mode 100644 index 38d1d56368..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbException.cs +++ /dev/null @@ -1,20 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; -using System.IO; - -namespace Microsoft.Cci.Pdb { - internal class PdbException : IOException { - internal PdbException(String format, params object[] args) - : base(String.Format(format, args)) { - } - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs deleted file mode 100644 index 9435d6ef6a..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFile.cs +++ /dev/null @@ -1,537 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; - -using System.Collections.Generic; -using System.IO; -using Mono.Cecil.Cil; - -namespace Microsoft.Cci.Pdb { - internal class PdbFile { - private PdbFile() // This class can't be instantiated. - { - } - - static void LoadGuidStream(BitAccess bits, out Guid doctype, out Guid language, out Guid vendor) { - bits.ReadGuid(out language); - bits.ReadGuid(out vendor); - bits.ReadGuid(out doctype); - } - - static Dictionary LoadNameIndex(BitAccess bits, out int age, out Guid guid) { - Dictionary result = new Dictionary(); - int ver; - int sig; - bits.ReadInt32(out ver); // 0..3 Version - bits.ReadInt32(out sig); // 4..7 Signature - bits.ReadInt32(out age); // 8..11 Age - bits.ReadGuid(out guid); // 12..27 GUID - - //if (ver != 20000404) { - // throw new PdbDebugException("Unsupported PDB Stream version {0}", ver); - //} - - // Read string buffer. - int buf; - bits.ReadInt32(out buf); // 28..31 Bytes of Strings - - int beg = bits.Position; - int nxt = bits.Position + buf; - - bits.Position = nxt; - - // Read map index. - int cnt; // n+0..3 hash size. - int max; // n+4..7 maximum ni. - - bits.ReadInt32(out cnt); - bits.ReadInt32(out max); - - BitSet present = new BitSet(bits); - BitSet deleted = new BitSet(bits); - if (!deleted.IsEmpty) { - throw new PdbDebugException("Unsupported PDB deleted bitset is not empty."); - } - - int j = 0; - for (int i = 0; i < max; i++) { - if (present.IsSet(i)) { - int ns; - int ni; - bits.ReadInt32(out ns); - bits.ReadInt32(out ni); - - string name; - int saved = bits.Position; - bits.Position = beg + ns; - bits.ReadCString(out name); - bits.Position = saved; - - result.Add(name.ToUpperInvariant(), ni); - j++; - } - } - if (j != cnt) { - throw new PdbDebugException("Count mismatch. ({0} != {1})", j, cnt); - } - return result; - } - - static IntHashTable LoadNameStream(BitAccess bits) { - IntHashTable ht = new IntHashTable(); - - uint sig; - int ver; - bits.ReadUInt32(out sig); // 0..3 Signature - bits.ReadInt32(out ver); // 4..7 Version - - // Read (or skip) string buffer. - int buf; - bits.ReadInt32(out buf); // 8..11 Bytes of Strings - - if (sig != 0xeffeeffe || ver != 1) { - throw new PdbDebugException("Unsupported Name Stream version. "+ - "(sig={0:x8}, ver={1})", - sig, ver); - } - int beg = bits.Position; - int nxt = bits.Position + buf; - bits.Position = nxt; - - // Read hash table. - int siz; - bits.ReadInt32(out siz); // n+0..3 Number of hash buckets. - nxt = bits.Position; - - for (int i = 0; i < siz; i++) { - int ni; - string name; - - bits.ReadInt32(out ni); - - if (ni != 0) { - int saved = bits.Position; - bits.Position = beg + ni; - bits.ReadCString(out name); - bits.Position = saved; - - ht.Add(ni, name); - } - } - bits.Position = nxt; - - return ht; - } - - private static int FindFunction(PdbFunction[] funcs, ushort sec, uint off) { - var match = new PdbFunction { - segment = sec, - address = off, - }; - - return Array.BinarySearch(funcs, match, PdbFunction.byAddress); - } - - static void LoadManagedLines(PdbFunction[] funcs, - IntHashTable names, - BitAccess bits, - MsfDirectory dir, - Dictionary nameIndex, - PdbReader reader, - uint limit) { - Array.Sort(funcs, PdbFunction.byAddressAndToken); - - int begin = bits.Position; - IntHashTable checks = ReadSourceFileInfo(bits, limit, names, dir, nameIndex, reader); - - // Read the lines next. - bits.Position = begin; - while (bits.Position < limit) { - int sig; - int siz; - bits.ReadInt32(out sig); - bits.ReadInt32(out siz); - int endSym = bits.Position + siz; - - switch ((DEBUG_S_SUBSECTION)sig) { - case DEBUG_S_SUBSECTION.LINES: { - CV_LineSection sec; - - bits.ReadUInt32(out sec.off); - bits.ReadUInt16(out sec.sec); - bits.ReadUInt16(out sec.flags); - bits.ReadUInt32(out sec.cod); - int funcIndex = FindFunction(funcs, sec.sec, sec.off); - if (funcIndex < 0) break; - var func = funcs[funcIndex]; - if (func.lines == null) { - while (funcIndex > 0) { - var f = funcs[funcIndex-1]; - if (f.lines != null || f.segment != sec.sec || f.address != sec.off) break; - func = f; - funcIndex--; - } - } else { - while (funcIndex < funcs.Length-1 && func.lines != null) { - var f = funcs[funcIndex+1]; - if (f.segment != sec.sec || f.address != sec.off) break; - func = f; - funcIndex++; - } - } - if (func.lines != null) break; - - // Count the line blocks. - int begSym = bits.Position; - int blocks = 0; - while (bits.Position < endSym) { - CV_SourceFile file; - bits.ReadUInt32(out file.index); - bits.ReadUInt32(out file.count); - bits.ReadUInt32(out file.linsiz); // Size of payload. - int linsiz = (int)file.count * (8 + ((sec.flags & 1) != 0 ? 4 : 0)); - bits.Position += linsiz; - blocks++; - } - - func.lines = new PdbLines[blocks]; - int block = 0; - - bits.Position = begSym; - while (bits.Position < endSym) { - CV_SourceFile file; - bits.ReadUInt32(out file.index); - bits.ReadUInt32(out file.count); - bits.ReadUInt32(out file.linsiz); // Size of payload. - - PdbSource src = (PdbSource)checks[(int)file.index]; - PdbLines tmp = new PdbLines(src, file.count); - func.lines[block++] = tmp; - PdbLine[] lines = tmp.lines; - - int plin = bits.Position; - int pcol = bits.Position + 8 * (int)file.count; - - for (int i = 0; i < file.count; i++) { - CV_Line line; - CV_Column column = new CV_Column(); - - bits.Position = plin + 8 * i; - bits.ReadUInt32(out line.offset); - bits.ReadUInt32(out line.flags); - - uint lineBegin = line.flags & (uint)CV_Line_Flags.linenumStart; - uint delta = (line.flags & (uint)CV_Line_Flags.deltaLineEnd) >> 24; - //bool statement = ((line.flags & (uint)CV_Line_Flags.fStatement) == 0); - if ((sec.flags & 1) != 0) { - bits.Position = pcol + 4 * i; - bits.ReadUInt16(out column.offColumnStart); - bits.ReadUInt16(out column.offColumnEnd); - } - - lines[i] = new PdbLine(line.offset, - lineBegin, - column.offColumnStart, - lineBegin+delta, - column.offColumnEnd); - } - } - break; - } - } - bits.Position = endSym; - } - } - - static void LoadFuncsFromDbiModule(BitAccess bits, - DbiModuleInfo info, - IntHashTable names, - List funcList, - bool readStrings, - MsfDirectory dir, - Dictionary nameIndex, - PdbReader reader) { - PdbFunction[] funcs = null; - - bits.Position = 0; - int sig; - bits.ReadInt32(out sig); - if (sig != 4) { - throw new PdbDebugException("Invalid signature. (sig={0})", sig); - } - - bits.Position = 4; - // Console.WriteLine("{0}:", info.moduleName); - funcs = PdbFunction.LoadManagedFunctions(/*info.moduleName,*/ - bits, (uint)info.cbSyms, - readStrings); - if (funcs != null) { - bits.Position = info.cbSyms + info.cbOldLines; - LoadManagedLines(funcs, names, bits, dir, nameIndex, reader, - (uint)(info.cbSyms + info.cbOldLines + info.cbLines)); - - for (int i = 0; i < funcs.Length; i++) { - funcList.Add(funcs[i]); - } - } - } - - static void LoadDbiStream(BitAccess bits, - out DbiModuleInfo[] modules, - out DbiDbgHdr header, - bool readStrings) { - DbiHeader dh = new DbiHeader(bits); - header = new DbiDbgHdr(); - - //if (dh.sig != -1 || dh.ver != 19990903) { - // throw new PdbException("Unsupported DBI Stream version, sig={0}, ver={1}", - // dh.sig, dh.ver); - //} - - // Read gpmod section. - List modList = new List(); - int end = bits.Position + dh.gpmodiSize; - while (bits.Position < end) { - DbiModuleInfo mod = new DbiModuleInfo(bits, readStrings); - modList.Add(mod); - } - if (bits.Position != end) { - throw new PdbDebugException("Error reading DBI stream, pos={0} != {1}", - bits.Position, end); - } - - if (modList.Count > 0) { - modules = modList.ToArray(); - } else { - modules = null; - } - - // Skip the Section Contribution substream. - bits.Position += dh.secconSize; - - // Skip the Section Map substream. - bits.Position += dh.secmapSize; - - // Skip the File Info substream. - bits.Position += dh.filinfSize; - - // Skip the TSM substream. - bits.Position += dh.tsmapSize; - - // Skip the EC substream. - bits.Position += dh.ecinfoSize; - - // Read the optional header. - end = bits.Position + dh.dbghdrSize; - if (dh.dbghdrSize > 0) { - header = new DbiDbgHdr(bits); - } - bits.Position = end; - } - - internal static PdbFunction[] LoadFunctions(Stream read, out Dictionary tokenToSourceMapping, out string sourceServerData, out int age, out Guid guid) { - tokenToSourceMapping = new Dictionary(); - BitAccess bits = new BitAccess(512 * 1024); - PdbFileHeader head = new PdbFileHeader(read, bits); - PdbReader reader = new PdbReader(read, head.pageSize); - MsfDirectory dir = new MsfDirectory(reader, head, bits); - DbiModuleInfo[] modules = null; - DbiDbgHdr header; - - dir.streams[1].Read(reader, bits); - Dictionary nameIndex = LoadNameIndex(bits, out age, out guid); - int nameStream; - if (!nameIndex.TryGetValue("/NAMES", out nameStream)) { - throw new PdbException("No `name' stream"); - } - dir.streams[nameStream].Read(reader, bits); - IntHashTable names = LoadNameStream(bits); - - int srcsrvStream; - if (!nameIndex.TryGetValue("SRCSRV", out srcsrvStream)) - sourceServerData = string.Empty; - else { - DataStream dataStream = dir.streams[srcsrvStream]; - byte[] bytes = new byte[dataStream.contentSize]; - dataStream.Read(reader, bits); - sourceServerData = bits.ReadBString(bytes.Length); - } - - dir.streams[3].Read(reader, bits); - LoadDbiStream(bits, out modules, out header, true); - - List funcList = new List(); - - if (modules != null) { - for (int m = 0; m < modules.Length; m++) { - var module = modules[m]; - if (module.stream > 0) { - dir.streams[module.stream].Read(reader, bits); - if (module.moduleName == "TokenSourceLineInfo") { - LoadTokenToSourceInfo(bits, module, names, dir, nameIndex, reader, tokenToSourceMapping); - continue; - } - LoadFuncsFromDbiModule(bits, module, names, funcList, true, dir, nameIndex, reader); - } - } - } - - PdbFunction[] funcs = funcList.ToArray(); - - // After reading the functions, apply the token remapping table if it exists. - if (header.snTokenRidMap != 0 && header.snTokenRidMap != 0xffff) { - dir.streams[header.snTokenRidMap].Read(reader, bits); - uint[] ridMap = new uint[dir.streams[header.snTokenRidMap].Length / 4]; - bits.ReadUInt32(ridMap); - - foreach (PdbFunction func in funcs) { - func.token = 0x06000000 | ridMap[func.token & 0xffffff]; - } - } - - // - Array.Sort(funcs, PdbFunction.byAddressAndToken); - //Array.Sort(funcs, PdbFunction.byToken); - return funcs; - } - - private static void LoadTokenToSourceInfo(BitAccess bits, DbiModuleInfo module, IntHashTable names, MsfDirectory dir, - Dictionary nameIndex, PdbReader reader, Dictionary tokenToSourceMapping) { - bits.Position = 0; - int sig; - bits.ReadInt32(out sig); - if (sig != 4) { - throw new PdbDebugException("Invalid signature. (sig={0})", sig); - } - - bits.Position = 4; - - while (bits.Position < module.cbSyms) { - ushort siz; - ushort rec; - - bits.ReadUInt16(out siz); - int star = bits.Position; - int stop = bits.Position + siz; - bits.Position = star; - bits.ReadUInt16(out rec); - - switch ((SYM)rec) { - case SYM.S_OEM: - OemSymbol oem; - - bits.ReadGuid(out oem.idOem); - bits.ReadUInt32(out oem.typind); - // internal byte[] rgl; // user data, force 4-byte alignment - - if (oem.idOem == PdbFunction.msilMetaData) { - string name = bits.ReadString(); - if (name == "TSLI") { - uint token; - uint file_id; - uint line; - uint column; - uint endLine; - uint endColumn; - bits.ReadUInt32(out token); - bits.ReadUInt32(out file_id); - bits.ReadUInt32(out line); - bits.ReadUInt32(out column); - bits.ReadUInt32(out endLine); - bits.ReadUInt32(out endColumn); - PdbTokenLine tokenLine; - if (!tokenToSourceMapping.TryGetValue(token, out tokenLine)) - tokenToSourceMapping.Add(token, new PdbTokenLine(token, file_id, line, column, endLine, endColumn)); - else { - while (tokenLine.nextLine != null) tokenLine = tokenLine.nextLine; - tokenLine.nextLine = new PdbTokenLine(token, file_id, line, column, endLine, endColumn); - } - } - bits.Position = stop; - break; - } else { - throw new PdbDebugException("OEM section: guid={0} ti={1}", - oem.idOem, oem.typind); - // bits.Position = stop; - } - - case SYM.S_END: - bits.Position = stop; - break; - - default: - //Console.WriteLine("{0,6}: {1:x2} {2}", - // bits.Position, rec, (SYM)rec); - bits.Position = stop; - break; - } - } - - bits.Position = module.cbSyms + module.cbOldLines; - int limit = module.cbSyms + module.cbOldLines + module.cbLines; - IntHashTable sourceFiles = ReadSourceFileInfo(bits, (uint)limit, names, dir, nameIndex, reader); - foreach (var tokenLine in tokenToSourceMapping.Values) { - tokenLine.sourceFile = (PdbSource)sourceFiles[(int)tokenLine.file_id]; - } - - } - - private static IntHashTable ReadSourceFileInfo(BitAccess bits, uint limit, IntHashTable names, MsfDirectory dir, - Dictionary nameIndex, PdbReader reader) { - IntHashTable checks = new IntHashTable(); - - int begin = bits.Position; - while (bits.Position < limit) { - int sig; - int siz; - bits.ReadInt32(out sig); - bits.ReadInt32(out siz); - int place = bits.Position; - int endSym = bits.Position + siz; - - switch ((DEBUG_S_SUBSECTION)sig) { - case DEBUG_S_SUBSECTION.FILECHKSMS: - while (bits.Position < endSym) { - CV_FileCheckSum chk; - - int ni = bits.Position - place; - bits.ReadUInt32(out chk.name); - bits.ReadUInt8(out chk.len); - bits.ReadUInt8(out chk.type); - - string name = (string)names[(int)chk.name]; - int guidStream; - Guid doctypeGuid = DocumentType.Text.ToGuid(); - Guid languageGuid = Guid.Empty; - Guid vendorGuid = Guid.Empty; - if (nameIndex.TryGetValue("/SRC/FILES/"+name.ToUpperInvariant(), out guidStream)) { - var guidBits = new BitAccess(0x100); - dir.streams[guidStream].Read(reader, guidBits); - LoadGuidStream(guidBits, out doctypeGuid, out languageGuid, out vendorGuid); - } - - PdbSource src = new PdbSource(/*(uint)ni,*/ name, doctypeGuid, languageGuid, vendorGuid); - checks.Add(ni, src); - bits.Position += chk.len; - bits.Align(4); - } - bits.Position = endSym; - break; - - default: - bits.Position = endSym; - break; - } - } - return checks; - } - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFileHeader.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFileHeader.cs deleted file mode 100644 index 0a920388ac..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFileHeader.cs +++ /dev/null @@ -1,95 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; -using System.IO; -using System.Text; - -namespace Microsoft.Cci.Pdb { - internal class PdbFileHeader { - //internal PdbFileHeader(int pageSize) { - // this.magic = new byte[32] { - // 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, // "Microsof" - // 0x74, 0x20, 0x43, 0x2F, 0x43, 0x2B, 0x2B, 0x20, // "t C/C++ " - // 0x4D, 0x53, 0x46, 0x20, 0x37, 0x2E, 0x30, 0x30, // "MSF 7.00" - // 0x0D, 0x0A, 0x1A, 0x44, 0x53, 0x00, 0x00, 0x00 // "^^^DS^^^" - // }; - // this.pageSize = pageSize; - //} - - const string MAGIC = "Microsoft C/C++ MSF 7.00"; - - internal PdbFileHeader(Stream reader, BitAccess bits) { - bits.MinCapacity(56); - reader.Seek(0, SeekOrigin.Begin); - bits.FillBuffer(reader, 52); - - this.magic = new byte[32]; - bits.ReadBytes(this.magic); // 0..31 - bits.ReadInt32(out this.pageSize); // 32..35 - bits.ReadInt32(out this.freePageMap); // 36..39 - bits.ReadInt32(out this.pagesUsed); // 40..43 - bits.ReadInt32(out this.directorySize); // 44..47 - bits.ReadInt32(out this.zero); // 48..51 - - if (Magic != MAGIC) { - throw new InvalidOperationException("Magic is wrong."); - } - int directoryPages = ((((directorySize + pageSize - 1) / pageSize) * 4) + pageSize - 1) / pageSize; - this.directoryRoot = new int[directoryPages]; - bits.FillBuffer(reader, directoryPages * 4); - bits.ReadInt32(this.directoryRoot); - } - - string Magic { - get { return StringFromBytesUTF8(magic, 0, MAGIC.Length); } - } - - //internal void Write(Stream writer, BitAccess bits) { - // bits.MinCapacity(pageSize); - // bits.WriteBytes(magic); // 0..31 - // bits.WriteInt32(pageSize); // 32..35 - // bits.WriteInt32(freePageMap); // 36..39 - // bits.WriteInt32(pagesUsed); // 40..43 - // bits.WriteInt32(directorySize); // 44..47 - // bits.WriteInt32(zero); // 48..51 - // bits.WriteInt32(directoryRoot); // 52..55 - - // writer.Seek(0, SeekOrigin.Begin); - // bits.WriteBuffer(writer, pageSize); - //} - - //////////////////////////////////////////////////// Helper Functions. - // - static string StringFromBytesUTF8(byte[] bytes) { - return StringFromBytesUTF8(bytes, 0, bytes.Length); - } - - static string StringFromBytesUTF8(byte[] bytes, int offset, int length) { - for (int i = 0; i < length; i++) { - if (bytes[offset + i] < ' ') { - length = i; - } - } - return Encoding.UTF8.GetString(bytes, offset, length); - } - - ////////////////////////////////////////////////////////////// Fields. - // - internal readonly byte[] magic; - internal readonly int pageSize; - internal int freePageMap; - internal int pagesUsed; - internal int directorySize; - internal readonly int zero; - internal int[] directoryRoot; - } - -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs deleted file mode 100644 index b02b97fee1..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbFunction.cs +++ /dev/null @@ -1,498 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; -using System.Collections; -using System.Collections.Generic; - -namespace Microsoft.Cci.Pdb { - internal class PdbFunction { - static internal readonly Guid msilMetaData = new Guid(0xc6ea3fc9, 0x59b3, 0x49d6, 0xbc, 0x25, - 0x09, 0x02, 0xbb, 0xab, 0xb4, 0x60); - static internal readonly IComparer byAddress = new PdbFunctionsByAddress(); - static internal readonly IComparer byAddressAndToken = new PdbFunctionsByAddressAndToken(); - //static internal readonly IComparer byToken = new PdbFunctionsByToken(); - - internal uint token; - internal uint slotToken; - internal uint tokenOfMethodWhoseUsingInfoAppliesToThisMethod; - //internal string name; - //internal string module; - //internal ushort flags; - - internal uint segment; - internal uint address; - internal uint length; - - //internal byte[] metadata; - internal PdbScope[] scopes; - internal PdbSlot[] slots; - internal PdbConstant[] constants; - internal string[] usedNamespaces; - internal PdbLines[] lines; - internal ushort[]/*?*/ usingCounts; - internal IEnumerable/*?*/ namespaceScopes; - internal string/*?*/ iteratorClass; - internal List/*?*/ iteratorScopes; - internal PdbSynchronizationInformation/*?*/ synchronizationInformation; - - private static string StripNamespace(string module) { - int li = module.LastIndexOf('.'); - if (li > 0) { - return module.Substring(li + 1); - } - return module; - } - - - internal static PdbFunction[] LoadManagedFunctions(/*string module,*/ - BitAccess bits, uint limit, - bool readStrings) { - //string mod = StripNamespace(module); - int begin = bits.Position; - int count = 0; - - while (bits.Position < limit) { - ushort siz; - ushort rec; - - bits.ReadUInt16(out siz); - int star = bits.Position; - int stop = bits.Position + siz; - bits.Position = star; - bits.ReadUInt16(out rec); - - switch ((SYM)rec) { - case SYM.S_GMANPROC: - case SYM.S_LMANPROC: - ManProcSym proc; - bits.ReadUInt32(out proc.parent); - bits.ReadUInt32(out proc.end); - bits.Position = (int)proc.end; - count++; - break; - - case SYM.S_END: - bits.Position = stop; - break; - - default: - //Console.WriteLine("{0,6}: {1:x2} {2}", - // bits.Position, rec, (SYM)rec); - bits.Position = stop; - break; - } - } - if (count == 0) { - return null; - } - - bits.Position = begin; - PdbFunction[] funcs = new PdbFunction[count]; - int func = 0; - - while (bits.Position < limit) { - ushort siz; - ushort rec; - - bits.ReadUInt16(out siz); - int star = bits.Position; - int stop = bits.Position + siz; - bits.ReadUInt16(out rec); - - switch ((SYM)rec) { - - case SYM.S_GMANPROC: - case SYM.S_LMANPROC: - ManProcSym proc; - //int offset = bits.Position; - - bits.ReadUInt32(out proc.parent); - bits.ReadUInt32(out proc.end); - bits.ReadUInt32(out proc.next); - bits.ReadUInt32(out proc.len); - bits.ReadUInt32(out proc.dbgStart); - bits.ReadUInt32(out proc.dbgEnd); - bits.ReadUInt32(out proc.token); - bits.ReadUInt32(out proc.off); - bits.ReadUInt16(out proc.seg); - bits.ReadUInt8(out proc.flags); - bits.ReadUInt16(out proc.retReg); - if (readStrings) { - bits.ReadCString(out proc.name); - } else { - bits.SkipCString(out proc.name); - } - //Console.WriteLine("token={0:X8} [{1}::{2}]", proc.token, module, proc.name); - - bits.Position = stop; - funcs[func++] = new PdbFunction(/*module,*/ proc, bits); - break; - - default: { - //throw new PdbDebugException("Unknown SYMREC {0}", (SYM)rec); - bits.Position = stop; - break; - } - } - } - return funcs; - } - - internal static void CountScopesAndSlots(BitAccess bits, uint limit, - out int constants, out int scopes, out int slots, out int usedNamespaces) { - int pos = bits.Position; - BlockSym32 block; - constants = 0; - slots = 0; - scopes = 0; - usedNamespaces = 0; - - while (bits.Position < limit) { - ushort siz; - ushort rec; - - bits.ReadUInt16(out siz); - int star = bits.Position; - int stop = bits.Position + siz; - bits.Position = star; - bits.ReadUInt16(out rec); - - switch ((SYM)rec) { - case SYM.S_BLOCK32: { - bits.ReadUInt32(out block.parent); - bits.ReadUInt32(out block.end); - - scopes++; - bits.Position = (int)block.end; - break; - } - - case SYM.S_MANSLOT: - slots++; - bits.Position = stop; - break; - - case SYM.S_UNAMESPACE: - usedNamespaces++; - bits.Position = stop; - break; - - case SYM.S_MANCONSTANT: - constants++; - bits.Position = stop; - break; - - default: - bits.Position = stop; - break; - } - } - bits.Position = pos; - } - - internal PdbFunction() { - } - - internal PdbFunction(/*string module, */ManProcSym proc, BitAccess bits) { - this.token = proc.token; - //this.module = module; - //this.name = proc.name; - //this.flags = proc.flags; - this.segment = proc.seg; - this.address = proc.off; - this.length = proc.len; - - if (proc.seg != 1) { - throw new PdbDebugException("Segment is {0}, not 1.", proc.seg); - } - if (proc.parent != 0 || proc.next != 0) { - throw new PdbDebugException("Warning parent={0}, next={1}", - proc.parent, proc.next); - } - //if (proc.dbgStart != 0 || proc.dbgEnd != 0) { - // throw new PdbDebugException("Warning DBG start={0}, end={1}", - // proc.dbgStart, proc.dbgEnd); - //} - - int constantCount; - int scopeCount; - int slotCount; - int usedNamespacesCount; - CountScopesAndSlots(bits, proc.end, out constantCount, out scopeCount, out slotCount, out usedNamespacesCount); - int scope = constantCount > 0 || slotCount > 0 || usedNamespacesCount > 0 ? 1 : 0; - int slot = 0; - int constant = 0; - int usedNs = 0; - scopes = new PdbScope[scopeCount+scope]; - slots = new PdbSlot[slotCount]; - constants = new PdbConstant[constantCount]; - usedNamespaces = new string[usedNamespacesCount]; - - if (scope > 0) - scopes[0] = new PdbScope(this.address, proc.len, slots, constants, usedNamespaces); - - while (bits.Position < proc.end) { - ushort siz; - ushort rec; - - bits.ReadUInt16(out siz); - int star = bits.Position; - int stop = bits.Position + siz; - bits.Position = star; - bits.ReadUInt16(out rec); - - switch ((SYM)rec) { - case SYM.S_OEM: { // 0x0404 - OemSymbol oem; - - bits.ReadGuid(out oem.idOem); - bits.ReadUInt32(out oem.typind); - // internal byte[] rgl; // user data, force 4-byte alignment - - if (oem.idOem == msilMetaData) { - string name = bits.ReadString(); - if (name == "MD2") { - byte version; - bits.ReadUInt8(out version); - if (version == 4) { - byte count; - bits.ReadUInt8(out count); - bits.Align(4); - while (count-- > 0) - this.ReadCustomMetadata(bits); - } - } else if (name == "asyncMethodInfo") { - this.synchronizationInformation = new PdbSynchronizationInformation(bits); - } - bits.Position = stop; - break; - } else { - throw new PdbDebugException("OEM section: guid={0} ti={1}", - oem.idOem, oem.typind); - // bits.Position = stop; - } - } - - case SYM.S_BLOCK32: { - BlockSym32 block = new BlockSym32(); - - bits.ReadUInt32(out block.parent); - bits.ReadUInt32(out block.end); - bits.ReadUInt32(out block.len); - bits.ReadUInt32(out block.off); - bits.ReadUInt16(out block.seg); - bits.SkipCString(out block.name); - bits.Position = stop; - - scopes[scope++] = new PdbScope(this.address, block, bits, out slotToken); - bits.Position = (int)block.end; - break; - } - - case SYM.S_MANSLOT: - slots[slot++] = new PdbSlot(bits); - bits.Position = stop; - break; - - case SYM.S_MANCONSTANT: - constants[constant++] = new PdbConstant(bits); - bits.Position = stop; - break; - - case SYM.S_UNAMESPACE: - bits.ReadCString(out usedNamespaces[usedNs++]); - bits.Position = stop; - break; - - case SYM.S_END: - bits.Position = stop; - break; - - default: { - //throw new PdbDebugException("Unknown SYM: {0}", (SYM)rec); - bits.Position = stop; - break; - } - } - } - - if (bits.Position != proc.end) { - throw new PdbDebugException("Not at S_END"); - } - - ushort esiz; - ushort erec; - bits.ReadUInt16(out esiz); - bits.ReadUInt16(out erec); - - if (erec != (ushort)SYM.S_END) { - throw new PdbDebugException("Missing S_END"); - } - } - - private void ReadCustomMetadata(BitAccess bits) { - int savedPosition = bits.Position; - byte version; - bits.ReadUInt8(out version); - if (version != 4) { - throw new PdbDebugException("Unknown custom metadata item version: {0}", version); - } - byte kind; - bits.ReadUInt8(out kind); - bits.Align(4); - uint numberOfBytesInItem; - bits.ReadUInt32(out numberOfBytesInItem); - switch (kind) { - case 0: this.ReadUsingInfo(bits); break; - case 1: this.ReadForwardInfo(bits); break; - case 2: break; // this.ReadForwardedToModuleInfo(bits); break; - case 3: this.ReadIteratorLocals(bits); break; - case 4: this.ReadForwardIterator(bits); break; - // TODO: handle unknown custom metadata, 5 & 6 are new with roslyn, see https://roslyn.codeplex.com/workitem/54 - } - bits.Position = savedPosition+(int)numberOfBytesInItem; - } - - private void ReadForwardIterator(BitAccess bits) { - this.iteratorClass = bits.ReadString(); - } - - private void ReadIteratorLocals(BitAccess bits) { - uint numberOfLocals; - bits.ReadUInt32(out numberOfLocals); - this.iteratorScopes = new List((int)numberOfLocals); - while (numberOfLocals-- > 0) { - uint ilStartOffset; - uint ilEndOffset; - bits.ReadUInt32(out ilStartOffset); - bits.ReadUInt32(out ilEndOffset); - this.iteratorScopes.Add(new PdbIteratorScope(ilStartOffset, ilEndOffset-ilStartOffset)); - } - } - - //private void ReadForwardedToModuleInfo(BitAccess bits) { - //} - - private void ReadForwardInfo(BitAccess bits) { - bits.ReadUInt32(out this.tokenOfMethodWhoseUsingInfoAppliesToThisMethod); - } - - private void ReadUsingInfo(BitAccess bits) { - ushort numberOfNamespaces; - bits.ReadUInt16(out numberOfNamespaces); - this.usingCounts = new ushort[numberOfNamespaces]; - for (ushort i = 0; i < numberOfNamespaces; i++) { - bits.ReadUInt16(out this.usingCounts[i]); - } - } - - internal class PdbFunctionsByAddress : IComparer { - public int Compare(Object x, Object y) { - PdbFunction fx = (PdbFunction)x; - PdbFunction fy = (PdbFunction)y; - - if (fx.segment < fy.segment) { - return -1; - } else if (fx.segment > fy.segment) { - return 1; - } else if (fx.address < fy.address) { - return -1; - } else if (fx.address > fy.address) { - return 1; - } else { - return 0; - } - } - } - - internal class PdbFunctionsByAddressAndToken : IComparer { - public int Compare(Object x, Object y) { - PdbFunction fx = (PdbFunction)x; - PdbFunction fy = (PdbFunction)y; - - if (fx.segment < fy.segment) { - return -1; - } else if (fx.segment > fy.segment) { - return 1; - } else if (fx.address < fy.address) { - return -1; - } else if (fx.address > fy.address) { - return 1; - } else { - if (fx.token < fy.token) - return -1; - else if (fx.token > fy.token) - return 1; - else - return 0; - } - } - } - - //internal class PdbFunctionsByToken : IComparer { - // public int Compare(Object x, Object y) { - // PdbFunction fx = (PdbFunction)x; - // PdbFunction fy = (PdbFunction)y; - - // if (fx.token < fy.token) { - // return -1; - // } else if (fx.token > fy.token) { - // return 1; - // } else { - // return 0; - // } - // } - - //} - } - - internal class PdbSynchronizationInformation { - internal uint kickoffMethodToken; - internal uint generatedCatchHandlerIlOffset; - internal PdbSynchronizationPoint[] synchronizationPoints; - - internal PdbSynchronizationInformation(BitAccess bits) { - uint asyncStepInfoCount; - bits.ReadUInt32(out this.kickoffMethodToken); - bits.ReadUInt32(out this.generatedCatchHandlerIlOffset); - bits.ReadUInt32(out asyncStepInfoCount); - this.synchronizationPoints = new PdbSynchronizationPoint[asyncStepInfoCount]; - for (uint i = 0; i < asyncStepInfoCount; i += 1) { - this.synchronizationPoints[i] = new PdbSynchronizationPoint(bits); - } - } - - public uint GeneratedCatchHandlerOffset { - get { return this.generatedCatchHandlerIlOffset; } - } - } - - internal class PdbSynchronizationPoint { - internal uint synchronizeOffset; - internal uint continuationMethodToken; - internal uint continuationOffset; - - internal PdbSynchronizationPoint(BitAccess bits) { - bits.ReadUInt32(out this.synchronizeOffset); - bits.ReadUInt32(out this.continuationMethodToken); - bits.ReadUInt32(out this.continuationOffset); - } - - public uint SynchronizeOffset { - get { return this.synchronizeOffset; } - } - - public uint ContinuationOffset { - get { return this.continuationOffset; } - } - } - -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbLine.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbLine.cs deleted file mode 100644 index f6fe3a9d3e..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbLine.cs +++ /dev/null @@ -1,29 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; - -namespace Microsoft.Cci.Pdb { - internal struct PdbLine { - internal uint offset; - internal uint lineBegin; - internal uint lineEnd; - internal ushort colBegin; - internal ushort colEnd; - - internal PdbLine(uint offset, uint lineBegin, ushort colBegin, uint lineEnd, ushort colEnd) { - this.offset = offset; - this.lineBegin = lineBegin; - this.colBegin = colBegin; - this.lineEnd = lineEnd; - this.colEnd = colEnd; - } - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbLines.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbLines.cs deleted file mode 100644 index 382638b70f..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbLines.cs +++ /dev/null @@ -1,23 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; - -namespace Microsoft.Cci.Pdb { - internal class PdbLines { - internal PdbSource file; - internal PdbLine[] lines; - - internal PdbLines(PdbSource file, uint count) { - this.file = file; - this.lines = new PdbLine[count]; - } - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbReader.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbReader.cs deleted file mode 100644 index edfd9263c9..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbReader.cs +++ /dev/null @@ -1,40 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; -using System.IO; - -namespace Microsoft.Cci.Pdb { - internal class PdbReader { - internal PdbReader(Stream reader, int pageSize) { - this.pageSize = pageSize; - this.reader = reader; - } - - internal void Seek(int page, int offset) { - reader.Seek(page * pageSize + offset, SeekOrigin.Begin); - } - - internal void Read(byte[] bytes, int offset, int count) { - reader.Read(bytes, offset, count); - } - - internal int PagesFromSize(int size) { - return (size + pageSize - 1) / (pageSize); - } - - //internal int PageSize { - // get { return pageSize; } - //} - - internal readonly int pageSize; - internal readonly Stream reader; - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs deleted file mode 100644 index 92ac385e99..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbScope.cs +++ /dev/null @@ -1,122 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; - -namespace Microsoft.Cci.Pdb { - internal class PdbScope { - internal PdbConstant[] constants; - internal PdbSlot[] slots; - internal PdbScope[] scopes; - internal string[] usedNamespaces; - - //internal uint segment; - internal uint address; - internal uint offset; - internal uint length; - - internal PdbScope(uint address, uint length, PdbSlot[] slots, PdbConstant[] constants, string[] usedNamespaces) { - this.constants = constants; - this.slots = slots; - this.scopes = new PdbScope[0]; - this.usedNamespaces = usedNamespaces; - this.address = address; - this.offset = 0; - this.length = length; - } - - internal PdbScope(uint funcOffset, BlockSym32 block, BitAccess bits, out uint typind) { - //this.segment = block.seg; - this.address = block.off; - this.offset = block.off - funcOffset; - this.length = block.len; - typind = 0; - - int constantCount; - int scopeCount; - int slotCount; - int namespaceCount; - PdbFunction.CountScopesAndSlots(bits, block.end, out constantCount, out scopeCount, out slotCount, out namespaceCount); - constants = new PdbConstant[constantCount]; - scopes = new PdbScope[scopeCount]; - slots = new PdbSlot[slotCount]; - usedNamespaces = new string[namespaceCount]; - int constant = 0; - int scope = 0; - int slot = 0; - int usedNs = 0; - - while (bits.Position < block.end) { - ushort siz; - ushort rec; - - bits.ReadUInt16(out siz); - int star = bits.Position; - int stop = bits.Position + siz; - bits.Position = star; - bits.ReadUInt16(out rec); - - switch ((SYM)rec) { - case SYM.S_BLOCK32: { - BlockSym32 sub = new BlockSym32(); - - bits.ReadUInt32(out sub.parent); - bits.ReadUInt32(out sub.end); - bits.ReadUInt32(out sub.len); - bits.ReadUInt32(out sub.off); - bits.ReadUInt16(out sub.seg); - bits.SkipCString(out sub.name); - - bits.Position = stop; - scopes[scope++] = new PdbScope(funcOffset, sub, bits, out typind); - break; - } - - case SYM.S_MANSLOT: - slots[slot++] = new PdbSlot(bits); - bits.Position = stop; - break; - - case SYM.S_UNAMESPACE: - bits.ReadCString(out usedNamespaces[usedNs++]); - bits.Position = stop; - break; - - case SYM.S_END: - bits.Position = stop; - break; - - case SYM.S_MANCONSTANT: - constants[constant++] = new PdbConstant(bits); - bits.Position = stop; - break; - - default: - //throw new PdbException("Unknown SYM in scope {0}", (SYM)rec); - bits.Position = stop; - break; - } - } - - if (bits.Position != block.end) { - throw new Exception("Not at S_END"); - } - - ushort esiz; - ushort erec; - bits.ReadUInt16(out esiz); - bits.ReadUInt16(out erec); - - if (erec != (ushort)SYM.S_END) { - throw new Exception("Missing S_END"); - } - } - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs deleted file mode 100644 index e2b76d5fb8..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSlot.cs +++ /dev/null @@ -1,41 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; - -namespace Microsoft.Cci.Pdb { - internal class PdbSlot { - internal uint slot; - internal uint typeToken; - internal string name; - internal ushort flags; - //internal uint segment; - //internal uint address; - - internal PdbSlot(BitAccess bits) { - AttrSlotSym slot; - - bits.ReadUInt32(out slot.index); - bits.ReadUInt32(out slot.typind); - bits.ReadUInt32(out slot.offCod); - bits.ReadUInt16(out slot.segCod); - bits.ReadUInt16(out slot.flags); - bits.ReadCString(out slot.name); - - this.slot = slot.index; - this.typeToken = slot.typind; - this.name = slot.name; - this.flags = slot.flags; - //this.segment = slot.segCod; - //this.address = slot.offCod; - - } - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSource.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSource.cs deleted file mode 100644 index ac40f85160..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbSource.cs +++ /dev/null @@ -1,29 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; - -namespace Microsoft.Cci.Pdb { - internal class PdbSource { - //internal uint index; - internal string name; - internal Guid doctype; - internal Guid language; - internal Guid vendor; - - internal PdbSource(/*uint index, */string name, Guid doctype, Guid language, Guid vendor) { - //this.index = index; - this.name = name; - this.doctype = doctype; - this.language = language; - this.vendor = vendor; - } - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbTokenLine.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbTokenLine.cs deleted file mode 100644 index 879339b23a..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbTokenLine.cs +++ /dev/null @@ -1,33 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//----------------------------------------------------------------------------- -using System; - -namespace Microsoft.Cci.Pdb { - internal class PdbTokenLine { - internal uint token; - internal uint file_id; - internal uint line; - internal uint column; - internal uint endLine; - internal uint endColumn; - internal PdbSource sourceFile; - internal PdbTokenLine/*?*/ nextLine; - - internal PdbTokenLine(uint token, uint file_id, uint line, uint column, uint endLine, uint endColumn) { - this.token = token; - this.file_id = file_id; - this.line = line; - this.column = column; - this.endLine = endLine; - this.endColumn = endColumn; - } - } -} diff --git a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/SourceLocationProvider.cs b/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/SourceLocationProvider.cs deleted file mode 100644 index 1c4da186a4..0000000000 --- a/external/linker/cecil/symbols/pdb/Microsoft.Cci.Pdb/SourceLocationProvider.cs +++ /dev/null @@ -1,32 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -//----------------------------------------------------------------------------- -using System; -using System.Collections.Generic; -using System.IO; -using Microsoft.Cci; -using Microsoft.Cci.Pdb; -using System.Text; - -namespace Microsoft.Cci { - - internal sealed class PdbIteratorScope : ILocalScope { - - internal PdbIteratorScope(uint offset, uint length) { - this.offset = offset; - this.length = length; - } - - public uint Offset { - get { return this.offset; } - } - uint offset; - - public uint Length { - get { return this.length; } - } - uint length; - } -} \ No newline at end of file diff --git a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb.csproj b/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb.csproj deleted file mode 100644 index eeebce1520..0000000000 --- a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - {63E6915C-7EA4-4D76-AB28-0D7191EEA626} - Mono.Cecil.Pdb - Mono.Cecil.Pdb - 0649 - - - - {D68133BD-1E63-496E-9EDE-4FBDBF77B486} - Mono.Cecil - - - - - - - - - - diff --git a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/AssemblyInfo.cs b/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/AssemblyInfo.cs deleted file mode 100644 index c4b4e2e9e0..0000000000 --- a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/AssemblyInfo.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Reflection; - -[assembly: AssemblyTitle ("Mono.Cecil.Pdb")] - -[assembly: CLSCompliant (false)] diff --git a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedDocumentWriter.cs b/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedDocumentWriter.cs deleted file mode 100644 index f694e2701c..0000000000 --- a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedDocumentWriter.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Author: -// Juerg Billeter (j@bitron.ch) -// -// (C) 2008 Juerg Billeter -// -// Licensed under the MIT/X11 license. -// - -using System.Runtime.InteropServices; - -#if !READ_ONLY - -namespace Mono.Cecil.Pdb { - - [Guid ("B01FAFEB-C450-3A4D-BEEC-B4CEEC01E006")] - [InterfaceType (ComInterfaceType.InterfaceIsIUnknown)] - [ComImport] - interface ISymUnmanagedDocumentWriter { - } -} - -#endif diff --git a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedWriter2.cs b/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedWriter2.cs deleted file mode 100644 index 81cc6a3a90..0000000000 --- a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/ISymUnmanagedWriter2.cs +++ /dev/null @@ -1,90 +0,0 @@ -// -// Author: -// Juerg Billeter (j@bitron.ch) -// -// (C) 2008 Juerg Billeter -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Runtime.InteropServices; -using System.Runtime.InteropServices.ComTypes; - -using Mono.Cecil.Cil; - -#if !READ_ONLY - -namespace Mono.Cecil.Pdb { - - [Guid ("0B97726E-9E6D-4f05-9A26-424022093CAA")] - [InterfaceType (ComInterfaceType.InterfaceIsIUnknown)] - [ComImport] - interface ISymUnmanagedWriter2 { - - void DefineDocument ( - [In, MarshalAs (UnmanagedType.LPWStr)] string url, - [In] ref Guid langauge, - [In] ref Guid languageVendor, - [In] ref Guid documentType, - [Out, MarshalAs (UnmanagedType.Interface)] out ISymUnmanagedDocumentWriter pRetVal); - void SetUserEntryPoint ([In] int methodToken); - void OpenMethod ([In] int methodToken); - void CloseMethod (); - void OpenScope ([In] int startOffset, [Out] out int pRetVal); - void CloseScope ([In] int endOffset); - void SetScopeRange_Placeholder (); - void DefineLocalVariable_Placeholder (); - void DefineParameter_Placeholder (); - void DefineField_Placeholder (); - void DefineGlobalVariable_Placeholder (); - void Close (); - void SetSymAttribute (uint parent, string name, uint data, IntPtr signature); - void OpenNamespace ([In, MarshalAs (UnmanagedType.LPWStr)] string name); - void CloseNamespace (); - void UsingNamespace ([In, MarshalAs (UnmanagedType.LPWStr)] string fullName); - void SetMethodSourceRange_Placeholder (); - void Initialize ( - [In, MarshalAs (UnmanagedType.IUnknown)] object emitter, - [In, MarshalAs (UnmanagedType.LPWStr)] string filename, - [In] IStream pIStream, - [In] bool fFullBuild); - void GetDebugInfo ( - [Out] out ImageDebugDirectory pIDD, - [In] int cData, - [Out] out int pcData, - [In, Out, MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 1)] byte [] data); - void DefineSequencePoints ( - [In, MarshalAs (UnmanagedType.Interface)] ISymUnmanagedDocumentWriter document, - [In] int spCount, - [In, MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 1)] int [] offsets, - [In, MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 1)] int [] lines, - [In, MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 1)] int [] columns, - [In, MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 1)] int [] endLines, - [In, MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 1)] int [] endColumns); - void RemapToken_Placeholder (); - void Initialize2_Placeholder (); - void DefineConstant_Placeholder (); - void Abort_Placeholder (); - - void DefineLocalVariable2 ( - [In, MarshalAs (UnmanagedType.LPWStr)] string name, - [In] int attributes, - [In] int sigToken, - [In] int addrKind, - [In] int addr1, - [In] int addr2, - [In] int addr3, - [In] int startOffset, - [In] int endOffset); - - void DefineGlobalVariable2_Placeholder (); - - void DefineConstant2 ( - [In, MarshalAs (UnmanagedType.LPWStr)] string name, - [In, MarshalAs (UnmanagedType.Struct)] object variant, - [In] int sigToken); - } -} - -#endif diff --git a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/ModuleMetadata.cs b/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/ModuleMetadata.cs deleted file mode 100644 index b175c06a4e..0000000000 --- a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/ModuleMetadata.cs +++ /dev/null @@ -1,796 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Text; - -#if !READ_ONLY - -namespace Mono.Cecil.Pdb { - - [ComImport, InterfaceType (ComInterfaceType.InterfaceIsIUnknown), Guid ("BA3FEE4C-ECB9-4e41-83B7-183FA41CD859")] - interface IMetaDataEmit { - void SetModuleProps (string szName); - void Save (string szFile, uint dwSaveFlags); - void SaveToStream (IntPtr pIStream, uint dwSaveFlags); - uint GetSaveSize (uint fSave); - uint DefineTypeDef (IntPtr szTypeDef, uint dwTypeDefFlags, uint tkExtends, IntPtr rtkImplements); - uint DefineNestedType (IntPtr szTypeDef, uint dwTypeDefFlags, uint tkExtends, IntPtr rtkImplements, uint tdEncloser); - void SetHandler ([MarshalAs (UnmanagedType.IUnknown), In]object pUnk); - uint DefineMethod (uint td, IntPtr zName, uint dwMethodFlags, IntPtr pvSigBlob, uint cbSigBlob, uint ulCodeRVA, uint dwImplFlags); - void DefineMethodImpl (uint td, uint tkBody, uint tkDecl); - uint DefineTypeRefByName (uint tkResolutionScope, IntPtr szName); - uint DefineImportType (IntPtr pAssemImport, IntPtr pbHashValue, uint cbHashValue, IMetaDataImport pImport, - uint tdImport, IntPtr pAssemEmit); - uint DefineMemberRef (uint tkImport, string szName, IntPtr pvSigBlob, uint cbSigBlob); - uint DefineImportMember (IntPtr pAssemImport, IntPtr /* void* */ pbHashValue, uint cbHashValue, - IMetaDataImport pImport, uint mbMember, IntPtr pAssemEmit, uint tkParent); - uint DefineEvent (uint td, string szEvent, uint dwEventFlags, uint tkEventType, uint mdAddOn, uint mdRemoveOn, uint mdFire, IntPtr /* uint* */ rmdOtherMethods); - void SetClassLayout (uint td, uint dwPackSize, IntPtr /*COR_FIELD_OFFSET**/ rFieldOffsets, uint ulClassSize); - void DeleteClassLayout (uint td); - void SetFieldMarshal (uint tk, IntPtr /* byte* */ pvNativeType, uint cbNativeType); - void DeleteFieldMarshal (uint tk); - uint DefinePermissionSet (uint tk, uint dwAction, IntPtr /* void* */ pvPermission, uint cbPermission); - void SetRVA (uint md, uint ulRVA); - uint GetTokenFromSig (IntPtr /* byte* */ pvSig, uint cbSig); - uint DefineModuleRef (string szName); - void SetParent (uint mr, uint tk); - uint GetTokenFromTypeSpec (IntPtr /* byte* */ pvSig, uint cbSig); - void SaveToMemory (IntPtr /* void* */ pbData, uint cbData); - uint DefineUserString (string szString, uint cchString); - void DeleteToken (uint tkObj); - void SetMethodProps (uint md, uint dwMethodFlags, uint ulCodeRVA, uint dwImplFlags); - void SetTypeDefProps (uint td, uint dwTypeDefFlags, uint tkExtends, IntPtr /* uint* */ rtkImplements); - void SetEventProps (uint ev, uint dwEventFlags, uint tkEventType, uint mdAddOn, uint mdRemoveOn, uint mdFire, IntPtr /* uint* */ rmdOtherMethods); - uint SetPermissionSetProps (uint tk, uint dwAction, IntPtr /* void* */ pvPermission, uint cbPermission); - void DefinePinvokeMap (uint tk, uint dwMappingFlags, string szImportName, uint mrImportDLL); - void SetPinvokeMap (uint tk, uint dwMappingFlags, string szImportName, uint mrImportDLL); - void DeletePinvokeMap (uint tk); - uint DefineCustomAttribute (uint tkObj, uint tkType, IntPtr /* void* */ pCustomAttribute, uint cbCustomAttribute); - void SetCustomAttributeValue (uint pcv, IntPtr /* void* */ pCustomAttribute, uint cbCustomAttribute); - uint DefineField (uint td, string szName, uint dwFieldFlags, IntPtr /* byte* */ pvSigBlob, uint cbSigBlob, uint dwCPlusTypeFlag, IntPtr /* void* */ pValue, uint cchValue); - uint DefineProperty (uint td, string szProperty, uint dwPropFlags, IntPtr /* byte* */ pvSig, uint cbSig, uint dwCPlusTypeFlag, - IntPtr /* void* */ pValue, uint cchValue, uint mdSetter, uint mdGetter, IntPtr /* uint* */ rmdOtherMethods); - uint DefineParam (uint md, uint ulParamSeq, string szName, uint dwParamFlags, uint dwCPlusTypeFlag, IntPtr /* void* */ pValue, uint cchValue); - void SetFieldProps (uint fd, uint dwFieldFlags, uint dwCPlusTypeFlag, IntPtr /* void* */ pValue, uint cchValue); - void SetPropertyProps (uint pr, uint dwPropFlags, uint dwCPlusTypeFlag, IntPtr /* void* */ pValue, uint cchValue, uint mdSetter, uint mdGetter, IntPtr /* uint* */ rmdOtherMethods); - void SetParamProps (uint pd, string szName, uint dwParamFlags, uint dwCPlusTypeFlag, IntPtr /* void* */ pValue, uint cchValue); - uint DefineSecurityAttributeSet (uint tkObj, IntPtr rSecAttrs, uint cSecAttrs); - void ApplyEditAndContinue ([MarshalAs (UnmanagedType.IUnknown)]object pImport); - uint TranslateSigWithScope (IntPtr pAssemImport, IntPtr /* void* */ pbHashValue, uint cbHashValue, - IMetaDataImport import, IntPtr /* byte* */ pbSigBlob, uint cbSigBlob, IntPtr pAssemEmit, IMetaDataEmit emit, IntPtr /* byte* */ pvTranslatedSig, uint cbTranslatedSigMax); - void SetMethodImplFlags (uint md, uint dwImplFlags); - void SetFieldRVA (uint fd, uint ulRVA); - void Merge (IMetaDataImport pImport, IntPtr pHostMapToken, [MarshalAs (UnmanagedType.IUnknown)]object pHandler); - void MergeEnd (); - } - - [ComImport, InterfaceType (ComInterfaceType.InterfaceIsIUnknown), Guid ("7DAC8207-D3AE-4c75-9B67-92801A497D44")] - interface IMetaDataImport { - [PreserveSig] - void CloseEnum (uint hEnum); - uint CountEnum (uint hEnum); - void ResetEnum (uint hEnum, uint ulPos); - uint EnumTypeDefs (ref uint phEnum, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 2)] uint [] rTypeDefs, uint cMax); - uint EnumInterfaceImpls (ref uint phEnum, uint td, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] uint [] rImpls, uint cMax); - uint EnumTypeRefs (ref uint phEnum, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 2)] uint [] rTypeRefs, uint cMax); - uint FindTypeDefByName (string szTypeDef, uint tkEnclosingClass); - Guid GetScopeProps (StringBuilder szName, uint cchName, out uint pchName); - uint GetModuleFromScope (); - uint GetTypeDefProps (uint td, IntPtr szTypeDef, uint cchTypeDef, out uint pchTypeDef, IntPtr pdwTypeDefFlags); - uint GetInterfaceImplProps (uint iiImpl, out uint pClass); - uint GetTypeRefProps (uint tr, out uint ptkResolutionScope, StringBuilder szName, uint cchName); - uint ResolveTypeRef (uint tr, [In] ref Guid riid, [MarshalAs (UnmanagedType.Interface)] out object ppIScope); - uint EnumMembers (ref uint phEnum, uint cl, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] uint [] rMembers, uint cMax); - uint EnumMembersWithName (ref uint phEnum, uint cl, string szName, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 4)] uint [] rMembers, uint cMax); - uint EnumMethods (ref uint phEnum, uint cl, IntPtr /* uint* */ rMethods, uint cMax); - uint EnumMethodsWithName (ref uint phEnum, uint cl, string szName, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 4)] uint [] rMethods, uint cMax); - uint EnumFields (ref uint phEnum, uint cl, IntPtr /* uint* */ rFields, uint cMax); - uint EnumFieldsWithName (ref uint phEnum, uint cl, string szName, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 4)] uint [] rFields, uint cMax); - uint EnumParams (ref uint phEnum, uint mb, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] uint [] rParams, uint cMax); - uint EnumMemberRefs (ref uint phEnum, uint tkParent, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] uint [] rMemberRefs, uint cMax); - uint EnumMethodImpls (ref uint phEnum, uint td, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 4)] uint [] rMethodBody, - [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 4)] uint [] rMethodDecl, uint cMax); - uint EnumPermissionSets (ref uint phEnum, uint tk, uint dwActions, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 4)] uint [] rPermission, - uint cMax); - uint FindMember (uint td, string szName, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] byte [] pvSigBlob, uint cbSigBlob); - uint FindMethod (uint td, string szName, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] byte [] pvSigBlob, uint cbSigBlob); - uint FindField (uint td, string szName, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] byte [] pvSigBlob, uint cbSigBlob); - uint FindMemberRef (uint td, string szName, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] byte [] pvSigBlob, uint cbSigBlob); - uint GetMethodProps (uint mb, out uint pClass, IntPtr szMethod, uint cchMethod, out uint pchMethod, IntPtr pdwAttr, IntPtr ppvSigBlob, IntPtr pcbSigBlob, IntPtr pulCodeRVA); - uint GetMemberRefProps (uint mr, ref uint ptk, StringBuilder szMember, uint cchMember, out uint pchMember, out IntPtr /* byte* */ ppvSigBlob); - uint EnumProperties (ref uint phEnum, uint td, IntPtr /* uint* */ rProperties, uint cMax); - uint EnumEvents (ref uint phEnum, uint td, IntPtr /* uint* */ rEvents, uint cMax); - uint GetEventProps (uint ev, out uint pClass, StringBuilder szEvent, uint cchEvent, out uint pchEvent, out uint pdwEventFlags, - out uint ptkEventType, out uint pmdAddOn, out uint pmdRemoveOn, out uint pmdFire, - [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 11)] uint [] rmdOtherMethod, uint cMax); - uint EnumMethodSemantics (ref uint phEnum, uint mb, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] uint [] rEventProp, uint cMax); - uint GetMethodSemantics (uint mb, uint tkEventProp); - uint GetClassLayout (uint td, out uint pdwPackSize, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 3)] IntPtr /*COR_FIELD_OFFSET **/ rFieldOffset, uint cMax, out uint pcFieldOffset); - uint GetFieldMarshal (uint tk, out IntPtr /* byte* */ ppvNativeType); - uint GetRVA (uint tk, out uint pulCodeRVA); - uint GetPermissionSetProps (uint pm, out uint pdwAction, out IntPtr /* void* */ ppvPermission); - uint GetSigFromToken (uint mdSig, out IntPtr /* byte* */ ppvSig); - uint GetModuleRefProps (uint mur, StringBuilder szName, uint cchName); - uint EnumModuleRefs (ref uint phEnum, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 2)] uint [] rModuleRefs, uint cmax); - uint GetTypeSpecFromToken (uint typespec, out IntPtr /* byte* */ ppvSig); - uint GetNameFromToken (uint tk); - uint EnumUnresolvedMethods (ref uint phEnum, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 2)] uint [] rMethods, uint cMax); - uint GetUserString (uint stk, StringBuilder szString, uint cchString); - uint GetPinvokeMap (uint tk, out uint pdwMappingFlags, StringBuilder szImportName, uint cchImportName, out uint pchImportName); - uint EnumSignatures (ref uint phEnum, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 2)] uint [] rSignatures, uint cmax); - uint EnumTypeSpecs (ref uint phEnum, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 2)] uint [] rTypeSpecs, uint cmax); - uint EnumUserStrings (ref uint phEnum, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 2)] uint [] rStrings, uint cmax); - [PreserveSig] - int GetParamForMethodIndex (uint md, uint ulParamSeq, out uint pParam); - uint EnumCustomAttributes (ref uint phEnum, uint tk, uint tkType, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 4)] uint [] rCustomAttributes, uint cMax); - uint GetCustomAttributeProps (uint cv, out uint ptkObj, out uint ptkType, out IntPtr /* void* */ ppBlob); - uint FindTypeRef (uint tkResolutionScope, string szName); - uint GetMemberProps (uint mb, out uint pClass, StringBuilder szMember, uint cchMember, out uint pchMember, out uint pdwAttr, - out IntPtr /* byte* */ ppvSigBlob, out uint pcbSigBlob, out uint pulCodeRVA, out uint pdwImplFlags, out uint pdwCPlusTypeFlag, out IntPtr /* void* */ ppValue); - uint GetFieldProps (uint mb, out uint pClass, StringBuilder szField, uint cchField, out uint pchField, out uint pdwAttr, - out IntPtr /* byte* */ ppvSigBlob, out uint pcbSigBlob, out uint pdwCPlusTypeFlag, out IntPtr /* void* */ ppValue); - uint GetPropertyProps (uint prop, out uint pClass, StringBuilder szProperty, uint cchProperty, out uint pchProperty, out uint pdwPropFlags, - out IntPtr /* byte* */ ppvSig, out uint pbSig, out uint pdwCPlusTypeFlag, out IntPtr /* void* */ ppDefaultValue, out uint pcchDefaultValue, out uint pmdSetter, - out uint pmdGetter, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 14)] uint [] rmdOtherMethod, uint cMax); - uint GetParamProps (uint tk, out uint pmd, out uint pulSequence, StringBuilder szName, uint cchName, out uint pchName, - out uint pdwAttr, out uint pdwCPlusTypeFlag, out IntPtr /* void* */ ppValue); - uint GetCustomAttributeByName (uint tkObj, string szName, out IntPtr /* void* */ ppData); - [PreserveSig] - [return: MarshalAs (UnmanagedType.Bool)] - bool IsValidToken (uint tk); - uint GetNestedClassProps (uint tdNestedClass); - uint GetNativeCallConvFromSig (IntPtr /* void* */ pvSig, uint cbSig); - int IsGlobal (uint pd); - } - - class ModuleMetadata : IMetaDataEmit, IMetaDataImport { - - readonly ModuleDefinition module; - - Dictionary types; - Dictionary methods; - - public ModuleMetadata (ModuleDefinition module) - { - this.module = module; - } - - bool TryGetType (uint token, out TypeDefinition type) - { - if (types == null) - InitializeMetadata (module); - - return types.TryGetValue (token, out type); - } - - bool TryGetMethod (uint token, out MethodDefinition method) - { - if (methods == null) - InitializeMetadata (module); - - return methods.TryGetValue (token, out method); - } - - void InitializeMetadata (ModuleDefinition module) - { - types = new Dictionary (); - methods = new Dictionary (); - - foreach (var type in module.GetTypes ()) { - types.Add (type.MetadataToken.ToUInt32 (), type); - InitializeMethods (type); - } - } - - void InitializeMethods (TypeDefinition type) - { - foreach (var method in type.Methods) - methods.Add (method.MetadataToken.ToUInt32 (), method); - } - - public void SetModuleProps (string szName) - { - throw new NotImplementedException (); - } - - public void Save (string szFile, uint dwSaveFlags) - { - throw new NotImplementedException (); - } - - public void SaveToStream (IntPtr pIStream, uint dwSaveFlags) - { - throw new NotImplementedException (); - } - - public uint GetSaveSize (uint fSave) - { - throw new NotImplementedException (); - } - - public uint DefineTypeDef (IntPtr szTypeDef, uint dwTypeDefFlags, uint tkExtends, IntPtr rtkImplements) - { - throw new NotImplementedException (); - } - - public uint DefineNestedType (IntPtr szTypeDef, uint dwTypeDefFlags, uint tkExtends, IntPtr rtkImplements, uint tdEncloser) - { - throw new NotImplementedException (); - } - - public void SetHandler (object pUnk) - { - throw new NotImplementedException (); - } - - public uint DefineMethod (uint td, IntPtr zName, uint dwMethodFlags, IntPtr pvSigBlob, uint cbSigBlob, uint ulCodeRVA, uint dwImplFlags) - { - throw new NotImplementedException (); - } - - public void DefineMethodImpl (uint td, uint tkBody, uint tkDecl) - { - throw new NotImplementedException (); - } - - public uint DefineTypeRefByName (uint tkResolutionScope, IntPtr szName) - { - throw new NotImplementedException (); - } - - public uint DefineImportType (IntPtr pAssemImport, IntPtr pbHashValue, uint cbHashValue, IMetaDataImport pImport, uint tdImport, IntPtr pAssemEmit) - { - throw new NotImplementedException (); - } - - public uint DefineMemberRef (uint tkImport, string szName, IntPtr pvSigBlob, uint cbSigBlob) - { - throw new NotImplementedException (); - } - - public uint DefineImportMember (IntPtr pAssemImport, IntPtr pbHashValue, uint cbHashValue, IMetaDataImport pImport, uint mbMember, IntPtr pAssemEmit, uint tkParent) - { - throw new NotImplementedException (); - } - - public uint DefineEvent (uint td, string szEvent, uint dwEventFlags, uint tkEventType, uint mdAddOn, uint mdRemoveOn, uint mdFire, IntPtr rmdOtherMethods) - { - throw new NotImplementedException (); - } - - public void SetClassLayout (uint td, uint dwPackSize, IntPtr rFieldOffsets, uint ulClassSize) - { - throw new NotImplementedException (); - } - - public void DeleteClassLayout (uint td) - { - throw new NotImplementedException (); - } - - public void SetFieldMarshal (uint tk, IntPtr pvNativeType, uint cbNativeType) - { - throw new NotImplementedException (); - } - - public void DeleteFieldMarshal (uint tk) - { - throw new NotImplementedException (); - } - - public uint DefinePermissionSet (uint tk, uint dwAction, IntPtr pvPermission, uint cbPermission) - { - throw new NotImplementedException (); - } - - public void SetRVA (uint md, uint ulRVA) - { - throw new NotImplementedException (); - } - - public uint GetTokenFromSig (IntPtr pvSig, uint cbSig) - { - throw new NotImplementedException (); - } - - public uint DefineModuleRef (string szName) - { - throw new NotImplementedException (); - } - - public void SetParent (uint mr, uint tk) - { - throw new NotImplementedException (); - } - - public uint GetTokenFromTypeSpec (IntPtr pvSig, uint cbSig) - { - throw new NotImplementedException (); - } - - public void SaveToMemory (IntPtr pbData, uint cbData) - { - throw new NotImplementedException (); - } - - public uint DefineUserString (string szString, uint cchString) - { - throw new NotImplementedException (); - } - - public void DeleteToken (uint tkObj) - { - throw new NotImplementedException (); - } - - public void SetMethodProps (uint md, uint dwMethodFlags, uint ulCodeRVA, uint dwImplFlags) - { - throw new NotImplementedException (); - } - - public void SetTypeDefProps (uint td, uint dwTypeDefFlags, uint tkExtends, IntPtr rtkImplements) - { - throw new NotImplementedException (); - } - - public void SetEventProps (uint ev, uint dwEventFlags, uint tkEventType, uint mdAddOn, uint mdRemoveOn, uint mdFire, IntPtr rmdOtherMethods) - { - throw new NotImplementedException (); - } - - public uint SetPermissionSetProps (uint tk, uint dwAction, IntPtr pvPermission, uint cbPermission) - { - throw new NotImplementedException (); - } - - public void DefinePinvokeMap (uint tk, uint dwMappingFlags, string szImportName, uint mrImportDLL) - { - throw new NotImplementedException (); - } - - public void SetPinvokeMap (uint tk, uint dwMappingFlags, string szImportName, uint mrImportDLL) - { - throw new NotImplementedException (); - } - - public void DeletePinvokeMap (uint tk) - { - throw new NotImplementedException (); - } - - public uint DefineCustomAttribute (uint tkObj, uint tkType, IntPtr pCustomAttribute, uint cbCustomAttribute) - { - throw new NotImplementedException (); - } - - public void SetCustomAttributeValue (uint pcv, IntPtr pCustomAttribute, uint cbCustomAttribute) - { - throw new NotImplementedException (); - } - - public uint DefineField (uint td, string szName, uint dwFieldFlags, IntPtr pvSigBlob, uint cbSigBlob, uint dwCPlusTypeFlag, IntPtr pValue, uint cchValue) - { - throw new NotImplementedException (); - } - - public uint DefineProperty (uint td, string szProperty, uint dwPropFlags, IntPtr pvSig, uint cbSig, uint dwCPlusTypeFlag, IntPtr pValue, uint cchValue, uint mdSetter, uint mdGetter, IntPtr rmdOtherMethods) - { - throw new NotImplementedException (); - } - - public uint DefineParam (uint md, uint ulParamSeq, string szName, uint dwParamFlags, uint dwCPlusTypeFlag, IntPtr pValue, uint cchValue) - { - throw new NotImplementedException (); - } - - public void SetFieldProps (uint fd, uint dwFieldFlags, uint dwCPlusTypeFlag, IntPtr pValue, uint cchValue) - { - throw new NotImplementedException (); - } - - public void SetPropertyProps (uint pr, uint dwPropFlags, uint dwCPlusTypeFlag, IntPtr pValue, uint cchValue, uint mdSetter, uint mdGetter, IntPtr rmdOtherMethods) - { - throw new NotImplementedException (); - } - - public void SetParamProps (uint pd, string szName, uint dwParamFlags, uint dwCPlusTypeFlag, IntPtr pValue, uint cchValue) - { - throw new NotImplementedException (); - } - - public uint DefineSecurityAttributeSet (uint tkObj, IntPtr rSecAttrs, uint cSecAttrs) - { - throw new NotImplementedException (); - } - - public void ApplyEditAndContinue (object pImport) - { - throw new NotImplementedException (); - } - - public uint TranslateSigWithScope (IntPtr pAssemImport, IntPtr pbHashValue, uint cbHashValue, IMetaDataImport import, IntPtr pbSigBlob, uint cbSigBlob, IntPtr pAssemEmit, IMetaDataEmit emit, IntPtr pvTranslatedSig, uint cbTranslatedSigMax) - { - throw new NotImplementedException (); - } - - public void SetMethodImplFlags (uint md, uint dwImplFlags) - { - throw new NotImplementedException (); - } - - public void SetFieldRVA (uint fd, uint ulRVA) - { - throw new NotImplementedException (); - } - - public void Merge (IMetaDataImport pImport, IntPtr pHostMapToken, object pHandler) - { - throw new NotImplementedException (); - } - - public void MergeEnd () - { - throw new NotImplementedException (); - } - - public void CloseEnum (uint hEnum) - { - throw new NotImplementedException (); - } - - public uint CountEnum (uint hEnum) - { - throw new NotImplementedException (); - } - - public void ResetEnum (uint hEnum, uint ulPos) - { - throw new NotImplementedException (); - } - - public uint EnumTypeDefs (ref uint phEnum, uint[] rTypeDefs, uint cMax) - { - throw new NotImplementedException (); - } - - public uint EnumInterfaceImpls (ref uint phEnum, uint td, uint[] rImpls, uint cMax) - { - throw new NotImplementedException (); - } - - public uint EnumTypeRefs (ref uint phEnum, uint[] rTypeRefs, uint cMax) - { - throw new NotImplementedException (); - } - - public uint FindTypeDefByName (string szTypeDef, uint tkEnclosingClass) - { - throw new NotImplementedException (); - } - - public Guid GetScopeProps (StringBuilder szName, uint cchName, out uint pchName) - { - throw new NotImplementedException (); - } - - public uint GetModuleFromScope () - { - throw new NotImplementedException (); - } - - public uint GetTypeDefProps (uint td, IntPtr szTypeDef, uint cchTypeDef, out uint pchTypeDef, IntPtr pdwTypeDefFlags) - { - TypeDefinition type; - if (!TryGetType (td, out type)) { - Marshal.WriteInt16 (szTypeDef, 0); - pchTypeDef = 1; - return 0; - } - - WriteString (type.IsNested ? type.Name : type.FullName, szTypeDef, cchTypeDef, out pchTypeDef); - WriteIntPtr (pdwTypeDefFlags, (uint) type.Attributes); - return type.BaseType != null ? type.BaseType.MetadataToken.ToUInt32 () : 0; - } - - static void WriteIntPtr (IntPtr ptr, uint value) - { - if (ptr == IntPtr.Zero) - return; - - Marshal.WriteInt32 (ptr, (int) value); - } - - static void WriteString (string str, IntPtr buffer, uint bufferSize, out uint chars) - { - var length = str.Length + 1 >= bufferSize ? bufferSize - 1 : (uint) str.Length; - chars = length + 1; - var offset = 0; - - for (int i = 0; i < length; i++) { - Marshal.WriteInt16 (buffer, offset, str [i]); - offset += 2; - } - - Marshal.WriteInt16 (buffer, offset, 0); - } - - public uint GetInterfaceImplProps (uint iiImpl, out uint pClass) - { - throw new NotImplementedException (); - } - - public uint GetTypeRefProps (uint tr, out uint ptkResolutionScope, StringBuilder szName, uint cchName) - { - throw new NotImplementedException (); - } - - public uint ResolveTypeRef (uint tr, ref Guid riid, out object ppIScope) - { - throw new NotImplementedException (); - } - - public uint EnumMembers (ref uint phEnum, uint cl, uint[] rMembers, uint cMax) - { - throw new NotImplementedException (); - } - - public uint EnumMembersWithName (ref uint phEnum, uint cl, string szName, uint[] rMembers, uint cMax) - { - throw new NotImplementedException (); - } - - public uint EnumMethods (ref uint phEnum, uint cl, IntPtr rMethods, uint cMax) - { - throw new NotImplementedException (); - } - - public uint EnumMethodsWithName (ref uint phEnum, uint cl, string szName, uint[] rMethods, uint cMax) - { - throw new NotImplementedException (); - } - - public uint EnumFields (ref uint phEnum, uint cl, IntPtr rFields, uint cMax) - { - throw new NotImplementedException (); - } - - public uint EnumFieldsWithName (ref uint phEnum, uint cl, string szName, uint[] rFields, uint cMax) - { - throw new NotImplementedException (); - } - - public uint EnumParams (ref uint phEnum, uint mb, uint[] rParams, uint cMax) - { - throw new NotImplementedException (); - } - - public uint EnumMemberRefs (ref uint phEnum, uint tkParent, uint[] rMemberRefs, uint cMax) - { - throw new NotImplementedException (); - } - - public uint EnumMethodImpls (ref uint phEnum, uint td, uint[] rMethodBody, uint[] rMethodDecl, uint cMax) - { - throw new NotImplementedException (); - } - - public uint EnumPermissionSets (ref uint phEnum, uint tk, uint dwActions, uint[] rPermission, uint cMax) - { - throw new NotImplementedException (); - } - - public uint FindMember (uint td, string szName, byte[] pvSigBlob, uint cbSigBlob) - { - throw new NotImplementedException (); - } - - public uint FindMethod (uint td, string szName, byte[] pvSigBlob, uint cbSigBlob) - { - throw new NotImplementedException (); - } - - public uint FindField (uint td, string szName, byte[] pvSigBlob, uint cbSigBlob) - { - throw new NotImplementedException (); - } - - public uint FindMemberRef (uint td, string szName, byte[] pvSigBlob, uint cbSigBlob) - { - throw new NotImplementedException (); - } - - public uint GetMethodProps (uint mb, out uint pClass, IntPtr szMethod, uint cchMethod, out uint pchMethod, IntPtr pdwAttr, IntPtr ppvSigBlob, IntPtr pcbSigBlob, IntPtr pulCodeRVA) - { - MethodDefinition method; - if (!TryGetMethod (mb, out method)) { - Marshal.WriteInt16 (szMethod, 0); - pchMethod = 1; - pClass = 0; - return 0; - } - - pClass = method.DeclaringType.MetadataToken.ToUInt32 (); - WriteString (method.Name, szMethod, cchMethod, out pchMethod); - WriteIntPtr (pdwAttr, (uint) method.Attributes); - WriteIntPtr (pulCodeRVA, (uint) method.RVA); - - return (uint) method.ImplAttributes; - } - - public uint GetMemberRefProps (uint mr, ref uint ptk, StringBuilder szMember, uint cchMember, out uint pchMember, out IntPtr ppvSigBlob) - { - throw new NotImplementedException (); - } - - public uint EnumProperties (ref uint phEnum, uint td, IntPtr rProperties, uint cMax) - { - throw new NotImplementedException (); - } - - public uint EnumEvents (ref uint phEnum, uint td, IntPtr rEvents, uint cMax) - { - throw new NotImplementedException (); - } - - public uint GetEventProps (uint ev, out uint pClass, StringBuilder szEvent, uint cchEvent, out uint pchEvent, out uint pdwEventFlags, out uint ptkEventType, out uint pmdAddOn, out uint pmdRemoveOn, out uint pmdFire, uint[] rmdOtherMethod, uint cMax) - { - throw new NotImplementedException (); - } - - public uint EnumMethodSemantics (ref uint phEnum, uint mb, uint[] rEventProp, uint cMax) - { - throw new NotImplementedException (); - } - - public uint GetMethodSemantics (uint mb, uint tkEventProp) - { - throw new NotImplementedException (); - } - - public uint GetClassLayout (uint td, out uint pdwPackSize, IntPtr rFieldOffset, uint cMax, out uint pcFieldOffset) - { - throw new NotImplementedException (); - } - - public uint GetFieldMarshal (uint tk, out IntPtr ppvNativeType) - { - throw new NotImplementedException (); - } - - public uint GetRVA (uint tk, out uint pulCodeRVA) - { - throw new NotImplementedException (); - } - - public uint GetPermissionSetProps (uint pm, out uint pdwAction, out IntPtr ppvPermission) - { - throw new NotImplementedException (); - } - - public uint GetSigFromToken (uint mdSig, out IntPtr ppvSig) - { - throw new NotImplementedException (); - } - - public uint GetModuleRefProps (uint mur, StringBuilder szName, uint cchName) - { - throw new NotImplementedException (); - } - - public uint EnumModuleRefs (ref uint phEnum, uint[] rModuleRefs, uint cmax) - { - throw new NotImplementedException (); - } - - public uint GetTypeSpecFromToken (uint typespec, out IntPtr ppvSig) - { - throw new NotImplementedException (); - } - - public uint GetNameFromToken (uint tk) - { - throw new NotImplementedException (); - } - - public uint EnumUnresolvedMethods (ref uint phEnum, uint[] rMethods, uint cMax) - { - throw new NotImplementedException (); - } - - public uint GetUserString (uint stk, StringBuilder szString, uint cchString) - { - throw new NotImplementedException (); - } - - public uint GetPinvokeMap (uint tk, out uint pdwMappingFlags, StringBuilder szImportName, uint cchImportName, out uint pchImportName) - { - throw new NotImplementedException (); - } - - public uint EnumSignatures (ref uint phEnum, uint[] rSignatures, uint cmax) - { - throw new NotImplementedException (); - } - - public uint EnumTypeSpecs (ref uint phEnum, uint[] rTypeSpecs, uint cmax) - { - throw new NotImplementedException (); - } - - public uint EnumUserStrings (ref uint phEnum, uint[] rStrings, uint cmax) - { - throw new NotImplementedException (); - } - - public int GetParamForMethodIndex (uint md, uint ulParamSeq, out uint pParam) - { - throw new NotImplementedException (); - } - - public uint EnumCustomAttributes (ref uint phEnum, uint tk, uint tkType, uint[] rCustomAttributes, uint cMax) - { - throw new NotImplementedException (); - } - - public uint GetCustomAttributeProps (uint cv, out uint ptkObj, out uint ptkType, out IntPtr ppBlob) - { - throw new NotImplementedException (); - } - - public uint FindTypeRef (uint tkResolutionScope, string szName) - { - throw new NotImplementedException (); - } - - public uint GetMemberProps (uint mb, out uint pClass, StringBuilder szMember, uint cchMember, out uint pchMember, out uint pdwAttr, out IntPtr ppvSigBlob, out uint pcbSigBlob, out uint pulCodeRVA, out uint pdwImplFlags, out uint pdwCPlusTypeFlag, out IntPtr ppValue) - { - throw new NotImplementedException (); - } - - public uint GetFieldProps (uint mb, out uint pClass, StringBuilder szField, uint cchField, out uint pchField, out uint pdwAttr, out IntPtr ppvSigBlob, out uint pcbSigBlob, out uint pdwCPlusTypeFlag, out IntPtr ppValue) - { - throw new NotImplementedException (); - } - - public uint GetPropertyProps (uint prop, out uint pClass, StringBuilder szProperty, uint cchProperty, out uint pchProperty, out uint pdwPropFlags, out IntPtr ppvSig, out uint pbSig, out uint pdwCPlusTypeFlag, out IntPtr ppDefaultValue, out uint pcchDefaultValue, out uint pmdSetter, out uint pmdGetter, uint[] rmdOtherMethod, uint cMax) - { - throw new NotImplementedException (); - } - - public uint GetParamProps (uint tk, out uint pmd, out uint pulSequence, StringBuilder szName, uint cchName, out uint pchName, out uint pdwAttr, out uint pdwCPlusTypeFlag, out IntPtr ppValue) - { - throw new NotImplementedException (); - } - - public uint GetCustomAttributeByName (uint tkObj, string szName, out IntPtr ppData) - { - throw new NotImplementedException (); - } - - public bool IsValidToken (uint tk) - { - throw new NotImplementedException (); - } - - public uint GetNestedClassProps (uint tdNestedClass) - { - TypeDefinition type; - if (!TryGetType (tdNestedClass, out type)) - return 0; - - return type.IsNested ? type.DeclaringType.MetadataToken.ToUInt32 () : 0; - } - - public uint GetNativeCallConvFromSig (IntPtr pvSig, uint cbSig) - { - throw new NotImplementedException (); - } - - public int IsGlobal (uint pd) - { - throw new NotImplementedException (); - } - } -} - -#endif diff --git a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/NativePdbReader.cs b/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/NativePdbReader.cs deleted file mode 100644 index 964f4ad5ba..0000000000 --- a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/NativePdbReader.cs +++ /dev/null @@ -1,376 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.IO; - -using Mono.Collections.Generic; - -using Microsoft.Cci.Pdb; - -using Mono.Cecil.Cil; - -namespace Mono.Cecil.Pdb { - - public class NativePdbReader : ISymbolReader { - - int age; - Guid guid; - - readonly Disposable pdb_file; - readonly Dictionary documents = new Dictionary (); - readonly Dictionary functions = new Dictionary (); - readonly Dictionary imports = new Dictionary (); - - internal NativePdbReader (Disposable file) - { - this.pdb_file = file; - } - -#if !READ_ONLY - public ISymbolWriterProvider GetWriterProvider () - { - return new NativePdbWriterProvider (); - } -#endif - /* - uint Magic = 0x53445352; - Guid Signature; - uint Age; - string FileName; - */ - - public bool ProcessDebugHeader (ImageDebugHeader header) - { - if (!header.HasEntries) - return false; - - var entry = header.GetCodeViewEntry (); - if (entry == null) - return false; - - var directory = entry.Directory; - - if (directory.Type != ImageDebugType.CodeView) - return false; - if (directory.MajorVersion != 0 || directory.MinorVersion != 0) - return false; - - var data = entry.Data; - - if (data.Length < 24) - return false; - - var magic = ReadInt32 (data, 0); - if (magic != 0x53445352) - return false; - - var guid_bytes = new byte [16]; - Buffer.BlockCopy (data, 4, guid_bytes, 0, 16); - - this.guid = new Guid (guid_bytes); - this.age = ReadInt32 (data, 20); - - return PopulateFunctions (); - } - - static int ReadInt32 (byte [] bytes, int start) - { - return (bytes [start] - | (bytes [start + 1] << 8) - | (bytes [start + 2] << 16) - | (bytes [start + 3] << 24)); - } - - bool PopulateFunctions () - { - using (pdb_file) { - Dictionary tokenToSourceMapping; - string sourceServerData; - int age; - Guid guid; - - var funcs = PdbFile.LoadFunctions (pdb_file.value, out tokenToSourceMapping, out sourceServerData, out age, out guid); - - if (this.guid != guid) - return false; - - foreach (PdbFunction function in funcs) - functions.Add (function.token, function); - } - - return true; - } - - public MethodDebugInformation Read (MethodDefinition method) - { - var method_token = method.MetadataToken; - - PdbFunction function; - if (!functions.TryGetValue (method_token.ToUInt32 (), out function)) - return null; - - var symbol = new MethodDebugInformation (method); - - ReadSequencePoints (function, symbol); - - symbol.scope = !function.scopes.IsNullOrEmpty () - ? ReadScopeAndLocals (function.scopes [0], symbol) - : new ScopeDebugInformation { Start = new InstructionOffset (0), End = new InstructionOffset ((int) function.length) }; - - if (function.tokenOfMethodWhoseUsingInfoAppliesToThisMethod != method.MetadataToken.ToUInt32 () && function.tokenOfMethodWhoseUsingInfoAppliesToThisMethod != 0) - symbol.scope.import = GetImport (function.tokenOfMethodWhoseUsingInfoAppliesToThisMethod, method.Module); - - if (function.scopes.Length > 1) { - for (int i = 1; i < function.scopes.Length; i++) { - var s = ReadScopeAndLocals (function.scopes [i], symbol); - if (!AddScope (symbol.scope.Scopes, s)) - symbol.scope.Scopes.Add (s); - } - } - - if (function.iteratorScopes != null) { - var state_machine = new StateMachineScopeDebugInformation (); - - foreach (var iterator_scope in function.iteratorScopes) { - state_machine.Scopes.Add (new StateMachineScope ((int) iterator_scope.Offset, (int) (iterator_scope.Offset + iterator_scope.Length + 1))); - } - - symbol.CustomDebugInformations.Add (state_machine); - } - - if (function.synchronizationInformation != null) { - var async_debug_info = new AsyncMethodBodyDebugInformation ((int) function.synchronizationInformation.GeneratedCatchHandlerOffset); - - foreach (var synchronization_point in function.synchronizationInformation.synchronizationPoints) { - async_debug_info.Yields.Add (new InstructionOffset ((int) synchronization_point.SynchronizeOffset)); - async_debug_info.Resumes.Add (new InstructionOffset ((int) synchronization_point.ContinuationOffset)); - async_debug_info.ResumeMethods.Add (method); - } - - symbol.CustomDebugInformations.Add (async_debug_info); - - symbol.StateMachineKickOffMethod = (MethodDefinition) method.Module.LookupToken ((int) function.synchronizationInformation.kickoffMethodToken); - } - - return symbol; - } - - Collection ReadScopeAndLocals (PdbScope [] scopes, MethodDebugInformation info) - { - var symbols = new Collection (scopes.Length); - - foreach (PdbScope scope in scopes) - if (scope != null) - symbols.Add (ReadScopeAndLocals (scope, info)); - - return symbols; - } - - ScopeDebugInformation ReadScopeAndLocals (PdbScope scope, MethodDebugInformation info) - { - var parent = new ScopeDebugInformation (); - parent.Start = new InstructionOffset ((int) scope.offset); - parent.End = new InstructionOffset ((int) (scope.offset + scope.length)); - - if (!scope.slots.IsNullOrEmpty ()) { - parent.variables = new Collection (scope.slots.Length); - - foreach (PdbSlot slot in scope.slots) { - if (slot.flags == 1) // parameter names - continue; - - var index = (int) slot.slot; - var variable = new VariableDebugInformation (index, slot.name); - if (slot.flags == 4) - variable.IsDebuggerHidden = true; - parent.variables.Add (variable); - } - } - - if (!scope.constants.IsNullOrEmpty ()) { - parent.constants = new Collection (scope.constants.Length); - - foreach (var constant in scope.constants) { - var type = info.Method.Module.Read (constant, (c, r) => r.ReadConstantSignature (new MetadataToken (c.token))); - var value = constant.value; - - // Object "null" is encoded as integer - if (type != null && !type.IsValueType && value is int && (int) value == 0) - value = null; - - parent.constants.Add (new ConstantDebugInformation (constant.name, type, value)); - } - } - - if (!scope.usedNamespaces.IsNullOrEmpty ()) { - ImportDebugInformation import; - if (imports.TryGetValue (scope, out import)) { - parent.import = import; - } else { - import = GetImport (scope, info.Method.Module); - imports.Add (scope, import); - parent.import = import; - } - } - - parent.scopes = ReadScopeAndLocals (scope.scopes, info); - - return parent; - } - - static bool AddScope (Collection scopes, ScopeDebugInformation scope) - { - foreach (var sub_scope in scopes) { - if (sub_scope.HasScopes && AddScope (sub_scope.Scopes, scope)) - return true; - - if (scope.Start.Offset >= sub_scope.Start.Offset && scope.End.Offset <= sub_scope.End.Offset) { - sub_scope.Scopes.Add (scope); - return true; - } - } - - return false; - } - - ImportDebugInformation GetImport (uint token, ModuleDefinition module) - { - PdbFunction function; - if (!functions.TryGetValue (token, out function)) - return null; - - if (function.scopes.Length != 1) - return null; - - var scope = function.scopes [0]; - - ImportDebugInformation import; - if (imports.TryGetValue (scope, out import)) - return import; - - import = GetImport (scope, module); - imports.Add (scope, import); - return import; - } - - static ImportDebugInformation GetImport (PdbScope scope, ModuleDefinition module) - { - if (scope.usedNamespaces.IsNullOrEmpty ()) - return null; - - var import = new ImportDebugInformation (); - - foreach (var used_namespace in scope.usedNamespaces) { - if (string.IsNullOrEmpty (used_namespace)) - continue; - - ImportTarget target = null; - var value = used_namespace.Substring (1); - switch (used_namespace [0]) { - case 'U': - target = new ImportTarget (ImportTargetKind.ImportNamespace) { @namespace = value }; - break; - case 'T': { - var type = module.GetType (value, runtimeName: true); - if (type != null) - target = new ImportTarget (ImportTargetKind.ImportType) { type = type }; - break; - } - case 'A': - var index = used_namespace.IndexOf (' '); - if (index < 0) { - target = new ImportTarget (ImportTargetKind.ImportNamespace) { @namespace = used_namespace }; - break; - } - var alias_value = used_namespace.Substring (1, index - 1); - var alias_target_value = used_namespace.Substring (index + 2); - switch (used_namespace [index + 1]) { - case 'U': - target = new ImportTarget (ImportTargetKind.DefineNamespaceAlias) { alias = alias_value, @namespace = alias_target_value }; - break; - case 'T': - var type = module.GetType (alias_target_value, runtimeName: true); - if (type != null) - target = new ImportTarget (ImportTargetKind.DefineTypeAlias) { alias = alias_value, type = type }; - break; - } - break; - case '*': - target = new ImportTarget (ImportTargetKind.ImportNamespace) { @namespace = value }; - break; - case '@': - if (!value.StartsWith ("P:")) - continue; - - target = new ImportTarget (ImportTargetKind.ImportNamespace) { @namespace = value.Substring (2) }; - break; - } - - if (target != null) - import.Targets.Add (target); - } - - return import; - } - - void ReadSequencePoints (PdbFunction function, MethodDebugInformation info) - { - if (function.lines == null) - return; - - info.sequence_points = new Collection (); - - foreach (PdbLines lines in function.lines) - ReadLines (lines, info); - } - - void ReadLines (PdbLines lines, MethodDebugInformation info) - { - var document = GetDocument (lines.file); - - foreach (var line in lines.lines) - ReadLine (line, document, info); - } - - static void ReadLine (PdbLine line, Document document, MethodDebugInformation info) - { - var sequence_point = new SequencePoint ((int) line.offset, document); - sequence_point.StartLine = (int) line.lineBegin; - sequence_point.StartColumn = (int) line.colBegin; - sequence_point.EndLine = (int) line.lineEnd; - sequence_point.EndColumn = (int) line.colEnd; - - info.sequence_points.Add (sequence_point); - } - - Document GetDocument (PdbSource source) - { - string name = source.name; - Document document; - if (documents.TryGetValue (name, out document)) - return document; - - document = new Document (name) { - Language = source.language.ToLanguage (), - LanguageVendor = source.vendor.ToVendor (), - Type = source.doctype.ToType (), - }; - documents.Add (name, document); - return document; - } - - public void Dispose () - { - pdb_file.Dispose (); - } - } -} diff --git a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/NativePdbWriter.cs b/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/NativePdbWriter.cs deleted file mode 100644 index be871ac481..0000000000 --- a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/NativePdbWriter.cs +++ /dev/null @@ -1,375 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; - -using Mono.Cecil.Cil; -using Mono.Cecil.PE; -using Mono.Collections.Generic; - -#if !READ_ONLY - -namespace Mono.Cecil.Pdb { - - public class NativePdbWriter : ISymbolWriter, IMetadataSymbolWriter { - - readonly ModuleDefinition module; - readonly SymWriter writer; - readonly Dictionary documents; - readonly Dictionary import_info_to_parent; - - MetadataBuilder metadata; - - internal NativePdbWriter (ModuleDefinition module, SymWriter writer) - { - this.module = module; - this.writer = writer; - this.documents = new Dictionary (); - this.import_info_to_parent = new Dictionary (); - } - - public ISymbolReaderProvider GetReaderProvider () - { - return new NativePdbReaderProvider (); - } - - public ImageDebugHeader GetDebugHeader () - { - ImageDebugDirectory directory; - var data = writer.GetDebugInfo (out directory); - directory.TimeDateStamp = (int) module.timestamp; - return new ImageDebugHeader (new ImageDebugHeaderEntry (directory, data)); - } - - public void Write (MethodDebugInformation info) - { - var method_token = info.method.MetadataToken; - var sym_token = method_token.ToInt32 (); - - if (!info.HasSequencePoints && info.scope == null && !info.HasCustomDebugInformations && info.StateMachineKickOffMethod == null) - return; - - writer.OpenMethod (sym_token); - - if (!info.sequence_points.IsNullOrEmpty ()) - DefineSequencePoints (info.sequence_points); - - var import_parent = new MetadataToken (); - - if (info.scope != null) - DefineScope (info.scope, info, out import_parent); - - DefineCustomMetadata (info, import_parent); - - writer.CloseMethod (); - } - - void IMetadataSymbolWriter.SetMetadata (MetadataBuilder metadata) - { - this.metadata = metadata; - } - - void IMetadataSymbolWriter.WriteModule () - { - } - - void DefineCustomMetadata (MethodDebugInformation info, MetadataToken import_parent) - { - var metadata = new CustomMetadataWriter (this.writer); - - if (import_parent.RID != 0) { - metadata.WriteForwardInfo (import_parent); - } else if (info.scope != null && info.scope.Import != null && info.scope.Import.HasTargets) { - metadata.WriteUsingInfo (info.scope.Import); - } - - if (info.Method.HasCustomAttributes) { - foreach (var attribute in info.Method.CustomAttributes) { - const string compiler_services = "System.Runtime.CompilerServices"; - var attribute_type = attribute.AttributeType; - - if (!attribute_type.IsTypeOf (compiler_services, "IteratorStateMachineAttribute") && !attribute_type.IsTypeOf (compiler_services, "AsyncStateMachineAttribute")) - continue; - - var type = attribute.ConstructorArguments [0].Value as TypeReference; - if (type == null) - continue; - - metadata.WriteForwardIterator (type); - } - } - - if (info.HasCustomDebugInformations) { - var state_machine = info.CustomDebugInformations.FirstOrDefault (cdi => cdi.Kind == CustomDebugInformationKind.StateMachineScope) as StateMachineScopeDebugInformation; - - if (state_machine != null) - metadata.WriteIteratorScopes (state_machine, info); - } - - metadata.WriteCustomMetadata (); - - DefineAsyncCustomMetadata (info); - } - - void DefineAsyncCustomMetadata (MethodDebugInformation info) - { - if (!info.HasCustomDebugInformations) - return; - - foreach (var custom_info in info.CustomDebugInformations) { - var async_debug_info = custom_info as AsyncMethodBodyDebugInformation; - if (async_debug_info == null) - continue; - - using (var stream = new MemoryStream ()) { - var async_metadata = new BinaryStreamWriter (stream); - async_metadata.WriteUInt32 (info.StateMachineKickOffMethod != null ? info.StateMachineKickOffMethod.MetadataToken.ToUInt32 () : 0); - async_metadata.WriteUInt32 ((uint) async_debug_info.CatchHandler.Offset); - async_metadata.WriteUInt32 ((uint) async_debug_info.Resumes.Count); - for (int i = 0; i < async_debug_info.Resumes.Count; ++i) { - async_metadata.WriteUInt32 ((uint) async_debug_info.Yields [i].Offset); - async_metadata.WriteUInt32 (async_debug_info.resume_methods [i].MetadataToken.ToUInt32 ()); - async_metadata.WriteUInt32 ((uint) async_debug_info.Resumes [i].Offset); - } - - writer.DefineCustomMetadata ("asyncMethodInfo", stream.ToArray ()); - } - } - } - - void DefineScope (ScopeDebugInformation scope, MethodDebugInformation info, out MetadataToken import_parent) - { - var start_offset = scope.Start.Offset; - var end_offset = scope.End.IsEndOfMethod - ? info.code_size - : scope.End.Offset; - - import_parent = new MetadataToken (0u); - - writer.OpenScope (start_offset); - - if (scope.Import != null && scope.Import.HasTargets && !import_info_to_parent.TryGetValue (info.scope.Import, out import_parent)) { - foreach (var target in scope.Import.Targets) { - switch (target.Kind) { - case ImportTargetKind.ImportNamespace: - writer.UsingNamespace ("U" + target.@namespace); - break; - case ImportTargetKind.ImportType: - writer.UsingNamespace ("T" + TypeParser.ToParseable (target.type)); - break; - case ImportTargetKind.DefineNamespaceAlias: - writer.UsingNamespace ("A" + target.Alias + " U" + target.@namespace); - break; - case ImportTargetKind.DefineTypeAlias: - writer.UsingNamespace ("A" + target.Alias + " T" + TypeParser.ToParseable (target.type)); - break; - } - } - - import_info_to_parent.Add (info.scope.Import, info.method.MetadataToken); - } - - var sym_token = info.local_var_token.ToInt32 (); - - if (!scope.variables.IsNullOrEmpty ()) { - for (int i = 0; i < scope.variables.Count; i++) { - var variable = scope.variables [i]; - DefineLocalVariable (variable, sym_token, start_offset, end_offset); - } - } - - if (!scope.constants.IsNullOrEmpty ()) { - for (int i = 0; i < scope.constants.Count; i++) { - var constant = scope.constants [i]; - DefineConstant (constant); - } - } - - if (!scope.scopes.IsNullOrEmpty ()) { - for (int i = 0; i < scope.scopes.Count; i++) { - MetadataToken _; - DefineScope (scope.scopes [i], info, out _); - } - } - - writer.CloseScope (end_offset); - } - - void DefineSequencePoints (Collection sequence_points) - { - for (int i = 0; i < sequence_points.Count; i++) { - var sequence_point = sequence_points [i]; - - writer.DefineSequencePoints ( - GetDocument (sequence_point.Document), - new [] { sequence_point.Offset }, - new [] { sequence_point.StartLine }, - new [] { sequence_point.StartColumn }, - new [] { sequence_point.EndLine }, - new [] { sequence_point.EndColumn }); - } - } - - void DefineLocalVariable (VariableDebugInformation variable, int local_var_token, int start_offset, int end_offset) - { - writer.DefineLocalVariable2 ( - variable.Name, - variable.Attributes, - local_var_token, - variable.Index, - 0, - 0, - start_offset, - end_offset); - } - - void DefineConstant (ConstantDebugInformation constant) - { - var row = metadata.AddStandAloneSignature (metadata.GetConstantTypeBlobIndex (constant.ConstantType)); - var token = new MetadataToken (TokenType.Signature, row); - - writer.DefineConstant2 (constant.Name, constant.Value, token.ToInt32 ()); - } - - SymDocumentWriter GetDocument (Document document) - { - if (document == null) - return null; - - SymDocumentWriter doc_writer; - if (documents.TryGetValue (document.Url, out doc_writer)) - return doc_writer; - - doc_writer = writer.DefineDocument ( - document.Url, - document.Language.ToGuid (), - document.LanguageVendor.ToGuid (), - document.Type.ToGuid ()); - - documents [document.Url] = doc_writer; - return doc_writer; - } - - public void Dispose () - { - var entry_point = module.EntryPoint; - if (entry_point != null) - writer.SetUserEntryPoint (entry_point.MetadataToken.ToInt32 ()); - - writer.Close (); - } - } - - enum CustomMetadataType : byte { - UsingInfo = 0, - ForwardInfo = 1, - IteratorScopes = 3, - ForwardIterator = 4, - } - - class CustomMetadataWriter : IDisposable { - - readonly SymWriter sym_writer; - readonly MemoryStream stream; - readonly BinaryStreamWriter writer; - - int count; - - const byte version = 4; - - public CustomMetadataWriter (SymWriter sym_writer) - { - this.sym_writer = sym_writer; - this.stream = new MemoryStream (); - this.writer = new BinaryStreamWriter (stream); - - writer.WriteByte (version); - writer.WriteByte (0); // count - writer.Align (4); - } - - public void WriteUsingInfo (ImportDebugInformation import_info) - { - Write (CustomMetadataType.UsingInfo, () => { - writer.WriteUInt16 ((ushort) 1); - writer.WriteUInt16 ((ushort) import_info.Targets.Count); - }); - } - - public void WriteForwardInfo (MetadataToken import_parent) - { - Write (CustomMetadataType.ForwardInfo, () => writer.WriteUInt32 (import_parent.ToUInt32 ())); - } - - public void WriteIteratorScopes (StateMachineScopeDebugInformation state_machine, MethodDebugInformation debug_info) - { - Write (CustomMetadataType.IteratorScopes, () => { - var scopes = state_machine.Scopes; - writer.WriteInt32 (scopes.Count); - foreach (var scope in scopes) { - var start = scope.Start.Offset; - var end = scope.End.IsEndOfMethod ? debug_info.code_size : scope.End.Offset; - writer.WriteInt32 (start); - writer.WriteInt32 (end - 1); - } - }); - } - - public void WriteForwardIterator (TypeReference type) - { - Write (CustomMetadataType.ForwardIterator, () => writer.WriteBytes(Encoding.Unicode.GetBytes(type.Name))); - } - - void Write (CustomMetadataType type, Action write) - { - count++; - writer.WriteByte (version); - writer.WriteByte ((byte) type); - writer.Align (4); - - var length_position = writer.Position; - writer.WriteUInt32 (0); - - write (); - writer.Align (4); - - var end = writer.Position; - var length = end - length_position + 4; // header is 4 bytes long - - writer.Position = length_position; - writer.WriteInt32 (length); - - writer.Position = end; - } - - public void WriteCustomMetadata () - { - if (count == 0) - return; - - writer.BaseStream.Position = 1; - writer.WriteByte ((byte) count); - writer.Flush (); - - sym_writer.DefineCustomMetadata ("MD2", stream.ToArray ()); - } - - public void Dispose () - { - stream.Dispose (); - } - } -} - -#endif diff --git a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbHelper.cs b/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbHelper.cs deleted file mode 100644 index eb75f3d11d..0000000000 --- a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/PdbHelper.cs +++ /dev/null @@ -1,130 +0,0 @@ -// -// Author: -// Jb Evain (jbevain@gmail.com) -// -// Copyright (c) 2008 - 2015 Jb Evain -// Copyright (c) 2008 - 2011 Novell, Inc. -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.IO; - -using Mono.Cecil.Cil; - -namespace Mono.Cecil.Pdb { - - public sealed class NativePdbReaderProvider : ISymbolReaderProvider { - - public ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName) - { - Mixin.CheckModule (module); - Mixin.CheckFileName (fileName); - - return new NativePdbReader (Disposable.Owned (File.OpenRead (Mixin.GetPdbFileName (fileName)) as Stream)); - } - - public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream) - { - Mixin.CheckModule (module); - Mixin.CheckStream (symbolStream); - - return new NativePdbReader (Disposable.NotOwned (symbolStream)); - } - } - - public sealed class PdbReaderProvider : ISymbolReaderProvider { - - public ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName) - { - Mixin.CheckModule (module); - Mixin.CheckFileName (fileName); - - if (module.HasDebugHeader) { - var header = module.GetDebugHeader (); - var entry = header.GetEmbeddedPortablePdbEntry (); - if (entry != null) - return new EmbeddedPortablePdbReaderProvider ().GetSymbolReader (module, fileName); - } - - return Mixin.IsPortablePdb (Mixin.GetPdbFileName (fileName)) - ? new PortablePdbReaderProvider ().GetSymbolReader (module, fileName) - : new NativePdbReaderProvider ().GetSymbolReader (module, fileName); - } - - public ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream) - { - Mixin.CheckModule (module); - Mixin.CheckStream (symbolStream); - Mixin.CheckReadSeek (symbolStream); - - return Mixin.IsPortablePdb (symbolStream) - ? new PortablePdbReaderProvider ().GetSymbolReader (module, symbolStream) - : new NativePdbReaderProvider ().GetSymbolReader (module, symbolStream); - } - } - -#if !READ_ONLY - - public sealed class NativePdbWriterProvider : ISymbolWriterProvider { - - public ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName) - { - Mixin.CheckModule (module); - Mixin.CheckFileName (fileName); - - return new NativePdbWriter (module, CreateWriter (module, Mixin.GetPdbFileName (fileName))); - } - - static SymWriter CreateWriter (ModuleDefinition module, string pdb) - { - var writer = new SymWriter (); - - if (File.Exists (pdb)) - File.Delete (pdb); - - writer.Initialize (new ModuleMetadata (module), pdb, true); - - return writer; - } - - public ISymbolWriter GetSymbolWriter (ModuleDefinition module, Stream symbolStream) - { - throw new NotImplementedException (); - } - } - - public sealed class PdbWriterProvider : ISymbolWriterProvider { - - public ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName) - { - Mixin.CheckModule (module); - Mixin.CheckFileName (fileName); - - if (HasPortablePdbSymbols (module)) - return new PortablePdbWriterProvider ().GetSymbolWriter (module, fileName); - - return new NativePdbWriterProvider ().GetSymbolWriter (module, fileName); - } - - static bool HasPortablePdbSymbols (ModuleDefinition module) - { - return module.symbol_reader != null && module.symbol_reader is PortablePdbReader; - } - - public ISymbolWriter GetSymbolWriter (ModuleDefinition module, Stream symbolStream) - { - Mixin.CheckModule (module); - Mixin.CheckStream (symbolStream); - Mixin.CheckReadSeek (symbolStream); - - if (HasPortablePdbSymbols (module)) - return new PortablePdbWriterProvider ().GetSymbolWriter (module, symbolStream); - - return new NativePdbWriterProvider ().GetSymbolWriter (module, symbolStream); - } - } - -#endif -} diff --git a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/SymDocumentWriter.cs b/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/SymDocumentWriter.cs deleted file mode 100644 index a2bd1a2bd8..0000000000 --- a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/SymDocumentWriter.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -// Author: -// Juerg Billeter (j@bitron.ch) -// -// (C) 2008 Juerg Billeter -// -// Licensed under the MIT/X11 license. -// - -using System; - -#if !READ_ONLY - -namespace Mono.Cecil.Pdb -{ - internal class SymDocumentWriter - { - readonly ISymUnmanagedDocumentWriter m_unmanagedDocumentWriter; - - public SymDocumentWriter (ISymUnmanagedDocumentWriter unmanagedDocumentWriter) - { - m_unmanagedDocumentWriter = unmanagedDocumentWriter; - } - - public ISymUnmanagedDocumentWriter GetUnmanaged () - { - return m_unmanagedDocumentWriter; - } - } -} - -#endif diff --git a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs b/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs deleted file mode 100644 index 5ecf2173bd..0000000000 --- a/external/linker/cecil/symbols/pdb/Mono.Cecil.Pdb/SymWriter.cs +++ /dev/null @@ -1,160 +0,0 @@ -// -// Author: -// Juerg Billeter (j@bitron.ch) -// -// (C) 2008 Juerg Billeter -// -// Licensed under the MIT/X11 license. -// - -using System; -using System.Runtime.InteropServices; - -using Mono.Cecil.Cil; -using Mono.Collections.Generic; - -#if !READ_ONLY - -namespace Mono.Cecil.Pdb -{ - internal class SymWriter - { - [DllImport("ole32.dll")] - static extern int CoCreateInstance ( - [In] ref Guid rclsid, - [In, MarshalAs (UnmanagedType.IUnknown)] object pUnkOuter, - [In] uint dwClsContext, - [In] ref Guid riid, - [Out, MarshalAs (UnmanagedType.Interface)] out object ppv); - - static Guid s_symUnmangedWriterIID = new Guid("0b97726e-9e6d-4f05-9a26-424022093caa"); - static Guid s_CorSymWriter_SxS_ClassID = new Guid ("108296c1-281e-11d3-bd22-0000f80849bd"); - - readonly ISymUnmanagedWriter2 m_writer; - readonly Collection documents; - - public SymWriter () - { - object objWriter; - CoCreateInstance (ref s_CorSymWriter_SxS_ClassID, null, 1, ref s_symUnmangedWriterIID, out objWriter); - - m_writer = (ISymUnmanagedWriter2) objWriter; - documents = new Collection (); - } - - public byte[] GetDebugInfo (out ImageDebugDirectory idd) - { - int size; - - // get size of debug info - m_writer.GetDebugInfo (out idd, 0, out size, null); - - byte[] debug_info = new byte[size]; - m_writer.GetDebugInfo (out idd, size, out size, debug_info); - - return debug_info; - } - - public void DefineLocalVariable2 ( - string name, - VariableAttributes attributes, - int sigToken, - int addr1, - int addr2, - int addr3, - int startOffset, - int endOffset) - { - m_writer.DefineLocalVariable2 (name, (int)attributes, sigToken, 1 /* ILOffset*/, addr1, addr2, addr3, startOffset, endOffset); - } - - public void DefineConstant2 (string name, object value, int sigToken) - { - if (value == null) { - m_writer.DefineConstant2 (name, 0, sigToken); - return; - } - - m_writer.DefineConstant2 (name, value, sigToken); - } - - public void Close () - { - m_writer.Close (); - Marshal.ReleaseComObject (m_writer); - - foreach (var document in documents) - Marshal.ReleaseComObject (document); - } - - public void CloseMethod () - { - m_writer.CloseMethod (); - } - - public void CloseNamespace () - { - m_writer.CloseNamespace (); - } - - public void CloseScope (int endOffset) - { - m_writer.CloseScope (endOffset); - } - - public SymDocumentWriter DefineDocument (string url, Guid language, Guid languageVendor, Guid documentType) - { - ISymUnmanagedDocumentWriter unmanagedDocumentWriter; - m_writer.DefineDocument (url, ref language, ref languageVendor, ref documentType, out unmanagedDocumentWriter); - - documents.Add (unmanagedDocumentWriter); - return new SymDocumentWriter (unmanagedDocumentWriter); - } - - public void DefineSequencePoints (SymDocumentWriter document, int[] offsets, int[] lines, int[] columns, int[] endLines, int[] endColumns) - { - m_writer.DefineSequencePoints (document.GetUnmanaged(), offsets.Length, offsets, lines, columns, endLines, endColumns); - } - - public void Initialize (object emitter, string filename, bool fFullBuild) - { - m_writer.Initialize (emitter, filename, null, fFullBuild); - } - - public void SetUserEntryPoint (int methodToken) - { - m_writer.SetUserEntryPoint (methodToken); - } - - public void OpenMethod (int methodToken) - { - m_writer.OpenMethod (methodToken); - } - - public void OpenNamespace (string name) - { - m_writer.OpenNamespace (name); - } - - public int OpenScope (int startOffset) - { - int result; - m_writer.OpenScope (startOffset, out result); - return result; - } - - public void UsingNamespace (string fullName) - { - m_writer.UsingNamespace (fullName); - } - - public void DefineCustomMetadata (string name, byte [] metadata) - { - var handle = GCHandle.Alloc (metadata, GCHandleType.Pinned); - m_writer.SetSymAttribute (0, name, (uint) metadata.Length, handle.AddrOfPinnedObject ()); - handle.Free (); - } - } -} - -#endif diff --git a/external/linker/cecil/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj b/external/linker/cecil/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj deleted file mode 100644 index 2b03651a9e..0000000000 --- a/external/linker/cecil/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - {29300103-CB76-4A1D-B6FD-FFD91C1EC8AA} - Mono.Cecil.Pdb.Tests - Mono.Cecil.Pdb.Tests - - - - {D68133BD-1E63-496E-9EDE-4FBDBF77B486} - Mono.Cecil - - - {A47B1F49-A81A-43E8-BE6B-DD28AF2C4055} - Mono.Cecil.Tests - - - {63E6915C-7EA4-4D76-AB28-0D7191EEA626} - Mono.Cecil.Pdb - - - - - - - - - - - \ No newline at end of file diff --git a/external/linker/cecil/symbols/pdb/Test/Mono.Cecil.Tests/PdbTests.cs b/external/linker/cecil/symbols/pdb/Test/Mono.Cecil.Tests/PdbTests.cs deleted file mode 100644 index b6fdcdf566..0000000000 --- a/external/linker/cecil/symbols/pdb/Test/Mono.Cecil.Tests/PdbTests.cs +++ /dev/null @@ -1,468 +0,0 @@ -#if !READ_ONLY -using System.IO; -using System.Linq; - -using Mono.Cecil.Cil; -using Mono.Cecil.Pdb; - -using NUnit.Framework; - -namespace Mono.Cecil.Tests { - - [TestFixture] - public class PdbTests : BaseTestFixture { - - [Test] - public void Main () - { - TestModule ("test.exe", module => { - var type = module.GetType ("Program"); - var main = type.GetMethod ("Main"); - - AssertCode (@" - .locals init (System.Int32 i, System.Int32 CS$1$0000, System.Boolean CS$4$0001) - .line 6,6:2,3 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs' - IL_0000: nop - .line 7,7:8,18 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs' - IL_0001: ldc.i4.0 - IL_0002: stloc.0 - .line hidden 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs' - IL_0003: br.s IL_0012 - .line 8,8:4,21 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs' - IL_0005: ldarg.0 - IL_0006: ldloc.0 - IL_0007: ldelem.ref - IL_0008: call System.Void Program::Print(System.String) - IL_000d: nop - .line 7,7:36,39 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs' - IL_000e: ldloc.0 - IL_000f: ldc.i4.1 - IL_0010: add - IL_0011: stloc.0 - .line 7,7:19,34 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs' - IL_0012: ldloc.0 - IL_0013: ldarg.0 - IL_0014: ldlen - IL_0015: conv.i4 - IL_0016: clt - IL_0018: stloc.2 - .line hidden 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs' - IL_0019: ldloc.2 - IL_001a: brtrue.s IL_0005 - .line 10,10:3,12 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs' - IL_001c: ldc.i4.0 - IL_001d: stloc.1 - IL_001e: br.s IL_0020 - .line 11,11:2,3 'c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs' - IL_0020: ldloc.1 - IL_0021: ret -", main); - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider)); - } - - [Test] - public void DebuggerHiddenVariable () - { - TestModule ("test.exe", module => { - var type = module.GetType ("Program"); - var method = type.GetMethod ("Main"); - - var scope = method.DebugInformation.Scope; - - Assert.IsTrue (scope.HasVariables); - var variables = scope.Variables; - - Assert.AreEqual ("CS$1$0000", variables [0].Name); - Assert.IsTrue (variables [0].IsDebuggerHidden); - Assert.AreEqual ("CS$4$0001", variables [1].Name); - Assert.IsTrue (variables [1].IsDebuggerHidden); - - Assert.AreEqual (1, scope.Scopes.Count); - scope = scope.Scopes [0]; - variables = scope.Variables; - - Assert.AreEqual ("i", variables [0].Name); - Assert.IsFalse (variables [0].IsDebuggerHidden); - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider)); - } - - [Test] - public void Document () - { - TestModule ("test.exe", module => { - var type = module.GetType ("Program"); - var method = type.GetMethod ("Main"); - - var sequence_point = method.DebugInformation.SequencePoints.First (sp => sp != null); - var document = sequence_point.Document; - - Assert.IsNotNull (document); - - Assert.AreEqual (@"c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs", document.Url); - Assert.AreEqual (DocumentType.Text, document.Type); - Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm); - Assert.AreEqual (DocumentLanguage.CSharp, document.Language); - Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor); - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider)); - } - - [Test] - public void BasicDocument () - { - TestModule ("VBConsApp.exe", module => { - var type = module.GetType ("VBConsApp.Program"); - var method = type.GetMethod ("Main"); - - var sequence_point = method.DebugInformation.SequencePoints.First (sp => sp != null); - var document = sequence_point.Document; - - Assert.IsNotNull (document); - - Assert.AreEqual (@"c:\tmp\VBConsApp\Program.vb", document.Url); - Assert.AreEqual (DocumentType.Text, document.Type); - Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm); - Assert.AreEqual (DocumentLanguage.Basic, document.Language); - Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor); - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider)); - } - - [Test] - public void FSharpDocument () - { - TestModule ("fsapp.exe", module => { - var type = module.GetType ("Program"); - var method = type.GetMethod ("fact"); - - var sequence_point = method.DebugInformation.SequencePoints.First (sp => sp != null); - var document = sequence_point.Document; - - Assert.IsNotNull (document); - - Assert.AreEqual (@"c:\tmp\fsapp\Program.fs", document.Url); - Assert.AreEqual (DocumentType.Text, document.Type); - Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm); - Assert.AreEqual (DocumentLanguage.FSharp, document.Language); - Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor); - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider)); - } - - [Test] - public void EmptyEnumerable () - { - TestModule ("empty-iterator.dll", module => { - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider)); - } - - [Test] - public void EmptyRootNamespace () - { - TestModule ("EmptyRootNamespace.dll", module => { - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider)); - } - - [Test] - public void VisualBasicNamespace () - { - TestModule ("AVbTest.exe", module => { - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider)); - - } - - [Test] - public void LocalVariables () - { - TestModule ("ComplexPdb.dll", module => { - var type = module.GetType ("ComplexPdb.Program"); - var method = type.GetMethod ("Bar"); - var debug_info = method.DebugInformation; - - Assert.IsNotNull (debug_info.Scope); - Assert.IsTrue (debug_info.Scope.HasScopes); - Assert.AreEqual (2, debug_info.Scope.Scopes.Count); - - var scope = debug_info.Scope.Scopes [0]; - - Assert.IsNotNull (scope); - Assert.IsTrue (scope.HasVariables); - Assert.AreEqual (1, scope.Variables.Count); - - var variable = scope.Variables [0]; - - Assert.AreEqual ("s", variable.Name); - Assert.IsFalse (variable.IsDebuggerHidden); - Assert.AreEqual (2, variable.Index); - - scope = debug_info.Scope.Scopes [1]; - - Assert.IsNotNull (scope); - Assert.IsTrue (scope.HasVariables); - Assert.AreEqual (1, scope.Variables.Count); - - variable = scope.Variables [0]; - - Assert.AreEqual ("s", variable.Name); - Assert.IsFalse (variable.IsDebuggerHidden); - Assert.AreEqual (3, variable.Index); - - Assert.IsTrue (scope.HasScopes); - Assert.AreEqual (1, scope.Scopes.Count); - - scope = scope.Scopes [0]; - - Assert.IsNotNull (scope); - Assert.IsTrue (scope.HasVariables); - Assert.AreEqual (1, scope.Variables.Count); - - variable = scope.Variables [0]; - - Assert.AreEqual ("u", variable.Name); - Assert.IsFalse (variable.IsDebuggerHidden); - Assert.AreEqual (5, variable.Index); - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider)); - } - - [Test] - public void LocalConstants () - { - TestModule ("ComplexPdb.dll", module => { - var type = module.GetType ("ComplexPdb.Program"); - var method = type.GetMethod ("Bar"); - var debug_info = method.DebugInformation; - - Assert.IsNotNull (debug_info.Scope); - Assert.IsTrue (debug_info.Scope.HasScopes); - Assert.AreEqual (2, debug_info.Scope.Scopes.Count); - - var scope = debug_info.Scope.Scopes [1]; - - Assert.IsNotNull (scope); - Assert.IsTrue (scope.HasConstants); - Assert.AreEqual (2, scope.Constants.Count); - - var constant = scope.Constants [0]; - - Assert.AreEqual ("b", constant.Name); - Assert.AreEqual (12, constant.Value); - Assert.AreEqual (MetadataType.Int32, constant.ConstantType.MetadataType); - - constant = scope.Constants [1]; - Assert.AreEqual ("c", constant.Name); - Assert.AreEqual ((decimal) 74, constant.Value); - Assert.AreEqual (MetadataType.ValueType, constant.ConstantType.MetadataType); - - method = type.GetMethod ("Foo"); - debug_info = method.DebugInformation; - - Assert.IsNotNull (debug_info.Scope); - Assert.IsTrue (debug_info.Scope.HasConstants); - Assert.AreEqual (4, debug_info.Scope.Constants.Count); - - constant = debug_info.Scope.Constants [0]; - Assert.AreEqual ("s", constant.Name); - Assert.AreEqual ("const string", constant.Value); - Assert.AreEqual (MetadataType.String, constant.ConstantType.MetadataType); - - constant = debug_info.Scope.Constants [1]; - Assert.AreEqual ("f", constant.Name); - Assert.AreEqual (1, constant.Value); - Assert.AreEqual (MetadataType.Int32, constant.ConstantType.MetadataType); - - constant = debug_info.Scope.Constants [2]; - Assert.AreEqual ("o", constant.Name); - Assert.AreEqual (null, constant.Value); - Assert.AreEqual (MetadataType.Object, constant.ConstantType.MetadataType); - - constant = debug_info.Scope.Constants [3]; - Assert.AreEqual ("u", constant.Name); - Assert.AreEqual (null, constant.Value); - Assert.AreEqual (MetadataType.String, constant.ConstantType.MetadataType); - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider)); - } - - [Test] - public void ImportScope () - { - TestModule ("ComplexPdb.dll", module => { - var type = module.GetType ("ComplexPdb.Program"); - var method = type.GetMethod ("Bar"); - var debug_info = method.DebugInformation; - - Assert.IsNotNull (debug_info.Scope); - - var import = debug_info.Scope.Import; - Assert.IsNotNull (import); - - Assert.IsTrue (import.HasTargets); - Assert.AreEqual (6, import.Targets.Count); - var target = import.Targets [0]; - - Assert.AreEqual (ImportTargetKind.ImportNamespace, target.Kind); - Assert.AreEqual ("System", target.Namespace); - - target = import.Targets [1]; - - Assert.AreEqual (ImportTargetKind.ImportNamespace, target.Kind); - Assert.AreEqual ("System.Collections.Generic", target.Namespace); - - target = import.Targets [2]; - - Assert.AreEqual (ImportTargetKind.ImportNamespace, target.Kind); - Assert.AreEqual ("System.Threading.Tasks", target.Namespace); - - target = import.Targets [3]; - - Assert.AreEqual (ImportTargetKind.ImportType, target.Kind); - Assert.AreEqual ("System.Console", target.Type.FullName); - - target = import.Targets [4]; - - Assert.AreEqual (ImportTargetKind.DefineTypeAlias, target.Kind); - Assert.AreEqual ("Foo1", target.Alias); - Assert.AreEqual ("System.Console", target.Type.FullName); - - target = import.Targets [5]; - - Assert.AreEqual (ImportTargetKind.DefineNamespaceAlias, target.Kind); - Assert.AreEqual ("Foo2", target.Alias); - Assert.AreEqual ("System.Reflection", target.Namespace); - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider)); - } - - [Test] - public void StateMachineKickOff () - { - TestModule ("ComplexPdb.dll", module => { - var state_machine = module.GetType ("ComplexPdb.Program/d__2"); - var move_next = state_machine.GetMethod ("MoveNext"); - var symbol = move_next.DebugInformation; - - Assert.IsNotNull (symbol); - Assert.IsNotNull (symbol.StateMachineKickOffMethod); - Assert.AreEqual ("System.Threading.Tasks.Task ComplexPdb.Program::TestAsync()", symbol.StateMachineKickOffMethod.FullName); - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider)); - } - - [Test] - public void Iterators () - { - TestModule ("ComplexPdb.dll", module => { - var state_machine = module.GetType ("ComplexPdb.Program/d__2"); - var move_next = state_machine.GetMethod ("MoveNext"); - - Assert.IsTrue (move_next.DebugInformation.HasCustomDebugInformations); - Assert.AreEqual (2, move_next.DebugInformation.CustomDebugInformations.Count); - - var state_machine_scope = move_next.DebugInformation.CustomDebugInformations [0] as StateMachineScopeDebugInformation; - Assert.IsNotNull (state_machine_scope); - Assert.AreEqual (1, state_machine_scope.Scopes.Count); - Assert.AreEqual (142, state_machine_scope.Scopes [0].Start.Offset); - Assert.AreEqual (319, state_machine_scope.Scopes [0].End.Offset); - - var async_body = move_next.DebugInformation.CustomDebugInformations [1] as AsyncMethodBodyDebugInformation; - Assert.IsNotNull (async_body); - Assert.AreEqual (-1, async_body.CatchHandler.Offset); - - Assert.AreEqual (2, async_body.Yields.Count); - Assert.AreEqual (68, async_body.Yields [0].Offset); - Assert.AreEqual (197, async_body.Yields [1].Offset); - - Assert.AreEqual (2, async_body.Resumes.Count); - Assert.AreEqual (98, async_body.Resumes [0].Offset); - Assert.AreEqual (227, async_body.Resumes [1].Offset); - - Assert.AreEqual (move_next, async_body.ResumeMethods [0]); - Assert.AreEqual (move_next, async_body.ResumeMethods [1]); - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider)); - } - - [Test] - public void ImportsForFirstMethod () - { - TestModule ("CecilTest.exe", module => { - var type = module.GetType ("CecilTest.Program"); - var method = type.GetMethod ("Main"); - - var debug = method.DebugInformation; - var scope = debug.Scope; - - Assert.IsTrue (scope.End.IsEndOfMethod); - - var import = scope.Import; - - Assert.IsNotNull (import); - Assert.AreEqual (5, import.Targets.Count); - - var ns = new [] { - "System", - "System.Collections.Generic", - "System.Linq", - "System.Text", - "System.Threading.Tasks", - }; - - for (int i = 0; i < import.Targets.Count; i++) { - var target = import.Targets [i]; - - Assert.AreEqual (ImportTargetKind.ImportNamespace, target.Kind); - Assert.AreEqual (ns [i], target.Namespace); - } - - Assert.AreEqual ("System", import.Targets [0].Namespace); - }, readOnly: Platform.OnMono, symbolReaderProvider: typeof (PdbReaderProvider), symbolWriterProvider: typeof (PdbWriterProvider)); - } - - [Test] - public void CreateMethodFromScratch () - { - IgnoreOnMono (); - - var module = ModuleDefinition.CreateModule ("Pan", ModuleKind.Dll); - var type = new TypeDefinition ("Pin", "Pon", TypeAttributes.Public | TypeAttributes.Abstract | TypeAttributes.Sealed, module.ImportReference (typeof (object))); - module.Types.Add (type); - - var method = new MethodDefinition ("Pang", MethodAttributes.Public | MethodAttributes.Static, module.ImportReference (typeof (string))); - type.Methods.Add (method); - - var body = method.Body; - - body.InitLocals = true; - - var il = body.GetILProcessor (); - var temp = new VariableDefinition (module.ImportReference (typeof (string))); - body.Variables.Add (temp); - - il.Emit (OpCodes.Nop); - il.Emit (OpCodes.Ldstr, "hello"); - il.Emit (OpCodes.Stloc, temp); - il.Emit (OpCodes.Ldloc, temp); - il.Emit (OpCodes.Ret); - - var sequence_point = new SequencePoint (body.Instructions [0], new Document (@"C:\test.cs")) { - StartLine = 0, - StartColumn = 0, - EndLine = 0, - EndColumn = 4, - }; - - method.DebugInformation.SequencePoints.Add (sequence_point); - - method.DebugInformation.Scope = new ScopeDebugInformation (body.Instructions [0], null) { - Variables = { new VariableDebugInformation (temp, "temp") } - }; - - var file = Path.Combine (Path.GetTempPath (), "Pan.dll"); - module.Write (file, new WriterParameters { - SymbolWriterProvider = new PdbWriterProvider (), - }); - - module = ModuleDefinition.ReadModule (file, new ReaderParameters { - SymbolReaderProvider = new PdbReaderProvider (), - }); - - method = module.GetType ("Pin.Pon").GetMethod ("Pang"); - - Assert.AreEqual ("temp", method.DebugInformation.Scope.Variables [0].Name); - } - } -} -#endif \ No newline at end of file diff --git a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/AVbTest.pdb b/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/AVbTest.pdb deleted file mode 100644 index c46ce47b3c..0000000000 Binary files a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/AVbTest.pdb and /dev/null differ diff --git a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/CecilTest.pdb b/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/CecilTest.pdb deleted file mode 100644 index 712efcbcfd..0000000000 Binary files a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/CecilTest.pdb and /dev/null differ diff --git a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/ComplexPdb.cs b/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/ComplexPdb.cs deleted file mode 100644 index ae29775cbe..0000000000 --- a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/ComplexPdb.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using static System.Console; -using Foo1 = System.Console; -using Foo2 = System.Reflection; - -namespace ComplexPdb -{ - public class Program - { - private static void Foo() - { - const string s = "const string"; - const int f = 1; - const object o = null; - const string u = null; - WriteLine(s); - WriteLine(2); - } - - private static void Bar(int i) - { - int result; - if (i < 0) - { - int s = 1; - result = s; - } - else - { - const int b = 12; - const decimal c = 74; - int s = -1; - result = s + b + (int)c; - if (result > b) - { - int u = result * b; - Console.WriteLine(u); - } - } - WriteLine(result); - } - - public async Task TestAsync() - { - WriteLine("Hello1"); - await Task.Delay(100); - - for (int i = 0; i < 4; ++i) - { - WriteLine("Hello2"); - await Task.Delay(100); - WriteLine("Hello3"); - } - } - - public IEnumerable TestIterator() - { - WriteLine("Hello1"); - yield return "Hello1"; - - for (int i = 0; i < 4; ++i) - { - WriteLine("Hello1"); - yield return "Hello2"; - WriteLine("Hello3"); - } - } - } -} diff --git a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/ComplexPdb.pdb b/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/ComplexPdb.pdb deleted file mode 100644 index 0aef0e3eb9..0000000000 Binary files a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/ComplexPdb.pdb and /dev/null differ diff --git a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/EmptyRootNamespace.pdb b/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/EmptyRootNamespace.pdb deleted file mode 100644 index 9550eceb56..0000000000 Binary files a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/EmptyRootNamespace.pdb and /dev/null differ diff --git a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/PdbTarget.pdb b/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/PdbTarget.pdb deleted file mode 100644 index f9ef6a0be0..0000000000 Binary files a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/PdbTarget.pdb and /dev/null differ diff --git a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/VBConsApp.pdb b/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/VBConsApp.pdb deleted file mode 100644 index 2625666b40..0000000000 Binary files a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/VBConsApp.pdb and /dev/null differ diff --git a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/empty-iterator.pdb b/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/empty-iterator.pdb deleted file mode 100644 index 42f57a6fb7..0000000000 Binary files a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/empty-iterator.pdb and /dev/null differ diff --git a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/fsapp.pdb b/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/fsapp.pdb deleted file mode 100644 index 3743d24be8..0000000000 Binary files a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/fsapp.pdb and /dev/null differ diff --git a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/test.pdb b/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/test.pdb deleted file mode 100644 index 1bad2a11c8..0000000000 Binary files a/external/linker/cecil/symbols/pdb/Test/Resources/assemblies/test.pdb and /dev/null differ diff --git a/mcs/build/common/Consts.cs b/mcs/build/common/Consts.cs index c28472a1e0..d18617b13a 100644 --- a/mcs/build/common/Consts.cs +++ b/mcs/build/common/Consts.cs @@ -41,7 +41,7 @@ static partial class Consts // Use these assembly version constants to make code more maintainable. // - public const string MonoVersion = "6.0.0.172"; + public const string MonoVersion = "6.0.0.176"; public const string MonoCompany = "Mono development team"; public const string MonoProduct = "Mono Common Language Infrastructure"; public const string MonoCopyright = "(c) Various Mono authors"; diff --git a/mcs/class/corlib/Test/System.IO/FileTest.cs b/mcs/class/corlib/Test/System.IO/FileTest.cs index 35d4641a8a..4840f6ba79 100644 --- a/mcs/class/corlib/Test/System.IO/FileTest.cs +++ b/mcs/class/corlib/Test/System.IO/FileTest.cs @@ -2593,6 +2593,9 @@ namespace MonoTests.System.IO public static extern int symlink (string oldpath, string newpath); [Test] +#if MONOTOUCH_TV + [Ignore ("See bug #59239: https://bugzilla.xamarin.com/show_bug.cgi?id=59239")] +#endif [Category ("NotWasm")] public void SymLinkStats() { if (!RunningOnUnix) @@ -2650,7 +2653,7 @@ namespace MonoTests.System.IO [Test] #if MONOTOUCH_TV - [Ignore ("See bug #59239")] + [Ignore ("See bug #59239: https://bugzilla.xamarin.com/show_bug.cgi?id=59239")] #endif [Category ("NotWasm")] public void SymLinkLoop () diff --git a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id index c89e15ccda..4135a0cb00 100644 --- a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id @@ -1 +1 @@ -afeeb56043367c7bcc9cbd66209da8cd5d7d7f75 \ No newline at end of file +3bb5075309cfee79947231190b6c06970814ecbf \ No newline at end of file diff --git a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id index c1ee085b05..6466c305cb 100644 --- a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id @@ -1 +1 @@ -cfbfe5c511362bf5545ef7420415dcb8aee72a42 \ No newline at end of file +4eff81e78b9af7cda22830830d3d49092a6b7018 \ No newline at end of file diff --git a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id index a339fe31e2..e7338d7154 100644 --- a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id @@ -1 +1 @@ -9826ed13a0e9dfe60927f42708d25f586254ddb7 \ No newline at end of file +3b0cda7b19ee016a6f2b3ad97ef9a6ddd8b9bbe5 \ No newline at end of file diff --git a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll index c56232fbdf..3349e66486 100644 Binary files a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll and b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll differ diff --git a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id index 9afb812e55..d971464fd3 100644 --- a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id @@ -1 +1 @@ -c4c5cff7297872225c62c9da4d8b7af016ca4a9b \ No newline at end of file +167a06dea1a9f639eed2d5ae04afc5c23891d656 \ No newline at end of file diff --git a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id index 01fa62852e..123bcc6a47 100644 --- a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id @@ -1 +1 @@ -6f8a43861c48d8f188b350be907b648bd870a55a \ No newline at end of file +71b6657d1ec9f6a632e30c9ed789ef7fd6e97b70 \ No newline at end of file diff --git a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id index 7363852cd5..9026f8c0b2 100644 --- a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id +++ b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id @@ -1 +1 @@ -21df3db3b5697fbd4c398790a72ec91643584e7c \ No newline at end of file +81c98bb54997edda2c51abc2c020a02ef58bcb65 \ No newline at end of file diff --git a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id index 99200397c1..fcd657b321 100644 --- a/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-linux/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id @@ -1 +1 @@ -2cf00fd56f1e6df0c410ea978639662194436aa4 \ No newline at end of file +02e92c8371781b6e97eef8cd9fff063521233353 \ No newline at end of file diff --git a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id index c89e15ccda..4135a0cb00 100644 --- a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id @@ -1 +1 @@ -afeeb56043367c7bcc9cbd66209da8cd5d7d7f75 \ No newline at end of file +3bb5075309cfee79947231190b6c06970814ecbf \ No newline at end of file diff --git a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id index c1ee085b05..6466c305cb 100644 --- a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id @@ -1 +1 @@ -cfbfe5c511362bf5545ef7420415dcb8aee72a42 \ No newline at end of file +4eff81e78b9af7cda22830830d3d49092a6b7018 \ No newline at end of file diff --git a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id index a339fe31e2..e7338d7154 100644 --- a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id @@ -1 +1 @@ -9826ed13a0e9dfe60927f42708d25f586254ddb7 \ No newline at end of file +3b0cda7b19ee016a6f2b3ad97ef9a6ddd8b9bbe5 \ No newline at end of file diff --git a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll index c56232fbdf..3349e66486 100644 Binary files a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll and b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll differ diff --git a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id index 9afb812e55..d971464fd3 100644 --- a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id @@ -1 +1 @@ -c4c5cff7297872225c62c9da4d8b7af016ca4a9b \ No newline at end of file +167a06dea1a9f639eed2d5ae04afc5c23891d656 \ No newline at end of file diff --git a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id index 01fa62852e..123bcc6a47 100644 --- a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id @@ -1 +1 @@ -6f8a43861c48d8f188b350be907b648bd870a55a \ No newline at end of file +71b6657d1ec9f6a632e30c9ed789ef7fd6e97b70 \ No newline at end of file diff --git a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id index 7363852cd5..9026f8c0b2 100644 --- a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id +++ b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id @@ -1 +1 @@ -21df3db3b5697fbd4c398790a72ec91643584e7c \ No newline at end of file +81c98bb54997edda2c51abc2c020a02ef58bcb65 \ No newline at end of file diff --git a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id index 99200397c1..fcd657b321 100644 --- a/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-macos/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id @@ -1 +1 @@ -2cf00fd56f1e6df0c410ea978639662194436aa4 \ No newline at end of file +02e92c8371781b6e97eef8cd9fff063521233353 \ No newline at end of file diff --git a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id index c89e15ccda..4135a0cb00 100644 --- a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id @@ -1 +1 @@ -afeeb56043367c7bcc9cbd66209da8cd5d7d7f75 \ No newline at end of file +3bb5075309cfee79947231190b6c06970814ecbf \ No newline at end of file diff --git a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id index c1ee085b05..6466c305cb 100644 --- a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id @@ -1 +1 @@ -cfbfe5c511362bf5545ef7420415dcb8aee72a42 \ No newline at end of file +4eff81e78b9af7cda22830830d3d49092a6b7018 \ No newline at end of file diff --git a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id index a339fe31e2..e7338d7154 100644 --- a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id @@ -1 +1 @@ -9826ed13a0e9dfe60927f42708d25f586254ddb7 \ No newline at end of file +3b0cda7b19ee016a6f2b3ad97ef9a6ddd8b9bbe5 \ No newline at end of file diff --git a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll index c56232fbdf..3349e66486 100644 Binary files a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll and b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll differ diff --git a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id index 9afb812e55..d971464fd3 100644 --- a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id @@ -1 +1 @@ -c4c5cff7297872225c62c9da4d8b7af016ca4a9b \ No newline at end of file +167a06dea1a9f639eed2d5ae04afc5c23891d656 \ No newline at end of file diff --git a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id index 01fa62852e..123bcc6a47 100644 --- a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id @@ -1 +1 @@ -6f8a43861c48d8f188b350be907b648bd870a55a \ No newline at end of file +71b6657d1ec9f6a632e30c9ed789ef7fd6e97b70 \ No newline at end of file diff --git a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id index 7363852cd5..9026f8c0b2 100644 --- a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id +++ b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id @@ -1 +1 @@ -21df3db3b5697fbd4c398790a72ec91643584e7c \ No newline at end of file +81c98bb54997edda2c51abc2c020a02ef58bcb65 \ No newline at end of file diff --git a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id index 99200397c1..fcd657b321 100644 --- a/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-unix/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id @@ -1 +1 @@ -2cf00fd56f1e6df0c410ea978639662194436aa4 \ No newline at end of file +02e92c8371781b6e97eef8cd9fff063521233353 \ No newline at end of file diff --git a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id index c89e15ccda..4135a0cb00 100644 --- a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/Mono.Security.dll.REMOVED.git-id @@ -1 +1 @@ -afeeb56043367c7bcc9cbd66209da8cd5d7d7f75 \ No newline at end of file +3bb5075309cfee79947231190b6c06970814ecbf \ No newline at end of file diff --git a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id index c1ee085b05..6466c305cb 100644 --- a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Configuration.dll.REMOVED.git-id @@ -1 +1 @@ -cfbfe5c511362bf5545ef7420415dcb8aee72a42 \ No newline at end of file +4eff81e78b9af7cda22830830d3d49092a6b7018 \ No newline at end of file diff --git a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id index a862543d07..be40159b0a 100644 --- a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Core.dll.REMOVED.git-id @@ -1 +1 @@ -3be13eb343c9f4191ce6709401a73db58478d105 \ No newline at end of file +be628dd9444478c2a5afb7a005df151971572827 \ No newline at end of file diff --git a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll index c56232fbdf..3349e66486 100644 Binary files a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll and b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.IO.Compression.dll differ diff --git a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id index 9afb812e55..d971464fd3 100644 --- a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Numerics.dll.REMOVED.git-id @@ -1 +1 @@ -c4c5cff7297872225c62c9da4d8b7af016ca4a9b \ No newline at end of file +167a06dea1a9f639eed2d5ae04afc5c23891d656 \ No newline at end of file diff --git a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id index 01fa62852e..123bcc6a47 100644 --- a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/System.Xml.dll.REMOVED.git-id @@ -1 +1 @@ -6f8a43861c48d8f188b350be907b648bd870a55a \ No newline at end of file +71b6657d1ec9f6a632e30c9ed789ef7fd6e97b70 \ No newline at end of file diff --git a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id index 7363852cd5..9026f8c0b2 100644 --- a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id +++ b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mcs.exe.REMOVED.git-id @@ -1 +1 @@ -21df3db3b5697fbd4c398790a72ec91643584e7c \ No newline at end of file +81c98bb54997edda2c51abc2c020a02ef58bcb65 \ No newline at end of file diff --git a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id index b16accf0de..349922a353 100644 --- a/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id +++ b/mcs/class/lib/monolite-win32/9032116E-BB4E-4ED5-9C71-9E5E0B0230CA/mscorlib.dll.REMOVED.git-id @@ -1 +1 @@ -3b9957c98ee6ad90b9933648eca9699aaba33607 \ No newline at end of file +21392ca5aa714720fd915319eaf0d6c04eea22fc \ No newline at end of file diff --git a/mcs/class/referencesource/mscorlib/system/typedreference.cs b/mcs/class/referencesource/mscorlib/system/typedreference.cs index 534fa30537..3dc06b4d31 100644 --- a/mcs/class/referencesource/mscorlib/system/typedreference.cs +++ b/mcs/class/referencesource/mscorlib/system/typedreference.cs @@ -56,7 +56,7 @@ namespace System { if (field == null) throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeFieldInfo")); - if (field.IsInitOnly || field.IsStatic) + if (field.IsStatic) throw new ArgumentException(Environment.GetResourceString("Argument_TypedReferenceInvalidField")); if (targetType != field.GetDeclaringTypeInternal() && !targetType.IsSubclassOf(field.GetDeclaringTypeInternal())) diff --git a/mono/metadata/w32socket-unix.c b/mono/metadata/w32socket-unix.c index f66c7be6be..6afe95813e 100644 --- a/mono/metadata/w32socket-unix.c +++ b/mono/metadata/w32socket-unix.c @@ -1545,6 +1545,9 @@ mono_w32socket_convert_error (gint error) #endif #ifdef ENXIO case ENXIO: return WSAENXIO; +#endif +#ifdef ENONET + case ENONET: return WSAENETUNREACH; #endif default: g_error ("%s: no translation into winsock error for (%d) \"%s\"", __func__, error, g_strerror (error)); diff --git a/mono/mini/version.h b/mono/mini/version.h index 7fca73a546..9f87930aa4 100644 --- a/mono/mini/version.h +++ b/mono/mini/version.h @@ -1 +1 @@ -#define FULL_VERSION "explicit/b31a8fa" +#define FULL_VERSION "explicit/d75c142" diff --git a/mono/unit-tests/Makefile.in b/mono/unit-tests/Makefile.in index 10239928c1..6330aae0ca 100644 --- a/mono/unit-tests/Makefile.in +++ b/mono/unit-tests/Makefile.in @@ -1430,10 +1430,10 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -@CROSS_COMPILE_TRUE@clean-local: -@HOST_WIN32_TRUE@clean-local: @CROSS_COMPILE_TRUE@test-local: @HOST_WIN32_TRUE@test-local: +@CROSS_COMPILE_TRUE@clean-local: +@HOST_WIN32_TRUE@clean-local: clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libtool clean-local \ diff --git a/po/mcs/de.gmo b/po/mcs/de.gmo index 1017bc1d6e..d9be6b6e10 100644 Binary files a/po/mcs/de.gmo and b/po/mcs/de.gmo differ diff --git a/po/mcs/de.po.REMOVED.git-id b/po/mcs/de.po.REMOVED.git-id index 351d3424df..0cea546239 100644 --- a/po/mcs/de.po.REMOVED.git-id +++ b/po/mcs/de.po.REMOVED.git-id @@ -1 +1 @@ -b5f7b8d151a1bf16eee374789875ce956c2fadfc \ No newline at end of file +20b0d421c5e2324009181031d01e869357c82ca5 \ No newline at end of file diff --git a/po/mcs/es.gmo b/po/mcs/es.gmo index cdab7ca0f5..c11b3a2856 100644 Binary files a/po/mcs/es.gmo and b/po/mcs/es.gmo differ diff --git a/po/mcs/es.po.REMOVED.git-id b/po/mcs/es.po.REMOVED.git-id index 198a84bbb5..1b01524d68 100644 --- a/po/mcs/es.po.REMOVED.git-id +++ b/po/mcs/es.po.REMOVED.git-id @@ -1 +1 @@ -b87047048c1ef9607b5ce7690ea5ff4f52b0ff8d \ No newline at end of file +dfa0243662d7a67bddbe9b8c3537f166d520e289 \ No newline at end of file diff --git a/po/mcs/ja.gmo b/po/mcs/ja.gmo index cc64ff428b..1784db4678 100644 Binary files a/po/mcs/ja.gmo and b/po/mcs/ja.gmo differ diff --git a/po/mcs/ja.po.REMOVED.git-id b/po/mcs/ja.po.REMOVED.git-id index a2bdc12043..8ab3ab2844 100644 --- a/po/mcs/ja.po.REMOVED.git-id +++ b/po/mcs/ja.po.REMOVED.git-id @@ -1 +1 @@ -fca4eaa92e563db8c9ff407a68d7129459562d10 \ No newline at end of file +3666efe6a8bfde05515288d200864e987a0362c9 \ No newline at end of file diff --git a/po/mcs/mcs.pot b/po/mcs/mcs.pot index ccc7db431a..7003a56f04 100644 --- a/po/mcs/mcs.pot +++ b/po/mcs/mcs.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: mono 6.0.0.172\n" +"Project-Id-Version: mono 6.0.0.176\n" "Report-Msgid-Bugs-To: http://www.mono-project.com/Bugs\n" -"POT-Creation-Date: 2019-04-12 13:43+0000\n" +"POT-Creation-Date: 2019-04-13 08:06+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/po/mcs/pt_BR.gmo b/po/mcs/pt_BR.gmo index 8546ff54cc..d188ba00f9 100644 Binary files a/po/mcs/pt_BR.gmo and b/po/mcs/pt_BR.gmo differ diff --git a/po/mcs/pt_BR.po.REMOVED.git-id b/po/mcs/pt_BR.po.REMOVED.git-id index 1fa3c9db40..8c614c764e 100644 --- a/po/mcs/pt_BR.po.REMOVED.git-id +++ b/po/mcs/pt_BR.po.REMOVED.git-id @@ -1 +1 @@ -f79477407585531887c408b1a8768c718bec052c \ No newline at end of file +b61652d1049177932bbbf3fb70bae129f1204ae6 \ No newline at end of file