Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(834)

Unified Diff: src/preparser.cc

Issue 918203002: Get rid of PreParserIdentifier. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: . Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/preparser.h ('k') | src/scanner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index 9e72422eb7deb1c28f824ac86937068d2eb5ddbe..c2547b724c094c2afe8ebede8f1a41c7a623a1e1 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -42,37 +42,14 @@ void PreParserTraits::ReportMessageAt(int start_pos,
}
-PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) {
- if (scanner->current_token() == Token::FUTURE_RESERVED_WORD) {
- return PreParserIdentifier::FutureReserved();
- } else if (scanner->current_token() ==
- Token::FUTURE_STRICT_RESERVED_WORD) {
- return PreParserIdentifier::FutureStrictReserved();
- } else if (scanner->current_token() == Token::LET) {
- return PreParserIdentifier::Let();
- } else if (scanner->current_token() == Token::STATIC) {
- return PreParserIdentifier::Static();
- } else if (scanner->current_token() == Token::YIELD) {
- return PreParserIdentifier::Yield();
- }
- if (scanner->UnescapedLiteralMatches("eval", 4)) {
- return PreParserIdentifier::Eval();
- }
- if (scanner->UnescapedLiteralMatches("arguments", 9)) {
- return PreParserIdentifier::Arguments();
- }
- if (scanner->LiteralMatches("prototype", 9)) {
- return PreParserIdentifier::Prototype();
- }
- if (scanner->LiteralMatches("constructor", 11)) {
- return PreParserIdentifier::Constructor();
- }
- return PreParserIdentifier::Default();
-}
-
-
-PreParserIdentifier PreParserTraits::GetNumberAsSymbol(Scanner* scanner) {
- return PreParserIdentifier::Default();
+PreParserExpression PreParserTraits::ExpressionFromIdentifier(
+ const AstRawString* name, int pos, Scope* scope,
+ PreParserFactory* factory) {
+ bool is_valid_arrow_function_param =
+ !(pre_parser_->IsEvalOrArguments(name) ||
+ pre_parser_->scanner()->IdentifierIsFutureStrictReserved(name));
+ return PreParserExpression::FromIdentifier(name,
+ is_valid_arrow_function_param);
}
@@ -93,7 +70,7 @@ PreParserExpression PreParserTraits::ParseV8Intrinsic(bool* ok) {
PreParserExpression PreParserTraits::ParseFunctionLiteral(
- PreParserIdentifier name, Scanner::Location function_name_location,
+ const AstRawString* name, Scanner::Location function_name_location,
bool name_is_strict_reserved, FunctionKind kind,
int function_token_position, FunctionLiteral::FunctionType type,
FunctionLiteral::ArityRestriction arity_restriction, bool* ok) {
@@ -135,7 +112,7 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction(
PreParserExpression PreParserTraits::ParseClassLiteral(
- PreParserIdentifier name, Scanner::Location class_name_location,
+ const AstRawString* name, Scanner::Location class_name_location,
bool name_is_strict_reserved, int pos, bool* ok) {
return pre_parser_->ParseClassLiteral(name, class_name_location,
name_is_strict_reserved, pos, ok);
@@ -339,8 +316,8 @@ PreParser::Statement PreParser::ParseFunctionDeclaration(bool* ok) {
int pos = position();
bool is_generator = Check(Token::MUL);
bool is_strict_reserved = false;
- Identifier name = ParseIdentifierOrStrictReservedWord(
- &is_strict_reserved, CHECK_OK);
+ const AstRawString* name =
+ ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK);
ParseFunctionLiteral(name, scanner()->location(), is_strict_reserved,
is_generator ? FunctionKind::kGeneratorFunction
: FunctionKind::kNormalFunction,
@@ -360,7 +337,7 @@ PreParser::Statement PreParser::ParseClassDeclaration(bool* ok) {
int pos = position();
bool is_strict_reserved = false;
- Identifier name =
+ const AstRawString* name =
ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK);
ParseClassLiteral(name, scanner()->location(), is_strict_reserved, pos,
CHECK_OK);
@@ -514,9 +491,9 @@ PreParser::Statement PreParser::ParseExpressionOrLabelledStatement(bool* ok) {
if (starts_with_identifier && expr.IsIdentifier() && peek() == Token::COLON) {
// Expression is a single identifier, and not, e.g., a parenthesized
// identifier.
- DCHECK(!expr.AsIdentifier().IsFutureReserved());
+ DCHECK(!scanner()->IdentifierIsFutureReserved(expr.AsIdentifier()));
DCHECK(is_sloppy(language_mode()) ||
- !IsFutureStrictReserved(expr.AsIdentifier()));
+ !scanner()->IdentifierIsFutureStrictReserved(expr.AsIdentifier()));
Consume(Token::COLON);
return ParseStatement(ok);
// Preparsing is disabled for extensions (because the extension details
@@ -526,7 +503,7 @@ PreParser::Statement PreParser::ParseExpressionOrLabelledStatement(bool* ok) {
// Parsed expression statement.
// Detect attempts at 'let' declarations in sloppy mode.
if (peek() == Token::IDENTIFIER && is_sloppy(language_mode()) &&
- expr.IsIdentifier() && expr.AsIdentifier().IsLet()) {
+ expr.IsIdentifier() && expr.AsIdentifier()->IsOneByteEqualTo("let")) {
ReportMessage("sloppy_lexical", NULL);
*ok = false;
return Statement::Default();
@@ -733,7 +710,7 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
} else {
Expression lhs = ParseExpression(false, CHECK_OK);
is_let_identifier_expression =
- lhs.IsIdentifier() && lhs.AsIdentifier().IsLet();
+ lhs.IsIdentifier() && lhs.AsIdentifier()->IsOneByteEqualTo("let");
if (CheckInOrOf(lhs.IsIdentifier())) {
ParseExpression(true, CHECK_OK);
Expect(Token::RPAREN, CHECK_OK);
@@ -849,7 +826,7 @@ PreParser::Statement PreParser::ParseDebuggerStatement(bool* ok) {
PreParser::Expression PreParser::ParseFunctionLiteral(
- Identifier function_name, Scanner::Location function_name_location,
+ const AstRawString* function_name, Scanner::Location function_name_location,
bool name_is_strict_reserved, FunctionKind kind, int function_token_pos,
FunctionLiteral::FunctionType function_type,
FunctionLiteral::ArityRestriction arity_restriction, bool* ok) {
@@ -885,9 +862,9 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
Consume(Token::ELLIPSIS);
}
- Identifier param_name =
+ const AstRawString* param_name =
ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK);
- if (!eval_args_error_loc.IsValid() && param_name.IsEvalOrArguments()) {
+ if (!eval_args_error_loc.IsValid() && IsEvalOrArguments(param_name)) {
eval_args_error_loc = scanner()->location();
}
if (!reserved_error_loc.IsValid() && is_strict_reserved) {
@@ -960,7 +937,7 @@ void PreParser::ParseLazyFunctionLiteralBody(bool* ok) {
PreParserExpression PreParser::ParseClassLiteral(
- PreParserIdentifier name, Scanner::Location class_name_location,
+ const AstRawString* name, Scanner::Location class_name_location,
bool name_is_strict_reserved, int pos, bool* ok) {
// All parts of a ClassDeclaration and ClassExpression are strict code.
if (name_is_strict_reserved) {
« no previous file with comments | « src/preparser.h ('k') | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698