Chromium Code Reviews| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 } | 61 } |
| 62 return m_caller.get(); | 62 return m_caller.get(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 int JavaScriptCallFrame::callV8FunctionReturnInt(const char* name) const | 65 int JavaScriptCallFrame::callV8FunctionReturnInt(const char* name) const |
| 66 { | 66 { |
| 67 v8::HandleScope handleScope(m_isolate); | 67 v8::HandleScope handleScope(m_isolate); |
| 68 v8::Context::Scope contextScope(m_debuggerContext.newLocal(m_isolate)); | 68 v8::Context::Scope contextScope(m_debuggerContext.newLocal(m_isolate)); |
| 69 v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 69 v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); |
| 70 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get( v8AtomicString(m_isolate, name))); | 70 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get( v8AtomicString(m_isolate, name))); |
| 71 v8::Local<v8::Value> result = V8ScriptRunner::callInternalFunction(func, cal lFrame, 0, 0, m_isolate); | 71 v8::Local<v8::Value> result; |
| 72 if (result.IsEmpty() || !result->IsInt32()) | 72 if (!V8ScriptRunner::callInternalFunction(func, callFrame, 0, 0, m_isolate). ToLocal(&result) || !result->IsInt32()) |
| 73 return 0; | 73 return 0; |
| 74 return result->Int32Value(); | 74 return result.As<v8::Int32>()->Value(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 String JavaScriptCallFrame::callV8FunctionReturnString(const char* name) const | 77 String JavaScriptCallFrame::callV8FunctionReturnString(const char* name) const |
| 78 { | 78 { |
| 79 v8::HandleScope handleScope(m_isolate); | 79 v8::HandleScope handleScope(m_isolate); |
| 80 v8::Context::Scope contextScope(m_debuggerContext.newLocal(m_isolate)); | 80 v8::Context::Scope contextScope(m_debuggerContext.newLocal(m_isolate)); |
| 81 v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 81 v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); |
| 82 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get( v8AtomicString(m_isolate, name))); | 82 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get( v8AtomicString(m_isolate, name))); |
| 83 v8::Local<v8::Value> result = V8ScriptRunner::callInternalFunction(func, cal lFrame, 0, 0, m_isolate); | 83 v8::Local<v8::Value> result; |
| 84 if (!V8ScriptRunner::callInternalFunction(func, callFrame, 0, 0, m_isolate). ToLocal(&result)) | |
| 85 return String(); | |
| 84 return toCoreStringWithUndefinedOrNullCheck(result); | 86 return toCoreStringWithUndefinedOrNullCheck(result); |
| 85 } | 87 } |
| 86 | 88 |
| 87 int JavaScriptCallFrame::sourceID() const | 89 int JavaScriptCallFrame::sourceID() const |
| 88 { | 90 { |
| 89 return callV8FunctionReturnInt("sourceID"); | 91 return callV8FunctionReturnInt("sourceID"); |
| 90 } | 92 } |
| 91 | 93 |
| 92 int JavaScriptCallFrame::line() const | 94 int JavaScriptCallFrame::line() const |
| 93 { | 95 { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 116 | 118 |
| 117 int JavaScriptCallFrame::functionColumn() const | 119 int JavaScriptCallFrame::functionColumn() const |
| 118 { | 120 { |
| 119 return callV8FunctionReturnInt("functionColumn"); | 121 return callV8FunctionReturnInt("functionColumn"); |
| 120 } | 122 } |
| 121 | 123 |
| 122 v8::Local<v8::Value> JavaScriptCallFrame::scopeChain() const | 124 v8::Local<v8::Value> JavaScriptCallFrame::scopeChain() const |
| 123 { | 125 { |
| 124 v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 126 v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); |
| 125 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get( v8AtomicString(m_isolate, "scopeChain"))); | 127 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get( v8AtomicString(m_isolate, "scopeChain"))); |
| 126 v8::Local<v8::Array> scopeChain = v8::Local<v8::Array>::Cast(V8ScriptRunner: :callInternalFunction(func, callFrame, 0, 0, m_isolate)); | 128 v8::Local<v8::Array> scopeChain = v8::Local<v8::Array>::Cast(V8ScriptRunner: :callInternalFunction(func, callFrame, 0, 0, m_isolate).ToLocalChecked()); |
| 127 v8::Local<v8::Array> result = v8::Array::New(m_isolate, scopeChain->Length() ); | 129 v8::Local<v8::Array> result = v8::Array::New(m_isolate, scopeChain->Length() ); |
| 128 for (uint32_t i = 0; i < scopeChain->Length(); i++) | 130 for (uint32_t i = 0; i < scopeChain->Length(); i++) |
| 129 result->Set(i, scopeChain->Get(i)); | 131 result->Set(i, scopeChain->Get(i)); |
| 130 return result; | 132 return result; |
| 131 } | 133 } |
| 132 | 134 |
| 133 int JavaScriptCallFrame::scopeType(int scopeIndex) const | 135 int JavaScriptCallFrame::scopeType(int scopeIndex) const |
| 134 { | 136 { |
| 135 v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 137 v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); |
| 136 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get( v8AtomicString(m_isolate, "scopeType"))); | 138 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get( v8AtomicString(m_isolate, "scopeType"))); |
| 137 v8::Local<v8::Array> scopeType = v8::Local<v8::Array>::Cast(V8ScriptRunner:: callInternalFunction(func, callFrame, 0, 0, m_isolate)); | 139 v8::Local<v8::Array> scopeType = v8::Local<v8::Array>::Cast(V8ScriptRunner:: callInternalFunction(func, callFrame, 0, 0, m_isolate).ToLocalChecked()); |
| 138 return scopeType->Get(scopeIndex)->Int32Value(); | 140 return scopeType->Get(scopeIndex)->Int32Value(); |
| 139 } | 141 } |
| 140 | 142 |
| 141 v8::Local<v8::Value> JavaScriptCallFrame::thisObject() const | 143 v8::Local<v8::Value> JavaScriptCallFrame::thisObject() const |
| 142 { | 144 { |
| 143 return m_callFrame.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "thisO bject")); | 145 return m_callFrame.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "thisO bject")); |
| 144 } | 146 } |
| 145 | 147 |
| 146 String JavaScriptCallFrame::stepInPositions() const | 148 String JavaScriptCallFrame::stepInPositions() const |
| 147 { | 149 { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 165 | 167 |
| 166 v8::Local<v8::Value> JavaScriptCallFrame::evaluateWithExceptionDetails(v8::Local <v8::Value> expression, v8::Local<v8::Value> scopeExtension) | 168 v8::Local<v8::Value> JavaScriptCallFrame::evaluateWithExceptionDetails(v8::Local <v8::Value> expression, v8::Local<v8::Value> scopeExtension) |
| 167 { | 169 { |
| 168 v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 170 v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); |
| 169 v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast(callFra me->Get(v8AtomicString(m_isolate, "evaluate"))); | 171 v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast(callFra me->Get(v8AtomicString(m_isolate, "evaluate"))); |
| 170 v8::Local<v8::Value> argv[] = { | 172 v8::Local<v8::Value> argv[] = { |
| 171 expression, | 173 expression, |
| 172 scopeExtension | 174 scopeExtension |
| 173 }; | 175 }; |
| 174 v8::TryCatch tryCatch; | 176 v8::TryCatch tryCatch; |
| 175 v8::Local<v8::Value> result = V8ScriptRunner::callInternalFunction(evalFunct ion, callFrame, WTF_ARRAY_LENGTH(argv), argv, m_isolate); | |
| 176 | |
| 177 v8::Local<v8::Object> wrappedResult = v8::Object::New(m_isolate); | 177 v8::Local<v8::Object> wrappedResult = v8::Object::New(m_isolate); |
| 178 if (tryCatch.HasCaught()) { | 178 v8::Local<v8::Value> result; |
| 179 if (V8ScriptRunner::callInternalFunction(evalFunction, callFrame, WTF_ARRAY_ LENGTH(argv), argv, m_isolate).ToLocal(&result)) { | |
| 180 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "result"), result) ; | |
| 181 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "exceptionDetails" ), v8::Undefined(m_isolate)); | |
| 182 } else { | |
| 179 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "result"), tryCatc h.Exception()); | 183 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "result"), tryCatc h.Exception()); |
| 180 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "exceptionDetails" ), createExceptionDetails(m_isolate, tryCatch.Message())); | 184 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "exceptionDetails" ), createExceptionDetails(m_isolate, tryCatch.Message())); |
| 181 } else { | |
| 182 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "result"), result) ; | |
| 183 wrappedResult->Set(v8::String::NewFromUtf8(m_isolate, "exceptionDetails" ), v8::Undefined(m_isolate)); | |
| 184 } | 185 } |
| 185 return wrappedResult; | 186 return wrappedResult; |
| 186 } | 187 } |
| 187 | 188 |
| 188 v8::Local<v8::Value> JavaScriptCallFrame::restart() | 189 v8::Local<v8::Value> JavaScriptCallFrame::restart() |
| 189 { | 190 { |
| 190 v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 191 v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); |
| 191 v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast(call Frame->Get(v8AtomicString(m_isolate, "restart"))); | 192 v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast(call Frame->Get(v8AtomicString(m_isolate, "restart"))); |
| 192 v8::Debug::SetLiveEditEnabled(m_isolate, true); | 193 v8::Debug::SetLiveEditEnabled(m_isolate, true); |
| 193 v8::Local<v8::Value> result = V8ScriptRunner::callInternalFunction(restartFu nction, callFrame, 0, 0, m_isolate); | 194 v8::Local<v8::Value> result = V8ScriptRunner::callInternalFunction(restartFu nction, callFrame, 0, 0, m_isolate).ToLocalChecked(); |
|
yurys
2015/04/01 04:11:02
Restarting frame may throw so we need to change re
bashi
2015/04/01 06:54:06
Done.
| |
| 194 v8::Debug::SetLiveEditEnabled(m_isolate, false); | 195 v8::Debug::SetLiveEditEnabled(m_isolate, false); |
| 195 return result; | 196 return result; |
| 196 } | 197 } |
| 197 | 198 |
| 198 v8::Local<v8::Value> JavaScriptCallFrame::setVariableValue(int scopeNumber, v8:: Local<v8::Value> variableName, v8::Local<v8::Value> newValue) | 199 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::setVariableValue(int scopeNumber, v8::Local<v8::Value> variableName, v8::Local<v8::Value> newValue) |
| 199 { | 200 { |
| 200 v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 201 v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); |
| 201 v8::Local<v8::Function> setVariableValueFunction = v8::Local<v8::Function>:: Cast(callFrame->Get(v8AtomicString(m_isolate, "setVariableValue"))); | 202 v8::Local<v8::Function> setVariableValueFunction = v8::Local<v8::Function>:: Cast(callFrame->Get(v8AtomicString(m_isolate, "setVariableValue"))); |
| 202 v8::Local<v8::Value> argv[] = { | 203 v8::Local<v8::Value> argv[] = { |
| 203 v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)), | 204 v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)), |
| 204 variableName, | 205 variableName, |
| 205 newValue | 206 newValue |
| 206 }; | 207 }; |
| 207 return V8ScriptRunner::callInternalFunction(setVariableValueFunction, callFr ame, WTF_ARRAY_LENGTH(argv), argv, m_isolate); | 208 return V8ScriptRunner::callInternalFunction(setVariableValueFunction, callFr ame, WTF_ARRAY_LENGTH(argv), argv, m_isolate); |
| 208 } | 209 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 221 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), v8 ::Undefined(isolate)); | 222 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), v8 ::Undefined(isolate)); |
| 222 return exceptionDetails; | 223 return exceptionDetails; |
| 223 } | 224 } |
| 224 | 225 |
| 225 DEFINE_TRACE(JavaScriptCallFrame) | 226 DEFINE_TRACE(JavaScriptCallFrame) |
| 226 { | 227 { |
| 227 visitor->trace(m_caller); | 228 visitor->trace(m_caller); |
| 228 } | 229 } |
| 229 | 230 |
| 230 } // namespace blink | 231 } // namespace blink |
| OLD | NEW |