Skip to content

Commit 6a2e12a

Browse files
authored
Scopes: Use relative encoding for column, absolute for 'generated_range_callsite' (tc39#188)
1 parent 8d01a3e commit 6a2e12a

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Diff for: proposals/scopes.md

+6-9
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ To reduce the number of bytes required to encode the "scopes" information, we us
293293
* `sKIND` in `original_scope_start` is relative to the previous occurrence of `sKIND` (or absolute for the first).
294294
* `uLINE` in `original_scope_start` and `original_scope_end` are relative to the previous occurrence (or absolute for the first).
295295
This means a `uLINE` of a `original_scope_start` is relative to either its parents' start line or its preceding siblings' end line.
296+
* `uCOLUMN` in `original_scope_start` and `original_scope_end` are relative to the previous occurrence if (and only if) the `uLINE` of this item is 0. That is, columns are encoded relative to each other if the pervious `original_scope_*` item is on the same line, absolute otherwise.
296297
* `sVARIABLE` in `original_scope_variables` is relative to the previous occurrence of `sVARIABLE` (or absolute for the first).
297298

298-
Each top-level `original_scope_tree` resets the "relative state". That is, each top-level `original_scope_tree` is decoded as if its the first.
299-
299+
Each top-level `original_scope_tree` resets the "relative state" of `uLINE` and `uCOLUMN`. That is, each top-level `original_scope_start` decodes `uLINE` and `uCOLUMN` as if the previous occurrence was (0, 0). In contrast, `sNAME`, `sKIND` and `sVARIABLE` are relative to each other even across top-level `original_scope_tree`s.
300300

301301
#### Generated Range Trees
302302

@@ -352,16 +352,13 @@ be found with the pseudo code `const scopeStart = scopes.filter(item => item.tag
352352
```
353353
generated_range_callsite :=
354354
'I' // Tag: 0x8 unsigned
355-
sSOURCE_IDX
356-
sLINE
357-
sCOLUMN
355+
uSOURCE_IDX
356+
uLINE
357+
uCOLUMN
358358
```
359359

360360
If a "generated range" contains a callsite, then the range describes an inlined function body. The inlined function was called at the original position described by this `generated_range_callsite`.
361-
362-
* `sSOURCE_IDX` in `generated_range_callsite` is relative to the previous occurrence (or absolute for the first).
363-
* `sLINE` in `generated_range_callsite` is relative to the previous occurrence, if the previous `generated_range_callsite` was in the same source file. Absolute otherwise.
364-
* `SCOLUMN` in `generated_range_callsite` is relative to the previous occurrence, if the previous `generated_range_callsite` was on the same line in the same file. Absolute otherwise.
361+
`uSOURCE_IDX`, `uLINE` and `uCOLUMN` of the `generated_range_callsite` are always encoded absolute.
365362

366363
```
367364
generated_range_bindings :=

0 commit comments

Comments
 (0)