pass LocalvariableManager to the BranchManager to create temp variable for CATCh blocks.

This commit is contained in:
Volker Berlin 2020-04-13 16:05:41 +02:00
parent 87374ff41b
commit 25423c6bb8
3 changed files with 19 additions and 3 deletions

View File

@ -56,6 +56,8 @@ class BranchManger {
private final List<WasmInstruction> instructions;
private final LocaleVariableManager localVariables;
private TryCatchFinally[] exceptionTable;
/**
@ -65,10 +67,13 @@ class BranchManger {
* compiler option/properties
* @param instructions
* the target for instructions
* @param localVariables
* the local variables
*/
public BranchManger( WasmOptions options, List<WasmInstruction> instructions ) {
this.instructions = instructions;
public BranchManger( WasmOptions options, List<WasmInstruction> instructions, LocaleVariableManager localVariables ) {
this.options = options;
this.instructions = instructions;
this.localVariables = localVariables;
}
/**
@ -921,6 +926,7 @@ class BranchManger {
if( tryCatch.isFinally() ) {
catchNode.add( new BranchNode( catchPos, catchPos, WasmBlockOperator.DROP, null ) );
} else {
//TODO localVariables.getTempVariable( ValueType.exnref, catchPos, endPos ); https://github.com/WebAssembly/wabt/issues/1388
catchNode.add( new BranchNode( catchPos, catchPos, WasmBlockOperator.BR_ON_EXN, null, 1 ) );
catchNode.add( new BranchNode( catchPos, catchPos, WasmBlockOperator.RETHROW, null ) );

View File

@ -53,7 +53,7 @@ class JavaMethodWasmCodeBuilder extends WasmCodeBuilder {
@Override
void init( WasmOptions options, ClassFileLoader classFileLoader ) {
super.init( options, classFileLoader );
this.branchManager = new BranchManger( options, getInstructions() );
this.branchManager = new BranchManger( options, getInstructions(), getLocalVariables() );
}
/**

View File

@ -90,10 +90,20 @@ public abstract class WasmCodeBuilder {
*
* @return the list
*/
@Nonnull
List<WasmInstruction> getInstructions() {
return instructions;
}
/**
* Get the manager of local variables
* @return the manager
*/
@Nonnull
LocaleVariableManager getLocalVariables() {
return localVariables;
}
/**
* Check if the last instruction is a return instruction
*