Chromium Code Reviews| Index: src/parsing/parser-base.h |
| diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h |
| index 2b8c10c5f84999f1a15d662b3e73b05866e574d4..8b224263d3dc3ed97d3536666ee97a1d59eed219 100644 |
| --- a/src/parsing/parser-base.h |
| +++ b/src/parsing/parser-base.h |
| @@ -184,6 +184,8 @@ class ParserBase { |
| mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. |
| parsing_module_(false), |
| stack_limit_(stack_limit), |
| + outer_most_receivers_function_kind_(kNormalFunction), |
| + outer_most_receivers_scope_type_(SCRIPT_SCOPE), |
| zone_(zone), |
| classifier_(nullptr), |
| scanner_(scanner), |
| @@ -866,8 +868,21 @@ class ParserBase { |
| typename Types::Factory* factory() { return &ast_node_factory_; } |
| - DeclarationScope* GetReceiverScope() const { |
| - return scope()->GetReceiverScope(); |
| + FunctionKind GetReceiverScopeFunctionKind() const { |
| + DeclarationScope* receiver_scope = scope()->GetReceiverScope(); |
| + if (receiver_scope->outer_scope()) return receiver_scope->function_kind(); |
|
marja
2016/09/12 07:50:32
Style nit: != nullptr (in several places)
|
| + return outer_most_receivers_function_kind_; |
| + } |
| + void RecordSuperPropertyUsage() { |
| + DeclarationScope* receiver_scope = scope()->GetReceiverScope(); |
| + if (receiver_scope->outer_scope()) { |
|
marja
2016/09/12 07:50:33
Why is this correct? If there's no outer scope, th
jochen (gone - plz use gerrit)
2016/09/12 08:18:18
done
|
| + return receiver_scope->RecordSuperPropertyUsage(); |
|
marja
2016/09/12 07:50:32
Nit: "return" is unnecessary here.
jochen (gone - plz use gerrit)
2016/09/12 08:18:18
done
|
| + } |
| + } |
| + ScopeType GetReceiverScopeType() const { |
| + Scope* receiver_scope = scope()->GetReceiverScope(); |
| + if (receiver_scope->outer_scope()) return receiver_scope->scope_type(); |
| + return outer_most_receivers_scope_type_; |
| } |
| LanguageMode language_mode() { return scope()->language_mode(); } |
| void RaiseLanguageMode(LanguageMode mode) { |
| @@ -1337,6 +1352,8 @@ class ParserBase { |
| Mode mode_; |
| bool parsing_module_; |
| uintptr_t stack_limit_; |
| + FunctionKind outer_most_receivers_function_kind_; |
|
marja
2016/09/12 07:50:32
Naming nit: "outermost" is one word, so outermost_
jochen (gone - plz use gerrit)
2016/09/12 08:18:18
done
|
| + ScopeType outer_most_receivers_scope_type_; |
| // Parser base's private field members. |
| @@ -3245,12 +3262,11 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseSuperExpression( |
| Expect(Token::SUPER, CHECK_OK); |
| int pos = position(); |
| - DeclarationScope* scope = GetReceiverScope(); |
| - FunctionKind kind = scope->function_kind(); |
| + FunctionKind kind = GetReceiverScopeFunctionKind(); |
| if (IsConciseMethod(kind) || IsAccessorFunction(kind) || |
| IsClassConstructor(kind)) { |
| if (peek() == Token::PERIOD || peek() == Token::LBRACK) { |
| - scope->RecordSuperPropertyUsage(); |
| + RecordSuperPropertyUsage(); |
| return impl()->NewSuperPropertyReference(pos); |
| } |
| // new super() is never allowed. |
| @@ -3288,7 +3304,7 @@ ParserBase<Impl>::ParseNewTargetExpression(bool* ok) { |
| int pos = position(); |
| ExpectMetaProperty(CStrVector("target"), "new.target", pos, CHECK_OK); |
| - if (!GetReceiverScope()->is_function_scope()) { |
| + if (GetReceiverScopeType() != FUNCTION_SCOPE) { |
| impl()->ReportMessageAt(scanner()->location(), |
| MessageTemplate::kUnexpectedNewTarget); |
| *ok = false; |