mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +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--;
|
startPosition--;
|
||||||
|
|
||||||
byteCode.readInt();
|
byteCode.readInt();
|
||||||
|
boolean writeFirstKey;
|
||||||
|
int low = 0;
|
||||||
if( op == 171 ) { // lookupswitch
|
if( op == 171 ) { // lookupswitch
|
||||||
int count = byteCode.readInt();
|
int count = byteCode.readInt();
|
||||||
|
writeFirstKey = count == 1;
|
||||||
for( int i = 0; i < count; i++ ) {
|
for( int i = 0; i < count; i++ ) {
|
||||||
byteCode.readInt();
|
int key = byteCode.readInt();
|
||||||
|
if( i== 0 ) {
|
||||||
|
low = key;
|
||||||
|
}
|
||||||
byteCode.readInt();
|
byteCode.readInt();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int low = byteCode.readInt();
|
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
|
writeFirstKey = true;
|
||||||
writeConstInt( low );
|
|
||||||
writeNumericOperator( NumericOperator.sub, ValueType.i32 );
|
|
||||||
}
|
|
||||||
int count = byteCode.readInt() - low + 1;
|
int count = byteCode.readInt() - low + 1;
|
||||||
for( int i = 0; i < count; i++ ) {
|
for( int i = 0; i < count; i++ ) {
|
||||||
byteCode.readInt();
|
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;
|
break;
|
||||||
case 172: // ireturn
|
case 172: // ireturn
|
||||||
case 173: // lreturn
|
case 173: // lreturn
|
||||||
|
Loading…
x
Reference in New Issue
Block a user