mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 20:14:01 -06:00
Add comment and address PR on comment
This commit is contained in:
parent
788f222059
commit
bfaa51b4e9
@ -2515,7 +2515,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
let leftHandSideExpression = node.left;
|
||||
if (node.operatorToken.kind === SyntaxKind.AsteriskAsteriskEqualsToken) {
|
||||
let synthesizedLHS: ElementAccessExpression | PropertyAccessExpression;
|
||||
// TODO (yuisu) : comment
|
||||
|
||||
// This is used to decide whether to emit parenthesis around the expresison.
|
||||
// Parenthesis is required for following cases:
|
||||
// capture variable while emitting right-hand side operand.
|
||||
// a[0] **= a[0] **= 2
|
||||
// _a = a, _a[0] = Math.pow(_a[0], (_b = a, _b[0] = Math.pow(_b[0], 2)));
|
||||
// ^ -> required extra parenthesis controlled by shouldEmitParenthesis
|
||||
// exponentiation compount in variable declaration
|
||||
// var x = a[0] **= a[0] **= 2
|
||||
// var x = (_a = a, _a[0] = Math.pow(_a[0], (_b = a, _b[0] = Math.pow(_b[0], 2))));
|
||||
// ^ -> required extra parenthesis controlled by shouldEmitParenthesis
|
||||
// Otherwise, false
|
||||
let shouldEmitParenthesis = false;
|
||||
|
||||
if (isElementAccessExpression(leftHandSideExpression)) {
|
||||
|
||||
@ -3015,8 +3015,8 @@ namespace ts {
|
||||
let newPrecedence = getBinaryOperatorPrecedence();
|
||||
|
||||
// Check the precedence to see if we should "take" this operator
|
||||
// - For left associative operator (all operator but **), only consume the operator
|
||||
// , recursively call the function below and parse binaryExpression as a rightOperand
|
||||
// - For left associative operator (all operator but **), consume the operator,
|
||||
// recursively call the function below, and parse binaryExpression as a rightOperand
|
||||
// of the caller if the new precendence of the operator is greater then or equal to the current precendence.
|
||||
// For example:
|
||||
// a - b - c;
|
||||
@ -3025,7 +3025,7 @@ namespace ts {
|
||||
// ^token; leftOperand = b. Return b to the caller as a rightOperand
|
||||
// a - b * c;
|
||||
// ^token; leftOperand = b. Return b * c to the caller as a rightOperand
|
||||
// - For right associative operator (**), only consume the operator, recursively call the function
|
||||
// - For right associative operator (**), consume the operator, recursively call the function
|
||||
// and parse binaryExpression as a rightOperand of the caller if the new precendence of
|
||||
// the operator is strictly grater than the current precendence
|
||||
// For example:
|
||||
@ -3187,33 +3187,6 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current token can possibly be in an ES7 increment expression.
|
||||
*
|
||||
* Increment Expression:
|
||||
* LeftHandSideExpression[?Yield]
|
||||
* LeftHandSideExpression[?Yield][no LineTerminator here]++
|
||||
* LeftHandSideExpression[?Yield][no LineTerminator here]--
|
||||
* ++LeftHandSideExpression[?Yield]
|
||||
* --LeftHandSideExpression[?Yield]
|
||||
*/
|
||||
function isIncrementExpression(): boolean{
|
||||
// TODO(yuisu): Comment why we have to do what are we doing here
|
||||
switch (token) {
|
||||
case SyntaxKind.PlusToken:
|
||||
case SyntaxKind.MinusToken:
|
||||
case SyntaxKind.TildeToken:
|
||||
case SyntaxKind.ExclamationToken:
|
||||
case SyntaxKind.DeleteKeyword:
|
||||
case SyntaxKind.TypeOfKeyword:
|
||||
case SyntaxKind.VoidKeyword:
|
||||
case SyntaxKind.LessThanToken:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse ES7 unary expression and await expression
|
||||
*
|
||||
@ -3241,9 +3214,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse ES7 simple-unary expression or higher:
|
||||
* Parse ES7 simple-unary expression or higher:
|
||||
*
|
||||
* SimpleUnaryExpression:
|
||||
* ES7 SimpleUnaryExpression:
|
||||
* 1) IncrementExpression[?yield]
|
||||
* 2) delete UnaryExpression[?yield]
|
||||
* 3) void UnaryExpression[?yield]
|
||||
@ -3283,9 +3256,37 @@ namespace ts {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse ES7 IncrementExpression. The IncrementExpression is used instead of ES6's PostFixExpression.
|
||||
* Check if the current token can possibly be an ES7 increment expression.
|
||||
*
|
||||
* IncrementExpression[yield]:
|
||||
* ES7 IncrementExpression:
|
||||
* LeftHandSideExpression[?Yield]
|
||||
* LeftHandSideExpression[?Yield][no LineTerminator here]++
|
||||
* LeftHandSideExpression[?Yield][no LineTerminator here]--
|
||||
* ++LeftHandSideExpression[?Yield]
|
||||
* --LeftHandSideExpression[?Yield]
|
||||
*/
|
||||
function isIncrementExpression(): boolean{
|
||||
// This function is called inside parseUnaryExpression to decide
|
||||
// whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly
|
||||
switch (token) {
|
||||
case SyntaxKind.PlusToken:
|
||||
case SyntaxKind.MinusToken:
|
||||
case SyntaxKind.TildeToken:
|
||||
case SyntaxKind.ExclamationToken:
|
||||
case SyntaxKind.DeleteKeyword:
|
||||
case SyntaxKind.TypeOfKeyword:
|
||||
case SyntaxKind.VoidKeyword:
|
||||
case SyntaxKind.LessThanToken:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse ES7 IncrementExpression. IncrementExpression is used instead of ES6's PostFixExpression.
|
||||
*
|
||||
* ES7 IncrementExpression[yield]:
|
||||
* 1) LeftHandSideExpression[?yield]
|
||||
* 2) LeftHandSideExpression[?yield] [[no LineTerminator here]]++
|
||||
* 3) LeftHandSideExpression[?yield] [[no LineTerminator here]]--
|
||||
|
||||
@ -711,11 +711,10 @@ namespace ts {
|
||||
export interface IncrementExpression extends UnaryExpression {
|
||||
_incrementExpressionBrand: any;
|
||||
}
|
||||
//export type IncrementExpression = PrefixUnaryExpression | PostfixUnaryExpression | LeftHandSideExpression;
|
||||
|
||||
export interface PrefixUnaryExpression extends IncrementExpression {
|
||||
operator: SyntaxKind;
|
||||
operand: UnaryExpression | BinaryExpression;
|
||||
operand: UnaryExpression;
|
||||
}
|
||||
|
||||
export interface PostfixUnaryExpression extends IncrementExpression {
|
||||
@ -740,19 +739,19 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface DeleteExpression extends UnaryExpression {
|
||||
expression: UnaryExpression | BinaryExpression;
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
|
||||
export interface TypeOfExpression extends UnaryExpression {
|
||||
expression: UnaryExpression | BinaryExpression;
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
|
||||
export interface VoidExpression extends UnaryExpression {
|
||||
expression: UnaryExpression | BinaryExpression;
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
|
||||
export interface AwaitExpression extends UnaryExpression {
|
||||
expression: UnaryExpression | BinaryExpression;
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
|
||||
export interface YieldExpression extends Expression {
|
||||
@ -859,7 +858,7 @@ namespace ts {
|
||||
|
||||
export interface TypeAssertion extends UnaryExpression {
|
||||
type: TypeNode;
|
||||
expression: UnaryExpression | BinaryExpression;
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
|
||||
export type AssertionExpression = TypeAssertion | AsExpression;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user