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 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 DCHECK(beg_pos >= 0 && end_pos >= 0); | 788 DCHECK(beg_pos >= 0 && end_pos >= 0); |
789 if (beg_pos <= position && position < end_pos) { | 789 if (beg_pos <= position && position < end_pos) { |
790 scope->GetNestedScopeChain(isolate, chain, position); | 790 scope->GetNestedScopeChain(isolate, chain, position); |
791 return; | 791 return; |
792 } | 792 } |
793 } | 793 } |
794 } | 794 } |
795 | 795 |
796 | 796 |
797 void Scope::ReportMessage(int start_position, int end_position, | 797 void Scope::ReportMessage(int start_position, int end_position, |
798 const char* message, const AstRawString* arg) { | 798 MessageTemplate::Template message, |
| 799 const AstRawString* arg) { |
799 // Propagate the error to the topmost scope targeted by this scope analysis | 800 // Propagate the error to the topmost scope targeted by this scope analysis |
800 // phase. | 801 // phase. |
801 Scope* top = this; | 802 Scope* top = this; |
802 while (!top->is_script_scope() && !top->outer_scope()->already_resolved()) { | 803 while (!top->is_script_scope() && !top->outer_scope()->already_resolved()) { |
803 top = top->outer_scope(); | 804 top = top->outer_scope(); |
804 } | 805 } |
805 | 806 |
806 top->pending_error_handler_.ReportMessageAt(start_position, end_position, | 807 top->pending_error_handler_.ReportMessageAt(start_position, end_position, |
807 message, arg, kReferenceError); | 808 message, arg, kReferenceError); |
808 } | 809 } |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 // TODO(marja,rossberg): Detect errors across different evals (depends on the | 1213 // TODO(marja,rossberg): Detect errors across different evals (depends on the |
1213 // future of eval in strong mode). | 1214 // future of eval in strong mode). |
1214 const Scope* eval_for_use = NearestOuterEvalScope(); | 1215 const Scope* eval_for_use = NearestOuterEvalScope(); |
1215 const Scope* eval_for_declaration = var->scope()->NearestOuterEvalScope(); | 1216 const Scope* eval_for_declaration = var->scope()->NearestOuterEvalScope(); |
1216 | 1217 |
1217 if (proxy->position() != RelocInfo::kNoPosition && | 1218 if (proxy->position() != RelocInfo::kNoPosition && |
1218 proxy->position() < var->initializer_position() && !var->is_function() && | 1219 proxy->position() < var->initializer_position() && !var->is_function() && |
1219 eval_for_use == eval_for_declaration) { | 1220 eval_for_use == eval_for_declaration) { |
1220 DCHECK(proxy->end_position() != RelocInfo::kNoPosition); | 1221 DCHECK(proxy->end_position() != RelocInfo::kNoPosition); |
1221 ReportMessage(proxy->position(), proxy->end_position(), | 1222 ReportMessage(proxy->position(), proxy->end_position(), |
1222 "strong_use_before_declaration", proxy->raw_name()); | 1223 MessageTemplate::kStrongUseBeforeDeclaration, |
| 1224 proxy->raw_name()); |
1223 return false; | 1225 return false; |
1224 } | 1226 } |
1225 return true; | 1227 return true; |
1226 } | 1228 } |
1227 | 1229 |
1228 | 1230 |
1229 ClassVariable* Scope::ClassVariableForMethod() const { | 1231 ClassVariable* Scope::ClassVariableForMethod() const { |
1230 // TODO(marja, rossberg): This fails to find a class variable in the following | 1232 // TODO(marja, rossberg): This fails to find a class variable in the following |
1231 // cases: | 1233 // cases: |
1232 // let A = class { ... } | 1234 // let A = class { ... } |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0); | 1545 (function_ != NULL && function_->proxy()->var()->IsStackLocal() ? 1 : 0); |
1544 } | 1546 } |
1545 | 1547 |
1546 | 1548 |
1547 int Scope::ContextLocalCount() const { | 1549 int Scope::ContextLocalCount() const { |
1548 if (num_heap_slots() == 0) return 0; | 1550 if (num_heap_slots() == 0) return 0; |
1549 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1551 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1550 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); | 1552 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); |
1551 } | 1553 } |
1552 } } // namespace v8::internal | 1554 } } // namespace v8::internal |
OLD | NEW |