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) Append all statements of another block to this block.voidaddMultiple(IJavaBlock src, int start, int end, boolean removeSourceStatements) Append a range of statements from another block.voidclear()Remove all statements of the block, making the block effectively empty: {}Duplicate this element.voidGenerate this block body.voidgenerateBody(JavaOutputSink out, boolean expectLambdaExpression) Raw body generation, the caller is responsible for calling generateEnter/generateExitvoidGenerate this block footer.voidGenerate this block header.get(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) Insert a range of statements from another block.booleanisEmpty()Determine whether this block contains no statements.remove(int index) Pull a statement from the block.booleanremove(IJavaStatement stm) Remove a statement from the block.Pull the last statement from the block.voidremoveMultiple(int index, int cnt) Remove multiple statements from the block.voidremoveRange(int from, int to) Remove a range of statements from the block.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()Determine whether this block contains no statements.- Returns:
- true if this block is empty
-
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()Pull the last statement from the block.- Returns:
- the removed statement
-
removeMultiple
void removeMultiple(int index, int cnt) Remove multiple statements from the block.- Parameters:
index- 0-based index of the first statement to removecnt- number of statements to remove
-
removeRange
void removeRange(int from, int to) Remove a range of statements from the block.- Parameters:
from- 0-based index of the first statement to removeto- 0-based exclusive end index
-
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
Append all statements of another block to this block.- Parameters:
b- mandatory source block
-
insertMultiple
Insert a range of statements from another block.- Parameters:
index- insertion indexsrc- source blockstart- source start index, inclusiveend- source end index, exclusiveremoveSourceStatements- true to remove transferred statements from the source block
-
addMultiple
Append a range of statements from another block.- Parameters:
src- source blockstart- source start index, inclusiveend- source end index, exclusiveremoveSourceStatements- true to remove transferred statements from the source block
-
clear
void clear()Remove all statements of the block, making the block effectively empty: {} -
generateBody
Generate this block body.- Parameters:
out- output sink
-
generateBody
Raw body generation, the caller is responsible for calling generateEnter/generateExit- Parameters:
out- output sinkexpectLambdaExpression- true if a lambda expression is expected
-
generateHeader
Generate this block header.- Parameters:
out- output sink
-
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
-