| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 Handle<FixedArray> details = | 128 Handle<FixedArray> details = |
| 129 isolate_->factory()->NewFixedArray(kScopeDetailsSize); | 129 isolate_->factory()->NewFixedArray(kScopeDetailsSize); |
| 130 // Fill in scope details. | 130 // Fill in scope details. |
| 131 details->set(kScopeDetailsTypeIndex, Smi::FromInt(Type())); | 131 details->set(kScopeDetailsTypeIndex, Smi::FromInt(Type())); |
| 132 Handle<JSObject> scope_object; | 132 Handle<JSObject> scope_object; |
| 133 ASSIGN_RETURN_ON_EXCEPTION(isolate_, scope_object, ScopeObject(), JSObject); | 133 ASSIGN_RETURN_ON_EXCEPTION(isolate_, scope_object, ScopeObject(), JSObject); |
| 134 details->set(kScopeDetailsObjectIndex, *scope_object); | 134 details->set(kScopeDetailsObjectIndex, *scope_object); |
| 135 Handle<JSFunction> js_function = HasContext() | 135 Handle<JSFunction> js_function = HasContext() |
| 136 ? handle(CurrentContext()->closure()) | 136 ? handle(CurrentContext()->closure()) |
| 137 : Handle<JSFunction>::null(); | 137 : Handle<JSFunction>::null(); |
| 138 if (!js_function.is_null()) { | |
| 139 Handle<String> closure_name = JSFunction::GetDebugName(js_function); | |
| 140 if (!closure_name.is_null() && (closure_name->length() != 0)) | |
| 141 details->set(kScopeDetailsNameIndex, *closure_name); | |
| 142 } | |
| 143 if (Type() == ScopeTypeGlobal || Type() == ScopeTypeScript) { | 138 if (Type() == ScopeTypeGlobal || Type() == ScopeTypeScript) { |
| 144 return isolate_->factory()->NewJSArrayWithElements(details); | 139 return isolate_->factory()->NewJSArrayWithElements(details); |
| 145 } | 140 } |
| 146 | 141 |
| 147 int start_position = 0; | 142 int start_position = 0; |
| 148 int end_position = 0; | 143 int end_position = 0; |
| 149 if (!nested_scope_chain_.is_empty()) { | 144 if (!nested_scope_chain_.is_empty()) { |
| 150 js_function = GetFunction(); | 145 js_function = GetFunction(); |
| 151 start_position = nested_scope_chain_.last().start_position; | 146 start_position = nested_scope_chain_.last().start_position; |
| 152 end_position = nested_scope_chain_.last().end_position; | 147 end_position = nested_scope_chain_.last().end_position; |
| 153 } else if (!js_function.is_null()) { | 148 } else if (!js_function.is_null()) { |
| 154 start_position = js_function->shared()->start_position(); | 149 start_position = js_function->shared()->start_position(); |
| 155 end_position = js_function->shared()->end_position(); | 150 end_position = js_function->shared()->end_position(); |
| 156 } | 151 } |
| 157 | 152 |
| 158 if (!js_function.is_null()) { | 153 if (!js_function.is_null()) { |
| 154 Handle<String> closure_name = JSFunction::GetDebugName(js_function); |
| 155 if (!closure_name.is_null() && closure_name->length() != 0) { |
| 156 details->set(kScopeDetailsNameIndex, *closure_name); |
| 157 } |
| 159 details->set(kScopeDetailsStartPositionIndex, Smi::FromInt(start_position)); | 158 details->set(kScopeDetailsStartPositionIndex, Smi::FromInt(start_position)); |
| 160 details->set(kScopeDetailsEndPositionIndex, Smi::FromInt(end_position)); | 159 details->set(kScopeDetailsEndPositionIndex, Smi::FromInt(end_position)); |
| 161 details->set(kScopeDetailsFunctionIndex, *js_function); | 160 details->set(kScopeDetailsFunctionIndex, *js_function); |
| 162 } | 161 } |
| 163 return isolate_->factory()->NewJSArrayWithElements(details); | 162 return isolate_->factory()->NewJSArrayWithElements(details); |
| 164 } | 163 } |
| 165 | 164 |
| 166 | 165 |
| 167 void ScopeIterator::Next() { | 166 void ScopeIterator::Next() { |
| 168 DCHECK(!failed_); | 167 DCHECK(!failed_); |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 DCHECK(beg_pos >= 0 && end_pos >= 0); | 853 DCHECK(beg_pos >= 0 && end_pos >= 0); |
| 855 if (beg_pos <= position && position < end_pos) { | 854 if (beg_pos <= position && position < end_pos) { |
| 856 GetNestedScopeChain(isolate, inner_scope, position); | 855 GetNestedScopeChain(isolate, inner_scope, position); |
| 857 return; | 856 return; |
| 858 } | 857 } |
| 859 } | 858 } |
| 860 } | 859 } |
| 861 | 860 |
| 862 } // namespace internal | 861 } // namespace internal |
| 863 } // namespace v8 | 862 } // namespace v8 |
| OLD | NEW |