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

Side by Side Diff: src/scopes.cc

Issue 1386253002: Use Scope::function_kind_ to distinguish arrow function scopes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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
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/scopes.h" 5 #include "src/scopes.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 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 while (!top->is_script_scope() && !top->outer_scope()->already_resolved()) { 837 while (!top->is_script_scope() && !top->outer_scope()->already_resolved()) {
838 top = top->outer_scope(); 838 top = top->outer_scope();
839 } 839 }
840 840
841 top->pending_error_handler_.ReportMessageAt(start_position, end_position, 841 top->pending_error_handler_.ReportMessageAt(start_position, end_position,
842 message, arg, kReferenceError); 842 message, arg, kReferenceError);
843 } 843 }
844 844
845 845
846 #ifdef DEBUG 846 #ifdef DEBUG
847 static const char* Header(ScopeType scope_type, bool is_declaration_scope) { 847 static const char* Header(ScopeType scope_type, FunctionKind function_kind,
848 bool is_declaration_scope) {
848 switch (scope_type) { 849 switch (scope_type) {
849 case EVAL_SCOPE: return "eval"; 850 case EVAL_SCOPE: return "eval";
850 case FUNCTION_SCOPE: return "function"; 851 // TODO(adamk): Should we print concise method scopes specially?
852 case FUNCTION_SCOPE:
853 return IsArrowFunction(function_kind) ? "arrow" : "function";
851 case MODULE_SCOPE: return "module"; 854 case MODULE_SCOPE: return "module";
852 case SCRIPT_SCOPE: return "global"; 855 case SCRIPT_SCOPE: return "global";
853 case CATCH_SCOPE: return "catch"; 856 case CATCH_SCOPE: return "catch";
854 case BLOCK_SCOPE: return is_declaration_scope ? "varblock" : "block"; 857 case BLOCK_SCOPE: return is_declaration_scope ? "varblock" : "block";
855 case WITH_SCOPE: return "with"; 858 case WITH_SCOPE: return "with";
856 case ARROW_SCOPE: return "arrow";
857 } 859 }
858 UNREACHABLE(); 860 UNREACHABLE();
859 return NULL; 861 return NULL;
860 } 862 }
861 863
862 864
863 static void Indent(int n, const char* str) { 865 static void Indent(int n, const char* str) {
864 PrintF("%*s%s", n, "", str); 866 PrintF("%*s%s", n, "", str);
865 } 867 }
866 868
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 } 930 }
929 } 931 }
930 } 932 }
931 933
932 934
933 void Scope::Print(int n) { 935 void Scope::Print(int n) {
934 int n0 = (n > 0 ? n : 0); 936 int n0 = (n > 0 ? n : 0);
935 int n1 = n0 + 2; // indentation 937 int n1 = n0 + 2; // indentation
936 938
937 // Print header. 939 // Print header.
938 Indent(n0, Header(scope_type_, is_declaration_scope())); 940 Indent(n0, Header(scope_type_, function_kind_, is_declaration_scope()));
939 if (!scope_name_->IsEmpty()) { 941 if (!scope_name_->IsEmpty()) {
940 PrintF(" "); 942 PrintF(" ");
941 PrintName(scope_name_); 943 PrintName(scope_name_);
942 } 944 }
943 945
944 // Print parameters, if any. 946 // Print parameters, if any.
945 if (is_function_scope()) { 947 if (is_function_scope()) {
946 PrintF(" ("); 948 PrintF(" (");
947 for (int i = 0; i < params_.length(); i++) { 949 for (int i = 0; i < params_.length(); i++) {
948 if (i > 0) PrintF(", "); 950 if (i > 0) PrintF(", ");
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 function_ != NULL && function_->proxy()->var()->IsContextSlot(); 1647 function_ != NULL && function_->proxy()->var()->IsContextSlot();
1646 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1648 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1647 (is_function_var_in_context ? 1 : 0); 1649 (is_function_var_in_context ? 1 : 0);
1648 } 1650 }
1649 1651
1650 1652
1651 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1653 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1652 1654
1653 } // namespace internal 1655 } // namespace internal
1654 } // namespace v8 1656 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698