[Wasm] Require a description on each usage of SourceLocation.NoLocation
This commit is contained in:
+1
-1
@@ -166,7 +166,7 @@ class WasmCompiledModuleFragment(val irBuiltIns: IrBuiltIns) {
|
|||||||
val masterInitFunction = WasmFunction.Defined("__init", WasmSymbol(masterInitFunctionType))
|
val masterInitFunction = WasmFunction.Defined("__init", WasmSymbol(masterInitFunctionType))
|
||||||
with(WasmIrExpressionBuilder(masterInitFunction.instructions)) {
|
with(WasmIrExpressionBuilder(masterInitFunction.instructions)) {
|
||||||
initFunctions.sortedBy { it.priority }.forEach {
|
initFunctions.sortedBy { it.priority }.forEach {
|
||||||
buildCall(WasmSymbol(it.function), SourceLocation.NoLocation)
|
buildCall(WasmSymbol(it.function), SourceLocation.NoLocation("Generated service code"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports += WasmExport.Function("__init", masterInitFunction)
|
exports += WasmExport.Function("__init", masterInitFunction)
|
||||||
|
|||||||
+2
-2
@@ -10,13 +10,13 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
|
|||||||
import org.jetbrains.kotlin.wasm.ir.source.location.SourceLocation
|
import org.jetbrains.kotlin.wasm.ir.source.location.SourceLocation
|
||||||
|
|
||||||
fun IrExpression.getSourceLocation(fileEntry: IrFileEntry?): SourceLocation {
|
fun IrExpression.getSourceLocation(fileEntry: IrFileEntry?): SourceLocation {
|
||||||
if (fileEntry == null) return SourceLocation.NoLocation
|
if (fileEntry == null) return SourceLocation.NoLocation("fileEntry is null")
|
||||||
|
|
||||||
val path = fileEntry.name
|
val path = fileEntry.name
|
||||||
val startLine = fileEntry.getLineNumber(startOffset)
|
val startLine = fileEntry.getLineNumber(startOffset)
|
||||||
val startColumn = fileEntry.getColumnNumber(startOffset)
|
val startColumn = fileEntry.getColumnNumber(startOffset)
|
||||||
|
|
||||||
if (startLine < 0 || startColumn < 0) return SourceLocation.NoLocation
|
if (startLine < 0 || startColumn < 0) return SourceLocation.NoLocation("startLine or startColumn < 0")
|
||||||
|
|
||||||
return SourceLocation.Location(path, startLine, startColumn)
|
return SourceLocation.Location(path, startLine, startColumn)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ 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(body: LocationHolder.() -> R): R = withLocation(SourceLocation.NoLocation, 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)
|
inline fun <R> withTBDLocation(body: LocationHolder.() -> R): R = withLocation<R>(SourceLocation.TBDLocation, body)
|
||||||
|
|||||||
@@ -6,8 +6,13 @@
|
|||||||
package org.jetbrains.kotlin.wasm.ir.source.location
|
package org.jetbrains.kotlin.wasm.ir.source.location
|
||||||
|
|
||||||
sealed class SourceLocation {
|
sealed class SourceLocation {
|
||||||
object NoLocation: SourceLocation()
|
private object NoLocation : SourceLocation()
|
||||||
object TBDLocation: 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()
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@Suppress("FunctionName", "UNUSED_PARAMETER")
|
||||||
|
fun NoLocation(description: String): SourceLocation = NoLocation
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user