diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-08-11 07:35:50 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-08-11 07:44:24 (GMT) |
commit | 81d8292e486bce768d9af27e3510520a769c4fa8 (patch) | |
tree | f2925d15dc89a6bb64b34ecf162d6ac9fa5e312d /src/script/api/qscriptcontext.cpp | |
parent | 62281ca6f9e74a5c8b66204d74ceec0215ecab92 (diff) | |
download | Qt-81d8292e486bce768d9af27e3510520a769c4fa8.zip Qt-81d8292e486bce768d9af27e3510520a769c4fa8.tar.gz Qt-81d8292e486bce768d9af27e3510520a769c4fa8.tar.bz2 |
Fix line number and arguments in QScriptContext::toString
For arguments, we always need to skip the implicit 'this' argument
For line number, we walk thought the stack frames from the top to find
the one above the requested one, which contains the returnPC we need.
Also fixed a crash because QScriptContext::parentContext would have
returned a pointer with flags inside.
Reviewed-by: Kent Hansen
Diffstat (limited to 'src/script/api/qscriptcontext.cpp')
-rw-r--r-- | src/script/api/qscriptcontext.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp index 669002d..f4b8af6 100644 --- a/src/script/api/qscriptcontext.cpp +++ b/src/script/api/qscriptcontext.cpp @@ -273,8 +273,7 @@ QScriptValue QScriptContext::argument(int index) const if (index >= argumentCount()) return QScriptValue(QScriptValue::UndefinedValue); JSC::Register* thisRegister = frame->registers() - JSC::RegisterFile::CallFrameHeaderSize - frame->argumentCount(); - if (frame->codeBlock() == 0) - ++index; // ### off-by-one issue with native functions + ++index; //skip the 'this' object return QScript::scriptEngineFromExec(frame)->scriptValueFromJSCValue(thisRegister[index].jsValue()); } @@ -370,9 +369,7 @@ bool QScriptContext::isCalledAsConstructor() const QScriptContext *QScriptContext::parentContext() const { const JSC::CallFrame *frame = QScriptEnginePrivate::frameForContext(this); - JSC::CallFrame *callerFrame = frame->callerFrame(); - if (callerFrame == (JSC::CallFrame*)(1)) // ### CallFrame::noCaller() is private - return 0; + JSC::CallFrame *callerFrame = frame->callerFrame()->removeHostCallFrameFlag(); return reinterpret_cast<QScriptContext *>(callerFrame); } |