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