mirror of https://github.com/icsharpcode/ILSpy.git
27 changed files with 1606 additions and 393 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
// Copyright (c) 2014 Daniel Grunwald
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Threading.Tasks; |
||||
namespace ICSharpCode.Decompiler.IL |
||||
{ |
||||
public abstract class BinaryComparisonInstruction : BinaryInstruction |
||||
{ |
||||
public readonly StackType OpType; |
||||
|
||||
protected BinaryComparisonInstruction(OpCode opCode, StackType opType) : base(opCode) |
||||
{ |
||||
this.OpType = opType; |
||||
} |
||||
|
||||
public sealed override StackType ResultType { |
||||
get { |
||||
return StackType.I4; |
||||
} |
||||
} |
||||
|
||||
public override void WriteTo(ITextOutput output) |
||||
{ |
||||
output.Write(OpCode); |
||||
output.Write('.'); |
||||
output.Write(OpType); |
||||
output.Write('('); |
||||
Left.WriteTo(output); |
||||
output.Write(", "); |
||||
Right.WriteTo(output); |
||||
output.Write(')'); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,84 @@
@@ -0,0 +1,84 @@
|
||||
// Copyright (c) 2014 Daniel Grunwald
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Threading.Tasks; |
||||
namespace ICSharpCode.Decompiler.IL |
||||
{ |
||||
[Flags] |
||||
public enum OverflowMode : byte |
||||
{ |
||||
/// <summary>Don't check for overflow, treat integers as signed.</summary>
|
||||
None = 0, |
||||
/// <summary>Check for overflow, treat integers as signed.</summary>
|
||||
Ovf = 1, |
||||
/// <summary>Don't check for overflow, treat integers as unsigned.</summary>
|
||||
Un = 2, |
||||
/// <summary>Check for overflow, treat integers as unsigned.</summary>
|
||||
Ovf_Un = 3 |
||||
} |
||||
|
||||
public abstract class BinaryNumericInstruction : BinaryInstruction |
||||
{ |
||||
public readonly StackType OpType; |
||||
|
||||
public readonly OverflowMode OverflowMode; |
||||
|
||||
readonly StackType resultType; |
||||
|
||||
protected BinaryNumericInstruction(OpCode opCode, StackType opType, StackType resultType, OverflowMode overflowMode) : base(opCode) |
||||
{ |
||||
this.OpType = opType; |
||||
this.resultType = resultType; |
||||
this.OverflowMode = overflowMode; |
||||
} |
||||
|
||||
public sealed override StackType ResultType { |
||||
get { |
||||
return resultType; |
||||
} |
||||
} |
||||
|
||||
protected override InstructionFlags ComputeFlags() |
||||
{ |
||||
var flags = base.ComputeFlags(); |
||||
if ((OverflowMode & OverflowMode.Ovf) != 0) |
||||
flags |= InstructionFlags.MayThrow; |
||||
return flags; |
||||
} |
||||
|
||||
public override void WriteTo(ITextOutput output) |
||||
{ |
||||
output.Write(OpCode); |
||||
output.WriteSuffix(OverflowMode); |
||||
output.Write(' '); |
||||
output.Write(OpType); |
||||
output.Write('('); |
||||
Left.WriteTo(output); |
||||
output.Write(", "); |
||||
Right.WriteTo(output); |
||||
output.Write(')'); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2014 Daniel Grunwald
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 ICSharpCode.Decompiler.IL |
||||
{ |
||||
partial class Conv : UnaryInstruction |
||||
{ |
||||
public readonly StackType FromType; |
||||
public readonly PrimitiveType ToType; |
||||
public readonly OverflowMode ConvMode; |
||||
|
||||
public Conv(StackType fromType, PrimitiveType toType, OverflowMode convMode) : base(OpCode.Conv) |
||||
{ |
||||
this.FromType = fromType; |
||||
this.ToType = toType; |
||||
this.ConvMode = convMode; |
||||
} |
||||
|
||||
public override void WriteTo(ITextOutput output) |
||||
{ |
||||
output.Write(OpCode); |
||||
output.WriteSuffix(ConvMode); |
||||
output.Write(' '); |
||||
output.Write(FromType); |
||||
output.Write("->"); |
||||
output.Write(ToType); |
||||
output.Write('('); |
||||
Argument.WriteTo(output); |
||||
output.Write(')'); |
||||
} |
||||
|
||||
protected override InstructionFlags ComputeFlags() |
||||
{ |
||||
var flags = base.ComputeFlags(); |
||||
if ((ConvMode & OverflowMode.Ovf) != 0) |
||||
flags |= InstructionFlags.MayThrow; |
||||
return flags; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
// Copyright (c) 2014 Daniel Grunwald
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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.Diagnostics; |
||||
|
||||
namespace ICSharpCode.Decompiler.IL |
||||
{ |
||||
partial class Return |
||||
{ |
||||
/// <summary>
|
||||
/// The value to return. Null if this return statement is within a void method.
|
||||
/// </summary>
|
||||
public ILInstruction Argument = null; |
||||
|
||||
internal override void CheckInvariant() |
||||
{ |
||||
base.CheckInvariant(); |
||||
if (Argument != null) { |
||||
Argument.CheckInvariant(); |
||||
Debug.Assert(Argument.ResultType != StackType.Void); |
||||
} |
||||
} |
||||
|
||||
public override void WriteTo(ITextOutput output) |
||||
{ |
||||
output.Write(OpCode); |
||||
if (Argument != null) { |
||||
output.Write('('); |
||||
Argument.WriteTo(output); |
||||
output.Write(')'); |
||||
} |
||||
} |
||||
|
||||
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func) |
||||
{ |
||||
TAccumulate value = initial; |
||||
if (Argument != null) |
||||
value = func(value, Argument.AcceptVisitor(visitor)); |
||||
return value; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2014 Daniel Grunwald
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 ICSharpCode.Decompiler.IL.Visitors |
||||
{ |
||||
sealed class CountPopInstructionsVisitor : ILVisitor<int> |
||||
{ |
||||
protected override int Default(ILInstruction inst) |
||||
{ |
||||
return inst.AggregateChildren(0, this, (a, b) => a + b); |
||||
} |
||||
|
||||
protected internal override int VisitPop(Pop inst) |
||||
{ |
||||
return 1; |
||||
} |
||||
|
||||
protected internal override int VisitBlock(Block inst) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue