| 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 13 matching lines...) Expand all Loading... |
| 24 ScopeTypeClosure, | 24 ScopeTypeClosure, |
| 25 ScopeTypeCatch, | 25 ScopeTypeCatch, |
| 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 kScopeDetailsStartPositionIndex = 3; |
| 35 static const int kScopeDetailsEndPositionIndex = 4; |
| 36 static const int kScopeDetailsFunctionIndex = 5; |
| 37 static const int kScopeDetailsSize = 6; |
| 35 | 38 |
| 36 enum Option { DEFAULT, IGNORE_NESTED_SCOPES, COLLECT_NON_LOCALS }; | 39 enum Option { DEFAULT, IGNORE_NESTED_SCOPES, COLLECT_NON_LOCALS }; |
| 37 | 40 |
| 38 ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, | 41 ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, |
| 39 Option options = DEFAULT); | 42 Option options = DEFAULT); |
| 40 | 43 |
| 41 ScopeIterator(Isolate* isolate, Handle<JSFunction> function); | 44 ScopeIterator(Isolate* isolate, Handle<JSFunction> function); |
| 42 | 45 |
| 43 ~ScopeIterator() { delete non_locals_; } | 46 ~ScopeIterator() { delete non_locals_; } |
| 44 | 47 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 void GetNonLocals(List<Handle<String> >* list_out); | 79 void GetNonLocals(List<Handle<String> >* list_out); |
| 77 | 80 |
| 78 bool ThisIsNonLocal(); | 81 bool ThisIsNonLocal(); |
| 79 | 82 |
| 80 #ifdef DEBUG | 83 #ifdef DEBUG |
| 81 // Debug print of the content of the current scope. | 84 // Debug print of the content of the current scope. |
| 82 void DebugPrint(); | 85 void DebugPrint(); |
| 83 #endif | 86 #endif |
| 84 | 87 |
| 85 private: | 88 private: |
| 89 struct ExtendedScopeInfo { |
| 90 ExtendedScopeInfo(Handle<ScopeInfo> info, int start, int end) |
| 91 : scope_info(info), start_position(start), end_position(end) {} |
| 92 Handle<ScopeInfo> scope_info; |
| 93 int start_position; |
| 94 int end_position; |
| 95 }; |
| 96 |
| 86 Isolate* isolate_; | 97 Isolate* isolate_; |
| 87 FrameInspector* const frame_inspector_; | 98 FrameInspector* const frame_inspector_; |
| 88 Handle<Context> context_; | 99 Handle<Context> context_; |
| 89 List<Handle<ScopeInfo> > nested_scope_chain_; | 100 List<ExtendedScopeInfo> nested_scope_chain_; |
| 90 HashMap* non_locals_; | 101 HashMap* non_locals_; |
| 91 bool seen_script_scope_; | 102 bool seen_script_scope_; |
| 92 bool failed_; | 103 bool failed_; |
| 93 | 104 |
| 94 inline JavaScriptFrame* GetFrame() { | 105 inline JavaScriptFrame* GetFrame() { |
| 95 return frame_inspector_->GetArgumentsFrame(); | 106 return frame_inspector_->GetArgumentsFrame(); |
| 96 } | 107 } |
| 97 | 108 |
| 98 inline Handle<JSFunction> GetFunction() { | 109 inline Handle<JSFunction> GetFunction() { |
| 99 return Handle<JSFunction>::cast(frame_inspector_->GetFunction()); | 110 return Handle<JSFunction>::cast(frame_inspector_->GetFunction()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 Handle<String> variable_name, | 144 Handle<String> variable_name, |
| 134 Handle<Object> new_value); | 145 Handle<Object> new_value); |
| 135 | 146 |
| 136 void CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info, | 147 void CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info, |
| 137 Handle<Context> context, | 148 Handle<Context> context, |
| 138 Handle<JSObject> scope_object); | 149 Handle<JSObject> scope_object); |
| 139 bool CopyContextExtensionToScopeObject(Handle<JSObject> extension, | 150 bool CopyContextExtensionToScopeObject(Handle<JSObject> extension, |
| 140 Handle<JSObject> scope_object, | 151 Handle<JSObject> scope_object, |
| 141 KeyCollectionType type); | 152 KeyCollectionType type); |
| 142 | 153 |
| 154 // Get the chain of nested scopes within this scope for the source statement |
| 155 // position. The scopes will be added to the list from the outermost scope to |
| 156 // the innermost scope. Only nested block, catch or with scopes are tracked |
| 157 // and will be returned, but no inner function scopes. |
| 158 void GetNestedScopeChain(Isolate* isolate, Scope* scope, |
| 159 int statement_position); |
| 160 |
| 143 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); | 161 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); |
| 144 }; | 162 }; |
| 145 | 163 |
| 146 } // namespace internal | 164 } // namespace internal |
| 147 } // namespace v8 | 165 } // namespace v8 |
| 148 | 166 |
| 149 #endif // V8_DEBUG_DEBUG_SCOPES_H_ | 167 #endif // V8_DEBUG_DEBUG_SCOPES_H_ |
| OLD | NEW |