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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/messages.h" | 9 #include "src/messages.h" |
10 #include "src/parser.h" | 10 #include "src/parser.h" |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 if (scope->is_with_scope() && !found_non_trivial_declarations) return false; | 727 if (scope->is_with_scope() && !found_non_trivial_declarations) return false; |
728 if (scope->is_block_scope() && !scope->decls_.is_empty()) return false; | 728 if (scope->is_block_scope() && !scope->decls_.is_empty()) return false; |
729 if (scope->is_declaration_scope() && scope->num_heap_slots() > 0) { | 729 if (scope->is_declaration_scope() && scope->num_heap_slots() > 0) { |
730 found_non_trivial_declarations = true; | 730 found_non_trivial_declarations = true; |
731 } | 731 } |
732 } | 732 } |
733 return true; | 733 return true; |
734 } | 734 } |
735 | 735 |
736 | 736 |
| 737 bool Scope::AllowsLazyParsing() const { |
| 738 // If we are inside a block scope, we must parse eagerly to find out how |
| 739 // to allocate variables on the block scope. At this point, declarations may |
| 740 // not have yet been parsed. |
| 741 for (const Scope* scope = this; scope != NULL; scope = scope->outer_scope_) { |
| 742 if (scope->is_block_scope()) return false; |
| 743 } |
| 744 return AllowsLazyCompilation(); |
| 745 } |
| 746 |
| 747 |
737 bool Scope::AllowsLazyCompilation() const { | 748 bool Scope::AllowsLazyCompilation() const { |
738 return !force_eager_compilation_ && HasLazyCompilableOuterContext(); | 749 return !force_eager_compilation_ && HasLazyCompilableOuterContext(); |
739 } | 750 } |
740 | 751 |
741 | 752 |
742 bool Scope::AllowsLazyCompilationWithoutContext() const { | 753 bool Scope::AllowsLazyCompilationWithoutContext() const { |
743 return !force_eager_compilation_ && HasTrivialOuterContext(); | 754 return !force_eager_compilation_ && HasTrivialOuterContext(); |
744 } | 755 } |
745 | 756 |
746 | 757 |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1574 } | 1585 } |
1575 | 1586 |
1576 | 1587 |
1577 int Scope::ContextLocalCount() const { | 1588 int Scope::ContextLocalCount() const { |
1578 if (num_heap_slots() == 0) return 0; | 1589 if (num_heap_slots() == 0) return 0; |
1579 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1590 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1580 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); | 1591 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); |
1581 } | 1592 } |
1582 } // namespace internal | 1593 } // namespace internal |
1583 } // namespace v8 | 1594 } // namespace v8 |
OLD | NEW |