mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
support dynamic result type for an if block
This commit is contained in:
parent
c8aecea7ab
commit
b1eb27c474
@ -698,7 +698,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
break;
|
||||
case IF:
|
||||
codeStream.write( IF );
|
||||
codeStream.write( ValueType.empty.getCode() ); // void; the return type of the block. currently we does not use it
|
||||
codeStream.write( ((ValueType)data).getCode() );
|
||||
break;
|
||||
case ELSE:
|
||||
codeStream.write( ELSE );
|
||||
|
@ -252,7 +252,7 @@ class BranchManger {
|
||||
ParsedBlock parsedBlock = parsedOperations.get( i );
|
||||
if( parsedBlock.startPosition == gotoPos && parsedBlock.op == JavaBlockOperator.GOTO && parsedBlock.startPosition < parsedBlock.endPosition) {
|
||||
parsedOperations.remove( i );
|
||||
branch = new BranchNode( startPos, startBlock.endPosition, WasmBlockOperator.IF, null );
|
||||
branch = new BranchNode( startPos, startBlock.endPosition, WasmBlockOperator.IF, null, ValueType.empty );
|
||||
parent.add( branch );
|
||||
if( i > 0 ) {
|
||||
calculate( branch, parsedOperations.subList( 0, i ) );
|
||||
@ -276,7 +276,7 @@ class BranchManger {
|
||||
}
|
||||
|
||||
if( branch == null ) {
|
||||
branch = new BranchNode( startPos, endPos, WasmBlockOperator.IF, WasmBlockOperator.END );
|
||||
branch = new BranchNode( startPos, endPos, WasmBlockOperator.IF, WasmBlockOperator.END, ValueType.empty );
|
||||
parent.add( branch );
|
||||
}
|
||||
startBlock.negateCompare();
|
||||
|
@ -282,6 +282,9 @@ public class TextModuleWriter extends ModuleWriter {
|
||||
break;
|
||||
case IF:
|
||||
name = "if";
|
||||
if( data != ValueType.empty ) {
|
||||
name += " (result " + data + ")";
|
||||
}
|
||||
insetAfter++;
|
||||
break;
|
||||
case ELSE:
|
||||
|
Loading…
x
Reference in New Issue
Block a user