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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 bool is_catch_scope() const { return scope_type_ == CATCH_SCOPE; } | 277 bool is_catch_scope() const { return scope_type_ == CATCH_SCOPE; } |
278 bool is_block_scope() const { return scope_type_ == BLOCK_SCOPE; } | 278 bool is_block_scope() const { return scope_type_ == BLOCK_SCOPE; } |
279 bool is_with_scope() const { return scope_type_ == WITH_SCOPE; } | 279 bool is_with_scope() const { return scope_type_ == WITH_SCOPE; } |
280 bool is_arrow_scope() const { return scope_type_ == ARROW_SCOPE; } | 280 bool is_arrow_scope() const { return scope_type_ == ARROW_SCOPE; } |
281 bool is_declaration_scope() const { return is_declaration_scope_; } | 281 bool is_declaration_scope() const { return is_declaration_scope_; } |
282 | 282 |
283 void set_is_declaration_scope() { is_declaration_scope_ = true; } | 283 void set_is_declaration_scope() { is_declaration_scope_ = true; } |
284 | 284 |
285 // Information about which scopes calls eval. | 285 // Information about which scopes calls eval. |
286 bool calls_eval() const { return scope_calls_eval_; } | 286 bool calls_eval() const { return scope_calls_eval_; } |
287 bool calls_sloppy_eval() { | 287 bool calls_sloppy_eval() const { |
288 return scope_calls_eval_ && is_sloppy(language_mode_); | 288 return scope_calls_eval_ && is_sloppy(language_mode_); |
289 } | 289 } |
290 bool outer_scope_calls_sloppy_eval() const { | 290 bool outer_scope_calls_sloppy_eval() const { |
291 return outer_scope_calls_sloppy_eval_; | 291 return outer_scope_calls_sloppy_eval_; |
292 } | 292 } |
293 bool asm_module() const { return asm_module_; } | 293 bool asm_module() const { return asm_module_; } |
294 bool asm_function() const { return asm_function_; } | 294 bool asm_function() const { return asm_function_; } |
295 | 295 |
296 // Is this scope inside a with statement. | 296 // Is this scope inside a with statement. |
297 bool inside_with() const { return scope_inside_with_; } | 297 bool inside_with() const { return scope_inside_with_; } |
298 // Does this scope contain a with statement. | 298 // Does this scope contain a with statement. |
299 bool contains_with() const { return scope_contains_with_; } | 299 bool contains_with() const { return scope_contains_with_; } |
300 | 300 |
301 // Does this scope access "arguments". | 301 // Does this scope access "arguments". |
302 bool uses_arguments() const { return scope_uses_arguments_; } | 302 bool uses_arguments() const { return scope_uses_arguments_; } |
303 // Does any inner scope access "arguments". | 303 // Does any inner scope access "arguments". |
304 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } | 304 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } |
305 // Does this scope access "super" property (super.foo). | 305 // Does this scope access "super" property (super.foo). |
306 bool uses_super_property() const { return scope_uses_super_property_; } | 306 bool uses_super_property() const { return scope_uses_super_property_; } |
307 | 307 |
| 308 // Whether this needs to be represented by a runtime context. |
| 309 bool NeedsContext() const { return num_heap_slots() > 0; } |
| 310 |
308 bool NeedsHomeObject() const { | 311 bool NeedsHomeObject() const { |
309 return scope_uses_super_property_ || | 312 return scope_uses_super_property_ || |
310 (scope_calls_eval_ && (IsConciseMethod(function_kind()) || | 313 (scope_calls_eval_ && (IsConciseMethod(function_kind()) || |
311 IsAccessorFunction(function_kind()) || | 314 IsAccessorFunction(function_kind()) || |
312 IsConstructor(function_kind()))); | 315 IsConstructor(function_kind()))); |
313 } | 316 } |
314 | 317 |
315 const Scope* NearestOuterEvalScope() const { | 318 const Scope* NearestOuterEvalScope() const { |
316 if (is_eval_scope()) return this; | 319 if (is_eval_scope()) return this; |
317 if (outer_scope() == nullptr) return nullptr; | 320 if (outer_scope() == nullptr) return nullptr; |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 PendingCompilationErrorHandler pending_error_handler_; | 765 PendingCompilationErrorHandler pending_error_handler_; |
763 | 766 |
764 // For tracking which classes are declared consecutively. Needed for strong | 767 // For tracking which classes are declared consecutively. Needed for strong |
765 // mode. | 768 // mode. |
766 int class_declaration_group_start_; | 769 int class_declaration_group_start_; |
767 }; | 770 }; |
768 | 771 |
769 } } // namespace v8::internal | 772 } } // namespace v8::internal |
770 | 773 |
771 #endif // V8_SCOPES_H_ | 774 #endif // V8_SCOPES_H_ |
OLD | NEW |