Interface IJavaBlock
- All Superinterfaces:
IJavaCompound,IJavaElement,IJavaExpression,IJavaStatement,Iterable<IJavaStatement>
Java AST interface to represent a sequence of
statements.
Example:
{
stm0;
stm1;
stm2;
}
Statements cannot be null. An exception will be raised if an attempt to insert a null statement is made.
-
Field Summary
Fields inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaElement
FLAG_BUILT, FLAG_FIELD_REFERENCES_OUTERCLASS, FLAG_LAMBDA_CLASS, FLAG_LAMBDA_IMPL, FLAG_OPTIONAL_RENDERING, FLAG_SECOND_PARAMETER_IS_OUTER_REF, FLAG_STICKY -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(IJavaStatement stm) Append a statement to this block.voidaddAll(IJavaBlock b) voidaddMultiple(IJavaBlock src, int start, int end, boolean removeSourceStatements) voidclear()Remove all statements of the block, making the block effectively empty: {}Duplicate this element.voidvoidgenerateBody(JavaOutputSink out, boolean expectLambdaExpression) Raw body generation, the caller is responsible for calling generateEnter/generateExitvoidvoidget(int index) Get the statement at a given index.getLast()Get the last statement from the block.voidinsert(int index, IJavaStatement stm) Insert a statement at the given index.voidinsertAll(int index, IJavaBlock b) Insert all statements of another block in this block.voidinsertMultiple(int index, IJavaBlock src, int start, int end, boolean removeSourceStatements) booleanisEmpty()remove(int index) Pull a statement from the block.booleanremove(IJavaStatement stm) Remove a statement from the block.voidremoveMultiple(int index, int cnt) voidremoveRange(int from, int to) voidset(int index, IJavaStatement stm) Replace a statement by another statement.intsize()Get the number of statements in this block.Methods inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaCompound
generateFlatList, getBlocks, getSubElements, insertAt, resetMethods inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaElement
addFlags, addTag, canCauseException, collectAllPhysicalOffsets, generate, getData, getElementType, getFlags, getOrigin, getPhysicalMethodIndex, getPhysicalOffset, getReconAnon, getReconEnum, getReconEnummap, getReconLambda, getSubElements, getTags, hasFlags, hasPhysicalMethodIndex, hasPhysicalOffset, isReconArtifact, removeFlags, removeTag, replaceSubElement, setData, setFlags, setLambdaRecon, setOrigin, setPhysicalMethodIndex, setPhysicalOffset, setReconAnon, setReconEnum, setReconEnummap, toShortString, visitDepthPost, visitDepthPost, visitDepthPost, visitDepthPost, visitDepthPre, visitDepthPre, visitDepthPreMethods inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaStatement
getIntermediateOffset, setIntermediateOffsetMethods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
size
int size()Get the number of statements in this block.Note:
Compound statementscount for a single statement.- Returns:
- the number of statements
-
isEmpty
boolean isEmpty() -
get
Get the statement at a given index.- Parameters:
index- 0-based statement index- Returns:
- the statement
-
getLast
IJavaStatement getLast()Get the last statement from the block.- Returns:
- the non-null statement
-
set
Replace a statement by another statement.- Parameters:
index- 0-based statement indexstm- mandatory statement
-
remove
Pull a statement from the block.- Parameters:
index- 0-based statement index- Returns:
- the removed statement
-
removeLast
IJavaStatement removeLast()- Returns:
-
removeMultiple
void removeMultiple(int index, int cnt) - Parameters:
index-cnt-
-
removeRange
void removeRange(int from, int to) - Parameters:
from-to-
-
remove
Remove a statement from the block. Does not throw if the statement is not found.- Parameters:
stm- mandatory statement- Returns:
- success indicator
-
add
Append a statement to this block.- Parameters:
stm- mandatory statement to be appended
-
insert
Insert a statement at the given index.- Parameters:
index- 0-based statement indexstm- mandatory statement to be inserted
-
insertAll
Insert all statements of another block in this block.- Parameters:
index- 0-based indexb- mandatory block
-
addAll
-
insertMultiple
-
addMultiple
-
clear
void clear()Remove all statements of the block, making the block effectively empty: {} -
generateBody
-
generateBody
Raw body generation, the caller is responsible for calling generateEnter/generateExit- Parameters:
out-expectLambdaExpression-
-
generateHeader
-
duplicate
IJavaBlock duplicate()Description copied from interface:IJavaElementDuplicate this element.- Specified by:
duplicatein interfaceIJavaCompound- Specified by:
duplicatein interfaceIJavaElement- Specified by:
duplicatein interfaceIJavaExpression- Specified by:
duplicatein interfaceIJavaStatement- Returns:
- a (possibly) duplicated object of the same type
-