mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-11-03 04:57:31 +09:00
Bug 1318017: Call GetPrototypeFromConstructor for generator/async function and Intl constructors
[Depends on] Bug 755821: Function() should use the parser's argument parsing code
This commit is contained in:
parent
093e83da1a
commit
e7fdd26fde
11 changed files with 586 additions and 53 deletions
|
|
@ -107,18 +107,15 @@ WrappedAsyncFunction(JSContext* cx, unsigned argc, Value* vp)
|
|||
// the async function's body, replacing `await` with `yield`. `wrapped` is a
|
||||
// function that is visible to the outside, and handles yielded values.
|
||||
JSObject*
|
||||
js::WrapAsyncFunction(JSContext* cx, HandleFunction unwrapped)
|
||||
js::WrapAsyncFunctionWithProto(JSContext* cx, HandleFunction unwrapped, HandleObject proto)
|
||||
{
|
||||
MOZ_ASSERT(unwrapped->isStarGenerator());
|
||||
MOZ_ASSERT(proto, "We need an explicit prototype to avoid the default"
|
||||
"%FunctionPrototype% fallback in NewFunctionWithProto().");
|
||||
|
||||
// Create a new function with AsyncFunctionPrototype, reusing the name and
|
||||
// the length of `unwrapped`.
|
||||
|
||||
// Step 1.
|
||||
RootedObject proto(cx, GlobalObject::getOrCreateAsyncFunctionPrototype(cx, cx->global()));
|
||||
if (!proto)
|
||||
return nullptr;
|
||||
|
||||
RootedAtom funName(cx, unwrapped->name());
|
||||
uint16_t length;
|
||||
if (!unwrapped->getLength(cx, &length))
|
||||
|
|
@ -141,6 +138,16 @@ js::WrapAsyncFunction(JSContext* cx, HandleFunction unwrapped)
|
|||
return wrapped;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
js::WrapAsyncFunction(JSContext* cx, HandleFunction unwrapped)
|
||||
{
|
||||
RootedObject proto(cx, GlobalObject::getOrCreateAsyncFunctionPrototype(cx, cx->global()));
|
||||
if (!proto)
|
||||
return nullptr;
|
||||
|
||||
return WrapAsyncFunctionWithProto(cx, unwrapped, proto);
|
||||
}
|
||||
|
||||
enum class ResumeKind {
|
||||
Normal,
|
||||
Throw
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue