summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/script/api/qscriptcontext.cpp2
-rw-r--r--src/script/api/qscriptengine.cpp10
-rw-r--r--src/script/api/qscriptengine_p.h1
3 files changed, 10 insertions, 3 deletions
diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp
index 2ca6d26..199ee66 100644
--- a/src/script/api/qscriptcontext.cpp
+++ b/src/script/api/qscriptcontext.cpp
@@ -571,7 +571,7 @@ void QScriptContext::setThisObject(const QScriptValue &thisObject)
if (cb != 0) {
frame[cb->thisRegister()] = jscThisObject;
} else {
- JSC::Register* thisRegister = frame->registers() - JSC::RegisterFile::CallFrameHeaderSize - frame->argumentCount();
+ JSC::Register* thisRegister = QScriptEnginePrivate::thisRegisterForFrame(frame);
thisRegister[0] = jscThisObject;
}
}
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index e39e1d1..163cf5f 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -1077,11 +1077,17 @@ JSC::JSValue QScriptEnginePrivate::thisForContext(JSC::ExecState *frame)
if (frame->codeBlock() != 0) {
return frame->thisValue();
} else {
- JSC::Register* thisRegister = frame->registers() - JSC::RegisterFile::CallFrameHeaderSize - frame->argumentCount();
+ JSC::Register *thisRegister = thisRegisterForFrame(frame);
return thisRegister->jsValue();
}
}
+JSC::Register* QScriptEnginePrivate::thisRegisterForFrame(JSC::ExecState *frame)
+{
+ Q_ASSERT(frame->codeBlock() == 0); // only for native calls
+ return frame->registers() - JSC::RegisterFile::CallFrameHeaderSize - frame->argumentCount();
+}
+
/*! \internal
For native context, we use the ReturnValueRegister entry in the stackframe header to store flags.
We can do that because this header is not used as the native function return their value thought C++
@@ -2306,7 +2312,7 @@ JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, JSC::JSV
#endif
if (calledAsConstructor) {
//update the new created this
- JSC::Register* thisRegister = newCallFrame->registers() - JSC::RegisterFile::CallFrameHeaderSize - newCallFrame->argumentCount();
+ JSC::Register* thisRegister = thisRegisterForFrame(newCallFrame);
*thisRegister = thisObject;
}
}
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index b36787b..c7db276 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -154,6 +154,7 @@ public:
JSC::ExecState *globalExec() const;
JSC::JSValue toUsableValue(JSC::JSValue value);
static JSC::JSValue thisForContext(JSC::ExecState *frame);
+ static JSC::Register *thisRegisterForFrame(JSC::ExecState *frame);
JSC::CallFrame *pushContext(JSC::CallFrame *exec, JSC::JSValue thisObject, const JSC::ArgList& args,
JSC::JSObject *callee, bool calledAsConstructor = false);