[WasmJs] Support catching JS exceptions
Fixed #KT-65660
This commit is contained in:
committed by
Space Team
parent
c6aac835e5
commit
8fe5cf2641
@@ -139,6 +139,10 @@ abstract class WasmExpressionBuilder {
|
||||
buildInstrWithNoLocation(WasmOp.CATCH, WasmImmediate.TagIdx(tagIdx))
|
||||
}
|
||||
|
||||
fun buildCatchAll() {
|
||||
buildInstrWithNoLocation(WasmOp.CATCH_ALL)
|
||||
}
|
||||
|
||||
fun buildBrIf(absoluteBlockLevel: Int, location: SourceLocation) {
|
||||
buildBrInstr(WasmOp.BR_IF, absoluteBlockLevel, location)
|
||||
}
|
||||
|
||||
@@ -117,13 +117,13 @@ class WasmIrToText(
|
||||
return
|
||||
}
|
||||
|
||||
if (op == WasmOp.END || op == WasmOp.ELSE || op == WasmOp.CATCH)
|
||||
if (op == WasmOp.END || op == WasmOp.ELSE || op == WasmOp.CATCH || op == WasmOp.CATCH_ALL)
|
||||
indent--
|
||||
|
||||
newLine()
|
||||
stringBuilder.append(wasmInstr.operator.mnemonic)
|
||||
|
||||
if (op == WasmOp.BLOCK || op == WasmOp.LOOP || op == WasmOp.IF || op == WasmOp.ELSE || op == WasmOp.CATCH || op == WasmOp.TRY)
|
||||
if (op == WasmOp.BLOCK || op == WasmOp.LOOP || op == WasmOp.IF || op == WasmOp.ELSE || op == WasmOp.CATCH || op == WasmOp.CATCH_ALL || op == WasmOp.TRY)
|
||||
indent++
|
||||
|
||||
if (wasmInstr.operator in setOf(WasmOp.CALL_INDIRECT, WasmOp.TABLE_INIT)) {
|
||||
|
||||
Generated
+6
@@ -84,6 +84,12 @@ public class FirWasmJsCodegenInteropTestGenerated extends AbstractFirWasmJsCodeg
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/jsCode.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jsException.kt")
|
||||
public void testJsException() {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/jsException.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jsExport.kt")
|
||||
public void testJsExport() {
|
||||
|
||||
+6
@@ -84,6 +84,12 @@ public class K1WasmCodegenWasmJsInteropTestGenerated extends AbstractK1WasmCodeg
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/jsCode.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jsException.kt")
|
||||
public void testJsException() {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/jsException.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jsExport.kt")
|
||||
public void testJsExport() {
|
||||
|
||||
Reference in New Issue
Block a user