| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr
otasks); | 63 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr
otasks); |
| 64 v8::Local<v8::Context> context = v8::Local<v8::Context>::New(m_isolate, m_de
buggerContext); | 64 v8::Local<v8::Context> context = v8::Local<v8::Context>::New(m_isolate, m_de
buggerContext); |
| 65 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca
llFrame); | 65 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca
llFrame); |
| 66 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(
toV8StringInternalized(m_isolate, name))); | 66 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(
toV8StringInternalized(m_isolate, name))); |
| 67 v8::Local<v8::Value> result; | 67 v8::Local<v8::Value> result; |
| 68 if (!func->Call(context, callFrame, 0, nullptr).ToLocal(&result) || !result-
>IsInt32()) | 68 if (!func->Call(context, callFrame, 0, nullptr).ToLocal(&result) || !result-
>IsInt32()) |
| 69 return 0; | 69 return 0; |
| 70 return result.As<v8::Int32>()->Value(); | 70 return result.As<v8::Int32>()->Value(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 String16 JavaScriptCallFrame::callV8FunctionReturnString(const char* name) const | |
| 74 { | |
| 75 v8::HandleScope handleScope(m_isolate); | |
| 76 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr
otasks); | |
| 77 v8::Local<v8::Context> context = v8::Local<v8::Context>::New(m_isolate, m_de
buggerContext); | |
| 78 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca
llFrame); | |
| 79 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(
toV8StringInternalized(m_isolate, name))); | |
| 80 v8::Local<v8::Value> result; | |
| 81 if (!func->Call(context, callFrame, 0, nullptr).ToLocal(&result)) | |
| 82 return String16(); | |
| 83 return toProtocolStringWithTypeCheck(result); | |
| 84 } | |
| 85 | |
| 86 int JavaScriptCallFrame::sourceID() const | 73 int JavaScriptCallFrame::sourceID() const |
| 87 { | 74 { |
| 88 return callV8FunctionReturnInt("sourceID"); | 75 return callV8FunctionReturnInt("sourceID"); |
| 89 } | 76 } |
| 90 | 77 |
| 91 int JavaScriptCallFrame::line() const | 78 int JavaScriptCallFrame::line() const |
| 92 { | 79 { |
| 93 return callV8FunctionReturnInt("line"); | 80 return callV8FunctionReturnInt("line"); |
| 94 } | 81 } |
| 95 | 82 |
| 96 int JavaScriptCallFrame::column() const | 83 int JavaScriptCallFrame::column() const |
| 97 { | 84 { |
| 98 return callV8FunctionReturnInt("column"); | 85 return callV8FunctionReturnInt("column"); |
| 99 } | 86 } |
| 100 | 87 |
| 101 String16 JavaScriptCallFrame::scriptName() const | |
| 102 { | |
| 103 return callV8FunctionReturnString("scriptName"); | |
| 104 } | |
| 105 | |
| 106 String16 JavaScriptCallFrame::functionName() const | |
| 107 { | |
| 108 return callV8FunctionReturnString("functionName"); | |
| 109 } | |
| 110 | |
| 111 int JavaScriptCallFrame::functionLine() const | |
| 112 { | |
| 113 return callV8FunctionReturnInt("functionLine"); | |
| 114 } | |
| 115 | |
| 116 int JavaScriptCallFrame::functionColumn() const | |
| 117 { | |
| 118 return callV8FunctionReturnInt("functionColumn"); | |
| 119 } | |
| 120 | |
| 121 v8::Local<v8::Value> JavaScriptCallFrame::scopeChain() const | |
| 122 { | |
| 123 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr
otasks); | |
| 124 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca
llFrame); | |
| 125 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(
toV8StringInternalized(m_isolate, "scopeChain"))); | |
| 126 v8::Local<v8::Array> scopeChain = v8::Local<v8::Array>::Cast(func->Call(m_is
olate->GetCurrentContext(), callFrame, 0, nullptr).ToLocalChecked()); | |
| 127 v8::Local<v8::Array> result = v8::Array::New(m_isolate, scopeChain->Length()
); | |
| 128 for (uint32_t i = 0; i < scopeChain->Length(); i++) | |
| 129 result->Set(i, scopeChain->Get(i)); | |
| 130 return result; | |
| 131 } | |
| 132 | |
| 133 v8::Local<v8::String> JavaScriptCallFrame::scopeType(int scopeIndex) const | |
| 134 { | |
| 135 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr
otasks); | |
| 136 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca
llFrame); | |
| 137 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(
toV8StringInternalized(m_isolate, "scopeType"))); | |
| 138 v8::Local<v8::Array> scopeType = v8::Local<v8::Array>::Cast(func->Call(m_iso
late->GetCurrentContext(), callFrame, 0, nullptr).ToLocalChecked()); | |
| 139 return scopeType->Get(scopeIndex)->ToString(); | |
| 140 } | |
| 141 | |
| 142 v8::Local<v8::String> JavaScriptCallFrame::scopeName(int scopeIndex) const | |
| 143 { | |
| 144 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr
otasks); | |
| 145 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca
llFrame); | |
| 146 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(
toV8StringInternalized(m_isolate, "scopeName"))); | |
| 147 v8::Local<v8::Array> scopeName = v8::Local<v8::Array>::Cast(func->Call(m_iso
late->GetCurrentContext(), callFrame, 0, nullptr).ToLocalChecked()); | |
| 148 return scopeName->Get(scopeIndex)->ToString(); | |
| 149 } | |
| 150 | |
| 151 v8::Local<v8::Value> JavaScriptCallFrame::scopeStartLocation(int scopeIndex) con
st | |
| 152 { | |
| 153 return callScopeLocationFunction("scopeStartLocation", scopeIndex); | |
| 154 } | |
| 155 | |
| 156 v8::Local<v8::Value> JavaScriptCallFrame::scopeEndLocation(int scopeIndex) const | |
| 157 { | |
| 158 return callScopeLocationFunction("scopeEndLocation", scopeIndex); | |
| 159 } | |
| 160 | |
| 161 v8::Local<v8::Value> JavaScriptCallFrame::callScopeLocationFunction(const char*
name, int scopeIndex) const | |
| 162 { | |
| 163 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr
otasks); | |
| 164 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca
llFrame); | |
| 165 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(
toV8StringInternalized(m_isolate, name))); | |
| 166 v8::Local<v8::Array> locations = v8::Local<v8::Array>::Cast(func->Call(m_iso
late->GetCurrentContext(), callFrame, 0, nullptr).ToLocalChecked()); | |
| 167 return locations->Get(scopeIndex); | |
| 168 } | |
| 169 | |
| 170 v8::Local<v8::Value> JavaScriptCallFrame::thisObject() const | |
| 171 { | |
| 172 return v8::Local<v8::Object>::New(m_isolate, m_callFrame)->Get(toV8StringInt
ernalized(m_isolate, "thisObject")); | |
| 173 } | |
| 174 | |
| 175 String16 JavaScriptCallFrame::stepInPositions() const | |
| 176 { | |
| 177 return callV8FunctionReturnString("stepInPositions"); | |
| 178 } | |
| 179 | |
| 180 bool JavaScriptCallFrame::isAtReturn() const | 88 bool JavaScriptCallFrame::isAtReturn() const |
| 181 { | 89 { |
| 182 v8::HandleScope handleScope(m_isolate); | 90 v8::HandleScope handleScope(m_isolate); |
| 183 v8::Local<v8::Value> result = v8::Local<v8::Object>::New(m_isolate, m_callFr
ame)->Get(toV8StringInternalized(m_isolate, "isAtReturn")); | 91 v8::Local<v8::Value> result = v8::Local<v8::Object>::New(m_isolate, m_callFr
ame)->Get(toV8StringInternalized(m_isolate, "isAtReturn")); |
| 184 if (result.IsEmpty() || !result->IsBoolean()) | 92 if (result.IsEmpty() || !result->IsBoolean()) |
| 185 return false; | 93 return false; |
| 186 return result->BooleanValue(); | 94 return result->BooleanValue(); |
| 187 } | 95 } |
| 188 | 96 |
| 189 v8::Local<v8::Value> JavaScriptCallFrame::returnValue() const | 97 v8::Local<v8::Object> JavaScriptCallFrame::details() const |
| 190 { | 98 { |
| 191 return v8::Local<v8::Object>::New(m_isolate, m_callFrame)->Get(toV8StringInt
ernalized(m_isolate, "returnValue")); | 99 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr
otasks); |
| 100 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca
llFrame); |
| 101 v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(
toV8StringInternalized(m_isolate, "details"))); |
| 102 return v8::Local<v8::Object>::Cast(func->Call(m_isolate->GetCurrentContext()
, callFrame, 0, nullptr).ToLocalChecked()); |
| 192 } | 103 } |
| 193 | 104 |
| 194 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::evaluate(v8::Local<v8::Value> exp
ression) | 105 v8::MaybeLocal<v8::Value> JavaScriptCallFrame::evaluate(v8::Local<v8::Value> exp
ression) |
| 195 { | 106 { |
| 196 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kRunMicrotask
s); | 107 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kRunMicrotask
s); |
| 197 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca
llFrame); | 108 v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_ca
llFrame); |
| 198 v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast(callFra
me->Get(toV8StringInternalized(m_isolate, "evaluate"))); | 109 v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast(callFra
me->Get(toV8StringInternalized(m_isolate, "evaluate"))); |
| 199 return evalFunction->Call(m_isolate->GetCurrentContext(), callFrame, 1, &exp
ression); | 110 return evalFunction->Call(m_isolate->GetCurrentContext(), callFrame, 1, &exp
ression); |
| 200 } | 111 } |
| 201 | 112 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 217 v8::Local<v8::Function> setVariableValueFunction = v8::Local<v8::Function>::
Cast(callFrame->Get(toV8StringInternalized(m_isolate, "setVariableValue"))); | 128 v8::Local<v8::Function> setVariableValueFunction = v8::Local<v8::Function>::
Cast(callFrame->Get(toV8StringInternalized(m_isolate, "setVariableValue"))); |
| 218 v8::Local<v8::Value> argv[] = { | 129 v8::Local<v8::Value> argv[] = { |
| 219 v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)), | 130 v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)), |
| 220 variableName, | 131 variableName, |
| 221 newValue | 132 newValue |
| 222 }; | 133 }; |
| 223 return setVariableValueFunction->Call(m_isolate->GetCurrentContext(), callFr
ame, WTF_ARRAY_LENGTH(argv), argv); | 134 return setVariableValueFunction->Call(m_isolate->GetCurrentContext(), callFr
ame, WTF_ARRAY_LENGTH(argv), argv); |
| 224 } | 135 } |
| 225 | 136 |
| 226 } // namespace blink | 137 } // namespace blink |
| OLD | NEW |