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 <memory> |
| 8 |
7 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
8 #include "src/compiler.h" | 10 #include "src/compiler.h" |
9 #include "src/debug/debug.h" | 11 #include "src/debug/debug.h" |
10 #include "src/frames-inl.h" | 12 #include "src/frames-inl.h" |
11 #include "src/globals.h" | 13 #include "src/globals.h" |
12 #include "src/isolate-inl.h" | 14 #include "src/isolate-inl.h" |
13 #include "src/parsing/parser.h" | 15 #include "src/parsing/parser.h" |
14 | 16 |
15 namespace v8 { | 17 namespace v8 { |
16 namespace internal { | 18 namespace internal { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 nested_scope_chain_.Add(ExtendedScopeInfo(scope_info, | 80 nested_scope_chain_.Add(ExtendedScopeInfo(scope_info, |
79 shared_info->start_position(), | 81 shared_info->start_position(), |
80 shared_info->end_position())); | 82 shared_info->end_position())); |
81 } | 83 } |
82 if (!collect_non_locals) return; | 84 if (!collect_non_locals) return; |
83 } | 85 } |
84 | 86 |
85 // Reparse the code and analyze the scopes. | 87 // Reparse the code and analyze the scopes. |
86 // Check whether we are in global, eval or function code. | 88 // Check whether we are in global, eval or function code. |
87 Zone zone(isolate->allocator()); | 89 Zone zone(isolate->allocator()); |
88 base::SmartPointer<ParseInfo> info; | 90 std::unique_ptr<ParseInfo> info; |
89 if (scope_info->scope_type() != FUNCTION_SCOPE) { | 91 if (scope_info->scope_type() != FUNCTION_SCOPE) { |
90 // Global or eval code. | 92 // Global or eval code. |
91 Handle<Script> script(Script::cast(shared_info->script())); | 93 Handle<Script> script(Script::cast(shared_info->script())); |
92 info.Reset(new ParseInfo(&zone, script)); | 94 info.reset(new ParseInfo(&zone, script)); |
93 info->set_toplevel(); | 95 info->set_toplevel(); |
94 if (scope_info->scope_type() == SCRIPT_SCOPE) { | 96 if (scope_info->scope_type() == SCRIPT_SCOPE) { |
95 info->set_global(); | 97 info->set_global(); |
96 } else { | 98 } else { |
97 DCHECK(scope_info->scope_type() == EVAL_SCOPE); | 99 DCHECK(scope_info->scope_type() == EVAL_SCOPE); |
98 info->set_eval(); | 100 info->set_eval(); |
99 info->set_context(Handle<Context>(function->context())); | 101 info->set_context(Handle<Context>(function->context())); |
100 // Language mode may be inherited from the eval caller. | 102 // Language mode may be inherited from the eval caller. |
101 // Retrieve it from shared function info. | 103 // Retrieve it from shared function info. |
102 info->set_language_mode(shared_info->language_mode()); | 104 info->set_language_mode(shared_info->language_mode()); |
103 } | 105 } |
104 } else { | 106 } else { |
105 // Inner function. | 107 // Inner function. |
106 info.Reset(new ParseInfo(&zone, function)); | 108 info.reset(new ParseInfo(&zone, function)); |
107 } | 109 } |
108 Scope* scope = NULL; | 110 Scope* scope = NULL; |
109 if (Compiler::ParseAndAnalyze(info.get())) scope = info->literal()->scope(); | 111 if (Compiler::ParseAndAnalyze(info.get())) scope = info->literal()->scope(); |
110 if (!ignore_nested_scopes) RetrieveScopeChain(scope); | 112 if (!ignore_nested_scopes) RetrieveScopeChain(scope); |
111 if (collect_non_locals) CollectNonLocals(scope); | 113 if (collect_non_locals) CollectNonLocals(scope); |
112 UnwrapEvaluationContext(); | 114 UnwrapEvaluationContext(); |
113 } | 115 } |
114 | 116 |
115 | 117 |
116 ScopeIterator::ScopeIterator(Isolate* isolate, Handle<JSFunction> function) | 118 ScopeIterator::ScopeIterator(Isolate* isolate, Handle<JSFunction> function) |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden()); | 808 DCHECK((beg_pos >= 0 && end_pos >= 0) || inner_scope->is_hidden()); |
807 if (beg_pos <= position && position < end_pos) { | 809 if (beg_pos <= position && position < end_pos) { |
808 GetNestedScopeChain(isolate, inner_scope, position); | 810 GetNestedScopeChain(isolate, inner_scope, position); |
809 return; | 811 return; |
810 } | 812 } |
811 } | 813 } |
812 } | 814 } |
813 | 815 |
814 } // namespace internal | 816 } // namespace internal |
815 } // namespace v8 | 817 } // namespace v8 |
OLD | NEW |