From 6985212c8909c89183b232ca28b96a2c8a2f1385 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 9 Jul 2009 12:44:52 +0200 Subject: 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). --- .../webkit/JavaScriptCore/interpreter/Interpreter.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) 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)); -- cgit v0.12