MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxNewHostInstance

Function fxNewHostInstance

xs/sources/xsAPI.c:638–664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

636}
637
638txSlot* fxNewHostInstance(txMachine* the)
639{
640 txSlot* prototype = fxGetInstance(the, the->stack);
641 txSlot* instance = fxNewSlot(the);
642 instance->kind = XS_INSTANCE_KIND;
643 instance->value.instance.garbage = C_NULL;
644 instance->value.instance.prototype = prototype;
645 the->stack->value.reference = instance;
646 the->stack->kind = XS_REFERENCE_KIND;
647 if (prototype) {
648 txSlot* prototypeHost = prototype->next;
649 if (prototypeHost && (prototypeHost->kind == XS_HOST_KIND) && (prototypeHost->value.host.variant.destructor != fxReleaseSharedChunk)) {
650 txSlot* instanceHost = instance->next = fxNewSlot(the);
651 instanceHost->flag = XS_INTERNAL_FLAG;
652 instanceHost->kind = XS_HOST_KIND;
653 instanceHost->value.host.data = C_NULL;
654 if (prototypeHost->flag & XS_HOST_HOOKS_FLAG) {
655 instanceHost->flag |= XS_HOST_HOOKS_FLAG;
656 instanceHost->value.host.variant.hooks = prototypeHost->value.host.variant.hooks;
657 }
658 else {
659 instanceHost->value.host.variant.destructor = prototypeHost->value.host.variant.destructor;
660 }
661 }
662 }
663 return instance;
664}
665
666
667txSlot* fxCheckHostObject(txMachine* the, txSlot* it)

Callers 7

fxRunConstructorFunction · 0.85
fxRunExtendsFunction · 0.85
fxRunInstantiateFunction · 0.85
fxNativeFunction · 0.85
fxCloneMachineFunction · 0.85
fx_Object_createFunction · 0.85
_xsNewHostInstanceFunction · 0.85

Calls 2

fxGetInstanceFunction · 0.85
fxNewSlotFunction · 0.85

Tested by

no test coverage detected