Remove ConstantValue flag, comment cleanup.

This commit is contained in:
Ron Buckton 2016-09-28 18:57:17 -07:00
parent deae9f211b
commit f03be92e7d
4 changed files with 12 additions and 10 deletions

View File

@ -413,7 +413,7 @@ const _super = (function (geti, seti) {
*
* NOTE: Do not call this method directly. It is part of the emit pipeline
* and should only be called indirectly from pipelineEmitWithSourceMap or
* pipelineEmitInUnspecifiedContext (when pickign a more specific context).
* pipelineEmitInUnspecifiedContext (when picking a more specific context).
*/
function pipelineEmitWithSubstitution(emitContext: EmitContext, node: Node) {
emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext);
@ -1172,7 +1172,7 @@ const _super = (function (geti, seti) {
const text = getLiteralTextOfNode(<LiteralExpression>expression);
return text.indexOf(tokenToString(SyntaxKind.DotToken)) < 0;
}
else {
else if (isPropertyAccessExpression(expression) || isElementAccessExpression(expression)) {
// check if constant enum value is integer
const constantValue = getConstantValue(expression);
// isFinite handles cases when constantValue is undefined

View File

@ -2798,17 +2798,20 @@ namespace ts {
return tokenSourceMapRanges && tokenSourceMapRanges[token];
}
export function getConstantValue(node: Node) {
/**
* Gets the constant value to emit for an expression.
*/
export function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression) {
const emitNode = node.emitNode;
if (emitNode && emitNode.flags & EmitFlags.ConstantValue) {
return emitNode.constantValue;
}
return emitNode && emitNode.constantValue;
}
export function setConstantValue(node: Node, value: number) {
/**
* Sets the constant value to emit for an expression.
*/
export function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number) {
const emitNode = getOrCreateEmitNode(node);
emitNode.constantValue = value;
emitNode.flags |= EmitFlags.ConstantValue;
return node;
}

View File

@ -348,7 +348,7 @@ namespace ts {
}
/**
* Emits a token of a node node with possible leading and trailing source maps.
* Emits a token of a node with possible leading and trailing source maps.
*
* @param node The node containing the token.
* @param token The token to emit.

View File

@ -3205,7 +3205,6 @@ namespace ts {
AsyncFunctionBody = 1 << 21,
ReuseTempVariableScope = 1 << 22, // Reuse the existing temp variable scope during emit.
CustomPrologue = 1 << 23, // Treat the statement as if it were a prologue directive (NOTE: Prologue directives are *not* transformed).
ConstantValue = 1 << 24, // The node was replaced with a constant value during substitution.
}
/* @internal */