Commit 000ef276 authored by Adam Klein's avatar Adam Klein Committed by Commit Bot

[parser] Remove unused PreParserIdentifier types and support code

Also remove a few bits of related dead code in Parser.

Bug: v8:6092
Change-Id: I310936341fe3e6193e36983723985a190d5d278b
Reviewed-on: https://chromium-review.googlesource.com/621958
Commit-Queue: Adam Klein <adamk@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47518}
parent 43c60aeb
...@@ -622,10 +622,6 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) { ...@@ -622,10 +622,6 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
return IsEval(identifier) || IsArguments(identifier); return IsEval(identifier) || IsArguments(identifier);
} }
V8_INLINE bool IsUndefined(const AstRawString* identifier) const {
return identifier == ast_value_factory()->undefined_string();
}
// Returns true if the expression is of type "this.foo". // Returns true if the expression is of type "this.foo".
V8_INLINE static bool IsThisProperty(Expression* expression) { V8_INLINE static bool IsThisProperty(Expression* expression) {
DCHECK(expression != NULL); DCHECK(expression != NULL);
...@@ -653,10 +649,6 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) { ...@@ -653,10 +649,6 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
return expression->AsVariableProxy(); return expression->AsVariableProxy();
} }
V8_INLINE bool IsPrototype(const AstRawString* identifier) const {
return identifier == ast_value_factory()->prototype_string();
}
V8_INLINE bool IsConstructor(const AstRawString* identifier) const { V8_INLINE bool IsConstructor(const AstRawString* identifier) const {
return identifier == ast_value_factory()->constructor_string(); return identifier == ast_value_factory()->constructor_string();
} }
......
...@@ -43,30 +43,18 @@ namespace { ...@@ -43,30 +43,18 @@ namespace {
PreParserIdentifier GetSymbolHelper(Scanner* scanner) { PreParserIdentifier GetSymbolHelper(Scanner* scanner) {
// These symbols require slightly different treatement: // These symbols require slightly different treatement:
// - regular keywords (enum, await, etc.; treated in 1st switch.) // - regular keywords (async, await, etc.; treated in 1st switch.)
// - 'contextual' keywords (and may contain escaped; treated in 2nd switch.) // - 'contextual' keywords (and may contain escaped; treated in 2nd switch.)
// - 'contextual' keywords, but may not be escaped (3rd switch). // - 'contextual' keywords, but may not be escaped (3rd switch).
switch (scanner->current_token()) { switch (scanner->current_token()) {
case Token::ENUM:
return PreParserIdentifier::Enum();
case Token::AWAIT: case Token::AWAIT:
return PreParserIdentifier::Await(); return PreParserIdentifier::Await();
case Token::FUTURE_STRICT_RESERVED_WORD:
return PreParserIdentifier::FutureStrictReserved();
case Token::LET:
return PreParserIdentifier::Let();
case Token::STATIC:
return PreParserIdentifier::Static();
case Token::YIELD:
return PreParserIdentifier::Yield();
case Token::ASYNC: case Token::ASYNC:
return PreParserIdentifier::Async(); return PreParserIdentifier::Async();
default: default:
break; break;
} }
switch (scanner->current_contextual_token()) { switch (scanner->current_contextual_token()) {
case Token::PROTOTYPE:
return PreParserIdentifier::Prototype();
case Token::CONSTRUCTOR: case Token::CONSTRUCTOR:
return PreParserIdentifier::Constructor(); return PreParserIdentifier::Constructor();
case Token::NAME: case Token::NAME:
...@@ -74,15 +62,14 @@ PreParserIdentifier GetSymbolHelper(Scanner* scanner) { ...@@ -74,15 +62,14 @@ PreParserIdentifier GetSymbolHelper(Scanner* scanner) {
default: default:
break; break;
} }
if (scanner->literal_contains_escapes()) if (scanner->literal_contains_escapes()) {
return PreParserIdentifier::Default(); return PreParserIdentifier::Default();
}
switch (scanner->current_contextual_token()) { switch (scanner->current_contextual_token()) {
case Token::EVAL: case Token::EVAL:
return PreParserIdentifier::Eval(); return PreParserIdentifier::Eval();
case Token::ARGUMENTS: case Token::ARGUMENTS:
return PreParserIdentifier::Arguments(); return PreParserIdentifier::Arguments();
case Token::UNDEFINED:
return PreParserIdentifier::Undefined();
default: default:
break; break;
} }
......
...@@ -39,33 +39,9 @@ class PreParserIdentifier { ...@@ -39,33 +39,9 @@ class PreParserIdentifier {
static PreParserIdentifier Arguments() { static PreParserIdentifier Arguments() {
return PreParserIdentifier(kArgumentsIdentifier); return PreParserIdentifier(kArgumentsIdentifier);
} }
static PreParserIdentifier Undefined() {
return PreParserIdentifier(kUndefinedIdentifier);
}
static PreParserIdentifier FutureReserved() {
return PreParserIdentifier(kFutureReservedIdentifier);
}
static PreParserIdentifier FutureStrictReserved() {
return PreParserIdentifier(kFutureStrictReservedIdentifier);
}
static PreParserIdentifier Let() {
return PreParserIdentifier(kLetIdentifier);
}
static PreParserIdentifier Static() {
return PreParserIdentifier(kStaticIdentifier);
}
static PreParserIdentifier Yield() {
return PreParserIdentifier(kYieldIdentifier);
}
static PreParserIdentifier Prototype() {
return PreParserIdentifier(kPrototypeIdentifier);
}
static PreParserIdentifier Constructor() { static PreParserIdentifier Constructor() {
return PreParserIdentifier(kConstructorIdentifier); return PreParserIdentifier(kConstructorIdentifier);
} }
static PreParserIdentifier Enum() {
return PreParserIdentifier(kEnumIdentifier);
}
static PreParserIdentifier Await() { static PreParserIdentifier Await() {
return PreParserIdentifier(kAwaitIdentifier); return PreParserIdentifier(kAwaitIdentifier);
} }
...@@ -79,39 +55,17 @@ class PreParserIdentifier { ...@@ -79,39 +55,17 @@ class PreParserIdentifier {
bool IsEval() const { return type_ == kEvalIdentifier; } bool IsEval() const { return type_ == kEvalIdentifier; }
bool IsArguments() const { return type_ == kArgumentsIdentifier; } bool IsArguments() const { return type_ == kArgumentsIdentifier; }
bool IsEvalOrArguments() const { return IsEval() || IsArguments(); } bool IsEvalOrArguments() const { return IsEval() || IsArguments(); }
bool IsUndefined() const { return type_ == kUndefinedIdentifier; }
bool IsLet() const { return type_ == kLetIdentifier; }
bool IsStatic() const { return type_ == kStaticIdentifier; }
bool IsYield() const { return type_ == kYieldIdentifier; }
bool IsPrototype() const { return type_ == kPrototypeIdentifier; }
bool IsConstructor() const { return type_ == kConstructorIdentifier; } bool IsConstructor() const { return type_ == kConstructorIdentifier; }
bool IsEnum() const { return type_ == kEnumIdentifier; }
bool IsAwait() const { return type_ == kAwaitIdentifier; } bool IsAwait() const { return type_ == kAwaitIdentifier; }
bool IsName() const { return type_ == kNameIdentifier; } bool IsName() const { return type_ == kNameIdentifier; }
// Allow identifier->name()[->length()] to work. The preparser
// does not need the actual positions/lengths of the identifiers.
const PreParserIdentifier* operator->() const { return this; }
const PreParserIdentifier raw_name() const { return *this; }
int position() const { return 0; }
int length() const { return 0; }
private: private:
enum Type { enum Type {
kNullIdentifier, kNullIdentifier,
kUnknownIdentifier, kUnknownIdentifier,
kFutureReservedIdentifier,
kFutureStrictReservedIdentifier,
kLetIdentifier,
kStaticIdentifier,
kYieldIdentifier,
kEvalIdentifier, kEvalIdentifier,
kArgumentsIdentifier, kArgumentsIdentifier,
kUndefinedIdentifier,
kPrototypeIdentifier,
kConstructorIdentifier, kConstructorIdentifier,
kEnumIdentifier,
kAwaitIdentifier, kAwaitIdentifier,
kAsyncIdentifier, kAsyncIdentifier,
kNameIdentifier kNameIdentifier
...@@ -1051,7 +1005,6 @@ class PreParser : public ParserBase<PreParser> { ...@@ -1051,7 +1005,6 @@ class PreParser : public ParserBase<PreParser> {
V8_INLINE ZoneList<const AstRawString*>* DeclareLabel( V8_INLINE ZoneList<const AstRawString*>* DeclareLabel(
ZoneList<const AstRawString*>* labels, PreParserExpression expr, ZoneList<const AstRawString*>* labels, PreParserExpression expr,
bool* ok) { bool* ok) {
DCHECK(!expr.AsIdentifier().IsEnum());
DCHECK(!parsing_module_ || !expr.AsIdentifier().IsAwait()); DCHECK(!parsing_module_ || !expr.AsIdentifier().IsAwait());
DCHECK(IsIdentifier(expr)); DCHECK(IsIdentifier(expr));
return labels; return labels;
...@@ -1224,10 +1177,6 @@ class PreParser : public ParserBase<PreParser> { ...@@ -1224,10 +1177,6 @@ class PreParser : public ParserBase<PreParser> {
return identifier.IsEvalOrArguments(); return identifier.IsEvalOrArguments();
} }
V8_INLINE bool IsUndefined(PreParserIdentifier identifier) const {
return identifier.IsUndefined();
}
V8_INLINE bool IsAwait(PreParserIdentifier identifier) const { V8_INLINE bool IsAwait(PreParserIdentifier identifier) const {
return identifier.IsAwait(); return identifier.IsAwait();
} }
...@@ -1251,10 +1200,6 @@ class PreParser : public ParserBase<PreParser> { ...@@ -1251,10 +1200,6 @@ class PreParser : public ParserBase<PreParser> {
return expression; return expression;
} }
V8_INLINE bool IsPrototype(PreParserIdentifier identifier) const {
return identifier.IsPrototype();
}
V8_INLINE bool IsConstructor(PreParserIdentifier identifier) const { V8_INLINE bool IsConstructor(PreParserIdentifier identifier) const {
return identifier.IsConstructor(); return identifier.IsConstructor();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment