Class Subroutines.SubroutineImpl
java.lang.Object
org.apache.bcel.verifier.structurals.Subroutines.SubroutineImpl
- All Implemented Interfaces:
Subroutine
- Enclosing class:
Subroutines
This inner class implements the Subroutine interface.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Subroutines.SubroutineImpl[]
private final Set
<InstructionHandle> The instructions that belong to this subroutine.private int
The Local Variable slot where the first instruction of this subroutine (an ASTORE) stores the JsrInstruction's ReturnAddress in and the RET of this subroutine operates on.private final Set
<InstructionHandle> The JSR or JSR_W instructions that define this subroutine by targeting it.private InstructionHandle
The RET instruction that leaves this subroutine.private static final int
UNSET, a symbol for an uninitialized localVariable field. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new JSR or JSR_W that has this subroutine as its target.(package private) void
boolean
contains
(InstructionHandle inst) Returns if the given InstructionHandle refers to an instruction that is part of this subroutine.int[]
Returns an int[] containing the indices of the local variable slots accessed by this Subroutine (read-accessed, write-accessed or both); local variables referenced by subroutines of this subroutine are not included.Returns all the JsrInstructions that have the first instruction of this subroutine as their target.Returns all instructions that together form this subroutine.Returns the one and only RET that leaves the subroutine.int[]
Returns an int[] containing the indices of the local variable slots accessed by this Subroutine (read-accessed, write-accessed or both); local variables referenced by subroutines of this subroutine are included.private void
getRecursivelyAccessedLocalsIndicesHelper
(Set<Integer> set, Subroutine[] subs) A recursive helper method for getRecursivelyAccessedLocalsIndices().(package private) void
Sets the leaving RET instruction.(package private) void
setLocalVariable
(int i) subSubs()
Returns the subroutines that are directly called from this subroutine.toString()
Returns a String representation of this object, merely for debugging purposes.
-
Field Details
-
UNSET
private static final int UNSETUNSET, a symbol for an uninitialized localVariable field. This is used for the "top-level" Subroutine; i.e. no subroutine.- See Also:
-
EMPTY_ARRAY
-
localVariable
private int localVariableThe Local Variable slot where the first instruction of this subroutine (an ASTORE) stores the JsrInstruction's ReturnAddress in and the RET of this subroutine operates on. -
instructions
The instructions that belong to this subroutine. -
theJSRs
The JSR or JSR_W instructions that define this subroutine by targeting it. -
theRET
The RET instruction that leaves this subroutine.
-
-
Constructor Details
-
SubroutineImpl
public SubroutineImpl()The default constructor.
-
-
Method Details
-
addEnteringJsrInstruction
Adds a new JSR or JSR_W that has this subroutine as its target. -
addInstruction
-
contains
Description copied from interface:Subroutine
Returns if the given InstructionHandle refers to an instruction that is part of this subroutine. This is a convenience method that saves iteration over the InstructionHandle objects returned by getInstructions().- Specified by:
contains
in interfaceSubroutine
- Parameters:
inst
- The InstructionHandle to test.- Returns:
- Whether the given InstructionHandle refers to an instruction that is part of this subroutine.
- See Also:
-
getAccessedLocalsIndices
public int[] getAccessedLocalsIndices()Description copied from interface:Subroutine
Returns an int[] containing the indices of the local variable slots accessed by this Subroutine (read-accessed, write-accessed or both); local variables referenced by subroutines of this subroutine are not included.- Specified by:
getAccessedLocalsIndices
in interfaceSubroutine
- Returns:
- An int[] containing the indices of the local variable slots.
- See Also:
-
getEnteringJsrInstructions
Description copied from interface:Subroutine
Returns all the JsrInstructions that have the first instruction of this subroutine as their target. Must not be invoked on the 'top-level subroutine'.- Specified by:
getEnteringJsrInstructions
in interfaceSubroutine
- Returns:
- The JsrInstructions that have the first instruction of this subroutine as their target.
-
getInstructions
Description copied from interface:Subroutine
Returns all instructions that together form this subroutine. Note that an instruction is part of exactly one subroutine (the top-level code is considered to be a special subroutine) - else it is not reachable at all (dead code).- Specified by:
getInstructions
in interfaceSubroutine
- Returns:
- All instructions that together form this subroutine.
-
getLeavingRET
Description copied from interface:Subroutine
Returns the one and only RET that leaves the subroutine. Note that JustIce has a pretty rigid notion of a subroutine. Must not be invoked on the 'top-level subroutine'.- Specified by:
getLeavingRET
in interfaceSubroutine
- Returns:
- The one and only RET that leaves the subroutine.
- See Also:
-
getRecursivelyAccessedLocalsIndices
public int[] getRecursivelyAccessedLocalsIndices()Description copied from interface:Subroutine
Returns an int[] containing the indices of the local variable slots accessed by this Subroutine (read-accessed, write-accessed or both); local variables referenced by subroutines of this subroutine are included.- Specified by:
getRecursivelyAccessedLocalsIndices
in interfaceSubroutine
- Returns:
- An int[] containing the indices of the local variable slots.
- See Also:
-
getRecursivelyAccessedLocalsIndicesHelper
A recursive helper method for getRecursivelyAccessedLocalsIndices().- See Also:
-
setLeavingRET
void setLeavingRET()Sets the leaving RET instruction. Must be invoked after all instructions are added. Must not be invoked for top-level 'subroutine'. -
setLocalVariable
void setLocalVariable(int i) -
subSubs
Description copied from interface:Subroutine
Returns the subroutines that are directly called from this subroutine.- Specified by:
subSubs
in interfaceSubroutine
- Returns:
- The subroutines that are directly called from this subroutine.
-
toString
Returns a String representation of this object, merely for debugging purposes. (Internal) Warning: Verbosity on a problematic subroutine may cause stack overflow errors due to recursive subSubs() calls. Don't use this, then.
-