// ES 2017 draft 7.4.7. JSObject* js::CreateIterResultObject(JSContext* cx, HandleValue value, bool done) { // Step 1 (implicit). // Step 2. RootedObject templateObject(cx, cx->compartment()->getOrCreateIterResultTemplateObject(cx)); if (!templateObject) return nullptr; NativeObject* resultObj; JS_TRY_VAR_OR_RETURN_NULL(cx, resultObj, NativeObject::createWithTemplate(cx, gc::DefaultHeap, templateObject)); // Step 3. resultObj->setSlot(JSCompartment::IterResultObjectValueSlot, value); // Step 4. resultObj->setSlot(JSCompartment::IterResultObjectDoneSlot, done ? TrueHandleValue : FalseHandleValue); // Step 5. return resultObj; }
JS::ForceLexicalInitialization(JSContext *cx, HandleObject obj) { AssertHeapIsIdle(); CHECK_REQUEST(cx); assertSameCompartment(cx, obj); bool initializedAny = false; NativeObject* nobj = &obj->as<NativeObject>(); for (Shape::Range<NoGC> r(nobj->lastProperty()); !r.empty(); r.popFront()) { Shape* s = &r.front(); Value v = nobj->getSlot(s->slot()); if (s->isDataProperty() && v.isMagic() && v.whyMagic() == JS_UNINITIALIZED_LEXICAL) { nobj->setSlot(s->slot(), UndefinedValue()); initializedAny = true; } } return initializedAny; }