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