mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 15:37:52 +01:00
make difference between tableswitch and lookupswitch clearer
This commit is contained in:
parent
6a7744e228
commit
59757b3927
@ -70,7 +70,7 @@ class BranchManger {
|
|||||||
* @param lineNumber
|
* @param lineNumber
|
||||||
* the current line number
|
* the current line number
|
||||||
* @param keys
|
* @param keys
|
||||||
* the values of the cases
|
* the values of the cases or null if a tableswitch
|
||||||
* @param positions
|
* @param positions
|
||||||
* the code positions
|
* the code positions
|
||||||
* @param defaultPosition
|
* @param defaultPosition
|
||||||
@ -235,7 +235,7 @@ class BranchManger {
|
|||||||
private void caculateSwitch( BranchNode parent, SwitchParsedBlock switchBlock, List<ParsedBlock> parsedOperations ) {
|
private void caculateSwitch( BranchNode parent, SwitchParsedBlock switchBlock, List<ParsedBlock> parsedOperations ) {
|
||||||
int startPosition = ((ParsedBlock)switchBlock).startPosition;
|
int startPosition = ((ParsedBlock)switchBlock).startPosition;
|
||||||
int posCount = switchBlock.positions.length;
|
int posCount = switchBlock.positions.length;
|
||||||
boolean isTable = switchBlock.keys.length == 1;
|
boolean isTable = switchBlock.keys == null;
|
||||||
|
|
||||||
// create a helper structure
|
// create a helper structure
|
||||||
SwitchCase[] cases = new SwitchCase[posCount + 1];
|
SwitchCase[] cases = new SwitchCase[posCount + 1];
|
||||||
|
@ -133,7 +133,7 @@ public abstract class ModuleWriter implements Closeable {
|
|||||||
stackManager.reset();
|
stackManager.reset();
|
||||||
branchManager.reset();
|
branchManager.reset();
|
||||||
for( CodeInputStream byteCode : code.getByteCodes() ) {
|
for( CodeInputStream byteCode : code.getByteCodes() ) {
|
||||||
prepareBranchManager( byteCode, lineNumber = byteCode.getLineNumber() );
|
prepareCodeChunk( byteCode, lineNumber = byteCode.getLineNumber() );
|
||||||
}
|
}
|
||||||
branchManager.calculate();
|
branchManager.calculate();
|
||||||
localVariables.calculate();
|
localVariables.calculate();
|
||||||
@ -278,7 +278,7 @@ public abstract class ModuleWriter implements Closeable {
|
|||||||
protected abstract void writeMethodFinish( List<ValueType> locals ) throws IOException;
|
protected abstract void writeMethodFinish( List<ValueType> locals ) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a chunk of byte code.
|
* Analyze and prepare a chunk of byte code.
|
||||||
*
|
*
|
||||||
* @param byteCode
|
* @param byteCode
|
||||||
* a stream of byte code
|
* a stream of byte code
|
||||||
@ -287,7 +287,7 @@ public abstract class ModuleWriter implements Closeable {
|
|||||||
* @throws WasmException
|
* @throws WasmException
|
||||||
* if some Java code can't converted
|
* if some Java code can't converted
|
||||||
*/
|
*/
|
||||||
private void prepareBranchManager( CodeInputStream byteCode, int lineNumber ) throws WasmException {
|
private void prepareCodeChunk( CodeInputStream byteCode, int lineNumber ) throws WasmException {
|
||||||
try {
|
try {
|
||||||
while( byteCode.available() > 0 ) {
|
while( byteCode.available() > 0 ) {
|
||||||
int codePosition = byteCode.getCodePosition();
|
int codePosition = byteCode.getCodePosition();
|
||||||
@ -478,7 +478,7 @@ public abstract class ModuleWriter implements Closeable {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int low = byteCode.readInt();
|
int low = byteCode.readInt();
|
||||||
keys = new int[] { low };
|
keys = null;
|
||||||
int count = byteCode.readInt() - low + 1;
|
int count = byteCode.readInt() - low + 1;
|
||||||
positions = new int[count];
|
positions = new int[count];
|
||||||
for( int i = 0; i < count; i++ ) {
|
for( int i = 0; i < count; i++ ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user