diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-07-09 12:52:41 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-07-09 12:52:41 (GMT) |
commit | 55507beaedf1ef277b84bf6b2dba6182b8c345c2 (patch) | |
tree | 42971ff75466e79834ee439b9d4a61b404c58c56 | |
parent | 07d33b502578497a3e142d0d410b0a0b1acb12f1 (diff) | |
download | Qt-55507beaedf1ef277b84bf6b2dba6182b8c345c2.zip Qt-55507beaedf1ef277b84bf6b2dba6182b8c345c2.tar.gz Qt-55507beaedf1ef277b84bf6b2dba6182b8c345c2.tar.bz2 |
use JSC::call() and JSC::construct()
-rw-r--r-- | src/script/api/qscriptvalue.cpp | 56 |
1 files changed, 2 insertions, 54 deletions
diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 13cef76..e523c93 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -1901,31 +1901,9 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject, JSC::ArgList jscArgs(argsVector.data(), argsVector.size()); JSC::JSValue callee = d->jscValue; - JSC::JSValue result; JSC::CallData callData; JSC::CallType callType = callee.getCallData(callData); - if (callType == JSC::CallTypeJS) { - result = JSC::asFunction(callee)->call(exec, jscThisObject, jscArgs); - } else if (callType == JSC::CallTypeHost) { - JSC::ScopeChainNode* scopeChain = exec->scopeChain(); - JSC::Interpreter *interp = exec->interpreter(); - JSC::Register *oldEnd = interp->registerFile().end(); - int argc = 1 + jscArgs.size(); // implicit "this" parameter - if (!interp->registerFile().grow(oldEnd + argc + JSC::RegisterFile::CallFrameHeaderSize)) { - Q_ASSERT_X(false, Q_FUNC_INFO, "stack overflow"); - } - JSC::CallFrame* newCallFrame = JSC::CallFrame::create(oldEnd); - size_t dst = 0; - newCallFrame[0] = jscThisObject; - JSC::ArgList::const_iterator it; - for (it = jscArgs.begin(); it != jscArgs.end(); ++it) - newCallFrame[++dst] = *it; - newCallFrame += argc + JSC::RegisterFile::CallFrameHeaderSize; - // ### dst? - newCallFrame->init(0, /*vPC=*/0, scopeChain, exec, dst, argc, JSC::asObject(callee)); - result = callData.native.function(newCallFrame, JSC::asObject(callee), jscThisObject, jscArgs); - interp->registerFile().shrink(oldEnd); - } + JSC::JSValue result = JSC::call(exec, callee, callType, callData, jscThisObject, jscArgs); if (exec->hadException()) eng_p->uncaughtException = exec->exception(); return eng_p->scriptValueFromJSCValue(result); @@ -2067,39 +2045,9 @@ QScriptValue QScriptValue::construct(const QScriptValueList &args) JSC::ArgList jscArgs(argsVector.data(), argsVector.size()); JSC::JSValue callee = d->jscValue; - JSC::JSValue result; JSC::ConstructData constructData; JSC::ConstructType constructType = callee.getConstructData(constructData); - if (constructType == JSC::ConstructTypeJS) { - result = JSC::asFunction(callee)->construct(exec, jscArgs); - } else if (constructType == JSC::ConstructTypeHost) { - JSC::Structure* structure; - JSC::JSValue prototype = callee.get(exec, exec->propertyNames().prototype); - if (prototype.isObject()) - structure = asObject(prototype)->inheritorID(); - else - structure = exec->lexicalGlobalObject()->emptyObjectStructure(); - JSC::JSObject* thisObj = new (exec) JSC::JSObject(structure); - // ### avoid copy+paste of call() - JSC::ScopeChainNode* scopeChain = exec->scopeChain(); - JSC::Interpreter *interp = exec->interpreter(); - JSC::Register *oldEnd = interp->registerFile().end(); - int argc = 1 + jscArgs.size(); // implicit "this" parameter - if (!interp->registerFile().grow(oldEnd + argc + JSC::RegisterFile::CallFrameHeaderSize)) { - Q_ASSERT_X(false, Q_FUNC_INFO, "stack overflow"); - } - JSC::CallFrame* newCallFrame = JSC::CallFrame::create(oldEnd); - size_t dst = 0; - newCallFrame[0] = JSC::JSValue(thisObj); - JSC::ArgList::const_iterator it; - for (it = jscArgs.begin(); it != jscArgs.end(); ++it) - newCallFrame[++dst] = *it; - newCallFrame += argc + JSC::RegisterFile::CallFrameHeaderSize; - // ### dst? - newCallFrame->init(0, /*vPC=*/0, scopeChain, exec, dst, argc, JSC::asObject(callee)); - result = constructData.native.function(newCallFrame, JSC::asObject(callee), jscArgs); - interp->registerFile().shrink(oldEnd); - } + JSC::JSObject *result = JSC::construct(exec, callee, constructType, constructData, jscArgs); if (exec->hadException()) eng_p->uncaughtException = exec->exception(); return eng_p->scriptValueFromJSCValue(result); |