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

Function fxArgToSafeByteLength

xs/sources/xsDataView.c:394–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

392}
393
394txS8 fxArgToSafeByteLength(txMachine* the, txInteger argi, txInteger length)
395{
396 txSlot *arg = mxArgv(argi);
397 if ((mxArgc > argi) && (arg->kind != XS_UNDEFINED_KIND)) {
398 txNumber value;
399 if (XS_INTEGER_KIND == arg->kind) {
400 txS8 value = arg->value.integer;
401 if (value < 0)
402 mxRangeError("byteLength < 0");
403 return value;
404 }
405 value = c_trunc(fxToNumber(the, arg));
406 if (c_isnan(value))
407 return 0;
408 if (value < 0)
409 mxRangeError("byteLength < 0");
410 if (C_MAX_SAFE_INTEGER < value)
411 mxRangeError("byteLength too big");
412 return (txS8)value;
413 }
414 return length;
415}
416
417txSlot* fxArgToInstance(txMachine* the, txInteger i)
418{

Callers 2

fx_ArrayBufferFunction · 0.85
fx_SharedArrayBufferFunction · 0.85

Calls 1

fxToNumberFunction · 0.85

Tested by

no test coverage detected