make difference between tableswitch and lookupswitch clearer

This commit is contained in:
Volker Berlin 2018-05-12 09:59:42 +02:00
parent 6a7744e228
commit 59757b3927
2 changed files with 6 additions and 6 deletions

View File

@ -70,7 +70,7 @@ class BranchManger {
* @param lineNumber
* the current line number
* @param keys
* the values of the cases
* the values of the cases or null if a tableswitch
* @param positions
* the code positions
* @param defaultPosition
@ -235,7 +235,7 @@ class BranchManger {
private void caculateSwitch( BranchNode parent, SwitchParsedBlock switchBlock, List<ParsedBlock> parsedOperations ) {
int startPosition = ((ParsedBlock)switchBlock).startPosition;
int posCount = switchBlock.positions.length;
boolean isTable = switchBlock.keys.length == 1;
boolean isTable = switchBlock.keys == null;
// create a helper structure
SwitchCase[] cases = new SwitchCase[posCount + 1];

View File

@ -133,7 +133,7 @@ public abstract class ModuleWriter implements Closeable {
stackManager.reset();
branchManager.reset();
for( CodeInputStream byteCode : code.getByteCodes() ) {
prepareBranchManager( byteCode, lineNumber = byteCode.getLineNumber() );
prepareCodeChunk( byteCode, lineNumber = byteCode.getLineNumber() );
}
branchManager.calculate();
localVariables.calculate();
@ -278,7 +278,7 @@ public abstract class ModuleWriter implements Closeable {
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
* a stream of byte code
@ -287,7 +287,7 @@ public abstract class ModuleWriter implements Closeable {
* @throws WasmException
* 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 {
while( byteCode.available() > 0 ) {
int codePosition = byteCode.getCodePosition();
@ -478,7 +478,7 @@ public abstract class ModuleWriter implements Closeable {
}
} else {
int low = byteCode.readInt();
keys = new int[] { low };
keys = null;
int count = byteCode.readInt() - low + 1;
positions = new int[count];
for( int i = 0; i < count; i++ ) {