mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
fix WHILE loop after a return
This commit is contained in:
parent
8eac318ef8
commit
86f95ad3bb
@ -617,7 +617,7 @@ class BranchManager {
|
||||
boolean isContinue = false;
|
||||
for( int i = ifCount + 1; i < parsedOpCount; i++ ) {
|
||||
ParsedBlock op = parsedOperations.get( i );
|
||||
if( op.endPosition >= elsePos ) {
|
||||
if( op.endPosition >= elsePos && op.op == JavaBlockOperator.IF ) {
|
||||
isContinue = true;
|
||||
break;
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ public class ControlFlowOperators extends AbstractBaseTest {
|
||||
addParam( list, script, "whileLoopInElse_3" );
|
||||
addParam( list, script, "whileLoopInElse_13" );
|
||||
addParam( list, script, "whileLoopInElseAfterReturn" );
|
||||
addParam( list, script, "whileLoopAfterIfWithReturn" );
|
||||
addParam( list, script, "forLoop" );
|
||||
addParam( list, script, "conditionalOperator" );
|
||||
addParam( list, script, "conditionalOperator2" );
|
||||
@ -392,6 +393,22 @@ public class ControlFlowOperators extends AbstractBaseTest {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Export
|
||||
public static int whileLoopAfterIfWithReturn() {
|
||||
int yIndex = 13;
|
||||
int result = 0;
|
||||
if (yIndex < 3) {
|
||||
if( yIndex == 3 ) {
|
||||
return 42;
|
||||
}
|
||||
while (yIndex > 7) {
|
||||
result++;
|
||||
yIndex--;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Export
|
||||
static int forLoop() {
|
||||
int a = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user