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

Function fxCreateArraySpecies

xs/sources/xsArray.c:518–548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

516}
517
518txSlot* fxCreateArraySpecies(txMachine* the, txNumber length)
519{
520 txSlot* instance = fxToInstance(the, mxThis);
521 txFlag flag = 1;
522 if (fxIsArray(the, instance)) {
523 mxPushSlot(mxThis);
524 mxGetID(mxID(_constructor));
525 if (mxIsReference(the->stack)) {
526 mxGetID(mxID(_Symbol_species));
527 if (the->stack->kind == XS_NULL_KIND)
528 the->stack->kind = XS_UNDEFINED_KIND;
529 }
530 }
531 else
532 mxPushUndefined();
533 if (the->stack->kind == XS_UNDEFINED_KIND) {
534 *the->stack = mxArrayConstructor;
535 flag = 0;
536 }
537 else if (mxIsReference(the->stack) && mxIsConstructor(the->stack->value.reference)) {
538 if (the->stack->value.reference != mxArrayConstructor.value.reference)
539 flag = 0;
540 }
541 else
542 mxTypeError("invalid constructor");
543 mxNew();
544 mxPushNumber(length);
545 mxRunCount(1);
546 mxPullSlot(mxResult);
547 return (flag) ? mxResult->value.reference->next : C_NULL;
548}
549
550void fxFindThisItem(txMachine* the, txSlot* function, txNumber index, txSlot* item)
551{

Callers 7

fx_Array_prototype_flatFunction · 0.85
fx_Array_prototype_mapFunction · 0.85
fx_Array_prototype_sliceFunction · 0.85

Calls 2

fxToInstanceFunction · 0.85
fxIsArrayFunction · 0.85

Tested by

no test coverage detected