SetIteratorPrototype.cpp [plain text]
#include "config.h"
#include "SetIteratorPrototype.h"
#include "IteratorOperations.h"
#include "JSCInlines.h"
#include "JSSetIterator.h"
namespace JSC {
const ClassInfo SetIteratorPrototype::s_info = { "Set Iterator", &Base::s_info, 0, CREATE_METHOD_TABLE(SetIteratorPrototype) };
static EncodedJSValue JSC_HOST_CALL SetIteratorPrototypeFuncNext(ExecState*);
void SetIteratorPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject)
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
vm.prototypeMap.addPrototype(this);
JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->next, SetIteratorPrototypeFuncNext, DontEnum, 0);
putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Set Iterator"), DontEnum | ReadOnly);
}
EncodedJSValue JSC_HOST_CALL SetIteratorPrototypeFuncNext(CallFrame* callFrame)
{
VM& vm = callFrame->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue result;
JSSetIterator* iterator = jsDynamicCast<JSSetIterator*>(callFrame->thisValue());
if (!iterator)
return JSValue::encode(throwTypeError(callFrame, scope, ASCIILiteral("Cannot call SetIterator.next() on a non-SetIterator object")));
if (iterator->next(callFrame, result)) {
scope.release();
return JSValue::encode(createIteratorResultObject(callFrame, result, false));
}
scope.release();
return JSValue::encode(createIteratorResultObject(callFrame, jsUndefined(), true));
}
}