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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 *index = rest_index_; | 383 *index = rest_index_; |
384 if (rest_index_ < 0) return NULL; | 384 if (rest_index_ < 0) return NULL; |
385 return rest_parameter_; | 385 return rest_parameter_; |
386 } | 386 } |
387 | 387 |
388 bool has_rest_parameter() const { | 388 bool has_rest_parameter() const { |
389 return rest_index_ >= 0; | 389 return rest_index_ >= 0; |
390 } | 390 } |
391 | 391 |
392 bool has_simple_parameters() const { | 392 bool has_simple_parameters() const { |
| 393 return has_simple_parameters_; |
| 394 } |
| 395 |
| 396 // TODO(caitp): manage this state in a better way. PreParser must be able to |
| 397 // communicate that the scope is non-simple, without allocating any parameters |
| 398 // as the Parser does. This is necessary to ensure that TC39's proposed early |
| 399 // error can be reported consistently regardless of whether lazily parsed or |
| 400 // not. |
| 401 void SetHasNonSimpleParameters() { |
393 DCHECK(is_function_scope()); | 402 DCHECK(is_function_scope()); |
394 return has_simple_parameters_; | 403 has_simple_parameters_ = false; |
| 404 } |
| 405 |
| 406 // Retrieve `IsSimpleParameterList` of current or outer function. |
| 407 bool HasSimpleParameters() { |
| 408 Scope* scope = ClosureScope(); |
| 409 return !scope->is_function_scope() || scope->has_simple_parameters(); |
395 } | 410 } |
396 | 411 |
397 // The local variable 'arguments' if we need to allocate it; NULL otherwise. | 412 // The local variable 'arguments' if we need to allocate it; NULL otherwise. |
398 Variable* arguments() const { | 413 Variable* arguments() const { |
399 DCHECK(!is_arrow_scope() || arguments_ == nullptr); | 414 DCHECK(!is_arrow_scope() || arguments_ == nullptr); |
400 return arguments_; | 415 return arguments_; |
401 } | 416 } |
402 | 417 |
403 Variable* this_function_var() const { | 418 Variable* this_function_var() const { |
404 // This is only used in derived constructors atm. | 419 // This is only used in derived constructors atm. |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 PendingCompilationErrorHandler pending_error_handler_; | 780 PendingCompilationErrorHandler pending_error_handler_; |
766 | 781 |
767 // For tracking which classes are declared consecutively. Needed for strong | 782 // For tracking which classes are declared consecutively. Needed for strong |
768 // mode. | 783 // mode. |
769 int class_declaration_group_start_; | 784 int class_declaration_group_start_; |
770 }; | 785 }; |
771 | 786 |
772 } } // namespace v8::internal | 787 } } // namespace v8::internal |
773 | 788 |
774 #endif // V8_SCOPES_H_ | 789 #endif // V8_SCOPES_H_ |
OLD | NEW |