Table of Contents

Class DataFlowVisitor<State>

Namespace
ICSharpCode.Decompiler.FlowAnalysis
Assembly
ICSharpCode.Decompiler.dll

Generic base class for forward data flow analyses.

public abstract class DataFlowVisitor<State> : ILVisitor where State : IDataFlowState<State>

Type Parameters

State

The state type used for the data flow analysis. See IDataFlowState<Self> for details.

Inheritance
DataFlowVisitor<State>
Inherited Members

Constructors

DataFlowVisitor()

protected DataFlowVisitor()

Fields

currentStateOnException

Combined state of all possible exceptional control flow paths in the current try block. Serves as input state for catch blocks.

Caution: any state object assigned to this member gets mutated as the visitor encounters instructions that may throw exceptions!

Within a try block, currentStateOnException == stateOnException[tryBlock.Parent].

protected State currentStateOnException

Field Value

State
See Also

flagsRequiringManualImpl

Derived classes may add to this set of flags to ensure they don't forget to override an interesting method.

protected InstructionFlags flagsRequiringManualImpl

Field Value

InstructionFlags

state

Current state.

Caution: any state object assigned to this member gets mutated as the visitor traverses the ILAst!

protected State state

Field Value

State

Methods

BeginTryCatchHandler(TryCatchHandler)

protected virtual void BeginTryCatchHandler(TryCatchHandler inst)

Parameters

inst TryCatchHandler

DebugEndPoint(ILInstruction)

[Conditional("DEBUG")]
protected void DebugEndPoint(ILInstruction inst)

Parameters

inst ILInstruction

DebugStartPoint(ILInstruction)

[Conditional("DEBUG")]
protected void DebugStartPoint(ILInstruction inst)

Parameters

inst ILInstruction

Default(ILInstruction)

Called by Visit*() methods that were not overridden

protected override sealed void Default(ILInstruction inst)

Parameters

inst ILInstruction

HandleMatchStore(MatchInstruction)

protected abstract void HandleMatchStore(MatchInstruction inst)

Parameters

inst MatchInstruction

HandleTryBlock(TryInstruction)

Visits the TryBlock.

Returns a new State object representing the exceptional control flow transfer out of the try block.

protected State HandleTryBlock(TryInstruction inst)

Parameters

inst TryInstruction

Returns

State

Initialize(State)

Initializes the DataFlowVisitor. This method must be called once before any Visit()-methods can be called. It must not be called more than once.

protected void Initialize(State initialState)

Parameters

initialState State

The initial state at the entry point of the analysis.

Remarks

This is a method instead of a constructor because derived classes might need complex initialization before they can construct the initial state.

MarkUnreachable()

Replace the current state with the bottom state.

protected void MarkUnreachable()

PropagateStateOnException()

Handle control flow when the current instruction throws an exception: joins the current state into the "exception state" of the current try block.

protected void PropagateStateOnException()

Remarks

This should not only be called for instructions that may throw an exception, but for all instructions (due to async exceptions like ThreadAbortException)!

To avoid redundant calls, every Visit() call may assume that the current state is already propagated, and has to guarantee the same at the end. This means this method should be called after every state change. Alternatively, derived classes may directly modify both state and currentStateOnException, so that a full JoinWith() call is not necessary.

VisitBlockContainer(BlockContainer)

protected override void VisitBlockContainer(BlockContainer container)

Parameters

container BlockContainer

VisitBranch(Branch)

protected override void VisitBranch(Branch inst)

Parameters

inst Branch

VisitDynamicLogicOperatorInstruction(DynamicLogicOperatorInstruction)

protected override void VisitDynamicLogicOperatorInstruction(DynamicLogicOperatorInstruction inst)

Parameters

inst DynamicLogicOperatorInstruction

VisitILFunction(ILFunction)

protected override void VisitILFunction(ILFunction function)

Parameters

function ILFunction

VisitIfInstruction(IfInstruction)

protected override void VisitIfInstruction(IfInstruction inst)

Parameters

inst IfInstruction

VisitInvalidBranch(InvalidBranch)

protected override void VisitInvalidBranch(InvalidBranch inst)

Parameters

inst InvalidBranch

VisitLeave(Leave)

protected override void VisitLeave(Leave inst)

Parameters

inst Leave

VisitLockInstruction(LockInstruction)

protected override void VisitLockInstruction(LockInstruction inst)

Parameters

inst LockInstruction

VisitMatchInstruction(MatchInstruction)

protected override void VisitMatchInstruction(MatchInstruction inst)

Parameters

inst MatchInstruction

VisitNullCoalescingInstruction(NullCoalescingInstruction)

protected override void VisitNullCoalescingInstruction(NullCoalescingInstruction inst)

Parameters

inst NullCoalescingInstruction

VisitNullableRewrap(NullableRewrap)

protected override void VisitNullableRewrap(NullableRewrap inst)

Parameters

inst NullableRewrap

VisitNullableUnwrap(NullableUnwrap)

protected override void VisitNullableUnwrap(NullableUnwrap inst)

Parameters

inst NullableUnwrap

VisitRethrow(Rethrow)

protected override void VisitRethrow(Rethrow inst)

Parameters

inst Rethrow

VisitSwitchInstruction(SwitchInstruction)

protected override void VisitSwitchInstruction(SwitchInstruction inst)

Parameters

inst SwitchInstruction

VisitThrow(Throw)

protected override void VisitThrow(Throw inst)

Parameters

inst Throw

VisitTryCatch(TryCatch)

protected override void VisitTryCatch(TryCatch inst)

Parameters

inst TryCatch

VisitTryCatchHandler(TryCatchHandler)

TryCatchHandler is handled directly in VisitTryCatch

protected override sealed void VisitTryCatchHandler(TryCatchHandler inst)

Parameters

inst TryCatchHandler

VisitTryFault(TryFault)

protected override void VisitTryFault(TryFault inst)

Parameters

inst TryFault

VisitTryFinally(TryFinally)

protected override void VisitTryFinally(TryFinally inst)

Parameters

inst TryFinally

VisitUserDefinedLogicOperator(UserDefinedLogicOperator)

protected override void VisitUserDefinedLogicOperator(UserDefinedLogicOperator inst)

Parameters

inst UserDefinedLogicOperator

VisitUsingInstruction(UsingInstruction)

protected override void VisitUsingInstruction(UsingInstruction inst)

Parameters

inst UsingInstruction

VisitYieldReturn(YieldReturn)

protected override void VisitYieldReturn(YieldReturn inst)

Parameters

inst YieldReturn