| 802 | } |
| 803 | |
| 804 | void fx_Promise(txMachine* the) |
| 805 | { |
| 806 | txSlot* stack = the->stack; |
| 807 | txSlot* promise; |
| 808 | txSlot* argument; |
| 809 | txSlot* status; |
| 810 | txSlot* resolveFunction; |
| 811 | txSlot* rejectFunction; |
| 812 | if (!mxHasTarget) |
| 813 | mxTypeError("call: Promise"); |
| 814 | if (mxArgc < 1) |
| 815 | mxTypeError("no executor"); |
| 816 | argument = mxArgv(0); |
| 817 | if (!fxIsCallable(the, argument)) |
| 818 | mxTypeError("executor: not a function"); |
| 819 | mxPushSlot(mxTarget); |
| 820 | fxGetPrototypeFromConstructor(the, &mxPromisePrototype); |
| 821 | promise = fxNewPromiseInstance(the); |
| 822 | #ifdef mxPromisePrint |
| 823 | fprintf(stderr, "fx_Promise %d\n", promise->next->ID); |
| 824 | #endif |
| 825 | mxPullSlot(mxResult); |
| 826 | status = mxPromiseStatus(promise); |
| 827 | status->value.integer = mxPendingStatus; |
| 828 | fxPushPromiseFunctions(the, promise); |
| 829 | resolveFunction = the->stack + 1; |
| 830 | rejectFunction = the->stack; |
| 831 | { |
| 832 | mxTry(the) { |
| 833 | /* THIS */ |
| 834 | mxPushUndefined(); |
| 835 | /* FUNCTION */ |
| 836 | mxPushSlot(argument); |
| 837 | mxCall(); |
| 838 | /* ARGUMENTS */ |
| 839 | mxPushSlot(resolveFunction); |
| 840 | mxPushSlot(rejectFunction); |
| 841 | mxRunCount(2); |
| 842 | } |
| 843 | mxCatch(the) { |
| 844 | fxRejectException(the, rejectFunction); |
| 845 | } |
| 846 | } |
| 847 | the->stack = stack; |
| 848 | } |
| 849 | |
| 850 | void fx_Promise_all(txMachine* the) |
| 851 | { |
nothing calls this directly
no test coverage detected