[Wasm] Add a comment about location into WasmExpressionBuilder

This commit is contained in:
Zalim Bashorov
2022-12-15 21:55:02 +01:00
parent 37879e18d9
commit 2fa2725012
2 changed files with 15 additions and 0 deletions
@@ -7,6 +7,17 @@ package org.jetbrains.kotlin.wasm.ir
import org.jetbrains.kotlin.wasm.ir.source.location.SourceLocation
/**
* Class for building a wasm instructions list.
*
* Note in most of the methods, location is a required parameter, and it's expected to be passed explicitly.
* The goals are:
* - Avoid missing a location
* - Avoid providing a wrong location
* - It's hard to achieve fully, but:
* - at least, an API user has to think about what to pass a location
* - it's not taken from some context-like thing implicitly, so you will not get it implicitly from a wrong context/scope.
*/
abstract class WasmExpressionBuilder {
abstract fun buildInstr(op: WasmOp, location: SourceLocation, vararg immediates: WasmImmediate)
@@ -22,6 +22,10 @@ private fun WasmOp.pureStacklessInstruction() = when (this) {
else -> false
}
/**
* Read comments in [WasmExpressionBuilder]
* TODO merge into [WasmExpressionBuilder]
*/
class WasmIrExpressionBuilder(
val expression: MutableList<WasmInstr>
) : WasmExpressionBuilder() {