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::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 69 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))); | 70 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); | 71 v8::Handle<v8::Value> result = func->Call(callFrame, 0, 0); |
72 if (result->IsInt32()) | 72 if (result.IsEmpty() || !result->IsInt32()) |
aandrey
2014/07/25 10:00:51
maybe we should add a context scope:
v8::Context::
aandrey
2014/07/25 10:11:52
Done.
| |
73 return result->Int32Value(); | 73 return 0; |
74 return 0; | 74 return result->Int32Value(); |
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::Handle<v8::Object> callFrame = m_callFrame.newLocal(m_isolate); | 80 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))); | 81 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); | 82 v8::Handle<v8::Value> result = func->Call(callFrame, 0, 0); |
83 return toCoreStringWithUndefinedOrNullCheck(result); | 83 return toCoreStringWithUndefinedOrNullCheck(result); |
84 } | 84 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 String JavaScriptCallFrame::stepInPositions() const | 133 String JavaScriptCallFrame::stepInPositions() const |
134 { | 134 { |
135 return callV8FunctionReturnString("stepInPositions"); | 135 return callV8FunctionReturnString("stepInPositions"); |
136 } | 136 } |
137 | 137 |
138 bool JavaScriptCallFrame::isAtReturn() const | 138 bool JavaScriptCallFrame::isAtReturn() const |
139 { | 139 { |
140 v8::HandleScope handleScope(m_isolate); | 140 v8::HandleScope handleScope(m_isolate); |
141 v8::Context::Scope contextScope(m_debuggerContext.newLocal(m_isolate)); | 141 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")); | 142 v8::Handle<v8::Value> result = m_callFrame.newLocal(m_isolate)->Get(v8Atomic String(m_isolate, "isAtReturn")); |
143 if (result->IsBoolean()) | 143 if (result.IsEmpty() || !result->IsBoolean()) |
144 return result->BooleanValue(); | 144 return false; |
145 return false; | 145 return result->BooleanValue(); |
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::evaluateWithExceptionDetails(const St ring& 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); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), v8 ::Undefined(isolate)); | 205 exceptionDetails->Set(v8::String::NewFromUtf8(isolate, "stackTrace"), v8 ::Undefined(isolate)); |
206 return exceptionDetails; | 206 return exceptionDetails; |
207 } | 207 } |
208 | 208 |
209 void JavaScriptCallFrame::trace(Visitor* visitor) | 209 void JavaScriptCallFrame::trace(Visitor* visitor) |
210 { | 210 { |
211 visitor->trace(m_caller); | 211 visitor->trace(m_caller); |
212 } | 212 } |
213 | 213 |
214 } // namespace blink | 214 } // namespace blink |
OLD | NEW |