TiValue JSC_HOST_CALL objectProtoFuncDefineSetter(TiExcState* exec, TiObject*, TiValue thisValue, const ArgList& args)
{
    CallData callData;
    if (args.at(1).getCallData(callData) == CallTypeNone)
        return throwError(exec, SyntaxError, "invalid setter usage");
    thisValue.toThisObject(exec)->defineSetter(exec, Identifier(exec, args.at(0).toString(exec)), asObject(args.at(1)));
    return jsUndefined();
}
TiValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(TiExcState* exec, TiObject*, TiValue thisValue, const ArgList& args)
{
    TiObject* thisObj = thisValue.toThisObject(exec);

    if (!args.at(0).isObject())
        return jsBoolean(false);

    TiValue v = asObject(args.at(0))->prototype();

    while (true) {
        if (!v.isObject())
            return jsBoolean(false);
        if (v == thisObj)
            return jsBoolean(true);
        v = asObject(v)->prototype();
    }
}
TiValue TiCallbackFunction::call(TiExcState* exec, TiObject* functionObject, TiValue thisValue, const ArgList& args)
{
    TiContextRef execRef = toRef(exec);
    TiObjectRef functionRef = toRef(functionObject);
    TiObjectRef thisObjRef = toRef(thisValue.toThisObject(exec));

    int argumentCount = static_cast<int>(args.size());
    Vector<TiValueRef, 16> arguments(argumentCount);
    for (int i = 0; i < argumentCount; i++)
        arguments[i] = toRef(exec, args.at(i));

    TiValueRef exception = 0;
    TiValueRef result;
    {
        APICallbackShim callbackShim(exec);
        result = static_cast<TiCallbackFunction*>(functionObject)->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception);
    }
    if (exception)
        exec->setException(toJS(exec, exception));

    return toJS(exec, result);
}
void ProfileGenerator::addParentForConsoleStart(TiExcState* exec)
{
    int lineNumber;
    intptr_t sourceID;
    UString sourceURL;
    TiValue function;

    exec->interpreter()->retrieveLastCaller(exec, lineNumber, sourceID, sourceURL, function);
    m_currentNode = ProfileNode::create(Profiler::createCallIdentifier(&exec->globalData(), function ? function.toThisObject(exec) : 0, sourceURL, lineNumber), m_head.get(), m_head.get());
    m_head->insertNode(m_currentNode.get());
}
TiValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(TiExcState* exec, TiObject*, TiValue thisValue, const ArgList& args)
{
    return jsBoolean(thisValue.toThisObject(exec)->hasOwnProperty(exec, Identifier(exec, args.at(0).toString(exec))));
}
TiValue JSC_HOST_CALL objectProtoFuncValueOf(TiExcState* exec, TiObject*, TiValue thisValue, const ArgList&)
{
    return thisValue.toThisObject(exec);
}
TiValue JSC_HOST_CALL objectProtoFuncToString(TiExcState* exec, TiObject*, TiValue thisValue, const ArgList&)
{
    return jsNontrivialString(exec, "[object " + thisValue.toThisObject(exec)->className() + "]");
}
TiValue JSC_HOST_CALL objectProtoFuncLookupSetter(TiExcState* exec, TiObject*, TiValue thisValue, const ArgList& args)
{
    return thisValue.toThisObject(exec)->lookupSetter(exec, Identifier(exec, args.at(0).toString(exec)));
}
Exemple #9
0
TiValue TiFunction::call(TiExcState* exec, TiValue thisValue, const ArgList& args)
{
    ASSERT(!isHostFunction());
    return exec->interpreter()->execute(jsExecutable(), exec, this, thisValue.toThisObject(exec), args, scopeChain().node(), exec->exceptionSlot());
}