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 TypeMethodDescriptionvoid
add
(IJavaStatement stm) Append a statement to this block.void
addAll
(IJavaBlock b) void
addMultiple
(IJavaBlock src, int start, int end, boolean removeSourceStatements) void
clear()
Remove all statements of the block, making the block effectively empty: {}Duplicate this element.void
void
generateBody
(JavaOutputSink out, boolean expectLambdaExpression) Raw body generation, the caller is responsible for calling generateEnter/generateExitvoid
void
get
(int index) Get the statement at a given index.getLast()
void
insert
(int index, IJavaStatement stm) Insert a statement at the given index.void
insertAll
(int index, IJavaBlock b) Insert all statements of another block in this block.void
insertMultiple
(int index, IJavaBlock src, int start, int end, boolean removeSourceStatements) boolean
isEmpty()
remove
(int index) Pull a statement from the block.boolean
remove
(IJavaStatement stm) Remove a statement from the block.void
removeMultiple
(int index, int cnt) void
removeRange
(int from, int to) void
set
(int index, IJavaStatement stm) Replace a statement by another statement.int
size()
Get the number of statements in this block.Methods inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaCompound
generateFlatList, getBlocks, getSubElements, insertAt, reset
Methods 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, visitDepthPre
Methods inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaStatement
getIntermediateOffset, setIntermediateOffset
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
size
int size()Get the number of statements in this block.Note:
Compound statements
count 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()- Returns:
-
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:IJavaElement
Duplicate this element.- Specified by:
duplicate
in interfaceIJavaCompound
- Specified by:
duplicate
in interfaceIJavaElement
- Specified by:
duplicate
in interfaceIJavaExpression
- Specified by:
duplicate
in interfaceIJavaStatement
- Returns:
- a (possibly) duplicated object of the same type
-