diff options
-rw-r--r-- | src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerCallFrame.h | 3 | ||||
-rw-r--r-- | src/script/api/qscriptengineagent.cpp | 54 | ||||
-rw-r--r-- | src/script/api/qscriptengineagent_p.h | 15 |
3 files changed, 42 insertions, 30 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerCallFrame.h b/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerCallFrame.h index 9d377ef..5984fab 100644 --- a/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerCallFrame.h +++ b/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerCallFrame.h @@ -56,6 +56,9 @@ namespace JSC { JSObject* thisObject() const; JSValue evaluate(const UString&, JSValue& exception) const; JSValue exception() const { return m_exception; } +#if QT_BUILD_SCRIPT_LIB + CallFrame* callFrame() const { return m_callFrame; } +#endif private: CallFrame* m_callFrame; diff --git a/src/script/api/qscriptengineagent.cpp b/src/script/api/qscriptengineagent.cpp index 4f89e81..ba8e5e9 100644 --- a/src/script/api/qscriptengineagent.cpp +++ b/src/script/api/qscriptengineagent.cpp @@ -42,6 +42,8 @@ #include "config.h" #include "qscriptengineagent.h" #include "qscriptengineagent_p.h" +#include "qscriptengine.h" +#include "qscriptengine_p.h" #include "CodeBlock.h" #include "Instruction.h" @@ -130,47 +132,67 @@ QT_BEGIN_NAMESPACE void QScriptEngineAgentPrivate::attach() { - QScriptEnginePrivate *d = QScriptEnginePrivate::get(engine); - if (d->originalGlobalObject()->debugger()) - d->originalGlobalObject()->setDebugger(0); - JSC::Debugger::attach(d->originalGlobalObject()); + if (engine->originalGlobalObject()->debugger()) + engine->originalGlobalObject()->setDebugger(0); + JSC::Debugger::attach(engine->originalGlobalObject()); } void QScriptEngineAgentPrivate::detach() { - JSC::Debugger::detach(QScriptEnginePrivate::get(engine)->originalGlobalObject()); + JSC::Debugger::detach(engine->originalGlobalObject()); } void QScriptEngineAgentPrivate::exceptionThrow(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, bool hasHandler) { - QScriptValue value(QScriptEnginePrivate::get(engine)->scriptValueFromJSCValue(frame.exception())); + JSC::CallFrame *oldFrame = engine->currentFrame; + engine->currentFrame = frame.callFrame(); + QScriptValue value(engine->scriptValueFromJSCValue(frame.exception())); q_ptr->exceptionThrow(sourceID, value, hasHandler); + engine->currentFrame = oldFrame; }; void QScriptEngineAgentPrivate::exceptionCatch(const JSC::DebuggerCallFrame& frame, intptr_t sourceID) { - QScriptValue value(QScriptEnginePrivate::get(engine)->scriptValueFromJSCValue(frame.exception())); + JSC::CallFrame *oldFrame = engine->currentFrame; + engine->currentFrame = frame.callFrame(); + QScriptValue value(engine->scriptValueFromJSCValue(frame.exception())); q_ptr->exceptionCatch(sourceID, value); + engine->currentFrame = oldFrame; } -void QScriptEngineAgentPrivate::atStatement(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno, int column) +void QScriptEngineAgentPrivate::atStatement(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno, int column) { + JSC::CallFrame *oldFrame = engine->currentFrame; + engine->currentFrame = frame.callFrame(); q_ptr->positionChange(sourceID, lineno, column); + engine->currentFrame = oldFrame; } void QScriptEngineAgentPrivate::functionExit(const JSC::JSValue& returnValue, intptr_t sourceID) { - QScriptValue result = QScriptEnginePrivate::get(engine)->scriptValueFromJSCValue(returnValue); + QScriptValue result = engine->scriptValueFromJSCValue(returnValue); q_ptr->functionExit(sourceID, result); q_ptr->contextPop(); } void QScriptEngineAgentPrivate::evaluateStop(const JSC::JSValue& returnValue, intptr_t sourceID) { - QScriptValue result = QScriptEnginePrivate::get(engine)->scriptValueFromJSCValue(returnValue); + QScriptValue result = engine->scriptValueFromJSCValue(returnValue); q_ptr->functionExit(sourceID, result); } +void QScriptEngineAgentPrivate::didReachBreakpoint(const JSC::DebuggerCallFrame& frame, + intptr_t sourceID, int lineno, int column) +{ + if (q_ptr->supportsExtension(QScriptEngineAgent::DebuggerInvocationRequest)) { + JSC::CallFrame *oldFrame = engine->currentFrame; + engine->currentFrame = frame.callFrame(); + QList<QVariant> args; + args << qint64(sourceID) << lineno << column; + q_ptr->extension(QScriptEngineAgent::DebuggerInvocationRequest, args); + engine->currentFrame = oldFrame; + } +}; /*! Constructs a QScriptEngineAgent object for the given \a engine. @@ -183,11 +205,8 @@ void QScriptEngineAgentPrivate::evaluateStop(const JSC::JSValue& returnValue, in QScriptEngineAgent::QScriptEngineAgent(QScriptEngine *engine) : d_ptr(new QScriptEngineAgentPrivate()) { - d_ptr->engine = engine; d_ptr->q_ptr = this; - if (engine) { - d_ptr->engine->setAgent(this); - } + d_ptr->engine = QScriptEnginePrivate::get(engine); } /*! @@ -197,7 +216,7 @@ QScriptEngineAgent::QScriptEngineAgent(QScriptEngineAgentPrivate &dd, QScriptEng : d_ptr(&dd) { d_ptr->q_ptr = this; - d_ptr->engine = engine; + d_ptr->engine = QScriptEnginePrivate::get(engine); } /*! @@ -205,8 +224,7 @@ QScriptEngineAgent::QScriptEngineAgent(QScriptEngineAgentPrivate &dd, QScriptEng */ QScriptEngineAgent::~QScriptEngineAgent() { - QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine()); - eng_p->agentDeleted(this); + d_ptr->engine->agentDeleted(this); delete d_ptr; d_ptr = 0; } @@ -470,7 +488,7 @@ QVariant QScriptEngineAgent::extension(Extension extension, QScriptEngine *QScriptEngineAgent::engine() const { Q_D(const QScriptEngineAgent); - return d->engine; + return QScriptEnginePrivate::get(d->engine); } QT_END_NAMESPACE diff --git a/src/script/api/qscriptengineagent_p.h b/src/script/api/qscriptengineagent_p.h index 183a02c..64befc1 100644 --- a/src/script/api/qscriptengineagent_p.h +++ b/src/script/api/qscriptengineagent_p.h @@ -56,8 +56,6 @@ #include <QtCore/qobjectdefs.h> #include "Debugger.h" #include "qscriptengineagent.h" -#include "qscriptengine.h" -#include "qscriptengine_p.h" #include "CallFrame.h" #include "SourceCode.h" @@ -66,7 +64,7 @@ QT_BEGIN_NAMESPACE -class QScriptEngine; +class QScriptEnginePrivate; class QScriptEngineAgent; class Q_SCRIPT_EXPORT QScriptEngineAgentPrivate : public JSC::Debugger @@ -132,14 +130,7 @@ public: }; virtual void functionExit(const JSC::JSValue& returnValue, intptr_t sourceID); //others - virtual void didReachBreakpoint(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno, int column) - { - Q_UNUSED(frame); - QList<QVariant> args; - args << qint64(sourceID) << lineno << column; - if (q_ptr->supportsExtension(QScriptEngineAgent::DebuggerInvocationRequest)) - q_ptr->extension(QScriptEngineAgent::DebuggerInvocationRequest, args); - }; + virtual void didReachBreakpoint(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno, int column); virtual void evaluateStart(intptr_t sourceID) { @@ -147,7 +138,7 @@ public: } virtual void evaluateStop(const JSC::JSValue& returnValue, intptr_t sourceID); - QScriptEngine *engine; + QScriptEnginePrivate *engine; QScriptEngineAgent *q_ptr; }; |