| 1855 | } |
| 1856 | |
| 1857 | void fx_FinalizationRegistry(txMachine* the) |
| 1858 | { |
| 1859 | txSlot* callback; |
| 1860 | txSlot* instance; |
| 1861 | txSlot* property; |
| 1862 | txSlot* registry; |
| 1863 | txSlot* slot; |
| 1864 | if (!mxHasTarget) |
| 1865 | mxTypeError("call: FinalizationRegistry"); |
| 1866 | if (mxArgc < 1) |
| 1867 | mxTypeError("no callback"); |
| 1868 | callback = mxArgv(0); |
| 1869 | if (!fxIsCallable(the, callback)) |
| 1870 | mxTypeError("callback: not a function"); |
| 1871 | mxPushSlot(mxTarget); |
| 1872 | fxGetPrototypeFromConstructor(the, &mxFinalizationRegistryPrototype); |
| 1873 | instance = fxNewSlot(the); |
| 1874 | instance->kind = XS_INSTANCE_KIND; |
| 1875 | instance->value.instance.garbage = C_NULL; |
| 1876 | instance->value.instance.prototype = the->stack->value.reference; |
| 1877 | the->stack->kind = XS_REFERENCE_KIND; |
| 1878 | the->stack->value.reference = instance; |
| 1879 | mxPullSlot(mxResult); |
| 1880 | property = instance->next = fxNewSlot(the); |
| 1881 | property->flag = XS_INTERNAL_FLAG; |
| 1882 | property->kind = XS_CLOSURE_KIND; |
| 1883 | property->value.closure = C_NULL; |
| 1884 | registry = fxNewSlot(the); |
| 1885 | registry->kind = XS_FINALIZATION_REGISTRY_KIND; |
| 1886 | registry->value.finalizationRegistry.callback = C_NULL; |
| 1887 | registry->value.finalizationRegistry.flags = XS_NO_FLAG; |
| 1888 | property->value.closure = registry; |
| 1889 | slot = fxNewSlot(the); |
| 1890 | slot->kind = callback->kind; |
| 1891 | slot->value = callback->value; |
| 1892 | registry->value.finalizationRegistry.callback = slot; |
| 1893 | } |
| 1894 | |
| 1895 | |
| 1896 | #if 0 |
nothing calls this directly
no test coverage detected