[Wasm] Require location for buildBr* and fix all usages

This commit is contained in:
Zalim Bashorov
2022-12-13 20:16:35 +01:00
parent 95c84d5d3f
commit 1244cd1259
3 changed files with 20 additions and 19 deletions
@@ -78,20 +78,20 @@ abstract class WasmExpressionBuilder {
}
fun buildBrInstr(brOp: WasmOp, absoluteBlockLevel: Int) {
fun buildBrInstr(brOp: WasmOp, absoluteBlockLevel: Int, location: SourceLocation) {
val relativeLevel = numberOfNestedBlocks - absoluteBlockLevel
assert(relativeLevel >= 0) { "Negative relative block index" }
buildInstr(brOp, WasmImmediate.LabelIdx(relativeLevel))
buildInstr(brOp, location, WasmImmediate.LabelIdx(relativeLevel))
}
fun buildBrInstr(brOp: WasmOp, absoluteBlockLevel: Int, symbol: WasmSymbolReadOnly<WasmTypeDeclaration>) {
fun buildBrInstr(brOp: WasmOp, absoluteBlockLevel: Int, symbol: WasmSymbolReadOnly<WasmTypeDeclaration>, location: SourceLocation) {
val relativeLevel = numberOfNestedBlocks - absoluteBlockLevel
assert(relativeLevel >= 0) { "Negative relative block index" }
buildInstr(brOp, WasmImmediate.LabelIdx(relativeLevel), WasmImmediate.TypeIdx(symbol))
buildInstr(brOp, location, WasmImmediate.LabelIdx(relativeLevel), WasmImmediate.TypeIdx(symbol))
}
fun buildBr(absoluteBlockLevel: Int) {
buildBrInstr(WasmOp.BR, absoluteBlockLevel)
fun buildBr(absoluteBlockLevel: Int, location: SourceLocation) {
buildBrInstr(WasmOp.BR, absoluteBlockLevel, location)
}
fun buildThrow(tagIdx: Int) {
@@ -108,8 +108,8 @@ abstract class WasmExpressionBuilder {
buildInstr(WasmOp.CATCH, WasmImmediate.TagIdx(tagIdx))
}
fun buildBrIf(absoluteBlockLevel: Int) {
buildBrInstr(WasmOp.BR_IF, absoluteBlockLevel)
fun buildBrIf(absoluteBlockLevel: Int, location: SourceLocation) {
buildBrInstr(WasmOp.BR_IF, absoluteBlockLevel, location)
}
fun buildCall(symbol: WasmSymbol<WasmFunction>, location: SourceLocation) {