Class BranchManager.BranchNode
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<BranchManager.BranchNode>
-
- de.inetsoftware.jwebassembly.module.BranchManager.BranchNode
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<BranchManager.BranchNode>
,java.util.Collection<BranchManager.BranchNode>
,java.util.List<BranchManager.BranchNode>
,java.util.RandomAccess
- Enclosing class:
- BranchManager
private static class BranchManager.BranchNode extends java.util.ArrayList<BranchManager.BranchNode>
Described a code branch/block node in a tree structure.
-
-
Field Summary
Fields Modifier and Type Field Description private int
continuePos
jump position for a CONTINUE in a loopprivate java.lang.Object
data
Extra data depending of the operator.private int
elseEndPos
private WasmBlockOperator
endOp
private int
endPos
private BranchManager.BranchNode
parent
private WasmBlockInstruction
startBlock
A instruction for which the return type must be calculated.private int
startIdx
The position of the startBlock in the instructionsprivate WasmBlockOperator
startOp
private int
startPos
-
Constructor Summary
Constructors Constructor Description BranchNode(int startPos, int endPos, WasmBlockOperator startOp, WasmBlockOperator endOp)
Create a new description.BranchNode(int startPos, int endPos, WasmBlockOperator startOp, WasmBlockOperator endOp, java.lang.Object data)
Create a new description.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, BranchManager.BranchNode node)
boolean
add(BranchManager.BranchNode node)
(package private) void
calculateBlockType(java.util.List<WasmInstruction> instructions)
Calculate the block type (return type).private int
findEndInstruction(java.util.List<WasmInstruction> instructions, int idx)
Find the END instruction of the block.(package private) int
handle(int codePosition, java.util.List<WasmInstruction> instructions, int idx, int lineNumber)
Handle branches on the current codePosition-
Methods inherited from class java.util.ArrayList
addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
-
-
-
Field Detail
-
startPos
private final int startPos
-
endPos
private int endPos
-
startOp
private final WasmBlockOperator startOp
-
endOp
private WasmBlockOperator endOp
-
data
private java.lang.Object data
Extra data depending of the operator. For example the return type of a block.
-
parent
private BranchManager.BranchNode parent
-
startBlock
private WasmBlockInstruction startBlock
A instruction for which the return type must be calculated.
-
startIdx
private int startIdx
The position of the startBlock in the instructions
-
elseEndPos
private int elseEndPos
-
continuePos
private int continuePos
jump position for a CONTINUE in a loop
-
-
Constructor Detail
-
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, java.lang.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 Detail
-
add
public boolean add(BranchManager.BranchNode node)
- Specified by:
add
in interfacejava.util.Collection<BranchManager.BranchNode>
- Specified by:
add
in interfacejava.util.List<BranchManager.BranchNode>
- Overrides:
add
in classjava.util.ArrayList<BranchManager.BranchNode>
-
add
public void add(int index, BranchManager.BranchNode node)
- Specified by:
add
in interfacejava.util.List<BranchManager.BranchNode>
- Overrides:
add
in classjava.util.ArrayList<BranchManager.BranchNode>
-
handle
int handle(int codePosition, java.util.List<WasmInstruction> instructions, int idx, int lineNumber)
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
void calculateBlockType(java.util.List<WasmInstruction> instructions)
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
private int findEndInstruction(java.util.List<WasmInstruction> instructions, int idx)
Find the END instruction of the block.- Parameters:
instructions
- the list of instructionsidx
- the index of the block start- Returns:
- the END index
-
-