mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-11-02 20:47:33 +09:00
Bug 1331092 - Part 2: Implement Async Generator except yield*.
Tag #1287
This commit is contained in:
parent
c8d569d1b8
commit
10b93afff4
23 changed files with 1015 additions and 55 deletions
|
|
@ -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)
|
||||
// Step 3.
|
||||
if (!DefineProperty(cx, resultObj, cx->names().value, value))
|
||||
return nullptr;
|
||||
|
||||
if (!DefineProperty(cx, obj, cx->names().value, value))
|
||||
// Step 4.
|
||||
if (!DefineProperty(cx, resultObj, cx->names().done,
|
||||
done ? TrueHandleValue : FalseHandleValue))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RootedValue doneBool(cx, BooleanValue(done));
|
||||
if (!DefineProperty(cx, obj, cx->names().done, doneBool))
|
||||
return nullptr;
|
||||
|
||||
return obj;
|
||||
// Step 5.
|
||||
return resultObj;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue