| 92 | } |
| 93 | |
| 94 | txSlot* fxNewPromiseInstance(txMachine* the) |
| 95 | { |
| 96 | #ifdef mxPromisePrint |
| 97 | static txID gID = 0; |
| 98 | #endif |
| 99 | txSlot* promise; |
| 100 | txSlot* slot; |
| 101 | txSlot* instance; |
| 102 | promise = fxNewSlot(the); |
| 103 | promise->kind = XS_INSTANCE_KIND; |
| 104 | promise->value.instance.garbage = C_NULL; |
| 105 | promise->value.instance.prototype = the->stack->value.reference; |
| 106 | the->stack->kind = XS_REFERENCE_KIND; |
| 107 | the->stack->value.reference = promise; |
| 108 | /* STATUS */ |
| 109 | slot = promise->next = fxNewSlot(the); |
| 110 | slot->flag = XS_INTERNAL_FLAG; |
| 111 | #ifdef mxPromisePrint |
| 112 | slot->ID = gID++; |
| 113 | #endif |
| 114 | slot->kind = XS_PROMISE_KIND; |
| 115 | slot->value.integer = mxUndefinedStatus; |
| 116 | /* THENS */ |
| 117 | slot = slot->next = fxNewSlot(the); |
| 118 | slot->flag = XS_INTERNAL_FLAG; |
| 119 | slot->value.reference = instance = fxNewSlot(the); |
| 120 | slot->kind = XS_REFERENCE_KIND; |
| 121 | instance->kind = XS_INSTANCE_KIND; |
| 122 | instance->value.instance.garbage = C_NULL; |
| 123 | instance->value.instance.prototype = C_NULL; |
| 124 | /* RESULT */ |
| 125 | slot = slot->next = fxNewSlot(the); |
| 126 | slot->flag = XS_INTERNAL_FLAG; |
| 127 | #if mxReportUnhandledRejections |
| 128 | /* ENVIRONMENT */ |
| 129 | slot = slot->next = fxNewSlot(the); |
| 130 | slot->flag = XS_INTERNAL_FLAG; |
| 131 | instance = the->frame; |
| 132 | while (instance) { |
| 133 | txSlot* environment = mxFrameToEnvironment(instance); |
| 134 | if (environment->ID != XS_NO_ID) { |
| 135 | slot->ID = environment->ID; |
| 136 | slot->value.environment.line = environment->value.environment.line; |
| 137 | break; |
| 138 | } |
| 139 | instance = instance->next; |
| 140 | } |
| 141 | #endif |
| 142 | return promise; |
| 143 | } |
| 144 | |
| 145 | txSlot* fxNewPromiseCapability(txMachine* the, txSlot* resolveFunction, txSlot* rejectFunction) |
| 146 | { |
no test coverage detected