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

Unified Diff: src/parsing/preparser.cc

Issue 2179423002: [parser] Refactor parser and preparser traits (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: More changes after reviewers' comments Created 4 years, 4 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/parsing/preparser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/preparser.cc
diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc
index ae141f7076f9866d93666439de90262707325f6c..e6424d8370288adc4c3a9e017f25695c02099921 100644
--- a/src/parsing/preparser.cc
+++ b/src/parsing/preparser.cc
@@ -45,15 +45,15 @@ void PreParserTraits::ReportMessageAt(Scanner::Location location,
MessageTemplate::Template message,
const char* arg,
ParseErrorType error_type) {
- ReportMessageAt(location.beg_pos, location.end_pos, message, arg, error_type);
+ pre_parser_->log_->LogMessage(location.beg_pos, location.end_pos, message,
+ arg, error_type);
}
-
-void PreParserTraits::ReportMessageAt(int start_pos, int end_pos,
+void PreParserTraits::ReportMessageAt(Scanner::Location location,
MessageTemplate::Template message,
- const char* arg,
+ const AstRawString* arg,
ParseErrorType error_type) {
- pre_parser_->log_->LogMessage(start_pos, end_pos, message, arg, error_type);
+ UNREACHABLE();
}
@@ -93,11 +93,6 @@ PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) {
}
-PreParserIdentifier PreParserTraits::GetNumberAsSymbol(Scanner* scanner) {
- return PreParserIdentifier::Default();
-}
-
-
PreParserExpression PreParserTraits::ExpressionFromString(
int pos, Scanner* scanner, PreParserFactory* factory) {
if (scanner->UnescapedLiteralMatches("use strict", 10)) {
@@ -262,9 +257,9 @@ void PreParser::ParseStatementList(int end_token, bool* ok,
// TC39 deemed "use strict" directives to be an error when occurring
// in the body of a function with non-simple parameter list, on
// 29/7/2015. https://goo.gl/ueA7Ln
- PreParserTraits::ReportMessageAt(
- token_loc, MessageTemplate::kIllegalLanguageModeDirective,
- "use strict");
+ ReportMessageAt(token_loc,
+ MessageTemplate::kIllegalLanguageModeDirective,
+ "use strict");
*ok = false;
return;
}
@@ -589,7 +584,7 @@ PreParser::Statement PreParser::ParseVariableDeclarations(
}
} else if ((require_initializer || is_pattern) &&
(var_context != kForStatement || !PeekInOrOf())) {
- PreParserTraits::ReportMessageAt(
+ ReportMessageAt(
Scanner::Location(decl_pos, scanner()->location().end_pos),
MessageTemplate::kDeclarationMissingInitializer,
is_pattern ? "destructuring" : "const");
@@ -616,8 +611,8 @@ PreParser::Statement PreParser::ParseFunctionDeclaration(bool* ok) {
if (Check(Token::MUL)) {
flags |= ParseFunctionFlags::kIsGenerator;
if (allow_harmony_restrictive_declarations()) {
- PreParserTraits::ReportMessageAt(
- scanner()->location(), MessageTemplate::kGeneratorInLegacyContext);
+ ReportMessageAt(scanner()->location(),
+ MessageTemplate::kGeneratorInLegacyContext);
*ok = false;
return Statement::Default();
}
@@ -884,9 +879,9 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
if (CheckInOrOf(&mode, ok)) {
if (!*ok) return Statement::Default();
if (decl_count != 1) {
- PreParserTraits::ReportMessageAt(
- bindings_loc, MessageTemplate::kForInOfLoopMultiBindings,
- ForEachStatement::VisitModeString(mode));
+ ReportMessageAt(bindings_loc,
+ MessageTemplate::kForInOfLoopMultiBindings,
+ ForEachStatement::VisitModeString(mode));
*ok = false;
return Statement::Default();
}
@@ -898,9 +893,9 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
if (use_counts_ != nullptr && allow_harmony_for_in()) {
++use_counts_[v8::Isolate::kForInInitializer];
}
- PreParserTraits::ReportMessageAt(
- first_initializer_loc, MessageTemplate::kForInOfLoopInitializer,
- ForEachStatement::VisitModeString(mode));
+ ReportMessageAt(first_initializer_loc,
+ MessageTemplate::kForInOfLoopInitializer,
+ ForEachStatement::VisitModeString(mode));
*ok = false;
return Statement::Default();
}
« no previous file with comments | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698