Properly calculate maxUsedValue
This commit is contained in:
@@ -152,7 +152,8 @@ interface SourceMapper {
|
||||
}
|
||||
|
||||
fun createFromSmap(smap: SMAP): SourceMapper {
|
||||
val sourceMapper = org.jetbrains.kotlin.codegen.inline2.DefaultSourceMapper(smap.sourceInfo)
|
||||
val maxUsedIndex = smap.fileMappings.maxBy { it.lineMappings.maxBy { it.maxDest }!!.maxDest }!!.lineMappings.maxBy { it.maxDest }!!.maxDest
|
||||
val sourceMapper = org.jetbrains.kotlin.codegen.inline2.DefaultSourceMapper(smap.sourceInfo, maxUsedIndex)
|
||||
smap.fileMappings.asSequence()
|
||||
//default one mapped through sourceInfo
|
||||
.filterNot { it == smap.default }
|
||||
@@ -337,6 +338,9 @@ data class RangeMapping(val source: Int, val dest: Int, var range: Int = 1) {
|
||||
var parent: FileMapping? = null
|
||||
private val skip = source == -1 && dest == -1
|
||||
|
||||
val maxDest: Int
|
||||
get() = dest + range - 1
|
||||
|
||||
operator fun contains(destLine: Int): Boolean {
|
||||
return if (skip) true else dest <= destLine && destLine < dest + range
|
||||
}
|
||||
|
||||
@@ -81,8 +81,11 @@ open class InlineLambdaSourceMapper(
|
||||
}
|
||||
|
||||
|
||||
open class DefaultSourceMapper(val sourceInfo: SourceInfo): SourceMapper {
|
||||
protected var maxUsedValue: Int = sourceInfo.linesInFile
|
||||
open class DefaultSourceMapper @JvmOverloads constructor(
|
||||
val sourceInfo: SourceInfo,
|
||||
protected var maxUsedValue: Int = sourceInfo.linesInFile
|
||||
) : SourceMapper {
|
||||
|
||||
var lastVisited: RawFileMapping? = null
|
||||
private var lastMappedWithChanges: RawFileMapping? = null
|
||||
private var fileMappings: LinkedHashMap<String, RawFileMapping> = linkedMapOf()
|
||||
@@ -92,7 +95,7 @@ open class DefaultSourceMapper(val sourceInfo: SourceInfo): SourceMapper {
|
||||
val name = sourceInfo.source
|
||||
val path = sourceInfo.pathOrCleanFQN
|
||||
origin = RawFileMapping(name, path)
|
||||
origin.initRange(1, maxUsedValue)
|
||||
origin.initRange(1, sourceInfo.linesInFile)
|
||||
fileMappings.put(createKey(name, path), origin)
|
||||
lastVisited = origin
|
||||
}
|
||||
|
||||
@@ -123,4 +123,4 @@ object SMAPTestUtil {
|
||||
}
|
||||
|
||||
val RangeMapping.toRange: IntRange
|
||||
get() = this.dest..this.dest + this.range - 1
|
||||
get() = this.dest..this.maxDest
|
||||
|
||||
Reference in New Issue
Block a user