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 int
jump position for a CONTINUE in a loopprivate Object
Extra data depending of the operator.private int
private WasmBlockOperator
private int
private BranchManager.BranchNode
private WasmBlockInstruction
A instruction for which the return type must be calculated.private int
The position of the startBlock in the instructionsprivate final WasmBlockOperator
private final int
Fields inherited from class java.util.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 TypeMethodDescriptionvoid
add
(int index, BranchManager.BranchNode node) boolean
add
(BranchManager.BranchNode node) (package private) void
calculateBlockType
(List<WasmInstruction> instructions) Calculate the block type (return type).private int
findEndInstruction
(List<WasmInstruction> instructions, int idx) Find the END instruction of the block.(package private) int
handle
(int codePosition, List<WasmInstruction> instructions, int idx, int lineNumber) Handle branches on the current codePositionMethods inherited from class java.util.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, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods inherited from interface java.util.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:
add
in interfaceCollection<BranchManager.BranchNode>
- Specified by:
add
in interfaceList<BranchManager.BranchNode>
- Overrides:
add
in classArrayList<BranchManager.BranchNode>
-
add
- Specified by:
add
in interfaceList<BranchManager.BranchNode>
- Overrides:
add
in 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
-