Range mappings: Change index encoding to start at 0#252
Range mappings: Change index encoding to start at 0#252takikawa merged 4 commits intotc39:proposal-range-mappingsfrom
Conversation
Currently "BB" means the first and second mappings are range mappings. Instead, we'll have "AB" encode the same. "BA" will be an (optional) error because a duplicate index is encoded.
| <emu-alg> | ||
| 1. Let _relativeIndex_ be the VLQUnsignedValue of |Vlq|. | ||
| 1. If _relativeIndex_ is 0, then | ||
| 1. If _relativeIndex_ = 0 and _state_.[[MappingIndex]] ≠ 0, then |
There was a problem hiding this comment.
Nit: this means AA is valid, both marking the 0th mapping as a range.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
One alternative that I forgot about yesterday, is that we could solve this in the grammar itself. Then you don't even need the check. We add a Then the range mapping grammar is something like: Probably a lot of addition to the spec for one use-site. But maybe something to keep in mind if we ever have a need for non-zero VLQs (both signed or unsigned). |
Disallows a range mapping string like "AA" that wasn't covered by the previous attempt.
|
I think the In the latest push, I initialized the decode state's |
| </tr> | ||
| <tr> | ||
| <td>[[MappingIndex]]</td> | ||
| <td>a non-negative integer or ~none~</td> |
There was a problem hiding this comment.
Alternatively we could allow this to be negative, initialize to -1, and verify it's positive in appending the new Range Mapping Offset Record.
There was a problem hiding this comment.
I prefer ~none~, as it makes the intent clearer when reading.
This implements the change discussed in the April TG4 meeting about reverting the range mapping encoding so that it will start at 0 with relative offset instead of at -1.