Renaming parsing context flags to NodeFlags.xxxContext

This commit is contained in:
Anders Hejlsberg
2016-01-31 08:57:32 -08:00
parent 83859c0d91
commit f4ee49f24e
3 changed files with 27 additions and 27 deletions

View File

@@ -7183,7 +7183,7 @@ namespace ts {
}
}
if (node.parserContextFlags & NodeFlags.Await) {
if (node.parserContextFlags & NodeFlags.AwaitContext) {
getNodeLinks(container).flags |= NodeCheckFlags.CaptureArguments;
}
}
@@ -10783,7 +10783,7 @@ namespace ts {
function checkAwaitExpression(node: AwaitExpression): Type {
// Grammar checking
if (produceDiagnostics) {
if (!(node.parserContextFlags & NodeFlags.Await)) {
if (!(node.parserContextFlags & NodeFlags.AwaitContext)) {
grammarErrorOnFirstToken(node, Diagnostics.await_expression_is_only_allowed_within_an_async_function);
}
@@ -11239,7 +11239,7 @@ namespace ts {
function checkYieldExpression(node: YieldExpression): Type {
// Grammar checking
if (produceDiagnostics) {
if (!(node.parserContextFlags & NodeFlags.Yield) || isYieldExpressionInClass(node)) {
if (!(node.parserContextFlags & NodeFlags.YieldContext) || isYieldExpressionInClass(node)) {
grammarErrorOnFirstToken(node, Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
}
@@ -13701,7 +13701,7 @@ namespace ts {
function checkWithStatement(node: WithStatement) {
// Grammar checking for withStatement
if (!checkGrammarStatementInAmbientContext(node)) {
if (node.parserContextFlags & NodeFlags.Await) {
if (node.parserContextFlags & NodeFlags.AwaitContext) {
grammarErrorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_an_async_function_block);
}
}

View File

@@ -438,7 +438,7 @@ namespace ts {
// Share a single scanner across all calls to parse a source file. This helps speed things
// up by avoiding the cost of creating/compiling scanners over and over again.
const scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true);
const disallowInAndDecoratorContext = NodeFlags.DisallowIn | NodeFlags.Decorator;
const disallowInAndDecoratorContext = NodeFlags.DisallowInContext | NodeFlags.DecoratorContext;
// capture constructors in 'initializeState' to avoid null checks
let NodeConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node;
@@ -682,19 +682,19 @@ namespace ts {
}
function setDisallowInContext(val: boolean) {
setContextFlag(val, NodeFlags.DisallowIn);
setContextFlag(val, NodeFlags.DisallowInContext);
}
function setYieldContext(val: boolean) {
setContextFlag(val, NodeFlags.Yield);
setContextFlag(val, NodeFlags.YieldContext);
}
function setDecoratorContext(val: boolean) {
setContextFlag(val, NodeFlags.Decorator);
setContextFlag(val, NodeFlags.DecoratorContext);
}
function setAwaitContext(val: boolean) {
setContextFlag(val, NodeFlags.Await);
setContextFlag(val, NodeFlags.AwaitContext);
}
function doOutsideOfContext<T>(context: NodeFlags, func: () => T): T {
@@ -740,31 +740,31 @@ namespace ts {
}
function allowInAnd<T>(func: () => T): T {
return doOutsideOfContext(NodeFlags.DisallowIn, func);
return doOutsideOfContext(NodeFlags.DisallowInContext, func);
}
function disallowInAnd<T>(func: () => T): T {
return doInsideOfContext(NodeFlags.DisallowIn, func);
return doInsideOfContext(NodeFlags.DisallowInContext, func);
}
function doInYieldContext<T>(func: () => T): T {
return doInsideOfContext(NodeFlags.Yield, func);
return doInsideOfContext(NodeFlags.YieldContext, func);
}
function doInDecoratorContext<T>(func: () => T): T {
return doInsideOfContext(NodeFlags.Decorator, func);
return doInsideOfContext(NodeFlags.DecoratorContext, func);
}
function doInAwaitContext<T>(func: () => T): T {
return doInsideOfContext(NodeFlags.Await, func);
return doInsideOfContext(NodeFlags.AwaitContext, func);
}
function doOutsideOfAwaitContext<T>(func: () => T): T {
return doOutsideOfContext(NodeFlags.Await, func);
return doOutsideOfContext(NodeFlags.AwaitContext, func);
}
function doInYieldAndAwaitContext<T>(func: () => T): T {
return doInsideOfContext(NodeFlags.Yield | NodeFlags.Await, func);
return doInsideOfContext(NodeFlags.YieldContext | NodeFlags.AwaitContext, func);
}
function inContext(flags: NodeFlags) {
@@ -772,19 +772,19 @@ namespace ts {
}
function inYieldContext() {
return inContext(NodeFlags.Yield);
return inContext(NodeFlags.YieldContext);
}
function inDisallowInContext() {
return inContext(NodeFlags.DisallowIn);
return inContext(NodeFlags.DisallowInContext);
}
function inDecoratorContext() {
return inContext(NodeFlags.Decorator);
return inContext(NodeFlags.DecoratorContext);
}
function inAwaitContext() {
return inContext(NodeFlags.Await);
return inContext(NodeFlags.AwaitContext);
}
function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void {
@@ -4785,7 +4785,7 @@ namespace ts {
// The checker may still error in the static case to explicitly disallow the yield expression.
property.initializer = modifiers && modifiers.flags & NodeFlags.Static
? allowInAnd(parseNonParameterInitializer)
: doOutsideOfContext(NodeFlags.Yield | NodeFlags.DisallowIn, parseNonParameterInitializer);
: doOutsideOfContext(NodeFlags.YieldContext | NodeFlags.DisallowInContext, parseNonParameterInitializer);
parseSemicolon();
return finishNode(property);

View File

@@ -393,10 +393,10 @@ namespace ts {
HasDecorators = 1 << 19, // If the file has decorators (initialized by binding)
HasParamDecorators = 1 << 20, // If the file has parameter decorators (initialized by binding)
HasAsyncFunctions = 1 << 21, // If the file has async functions (initialized by binding)
DisallowIn = 1 << 22, // If node was parsed in a context where 'in-expressions' are not allowed
Yield = 1 << 23, // If node was parsed in the 'yield' context created when parsing a generator
Decorator = 1 << 24, // If node was parsed as part of a decorator
Await = 1 << 25, // If node was parsed in the 'await' context created when parsing an async function
DisallowInContext = 1 << 22, // If node was parsed in a context where 'in-expressions' are not allowed
YieldContext = 1 << 23, // If node was parsed in the 'yield' context created when parsing a generator
DecoratorContext = 1 << 24, // If node was parsed as part of a decorator
AwaitContext = 1 << 25, // If node was parsed in the 'await' context created when parsing an async function
ThisNodeHasError = 1 << 26, // If the parser encountered an error when parsing the code that created this node
JavaScriptFile = 1 << 27, // If node was parsed in a JavaScript
ThisNodeOrAnySubNodesHasError = 1 << 28, // If this node or any of its children had an error
@@ -410,10 +410,10 @@ namespace ts {
EmitHelperFlags = HasClassExtends | HasDecorators | HasParamDecorators | HasAsyncFunctions,
// Context flags set directly by the parser.
ParserGeneratedFlags = DisallowIn | Yield | Decorator | ThisNodeHasError | Await,
ParserGeneratedFlags = DisallowInContext | YieldContext | DecoratorContext | ThisNodeHasError | AwaitContext,
// Exclude these flags when parsing a Type
TypeExcludesFlags = Yield | Await,
TypeExcludesFlags = YieldContext | AwaitContext,
}
export const enum JsxFlags {