Change default node pos/end to -1 #3719
Merged
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
objectAllocator
for both compiler and services sets the default nodepos
/end
to0
. While generally this seems a valid default, we always set thepos
andend
of every node created by the parser to a non-negative value when we callcreateNode
andfinishNode
. Whenever we create a synthesized node in the emitter, we explicitly set thepos
/end
to-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 newNode
as synthesized by default (with apos
/end
of-1
) until such time as the parser explicitly sets the position.In addition, the
nodeIsMissing
function currently tests whether the node exists, is not theEndOfFileToken
, and that itspos
andend
are 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'spos
must be non-negative to be considered "missing".