Class BranchManager.BranchNode
java.lang.Object
java.util.AbstractCollection<BranchManager.BranchNode>
java.util.AbstractList<BranchManager.BranchNode>
java.util.ArrayList<BranchManager.BranchNode>
de.inetsoftware.jwebassembly.module.BranchManager.BranchNode
- All Implemented Interfaces:
Serializable, Cloneable, Iterable<BranchManager.BranchNode>, Collection<BranchManager.BranchNode>, List<BranchManager.BranchNode>, RandomAccess, SequencedCollection<BranchManager.BranchNode>
- Enclosing class:
BranchManager
Described a code branch/block node in a tree structure.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intjump position for a CONTINUE in a loopprivate ObjectExtra data depending of the operator.private intprivate WasmBlockOperatorprivate intprivate BranchManager.BranchNodeprivate WasmBlockInstructionA instruction for which the return type must be calculated.private intThe position of the startBlock in the instructionsprivate final WasmBlockOperatorprivate final intFields inherited from class AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionBranchNode(int startPos, int endPos, WasmBlockOperator startOp, WasmBlockOperator endOp) Create a new description.BranchNode(int startPos, int endPos, WasmBlockOperator startOp, WasmBlockOperator endOp, Object data) Create a new description. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int index, BranchManager.BranchNode node) booleanadd(BranchManager.BranchNode node) (package private) voidcalculateBlockType(List<WasmInstruction> instructions) Calculate the block type (return type).private intfindEndInstruction(List<WasmInstruction> instructions, int idx) Find the END instruction of the block.(package private) inthandle(int codePosition, List<WasmInstruction> instructions, int idx, int lineNumber) Handle branches on the current codePositionMethods inherited from class ArrayList
addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class AbstractCollection
containsAll, toStringMethods inherited from interface Collection
parallelStream, stream, toArrayMethods inherited from interface List
containsAll, reversed
-
Field Details
-
startPos
private final int startPos -
endPos
private int endPos -
startOp
-
endOp
-
data
Extra data depending of the operator. For example the return type of a block. -
parent
-
startBlock
A instruction for which the return type must be calculated. -
startIdx
private int startIdxThe position of the startBlock in the instructions -
elseEndPos
private int elseEndPos -
continuePos
private int continuePosjump position for a CONTINUE in a loop
-
-
Constructor Details
-
BranchNode
BranchNode(int startPos, int endPos, WasmBlockOperator startOp, WasmBlockOperator endOp) Create a new description.- Parameters:
startPos- the start position in the Java code. Limit also the children.endPos- the end position in the Java code. Limit also the children.startOp- The WASM operation on the start position. Can be null if there is nothing in WASM.endOp- the WASM operation on the end position. Can be null if there is nothing in WASM.
-
BranchNode
BranchNode(int startPos, int endPos, WasmBlockOperator startOp, WasmBlockOperator endOp, Object data) Create a new description.- Parameters:
startPos- the start position in the Java code. Limit also the children.endPos- the end position in the Java code. Limit also the children.startOp- The WASM operation on the start position. Can be null if there is nothing in WASM.endOp- the WASM operation on the end position. Can be null if there is nothing in WASM.data- extra data depending of the start operator
-
-
Method Details
-
add
- Specified by:
addin interfaceCollection<BranchManager.BranchNode>- Specified by:
addin interfaceList<BranchManager.BranchNode>- Overrides:
addin classArrayList<BranchManager.BranchNode>
-
add
- Specified by:
addin interfaceList<BranchManager.BranchNode>- Overrides:
addin classArrayList<BranchManager.BranchNode>
-
handle
Handle branches on the current codePosition- Parameters:
codePosition- current code positioninstructions- the target for instructionsidx- index in the current instructionlineNumber- the line number in the Java source code- Returns:
- the new index in the instructions
-
calculateBlockType
Calculate the block type (return type). The value type that is on the stack after the block.- Parameters:
instructions- the instructions of the function
-
findEndInstruction
Find the END instruction of the block.- Parameters:
instructions- the list of instructionsidx- the index of the block start- Returns:
- the END index
-