[Wasm] Remove SourceLocation.TBDLocation and related things

This commit is contained in:
Zalim Bashorov
2022-12-13 20:47:27 +01:00
parent 0d203d190e
commit e62add937b
3 changed files with 9 additions and 12 deletions
@@ -390,7 +390,7 @@ class WasmIrToBinary(
} }
appendType(c.type) appendType(c.type)
b.writeVarUInt1(c.isMutable) b.writeVarUInt1(c.isMutable)
appendExpr(c.init, SourceLocation.TBDLocation) appendExpr(c.init)
} }
private fun appendTag(t: WasmTag) { private fun appendTag(t: WasmTag) {
@@ -405,9 +405,9 @@ class WasmIrToBinary(
b.writeVarUInt32(t.type.id!!) b.writeVarUInt32(t.type.id!!)
} }
private fun appendExpr(expr: Iterable<WasmInstr>, location: SourceLocation) { private fun appendExpr(expr: Iterable<WasmInstr>) {
expr.forEach { appendInstr(it) } expr.forEach { appendInstr(it) }
appendInstr(WasmInstrWithLocation(WasmOp.END, location)) appendInstr(WasmInstrWithLocation(WasmOp.END, SourceLocation.NoLocation("End of instruction list")))
} }
private fun appendExport(export: WasmExport<*>) { private fun appendExport(export: WasmExport<*>) {
@@ -433,7 +433,7 @@ class WasmIrToBinary(
funcIndices.forEach { b.writeVarUInt32(it) } funcIndices.forEach { b.writeVarUInt32(it) }
} else { } else {
element.values.forEach { element.values.forEach {
appendExpr((it as WasmTable.Value.Expression).expr, SourceLocation.TBDLocation) appendExpr((it as WasmTable.Value.Expression).expr)
} }
} }
} }
@@ -457,18 +457,18 @@ class WasmIrToBinary(
when { when {
tableId == 0 && isFuncIndices -> { tableId == 0 && isFuncIndices -> {
b.writeByte(0x0) b.writeByte(0x0)
appendExpr(mode.offset, SourceLocation.TBDLocation) appendExpr(mode.offset)
} }
isFuncIndices -> { isFuncIndices -> {
b.writeByte(0x2) b.writeByte(0x2)
appendModuleFieldReference(mode.table) appendModuleFieldReference(mode.table)
appendExpr(mode.offset, SourceLocation.TBDLocation) appendExpr(mode.offset)
writeTypeOrKind() writeTypeOrKind()
} }
else -> { else -> {
b.writeByte(0x6) b.writeByte(0x6)
appendModuleFieldReference(mode.table) appendModuleFieldReference(mode.table)
appendExpr(mode.offset, SourceLocation.TBDLocation) appendExpr(mode.offset)
writeTypeOrKind() writeTypeOrKind()
} }
} }
@@ -492,7 +492,7 @@ class WasmIrToBinary(
} }
} }
appendExpr(function.instructions, SourceLocation.TBDLocation) appendExpr(function.instructions)
} }
} }
@@ -505,7 +505,7 @@ class WasmIrToBinary(
b.writeByte(2) b.writeByte(2)
b.writeVarUInt32(mode.memoryIdx) b.writeVarUInt32(mode.memoryIdx)
} }
appendExpr(mode.offset, SourceLocation.TBDLocation) appendExpr(mode.offset)
} }
WasmDataMode.Passive -> b.writeByte(1) WasmDataMode.Passive -> b.writeByte(1)
} }
@@ -11,5 +11,3 @@ value class LocationHolder(val location: SourceLocation)
inline fun <R> withLocation(location: SourceLocation, body: LocationHolder.() -> R): R = LocationHolder(location).body() inline fun <R> withLocation(location: SourceLocation, body: LocationHolder.() -> R): R = LocationHolder(location).body()
inline fun <R> withNoLocation(description: String, body: LocationHolder.() -> R): R = withLocation(SourceLocation.NoLocation(description), body) inline fun <R> withNoLocation(description: String, body: LocationHolder.() -> R): R = withLocation(SourceLocation.NoLocation(description), body)
inline fun <R> withTBDLocation(body: LocationHolder.() -> R): R = withLocation<R>(SourceLocation.TBDLocation, body)
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.wasm.ir.source.location
sealed class SourceLocation { sealed class SourceLocation {
private object NoLocation : SourceLocation() private object NoLocation : SourceLocation()
object TBDLocation : SourceLocation()
data class Location(val file: String, val line: Int, val column: Int) : SourceLocation() data class Location(val file: String, val line: Int, val column: Int) : SourceLocation()