[Wasm] Require location for buildDrop and fix all usages

This commit is contained in:
Zalim Bashorov
2022-12-13 19:31:49 +01:00
parent 6eba0392db
commit 95c84d5d3f
3 changed files with 9 additions and 10 deletions
@@ -68,7 +68,7 @@ class BodyGenerator(
private fun generateAsStatement(statement: IrExpression) {
generateExpression(statement)
if (statement.type != wasmSymbols.voidType) {
body.buildDrop()
body.buildDrop(statement.getSourceLocation())
}
}
@@ -489,7 +489,7 @@ class BodyGenerator(
location
)
} else {
body.buildDrop()
body.buildDrop(location)
body.buildConstI32(1, location)
}
}
@@ -546,11 +546,11 @@ class BodyGenerator(
body.buildInstr(WasmOp.I32_EQZ)
body.buildBr(outerLabel)
}
body.buildDrop()
body.buildDrop(location)
body.buildConstI32(0, location)
}
} else {
body.buildDrop()
body.buildDrop(location)
body.buildConstI32(0, location)
}
}
@@ -589,7 +589,6 @@ class BodyGenerator(
}
wasmSymbols.unsafeGetScratchRawMemory -> {
body.buildConstI32Symbol(context.scratchMemAddr, location)
}
@@ -721,7 +720,7 @@ class BodyGenerator(
// NOTHING? -> TYPE? -> (NOTHING?)NULL
if (actualType.isNullableNothing() && expectedType.isNullable()) {
if (expectedType.getClass()?.isExternal == true) {
body.buildDrop()
body.buildDrop(location)
body.buildRefNull(WasmHeapType.Simple.NullNoExtern, location)
}
return
@@ -333,7 +333,7 @@ private fun BodyGenerator.genTableIntSwitch(
for (expression in branches) {
if (resultType != null) {
body.buildDrop()
body.buildDrop(location)
}
generateWithExpectedType(expression.expression, expectedType)
@@ -343,7 +343,7 @@ private fun BodyGenerator.genTableIntSwitch(
if (elseExpression != null) {
if (resultType != null) {
body.buildDrop()
body.buildDrop(location)
}
generateWithExpectedType(elseExpression, expectedType)
}
@@ -179,8 +179,8 @@ abstract class WasmExpressionBuilder {
buildInstr(WasmOp.REF_NULL, location, WasmImmediate.HeapType(WasmRefType(type)))
}
fun buildDrop() {
buildInstr(WasmOp.DROP)
fun buildDrop(location: SourceLocation) {
buildInstr(WasmOp.DROP, location)
}
inline fun commentPreviousInstr(text: () -> String) {