QVariant QuickInterpreter::call(QSObject ctx, const QString &func, const QSList &args) { if (shuttingDown) return QVariant(); QSEngine::call(&ctx, func, args); if (hadError()) emit runtimeError(); // Make sure we dereference the engines return value to avoid pooling QVariant a = convertToArgument(returnValue()); setReturnValue(QSObject()); return a; }
QVariant QuickInterpreter::execute(QObject *obj, const QString &c, const QString &name) { QString code = c + QString::fromLatin1("\n"); int sourceId = debugger ? debugger->freeSourceId() : -1; if(!name.isNull() && sourceId >= 0) sourceIdNames[sourceId] = name; QSObject t, oldThis; if (obj) { if (!name.isNull() && sourceId >= 0) addSourceId(sourceId, obj); if (!hasTopLevelParent(obj)) addTopLevelObject(obj); t = wrap(obj); oldThis = env()->thisValue(); env()->setThisValue(t); } QSEngine::evaluate(t, code); // restore this value if (obj) env()->setThisValue(oldThis); if (hadError()) if(errorType() == QSErrParseError) emit parseError(); else emit runtimeError(); // Make sure we dereference the engines return value to avoid pooling QVariant a = convertToArgument(returnValue()); setReturnValue(QSObject()); return a; }
SimdFunctionCall::SimdFunctionCall (SimdInterpreter &interpreter, const string &name, FunctionTypePtr type, SimdInstAddrPtr addr, SymbolTable &symbols) : FunctionCall (name), _xcontext (interpreter), _entryPoint (addr->inst()), _symbols(symbols) { { SimdReg *returnReg = new SimdReg (type->returnVarying(), type->returnType()->alignedObjectSize()); _xcontext.stack().push (returnReg, TAKE_OWNERSHIP); setReturnValue (new SimdFunctionArg ("", this, type->returnType(), type->returnVarying(), returnReg)); } const ParamVector ¶meters = type->parameters(); vector<FunctionArgPtr> inputs; vector<FunctionArgPtr> outputs; for (int i = parameters.size() - 1; i >= 0; --i) { const Param ¶m = parameters[i]; SimdReg *paramReg = new SimdReg (param.varying, param.type->alignedObjectSize()); _xcontext.stack().push (paramReg, TAKE_OWNERSHIP); FunctionArgPtr arg = new SimdFunctionArg (param.name, this, param.type, param.varying, paramReg); if (param.isWritable()) outputs.push_back(arg); else inputs.push_back(arg); } int count = 0; for(vector<FunctionArgPtr>::reverse_iterator it = inputs.rbegin(); it != inputs.rend(); ++it) { setInputArg (count++, *it); } count = 0; for(vector<FunctionArgPtr>::reverse_iterator it = outputs.rbegin(); it != outputs.rend(); ++it) { setOutputArg (count++, *it); } }