mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
some Java compiler use lookupswitch for a switch with one case
This commit is contained in:
parent
903c2e0e28
commit
91287c9fd3
@ -746,23 +746,30 @@ public abstract class ModuleWriter implements Closeable {
|
||||
startPosition--;
|
||||
|
||||
byteCode.readInt();
|
||||
boolean writeFirstKey;
|
||||
int low = 0;
|
||||
if( op == 171 ) { // lookupswitch
|
||||
int count = byteCode.readInt();
|
||||
writeFirstKey = count == 1;
|
||||
for( int i = 0; i < count; i++ ) {
|
||||
byteCode.readInt();
|
||||
int key = byteCode.readInt();
|
||||
if( i== 0 ) {
|
||||
low = key;
|
||||
}
|
||||
byteCode.readInt();
|
||||
}
|
||||
} else {
|
||||
int low = byteCode.readInt();
|
||||
if( low != 0 ) { // the br_table starts ever with the value 0. That we need to subtract the start value if it different
|
||||
writeConstInt( low );
|
||||
writeNumericOperator( NumericOperator.sub, ValueType.i32 );
|
||||
}
|
||||
low = byteCode.readInt();
|
||||
writeFirstKey = true;
|
||||
int count = byteCode.readInt() - low + 1;
|
||||
for( int i = 0; i < count; i++ ) {
|
||||
byteCode.readInt();
|
||||
}
|
||||
}
|
||||
if( writeFirstKey && low != 0 ) { // the br_table starts ever with the value 0. That we need to subtract the start value if it different
|
||||
writeConstInt( low );
|
||||
writeNumericOperator( NumericOperator.sub, ValueType.i32 );
|
||||
}
|
||||
break;
|
||||
case 172: // ireturn
|
||||
case 173: // lreturn
|
||||
|
Loading…
x
Reference in New Issue
Block a user