[Sourcemap] Introduce getCurrentColumn and stop using TextOutput directly

The general goal is remove dependency on TextOutput and
make it simpler to use for wasm backend.
This commit is contained in:
Zalim Bashorov
2022-12-05 16:18:36 +01:00
committed by Space Team
parent e34d3d09bc
commit fb4dcc6a6a
6 changed files with 11 additions and 8 deletions
@@ -13,7 +13,7 @@ import java.util.function.Supplier
class SourceMap3Builder(
private val generatedFile: File?,
private val textOutput: TextOutput,
private val getCurrentOutputColumn: () -> Int,
private val pathPrefix: String
) : SourceMapBuilder {
@@ -169,13 +169,16 @@ class SourceMap3Builder(
if (newGroupStarted) {
previousGeneratedColumn = 0
}
val columnDiff = textOutput.column - previousGeneratedColumn
val column = getCurrentOutputColumn()
val columnDiff = column - previousGeneratedColumn
if (!newGroupStarted) {
out.append(',')
}
if (columnDiff > 0 || newGroupStarted) {
Base64VLQ.encode(out, columnDiff)
previousGeneratedColumn = textOutput.column
previousGeneratedColumn = column
previousMappingOffset = out.length
previousPreviousSourceIndex = previousSourceIndex