Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: src/scopes.cc

Issue 1244423003: [es6] Fix function context check for super and new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment; added test for super calls Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/scopes.h ('k') | test/mjsunit/harmony/new-target.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 DCHECK(s != NULL); // scope must be in the scope chain 756 DCHECK(s != NULL); // scope must be in the scope chain
757 if (s->is_with_scope() || s->num_heap_slots() > 0) n++; 757 if (s->is_with_scope() || s->num_heap_slots() > 0) n++;
758 // Catch and module scopes always have heap slots. 758 // Catch and module scopes always have heap slots.
759 DCHECK(!s->is_catch_scope() || s->num_heap_slots() > 0); 759 DCHECK(!s->is_catch_scope() || s->num_heap_slots() > 0);
760 DCHECK(!s->is_module_scope() || s->num_heap_slots() > 0); 760 DCHECK(!s->is_module_scope() || s->num_heap_slots() > 0);
761 } 761 }
762 return n; 762 return n;
763 } 763 }
764 764
765 765
766 Scope* Scope::ScriptScope() {
767 Scope* scope = this;
768 while (!scope->is_script_scope()) {
769 scope = scope->outer_scope();
770 }
771 return scope;
772 }
773
774
775 Scope* Scope::DeclarationScope() { 766 Scope* Scope::DeclarationScope() {
776 Scope* scope = this; 767 Scope* scope = this;
777 while (!scope->is_declaration_scope()) { 768 while (!scope->is_declaration_scope()) {
778 scope = scope->outer_scope(); 769 scope = scope->outer_scope();
779 } 770 }
780 return scope; 771 return scope;
781 } 772 }
782 773
783 774
775 Scope* Scope::ReceiverScope() {
776 Scope* scope = this;
777 while (!scope->is_script_scope() &&
778 (!scope->is_function_scope() || scope->is_arrow_scope())) {
779 scope = scope->outer_scope();
780 }
781 return scope;
782 }
783
784
785
784 Handle<ScopeInfo> Scope::GetScopeInfo(Isolate* isolate) { 786 Handle<ScopeInfo> Scope::GetScopeInfo(Isolate* isolate) {
785 if (scope_info_.is_null()) { 787 if (scope_info_.is_null()) {
786 scope_info_ = ScopeInfo::Create(isolate, zone(), this); 788 scope_info_ = ScopeInfo::Create(isolate, zone(), this);
787 } 789 }
788 return scope_info_; 790 return scope_info_;
789 } 791 }
790 792
791 793
792 void Scope::GetNestedScopeChain(Isolate* isolate, 794 void Scope::GetNestedScopeChain(Isolate* isolate,
793 List<Handle<ScopeInfo> >* chain, int position) { 795 List<Handle<ScopeInfo> >* chain, int position) {
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 bool is_function_var_in_context = 1627 bool is_function_var_in_context =
1626 function_ != NULL && function_->proxy()->var()->IsContextSlot(); 1628 function_ != NULL && function_->proxy()->var()->IsContextSlot();
1627 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1629 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1628 2 * num_global_slots() - (is_function_var_in_context ? 1 : 0); 1630 2 * num_global_slots() - (is_function_var_in_context ? 1 : 0);
1629 } 1631 }
1630 1632
1631 1633
1632 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1634 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1633 } // namespace internal 1635 } // namespace internal
1634 } // namespace v8 1636 } // namespace v8
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | test/mjsunit/harmony/new-target.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698