| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/inspector/JavaScriptCallFrame.h" | 32 #include "core/inspector/JavaScriptCallFrame.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/EvaluateExceptionDetailsFactory.h" |
| 34 #include "bindings/core/v8/ScriptValue.h" | 35 #include "bindings/core/v8/ScriptValue.h" |
| 35 #include "bindings/core/v8/V8Binding.h" | 36 #include "bindings/core/v8/V8Binding.h" |
| 36 #include <v8-debug.h> | 37 #include <v8-debug.h> |
| 37 | 38 |
| 38 namespace WebCore { | 39 namespace WebCore { |
| 39 | 40 |
| 40 JavaScriptCallFrame::JavaScriptCallFrame(v8::Handle<v8::Context> debuggerContext
, v8::Handle<v8::Object> callFrame) | 41 JavaScriptCallFrame::JavaScriptCallFrame(v8::Handle<v8::Context> debuggerContext
, v8::Handle<v8::Object> callFrame) |
| 41 : m_isolate(v8::Isolate::GetCurrent()) | 42 : m_isolate(v8::Isolate::GetCurrent()) |
| 42 , m_debuggerContext(m_isolate, debuggerContext) | 43 , m_debuggerContext(m_isolate, debuggerContext) |
| 43 , m_callFrame(m_isolate, callFrame) | 44 , m_callFrame(m_isolate, callFrame) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 v8::Handle<v8::Value> JavaScriptCallFrame::returnValue() const | 144 v8::Handle<v8::Value> JavaScriptCallFrame::returnValue() const |
| 144 { | 145 { |
| 145 return m_callFrame.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "retur
nValue")); | 146 return m_callFrame.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "retur
nValue")); |
| 146 } | 147 } |
| 147 | 148 |
| 148 v8::Handle<v8::Value> JavaScriptCallFrame::evaluate(const String& expression) | 149 v8::Handle<v8::Value> JavaScriptCallFrame::evaluate(const String& expression) |
| 149 { | 150 { |
| 150 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 151 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); |
| 151 v8::Handle<v8::Function> evalFunction = v8::Handle<v8::Function>::Cast(callF
rame->Get(v8AtomicString(m_isolate, "evaluate"))); | 152 v8::Handle<v8::Function> evalFunction = v8::Handle<v8::Function>::Cast(callF
rame->Get(v8AtomicString(m_isolate, "evaluate"))); |
| 152 v8::Handle<v8::Value> argv[] = { v8String(m_debuggerContext.newLocal(m_isola
te)->GetIsolate(), expression) }; | 153 v8::Handle<v8::Value> argv[] = { v8String(m_debuggerContext.newLocal(m_isola
te)->GetIsolate(), expression) }; |
| 153 return evalFunction->Call(callFrame, WTF_ARRAY_LENGTH(argv), argv); | 154 v8::TryCatch tryCatch; |
| 155 v8::Handle<v8::Value> result = evalFunction->Call(callFrame, WTF_ARRAY_LENGT
H(argv), argv); |
| 156 |
| 157 v8::Handle<v8::Object> wrappedResult = v8::Object::New(m_isolate); |
| 158 if (tryCatch.HasCaught()) { |
| 159 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "result"), tryCatc
h.Exception()); |
| 160 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "exceptionDetails"
), createEvaluateExceptionDetails(tryCatch.Message(), m_isolate)); |
| 161 } else { |
| 162 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "result"), result)
; |
| 163 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "exceptionDetails"
), v8::Undefined(m_isolate)); |
| 164 } |
| 165 return wrappedResult; |
| 154 } | 166 } |
| 155 | 167 |
| 156 v8::Handle<v8::Value> JavaScriptCallFrame::restart() | 168 v8::Handle<v8::Value> JavaScriptCallFrame::restart() |
| 157 { | 169 { |
| 158 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 170 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); |
| 159 v8::Handle<v8::Function> restartFunction = v8::Handle<v8::Function>::Cast(ca
llFrame->Get(v8AtomicString(m_isolate, "restart"))); | 171 v8::Handle<v8::Function> restartFunction = v8::Handle<v8::Function>::Cast(ca
llFrame->Get(v8AtomicString(m_isolate, "restart"))); |
| 160 v8::Debug::SetLiveEditEnabled(m_isolate, true); | 172 v8::Debug::SetLiveEditEnabled(m_isolate, true); |
| 161 v8::Handle<v8::Value> result = restartFunction->Call(callFrame, 0, 0); | 173 v8::Handle<v8::Value> result = restartFunction->Call(callFrame, 0, 0); |
| 162 v8::Debug::SetLiveEditEnabled(m_isolate, false); | 174 v8::Debug::SetLiveEditEnabled(m_isolate, false); |
| 163 return result; | 175 return result; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 175 }; | 187 }; |
| 176 return ScriptValue(scriptState, setVariableValueFunction->Call(callFrame, WT
F_ARRAY_LENGTH(argv), argv)); | 188 return ScriptValue(scriptState, setVariableValueFunction->Call(callFrame, WT
F_ARRAY_LENGTH(argv), argv)); |
| 177 } | 189 } |
| 178 | 190 |
| 179 void JavaScriptCallFrame::trace(Visitor* visitor) | 191 void JavaScriptCallFrame::trace(Visitor* visitor) |
| 180 { | 192 { |
| 181 visitor->trace(m_caller); | 193 visitor->trace(m_caller); |
| 182 } | 194 } |
| 183 | 195 |
| 184 } // namespace WebCore | 196 } // namespace WebCore |
| OLD | NEW |