summaryrefslogtreecommitdiff
path: root/js/src/jsiter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jsiter.cpp')
-rw-r--r--js/src/jsiter.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/js/src/jsiter.cpp b/js/src/jsiter.cpp
index c4da86bdb7..c58f323825 100644
--- a/js/src/jsiter.cpp
+++ b/js/src/jsiter.cpp
@@ -916,28 +916,30 @@ js::GetIteratorObject(JSContext* cx, HandleObject obj, uint32_t flags)
return iterator;
}
+// ES 2017 draft 7.4.7.
JSObject*
-js::CreateItrResultObject(JSContext* cx, HandleValue value, bool done)
+js::CreateIterResultObject(JSContext* cx, HandleValue value, bool done)
{
- // FIXME: We can cache the iterator result object shape somewhere.
- AssertHeapIsIdle(cx);
+ // Step 1 (implicit).
- RootedObject proto(cx, GlobalObject::getOrCreateObjectPrototype(cx, cx->global()));
- if (!proto)
+ // Step 2.
+ RootedObject resultObj(cx, NewBuiltinClassInstance<PlainObject>(cx));
+ if (!resultObj)
return nullptr;
- RootedPlainObject obj(cx, NewObjectWithGivenProto<PlainObject>(cx, proto));
- if (!obj)
- return nullptr;
-
- if (!DefineProperty(cx, obj, cx->names().value, value))
+ // Step 3.
+ if (!DefineProperty(cx, resultObj, cx->names().value, value))
return nullptr;
- RootedValue doneBool(cx, BooleanValue(done));
- if (!DefineProperty(cx, obj, cx->names().done, doneBool))
+ // Step 4.
+ if (!DefineProperty(cx, resultObj, cx->names().done,
+ done ? TrueHandleValue : FalseHandleValue))
+ {
return nullptr;
+ }
- return obj;
+ // Step 5.
+ return resultObj;
}
bool