mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 17:31:47 +09:00
1320408 - Part 1: Change JSFunction::getLength and JSFunction::getUnresolvedLength to static method.
This commit is contained in:
parent
85df465355
commit
6633322957
4 changed files with 19 additions and 19 deletions
|
|
@ -476,7 +476,7 @@ fun_resolve(JSContext* cx, HandleObject obj, HandleId id, bool* resolvedp)
|
|||
if (fun->hasResolvedLength())
|
||||
return true;
|
||||
|
||||
if (!fun->getUnresolvedLength(cx, &v))
|
||||
if (!JSFunction::getUnresolvedLength(cx, fun, &v))
|
||||
return false;
|
||||
} else {
|
||||
if (fun->hasResolvedName())
|
||||
|
|
@ -1242,34 +1242,33 @@ JSFunction::isDerivedClassConstructor()
|
|||
return derived;
|
||||
}
|
||||
|
||||
bool
|
||||
JSFunction::getLength(JSContext* cx, uint16_t* length)
|
||||
/* static */ bool
|
||||
JSFunction::getLength(JSContext* cx, HandleFunction fun, uint16_t* length)
|
||||
{
|
||||
JS::RootedFunction self(cx, this);
|
||||
MOZ_ASSERT(!self->isBoundFunction());
|
||||
if (self->isInterpretedLazy() && !self->getOrCreateScript(cx))
|
||||
MOZ_ASSERT(!fun->isBoundFunction());
|
||||
if (fun->isInterpretedLazy() && !fun->getOrCreateScript(cx))
|
||||
return false;
|
||||
|
||||
*length = self->isNative() ? self->nargs() : self->nonLazyScript()->funLength();
|
||||
*length = fun->isNative() ? fun->nargs() : fun->nonLazyScript()->funLength();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
JSFunction::getUnresolvedLength(JSContext* cx, MutableHandleValue v)
|
||||
/* static */ bool
|
||||
JSFunction::getUnresolvedLength(JSContext* cx, HandleFunction fun, MutableHandleValue v)
|
||||
{
|
||||
MOZ_ASSERT(!IsInternalFunctionObject(*this));
|
||||
MOZ_ASSERT(!hasResolvedLength());
|
||||
MOZ_ASSERT(!IsInternalFunctionObject(*fun));
|
||||
MOZ_ASSERT(!fun->hasResolvedLength());
|
||||
|
||||
// Bound functions' length can have values up to MAX_SAFE_INTEGER, so
|
||||
// they're handled differently from other functions.
|
||||
if (isBoundFunction()) {
|
||||
MOZ_ASSERT(getExtendedSlot(BOUND_FUN_LENGTH_SLOT).isNumber());
|
||||
v.set(getExtendedSlot(BOUND_FUN_LENGTH_SLOT));
|
||||
if (fun->isBoundFunction()) {
|
||||
MOZ_ASSERT(fun->getExtendedSlot(BOUND_FUN_LENGTH_SLOT).isNumber());
|
||||
v.set(fun->getExtendedSlot(BOUND_FUN_LENGTH_SLOT));
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16_t length;
|
||||
if (!getLength(cx, &length))
|
||||
if (!JSFunction::getLength(cx, fun, &length))
|
||||
return false;
|
||||
|
||||
v.setInt32(length);
|
||||
|
|
|
|||
|
|
@ -306,7 +306,8 @@ class JSFunction : public js::NativeObject
|
|||
nonLazyScript()->setAsyncKind(asyncKind);
|
||||
}
|
||||
|
||||
bool getUnresolvedLength(JSContext* cx, js::MutableHandleValue v);
|
||||
static bool getUnresolvedLength(JSContext* cx, js::HandleFunction fun,
|
||||
js::MutableHandleValue v);
|
||||
|
||||
JSAtom* getUnresolvedName(JSContext* cx);
|
||||
|
||||
|
|
@ -478,7 +479,7 @@ class JSFunction : public js::NativeObject
|
|||
return u.i.s.script_;
|
||||
}
|
||||
|
||||
bool getLength(JSContext* cx, uint16_t* length);
|
||||
static bool getLength(JSContext* cx, js::HandleFunction fun, uint16_t* length);
|
||||
|
||||
js::LazyScript* lazyScript() const {
|
||||
MOZ_ASSERT(isInterpretedLazy() && u.i.s.lazy_);
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ js::WrapAsyncFunctionWithProto(JSContext* cx, HandleFunction unwrapped, HandleOb
|
|||
|
||||
RootedAtom funName(cx, unwrapped->explicitName());
|
||||
uint16_t length;
|
||||
if (!unwrapped->getLength(cx, &length))
|
||||
if (!JSFunction::getLength(cx, unwrapped, &length))
|
||||
return nullptr;
|
||||
|
||||
// Steps 3 (partially).
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ intrinsic_FinishBoundFunctionInit(JSContext* cx, unsigned argc, Value* vp)
|
|||
// Try to avoid invoking the resolve hook.
|
||||
if (targetObj->is<JSFunction>() && !targetObj->as<JSFunction>().hasResolvedLength()) {
|
||||
RootedValue targetLength(cx);
|
||||
if (!targetObj->as<JSFunction>().getUnresolvedLength(cx, &targetLength))
|
||||
if (!JSFunction::getUnresolvedLength(cx, targetObj.as<JSFunction>(), &targetLength))
|
||||
return false;
|
||||
|
||||
length = Max(0.0, targetLength.toNumber() - argCount);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue