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>) {
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".
V8_INLINE static bool IsThisProperty(Expression* expression) {
DCHECK(expression != NULL);
......@@ -653,10 +649,6 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
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 {
return identifier == ast_value_factory()->constructor_string();
}
......
......@@ -43,30 +43,18 @@ namespace {
PreParserIdentifier GetSymbolHelper(Scanner* scanner) {
// 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, but may not be escaped (3rd switch).
switch (scanner->current_token()) {
case Token::ENUM:
return PreParserIdentifier::Enum();
case Token::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:
return PreParserIdentifier::Async();
default:
break;
}
switch (scanner->current_contextual_token()) {
case Token::PROTOTYPE:
return PreParserIdentifier::Prototype();
case Token::CONSTRUCTOR:
return PreParserIdentifier::Constructor();
case Token::NAME:
......@@ -74,15 +62,14 @@ PreParserIdentifier GetSymbolHelper(Scanner* scanner) {
default:
break;
}
if (scanner->literal_contains_escapes())
if (scanner->literal_contains_escapes()) {
return PreParserIdentifier::Default();
}
switch (scanner->current_contextual_token()) {
case Token::EVAL:
return PreParserIdentifier::Eval();
case Token::ARGUMENTS:
return PreParserIdentifier::Arguments();
case Token::UNDEFINED:
return PreParserIdentifier::Undefined();
default:
break;
}
......
......@@ -39,33 +39,9 @@ class PreParserIdentifier {
static PreParserIdentifier Arguments() {
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() {
return PreParserIdentifier(kConstructorIdentifier);
}
static PreParserIdentifier Enum() {
return PreParserIdentifier(kEnumIdentifier);
}
static PreParserIdentifier Await() {
return PreParserIdentifier(kAwaitIdentifier);
}
......@@ -79,39 +55,17 @@ class PreParserIdentifier {
bool IsEval() const { return type_ == kEvalIdentifier; }
bool IsArguments() const { return type_ == kArgumentsIdentifier; }
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 IsEnum() const { return type_ == kEnumIdentifier; }
bool IsAwait() const { return type_ == kAwaitIdentifier; }
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:
enum Type {
kNullIdentifier,
kUnknownIdentifier,
kFutureReservedIdentifier,
kFutureStrictReservedIdentifier,
kLetIdentifier,
kStaticIdentifier,
kYieldIdentifier,
kEvalIdentifier,
kArgumentsIdentifier,
kUndefinedIdentifier,
kPrototypeIdentifier,
kConstructorIdentifier,
kEnumIdentifier,
kAwaitIdentifier,
kAsyncIdentifier,
kNameIdentifier
......@@ -1051,7 +1005,6 @@ class PreParser : public ParserBase<PreParser> {
V8_INLINE ZoneList<const AstRawString*>* DeclareLabel(
ZoneList<const AstRawString*>* labels, PreParserExpression expr,
bool* ok) {
DCHECK(!expr.AsIdentifier().IsEnum());
DCHECK(!parsing_module_ || !expr.AsIdentifier().IsAwait());
DCHECK(IsIdentifier(expr));
return labels;
......@@ -1224,10 +1177,6 @@ class PreParser : public ParserBase<PreParser> {
return identifier.IsEvalOrArguments();
}
V8_INLINE bool IsUndefined(PreParserIdentifier identifier) const {
return identifier.IsUndefined();
}
V8_INLINE bool IsAwait(PreParserIdentifier identifier) const {
return identifier.IsAwait();
}
......@@ -1251,10 +1200,6 @@ class PreParser : public ParserBase<PreParser> {
return expression;
}
V8_INLINE bool IsPrototype(PreParserIdentifier identifier) const {
return identifier.IsPrototype();
}
V8_INLINE bool IsConstructor(PreParserIdentifier identifier) const {
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