| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 if (result->IsBoolean()) | 143 if (result->IsBoolean()) |
| 144 return result->BooleanValue(); | 144 return result->BooleanValue(); |
| 145 return false; | 145 return false; |
| 146 } | 146 } |
| 147 | 147 |
| 148 v8::Handle<v8::Value> JavaScriptCallFrame::returnValue() const | 148 v8::Handle<v8::Value> JavaScriptCallFrame::returnValue() const |
| 149 { | 149 { |
| 150 return m_callFrame.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "retur
nValue")); | 150 return m_callFrame.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "retur
nValue")); |
| 151 } | 151 } |
| 152 | 152 |
| 153 v8::Handle<v8::Value> JavaScriptCallFrame::evaluate(const String& expression) | 153 v8::Handle<v8::Value> JavaScriptCallFrame::evaluateWithExceptionDetails(const St
ring& expression) |
| 154 { | 154 { |
| 155 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 155 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); |
| 156 v8::Handle<v8::Function> evalFunction = v8::Handle<v8::Function>::Cast(callF
rame->Get(v8AtomicString(m_isolate, "evaluate"))); | 156 v8::Handle<v8::Function> evalFunction = v8::Handle<v8::Function>::Cast(callF
rame->Get(v8AtomicString(m_isolate, "evaluate"))); |
| 157 v8::Handle<v8::Value> argv[] = { v8String(m_debuggerContext.newLocal(m_isola
te)->GetIsolate(), expression) }; | 157 v8::Handle<v8::Value> argv[] = { v8String(m_debuggerContext.newLocal(m_isola
te)->GetIsolate(), expression) }; |
| 158 return evalFunction->Call(callFrame, WTF_ARRAY_LENGTH(argv), argv); | 158 v8::TryCatch tryCatch; |
| 159 v8::Handle<v8::Value> result = evalFunction->Call(callFrame, WTF_ARRAY_LENGT
H(argv), argv); |
| 160 |
| 161 v8::Handle<v8::Object> wrappedResult = v8::Object::New(m_isolate); |
| 162 if (tryCatch.HasCaught()) { |
| 163 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "result"), tryCatc
h.Exception()); |
| 164 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "exceptionDetails"
), createExceptionDetails(tryCatch.Message(), m_isolate)); |
| 165 } else { |
| 166 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "result"), result)
; |
| 167 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "exceptionDetails"
), v8::Undefined(m_isolate)); |
| 168 } |
| 169 return wrappedResult; |
| 159 } | 170 } |
| 160 | 171 |
| 161 v8::Handle<v8::Value> JavaScriptCallFrame::restart() | 172 v8::Handle<v8::Value> JavaScriptCallFrame::restart() |
| 162 { | 173 { |
| 163 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 174 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); |
| 164 v8::Handle<v8::Function> restartFunction = v8::Handle<v8::Function>::Cast(ca
llFrame->Get(v8AtomicString(m_isolate, "restart"))); | 175 v8::Handle<v8::Function> restartFunction = v8::Handle<v8::Function>::Cast(ca
llFrame->Get(v8AtomicString(m_isolate, "restart"))); |
| 165 v8::Debug::SetLiveEditEnabled(m_isolate, true); | 176 v8::Debug::SetLiveEditEnabled(m_isolate, true); |
| 166 v8::Handle<v8::Value> result = restartFunction->Call(callFrame, 0, 0); | 177 v8::Handle<v8::Value> result = restartFunction->Call(callFrame, 0, 0); |
| 167 v8::Debug::SetLiveEditEnabled(m_isolate, false); | 178 v8::Debug::SetLiveEditEnabled(m_isolate, false); |
| 168 return result; | 179 return result; |
| 169 } | 180 } |
| 170 | 181 |
| 171 ScriptValue JavaScriptCallFrame::setVariableValue(ScriptState* scriptState, int
scopeNumber, const String& variableName, const ScriptValue& newValue) | 182 ScriptValue JavaScriptCallFrame::setVariableValue(ScriptState* scriptState, int
scopeNumber, const String& variableName, const ScriptValue& newValue) |
| 172 { | 183 { |
| 173 ScriptState::Scope scriptScope(scriptState); | 184 ScriptState::Scope scriptScope(scriptState); |
| 174 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 185 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); |
| 175 v8::Handle<v8::Function> setVariableValueFunction = v8::Handle<v8::Function>
::Cast(callFrame->Get(v8AtomicString(m_isolate, "setVariableValue"))); | 186 v8::Handle<v8::Function> setVariableValueFunction = v8::Handle<v8::Function>
::Cast(callFrame->Get(v8AtomicString(m_isolate, "setVariableValue"))); |
| 176 v8::Handle<v8::Value> argv[] = { | 187 v8::Handle<v8::Value> argv[] = { |
| 177 v8::Handle<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)), | 188 v8::Handle<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)), |
| 178 v8String(m_isolate, variableName), | 189 v8String(m_isolate, variableName), |
| 179 newValue.v8Value() | 190 newValue.v8Value() |
| 180 }; | 191 }; |
| 181 return ScriptValue(scriptState, setVariableValueFunction->Call(callFrame, WT
F_ARRAY_LENGTH(argv), argv)); | 192 return ScriptValue(scriptState, setVariableValueFunction->Call(callFrame, WT
F_ARRAY_LENGTH(argv), argv)); |
| 182 } | 193 } |
| 183 | 194 |
| 195 v8::Handle<v8::Object> JavaScriptCallFrame::createExceptionDetails(v8::Handle<v8
::Message> message, v8::Isolate* isolate) |
| 196 { |
| 197 v8::Handle<v8::Object> exceptionDetails = v8::Object::New(isolate); |
| 198 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "text"), message->Get
()); |
| 199 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "url"), message->GetS
criptOrigin().ResourceName()); |
| 200 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "line"), v8::Integer:
:New(isolate, message->GetLineNumber())); |
| 201 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "column"), v8::Intege
r::New(isolate, message->GetStartColumn())); |
| 202 if (!message->GetStackTrace().IsEmpty()) |
| 203 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), me
ssage->GetStackTrace()->AsArray()); |
| 204 else |
| 205 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), v8
::Undefined(isolate)); |
| 206 return exceptionDetails; |
| 207 } |
| 208 |
| 184 void JavaScriptCallFrame::trace(Visitor* visitor) | 209 void JavaScriptCallFrame::trace(Visitor* visitor) |
| 185 { | 210 { |
| 186 visitor->trace(m_caller); | 211 visitor->trace(m_caller); |
| 187 } | 212 } |
| 188 | 213 |
| 189 } // namespace WebCore | 214 } // namespace WebCore |
| OLD | NEW |