src/script/api/qscriptengineagent.cpp
changeset 37 758a864f9613
parent 30 5dc02b23752f
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
   115 void QScriptEngineAgentPrivate::attach()
   115 void QScriptEngineAgentPrivate::attach()
   116 {
   116 {
   117     if (engine->originalGlobalObject()->debugger())
   117     if (engine->originalGlobalObject()->debugger())
   118         engine->originalGlobalObject()->setDebugger(0);
   118         engine->originalGlobalObject()->setDebugger(0);
   119     JSC::Debugger::attach(engine->originalGlobalObject());
   119     JSC::Debugger::attach(engine->originalGlobalObject());
       
   120     if (!QScriptEnginePrivate::get(engine)->isEvaluating())
       
   121         JSC::Debugger::recompileAllJSFunctions(engine->globalData);
   120 }
   122 }
   121 
   123 
   122 void QScriptEngineAgentPrivate::detach()
   124 void QScriptEngineAgentPrivate::detach()
   123 {
   125 {
   124     JSC::Debugger::detach(engine->originalGlobalObject());
   126     JSC::Debugger::detach(engine->originalGlobalObject());
   132 }
   134 }
   133 
   135 
   134 void QScriptEngineAgentPrivate::exceptionThrow(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, bool hasHandler)
   136 void QScriptEngineAgentPrivate::exceptionThrow(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, bool hasHandler)
   135 {
   137 {
   136     JSC::CallFrame *oldFrame = engine->currentFrame;
   138     JSC::CallFrame *oldFrame = engine->currentFrame;
       
   139     int oldAgentLineNumber = engine->agentLineNumber;
   137     engine->currentFrame = frame.callFrame();
   140     engine->currentFrame = frame.callFrame();
   138     QScriptValue value(engine->scriptValueFromJSCValue(frame.exception()));
   141     QScriptValue value(engine->scriptValueFromJSCValue(frame.exception()));
       
   142     engine->agentLineNumber = value.property(QLatin1String("lineNumber")).toInt32();
   139     q_ptr->exceptionThrow(sourceID, value, hasHandler);
   143     q_ptr->exceptionThrow(sourceID, value, hasHandler);
       
   144     engine->agentLineNumber = oldAgentLineNumber;
   140     engine->currentFrame = oldFrame;
   145     engine->currentFrame = oldFrame;
   141     engine->setCurrentException(value);
   146     engine->setCurrentException(value);
   142 };
   147 };
   143 
   148 
   144 void QScriptEngineAgentPrivate::exceptionCatch(const JSC::DebuggerCallFrame& frame, intptr_t sourceID)
   149 void QScriptEngineAgentPrivate::exceptionCatch(const JSC::DebuggerCallFrame& frame, intptr_t sourceID)
   365 }
   370 }
   366 
   371 
   367 /*!
   372 /*!
   368   This function is called when the engine is about to execute a new
   373   This function is called when the engine is about to execute a new
   369   statement in the script identified by \a scriptId.  The statement
   374   statement in the script identified by \a scriptId.  The statement
   370   begins on the line and column specified by \a lineNumber and \a
   375   begins on the line and column specified by \a lineNumber
   371   columnNumber.  This event is not generated for native Qt Script
   376   This event is not generated for native Qt Script functions.
   372   functions.
       
   373 
   377 
   374   Reimplement this function to handle this event. For example, a
   378   Reimplement this function to handle this event. For example, a
   375   debugger implementation could reimplement this function to provide
   379   debugger implementation could reimplement this function to provide
   376   line-by-line stepping, and a profiler implementation could use it to
   380   line-by-line stepping, and a profiler implementation could use it to
   377   count the number of times each statement is executed.
   381   count the number of times each statement is executed.
   378 
   382 
   379   The default implementation does nothing.
   383   The default implementation does nothing.
       
   384 
       
   385   \note \a columnNumber is undefined
   380 
   386 
   381   \sa scriptLoad(), functionEntry()
   387   \sa scriptLoad(), functionEntry()
   382 */
   388 */
   383 void QScriptEngineAgent::positionChange(qint64 scriptId,
   389 void QScriptEngineAgent::positionChange(qint64 scriptId,
   384                                         int lineNumber, int columnNumber)
   390                                         int lineNumber, int columnNumber)