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

Function fxConstructArrayBufferResult

xs/sources/xsDataView.c:455–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

453}
454
455void fxConstructArrayBufferResult(txMachine* the, txSlot* constructor, txInteger length)
456{
457 txSlot* instance;
458 if (constructor)
459 mxPushSlot(constructor);
460 else {
461 mxPushSlot(mxThis);
462 mxGetID(mxID(_constructor));
463 fxToSpeciesConstructor(the, &mxArrayBufferConstructor);
464 }
465 mxNew();
466 mxPushInteger(length);
467 mxRunCount(1);
468 if (the->stack->kind != XS_REFERENCE_KIND)
469 mxTypeError("not an object");
470 instance = the->stack->value.reference;
471 if (!(instance->next) || (instance->next->kind != XS_ARRAY_BUFFER_KIND))
472 mxTypeError("not an ArrayBuffer instance");
473 if (!constructor && (mxThis->value.reference == instance))
474 mxTypeError("same ArrayBuffer instance");
475 if (instance->next->next->value.bufferInfo.length < length)
476 mxTypeError("smaller ArrayBuffer instance");
477 mxPullSlot(mxResult);
478}
479
480txSlot* fxNewArrayBufferInstance(txMachine* the)
481{

Calls 1

fxToSpeciesConstructorFunction · 0.85

Tested by

no test coverage detected