JSInternalPromise.cpp [plain text]
#include "config.h"
#include "JSInternalPromise.h"
#include "BuiltinNames.h"
#include "JSCInlines.h"
namespace JSC {
const ClassInfo JSInternalPromise::s_info = { "InternalPromise", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSInternalPromise) };
JSInternalPromise* JSInternalPromise::create(VM& vm, Structure* structure)
{
JSInternalPromise* promise = new (NotNull, allocateCell<JSInternalPromise>(vm.heap)) JSInternalPromise(vm, structure);
promise->finishCreation(vm);
return promise;
}
Structure* JSInternalPromise::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
}
JSInternalPromise::JSInternalPromise(VM& vm, Structure* structure)
: Base(vm, structure)
{
}
JSInternalPromise* JSInternalPromise::then(ExecState* exec, JSFunction* onFulfilled, JSFunction* onRejected)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* function = jsCast<JSObject*>(get(exec, vm.propertyNames->builtinNames().thenPublicName()));
RETURN_IF_EXCEPTION(scope, nullptr);
CallData callData;
CallType callType = JSC::getCallData(vm, function, callData);
ASSERT(callType != CallType::None);
MarkedArgumentBuffer arguments;
arguments.append(onFulfilled ? onFulfilled : jsUndefined());
arguments.append(onRejected ? onRejected : jsUndefined());
ASSERT(!arguments.hasOverflowed());
scope.release();
return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments));
}
}