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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 bool is_eval_scope() const { return scope_type_ == EVAL_SCOPE; } | 273 bool is_eval_scope() const { return scope_type_ == EVAL_SCOPE; } |
274 bool is_function_scope() const { | 274 bool is_function_scope() const { |
275 return scope_type_ == FUNCTION_SCOPE || scope_type_ == ARROW_SCOPE; | 275 return scope_type_ == FUNCTION_SCOPE || scope_type_ == ARROW_SCOPE; |
276 } | 276 } |
277 bool is_module_scope() const { return scope_type_ == MODULE_SCOPE; } | 277 bool is_module_scope() const { return scope_type_ == MODULE_SCOPE; } |
278 bool is_script_scope() const { return scope_type_ == SCRIPT_SCOPE; } | 278 bool is_script_scope() const { return scope_type_ == SCRIPT_SCOPE; } |
279 bool is_catch_scope() const { return scope_type_ == CATCH_SCOPE; } | 279 bool is_catch_scope() const { return scope_type_ == CATCH_SCOPE; } |
280 bool is_block_scope() const { return scope_type_ == BLOCK_SCOPE; } | 280 bool is_block_scope() const { return scope_type_ == BLOCK_SCOPE; } |
281 bool is_with_scope() const { return scope_type_ == WITH_SCOPE; } | 281 bool is_with_scope() const { return scope_type_ == WITH_SCOPE; } |
282 bool is_arrow_scope() const { return scope_type_ == ARROW_SCOPE; } | 282 bool is_arrow_scope() const { return scope_type_ == ARROW_SCOPE; } |
283 void tag_as_class_scope() { | |
284 DCHECK(is_block_scope()); | |
285 block_scope_is_class_scope_ = true; | |
286 } | |
287 bool is_class_scope() const { | |
288 return is_block_scope() && block_scope_is_class_scope_; | |
289 } | |
290 bool is_declaration_scope() const { | 283 bool is_declaration_scope() const { |
291 return is_eval_scope() || is_function_scope() || | 284 return is_eval_scope() || is_function_scope() || |
292 is_module_scope() || is_script_scope(); | 285 is_module_scope() || is_script_scope(); |
293 } | 286 } |
294 bool is_strict_eval_scope() const { | 287 bool is_strict_eval_scope() const { |
295 return is_eval_scope() && is_strict(language_mode_); | 288 return is_eval_scope() && is_strict(language_mode_); |
296 } | 289 } |
297 | 290 |
298 // Information about which scopes calls eval. | 291 // Information about which scopes calls eval. |
299 bool calls_eval() const { return scope_calls_eval_; } | 292 bool calls_eval() const { return scope_calls_eval_; } |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 // Implementation. | 530 // Implementation. |
538 protected: | 531 protected: |
539 friend class ParserFactory; | 532 friend class ParserFactory; |
540 | 533 |
541 // Scope tree. | 534 // Scope tree. |
542 Scope* outer_scope_; // the immediately enclosing outer scope, or NULL | 535 Scope* outer_scope_; // the immediately enclosing outer scope, or NULL |
543 ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes | 536 ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes |
544 | 537 |
545 // The scope type. | 538 // The scope type. |
546 ScopeType scope_type_; | 539 ScopeType scope_type_; |
547 // Some block scopes are tagged as class scopes. | |
548 bool block_scope_is_class_scope_; | |
549 // If the scope is a function scope, this is the function kind. | 540 // If the scope is a function scope, this is the function kind. |
550 FunctionKind function_kind_; | 541 FunctionKind function_kind_; |
551 | 542 |
552 // Debugging support. | 543 // Debugging support. |
553 const AstRawString* scope_name_; | 544 const AstRawString* scope_name_; |
554 | 545 |
555 // The variables declared in this scope: | 546 // The variables declared in this scope: |
556 // | 547 // |
557 // All user-declared variables (incl. parameters). For script scopes | 548 // All user-declared variables (incl. parameters). For script scopes |
558 // variables may be implicitly 'declared' by being used (possibly in | 549 // variables may be implicitly 'declared' by being used (possibly in |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 PendingCompilationErrorHandler pending_error_handler_; | 756 PendingCompilationErrorHandler pending_error_handler_; |
766 | 757 |
767 // For tracking which classes are declared consecutively. Needed for strong | 758 // For tracking which classes are declared consecutively. Needed for strong |
768 // mode. | 759 // mode. |
769 int class_declaration_group_start_; | 760 int class_declaration_group_start_; |
770 }; | 761 }; |
771 | 762 |
772 } } // namespace v8::internal | 763 } } // namespace v8::internal |
773 | 764 |
774 #endif // V8_SCOPES_H_ | 765 #endif // V8_SCOPES_H_ |
OLD | NEW |