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

Function fxCheckArrayLength

xs/sources/xsArray.c:399–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397}
398
399txIndex fxCheckArrayLength(txMachine* the, txSlot* slot)
400{
401 if (slot->kind == XS_INTEGER_KIND) {
402 if (slot->value.integer >= 0)
403 return (txIndex)slot->value.integer;
404 }
405 else if (slot->kind == XS_NUMBER_KIND) {
406 txIndex length = (txIndex)slot->value.number;
407 txNumber check = length;
408 if (slot->value.number == check)
409 return length;
410 }
411 else {
412 txUnsigned length;
413 txNumber check;
414 mxPushSlot(slot);
415 length = fxToUnsigned(the, the->stack);
416 mxPop();
417 mxPushSlot(slot);
418 check = fxToNumber(the, the->stack);
419 mxPop();
420 if (length == check)
421 return length;
422 }
423 mxRangeError("invalid length");
424 return 0;
425}
426
427int fxCompareArrayItem(txMachine* the, txSlot* function, txSlot* array, txInteger i)
428{

Callers 4

fxArrayLengthSetterFunction · 0.85
fxArrayDefineOwnPropertyFunction · 0.85
fx_ArrayFunction · 0.85
fx_Array_fromFunction · 0.85

Calls 2

fxToUnsignedFunction · 0.85
fxToNumberFunction · 0.85

Tested by

no test coverage detected