-
Couldn't load subscription status.
- Fork 0
Refactor scopes tree decoding #1
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
Refactor scopes tree decoding #1
Conversation
| <emu-alg> | ||
| 1. Perform DecodeScopesInfoItem of |OriginalScopeTreeList| with arguments _info_, _state_ and _names_. | ||
| 1. Let _originalScopes_ be the DecodedOriginalScopeTrees of |OriginalScopeTreeList| with arguments _state_ and _names_. | ||
| 1. Set _info_.[[Scopes]] to _originalScopes_. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we need to set the result on DecodeOriginalScopeTrees now on _info_.[[Scopes]], do we also need to duplicate this for the production:
Scopes :
OriginalScopeTreeList
Since the application of the chain rule only performs the SDO but does not set t on _info_?
spec.emu
Outdated
| _state_: a Decode Scope State Record, | ||
| _names_: a List of Strings, | ||
| ) | ||
| ): a List of Original Scope Record |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is important that we preserve the OriginalScopeTreeItem: [empty] case with a null.
The motivation is that if a source map has a list of N sources, then we expect N original scope trees. To signify that a specific source file doesn't have an original scope tree, we currently use the empty production and add null.
The PR currently removes the null, so afterwards we can't associate source records with their respective original scope tree.
I don't have a strong opinion if we want to do this differently. Either by having an "empty" tag, or by adding a "sourceFileIndex" field or item.
If we keep the "null" route we'd need to:
- Return here
a List of either a Original Scope Record or ~null~ - Change the empty production to return a single element list:
1. Return « ~null~ »
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also add null to the flattened scopes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say no. Reason being that the "definition index" in a generated range is basically the Nth "original scope start" item. I.e. an index into the flattened scopes without pushing the top-level null scopes.
e9babd7 to
7479908
Compare
|
I have an extra closing tag somewhere, that's why the diff is weird. |
7479908 to
0043d9c
Compare
|
Fixed! |
|
I'll re-open on the other repo |
See tc39#196 (comment).
I tried to make it a bit easier to see what is going on by:
We could do something similar for TopLevelItemList.