mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
Fix compound IF that continue a loop
This commit is contained in:
parent
a5e4b6a353
commit
c2655dbce2
@ -635,7 +635,15 @@ class BranchManager {
|
|||||||
|
|
||||||
for( int i = 0; i < positions.ifCount; i++ ) {
|
for( int i = 0; i < positions.ifCount; i++ ) {
|
||||||
IfParsedBlock parsedBlock = (IfParsedBlock)parsedOperations.remove( 0 );
|
IfParsedBlock parsedBlock = (IfParsedBlock)parsedOperations.remove( 0 );
|
||||||
breakOperations.add( new BreakBlock( WasmBlockOperator.BR_IF, branch, parsedBlock.nextPosition - 1, parsedBlock.endPosition ) );
|
int start = parsedBlock.nextPosition - 1;
|
||||||
|
int end = parsedBlock.endPosition;
|
||||||
|
if( start > end ) {
|
||||||
|
// the condition in a do while(condition) loop
|
||||||
|
int breakDeep = calculateContinueDeep( parent, end );
|
||||||
|
instructions.add( findIdxOfCodePos( start + 1 ), new WasmBlockInstruction( WasmBlockOperator.BR_IF, breakDeep, start, parsedBlock.lineNumber ) );
|
||||||
|
} else {
|
||||||
|
breakOperations.add( new BreakBlock( WasmBlockOperator.BR_IF, branch, start, end ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( createThenBlock ) {
|
if( createThenBlock ) {
|
||||||
@ -1783,6 +1791,7 @@ class BranchManager {
|
|||||||
this.startOp = startOp;
|
this.startOp = startOp;
|
||||||
this.endOp = endOp;
|
this.endOp = endOp;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
|
assert startPos <= endPos : "negative block size: " + this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2085,6 +2094,15 @@ class BranchManager {
|
|||||||
this.breakPos = breakPos;
|
this.breakPos = breakPos;
|
||||||
this.endPosition = endPosition;
|
this.endPosition = endPosition;
|
||||||
this.branch = branch;
|
this.branch = branch;
|
||||||
|
assert breakPos < endPosition : "Continue not possible: " + this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only used for debugging
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return op + "(" + breakPos + "->" + endPosition + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user