diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2019-12-13 21:29:23 -0500 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2019-12-17 06:25:27 -0500 |
commit | d5086ac3aa308bb1ef177834366eeaf7b39bb17e (patch) | |
tree | 9b2c84158cf996b388bcb191130a5062fd7d6992 /js/src/jsiter.cpp | |
parent | 82f9efff935a4ac4379bdfddddc84aae84fc869e (diff) | |
download | uxp-d5086ac3aa308bb1ef177834366eeaf7b39bb17e.tar.gz |
Bug 1331092 - Part 2: Implement Async Generator except yield*.
Tag #1287
Diffstat (limited to 'js/src/jsiter.cpp')
-rw-r--r-- | js/src/jsiter.cpp | 28 |
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 |