Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: src/debug/debug-scopes.h

Issue 1264993002: Debugger: refactor ScopeIterator, FrameInspector and DebugEvaluate. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: readd include Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_DEBUG_DEBUG_SCOPES_H_
6 #define V8_DEBUG_DEBUG_SCOPES_H_
7
8 #include "src/debug/debug-frames.h"
9 #include "src/frames.h"
10
11 namespace v8 {
12 namespace internal {
13
14 // Iterate over the actual scopes visible from a stack frame or from a closure.
15 // The iteration proceeds from the innermost visible nested scope outwards.
16 // All scopes are backed by an actual context except the local scope,
17 // which is inserted "artificially" in the context chain.
18 class ScopeIterator {
19 public:
20 enum ScopeType {
21 ScopeTypeGlobal = 0,
22 ScopeTypeLocal,
23 ScopeTypeWith,
24 ScopeTypeClosure,
25 ScopeTypeCatch,
26 ScopeTypeBlock,
27 ScopeTypeScript,
28 ScopeTypeModule
29 };
30
31 static const int kScopeDetailsTypeIndex = 0;
32 static const int kScopeDetailsObjectIndex = 1;
33 static const int kScopeDetailsSize = 2;
34
35 ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector,
36 bool ignore_nested_scopes = false);
37
38 ScopeIterator(Isolate* isolate, Handle<JSFunction> function);
39
40 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeScopeDetails();
41
42 // More scopes?
43 bool Done() {
44 DCHECK(!failed_);
45 return context_.is_null();
46 }
47
48 bool Failed() { return failed_; }
49
50 // Move to the next scope.
51 void Next();
52
53 // Return the type of the current scope.
54 ScopeType Type();
55
56 // Return the JavaScript object with the content of the current scope.
57 MaybeHandle<JSObject> ScopeObject();
58
59 bool HasContext();
60
61 // Set variable value and return true on success.
62 bool SetVariableValue(Handle<String> variable_name, Handle<Object> new_value);
63
64 Handle<ScopeInfo> CurrentScopeInfo();
65
66 // Return the context for this scope. For the local context there might not
67 // be an actual context.
68 Handle<Context> CurrentContext();
69
70 #ifdef DEBUG
71 // Debug print of the content of the current scope.
72 void DebugPrint();
73 #endif
74
75 private:
76 Isolate* isolate_;
77 FrameInspector* const frame_inspector_;
78 Handle<Context> context_;
79 List<Handle<ScopeInfo> > nested_scope_chain_;
80 bool seen_script_scope_;
81 bool failed_;
82
83 inline JavaScriptFrame* GetFrame() {
84 return frame_inspector_->GetArgumentsFrame();
85 }
86
87 inline Handle<JSFunction> GetFunction() {
88 return Handle<JSFunction>(
89 JSFunction::cast(frame_inspector_->GetFunction()));
90 }
91
92 void RetrieveScopeChain(Scope* scope, Handle<SharedFunctionInfo> shared_info);
93
94 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeScriptScope();
95 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeLocalScope();
96 MUST_USE_RESULT MaybeHandle<JSObject> MaterializeModuleScope();
97 Handle<JSObject> MaterializeClosure();
98 Handle<JSObject> MaterializeCatchScope();
99 Handle<JSObject> MaterializeBlockScope();
100
101 bool SetLocalVariableValue(Handle<String> variable_name,
102 Handle<Object> new_value);
103 bool SetBlockVariableValue(Handle<String> variable_name,
104 Handle<Object> new_value);
105 bool SetClosureVariableValue(Handle<String> variable_name,
106 Handle<Object> new_value);
107 bool SetScriptVariableValue(Handle<String> variable_name,
108 Handle<Object> new_value);
109 bool SetCatchVariableValue(Handle<String> variable_name,
110 Handle<Object> new_value);
111 bool SetContextLocalValue(Handle<ScopeInfo> scope_info,
112 Handle<Context> context,
113 Handle<String> variable_name,
114 Handle<Object> new_value);
115
116 void CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info,
117 Handle<Context> context,
118 Handle<JSObject> scope_object);
119
120 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator);
121 };
122
123 } // namespace internal
124 } // namespace v8
125
126 #endif // V8_DEBUG_DEBUG_SCOPES_H_
OLDNEW
« no previous file with comments | « src/debug/debug-frames.cc ('k') | src/debug/debug-scopes.cc » ('j') | src/debug/debug-scopes.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698