OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/debug/debug-scopes.h" | 5 #include "src/debug/debug-scopes.h" |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
9 #include "src/frames-inl.h" | 9 #include "src/frames-inl.h" |
10 #include "src/globals.h" | 10 #include "src/globals.h" |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 // Optimized frames are not supported. | 636 // Optimized frames are not supported. |
637 if (frame->is_optimized()) return false; | 637 if (frame->is_optimized()) return false; |
638 | 638 |
639 Handle<JSFunction> function(frame->function()); | 639 Handle<JSFunction> function(frame->function()); |
640 Handle<SharedFunctionInfo> shared(function->shared()); | 640 Handle<SharedFunctionInfo> shared(function->shared()); |
641 Handle<ScopeInfo> scope_info(shared->scope_info()); | 641 Handle<ScopeInfo> scope_info(shared->scope_info()); |
642 | 642 |
643 bool default_result = false; | 643 bool default_result = false; |
644 | 644 |
645 // Parameters. | 645 // Parameters. |
646 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 646 FOR_WITH_HANDLE_SCOPE( |
647 HandleScope scope(isolate_); | 647 isolate_, int, i = 0, i, i < scope_info->ParameterCount(), ++i, { |
648 if (String::Equals(handle(scope_info->ParameterName(i)), variable_name)) { | 648 if (String::Equals(handle(scope_info->ParameterName(i)), |
649 frame->SetParameterValue(i, *new_value); | 649 variable_name)) { |
650 // Argument might be shadowed in heap context, don't stop here. | 650 frame->SetParameterValue(i, *new_value); |
651 default_result = true; | 651 // Argument might be shadowed in heap context, don't stop here. |
652 } | 652 default_result = true; |
653 } | 653 } |
| 654 }); |
654 | 655 |
655 // Stack locals. | 656 // Stack locals. |
656 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 657 FOR_WITH_HANDLE_SCOPE( |
657 HandleScope scope(isolate_); | 658 isolate_, int, i = 0, i, i < scope_info->StackLocalCount(), ++i, { |
658 if (String::Equals(handle(scope_info->StackLocalName(i)), variable_name)) { | 659 if (String::Equals(handle(scope_info->StackLocalName(i)), |
659 frame->SetExpression(scope_info->StackLocalIndex(i), *new_value); | 660 variable_name)) { |
660 return true; | 661 frame->SetExpression(scope_info->StackLocalIndex(i), *new_value); |
661 } | 662 return true; |
662 } | 663 } |
| 664 }); |
663 | 665 |
664 if (scope_info->HasContext()) { | 666 if (scope_info->HasContext()) { |
665 // Context locals. | 667 // Context locals. |
666 Handle<Context> frame_context(Context::cast(frame->context())); | 668 Handle<Context> frame_context(Context::cast(frame->context())); |
667 Handle<Context> function_context(frame_context->declaration_context()); | 669 Handle<Context> function_context(frame_context->declaration_context()); |
668 if (SetContextLocalValue(scope_info, function_context, variable_name, | 670 if (SetContextLocalValue(scope_info, function_context, variable_name, |
669 new_value)) { | 671 new_value)) { |
670 return true; | 672 return true; |
671 } | 673 } |
672 | 674 |
(...skipping 19 matching lines...) Expand all Loading... |
692 | 694 |
693 return default_result; | 695 return default_result; |
694 } | 696 } |
695 | 697 |
696 | 698 |
697 bool ScopeIterator::SetBlockVariableValue(Handle<String> variable_name, | 699 bool ScopeIterator::SetBlockVariableValue(Handle<String> variable_name, |
698 Handle<Object> new_value) { | 700 Handle<Object> new_value) { |
699 Handle<ScopeInfo> scope_info = CurrentScopeInfo(); | 701 Handle<ScopeInfo> scope_info = CurrentScopeInfo(); |
700 JavaScriptFrame* frame = GetFrame(); | 702 JavaScriptFrame* frame = GetFrame(); |
701 | 703 |
702 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 704 FOR_WITH_HANDLE_SCOPE( |
703 HandleScope scope(isolate_); | 705 isolate_, int, i = 0, i, i < scope_info->StackLocalCount(), ++i, { |
704 if (String::Equals(handle(scope_info->StackLocalName(i)), variable_name)) { | 706 HandleScope scope(isolate_); |
705 frame->SetExpression(scope_info->StackLocalIndex(i), *new_value); | 707 if (String::Equals(handle(scope_info->StackLocalName(i)), |
706 return true; | 708 variable_name)) { |
707 } | 709 frame->SetExpression(scope_info->StackLocalIndex(i), *new_value); |
708 } | 710 return true; |
| 711 } |
| 712 }); |
709 | 713 |
710 if (HasContext()) { | 714 if (HasContext()) { |
711 Handle<Context> context = CurrentContext(); | 715 Handle<Context> context = CurrentContext(); |
712 if (SetContextLocalValue(scope_info, context, variable_name, new_value)) { | 716 if (SetContextLocalValue(scope_info, context, variable_name, new_value)) { |
713 return true; | 717 return true; |
714 } | 718 } |
715 | 719 |
716 Handle<JSObject> ext(context->extension_object(), isolate_); | 720 Handle<JSObject> ext(context->extension_object(), isolate_); |
717 if (!ext.is_null()) { | 721 if (!ext.is_null()) { |
718 Maybe<bool> maybe = JSReceiver::HasOwnProperty(ext, variable_name); | 722 Maybe<bool> maybe = JSReceiver::HasOwnProperty(ext, variable_name); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 DCHECK(beg_pos >= 0 && end_pos >= 0); | 858 DCHECK(beg_pos >= 0 && end_pos >= 0); |
855 if (beg_pos <= position && position < end_pos) { | 859 if (beg_pos <= position && position < end_pos) { |
856 GetNestedScopeChain(isolate, inner_scope, position); | 860 GetNestedScopeChain(isolate, inner_scope, position); |
857 return; | 861 return; |
858 } | 862 } |
859 } | 863 } |
860 } | 864 } |
861 | 865 |
862 } // namespace internal | 866 } // namespace internal |
863 } // namespace v8 | 867 } // namespace v8 |
OLD | NEW |