Change default node pos/end to -1#3719
Merged
Merged
Conversation
Contributor
|
👍 |
rbuckton
added a commit
that referenced
this pull request
Jul 3, 2015
Change default node pos/end to -1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There are two issues addressed here, meant to help support down-level emit for Async Functions (and optionally Generators) in ES5/3.
Currently, the
objectAllocatorfor both compiler and services sets the default nodepos/endto0. While generally this seems a valid default, we always set theposandendof every node created by the parser to a non-negative value when we callcreateNodeandfinishNode. Whenever we create a synthesized node in the emitter, we explicitly set thepos/endto-1. For the down-level rewrite, I will be generating many synthesized nodes and am looking to centralize node creation into a set of factory methods for creating each of our various types of nodes. I plan to have both parser and emitter rely on this to centralize node creation, and as such it seems reasonable to treat any newNodeas synthesized by default (with apos/endof-1) until such time as the parser explicitly sets the position.In addition, the
nodeIsMissingfunction currently tests whether the node exists, is not theEndOfFileToken, and that itsposandendare not the same value. This means that any any synthesized node would be considered "missing". As such, I have added a condition that the node'sposmust be non-negative to be considered "missing".