mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
pass LocalvariableManager to the BranchManager to create temp variable for CATCh blocks.
This commit is contained in:
parent
87374ff41b
commit
25423c6bb8
@ -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 ) );
|
||||
|
||||
|
@ -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() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user