[K/Wasm] Reduce debug information for the internal Kotlin functions
This commit is contained in:
+2
-2
@@ -1022,6 +1022,6 @@ class BodyGenerator(
|
||||
return false
|
||||
}
|
||||
|
||||
private fun IrElement.getSourceLocation() = getSourceLocation(functionContext.currentFunction.fileOrNull?.fileEntry)
|
||||
private fun IrElement.getSourceEndLocation() = getSourceLocation(functionContext.currentFunction.fileOrNull?.fileEntry, type = LocationType.END)
|
||||
private fun IrElement.getSourceLocation() = getSourceLocation(functionContext.currentFunction.fileOrNull)
|
||||
private fun IrElement.getSourceEndLocation() = getSourceLocation(functionContext.currentFunction.fileOrNull, type = LocationType.END)
|
||||
}
|
||||
|
||||
+1
-1
@@ -471,7 +471,7 @@ class DeclarationGenerator(
|
||||
initValue,
|
||||
wasmExpressionGenerator,
|
||||
context,
|
||||
declaration.getSourceLocation(declaration.fileOrNull?.fileEntry)
|
||||
declaration.getSourceLocation(declaration.fileOrNull)
|
||||
)
|
||||
} else {
|
||||
generateDefaultInitializerForType(wasmType, wasmExpressionGenerator)
|
||||
|
||||
+13
-1
@@ -9,7 +9,9 @@ import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.IrFileEntry
|
||||
import org.jetbrains.kotlin.ir.LineAndColumn
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.util.SYNTHETIC_OFFSET
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.wasm.ir.WasmExpressionBuilder
|
||||
import org.jetbrains.kotlin.wasm.ir.source.location.SourceLocation
|
||||
|
||||
@@ -30,7 +32,12 @@ enum class LocationType {
|
||||
abstract fun getLineAndColumnNumberFor(irElement: IrElement, fileEntry: IrFileEntry): LineAndColumn
|
||||
}
|
||||
|
||||
fun IrElement.getSourceLocation(fileEntry: IrFileEntry?, type: LocationType = LocationType.START): SourceLocation {
|
||||
private val IrFile.isIgnoredFile: Boolean
|
||||
get() = packageFqName.startsWith(StandardClassIds.BASE_KOTLIN_PACKAGE)
|
||||
|
||||
fun IrElement.getSourceLocation(file: IrFile?, type: LocationType = LocationType.START): SourceLocation {
|
||||
val fileEntry = file?.fileEntry
|
||||
|
||||
if (fileEntry == null) return SourceLocation.NoLocation("fileEntry is null")
|
||||
if (hasSyntheticOrUndefinedLocation) return SourceLocation.NoLocation("Synthetic declaration")
|
||||
|
||||
@@ -39,6 +46,11 @@ fun IrElement.getSourceLocation(fileEntry: IrFileEntry?, type: LocationType = Lo
|
||||
|
||||
if (line < 0 || column < 0) return SourceLocation.NoLocation("startLine or startColumn < 0")
|
||||
|
||||
if (file.isIgnoredFile) {
|
||||
return SourceLocation.IgnoredLocation(path, line, column)
|
||||
}
|
||||
|
||||
|
||||
return SourceLocation.Location(path, line, column)
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -42,7 +42,7 @@ class SourceMapGenerator(
|
||||
val pathResolver =
|
||||
SourceFilePathResolver.create(sourceMapsInfo.sourceRoots, sourceMapsInfo.sourceMapPrefix, sourceMapsInfo.outputDir)
|
||||
|
||||
var prev: SourceLocation? = null
|
||||
var prev: SourceLocation.Location? = null
|
||||
var prevGeneratedLine = 0
|
||||
|
||||
for (mapping in sourceLocationMappings) {
|
||||
@@ -59,7 +59,8 @@ class SourceMapGenerator(
|
||||
}
|
||||
|
||||
when (sourceLocation) {
|
||||
is SourceLocation.NoLocation -> sourceMapBuilder.addEmptyMapping(generatedLocation.column)
|
||||
// TODO: add the ignored location into "ignoreList" in future
|
||||
is SourceLocation.NoLocation, is SourceLocation.IgnoredLocation -> sourceMapBuilder.addEmptyMapping(generatedLocation.column)
|
||||
is SourceLocation.Location -> {
|
||||
sourceLocation.apply {
|
||||
// TODO resulting path goes too deep since temporary directory we compiled first is deeper than final destination.
|
||||
|
||||
Reference in New Issue
Block a user