| 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/debug/liveedit.h" | 5 #include "src/debug/liveedit.h" |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/compilation-cache.h" | 9 #include "src/compilation-cache.h" |
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| (...skipping 1882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1893 Handle<Object> LiveEditFunctionTracker::SerializeFunctionScope(Scope* scope) { | 1893 Handle<Object> LiveEditFunctionTracker::SerializeFunctionScope(Scope* scope) { |
| 1894 Handle<JSArray> scope_info_list = isolate_->factory()->NewJSArray(10); | 1894 Handle<JSArray> scope_info_list = isolate_->factory()->NewJSArray(10); |
| 1895 int scope_info_length = 0; | 1895 int scope_info_length = 0; |
| 1896 | 1896 |
| 1897 // Saves some description of scope. It stores name and indexes of | 1897 // Saves some description of scope. It stores name and indexes of |
| 1898 // variables in the whole scope chain. Null-named slots delimit | 1898 // variables in the whole scope chain. Null-named slots delimit |
| 1899 // scopes of this chain. | 1899 // scopes of this chain. |
| 1900 Scope* current_scope = scope; | 1900 Scope* current_scope = scope; |
| 1901 while (current_scope != NULL) { | 1901 while (current_scope != NULL) { |
| 1902 HandleScope handle_scope(isolate_); | 1902 HandleScope handle_scope(isolate_); |
| 1903 ZoneList<Variable*> stack_list(current_scope->StackLocalCount(), zone_); | 1903 ZoneList<Variable*>* locals = current_scope->locals(); |
| 1904 ZoneList<Variable*> context_list(current_scope->ContextLocalCount(), zone_); | 1904 for (int i = 0; i < locals->length(); i++) { |
| 1905 ZoneList<Variable*> globals_list(current_scope->ContextGlobalCount(), | 1905 Variable* var = locals->at(i); |
| 1906 zone_); | 1906 if (!var->IsContextSlot()) continue; |
| 1907 current_scope->CollectVariables(&stack_list, &context_list, &globals_list); | 1907 int context_index = var->index() - Context::MIN_CONTEXT_SLOTS; |
| 1908 for (int i = 0; i < context_list.length(); i++) { | |
| 1909 int context_index = context_list[i]->index() - Context::MIN_CONTEXT_SLOTS; | |
| 1910 int location = scope_info_length + context_index * 2; | 1908 int location = scope_info_length + context_index * 2; |
| 1911 SetElementSloppy(scope_info_list, location, context_list[i]->name()); | 1909 SetElementSloppy(scope_info_list, location, var->name()); |
| 1912 SetElementSloppy( | 1910 SetElementSloppy(scope_info_list, location + 1, |
| 1913 scope_info_list, location + 1, | 1911 handle(Smi::FromInt(var->index()), isolate_)); |
| 1914 handle(Smi::FromInt(context_list[i]->index()), isolate_)); | |
| 1915 } | 1912 } |
| 1916 scope_info_length += context_list.length() * 2; | 1913 scope_info_length += current_scope->ContextLocalCount() * 2; |
| 1917 SetElementSloppy(scope_info_list, scope_info_length, | 1914 SetElementSloppy(scope_info_list, scope_info_length, |
| 1918 Handle<Object>(isolate_->heap()->null_value(), isolate_)); | 1915 isolate_->factory()->null_value()); |
| 1919 scope_info_length++; | 1916 scope_info_length++; |
| 1920 | 1917 |
| 1921 current_scope = current_scope->outer_scope(); | 1918 current_scope = current_scope->outer_scope(); |
| 1922 } | 1919 } |
| 1923 | 1920 |
| 1924 return scope_info_list; | 1921 return scope_info_list; |
| 1925 } | 1922 } |
| 1926 | 1923 |
| 1927 } // namespace internal | 1924 } // namespace internal |
| 1928 } // namespace v8 | 1925 } // namespace v8 |
| OLD | NEW |