mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 01:08:39 +09:00
Issue #2234 - Part 1: Create async function wrapper when instantiating module functions
This excludes the change that removes "excessive" rooting from the Lambda* methods in Interpreter.cpp. Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1382306
This commit is contained in:
parent
9693552c5c
commit
ab1c0a384d
1 changed files with 13 additions and 2 deletions
|
|
@ -12,6 +12,8 @@
|
|||
#include "gc/Policy.h"
|
||||
#include "gc/Tracer.h"
|
||||
#include "vm/SelfHosting.h"
|
||||
#include "vm/AsyncFunction.h"
|
||||
#include "vm/AsyncIteration.h"
|
||||
|
||||
#include "jsobjinlines.h"
|
||||
#include "jsscriptinlines.h"
|
||||
|
|
@ -954,15 +956,24 @@ ModuleObject::instantiateFunctionDeclarations(JSContext* cx, HandleModuleObject
|
|||
|
||||
RootedModuleEnvironmentObject env(cx, &self->initialEnvironment());
|
||||
RootedFunction fun(cx);
|
||||
RootedObject obj(cx);
|
||||
RootedValue value(cx);
|
||||
|
||||
for (const auto& funDecl : *funDecls) {
|
||||
fun = funDecl.fun;
|
||||
RootedObject obj(cx, Lambda(cx, fun, env));
|
||||
obj = Lambda(cx, fun, env);
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
value = ObjectValue(*fun);
|
||||
if (fun->isAsync()) {
|
||||
if (fun->isStarGenerator()) {
|
||||
obj = WrapAsyncGenerator(cx, obj.as<JSFunction>());
|
||||
} else {
|
||||
obj = WrapAsyncFunction(cx, obj.as<JSFunction>());
|
||||
}
|
||||
}
|
||||
|
||||
value = ObjectValue(*obj);
|
||||
if (!SetProperty(cx, env, funDecl.name->asPropertyName(), value))
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue