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 #ifndef V8_DEBUG_DEBUG_SCOPES_H_ | 5 #ifndef V8_DEBUG_DEBUG_SCOPES_H_ |
6 #define V8_DEBUG_DEBUG_SCOPES_H_ | 6 #define V8_DEBUG_DEBUG_SCOPES_H_ |
7 | 7 |
8 #include "src/debug/debug-frames.h" | 8 #include "src/debug/debug-frames.h" |
9 #include "src/frames.h" | 9 #include "src/frames.h" |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 static const int kScopeDetailsFunctionIndex = 5; | 36 static const int kScopeDetailsFunctionIndex = 5; |
37 static const int kScopeDetailsSize = 6; | 37 static const int kScopeDetailsSize = 6; |
38 | 38 |
39 enum Option { DEFAULT, IGNORE_NESTED_SCOPES, COLLECT_NON_LOCALS }; | 39 enum Option { DEFAULT, IGNORE_NESTED_SCOPES, COLLECT_NON_LOCALS }; |
40 | 40 |
41 ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, | 41 ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, |
42 Option options = DEFAULT); | 42 Option options = DEFAULT); |
43 | 43 |
44 ScopeIterator(Isolate* isolate, Handle<JSFunction> function); | 44 ScopeIterator(Isolate* isolate, Handle<JSFunction> function); |
45 | 45 |
46 ~ScopeIterator() { delete non_locals_; } | |
47 | |
48 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeScopeDetails(); | 46 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeScopeDetails(); |
49 | 47 |
50 // More scopes? | 48 // More scopes? |
51 bool Done() { | 49 bool Done() { |
52 DCHECK(!failed_); | 50 DCHECK(!failed_); |
53 return context_.is_null(); | 51 return context_.is_null(); |
54 } | 52 } |
55 | 53 |
56 bool Failed() { return failed_; } | 54 bool Failed() { return failed_; } |
57 | 55 |
(...skipping 10 matching lines...) Expand all Loading... |
68 | 66 |
69 // Set variable value and return true on success. | 67 // Set variable value and return true on success. |
70 bool SetVariableValue(Handle<String> variable_name, Handle<Object> new_value); | 68 bool SetVariableValue(Handle<String> variable_name, Handle<Object> new_value); |
71 | 69 |
72 Handle<ScopeInfo> CurrentScopeInfo(); | 70 Handle<ScopeInfo> CurrentScopeInfo(); |
73 | 71 |
74 // Return the context for this scope. For the local context there might not | 72 // Return the context for this scope. For the local context there might not |
75 // be an actual context. | 73 // be an actual context. |
76 Handle<Context> CurrentContext(); | 74 Handle<Context> CurrentContext(); |
77 | 75 |
78 // Populate the list with collected non-local variable names. | 76 // Populate the set with collected non-local variable names. |
79 void GetNonLocals(List<Handle<String> >* list_out); | 77 Handle<StringSet> GetNonLocals(); |
80 | |
81 bool ThisIsNonLocal(); | |
82 | 78 |
83 #ifdef DEBUG | 79 #ifdef DEBUG |
84 // Debug print of the content of the current scope. | 80 // Debug print of the content of the current scope. |
85 void DebugPrint(); | 81 void DebugPrint(); |
86 #endif | 82 #endif |
87 | 83 |
88 private: | 84 private: |
89 struct ExtendedScopeInfo { | 85 struct ExtendedScopeInfo { |
90 ExtendedScopeInfo(Handle<ScopeInfo> info, int start, int end) | 86 ExtendedScopeInfo(Handle<ScopeInfo> info, int start, int end) |
91 : scope_info(info), start_position(start), end_position(end) {} | 87 : scope_info(info), start_position(start), end_position(end) {} |
92 Handle<ScopeInfo> scope_info; | 88 Handle<ScopeInfo> scope_info; |
93 int start_position; | 89 int start_position; |
94 int end_position; | 90 int end_position; |
95 }; | 91 }; |
96 | 92 |
97 Isolate* isolate_; | 93 Isolate* isolate_; |
98 FrameInspector* const frame_inspector_; | 94 FrameInspector* const frame_inspector_; |
99 Handle<Context> context_; | 95 Handle<Context> context_; |
100 List<ExtendedScopeInfo> nested_scope_chain_; | 96 List<ExtendedScopeInfo> nested_scope_chain_; |
101 HashMap* non_locals_; | 97 Handle<StringSet> non_locals_; |
102 bool seen_script_scope_; | 98 bool seen_script_scope_; |
103 bool failed_; | 99 bool failed_; |
104 | 100 |
105 inline JavaScriptFrame* GetFrame() { | 101 inline JavaScriptFrame* GetFrame() { |
106 return frame_inspector_->GetArgumentsFrame(); | 102 return frame_inspector_->GetArgumentsFrame(); |
107 } | 103 } |
108 | 104 |
109 inline Handle<JSFunction> GetFunction() { | 105 inline Handle<JSFunction> GetFunction() { |
110 return Handle<JSFunction>::cast(frame_inspector_->GetFunction()); | 106 return Handle<JSFunction>::cast(frame_inspector_->GetFunction()); |
111 } | 107 } |
112 | 108 |
113 static bool InternalizedStringMatch(void* key1, void* key2) { | |
114 Handle<String> s1(reinterpret_cast<String**>(key1)); | |
115 Handle<String> s2(reinterpret_cast<String**>(key2)); | |
116 DCHECK(s1->IsInternalizedString()); | |
117 DCHECK(s2->IsInternalizedString()); | |
118 return s1.is_identical_to(s2); | |
119 } | |
120 | |
121 void RetrieveScopeChain(Scope* scope); | 109 void RetrieveScopeChain(Scope* scope); |
122 | 110 |
123 void CollectNonLocals(Scope* scope); | 111 void CollectNonLocals(Scope* scope); |
124 | 112 |
125 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeScriptScope(); | 113 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeScriptScope(); |
126 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeLocalScope(); | 114 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeLocalScope(); |
127 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeModuleScope(); | 115 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeModuleScope(); |
128 Handle<JSObject> MaterializeClosure(); | 116 Handle<JSObject> MaterializeClosure(); |
129 Handle<JSObject> MaterializeCatchScope(); | 117 Handle<JSObject> MaterializeCatchScope(); |
130 Handle<JSObject> MaterializeBlockScope(); | 118 Handle<JSObject> MaterializeBlockScope(); |
(...skipping 27 matching lines...) Expand all Loading... |
158 void GetNestedScopeChain(Isolate* isolate, Scope* scope, | 146 void GetNestedScopeChain(Isolate* isolate, Scope* scope, |
159 int statement_position); | 147 int statement_position); |
160 | 148 |
161 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); | 149 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); |
162 }; | 150 }; |
163 | 151 |
164 } // namespace internal | 152 } // namespace internal |
165 } // namespace v8 | 153 } // namespace v8 |
166 | 154 |
167 #endif // V8_DEBUG_DEBUG_SCOPES_H_ | 155 #endif // V8_DEBUG_DEBUG_SCOPES_H_ |
OLD | NEW |