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::Local<v8::Object> JavaScriptCallFrame::details() const { | 94 v8::MaybeLocal<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 return v8::Local<v8::Object>::Cast( | 104 v8::TryCatch try_catch(m_isolate); |
105 func->Call(context, callFrame, 0, nullptr).ToLocalChecked()); | 105 v8::Local<v8::Value> details; |
| 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>(); |
106 } | 110 } |
107 | 111 |
108 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::evaluate( | 112 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::evaluate( |
109 v8::Local<v8::Value> expression) { | 113 v8::Local<v8::Value> expression) { |
110 v8::MicrotasksScope microtasks(m_isolate, | 114 v8::MicrotasksScope microtasks(m_isolate, |
111 v8::MicrotasksScope::kRunMicrotasks); | 115 v8::MicrotasksScope::kRunMicrotasks); |
112 v8::Local<v8::Context> context = | 116 v8::Local<v8::Context> context = |
113 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); | 117 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); |
114 v8::Local<v8::Object> callFrame = | 118 v8::Local<v8::Object> callFrame = |
115 v8::Local<v8::Object>::New(m_isolate, m_callFrame); | 119 v8::Local<v8::Object>::New(m_isolate, m_callFrame); |
116 v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast( | 120 v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast( |
117 callFrame->Get(context, toV8StringInternalized(m_isolate, "evaluate")) | 121 callFrame->Get(context, toV8StringInternalized(m_isolate, "evaluate")) |
118 .ToLocalChecked()); | 122 .ToLocalChecked()); |
119 return evalFunction->Call(context, callFrame, 1, &expression); | 123 return evalFunction->Call(context, callFrame, 1, &expression); |
120 } | 124 } |
121 | 125 |
122 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart() { | 126 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart() { |
123 v8::MicrotasksScope microtasks(m_isolate, | 127 v8::MicrotasksScope microtasks(m_isolate, |
124 v8::MicrotasksScope::kDoNotRunMicrotasks); | 128 v8::MicrotasksScope::kDoNotRunMicrotasks); |
125 v8::Local<v8::Context> context = | 129 v8::Local<v8::Context> context = |
126 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); | 130 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); |
127 v8::Local<v8::Object> callFrame = | 131 v8::Local<v8::Object> callFrame = |
128 v8::Local<v8::Object>::New(m_isolate, m_callFrame); | 132 v8::Local<v8::Object>::New(m_isolate, m_callFrame); |
129 v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast( | 133 v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast( |
130 callFrame->Get(context, toV8StringInternalized(m_isolate, "restart")) | 134 callFrame->Get(context, toV8StringInternalized(m_isolate, "restart")) |
131 .ToLocalChecked()); | 135 .ToLocalChecked()); |
| 136 v8::TryCatch try_catch(m_isolate); |
132 v8::debug::SetLiveEditEnabled(m_isolate, true); | 137 v8::debug::SetLiveEditEnabled(m_isolate, true); |
133 v8::MaybeLocal<v8::Value> result = restartFunction->Call( | 138 v8::MaybeLocal<v8::Value> result = restartFunction->Call( |
134 m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr); | 139 m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr); |
135 v8::debug::SetLiveEditEnabled(m_isolate, false); | 140 v8::debug::SetLiveEditEnabled(m_isolate, false); |
136 return result; | 141 return result; |
137 } | 142 } |
138 | 143 |
139 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::setVariableValue( | 144 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::setVariableValue( |
140 int scopeNumber, v8::Local<v8::Value> variableName, | 145 int scopeNumber, v8::Local<v8::Value> variableName, |
141 v8::Local<v8::Value> newValue) { | 146 v8::Local<v8::Value> newValue) { |
142 v8::MicrotasksScope microtasks(m_isolate, | 147 v8::MicrotasksScope microtasks(m_isolate, |
143 v8::MicrotasksScope::kDoNotRunMicrotasks); | 148 v8::MicrotasksScope::kDoNotRunMicrotasks); |
144 v8::Local<v8::Context> context = | 149 v8::Local<v8::Context> context = |
145 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); | 150 v8::Local<v8::Context>::New(m_isolate, m_debuggerContext); |
146 v8::Local<v8::Object> callFrame = | 151 v8::Local<v8::Object> callFrame = |
147 v8::Local<v8::Object>::New(m_isolate, m_callFrame); | 152 v8::Local<v8::Object>::New(m_isolate, m_callFrame); |
148 v8::Local<v8::Function> setVariableValueFunction = | 153 v8::Local<v8::Function> setVariableValueFunction = |
149 v8::Local<v8::Function>::Cast( | 154 v8::Local<v8::Function>::Cast( |
150 callFrame | 155 callFrame |
151 ->Get(context, | 156 ->Get(context, |
152 toV8StringInternalized(m_isolate, "setVariableValue")) | 157 toV8StringInternalized(m_isolate, "setVariableValue")) |
153 .ToLocalChecked()); | 158 .ToLocalChecked()); |
154 v8::Local<v8::Value> argv[] = { | 159 v8::Local<v8::Value> argv[] = { |
155 v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)), | 160 v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)), |
156 variableName, newValue}; | 161 variableName, newValue}; |
| 162 v8::TryCatch try_catch(m_isolate); |
157 return setVariableValueFunction->Call(context, callFrame, arraysize(argv), | 163 return setVariableValueFunction->Call(context, callFrame, arraysize(argv), |
158 argv); | 164 argv); |
159 } | 165 } |
160 | 166 |
161 } // namespace v8_inspector | 167 } // namespace v8_inspector |
OLD | NEW |