diff --git a/src/de/inetsoftware/jwebassembly/module/BranchManger.java b/src/de/inetsoftware/jwebassembly/module/BranchManger.java index 3f52288..709c1d5 100644 --- a/src/de/inetsoftware/jwebassembly/module/BranchManger.java +++ b/src/de/inetsoftware/jwebassembly/module/BranchManger.java @@ -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 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]; diff --git a/src/de/inetsoftware/jwebassembly/module/ModuleWriter.java b/src/de/inetsoftware/jwebassembly/module/ModuleWriter.java index bf6c609..6592499 100644 --- a/src/de/inetsoftware/jwebassembly/module/ModuleWriter.java +++ b/src/de/inetsoftware/jwebassembly/module/ModuleWriter.java @@ -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 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++ ) {