Skip to content

Conversation

rbuckton
Copy link
Contributor

@rbuckton rbuckton commented Jul 2, 2015

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 node pos/end to 0. While generally this seems a valid default, we always set the pos and end of every node created by the parser to a non-negative value when we call createNode and finishNode. Whenever we create a synthesized node in the emitter, we explicitly set the pos/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 new Node as synthesized by default (with a pos/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 the EndOfFileToken, and that its pos and end 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's pos must be non-negative to be considered "missing".

@mhegazy
Copy link
Contributor

mhegazy commented Jul 2, 2015

👍

rbuckton added a commit that referenced this pull request Jul 3, 2015
Change default node pos/end to -1
@rbuckton rbuckton merged commit b294443 into master Jul 3, 2015
@RyanCavanaugh RyanCavanaugh deleted the createNodePos branch July 14, 2015 18:46
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants