summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-07-09 10:44:52 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-07-09 10:44:52 (GMT)
commit6985212c8909c89183b232ca28b96a2c8a2f1385 (patch)
treef7a81e7be10b9e1f6051052ab414d1ae4dd467d5 /src/3rdparty/webkit
parentd8cde61540b94e36a759d9d6a5adbb432f3625ea (diff)
downloadQt-6985212c8909c89183b232ca28b96a2c8a2f1385.zip
Qt-6985212c8909c89183b232ca28b96a2c8a2f1385.tar.gz
Qt-6985212c8909c89183b232ca28b96a2c8a2f1385.tar.bz2
create a default-constructed object when calling native constructors
It's up to the implementation of the constructor to decide whether it wants to initialize the default-constructed object, or create and return a new one; just like for JS constructors. We need this functionality in QtScript so that QScriptContext::thisObject() will return the right thing. The built-in constructors (RegExp etc.) should be modified to initialize the default-constructed object instead of always creating a new object (only when RegExp is called as a function should it create a new object).
Diffstat (limited to 'src/3rdparty/webkit')
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp b/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp
index f8a3746..d9c5cda 100644
--- a/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/interpreter/Interpreter.cpp
@@ -3495,6 +3495,17 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
ArgList args(callFrame->registers() + thisRegister + 1, argCount - 1);
ScopeChainNode* scopeChain = callFrame->scopeChain();
+
+ Structure* structure;
+ JSValue prototype = callFrame[proto].jsValue();
+ if (prototype.isObject())
+ structure = asObject(prototype)->inheritorID();
+ else
+ structure = scopeChain->globalObject()->emptyObjectStructure();
+ JSObject* newObject = new (globalData) JSObject(structure);
+
+ callFrame[thisRegister] = JSValue(newObject); // "this" value
+
CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + registerOffset);
newCallFrame->init(0, vPC + 7, scopeChain, callFrame, dst, argCount, asObject(v));