Class Subroutines.SubroutineImpl
- java.lang.Object
-
- org.apache.bcel.verifier.structurals.Subroutines.SubroutineImpl
-
- All Implemented Interfaces:
Subroutine
- Enclosing class:
- Subroutines
private class Subroutines.SubroutineImpl extends java.lang.Object implements Subroutine
This inner class implements the Subroutine interface.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<InstructionHandle>instructionsThe instructions that belong to this subroutine.private intlocalVariableThe 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 java.util.Set<InstructionHandle>theJSRsThe JSR or JSR_W instructions that define this subroutine by targeting it.private InstructionHandletheRETThe RET instruction that leaves this subroutine.private static intUNSETUNSET, a symbol for an uninitialized localVariable field.
-
Constructor Summary
Constructors Constructor Description SubroutineImpl()The default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void_getRecursivelyAccessedLocalsIndicesHelper(java.util.Set<java.lang.Integer> s, Subroutine[] subs)A recursive helper method for getRecursivelyAccessedLocalsIndices().voidaddEnteringJsrInstruction(InstructionHandle jsrInst)Adds a new JSR or JSR_W that has this subroutine as its target.(package private) voidaddInstruction(InstructionHandle ih)booleancontains(InstructionHandle inst)Returns if the given InstructionHandle refers to an instruction that is part of this subroutine.int[]getAccessedLocalsIndices()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.InstructionHandle[]getEnteringJsrInstructions()Returns all the JsrInstructions that have the first instruction of this subroutine as their target.InstructionHandle[]getInstructions()Returns all instructions that together form this subroutine.InstructionHandlegetLeavingRET()Returns the one and only RET that leaves the subroutine.int[]getRecursivelyAccessedLocalsIndices()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.(package private) voidsetLeavingRET()Sets the leaving RET instruction.(package private) voidsetLocalVariable(int i)Subroutine[]subSubs()Returns the subroutines that are directly called from this subroutine.java.lang.StringtoString()Returns a String representation of this object, merely for debugging purposes.
-
-
-
Field Detail
-
UNSET
private static final int UNSET
UNSET, a symbol for an uninitialized localVariable field. This is used for the "top-level" Subroutine; i.e. no subroutine.- See Also:
- Constant Field Values
-
localVariable
private int localVariable
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.
-
instructions
private final java.util.Set<InstructionHandle> instructions
The instructions that belong to this subroutine.
-
theJSRs
private final java.util.Set<InstructionHandle> theJSRs
The JSR or JSR_W instructions that define this subroutine by targeting it.
-
theRET
private InstructionHandle theRET
The RET instruction that leaves this subroutine.
-
-
Method Detail
-
contains
public boolean contains(InstructionHandle inst)
Description copied from interface:SubroutineReturns 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:
containsin interfaceSubroutine- Parameters:
inst- The InstructionHandle to test.- Returns:
- Whether the given InstructionHandle refers to an instruction that is part of this subroutine.
- See Also:
Subroutine.getInstructions()
-
toString
public java.lang.String 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.- Overrides:
toStringin classjava.lang.Object
-
setLeavingRET
void setLeavingRET()
Sets the leaving RET instruction. Must be invoked after all instructions are added. Must not be invoked for top-level 'subroutine'.
-
getEnteringJsrInstructions
public InstructionHandle[] getEnteringJsrInstructions()
Description copied from interface:SubroutineReturns 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:
getEnteringJsrInstructionsin interfaceSubroutine- Returns:
- The JsrInstructions that have the first instruction of this subroutine as their target.
-
addEnteringJsrInstruction
public void addEnteringJsrInstruction(InstructionHandle jsrInst)
Adds a new JSR or JSR_W that has this subroutine as its target.
-
getLeavingRET
public InstructionHandle getLeavingRET()
Description copied from interface:SubroutineReturns 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:
getLeavingRETin interfaceSubroutine- Returns:
- The one and only RET that leaves the subroutine.
- See Also:
Subroutines
-
getInstructions
public InstructionHandle[] getInstructions()
Description copied from interface:SubroutineReturns 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:
getInstructionsin interfaceSubroutine- Returns:
- All instructions that together form this subroutine.
-
addInstruction
void addInstruction(InstructionHandle ih)
-
getRecursivelyAccessedLocalsIndices
public int[] getRecursivelyAccessedLocalsIndices()
Description copied from interface:SubroutineReturns 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:
getRecursivelyAccessedLocalsIndicesin interfaceSubroutine- Returns:
- An int[] containing the indices of the local variable slots.
- See Also:
Subroutine.getAccessedLocalsIndices()
-
_getRecursivelyAccessedLocalsIndicesHelper
private void _getRecursivelyAccessedLocalsIndicesHelper(java.util.Set<java.lang.Integer> s, Subroutine[] subs)A recursive helper method for getRecursivelyAccessedLocalsIndices().- See Also:
getRecursivelyAccessedLocalsIndices()
-
getAccessedLocalsIndices
public int[] getAccessedLocalsIndices()
Description copied from interface:SubroutineReturns 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:
getAccessedLocalsIndicesin interfaceSubroutine- Returns:
- An int[] containing the indices of the local variable slots.
- See Also:
Subroutine.getRecursivelyAccessedLocalsIndices()
-
subSubs
public Subroutine[] subSubs()
Description copied from interface:SubroutineReturns the subroutines that are directly called from this subroutine.- Specified by:
subSubsin interfaceSubroutine- Returns:
- The subroutines that are directly called from this subroutine.
-
setLocalVariable
void setLocalVariable(int i)
-
-