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

Function fxRunExtends

xs/sources/xsRun.c:4578–4604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4576}
4577
4578void fxRunExtends(txMachine* the)
4579{
4580 txSlot* constructor;
4581 txSlot* prototype;
4582
4583 constructor = fxGetInstance(the, the->stack);
4584 if (!mxIsConstructor(constructor))
4585 mxTypeError("extends: class is not a constructor");
4586 mxPushUndefined();
4587 prototype = the->stack;
4588 fxBeginHost(the);
4589 mxPushReference(constructor);
4590 mxGetID(mxID(_prototype));
4591 *prototype = *the->stack;
4592 fxEndHost(the);
4593 if (the->stack->kind == XS_NULL_KIND) {
4594 mxPop();
4595 fxNewInstance(the);
4596 }
4597 else if (the->stack->kind == XS_REFERENCE_KIND) {
4598 if (the->stack->value.reference->value.instance.prototype == mxGeneratorPrototype.value.reference)
4599 mxTypeError("extends: class is a generator");
4600 fxNewHostInstance(the);
4601 }
4602 else
4603 mxTypeError("extends: class prototype is not an object");
4604}
4605
4606void fxRunEval(txMachine* the)
4607{

Callers 1

fxRunIDFunction · 0.85

Calls 5

fxGetInstanceFunction · 0.85
fxBeginHostFunction · 0.85
fxEndHostFunction · 0.85
fxNewInstanceFunction · 0.85
fxNewHostInstanceFunction · 0.85

Tested by

no test coverage detected