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

Unified Diff: src/preparser.h

Issue 231073002: WIP: Parser: delay string internalization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: internalizing better Created 6 years, 7 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
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index 6733658579c0f1adc4a8b3ad418367eb80187c65..ed1d709c6770e807d967fc31b10c89d279592167 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -327,7 +327,7 @@ class ParserBase : public Traits {
Scanner::Location octal = scanner()->octal_position();
if (octal.IsValid() && beg_pos <= octal.beg_pos &&
octal.end_pos <= end_pos) {
- ReportMessageAt(octal, "strict_octal_literal");
+ this->ReportMessageAt(octal, "strict_octal_literal");
scanner()->clear_octal_position();
*ok = false;
}
@@ -348,16 +348,10 @@ class ParserBase : public Traits {
bool is_generator() const { return function_state_->is_generator(); }
// Report syntax errors.
- void ReportMessage(const char* message, Vector<const char*> args,
+ void ReportMessage(const char* message, const char* arg = NULL,
bool is_reference_error = false) {
Scanner::Location source_location = scanner()->location();
- Traits::ReportMessageAt(source_location, message, args, is_reference_error);
- }
-
- void ReportMessageAt(Scanner::Location location, const char* message,
- bool is_reference_error = false) {
- Traits::ReportMessageAt(location, message, Vector<const char*>::empty(),
- is_reference_error);
+ Traits::ReportMessageAt(source_location, message, arg, is_reference_error);
}
void ReportUnexpectedToken(Token::Value token);
@@ -369,9 +363,7 @@ class ParserBase : public Traits {
// allow_eval_or_arguments is kAllowEvalOrArguments, we allow "eval" or
// "arguments" as identifier even in strict mode (this is needed in cases like
// "var foo = eval;").
- IdentifierT ParseIdentifier(
- AllowEvalOrArgumentsAsIdentifier,
- bool* ok);
+ IdentifierT ParseIdentifier(AllowEvalOrArgumentsAsIdentifier, bool* ok);
// Parses an identifier or a strict mode future reserved word, and indicate
// whether it is strict mode future reserved.
IdentifierT ParseIdentifierOrStrictReservedWord(
@@ -968,16 +960,12 @@ class PreParserTraits {
// Reporting errors.
void ReportMessageAt(Scanner::Location location,
const char* message,
- Vector<const char*> args,
- bool is_reference_error = false);
- void ReportMessageAt(Scanner::Location location,
- const char* type,
- const char* name_opt,
+ const char* arg = NULL,
bool is_reference_error = false);
void ReportMessageAt(int start_pos,
int end_pos,
- const char* type,
- const char* name_opt,
+ const char* message,
+ const char* arg = NULL,
bool is_reference_error = false);
// "null" return type creators.
@@ -1002,8 +990,8 @@ class PreParserTraits {
// Producing data during the recursive descent.
PreParserIdentifier GetSymbol(Scanner* scanner);
- static PreParserIdentifier NextLiteralString(Scanner* scanner,
- PretenureFlag tenured) {
+
+ PreParserIdentifier GetNextSymbol(Scanner* scanner) {
return PreParserIdentifier::Default();
}
@@ -1223,24 +1211,25 @@ void ParserBase<Traits>::ReportUnexpectedToken(Token::Value token) {
// Four of the tokens are treated specially
switch (token) {
case Token::EOS:
- return ReportMessageAt(source_location, "unexpected_eos");
+ return this->ReportMessageAt(source_location, "unexpected_eos");
case Token::NUMBER:
- return ReportMessageAt(source_location, "unexpected_token_number");
+ return this->ReportMessageAt(source_location, "unexpected_token_number");
case Token::STRING:
- return ReportMessageAt(source_location, "unexpected_token_string");
+ return this->ReportMessageAt(source_location, "unexpected_token_string");
case Token::IDENTIFIER:
- return ReportMessageAt(source_location, "unexpected_token_identifier");
+ return this->ReportMessageAt(source_location,
+ "unexpected_token_identifier");
case Token::FUTURE_RESERVED_WORD:
- return ReportMessageAt(source_location, "unexpected_reserved");
+ return this->ReportMessageAt(source_location, "unexpected_reserved");
case Token::YIELD:
case Token::FUTURE_STRICT_RESERVED_WORD:
- return ReportMessageAt(source_location, strict_mode() == SLOPPY
+ return this->ReportMessageAt(source_location, strict_mode() == SLOPPY
? "unexpected_token_identifier" : "unexpected_strict_reserved");
default:
const char* name = Token::String(token);
ASSERT(name != NULL);
Traits::ReportMessageAt(
- source_location, "unexpected_token", Vector<const char*>(&name, 1));
+ source_location, "unexpected_token", name);
}
}
@@ -1253,7 +1242,8 @@ typename ParserBase<Traits>::IdentifierT ParserBase<Traits>::ParseIdentifier(
if (next == Token::IDENTIFIER) {
IdentifierT name = this->GetSymbol(scanner());
if (allow_eval_or_arguments == kDontAllowEvalOrArguments &&
- strict_mode() == STRICT && this->IsEvalOrArguments(name)) {
+ strict_mode() == STRICT &&
+ this->IsEvalOrArguments(name)) {
ReportMessageAt(scanner()->location(), "strict_eval_arguments");
*ok = false;
}
@@ -1305,8 +1295,7 @@ ParserBase<Traits>::ParseIdentifierName(bool* ok) {
template <class Traits>
typename ParserBase<Traits>::IdentifierT
-ParserBase<Traits>::ParseIdentifierNameOrGetOrSet(bool* is_get,
- bool* is_set,
+ParserBase<Traits>::ParseIdentifierNameOrGetOrSet(bool* is_get, bool* is_set,
bool* ok) {
IdentifierT result = ParseIdentifierName(ok);
if (!*ok) return Traits::EmptyIdentifier();
@@ -1321,21 +1310,21 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseRegExpLiteral(
int pos = peek_position();
if (!scanner()->ScanRegExpPattern(seen_equal)) {
Next();
- ReportMessage("unterminated_regexp", Vector<const char*>::empty());
+ this->ReportMessage("unterminated_regexp");
*ok = false;
return Traits::EmptyExpression();
}
int literal_index = function_state_->NextMaterializedLiteralIndex();
- IdentifierT js_pattern = this->NextLiteralString(scanner(), TENURED);
+ IdentifierT js_pattern = this->GetNextSymbol(scanner());
if (!scanner()->ScanRegExpFlags()) {
Next();
- ReportMessageAt(scanner()->location(), "invalid_regexp_flags");
+ this->ReportMessage("invalid_regexp_flags");
*ok = false;
return Traits::EmptyExpression();
}
- IdentifierT js_flags = this->NextLiteralString(scanner(), TENURED);
+ IdentifierT js_flags = this->GetNextSymbol(scanner());
Next();
return factory()->NewRegExpLiteral(js_pattern, js_flags, literal_index, pos);
}
@@ -1864,7 +1853,7 @@ ParserBase<Traits>::ParseUnaryExpression(bool* ok) {
// "delete identifier" is a syntax error in strict mode.
if (op == Token::DELETE && strict_mode() == STRICT &&
this->IsIdentifier(expression)) {
- ReportMessage("strict_delete", Vector<const char*>::empty());
+ this->ReportMessage("strict_delete");
*ok = false;
return this->EmptyExpression();
}
@@ -2118,7 +2107,8 @@ ParserBase<Traits>::CheckAndRewriteReferenceExpression(
Scanner::Location location, const char* message, bool* ok) {
if (strict_mode() == STRICT && this->IsIdentifier(expression) &&
this->IsEvalOrArguments(this->AsIdentifier(expression))) {
- this->ReportMessageAt(location, "strict_eval_arguments", false);
+ this->ReportMessageAt(location, "strict_eval_arguments", (const char*)NULL,
rossberg 2014/05/08 12:52:08 Nit: style guide forbids C casts
marja 2014/06/03 08:48:20 This change is no longer needed
+ false);
*ok = false;
return this->EmptyExpression();
} else if (expression->IsValidReferenceExpression()) {
@@ -2130,7 +2120,7 @@ ParserBase<Traits>::CheckAndRewriteReferenceExpression(
ExpressionT error = this->NewThrowReferenceError(message, pos);
return factory()->NewProperty(expression, error, pos);
} else {
- this->ReportMessageAt(location, message, true);
+ this->ReportMessageAt(location, message, (const char*)NULL, true);
rossberg 2014/05/08 12:52:08 Same here
marja 2014/06/03 08:48:20 This change is no longer needed
*ok = false;
return this->EmptyExpression();
}

Powered by Google App Engine
This is Rietveld 408576698