refactor: remove inClassProperty parser state (#10906)

This commit is contained in:
Huáng Jùnliàng 2019-12-24 05:43:39 -05:00 committed by Nicolò Ribaudo
parent c09664f35d
commit a18166d2a9
3 changed files with 1 additions and 11 deletions

View File

@ -1389,7 +1389,7 @@ export default class ExpressionParser extends LValParser {
if (this.eat(tt.dot)) {
const metaProp = this.parseMetaProperty(node, meta, "target");
if (!this.scope.inNonArrowFunction && !this.state.inClassProperty) {
if (!this.scope.inNonArrowFunction && !this.scope.inClass) {
let error = "new.target can only be used in functions";
if (this.hasPlugin("classProperties")) {

View File

@ -1048,11 +1048,9 @@ export default class StatementParser extends ExpressionParser {
}
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
const oldInClassProperty = this.state.inClassProperty;
const oldYieldPos = this.state.yieldPos;
const oldAwaitPos = this.state.awaitPos;
this.state.maybeInArrowParameters = false;
this.state.inClassProperty = false;
this.state.yieldPos = -1;
this.state.awaitPos = -1;
this.scope.enter(functionFlags(node.async, node.generator));
@ -1084,7 +1082,6 @@ export default class StatementParser extends ExpressionParser {
}
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
this.state.inClassProperty = oldInClassProperty;
this.state.yieldPos = oldYieldPos;
this.state.awaitPos = oldAwaitPos;
@ -1575,13 +1572,10 @@ export default class StatementParser extends ExpressionParser {
parseClassPrivateProperty(
node: N.ClassPrivateProperty,
): N.ClassPrivateProperty {
this.state.inClassProperty = true;
this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);
node.value = this.eat(tt.eq) ? this.parseMaybeAssign() : null;
this.semicolon();
this.state.inClassProperty = false;
this.scope.exit();
@ -1593,8 +1587,6 @@ export default class StatementParser extends ExpressionParser {
this.expectPlugin("classProperties");
}
this.state.inClassProperty = true;
this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);
if (this.match(tt.eq)) {
@ -1605,7 +1597,6 @@ export default class StatementParser extends ExpressionParser {
node.value = null;
}
this.semicolon();
this.state.inClassProperty = false;
this.scope.exit();

View File

@ -64,7 +64,6 @@ export default class State {
inType: boolean = false;
noAnonFunctionType: boolean = false;
inPropertyName: boolean = false;
inClassProperty: boolean = false;
hasFlowComment: boolean = false;
isIterator: boolean = false;