| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef V8_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H | 
| 6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H | 
| 7 | 7 | 
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" | 
| 9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" | 
| 10 #include "src/base/hashmap.h" | 10 #include "src/base/hashmap.h" | 
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 618   Scope* NewScope(Scope* parent, ScopeType scope_type) { | 618   Scope* NewScope(Scope* parent, ScopeType scope_type) { | 
| 619     // Must always pass the function kind for FUNCTION_SCOPE. | 619     // Must always pass the function kind for FUNCTION_SCOPE. | 
| 620     DCHECK(scope_type != FUNCTION_SCOPE); | 620     DCHECK(scope_type != FUNCTION_SCOPE); | 
| 621     Scope* result = | 621     Scope* result = | 
| 622         new (zone()) Scope(zone(), parent, scope_type, kNormalFunction); | 622         new (zone()) Scope(zone(), parent, scope_type, kNormalFunction); | 
| 623     result->Initialize(); | 623     result->Initialize(); | 
| 624     if (scope_type == MODULE_SCOPE) result->DeclareThis(ast_value_factory()); | 624     if (scope_type == MODULE_SCOPE) result->DeclareThis(ast_value_factory()); | 
| 625     return result; | 625     return result; | 
| 626   } | 626   } | 
| 627 | 627 | 
| 628   Scope* NewFunctionScope(Scope* parent, FunctionKind kind) { | 628   Scope* NewFunctionScope(FunctionKind kind) { | 
| 629     DCHECK(ast_value_factory()); | 629     DCHECK(ast_value_factory()); | 
| 630     Scope* result = new (zone()) Scope(zone(), parent, FUNCTION_SCOPE, kind); | 630     Scope* result = new (zone()) Scope(zone(), scope(), FUNCTION_SCOPE, kind); | 
| 631     result->Initialize(); | 631     result->Initialize(); | 
| 632     if (!IsArrowFunction(kind)) { | 632     if (!IsArrowFunction(kind)) { | 
| 633       result->DeclareThis(ast_value_factory()); | 633       result->DeclareThis(ast_value_factory()); | 
| 634       result->DeclareDefaultFunctionVariables(ast_value_factory()); | 634       result->DeclareDefaultFunctionVariables(ast_value_factory()); | 
| 635     } | 635     } | 
| 636     return result; | 636     return result; | 
| 637   } | 637   } | 
| 638 | 638 | 
| 639   Scanner* scanner() const { return scanner_; } | 639   Scanner* scanner() const { return scanner_; } | 
| 640   AstValueFactory* ast_value_factory() const { return ast_value_factory_; } | 640   AstValueFactory* ast_value_factory() const { return ast_value_factory_; } | 
| (...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2307                                   parenthesized_formals, is_async, CHECK_OK); | 2307                                   parenthesized_formals, is_async, CHECK_OK); | 
| 2308     // This reads strangely, but is correct: it checks whether any | 2308     // This reads strangely, but is correct: it checks whether any | 
| 2309     // sub-expression of the parameter list failed to be a valid formal | 2309     // sub-expression of the parameter list failed to be a valid formal | 
| 2310     // parameter initializer. Since YieldExpressions are banned anywhere | 2310     // parameter initializer. Since YieldExpressions are banned anywhere | 
| 2311     // in an arrow parameter list, this is correct. | 2311     // in an arrow parameter list, this is correct. | 
| 2312     // TODO(adamk): Rename "FormalParameterInitializerError" to refer to | 2312     // TODO(adamk): Rename "FormalParameterInitializerError" to refer to | 
| 2313     // "YieldExpression", which is its only use. | 2313     // "YieldExpression", which is its only use. | 
| 2314     ValidateFormalParameterInitializer(&arrow_formals_classifier, ok); | 2314     ValidateFormalParameterInitializer(&arrow_formals_classifier, ok); | 
| 2315 | 2315 | 
| 2316     Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos); | 2316     Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos); | 
| 2317     Scope* scope = this->NewFunctionScope( | 2317     Scope* scope = | 
| 2318         this->scope(), is_async ? FunctionKind::kAsyncArrowFunction | 2318         this->NewFunctionScope(is_async ? FunctionKind::kAsyncArrowFunction | 
| 2319                                 : FunctionKind::kArrowFunction); | 2319                                         : FunctionKind::kArrowFunction); | 
| 2320     // Because the arrow's parameters were parsed in the outer scope, any | 2320     // Because the arrow's parameters were parsed in the outer scope, any | 
| 2321     // usage flags that might have been triggered there need to be copied | 2321     // usage flags that might have been triggered there need to be copied | 
| 2322     // to the arrow scope. | 2322     // to the arrow scope. | 
| 2323     this->scope()->PropagateUsageFlagsToScope(scope); | 2323     this->scope()->PropagateUsageFlagsToScope(scope); | 
| 2324     FormalParametersT parameters(scope); | 2324     FormalParametersT parameters(scope); | 
| 2325     if (!arrow_formals_classifier.is_simple_parameter_list()) { | 2325     if (!arrow_formals_classifier.is_simple_parameter_list()) { | 
| 2326       scope->SetHasNonSimpleParameters(); | 2326       scope->SetHasNonSimpleParameters(); | 
| 2327       parameters.is_simple = false; | 2327       parameters.is_simple = false; | 
| 2328     } | 2328     } | 
| 2329 | 2329 | 
| (...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3684     has_seen_constructor_ = true; | 3684     has_seen_constructor_ = true; | 
| 3685     return; | 3685     return; | 
| 3686   } | 3686   } | 
| 3687 } | 3687 } | 
| 3688 | 3688 | 
| 3689 | 3689 | 
| 3690 }  // namespace internal | 3690 }  // namespace internal | 
| 3691 }  // namespace v8 | 3691 }  // namespace v8 | 
| 3692 | 3692 | 
| 3693 #endif  // V8_PARSING_PARSER_BASE_H | 3693 #endif  // V8_PARSING_PARSER_BASE_H | 
| OLD | NEW | 
|---|