mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 23:27:30 +09:00
Bug 1343481 - Part 4: Add Add GeneratorObject.{isAfterYield,isAfterAwait}.
Tag #1287
This commit is contained in:
parent
a6872d9ea3
commit
bc80cb0d51
2 changed files with 38 additions and 0 deletions
|
|
@ -370,3 +370,34 @@ js::CheckStarGeneratorResumptionValue(JSContext* cx, HandleValue v)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
GeneratorObject::isAfterYield()
|
||||||
|
{
|
||||||
|
return isAfterYieldOrAwait(JSOP_YIELD);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
GeneratorObject::isAfterAwait()
|
||||||
|
{
|
||||||
|
return isAfterYieldOrAwait(JSOP_AWAIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
GeneratorObject::isAfterYieldOrAwait(JSOp op)
|
||||||
|
{
|
||||||
|
if (isClosed() || isClosing() || isRunning())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
JSScript* script = callee().nonLazyScript();
|
||||||
|
jsbytecode* code = script->code();
|
||||||
|
uint32_t nextOffset = script->yieldAndAwaitOffsets()[yieldAndAwaitIndex()];
|
||||||
|
if (code[nextOffset] != JSOP_DEBUGAFTERYIELD)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
uint32_t offset = nextOffset - JSOP_YIELD_LENGTH;
|
||||||
|
MOZ_ASSERT(code[offset] == JSOP_INITIALYIELD || code[offset] == JSOP_YIELD ||
|
||||||
|
code[offset] == JSOP_AWAIT);
|
||||||
|
|
||||||
|
return code[offset] == op;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,13 @@ class GeneratorObject : public NativeObject
|
||||||
setFixedSlot(NEWTARGET_SLOT, NullValue());
|
setFixedSlot(NEWTARGET_SLOT, NullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isAfterYield();
|
||||||
|
bool isAfterAwait();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool isAfterYieldOrAwait(JSOp op);
|
||||||
|
|
||||||
|
public:
|
||||||
static size_t offsetOfCalleeSlot() {
|
static size_t offsetOfCalleeSlot() {
|
||||||
return getFixedSlotOffset(CALLEE_SLOT);
|
return getFixedSlotOffset(CALLEE_SLOT);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue