diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-03-16 09:04:55 +0100 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-03-16 09:04:55 +0100 |
commit | 28d4e4a5fa5ba7a22d3497769fbb5a9d11db7a9e (patch) | |
tree | 3565ccfc38a6ea0f86c1bfbe5751dee60be602b7 /js/src/vm/AsyncFunction.cpp | |
parent | 11bdaa144d8a38ecd897dde278cb1db9b8313961 (diff) | |
download | UXP-28d4e4a5fa5ba7a22d3497769fbb5a9d11db7a9e.tar UXP-28d4e4a5fa5ba7a22d3497769fbb5a9d11db7a9e.tar.gz UXP-28d4e4a5fa5ba7a22d3497769fbb5a9d11db7a9e.tar.lz UXP-28d4e4a5fa5ba7a22d3497769fbb5a9d11db7a9e.tar.xz UXP-28d4e4a5fa5ba7a22d3497769fbb5a9d11db7a9e.zip |
Bug 1318017: Call GetPrototypeFromConstructor for generator/async function and Intl constructors
[Depends on] Bug 755821: Function() should use the parser's argument
parsing code
Diffstat (limited to 'js/src/vm/AsyncFunction.cpp')
-rw-r--r-- | js/src/vm/AsyncFunction.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/js/src/vm/AsyncFunction.cpp b/js/src/vm/AsyncFunction.cpp index bd0b4f32a..1e0c7d7c2 100644 --- a/js/src/vm/AsyncFunction.cpp +++ b/js/src/vm/AsyncFunction.cpp @@ -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 |