GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||
GeezerVison is showing github.com — Adds the Transform Flags concept for tree transformations by rbuckton · Pull Request #6983 · microsoft/TypeScript Conversation
Contributor
To ensure tree transformations in the TypeScript compiler are efficient, we compute information about various required transformations for each node. Transform flags are aggregated in a bottom-up fashion, so that we already have information about a node's subtree when we compute the transform flags for the node. These transform flags are initially computed during the bind phase of the compiler, as at that point we guarantee a full walk of the tree. The values in the
As a result, the
The binder is modified to compute the transform flags for each node as it walks the tree. As a performance optimization, we skip transform flag aggregation for ambient nodes, type nodes, and declaration files. Each transformation phase will likely introduce new nodes. As a result, the For example, it is possible that during the transformation from TypeScript to ES6 we may introduce an arrow function a for more idiomatic ES6 emit. This may then result in a new These flags will enable us to have more efficient transformers in the long term, that can make decisions about whether to continue to walk a subtree based on querying these flags. The following example builds on the one found in #6892: function visitor(node: Node) { if (node.transformFlags & TransformFlags.ES7) { // This node is an ES7 node and needs a specific transformation return visitorWorker(node); } else if (node.transformFlags & TransformFlags.ContainsES7) { // This node contains an ES7 node somewhere in its subtree, so we must walk the subtree return visitEachChild(node, visitor); } else { // Neither this node, nor its subtree, require any transformation, so we can simply // reuse the node and its subtree and avoid a costly walk return node; } } function visitorWorker(node: Node) { switch (node.kind) { case SyntaxKind.BinaryExpression: return visitBinaryExpression(<BinaryExpression>node); ... default: return visitEachChild(node, visitor); } } function visitBinaryExpression(node: BinaryExpression) { if (node.operatorToken.kind === SyntaxKind.AsteriskAsteriskToken) { return createCall( createPropertyAccess(createIdentifier("Math"), "pow"), [ visitNode(node.left, visitor, isExpressionNode), visitNode(node.right, visitor, isExpressionNode) ] ); } else { return visitEachChild(node, visitor); } } Related Pull Requests:
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
This was referenced
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this trigger false positives for
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we don't treat
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how is 'const' has flag of
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only ES6
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsAdds the Module transformers Adds the ES6 transformer Adds the ES7 transformer Adds the JSX transformer Adds the TypeScript transformer Adds a simplified pretty printer for tree transformations Adds the transformFiles API for tree transformations
Ron Buckton (rbuckton)
added a commit
that referenced
this pull request
Adds the Transform Flags concept for tree transformations
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
ReviewersNo reviewsUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. 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. | |||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |