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/scopeinfo.h" | 7 #include "src/ast/scopeinfo.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1850 Handle<JSArray> LiveEditFunctionTracker::Collect(FunctionLiteral* node, | 1850 Handle<JSArray> LiveEditFunctionTracker::Collect(FunctionLiteral* node, |
1851 Handle<Script> script, | 1851 Handle<Script> script, |
1852 Zone* zone, Isolate* isolate) { | 1852 Zone* zone, Isolate* isolate) { |
1853 LiveEditFunctionTracker visitor(script, zone, isolate); | 1853 LiveEditFunctionTracker visitor(script, zone, isolate); |
1854 visitor.VisitFunctionLiteral(node); | 1854 visitor.VisitFunctionLiteral(node); |
1855 return visitor.result_; | 1855 return visitor.result_; |
1856 } | 1856 } |
1857 | 1857 |
1858 LiveEditFunctionTracker::LiveEditFunctionTracker(Handle<Script> script, | 1858 LiveEditFunctionTracker::LiveEditFunctionTracker(Handle<Script> script, |
1859 Zone* zone, Isolate* isolate) | 1859 Zone* zone, Isolate* isolate) |
1860 : AstTraversalVisitor(isolate) { | 1860 : AstTraversalVisitor<LiveEditFunctionTracker>(isolate) { |
1861 current_parent_index_ = -1; | 1861 current_parent_index_ = -1; |
1862 isolate_ = isolate; | 1862 isolate_ = isolate; |
1863 len_ = 0; | 1863 len_ = 0; |
1864 result_ = isolate->factory()->NewJSArray(10); | 1864 result_ = isolate->factory()->NewJSArray(10); |
1865 script_ = script; | 1865 script_ = script; |
1866 zone_ = zone; | 1866 zone_ = zone; |
1867 } | 1867 } |
1868 | 1868 |
1869 void LiveEditFunctionTracker::VisitFunctionLiteral(FunctionLiteral* node) { | 1869 void LiveEditFunctionTracker::VisitFunctionLiteral(FunctionLiteral* node) { |
1870 Scope* scope = node->scope(); | |
1871 | |
1872 // FunctionStarted is called in pre-order. | 1870 // FunctionStarted is called in pre-order. |
1873 FunctionStarted(node); | 1871 FunctionStarted(node); |
1874 | 1872 // Recurse using the regular traversal. |
1875 VisitDeclarations(scope->declarations()); | 1873 AstTraversalVisitor::VisitFunctionLiteral(node); |
1876 VisitStatements(node->body()); | |
1877 | |
1878 // FunctionDone are called in post-order. | 1874 // FunctionDone are called in post-order. |
1879 // TODO(jgruber): If required, replace the (linear cost) | 1875 // TODO(jgruber): If required, replace the (linear cost) |
1880 // FindSharedFunctionInfo call with a more efficient implementation. | 1876 // FindSharedFunctionInfo call with a more efficient implementation. |
1881 Handle<SharedFunctionInfo> info = | 1877 Handle<SharedFunctionInfo> info = |
1882 script_->FindSharedFunctionInfo(node).ToHandleChecked(); | 1878 script_->FindSharedFunctionInfo(node).ToHandleChecked(); |
1883 FunctionDone(info, scope); | 1879 FunctionDone(info, node->scope()); |
1884 } | 1880 } |
1885 | 1881 |
1886 void LiveEditFunctionTracker::FunctionStarted(FunctionLiteral* fun) { | 1882 void LiveEditFunctionTracker::FunctionStarted(FunctionLiteral* fun) { |
1887 HandleScope handle_scope(isolate_); | 1883 HandleScope handle_scope(isolate_); |
1888 FunctionInfoWrapper info = FunctionInfoWrapper::Create(isolate_); | 1884 FunctionInfoWrapper info = FunctionInfoWrapper::Create(isolate_); |
1889 info.SetInitialProperties(fun->name(), fun->start_position(), | 1885 info.SetInitialProperties(fun->name(), fun->start_position(), |
1890 fun->end_position(), fun->parameter_count(), | 1886 fun->end_position(), fun->parameter_count(), |
1891 fun->materialized_literal_count(), | 1887 fun->materialized_literal_count(), |
1892 current_parent_index_); | 1888 current_parent_index_); |
1893 current_parent_index_ = len_; | 1889 current_parent_index_ = len_; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1945 scope_info_length++; | 1941 scope_info_length++; |
1946 | 1942 |
1947 current_scope = current_scope->outer_scope(); | 1943 current_scope = current_scope->outer_scope(); |
1948 } | 1944 } |
1949 | 1945 |
1950 return scope_info_list; | 1946 return scope_info_list; |
1951 } | 1947 } |
1952 | 1948 |
1953 } // namespace internal | 1949 } // namespace internal |
1954 } // namespace v8 | 1950 } // namespace v8 |
OLD | NEW |