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

Unified Diff: src/parsing/parser-base.h

Issue 1700123003: [parser] unify metaproperty parsing and require unescaped property name (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: more oops Created 4 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/messages.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index 4a13688eda09ec3e35d0e6bb77285887f65341cb..8922c7e282e84906a57ff6f737303f9e35e78c3a 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -454,6 +454,9 @@ class ParserBase : public Traits {
scanner()->is_next_contextual_keyword(keyword);
}
+ void ExpectMetaProperty(Vector<const char> property_name,
+ const char* full_name, int pos, bool* ok);
+
void ExpectContextualKeyword(Vector<const char> keyword, bool* ok) {
Expect(Token::IDENTIFIER, ok);
if (!*ok) return;
@@ -2540,11 +2543,10 @@ ParserBase<Traits>::ParseMemberExpression(ExpressionClassifier* classifier,
Consume(Token::FUNCTION);
int function_token_position = position();
- if (FLAG_harmony_function_sent && Check(Token::PERIOD)) {
+ if (FLAG_harmony_function_sent && peek() == Token::PERIOD) {
// function.sent
-
int pos = position();
- ExpectContextualKeyword(CStrVector("sent"), CHECK_OK);
+ ExpectMetaProperty(CStrVector("sent"), "function.sent", pos, CHECK_OK);
if (!is_generator()) {
// TODO(neis): allow escaping into closures?
@@ -2769,13 +2771,26 @@ ParserBase<Traits>::ParseSuperExpression(bool is_new,
return this->EmptyExpression();
}
+template <class Traits>
+void ParserBase<Traits>::ExpectMetaProperty(Vector<const char> property_name,
+ const char* full_name, int pos,
+ bool* ok) {
+ Consume(Token::PERIOD);
+ ExpectContextualKeyword(property_name, ok);
+ if (!*ok) return;
+ if (scanner()->literal_contains_escapes()) {
+ Traits::ReportMessageAt(
+ Scanner::Location(pos, scanner()->location().end_pos),
+ MessageTemplate::kInvalidEscapedMetaProperty, full_name);
+ *ok = false;
+ }
+}
template <class Traits>
typename ParserBase<Traits>::ExpressionT
ParserBase<Traits>::ParseNewTargetExpression(bool* ok) {
int pos = position();
- Consume(Token::PERIOD);
- ExpectContextualKeyword(CStrVector("target"), CHECK_OK);
+ ExpectMetaProperty(CStrVector("target"), "new.target", pos, CHECK_OK);
if (!scope_->ReceiverScope()->is_function_scope()) {
ReportMessageAt(scanner()->location(),
« no previous file with comments | « src/messages.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698