mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
fix conditionals expressions as method parameters in a SWITCH.
This commit is contained in:
parent
f61a994d40
commit
9acda37be4
@ -885,7 +885,7 @@ class BranchManager {
|
||||
for( int p = 0; p < parsedOperations.size(); p++ ) {
|
||||
ParsedBlock parsedBlock = parsedOperations.get( p );
|
||||
int start = parsedBlock.startPosition;
|
||||
if( startPosition >= lastPosition ) {
|
||||
if( start >= lastPosition ) {
|
||||
break;
|
||||
}
|
||||
if( parsedBlock.op != JavaBlockOperator.IF ) {
|
||||
@ -923,10 +923,11 @@ class BranchManager {
|
||||
}
|
||||
|
||||
// handle the GOTO (breaks) at the end of the CASE blocks.
|
||||
int lastBlockPosition = lastPosition;
|
||||
for( Iterator<ParsedBlock> it = parsedOperations.iterator(); it.hasNext(); ) {
|
||||
ParsedBlock parsedBlock = it.next();
|
||||
int start = parsedBlock.startPosition;
|
||||
if( startPosition >= lastPosition ) {
|
||||
if( start >= lastBlockPosition ) {
|
||||
break;
|
||||
}
|
||||
switch( parsedBlock.op ) {
|
||||
|
@ -46,6 +46,7 @@ public class ControlFlowOperators extends AbstractBaseTest {
|
||||
addParam( list, script, "ifMultipleDouble" );
|
||||
addParam( list, script, "ifCompare" );
|
||||
addParam( list, script, "switchDirect" );
|
||||
addParam( list, script, "switchWithConditionMethodParams" );
|
||||
addParam( list, script, "endlessLoop" );
|
||||
addParam( list, script, "doWhileLoop" );
|
||||
addParam( list, script, "doWhileLoopTwoConditions" );
|
||||
@ -287,6 +288,20 @@ public class ControlFlowOperators extends AbstractBaseTest {
|
||||
return b;
|
||||
}
|
||||
|
||||
@Export
|
||||
public static int switchWithConditionMethodParams() {
|
||||
int last = 8;
|
||||
switch( last ) {
|
||||
case -2:
|
||||
last = -13;
|
||||
break;
|
||||
default:
|
||||
last = tableSwitch( (last == 0 ? 0 : last) );
|
||||
break;
|
||||
}
|
||||
return last;
|
||||
}
|
||||
|
||||
@Export
|
||||
static int endlessLoop() {
|
||||
int a = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user