Skip to content

Commit 384edda

Browse files
committed
Make source, line and column in call site absolute
Part of aligning the imlpementation with tc39/ecma426#188.
1 parent 8cbab81 commit 384edda

File tree

2 files changed

+9
-38
lines changed

2 files changed

+9
-38
lines changed

src/decode/decode.ts

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ const DEFAULT_RANGE_STATE = {
5656
line: 0,
5757
column: 0,
5858
defScopeIdx: 0,
59-
callsiteSourceIdx: 0,
60-
callsiteLine: 0,
61-
callsiteColumn: 0,
6259
};
6360

6461
class Decoder {
@@ -173,9 +170,9 @@ class Decoder {
173170
}
174171
case Tag.GENERATED_RANGE_CALL_SITE: {
175172
this.#handleGeneratedRangeCallSite(
176-
iter.nextSignedVLQ(),
177-
iter.nextSignedVLQ(),
178-
iter.nextSignedVLQ(),
173+
iter.nextUnsignedVLQ(),
174+
iter.nextUnsignedVLQ(),
175+
iter.nextUnsignedVLQ(),
179176
);
180177
break;
181178
}
@@ -352,21 +349,10 @@ class Decoder {
352349
return;
353350
}
354351

355-
if (sourceIndex === 0 && line === 0) {
356-
this.#rangeState.callsiteColumn += column;
357-
} else if (sourceIndex === 0) {
358-
this.#rangeState.callsiteLine += line;
359-
this.#rangeState.callsiteColumn = column;
360-
} else {
361-
this.#rangeState.callsiteSourceIdx += sourceIndex;
362-
this.#rangeState.callsiteLine = line;
363-
this.#rangeState.callsiteColumn = column;
364-
}
365-
366352
range.callSite = {
367-
sourceIndex: this.#rangeState.callsiteSourceIdx,
368-
line: this.#rangeState.callsiteLine,
369-
column: this.#rangeState.callsiteColumn,
353+
sourceIndex,
354+
line,
355+
column,
370356
};
371357
}
372358

src/encode/encoder.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ const DEFAULT_RANGE_STATE = {
2222
line: 0,
2323
column: 0,
2424
defScopeIdx: 0,
25-
callsiteSourceIdx: 0,
26-
callsiteLine: 0,
27-
callsiteColumn: 0,
2825
};
2926

3027
export class Encoder {
@@ -217,21 +214,9 @@ export class Encoder {
217214

218215
// TODO: Throw if stackFrame flag is set or OriginalScope index is invalid or no generated range is here.
219216

220-
const encodedSourceIndex = sourceIndex - this.#rangeState.callsiteSourceIdx;
221-
const encodedLine = encodedSourceIndex == 0
222-
? line - this.#rangeState.callsiteLine
223-
: line;
224-
const encodedColumn = encodedLine == 0
225-
? column - this.#rangeState.callsiteColumn
226-
: column;
227-
228-
this.#rangeState.callsiteSourceIdx = sourceIndex;
229-
this.#rangeState.callsiteLine = line;
230-
this.#rangeState.callsiteColumn = column;
231-
232-
this.#encodeTag(EncodedTag.GENERATED_RANGE_CALL_SITE).#encodeSigned(
233-
encodedSourceIndex,
234-
).#encodeSigned(encodedLine).#encodeSigned(encodedColumn).#finishItem();
217+
this.#encodeTag(EncodedTag.GENERATED_RANGE_CALL_SITE).#encodeUnsigned(
218+
sourceIndex,
219+
).#encodeUnsigned(line).#encodeUnsigned(column).#finishItem();
235220
}
236221

237222
#encodeGeneratedRangeEnd(range: GeneratedRange) {

0 commit comments

Comments
 (0)