mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
END can not be outside of parent block
This commit is contained in:
parent
b5296e6268
commit
0822d9af8c
@ -260,10 +260,13 @@ class BranchManger {
|
||||
if( i > 0 ) {
|
||||
calculate( branch, parsedOperations.subList( 0, i ) );
|
||||
}
|
||||
branch.data = calculateBlockType( startPos, branch.endPos );
|
||||
endPos = parsedBlock.endPosition;
|
||||
ValueType blockType = calculateBlockType( startPos, branch.endPos );
|
||||
branch.data = blockType;
|
||||
// end position can not be outside of the parent
|
||||
endPos = Math.min( parsedBlock.endPosition, parent.endPos );
|
||||
|
||||
int breakDeep = calculateBreakDeep( parent, endPos );
|
||||
// if with block type signature must have an else block
|
||||
int breakDeep = blockType == ValueType.empty ? calculateBreakDeep( parent, endPos ) : -1;
|
||||
if( breakDeep >= 0 ) {
|
||||
branch.endOp = WasmBlockOperator.END;
|
||||
branch.add( new BranchNode( startBlock.endPosition, endPos, WasmBlockOperator.BR, null, breakDeep + 1 ) );
|
||||
|
@ -299,7 +299,7 @@ public class ControlFlowOperators extends AbstractBaseTest {
|
||||
@Export
|
||||
static int conditionalOperator () {
|
||||
int condition = 4;
|
||||
return condition >= 4 ? 1 : 2;
|
||||
return condition >= 4 ? condition < 4 ? 1 : 2 : condition == 4 ? 3 : 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user