Class ControlFlowGraph.InstructionContextImpl
- java.lang.Object
-
- org.apache.bcel.verifier.structurals.ControlFlowGraph.InstructionContextImpl
-
- All Implemented Interfaces:
InstructionContext
- Enclosing class:
- ControlFlowGraph
private class ControlFlowGraph.InstructionContextImpl extends java.lang.Object implements InstructionContext
Objects of this class represent a node in a ControlFlowGraph. These nodes are instructions, not basic blocks.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<InstructionContext>executionPredecessorsThe 'execution predecessors' - a list of type InstructionContext of those instances that have been execute()d before in that order.private java.util.Map<InstructionContext,Frame>inFramesThe 'incoming' execution Frames.private InstructionHandleinstructionThe InstructionHandle this InstructionContext is wrapped around.private java.util.Map<InstructionContext,Frame>outFramesThe 'outgoing' execution Frames.private intTAGThe TAG field is here for external temporary flagging, such as graph colouring.
-
Constructor Summary
Constructors Constructor Description InstructionContextImpl(InstructionHandle inst)Creates an InstructionHandleImpl object from an InstructionHandle.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private InstructionHandle[]_getSuccessors()A utility method that calculates the successors of a given InstructionHandle That means, a RET does have successors as defined here.booleanexecute(Frame inFrame, java.util.ArrayList<InstructionContext> execPreds, InstConstraintVisitor icv, ExecutionVisitor ev)"Merges in" (vmspec2, page 146) the "incoming" frame situation; executes the instructions symbolically and therefore calculates the "outgoing" frame situation.private voidextendMessageWithFlow(StructuralCodeConstraintException e)Extends the StructuralCodeConstraintException ("e") object with an at-the-end-extended message.ExceptionHandler[]getExceptionHandlers()Returns the exception handlers of this instruction.private java.lang.StringgetExecutionChain()Returns the control flow execution chain.FramegetInFrame()InstructionHandlegetInstruction()Returns the InstructionHandle this InstructionContext is wrapped around.FramegetOutFrame(java.util.ArrayList<InstructionContext> execChain)Returns a clone of the "outgoing" frame situation with respect to the given ExecutionChain.InstructionContext[]getSuccessors()Returns the usual control flow successors.intgetTag()The getTag and setTag methods may be used for temporary flagging, such as graph colouring.private ControlFlowGraph.InstructionContextImpllastExecutionJSR()Returns the InstructionContextImpl with an JSR/JSR_W that was last in the ExecutionChain, without a corresponding RET, i.e.private booleanmergeInFrames(Frame inFrame)Does the actual merging (vmspec2, page 146).voidsetTag(int tag)The getTag and setTag methods may be used for temporary flagging, such as graph colouring.java.lang.StringtoString()Returns a simple String representation of this InstructionContext.
-
-
-
Field Detail
-
TAG
private int TAG
The TAG field is here for external temporary flagging, such as graph colouring.- See Also:
getTag(),setTag(int)
-
instruction
private final InstructionHandle instruction
The InstructionHandle this InstructionContext is wrapped around.
-
inFrames
private final java.util.Map<InstructionContext,Frame> inFrames
The 'incoming' execution Frames.
-
outFrames
private final java.util.Map<InstructionContext,Frame> outFrames
The 'outgoing' execution Frames.
-
executionPredecessors
private java.util.List<InstructionContext> executionPredecessors
The 'execution predecessors' - a list of type InstructionContext of those instances that have been execute()d before in that order.
-
-
Constructor Detail
-
InstructionContextImpl
public InstructionContextImpl(InstructionHandle inst)
Creates an InstructionHandleImpl object from an InstructionHandle. Creation of one per InstructionHandle suffices. Don't create more.
-
-
Method Detail
-
getTag
public int getTag()
Description copied from interface:InstructionContextThe getTag and setTag methods may be used for temporary flagging, such as graph colouring. Nothing in the InstructionContext object depends on the value of the tag. JustIce does not use it.- Specified by:
getTagin interfaceInstructionContext- See Also:
InstructionContext.setTag(int tag)
-
setTag
public void setTag(int tag)
Description copied from interface:InstructionContextThe getTag and setTag methods may be used for temporary flagging, such as graph colouring. Nothing in the InstructionContext object depends on the value of the tag. JustIce does not use it.- Specified by:
setTagin interfaceInstructionContext- See Also:
InstructionContext.getTag()
-
getExceptionHandlers
public ExceptionHandler[] getExceptionHandlers()
Returns the exception handlers of this instruction.- Specified by:
getExceptionHandlersin interfaceInstructionContext
-
getOutFrame
public Frame getOutFrame(java.util.ArrayList<InstructionContext> execChain)
Returns a clone of the "outgoing" frame situation with respect to the given ExecutionChain.- Specified by:
getOutFramein interfaceInstructionContext- See Also:
InstructionContext.execute(Frame, ArrayList, InstConstraintVisitor, ExecutionVisitor)
-
getInFrame
public Frame getInFrame()
- Specified by:
getInFramein interfaceInstructionContext
-
execute
public boolean execute(Frame inFrame, java.util.ArrayList<InstructionContext> execPreds, InstConstraintVisitor icv, ExecutionVisitor ev)
"Merges in" (vmspec2, page 146) the "incoming" frame situation; executes the instructions symbolically and therefore calculates the "outgoing" frame situation. Returns: True iff the "incoming" frame situation changed after merging with "inFrame". The execPreds ArrayList must contain the InstructionContext objects executed so far in the correct order. This is just one execution path [out of many]. This is needed to correctly "merge" in the special case of a RET's successor. The InstConstraintVisitor and ExecutionVisitor instances must be set up correctly.- Specified by:
executein interfaceInstructionContext- Returns:
- true - if and only if the "outgoing" frame situation changed from the one before execute()ing.
- See Also:
ControlFlowGraph,ExecutionVisitor,InstructionContext.getOutFrame(ArrayList)
-
toString
public java.lang.String toString()
Returns a simple String representation of this InstructionContext.- Overrides:
toStringin classjava.lang.Object
-
mergeInFrames
private boolean mergeInFrames(Frame inFrame)
Does the actual merging (vmspec2, page 146). Returns true IFF this.inFrame was changed in course of merging with inFrame.
-
getExecutionChain
private java.lang.String getExecutionChain()
Returns the control flow execution chain. This is built while execute(Frame, ArrayList)-ing the code represented by the surrounding ControlFlowGraph.
-
extendMessageWithFlow
private void extendMessageWithFlow(StructuralCodeConstraintException e)
Extends the StructuralCodeConstraintException ("e") object with an at-the-end-extended message. This extended message will then reflect the execution flow needed to get to the constraint violation that triggered the throwing of the "e" object.
-
getInstruction
public InstructionHandle getInstruction()
Description copied from interface:InstructionContextReturns the InstructionHandle this InstructionContext is wrapped around.- Specified by:
getInstructionin interfaceInstructionContext- Returns:
- The InstructionHandle this InstructionContext is wrapped around.
-
lastExecutionJSR
private ControlFlowGraph.InstructionContextImpl lastExecutionJSR()
Returns the InstructionContextImpl with an JSR/JSR_W that was last in the ExecutionChain, without a corresponding RET, i.e. we were called by this one. Returns null if we were called from the top level.
-
getSuccessors
public InstructionContext[] getSuccessors()
Description copied from interface:InstructionContextReturns the usual control flow successors.- Specified by:
getSuccessorsin interfaceInstructionContext- See Also:
InstructionContext.getExceptionHandlers()
-
_getSuccessors
private InstructionHandle[] _getSuccessors()
A utility method that calculates the successors of a given InstructionHandle That means, a RET does have successors as defined here. A JsrInstruction has its target as its successor (opposed to its physical successor) as defined here.
-
-