Chromium Code Reviews| Index: src/parsing/parser-base.h |
| diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h |
| index 4a13688eda09ec3e35d0e6bb77285887f65341cb..291a0088cbf8e5a17edce42294d1683b389bc040 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); |
| } |
| + int ExpectMetaProperty(Vector<const char> keyword, const char* full, |
|
adamk
2016/02/16 20:52:09
Some nits on argument names: this should be "prope
caitp (gmail)
2016/02/16 22:13:55
Done.
|
| + 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); |
| + int pos = |
| + ExpectMetaProperty(CStrVector("sent"), "function.sent", CHECK_OK); |
| if (!is_generator()) { |
| // TODO(neis): allow escaping into closures? |
| @@ -2769,13 +2771,28 @@ ParserBase<Traits>::ParseSuperExpression(bool is_new, |
| return this->EmptyExpression(); |
| } |
| +template <class Traits> |
| +int ParserBase<Traits>::ExpectMetaProperty(Vector<const char> keyword, |
|
adamk
2016/02/16 20:52:09
Returning a position isn't something we do elsewhe
caitp (gmail)
2016/02/16 22:13:55
Done.
|
| + const char* full, bool* ok) { |
| + int pos = position(); |
| + if (*ok) { |
|
adamk
2016/02/16 20:52:09
I don't think should ever be false, so this if sta
caitp (gmail)
2016/02/16 22:13:55
Done.
|
| + Consume(Token::PERIOD); |
| + ExpectContextualKeyword(keyword, ok); |
| + if (!*ok) return pos; |
| + if (scanner()->literal_contains_escapes()) { |
| + Traits::ReportMessageAt( |
| + Scanner::Location(pos, scanner()->location().end_pos), |
| + MessageTemplate::kInvalidEscapedMetaProperty, full, kSyntaxError); |
|
adamk
2016/02/16 20:52:09
kSyntaxError is the default
caitp (gmail)
2016/02/16 22:13:55
Done.
|
| + *ok = false; |
| + } |
| + } |
| + return pos; |
| +} |
| template <class Traits> |
| typename ParserBase<Traits>::ExpressionT |
| ParserBase<Traits>::ParseNewTargetExpression(bool* ok) { |
| - int pos = position(); |
| - Consume(Token::PERIOD); |
| - ExpectContextualKeyword(CStrVector("target"), CHECK_OK); |
| + int pos = ExpectMetaProperty(CStrVector("target"), "new.target", CHECK_OK); |
| if (!scope_->ReceiverScope()->is_function_scope()) { |
| ReportMessageAt(scanner()->location(), |