Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scopes: how to encode unavailable bindings #70

Open
hbenl opened this issue Feb 27, 2024 · 2 comments
Open

Scopes: how to encode unavailable bindings #70

hbenl opened this issue Feb 27, 2024 · 2 comments
Labels

Comments

@hbenl
Copy link
Collaborator

hbenl commented Feb 27, 2024

The scopes proposal adds information about scopes and their variables and bindings to the sourcemap. But some bindings will be unavailable, i.e. for some original variables there will be no expression that can be evaluated to get the variable's current value. We could encode this by using -1 as the index in the names array for these bindings but this clashes with our use of relative indices into the names array. We use relative indices in the hopes of reducing the encoded scope's size because the encoding of relative indices will hopefully be smaller on average than that of absolute indices. But if some of the indices will be -1 then using relative indices will probably not reduce the size of the encoded scope.

@szuend
Copy link
Collaborator

szuend commented Mar 4, 2024

To summarize the possible solutions that were discussed on the call 2024-02-29:

  • Use an additional bitfield to indicate which of the live ranges indicate an "unavailable" range and the expression index must be ignored.
  • Introduce one more character on top of " and , to signal undefined or null.
  • (from @jridgewell in chat) Add an empty string to names and point to that.

@hbenl
Copy link
Collaborator Author

hbenl commented Mar 8, 2024

Add an empty string to names and point to that.

That would leave us with the same problem: if, for example, you added the empty string at the start of names then unavailable bindings would all be encoded with 0 instead of -1 - using relative indices will still not reduce the size of the encoded scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants