OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 v8::Local<v8::Object> callFrame = | 84 v8::Local<v8::Object> callFrame = |
85 v8::Local<v8::Object>::New(m_isolate, m_callFrame); | 85 v8::Local<v8::Object>::New(m_isolate, m_callFrame); |
86 v8::Local<v8::Value> result; | 86 v8::Local<v8::Value> result; |
87 if (!callFrame->Get(context, toV8StringInternalized(m_isolate, "isAtReturn")) | 87 if (!callFrame->Get(context, toV8StringInternalized(m_isolate, "isAtReturn")) |
88 .ToLocal(&result) || | 88 .ToLocal(&result) || |
89 !result->IsBoolean()) | 89 !result->IsBoolean()) |
90 return false; | 90 return false; |
91 return result.As<v8::Boolean>()->BooleanValue(context).FromMaybe(false); | 91 return result.As<v8::Boolean>()->BooleanValue(context).FromMaybe(false); |
92 } | 92 } |
93 | 93 |
94 v8::MaybeLocal<v8::Object> JavaScriptCallFrame::details() const { | 94 v8::Local<v8::Object> JavaScriptCallFrame::details() const { |
95 v8::MicrotasksScope microtasks(m_isolate, | 95 v8::MicrotasksScope microtasks(m_isolate, |
96 v8::MicrotasksScope::kDoNotRunMicrotasks); | 96 v8::MicrotasksScope::kDoNotRunMicrotasks); |
97 v8::Local<v8::Context> context = | 97 v8::Local<v8::Context> context = |
98 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); | 98 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); |
99 v8::Local<v8::Object> callFrame = | 99 v8::Local<v8::Object> callFrame = |
100 v8::Local<v8::Object>::New(m_isolate, m_callFrame); | 100 v8::Local<v8::Object>::New(m_isolate, m_callFrame); |
101 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast( | 101 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast( |
102 callFrame->Get(context, toV8StringInternalized(m_isolate, "details")) | 102 callFrame->Get(context, toV8StringInternalized(m_isolate, "details")) |
103 .ToLocalChecked()); | 103 .ToLocalChecked()); |
104 v8::TryCatch try_catch(m_isolate); | 104 return v8::Local<v8::Object>::Cast( |
105 v8::Local<v8::Value> details; | 105 func->Call(context, callFrame, 0, nullptr).ToLocalChecked()); |
106 if (func->Call(context, callFrame, 0, nullptr).ToLocal(&details)) { | |
107 return v8::Local<v8::Object>::Cast(details); | |
108 } | |
109 return v8::MaybeLocal<v8::Object>(); | |
110 } | 106 } |
111 | 107 |
112 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::evaluate( | 108 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::evaluate( |
113 v8::Local<v8::Value> expression) { | 109 v8::Local<v8::Value> expression) { |
114 v8::MicrotasksScope microtasks(m_isolate, | 110 v8::MicrotasksScope microtasks(m_isolate, |
115 v8::MicrotasksScope::kRunMicrotasks); | 111 v8::MicrotasksScope::kRunMicrotasks); |
116 v8::Local<v8::Context> context = | 112 v8::Local<v8::Context> context = |
117 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); | 113 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); |
118 v8::Local<v8::Object> callFrame = | 114 v8::Local<v8::Object> callFrame = |
119 v8::Local<v8::Object>::New(m_isolate, m_callFrame); | 115 v8::Local<v8::Object>::New(m_isolate, m_callFrame); |
120 v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast( | 116 v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast( |
121 callFrame->Get(context, toV8StringInternalized(m_isolate, "evaluate")) | 117 callFrame->Get(context, toV8StringInternalized(m_isolate, "evaluate")) |
122 .ToLocalChecked()); | 118 .ToLocalChecked()); |
123 return evalFunction->Call(context, callFrame, 1, &expression); | 119 return evalFunction->Call(context, callFrame, 1, &expression); |
124 } | 120 } |
125 | 121 |
126 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart() { | 122 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart() { |
127 v8::MicrotasksScope microtasks(m_isolate, | 123 v8::MicrotasksScope microtasks(m_isolate, |
128 v8::MicrotasksScope::kDoNotRunMicrotasks); | 124 v8::MicrotasksScope::kDoNotRunMicrotasks); |
129 v8::Local<v8::Context> context = | 125 v8::Local<v8::Context> context = |
130 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); | 126 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); |
131 v8::Local<v8::Object> callFrame = | 127 v8::Local<v8::Object> callFrame = |
132 v8::Local<v8::Object>::New(m_isolate, m_callFrame); | 128 v8::Local<v8::Object>::New(m_isolate, m_callFrame); |
133 v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast( | 129 v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast( |
134 callFrame->Get(context, toV8StringInternalized(m_isolate, "restart")) | 130 callFrame->Get(context, toV8StringInternalized(m_isolate, "restart")) |
135 .ToLocalChecked()); | 131 .ToLocalChecked()); |
136 v8::TryCatch try_catch(m_isolate); | |
137 v8::debug::SetLiveEditEnabled(m_isolate, true); | 132 v8::debug::SetLiveEditEnabled(m_isolate, true); |
138 v8::MaybeLocal<v8::Value> result = restartFunction->Call( | 133 v8::MaybeLocal<v8::Value> result = restartFunction->Call( |
139 m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr); | 134 m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr); |
140 v8::debug::SetLiveEditEnabled(m_isolate, false); | 135 v8::debug::SetLiveEditEnabled(m_isolate, false); |
141 return result; | 136 return result; |
142 } | 137 } |
143 | 138 |
144 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::setVariableValue( | 139 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::setVariableValue( |
145 int scopeNumber, v8::Local<v8::Value> variableName, | 140 int scopeNumber, v8::Local<v8::Value> variableName, |
146 v8::Local<v8::Value> newValue) { | 141 v8::Local<v8::Value> newValue) { |
147 v8::MicrotasksScope microtasks(m_isolate, | 142 v8::MicrotasksScope microtasks(m_isolate, |
148 v8::MicrotasksScope::kDoNotRunMicrotasks); | 143 v8::MicrotasksScope::kDoNotRunMicrotasks); |
149 v8::Local<v8::Context> context = | 144 v8::Local<v8::Context> context = |
150 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); | 145 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); |
151 v8::Local<v8::Object> callFrame = | 146 v8::Local<v8::Object> callFrame = |
152 v8::Local<v8::Object>::New(m_isolate, m_callFrame); | 147 v8::Local<v8::Object>::New(m_isolate, m_callFrame); |
153 v8::Local<v8::Function> setVariableValueFunction = | 148 v8::Local<v8::Function> setVariableValueFunction = |
154 v8::Local<v8::Function>::Cast( | 149 v8::Local<v8::Function>::Cast( |
155 callFrame | 150 callFrame |
156 ->Get(context, | 151 ->Get(context, |
157 toV8StringInternalized(m_isolate, "setVariableValue")) | 152 toV8StringInternalized(m_isolate, "setVariableValue")) |
158 .ToLocalChecked()); | 153 .ToLocalChecked()); |
159 v8::Local<v8::Value> argv[] = { | 154 v8::Local<v8::Value> argv[] = { |
160 v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)), | 155 v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)), |
161 variableName, newValue}; | 156 variableName, newValue}; |
162 v8::TryCatch try_catch(m_isolate); | |
163 return setVariableValueFunction->Call(context, callFrame, arraysize(argv), | 157 return setVariableValueFunction->Call(context, callFrame, arraysize(argv), |
164 argv); | 158 argv); |
165 } | 159 } |
166 | 160 |
167 } // namespace v8_inspector | 161 } // namespace v8_inspector |
OLD | NEW |