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..f0b907dbb017eefb74e755e1db7acad94c0dbb3a 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), |
| + outermost_receiver_function_kind_(kNormalFunction), |
| + outermost_receiver_scope_type_(SCRIPT_SCOPE), |
| zone_(zone), |
| classifier_(nullptr), |
| scanner_(scanner), |
| @@ -866,8 +868,25 @@ 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(); |
| + return outermost_receiver_function_kind_; |
| + } |
| + void RecordSuperPropertyUsage() { |
| + DeclarationScope* receiver_scope = scope()->GetReceiverScope(); |
| + // If the receiver scope is the outermost script scope, a) it might not be |
|
adamk
2016/09/12 16:57:47
This comment points to some weirdness in this CL.
jochen (gone - plz use gerrit)
2016/09/12 19:00:43
it's a bit easier - the parser just never has an c
adamk
2016/09/12 21:35:11
The two modes I'm talking about are:
- Deep insid
|
| + // the correct receiver scope as the correct one might first get |
| + // deserialized later, and b) recording is pointless anyways, as we won't |
| + // create a scope infos for deserialized scopes. |
| + if (receiver_scope->outer_scope()) { |
| + receiver_scope->RecordSuperPropertyUsage(); |
| + } |
| + } |
| + ScopeType GetReceiverScopeType() const { |
| + Scope* receiver_scope = scope()->GetReceiverScope(); |
| + if (receiver_scope->outer_scope()) return receiver_scope->scope_type(); |
| + return outermost_receiver_scope_type_; |
| } |
| LanguageMode language_mode() { return scope()->language_mode(); } |
| void RaiseLanguageMode(LanguageMode mode) { |
| @@ -1337,6 +1356,8 @@ class ParserBase { |
| Mode mode_; |
| bool parsing_module_; |
| uintptr_t stack_limit_; |
| + FunctionKind outermost_receiver_function_kind_; |
| + ScopeType outermost_receiver_scope_type_; |
| // Parser base's private field members. |
| @@ -3245,12 +3266,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 +3308,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; |