using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ICSharpCode.Decompiler.IL { /// /// Represents a decoded IL instruction /// public abstract class ILInstruction(public readonly OpCode OpCode) { public static readonly ILInstruction Pop = new Pop(); /// /// Gets the ILRange for this instruction alone, ignoring the operands. /// public Interval ILRange; /// /// Gets whether this instruction peeks at the top value of the stack. /// If this instruction also pops elements from the stack, this property refers to the top value /// left after the pop operations. /// public abstract bool IsPeeking { get; } /// /// Gets whether the instruction produces no result. /// Instructions without result may not be used as arguments to other instructions; /// and do not result in a stack push when used as a top-level instruction within a block. /// public virtual bool NoResult { get { return false; } } /// /// Gets whether the end point of this instruction is reachable from the start point. /// Returns false if the instruction performs an unconditional branch, or always throws an exception. /// public virtual bool IsEndReachable { get { return true; } } public abstract InstructionFlags Flags { get; } public virtual void WriteTo(ITextOutput output) { output.Write(OpCode); } /// /// Attempts inlining from the instruction stack into this instruction. /// /// Combined instruction flags of the instructions /// that the instructions getting inlined would get moved over. /// The instruction stack. /// Receives 'true' if all open 'pop' or 'peek' placeholders were inlined into; false otherwise. internal abstract ILInstruction Inline(InstructionFlags flagsBefore, Stack instructionStack, out bool finished); public abstract void TransformChildren(Func transformFunc); } }