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/ast/scopes.h" | 5 #include "src/ast/scopes.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/ast/scopeinfo.h" | 8 #include "src/ast/scopeinfo.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 Handle<String> name = proxy->name(); | 809 Handle<String> name = proxy->name(); |
810 non_locals = StringSet::Add(non_locals, name); | 810 non_locals = StringSet::Add(non_locals, name); |
811 } | 811 } |
812 for (int i = 0; i < inner_scopes_.length(); i++) { | 812 for (int i = 0; i < inner_scopes_.length(); i++) { |
813 non_locals = inner_scopes_[i]->CollectNonLocals(non_locals); | 813 non_locals = inner_scopes_[i]->CollectNonLocals(non_locals); |
814 } | 814 } |
815 return non_locals; | 815 return non_locals; |
816 } | 816 } |
817 | 817 |
818 | 818 |
819 void Scope::ReportMessage(int start_position, int end_position, | |
820 MessageTemplate::Template message, | |
821 const AstRawString* arg) { | |
822 // Propagate the error to the topmost scope targeted by this scope analysis | |
823 // phase. | |
824 Scope* top = this; | |
825 while (!top->is_script_scope() && !top->outer_scope()->already_resolved()) { | |
826 top = top->outer_scope(); | |
827 } | |
828 | |
829 top->pending_error_handler_.ReportMessageAt(start_position, end_position, | |
830 message, arg, kReferenceError); | |
831 } | |
832 | |
833 | |
834 #ifdef DEBUG | 819 #ifdef DEBUG |
835 static const char* Header(ScopeType scope_type, FunctionKind function_kind, | 820 static const char* Header(ScopeType scope_type, FunctionKind function_kind, |
836 bool is_declaration_scope) { | 821 bool is_declaration_scope) { |
837 switch (scope_type) { | 822 switch (scope_type) { |
838 case EVAL_SCOPE: return "eval"; | 823 case EVAL_SCOPE: return "eval"; |
839 // TODO(adamk): Should we print concise method scopes specially? | 824 // TODO(adamk): Should we print concise method scopes specially? |
840 case FUNCTION_SCOPE: | 825 case FUNCTION_SCOPE: |
841 return IsArrowFunction(function_kind) ? "arrow" : "function"; | 826 return IsArrowFunction(function_kind) ? "arrow" : "function"; |
842 case MODULE_SCOPE: return "module"; | 827 case MODULE_SCOPE: return "module"; |
843 case SCRIPT_SCOPE: return "global"; | 828 case SCRIPT_SCOPE: return "global"; |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1529 function_ != NULL && function_->proxy()->var()->IsContextSlot(); | 1514 function_ != NULL && function_->proxy()->var()->IsContextSlot(); |
1530 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 1515 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - |
1531 (is_function_var_in_context ? 1 : 0); | 1516 (is_function_var_in_context ? 1 : 0); |
1532 } | 1517 } |
1533 | 1518 |
1534 | 1519 |
1535 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 1520 int Scope::ContextGlobalCount() const { return num_global_slots(); } |
1536 | 1521 |
1537 } // namespace internal | 1522 } // namespace internal |
1538 } // namespace v8 | 1523 } // namespace v8 |
OLD | NEW |