| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 { | 49 { |
| 50 } | 50 } |
| 51 | 51 |
| 52 JavaScriptCallFrame* JavaScriptCallFrame::caller() | 52 JavaScriptCallFrame* JavaScriptCallFrame::caller() |
| 53 { | 53 { |
| 54 if (!m_caller) { | 54 if (!m_caller) { |
| 55 v8::HandleScope handleScope(m_isolate); | 55 v8::HandleScope handleScope(m_isolate); |
| 56 v8::Handle<v8::Context> debuggerContext = m_debuggerContext.newLocal(m_i
solate); | 56 v8::Handle<v8::Context> debuggerContext = m_debuggerContext.newLocal(m_i
solate); |
| 57 v8::Context::Scope contextScope(debuggerContext); | 57 v8::Context::Scope contextScope(debuggerContext); |
| 58 v8::Handle<v8::Value> callerFrame = m_callFrame.newLocal(m_isolate)->Get
(v8AtomicString(m_isolate, "caller")); | 58 v8::Handle<v8::Value> callerFrame = m_callFrame.newLocal(m_isolate)->Get
(v8AtomicString(m_isolate, "caller")); |
| 59 if (!callerFrame->IsObject()) | 59 if (callerFrame.IsEmpty() || !callerFrame->IsObject()) |
| 60 return 0; | 60 return 0; |
| 61 m_caller = JavaScriptCallFrame::create(debuggerContext, v8::Handle<v8::O
bject>::Cast(callerFrame)); | 61 m_caller = JavaScriptCallFrame::create(debuggerContext, v8::Handle<v8::O
bject>::Cast(callerFrame)); |
| 62 } | 62 } |
| 63 return m_caller.get(); | 63 return m_caller.get(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 int JavaScriptCallFrame::callV8FunctionReturnInt(const char* name) const | 66 int JavaScriptCallFrame::callV8FunctionReturnInt(const char* name) const |
| 67 { | 67 { |
| 68 v8::HandleScope handleScope(m_isolate); | 68 v8::HandleScope handleScope(m_isolate); |
| 69 v8::Context::Scope contextScope(m_debuggerContext.newLocal(m_isolate)); |
| 69 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 70 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); |
| 70 v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(callFrame->Ge
t(v8AtomicString(m_isolate, name))); | 71 v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(callFrame->Ge
t(v8AtomicString(m_isolate, name))); |
| 71 v8::Handle<v8::Value> result = func->Call(callFrame, 0, 0); | 72 v8::Handle<v8::Value> result = func->Call(callFrame, 0, 0); |
| 72 if (result->IsInt32()) | 73 if (result.IsEmpty() || !result->IsInt32()) |
| 73 return result->Int32Value(); | 74 return 0; |
| 74 return 0; | 75 return result->Int32Value(); |
| 75 } | 76 } |
| 76 | 77 |
| 77 String JavaScriptCallFrame::callV8FunctionReturnString(const char* name) const | 78 String JavaScriptCallFrame::callV8FunctionReturnString(const char* name) const |
| 78 { | 79 { |
| 79 v8::HandleScope handleScope(m_isolate); | 80 v8::HandleScope handleScope(m_isolate); |
| 81 v8::Context::Scope contextScope(m_debuggerContext.newLocal(m_isolate)); |
| 80 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 82 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); |
| 81 v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(callFrame->Ge
t(v8AtomicString(m_isolate, name))); | 83 v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(callFrame->Ge
t(v8AtomicString(m_isolate, name))); |
| 82 v8::Handle<v8::Value> result = func->Call(callFrame, 0, 0); | 84 v8::Handle<v8::Value> result = func->Call(callFrame, 0, 0); |
| 83 return toCoreStringWithUndefinedOrNullCheck(result); | 85 return toCoreStringWithUndefinedOrNullCheck(result); |
| 84 } | 86 } |
| 85 | 87 |
| 86 int JavaScriptCallFrame::sourceID() const | 88 int JavaScriptCallFrame::sourceID() const |
| 87 { | 89 { |
| 88 return callV8FunctionReturnInt("sourceID"); | 90 return callV8FunctionReturnInt("sourceID"); |
| 89 } | 91 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 String JavaScriptCallFrame::stepInPositions() const | 135 String JavaScriptCallFrame::stepInPositions() const |
| 134 { | 136 { |
| 135 return callV8FunctionReturnString("stepInPositions"); | 137 return callV8FunctionReturnString("stepInPositions"); |
| 136 } | 138 } |
| 137 | 139 |
| 138 bool JavaScriptCallFrame::isAtReturn() const | 140 bool JavaScriptCallFrame::isAtReturn() const |
| 139 { | 141 { |
| 140 v8::HandleScope handleScope(m_isolate); | 142 v8::HandleScope handleScope(m_isolate); |
| 141 v8::Context::Scope contextScope(m_debuggerContext.newLocal(m_isolate)); | 143 v8::Context::Scope contextScope(m_debuggerContext.newLocal(m_isolate)); |
| 142 v8::Handle<v8::Value> result = m_callFrame.newLocal(m_isolate)->Get(v8Atomic
String(m_isolate, "isAtReturn")); | 144 v8::Handle<v8::Value> result = m_callFrame.newLocal(m_isolate)->Get(v8Atomic
String(m_isolate, "isAtReturn")); |
| 143 if (result->IsBoolean()) | 145 if (result.IsEmpty() || !result->IsBoolean()) |
| 144 return result->BooleanValue(); | 146 return false; |
| 145 return false; | 147 return result->BooleanValue(); |
| 146 } | 148 } |
| 147 | 149 |
| 148 v8::Handle<v8::Value> JavaScriptCallFrame::returnValue() const | 150 v8::Handle<v8::Value> JavaScriptCallFrame::returnValue() const |
| 149 { | 151 { |
| 150 return m_callFrame.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "retur
nValue")); | 152 return m_callFrame.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "retur
nValue")); |
| 151 } | 153 } |
| 152 | 154 |
| 153 v8::Handle<v8::Value> JavaScriptCallFrame::evaluateWithExceptionDetails(const St
ring& expression) | 155 v8::Handle<v8::Value> JavaScriptCallFrame::evaluateWithExceptionDetails(const St
ring& expression) |
| 154 { | 156 { |
| 155 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 157 v8::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), v8
::Undefined(isolate)); | 207 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), v8
::Undefined(isolate)); |
| 206 return exceptionDetails; | 208 return exceptionDetails; |
| 207 } | 209 } |
| 208 | 210 |
| 209 void JavaScriptCallFrame::trace(Visitor* visitor) | 211 void JavaScriptCallFrame::trace(Visitor* visitor) |
| 210 { | 212 { |
| 211 visitor->trace(m_caller); | 213 visitor->trace(m_caller); |
| 212 } | 214 } |
| 213 | 215 |
| 214 } // namespace blink | 216 } // namespace blink |
| OLD | NEW |