| 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_SCOPES_H_ | 5 #ifndef V8_SCOPES_H_ |
| 6 #define V8_SCOPES_H_ | 6 #define V8_SCOPES_H_ |
| 7 | 7 |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/pending-compilation-error-handler.h" | 9 #include "src/pending-compilation-error-handler.h" |
| 10 #include "src/zone.h" | 10 #include "src/zone.h" |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 } | 396 } |
| 397 | 397 |
| 398 bool has_rest_parameter() const { | 398 bool has_rest_parameter() const { |
| 399 return rest_index_ >= 0; | 399 return rest_index_ >= 0; |
| 400 } | 400 } |
| 401 | 401 |
| 402 bool has_simple_parameters() const { | 402 bool has_simple_parameters() const { |
| 403 return has_simple_parameters_; | 403 return has_simple_parameters_; |
| 404 } | 404 } |
| 405 | 405 |
| 406 bool has_parameter_expressions() const { return has_parameter_expressions_; } |
| 407 |
| 406 // TODO(caitp): manage this state in a better way. PreParser must be able to | 408 // TODO(caitp): manage this state in a better way. PreParser must be able to |
| 407 // communicate that the scope is non-simple, without allocating any parameters | 409 // communicate that the scope is non-simple, without allocating any parameters |
| 408 // as the Parser does. This is necessary to ensure that TC39's proposed early | 410 // as the Parser does. This is necessary to ensure that TC39's proposed early |
| 409 // error can be reported consistently regardless of whether lazily parsed or | 411 // error can be reported consistently regardless of whether lazily parsed or |
| 410 // not. | 412 // not. |
| 411 void SetHasNonSimpleParameters() { | 413 void SetHasNonSimpleParameters() { |
| 412 DCHECK(is_function_scope()); | 414 DCHECK(is_function_scope()); |
| 413 has_simple_parameters_ = false; | 415 has_simple_parameters_ = false; |
| 414 } | 416 } |
| 415 | 417 |
| 416 // Retrieve `IsSimpleParameterList` of current or outer function. | 418 // Retrieve `IsSimpleParameterList` of current or outer function. |
| 417 bool HasSimpleParameters() { | 419 bool HasSimpleParameters() { |
| 418 Scope* scope = ClosureScope(); | 420 Scope* scope = ClosureScope(); |
| 419 return !scope->is_function_scope() || scope->has_simple_parameters(); | 421 return !scope->is_function_scope() || scope->has_simple_parameters(); |
| 420 } | 422 } |
| 421 | 423 |
| 424 void SetHasParameterExpressions() { |
| 425 DCHECK(is_function_scope()); |
| 426 has_parameter_expressions_ = true; |
| 427 } |
| 428 |
| 429 bool HasParameterExpressions() { |
| 430 Scope* scope = ClosureScope(); |
| 431 return !scope->is_function_scope() || scope->has_parameter_expressions(); |
| 432 } |
| 433 |
| 422 // The local variable 'arguments' if we need to allocate it; NULL otherwise. | 434 // The local variable 'arguments' if we need to allocate it; NULL otherwise. |
| 423 Variable* arguments() const { | 435 Variable* arguments() const { |
| 424 DCHECK(!is_arrow_scope() || arguments_ == nullptr); | 436 DCHECK(!is_arrow_scope() || arguments_ == nullptr); |
| 425 return arguments_; | 437 return arguments_; |
| 426 } | 438 } |
| 427 | 439 |
| 428 Variable* this_function_var() const { | 440 Variable* this_function_var() const { |
| 429 // This is only used in derived constructors atm. | 441 // This is only used in derived constructors atm. |
| 430 DCHECK(this_function_ == nullptr || | 442 DCHECK(this_function_ == nullptr || |
| 431 (is_function_scope() && (IsConstructor(function_kind()) || | 443 (is_function_scope() && (IsConstructor(function_kind()) || |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 | 666 |
| 655 // The number of modules (including nested ones). | 667 // The number of modules (including nested ones). |
| 656 int num_modules_; | 668 int num_modules_; |
| 657 | 669 |
| 658 // For module scopes, the host scope's temporary variable binding this module. | 670 // For module scopes, the host scope's temporary variable binding this module. |
| 659 Variable* module_var_; | 671 Variable* module_var_; |
| 660 | 672 |
| 661 // Info about the parameter list of a function. | 673 // Info about the parameter list of a function. |
| 662 int arity_; | 674 int arity_; |
| 663 bool has_simple_parameters_; | 675 bool has_simple_parameters_; |
| 676 bool has_parameter_expressions_; |
| 664 Variable* rest_parameter_; | 677 Variable* rest_parameter_; |
| 665 int rest_index_; | 678 int rest_index_; |
| 666 | 679 |
| 667 // Serialized scope info support. | 680 // Serialized scope info support. |
| 668 Handle<ScopeInfo> scope_info_; | 681 Handle<ScopeInfo> scope_info_; |
| 669 bool already_resolved() { return already_resolved_; } | 682 bool already_resolved() { return already_resolved_; } |
| 670 | 683 |
| 671 // Create a non-local variable with a given name. | 684 // Create a non-local variable with a given name. |
| 672 // These variables are looked up dynamically at runtime. | 685 // These variables are looked up dynamically at runtime. |
| 673 Variable* NonLocal(const AstRawString* name, VariableMode mode); | 686 Variable* NonLocal(const AstRawString* name, VariableMode mode); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 PendingCompilationErrorHandler pending_error_handler_; | 806 PendingCompilationErrorHandler pending_error_handler_; |
| 794 | 807 |
| 795 // For tracking which classes are declared consecutively. Needed for strong | 808 // For tracking which classes are declared consecutively. Needed for strong |
| 796 // mode. | 809 // mode. |
| 797 int class_declaration_group_start_; | 810 int class_declaration_group_start_; |
| 798 }; | 811 }; |
| 799 | 812 |
| 800 } } // namespace v8::internal | 813 } } // namespace v8::internal |
| 801 | 814 |
| 802 #endif // V8_SCOPES_H_ | 815 #endif // V8_SCOPES_H_ |
| OLD | NEW |