support dynamic result type for an if block

This commit is contained in:
Volker 2018-08-05 14:45:18 +02:00
parent c8aecea7ab
commit b1eb27c474
3 changed files with 6 additions and 3 deletions

View File

@ -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 );

View File

@ -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();

View File

@ -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: