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 15 matching lines...) Expand all Loading... |
26 ScopeTypeBlock, | 26 ScopeTypeBlock, |
27 ScopeTypeScript, | 27 ScopeTypeScript, |
28 ScopeTypeModule | 28 ScopeTypeModule |
29 }; | 29 }; |
30 | 30 |
31 static const int kScopeDetailsTypeIndex = 0; | 31 static const int kScopeDetailsTypeIndex = 0; |
32 static const int kScopeDetailsObjectIndex = 1; | 32 static const int kScopeDetailsObjectIndex = 1; |
33 static const int kScopeDetailsNameIndex = 2; | 33 static const int kScopeDetailsNameIndex = 2; |
34 static const int kScopeDetailsSize = 3; | 34 static const int kScopeDetailsSize = 3; |
35 | 35 |
| 36 enum Option { DEFAULT, IGNORE_NESTED_SCOPES, COLLECT_NON_LOCALS }; |
| 37 |
36 ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, | 38 ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, |
37 bool ignore_nested_scopes = false); | 39 Option options = DEFAULT); |
38 | 40 |
39 ScopeIterator(Isolate* isolate, Handle<JSFunction> function); | 41 ScopeIterator(Isolate* isolate, Handle<JSFunction> function); |
40 | 42 |
| 43 ~ScopeIterator() { delete non_locals_; } |
| 44 |
41 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeScopeDetails(); | 45 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeScopeDetails(); |
42 | 46 |
43 // More scopes? | 47 // More scopes? |
44 bool Done() { | 48 bool Done() { |
45 DCHECK(!failed_); | 49 DCHECK(!failed_); |
46 return context_.is_null(); | 50 return context_.is_null(); |
47 } | 51 } |
48 | 52 |
49 bool Failed() { return failed_; } | 53 bool Failed() { return failed_; } |
50 | 54 |
(...skipping 10 matching lines...) Expand all Loading... |
61 | 65 |
62 // Set variable value and return true on success. | 66 // Set variable value and return true on success. |
63 bool SetVariableValue(Handle<String> variable_name, Handle<Object> new_value); | 67 bool SetVariableValue(Handle<String> variable_name, Handle<Object> new_value); |
64 | 68 |
65 Handle<ScopeInfo> CurrentScopeInfo(); | 69 Handle<ScopeInfo> CurrentScopeInfo(); |
66 | 70 |
67 // Return the context for this scope. For the local context there might not | 71 // Return the context for this scope. For the local context there might not |
68 // be an actual context. | 72 // be an actual context. |
69 Handle<Context> CurrentContext(); | 73 Handle<Context> CurrentContext(); |
70 | 74 |
| 75 // Populate the list with collected non-local variable names. |
| 76 void GetNonLocals(List<Handle<String> >* list_out); |
| 77 |
| 78 bool ThisIsNonLocal(); |
| 79 |
71 #ifdef DEBUG | 80 #ifdef DEBUG |
72 // Debug print of the content of the current scope. | 81 // Debug print of the content of the current scope. |
73 void DebugPrint(); | 82 void DebugPrint(); |
74 #endif | 83 #endif |
75 | 84 |
76 private: | 85 private: |
77 Isolate* isolate_; | 86 Isolate* isolate_; |
78 FrameInspector* const frame_inspector_; | 87 FrameInspector* const frame_inspector_; |
79 Handle<Context> context_; | 88 Handle<Context> context_; |
80 List<Handle<ScopeInfo> > nested_scope_chain_; | 89 List<Handle<ScopeInfo> > nested_scope_chain_; |
| 90 HashMap* non_locals_; |
81 bool seen_script_scope_; | 91 bool seen_script_scope_; |
82 bool failed_; | 92 bool failed_; |
83 | 93 |
84 inline JavaScriptFrame* GetFrame() { | 94 inline JavaScriptFrame* GetFrame() { |
85 return frame_inspector_->GetArgumentsFrame(); | 95 return frame_inspector_->GetArgumentsFrame(); |
86 } | 96 } |
87 | 97 |
88 inline Handle<JSFunction> GetFunction() { | 98 inline Handle<JSFunction> GetFunction() { |
89 return Handle<JSFunction>( | 99 return Handle<JSFunction>( |
90 JSFunction::cast(frame_inspector_->GetFunction())); | 100 JSFunction::cast(frame_inspector_->GetFunction())); |
91 } | 101 } |
92 | 102 |
93 void RetrieveScopeChain(Scope* scope, Handle<SharedFunctionInfo> shared_info); | 103 static bool InternalizedStringMatch(void* key1, void* key2) { |
| 104 Handle<String> s1(reinterpret_cast<String**>(key1)); |
| 105 Handle<String> s2(reinterpret_cast<String**>(key2)); |
| 106 DCHECK(s1->IsInternalizedString()); |
| 107 DCHECK(s2->IsInternalizedString()); |
| 108 return s1.is_identical_to(s2); |
| 109 } |
| 110 |
| 111 void RetrieveScopeChain(Scope* scope); |
| 112 |
| 113 void CollectNonLocals(Scope* scope); |
94 | 114 |
95 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeScriptScope(); | 115 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeScriptScope(); |
96 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeLocalScope(); | 116 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeLocalScope(); |
97 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeModuleScope(); | 117 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeModuleScope(); |
98 Handle<JSObject> MaterializeClosure(); | 118 Handle<JSObject> MaterializeClosure(); |
99 Handle<JSObject> MaterializeCatchScope(); | 119 Handle<JSObject> MaterializeCatchScope(); |
100 Handle<JSObject> MaterializeBlockScope(); | 120 Handle<JSObject> MaterializeBlockScope(); |
101 | 121 |
102 bool SetLocalVariableValue(Handle<String> variable_name, | 122 bool SetLocalVariableValue(Handle<String> variable_name, |
103 Handle<Object> new_value); | 123 Handle<Object> new_value); |
(...skipping 17 matching lines...) Expand all Loading... |
121 Handle<JSObject> scope_object, | 141 Handle<JSObject> scope_object, |
122 JSReceiver::KeyCollectionType type); | 142 JSReceiver::KeyCollectionType type); |
123 | 143 |
124 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); | 144 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); |
125 }; | 145 }; |
126 | 146 |
127 } // namespace internal | 147 } // namespace internal |
128 } // namespace v8 | 148 } // namespace v8 |
129 | 149 |
130 #endif // V8_DEBUG_DEBUG_SCOPES_H_ | 150 #endif // V8_DEBUG_DEBUG_SCOPES_H_ |
OLD | NEW |