Fix the lineNumer in some WasmExceptions

This commit is contained in:
Volker Berlin 2019-04-14 14:06:56 +02:00
parent cd7e20f5ed
commit 0ad94fbc56

View File

@ -80,11 +80,12 @@ class JavaMethodWasmCodeBuilder extends WasmCodeBuilder {
* if some Java code can't converted * if some Java code can't converted
*/ */
private void writeCode( CodeInputStream byteCode, ConstantPool constantPool, boolean hasReturn ) throws WasmException { private void writeCode( CodeInputStream byteCode, ConstantPool constantPool, boolean hasReturn ) throws WasmException {
int lineNumber = -1;
try { try {
boolean wide = false; boolean wide = false;
while( byteCode.available() > 0 ) { while( byteCode.available() > 0 ) {
int codePos = byteCode.getCodePosition(); int codePos = byteCode.getCodePosition();
int lineNumber = byteCode.getLineNumber(); lineNumber = byteCode.getLineNumber();
int op = byteCode.readUnsignedByte(); int op = byteCode.readUnsignedByte();
switch( op ) { switch( op ) {
case 0: // nop case 0: // nop
@ -654,10 +655,8 @@ class JavaMethodWasmCodeBuilder extends WasmCodeBuilder {
// But WebAssembly need the dead code to validate // But WebAssembly need the dead code to validate
addBlockInstruction( WasmBlockOperator.UNREACHABLE, null, byteCode.getCodePosition(), byteCode.getLineNumber() ); addBlockInstruction( WasmBlockOperator.UNREACHABLE, null, byteCode.getCodePosition(), byteCode.getLineNumber() );
} }
} catch( WasmException ex ) {
throw ex;
} catch( Exception ex ) { } catch( Exception ex ) {
throw WasmException.create( ex, byteCode.getLineNumber() ); throw WasmException.create( ex, lineNumber );
} }
} }