JSArrayIterator.cpp [plain text]
#include "config.h"
#include "JSArrayIterator.h"
#include "JSCInlines.h"
#include "JSInternalFieldObjectImplInlines.h"
namespace JSC {
const ClassInfo JSArrayIterator::s_info = { "ArrayIterator", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSArrayIterator) };
JSArrayIterator* JSArrayIterator::create(VM& vm, Structure* structure, JSObject* iteratedObject, JSValue kind)
{
ASSERT(kind.asUInt32() <= static_cast<uint32_t>(IterationKind::Entries));
JSArrayIterator* iterator = new (NotNull, allocateCell<JSArrayIterator>(vm.heap)) JSArrayIterator(vm, structure);
iterator->finishCreation(vm);
iterator->internalField(Field::IteratedObject).set(vm, iterator, iteratedObject);
iterator->internalField(Field::Kind).set(vm, iterator, kind);
return iterator;
}
JSArrayIterator* JSArrayIterator::createWithInitialValues(VM& vm, Structure* structure)
{
JSArrayIterator* iterator = new (NotNull, allocateCell<JSArrayIterator>(vm.heap)) JSArrayIterator(vm, structure);
iterator->finishCreation(vm);
return iterator;
}
Structure* JSArrayIterator::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(vm, globalObject, prototype, TypeInfo(JSArrayIteratorType, StructureFlags), info());
}
JSArrayIterator::JSArrayIterator(VM& vm, Structure* structure)
: Base(vm, structure)
{
}
void JSArrayIterator::finishCreation(VM& vm)
{
Base::finishCreation(vm);
auto values = initialValues();
for (unsigned index = 0; index < values.size(); ++index)
Base::internalField(index).set(vm, this, values[index]);
}
void JSArrayIterator::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
auto* thisObject = jsCast<JSArrayIterator*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
}
}