| 1668 | } |
| 1669 | |
| 1670 | void fxAsyncGeneratorStep(txMachine* the, txSlot* generator, txFlag status) |
| 1671 | { |
| 1672 | txSlot* stack = generator->next; |
| 1673 | txSlot* state = stack->next; |
| 1674 | txSlot* queue = state->next; |
| 1675 | txSlot* resolveAwaitFunction = queue->next; |
| 1676 | txSlot* rejectAwaitFunction = resolveAwaitFunction->next; |
| 1677 | txSlot* resolveYieldFunction = rejectAwaitFunction->next; |
| 1678 | txSlot* rejectYieldFunction = resolveYieldFunction->next; |
| 1679 | txSlot* resolveFunction; |
| 1680 | txSlot* rejectFunction; |
| 1681 | txSlot* value; |
| 1682 | |
| 1683 | mxTry(the) { |
| 1684 | if (state->value.integer == XS_CODE_END) { |
| 1685 | mxPush(the->scratch); |
| 1686 | value = the->stack; |
| 1687 | mxTemporary(resolveFunction); |
| 1688 | mxTemporary(rejectFunction); |
| 1689 | mxPush(mxPromiseConstructor); |
| 1690 | fxNewPromiseCapability(the, resolveFunction, rejectFunction); |
| 1691 | fxPromiseThen(the, the->stack->value.reference, resolveYieldFunction, rejectYieldFunction, C_NULL, C_NULL); |
| 1692 | /* THIS */ |
| 1693 | mxPushUndefined(); |
| 1694 | /* FUNCTION */ |
| 1695 | if (status == XS_THROW_STATUS) |
| 1696 | mxPushSlot(rejectFunction); |
| 1697 | else |
| 1698 | mxPushSlot(resolveFunction); |
| 1699 | mxCall(); |
| 1700 | /* ARGUMENTS */ |
| 1701 | mxPushSlot(value); |
| 1702 | mxRunCount(1); |
| 1703 | mxPop(); |
| 1704 | } |
| 1705 | else { |
| 1706 | the->status = status; |
| 1707 | status = XS_NO_STATUS; |
| 1708 | state->value.integer = XS_NO_CODE; |
| 1709 | fxRunID(the, generator, XS_NO_ID); |
| 1710 | if (state->value.integer == XS_NO_CODE) |
| 1711 | state->value.integer = XS_CODE_END; |
| 1712 | value = the->stack; |
| 1713 | if (state->value.integer == XS_CODE_END) { |
| 1714 | txSlot* current = queue->value.list.first; |
| 1715 | if (current) { |
| 1716 | if (value->kind == XS_UNINITIALIZED_KIND) |
| 1717 | value->kind = XS_UNDEFINED_KIND; |
| 1718 | mxPushUndefined(); |
| 1719 | if (status == XS_THROW_STATUS) |
| 1720 | mxPushSlot(rejectYieldFunction); |
| 1721 | else |
| 1722 | mxPushSlot(resolveYieldFunction); |
| 1723 | mxCall(); |
| 1724 | mxPushSlot(value); |
| 1725 | mxRunCount(1); |
| 1726 | mxPop(); |
| 1727 | } |
no test coverage detected