mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 15:37:52 +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 List<WasmInstruction> instructions;
|
||||||
|
|
||||||
|
private final LocaleVariableManager localVariables;
|
||||||
|
|
||||||
private TryCatchFinally[] exceptionTable;
|
private TryCatchFinally[] exceptionTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,10 +67,13 @@ class BranchManger {
|
|||||||
* compiler option/properties
|
* compiler option/properties
|
||||||
* @param instructions
|
* @param instructions
|
||||||
* the target for instructions
|
* the target for instructions
|
||||||
|
* @param localVariables
|
||||||
|
* the local variables
|
||||||
*/
|
*/
|
||||||
public BranchManger( WasmOptions options, List<WasmInstruction> instructions ) {
|
public BranchManger( WasmOptions options, List<WasmInstruction> instructions, LocaleVariableManager localVariables ) {
|
||||||
this.instructions = instructions;
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
this.instructions = instructions;
|
||||||
|
this.localVariables = localVariables;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -921,6 +926,7 @@ class BranchManger {
|
|||||||
if( tryCatch.isFinally() ) {
|
if( tryCatch.isFinally() ) {
|
||||||
catchNode.add( new BranchNode( catchPos, catchPos, WasmBlockOperator.DROP, null ) );
|
catchNode.add( new BranchNode( catchPos, catchPos, WasmBlockOperator.DROP, null ) );
|
||||||
} else {
|
} 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.BR_ON_EXN, null, 1 ) );
|
||||||
catchNode.add( new BranchNode( catchPos, catchPos, WasmBlockOperator.RETHROW, null ) );
|
catchNode.add( new BranchNode( catchPos, catchPos, WasmBlockOperator.RETHROW, null ) );
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class JavaMethodWasmCodeBuilder extends WasmCodeBuilder {
|
|||||||
@Override
|
@Override
|
||||||
void init( WasmOptions options, ClassFileLoader classFileLoader ) {
|
void init( WasmOptions options, ClassFileLoader classFileLoader ) {
|
||||||
super.init( options, 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
|
* @return the list
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
List<WasmInstruction> getInstructions() {
|
List<WasmInstruction> getInstructions() {
|
||||||
return instructions;
|
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
|
* Check if the last instruction is a return instruction
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user