You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
parent
ee1447783b
commit
94b2861243
252
external/cecil-legacy/Mono.Cecil.Cil/Code.cs
vendored
Normal file
252
external/cecil-legacy/Mono.Cecil.Cil/Code.cs
vendored
Normal file
@@ -0,0 +1,252 @@
|
||||
//
|
||||
// Code.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
namespace Mono.Cecil.Cil {
|
||||
|
||||
public enum Code {
|
||||
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,
|
||||
}
|
||||
}
|
||||
598
external/cecil-legacy/Mono.Cecil.Cil/CodeReader.cs
vendored
Normal file
598
external/cecil-legacy/Mono.Cecil.Cil/CodeReader.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
649
external/cecil-legacy/Mono.Cecil.Cil/CodeWriter.cs
vendored
Normal file
649
external/cecil-legacy/Mono.Cecil.Cil/CodeWriter.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
112
external/cecil-legacy/Mono.Cecil.Cil/Document.cs
vendored
Normal file
112
external/cecil-legacy/Mono.Cecil.Cil/Document.cs
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// Document.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace Mono.Cecil.Cil {
|
||||
|
||||
public enum DocumentType {
|
||||
Other,
|
||||
Text,
|
||||
}
|
||||
|
||||
public enum DocumentHashAlgorithm {
|
||||
None,
|
||||
MD5,
|
||||
SHA1,
|
||||
}
|
||||
|
||||
public enum DocumentLanguage {
|
||||
Other,
|
||||
C,
|
||||
Cpp,
|
||||
CSharp,
|
||||
Basic,
|
||||
Java,
|
||||
Cobol,
|
||||
Pascal,
|
||||
Cil,
|
||||
JScript,
|
||||
Smc,
|
||||
MCpp,
|
||||
FSharp,
|
||||
}
|
||||
|
||||
public enum DocumentLanguageVendor {
|
||||
Other,
|
||||
Microsoft,
|
||||
}
|
||||
|
||||
public sealed class Document {
|
||||
|
||||
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<byte>.Array;
|
||||
}
|
||||
}
|
||||
}
|
||||
89
external/cecil-legacy/Mono.Cecil.Cil/ExceptionHandler.cs
vendored
Normal file
89
external/cecil-legacy/Mono.Cecil.Cil/ExceptionHandler.cs
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
//
|
||||
// ExceptionHandler.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
namespace Mono.Cecil.Cil {
|
||||
|
||||
public enum ExceptionHandlerType {
|
||||
Catch = 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
278
external/cecil-legacy/Mono.Cecil.Cil/ILProcessor.cs
vendored
Normal file
278
external/cecil-legacy/Mono.Cecil.Cil/ILProcessor.cs
vendored
Normal file
@@ -0,0 +1,278 @@
|
||||
//
|
||||
// ILProcessor.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
using Mono.Collections.Generic;
|
||||
|
||||
namespace Mono.Cecil.Cil {
|
||||
|
||||
public sealed class ILProcessor {
|
||||
|
||||
readonly MethodBody body;
|
||||
readonly Collection<Instruction> instructions;
|
||||
|
||||
public MethodBody Body {
|
||||
get { return body; }
|
||||
}
|
||||
|
||||
internal ILProcessor (MethodBody body)
|
||||
{
|
||||
this.body = body;
|
||||
this.instructions = body.Instructions;
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode)
|
||||
{
|
||||
return Instruction.Create (opcode);
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode, TypeReference type)
|
||||
{
|
||||
return Instruction.Create (opcode, type);
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode, CallSite site)
|
||||
{
|
||||
return Instruction.Create (opcode, site);
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode, MethodReference method)
|
||||
{
|
||||
return Instruction.Create (opcode, method);
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode, FieldReference field)
|
||||
{
|
||||
return Instruction.Create (opcode, field);
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode, string value)
|
||||
{
|
||||
return Instruction.Create (opcode, value);
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode, sbyte value)
|
||||
{
|
||||
return Instruction.Create (opcode, value);
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode, byte value)
|
||||
{
|
||||
if (opcode.OperandType == OperandType.ShortInlineVar)
|
||||
return Instruction.Create (opcode, body.Variables [value]);
|
||||
|
||||
if (opcode.OperandType == OperandType.ShortInlineArg)
|
||||
return Instruction.Create (opcode, body.GetParameter (value));
|
||||
|
||||
return Instruction.Create (opcode, value);
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode, int value)
|
||||
{
|
||||
if (opcode.OperandType == OperandType.InlineVar)
|
||||
return Instruction.Create (opcode, body.Variables [value]);
|
||||
|
||||
if (opcode.OperandType == OperandType.InlineArg)
|
||||
return Instruction.Create (opcode, body.GetParameter (value));
|
||||
|
||||
return Instruction.Create (opcode, value);
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode, long value)
|
||||
{
|
||||
return Instruction.Create (opcode, value);
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode, float value)
|
||||
{
|
||||
return Instruction.Create (opcode, value);
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode, double value)
|
||||
{
|
||||
return Instruction.Create (opcode, value);
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode, Instruction target)
|
||||
{
|
||||
return Instruction.Create (opcode, target);
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode, Instruction [] targets)
|
||||
{
|
||||
return Instruction.Create (opcode, targets);
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode, VariableDefinition variable)
|
||||
{
|
||||
return Instruction.Create (opcode, variable);
|
||||
}
|
||||
|
||||
public Instruction Create (OpCode opcode, ParameterDefinition parameter)
|
||||
{
|
||||
return Instruction.Create (opcode, parameter);
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode)
|
||||
{
|
||||
Append (Create (opcode));
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode, TypeReference type)
|
||||
{
|
||||
Append (Create (opcode, type));
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode, MethodReference method)
|
||||
{
|
||||
Append (Create (opcode, method));
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode, CallSite site)
|
||||
{
|
||||
Append (Create (opcode, site));
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode, FieldReference field)
|
||||
{
|
||||
Append (Create (opcode, field));
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode, string value)
|
||||
{
|
||||
Append (Create (opcode, value));
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode, byte value)
|
||||
{
|
||||
Append (Create (opcode, value));
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode, sbyte value)
|
||||
{
|
||||
Append (Create (opcode, value));
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode, int value)
|
||||
{
|
||||
Append (Create (opcode, value));
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode, long value)
|
||||
{
|
||||
Append (Create (opcode, value));
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode, float value)
|
||||
{
|
||||
Append (Create (opcode, value));
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode, double value)
|
||||
{
|
||||
Append (Create (opcode, value));
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode, Instruction target)
|
||||
{
|
||||
Append (Create (opcode, target));
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode, Instruction [] targets)
|
||||
{
|
||||
Append (Create (opcode, targets));
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode, VariableDefinition variable)
|
||||
{
|
||||
Append (Create (opcode, variable));
|
||||
}
|
||||
|
||||
public void Emit (OpCode opcode, ParameterDefinition parameter)
|
||||
{
|
||||
Append (Create (opcode, parameter));
|
||||
}
|
||||
|
||||
public void InsertBefore (Instruction target, Instruction instruction)
|
||||
{
|
||||
if (target == null)
|
||||
throw new ArgumentNullException ("target");
|
||||
if (instruction == null)
|
||||
throw new ArgumentNullException ("instruction");
|
||||
|
||||
var index = instructions.IndexOf (target);
|
||||
if (index == -1)
|
||||
throw new ArgumentOutOfRangeException ("target");
|
||||
|
||||
instructions.Insert (index, instruction);
|
||||
}
|
||||
|
||||
public void InsertAfter (Instruction target, Instruction instruction)
|
||||
{
|
||||
if (target == null)
|
||||
throw new ArgumentNullException ("target");
|
||||
if (instruction == null)
|
||||
throw new ArgumentNullException ("instruction");
|
||||
|
||||
var index = instructions.IndexOf (target);
|
||||
if (index == -1)
|
||||
throw new ArgumentOutOfRangeException ("target");
|
||||
|
||||
instructions.Insert (index + 1, instruction);
|
||||
}
|
||||
|
||||
public void Append (Instruction instruction)
|
||||
{
|
||||
if (instruction == null)
|
||||
throw new ArgumentNullException ("instruction");
|
||||
|
||||
instructions.Add (instruction);
|
||||
}
|
||||
|
||||
public void Replace (Instruction target, Instruction instruction)
|
||||
{
|
||||
if (target == null)
|
||||
throw new ArgumentNullException ("target");
|
||||
if (instruction == null)
|
||||
throw new ArgumentNullException ("instruction");
|
||||
|
||||
InsertAfter (target, instruction);
|
||||
Remove (target);
|
||||
}
|
||||
|
||||
public void Remove (Instruction instruction)
|
||||
{
|
||||
if (instruction == null)
|
||||
throw new ArgumentNullException ("instruction");
|
||||
|
||||
if (!instructions.Remove (instruction))
|
||||
throw new ArgumentOutOfRangeException ("instruction");
|
||||
}
|
||||
}
|
||||
}
|
||||
321
external/cecil-legacy/Mono.Cecil.Cil/Instruction.cs
vendored
Normal file
321
external/cecil-legacy/Mono.Cecil.Cil/Instruction.cs
vendored
Normal file
@@ -0,0 +1,321 @@
|
||||
//
|
||||
// Instruction.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Cecil.Cil {
|
||||
|
||||
public sealed class Instruction {
|
||||
|
||||
internal int offset;
|
||||
internal OpCode opcode;
|
||||
internal object operand;
|
||||
|
||||
internal Instruction previous;
|
||||
internal Instruction next;
|
||||
|
||||
SequencePoint sequence_point;
|
||||
|
||||
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; }
|
||||
}
|
||||
|
||||
public SequencePoint SequencePoint {
|
||||
get { return sequence_point; }
|
||||
set { sequence_point = 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
241
external/cecil-legacy/Mono.Cecil.Cil/MethodBody.cs
vendored
Normal file
241
external/cecil-legacy/Mono.Cecil.Cil/MethodBody.cs
vendored
Normal file
@@ -0,0 +1,241 @@
|
||||
//
|
||||
// MethodBody.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
using Mono.Collections.Generic;
|
||||
|
||||
namespace Mono.Cecil.Cil {
|
||||
|
||||
public sealed class MethodBody : IVariableDefinitionProvider {
|
||||
|
||||
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<Instruction> instructions;
|
||||
internal Collection<ExceptionHandler> exceptions;
|
||||
internal Collection<VariableDefinition> variables;
|
||||
Scope scope;
|
||||
|
||||
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<Instruction> Instructions {
|
||||
get { return instructions ?? (instructions = new InstructionCollection ()); }
|
||||
}
|
||||
|
||||
public bool HasExceptionHandlers {
|
||||
get { return !exceptions.IsNullOrEmpty (); }
|
||||
}
|
||||
|
||||
public Collection<ExceptionHandler> ExceptionHandlers {
|
||||
get { return exceptions ?? (exceptions = new Collection<ExceptionHandler> ()); }
|
||||
}
|
||||
|
||||
public bool HasVariables {
|
||||
get { return !variables.IsNullOrEmpty (); }
|
||||
}
|
||||
|
||||
public Collection<VariableDefinition> Variables {
|
||||
get { return variables ?? (variables = new VariableDefinitionCollection ()); }
|
||||
}
|
||||
|
||||
public Scope Scope {
|
||||
get { return scope; }
|
||||
set { scope = value; }
|
||||
}
|
||||
|
||||
public ParameterDefinition ThisParameter {
|
||||
get {
|
||||
if (method == null || method.DeclaringType == null)
|
||||
throw new NotSupportedException ();
|
||||
|
||||
if (!method.HasThis)
|
||||
return null;
|
||||
|
||||
if (this_parameter != null)
|
||||
return this_parameter;
|
||||
|
||||
var declaring_type = method.DeclaringType;
|
||||
var type = declaring_type.IsValueType || declaring_type.IsPrimitive
|
||||
? new PointerType (declaring_type)
|
||||
: declaring_type as TypeReference;
|
||||
|
||||
return this_parameter = new ParameterDefinition (type, method);
|
||||
}
|
||||
}
|
||||
|
||||
public MethodBody (MethodDefinition method)
|
||||
{
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public ILProcessor GetILProcessor ()
|
||||
{
|
||||
return new ILProcessor (this);
|
||||
}
|
||||
}
|
||||
|
||||
public interface IVariableDefinitionProvider {
|
||||
bool HasVariables { get; }
|
||||
Collection<VariableDefinition> Variables { get; }
|
||||
}
|
||||
|
||||
class VariableDefinitionCollection : Collection<VariableDefinition> {
|
||||
|
||||
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<Instruction> {
|
||||
|
||||
internal InstructionCollection ()
|
||||
{
|
||||
}
|
||||
|
||||
internal InstructionCollection (int capacity)
|
||||
: base (capacity)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnAdd (Instruction item, int index)
|
||||
{
|
||||
if (index == 0)
|
||||
return;
|
||||
|
||||
var previous = items [index - 1];
|
||||
previous.next = item;
|
||||
item.previous = previous;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
item.previous = null;
|
||||
item.next = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
455
external/cecil-legacy/Mono.Cecil.Cil/OpCode.cs
vendored
Normal file
455
external/cecil-legacy/Mono.Cecil.Cil/OpCode.cs
vendored
Normal file
@@ -0,0 +1,455 @@
|
||||
//
|
||||
// OpCode.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
namespace Mono.Cecil.Cil {
|
||||
|
||||
public enum 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 {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
912
external/cecil-legacy/Mono.Cecil.Cil/OpCodes.cs
vendored
Normal file
912
external/cecil-legacy/Mono.Cecil.Cil/OpCodes.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
70
external/cecil-legacy/Mono.Cecil.Cil/SequencePoint.cs
vendored
Normal file
70
external/cecil-legacy/Mono.Cecil.Cil/SequencePoint.cs
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// SequencePoint.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
namespace Mono.Cecil.Cil {
|
||||
|
||||
public sealed class SequencePoint {
|
||||
|
||||
Document document;
|
||||
|
||||
int start_line;
|
||||
int start_column;
|
||||
int end_line;
|
||||
int end_column;
|
||||
|
||||
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 Document Document {
|
||||
get { return document; }
|
||||
set { document = value; }
|
||||
}
|
||||
|
||||
public SequencePoint (Document document)
|
||||
{
|
||||
this.document = document;
|
||||
}
|
||||
}
|
||||
}
|
||||
277
external/cecil-legacy/Mono.Cecil.Cil/Symbols.cs
vendored
Normal file
277
external/cecil-legacy/Mono.Cecil.Cil/Symbols.cs
vendored
Normal file
@@ -0,0 +1,277 @@
|
||||
//
|
||||
// Symbols.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using SR = System.Reflection;
|
||||
|
||||
using Mono.Collections.Generic;
|
||||
|
||||
namespace Mono.Cecil.Cil {
|
||||
|
||||
[StructLayout (LayoutKind.Sequential)]
|
||||
public struct ImageDebugDirectory {
|
||||
public int Characteristics;
|
||||
public int TimeDateStamp;
|
||||
public short MajorVersion;
|
||||
public short MinorVersion;
|
||||
public int Type;
|
||||
public int SizeOfData;
|
||||
public int AddressOfRawData;
|
||||
public int PointerToRawData;
|
||||
}
|
||||
|
||||
public sealed class Scope : IVariableDefinitionProvider {
|
||||
|
||||
Instruction start;
|
||||
Instruction end;
|
||||
|
||||
Collection<Scope> scopes;
|
||||
Collection<VariableDefinition> variables;
|
||||
|
||||
public Instruction Start {
|
||||
get { return start; }
|
||||
set { start = value; }
|
||||
}
|
||||
|
||||
public Instruction End {
|
||||
get { return end; }
|
||||
set { end = value; }
|
||||
}
|
||||
|
||||
public bool HasScopes {
|
||||
get { return !scopes.IsNullOrEmpty (); }
|
||||
}
|
||||
|
||||
public Collection<Scope> Scopes {
|
||||
get {
|
||||
if (scopes == null)
|
||||
scopes = new Collection<Scope> ();
|
||||
|
||||
return scopes;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasVariables {
|
||||
get { return !variables.IsNullOrEmpty (); }
|
||||
}
|
||||
|
||||
public Collection<VariableDefinition> Variables {
|
||||
get {
|
||||
if (variables == null)
|
||||
variables = new Collection<VariableDefinition> ();
|
||||
|
||||
return variables;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct InstructionSymbol {
|
||||
|
||||
public readonly int Offset;
|
||||
public readonly SequencePoint SequencePoint;
|
||||
|
||||
public InstructionSymbol (int offset, SequencePoint sequencePoint)
|
||||
{
|
||||
this.Offset = offset;
|
||||
this.SequencePoint = sequencePoint;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MethodSymbols {
|
||||
|
||||
internal int code_size;
|
||||
internal string method_name;
|
||||
internal MetadataToken method_token;
|
||||
internal MetadataToken local_var_token;
|
||||
internal Collection<VariableDefinition> variables;
|
||||
internal Collection<InstructionSymbol> instructions;
|
||||
|
||||
public bool HasVariables {
|
||||
get { return !variables.IsNullOrEmpty (); }
|
||||
}
|
||||
|
||||
public Collection<VariableDefinition> Variables {
|
||||
get {
|
||||
if (variables == null)
|
||||
variables = new Collection<VariableDefinition> ();
|
||||
|
||||
return variables;
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<InstructionSymbol> Instructions {
|
||||
get {
|
||||
if (instructions == null)
|
||||
instructions = new Collection<InstructionSymbol> ();
|
||||
|
||||
return instructions;
|
||||
}
|
||||
}
|
||||
|
||||
public int CodeSize {
|
||||
get { return code_size; }
|
||||
}
|
||||
|
||||
public string MethodName {
|
||||
get { return method_name; }
|
||||
}
|
||||
|
||||
public MetadataToken MethodToken {
|
||||
get { return method_token; }
|
||||
}
|
||||
|
||||
public MetadataToken LocalVarToken {
|
||||
get { return local_var_token; }
|
||||
}
|
||||
|
||||
internal MethodSymbols (string methodName)
|
||||
{
|
||||
this.method_name = methodName;
|
||||
}
|
||||
|
||||
public MethodSymbols (MetadataToken methodToken)
|
||||
{
|
||||
this.method_token = methodToken;
|
||||
}
|
||||
}
|
||||
|
||||
public delegate Instruction InstructionMapper (int offset);
|
||||
|
||||
public interface ISymbolReader : IDisposable {
|
||||
|
||||
bool ProcessDebugHeader (ImageDebugDirectory directory, byte [] header);
|
||||
void Read (MethodBody body, InstructionMapper mapper);
|
||||
void Read (MethodSymbols symbols);
|
||||
}
|
||||
|
||||
public interface ISymbolReaderProvider {
|
||||
|
||||
ISymbolReader GetSymbolReader (ModuleDefinition module, string fileName);
|
||||
ISymbolReader GetSymbolReader (ModuleDefinition module, Stream symbolStream);
|
||||
}
|
||||
|
||||
static class SymbolProvider {
|
||||
|
||||
static readonly string symbol_kind = Type.GetType ("Mono.Runtime") != null ? "Mdb" : "Pdb";
|
||||
|
||||
static SR.AssemblyName GetPlatformSymbolAssemblyName ()
|
||||
{
|
||||
var cecil_name = typeof (SymbolProvider).Assembly.GetName ();
|
||||
|
||||
var name = new SR.AssemblyName {
|
||||
Name = "Mono.Cecil." + symbol_kind,
|
||||
Version = cecil_name.Version,
|
||||
};
|
||||
|
||||
name.SetPublicKeyToken (cecil_name.GetPublicKeyToken ());
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
static Type GetPlatformType (string fullname)
|
||||
{
|
||||
var type = Type.GetType (fullname);
|
||||
if (type != null)
|
||||
return type;
|
||||
|
||||
var assembly_name = GetPlatformSymbolAssemblyName ();
|
||||
|
||||
type = Type.GetType (fullname + ", " + assembly_name.FullName);
|
||||
if (type != null)
|
||||
return type;
|
||||
|
||||
try {
|
||||
var assembly = SR.Assembly.Load (assembly_name);
|
||||
if (assembly != null)
|
||||
return assembly.GetType (fullname);
|
||||
} catch (FileNotFoundException) {
|
||||
#if !CF
|
||||
} catch (FileLoadException) {
|
||||
#endif
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static ISymbolReaderProvider reader_provider;
|
||||
|
||||
public static ISymbolReaderProvider GetPlatformReaderProvider ()
|
||||
{
|
||||
if (reader_provider != null)
|
||||
return reader_provider;
|
||||
|
||||
var type = GetPlatformType (GetProviderTypeName ("ReaderProvider"));
|
||||
if (type == null)
|
||||
return null;
|
||||
|
||||
return reader_provider = (ISymbolReaderProvider) Activator.CreateInstance (type);
|
||||
}
|
||||
|
||||
static string GetProviderTypeName (string name)
|
||||
{
|
||||
return "Mono.Cecil." + symbol_kind + "." + symbol_kind + name;
|
||||
}
|
||||
|
||||
#if !READ_ONLY
|
||||
|
||||
static ISymbolWriterProvider writer_provider;
|
||||
|
||||
public static ISymbolWriterProvider GetPlatformWriterProvider ()
|
||||
{
|
||||
if (writer_provider != null)
|
||||
return writer_provider;
|
||||
|
||||
var type = GetPlatformType (GetProviderTypeName ("WriterProvider"));
|
||||
if (type == null)
|
||||
return null;
|
||||
|
||||
return writer_provider = (ISymbolWriterProvider) Activator.CreateInstance (type);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !READ_ONLY
|
||||
|
||||
public interface ISymbolWriter : IDisposable {
|
||||
|
||||
bool GetDebugHeader (out ImageDebugDirectory directory, out byte [] header);
|
||||
void Write (MethodBody body);
|
||||
void Write (MethodSymbols symbols);
|
||||
}
|
||||
|
||||
public interface ISymbolWriterProvider {
|
||||
|
||||
ISymbolWriter GetSymbolWriter (ModuleDefinition module, string fileName);
|
||||
ISymbolWriter GetSymbolWriter (ModuleDefinition module, Stream symbolStream);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
52
external/cecil-legacy/Mono.Cecil.Cil/VariableDefinition.cs
vendored
Normal file
52
external/cecil-legacy/Mono.Cecil.Cil/VariableDefinition.cs
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// VariableDefinition.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
namespace Mono.Cecil.Cil {
|
||||
|
||||
public sealed class VariableDefinition : VariableReference {
|
||||
|
||||
public bool IsPinned {
|
||||
get { return variable_type.IsPinned; }
|
||||
}
|
||||
|
||||
public VariableDefinition (TypeReference variableType)
|
||||
: base (variableType)
|
||||
{
|
||||
}
|
||||
|
||||
public VariableDefinition (string name, TypeReference variableType)
|
||||
: base (name, variableType)
|
||||
{
|
||||
}
|
||||
|
||||
public override VariableDefinition Resolve ()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
75
external/cecil-legacy/Mono.Cecil.Cil/VariableReference.cs
vendored
Normal file
75
external/cecil-legacy/Mono.Cecil.Cil/VariableReference.cs
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// VariableReference.cs
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2011 Jb Evain
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
namespace Mono.Cecil.Cil {
|
||||
|
||||
public abstract class VariableReference {
|
||||
|
||||
string name;
|
||||
internal int index = -1;
|
||||
protected TypeReference variable_type;
|
||||
|
||||
public string Name {
|
||||
get { return name; }
|
||||
set { name = value; }
|
||||
}
|
||||
|
||||
public TypeReference VariableType {
|
||||
get { return variable_type; }
|
||||
set { variable_type = value; }
|
||||
}
|
||||
|
||||
public int Index {
|
||||
get { return index; }
|
||||
}
|
||||
|
||||
internal VariableReference (TypeReference variable_type)
|
||||
: this (string.Empty, variable_type)
|
||||
{
|
||||
}
|
||||
|
||||
internal VariableReference (string name, TypeReference variable_type)
|
||||
{
|
||||
this.name = name;
|
||||
this.variable_type = variable_type;
|
||||
}
|
||||
|
||||
public abstract VariableDefinition Resolve ();
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
if (!string.IsNullOrEmpty (name))
|
||||
return name;
|
||||
|
||||
if (index >= 0)
|
||||
return "V_" + index;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user