Skip to content

Commit

Permalink
Remove DestructuringAssignment and Generator flags
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton committed Mar 6, 2019
1 parent cc9e2f4 commit 1f212ec
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 36 deletions.
17 changes: 1 addition & 16 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3189,7 +3189,6 @@ namespace ts {
let transformFlags = subtreeFlags;
const expression = node.expression;
const expressionKind = expression.kind;
const expressionTransformFlags = expression.transformFlags;

// If the node is synthesized, it means the emitter put the parentheses there,
// not the user. If we didn't want them, the emitter would not have put them
Expand All @@ -3199,12 +3198,6 @@ namespace ts {
transformFlags |= TransformFlags.AssertTypeScript;
}

// If the expression of a ParenthesizedExpression is a destructuring assignment,
// then the ParenthesizedExpression is a destructuring assignment.
if (expressionTransformFlags & TransformFlags.DestructuringAssignment) {
transformFlags |= TransformFlags.DestructuringAssignment;
}

node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
return transformFlags & ~TransformFlags.OuterExpressionExcludes;
}
Expand Down Expand Up @@ -3585,15 +3578,7 @@ namespace ts {
}

function computeExpressionStatement(node: ExpressionStatement, subtreeFlags: TransformFlags) {
let transformFlags = subtreeFlags;

// If the expression of an expression statement is a destructuring assignment,
// then we treat the statement as ES6 so that we can indicate that we do not
// need to hold on to the right-hand side.
if (node.expression.transformFlags & TransformFlags.DestructuringAssignment) {
transformFlags |= TransformFlags.AssertES2015;
}

const transformFlags = subtreeFlags;
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
return transformFlags & ~TransformFlags.NodeExcludes;
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/transformers/generators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ namespace ts {
else if (inGeneratorFunctionBody) {
return visitJavaScriptInGeneratorFunctionBody(node);
}
else if (transformFlags & TransformFlags.Generator) {
else if (isFunctionLikeDeclaration(node) && node.asteriskToken) {
return visitGenerator(node);
}
else if (transformFlags & TransformFlags.ContainsGenerator) {
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/transformers/module/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,8 @@ namespace ts {
if (isImportCall(node)) {
return visitImportCallExpression(node);
}
else if (node.transformFlags & TransformFlags.DestructuringAssignment && isBinaryExpression(node)) {
return visitDestructuringAssignment(node as DestructuringAssignment);
else if (isDestructuringAssignment(node)) {
return visitDestructuringAssignment(node);
}
else {
return visitEachChild(node, moduleExpressionElementVisitor, context);
Expand Down
5 changes: 2 additions & 3 deletions src/compiler/transformers/module/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1463,9 +1463,8 @@ namespace ts {
* @param node The node to visit.
*/
function destructuringAndImportCallVisitor(node: Node): VisitResult<Node> {
if (node.transformFlags & TransformFlags.DestructuringAssignment
&& node.kind === SyntaxKind.BinaryExpression) {
return visitDestructuringAssignment(<DestructuringAssignment>node);
if (isDestructuringAssignment(node)) {
return visitDestructuringAssignment(node);
}
else if (isImportCall(node)) {
return visitImportCallExpression(node);
Expand Down
27 changes: 13 additions & 14 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5049,21 +5049,20 @@ namespace ts {
ContainsES2016 = 1 << 5,
ContainsES2015 = 1 << 6,
ContainsGenerator = 1 << 7,
DestructuringAssignment = 1 << 8,
ContainsDestructuringAssignment = 1 << 9,
ContainsDestructuringAssignment = 1 << 8,

// Markers
// - Flags used to indicate that a subtree contains a specific transformation.
ContainsTypeScriptClassSyntax = 1 << 10, // Decorators, Property Initializers, Parameter Property Initializers
ContainsLexicalThis = 1 << 11,
ContainsRestOrSpread = 1 << 12,
ContainsObjectRestOrSpread = 1 << 13,
ContainsComputedPropertyName = 1 << 14,
ContainsBlockScopedBinding = 1 << 15,
ContainsBindingPattern = 1 << 16,
ContainsYield = 1 << 17,
ContainsHoistedDeclarationOrCompletion = 1 << 18,
ContainsDynamicImport = 1 << 19,
ContainsTypeScriptClassSyntax = 1 << 9, // Decorators, Property Initializers, Parameter Property Initializers
ContainsLexicalThis = 1 << 10,
ContainsRestOrSpread = 1 << 11,
ContainsObjectRestOrSpread = 1 << 12,
ContainsComputedPropertyName = 1 << 13,
ContainsBlockScopedBinding = 1 << 14,
ContainsBindingPattern = 1 << 15,
ContainsYield = 1 << 16,
ContainsHoistedDeclarationOrCompletion = 1 << 17,
ContainsDynamicImport = 1 << 18,

// Please leave this as 1 << 29.
// It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
Expand All @@ -5080,12 +5079,12 @@ namespace ts {
AssertES2016 = ContainsES2016,
AssertES2015 = ContainsES2015,
AssertGenerator = ContainsGenerator,
AssertDestructuringAssignment = DestructuringAssignment | ContainsDestructuringAssignment,
AssertDestructuringAssignment = ContainsDestructuringAssignment,

// Scope Exclusions
// - Bitmasks that exclude flags from propagating out of a specific context
// into the subtree flags of their container.
OuterExpressionExcludes = DestructuringAssignment | HasComputedFlags,
OuterExpressionExcludes = HasComputedFlags,
PropertyAccessExcludes = OuterExpressionExcludes,
NodeExcludes = PropertyAccessExcludes,
ArrowFunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread,
Expand Down

0 comments on commit 1f212ec

Please sign in to comment.