[Wasm] Minor: move buildUnreachable* helpers to more specific module

This commit is contained in:
Zalim Bashorov
2023-01-16 22:56:26 +01:00
parent 9e4b2b78e6
commit ab1cbc49dd
2 changed files with 14 additions and 13 deletions
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.backend.wasm.ir2wasm
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrFileEntry
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.wasm.ir.WasmExpressionBuilder
import org.jetbrains.kotlin.wasm.ir.source.location.SourceLocation
fun IrElement.getSourceLocation(fileEntry: IrFileEntry?): SourceLocation {
@@ -21,3 +22,16 @@ fun IrElement.getSourceLocation(fileEntry: IrFileEntry?): SourceLocation {
return SourceLocation.Location(path, startLine, startColumn)
}
fun WasmExpressionBuilder.buildUnreachableForVerifier() {
buildUnreachable(SourceLocation.NoLocation("This instruction should never be reached, but required for wasm verifier"))
}
fun WasmExpressionBuilder.buildUnreachableAfterNothingType() {
buildUnreachable(
SourceLocation.NoLocation(
"The unreachable instruction after an expression with Nothing type to make sure that " +
"execution doesn't come here (or it fails fast if so). It also might be required for wasm verifier."
)
)
}
@@ -206,16 +206,3 @@ abstract class WasmExpressionBuilder {
buildInstr(WasmOp.PSEUDO_COMMENT_GROUP_END)
}
}
fun WasmExpressionBuilder.buildUnreachableForVerifier() {
buildUnreachable(SourceLocation.NoLocation("This instruction should never be reached, but required for wasm verifier"))
}
fun WasmExpressionBuilder.buildUnreachableAfterNothingType() {
buildUnreachable(
SourceLocation.NoLocation(
"The unreachable instruction after an expression with Nothing type to make sure that " +
"execution doesn't come here (or it fails fast if so). It also might be required for wasm verifier."
)
)
}