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

Function fxToBigInt

xs/sources/xsBigInt.c:827–865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

825}
826
827txBigInt* fxToBigInt(txMachine* the, txSlot* slot, txFlag strict)
828{
829again:
830 switch (slot->kind) {
831 case XS_BOOLEAN_KIND:
832 slot->value.bigint = *fxBigInt_dup(the, (txBigInt *)((slot->value.boolean) ? &gxBigIntOne : &gxBigIntZero));
833 slot->kind = XS_BIGINT_KIND;
834 break;
835 case XS_INTEGER_KIND:
836 if (strict)
837 mxTypeError("cannot coerce number to bigint");
838 fxIntegerToBigInt(the, slot);
839 break;
840 case XS_NUMBER_KIND:
841 if (strict)
842 mxTypeError("cannot coerce number to bigint");
843 fxNumberToBigInt(the, slot);
844 break;
845 case XS_STRING_KIND:
846 case XS_STRING_X_KIND:
847 fxStringToBigInt(the, slot, 1);
848 if (mxBigIntIsNaN(&slot->value.bigint))
849 mxSyntaxError("cannot coerce string to bigint");
850 break;
851 case XS_BIGINT_KIND:
852 case XS_BIGINT_X_KIND:
853 break;
854 case XS_SYMBOL_KIND:
855 mxTypeError("cannot coerce symbol to bigint");
856 break;
857 case XS_REFERENCE_KIND:
858 fxToPrimitive(the, slot, XS_NUMBER_HINT);
859 goto again;
860 default:
861 mxTypeError("cannot coerce to bigint");
862 break;
863 }
864 return &slot->value.bigint;
865}
866
867void fxFromBigInt64(txMachine* the, txSlot* slot, txS8 it)
868{

Callers 7

fx_BigIntFunction · 0.85
fx_BigInt_asIntNFunction · 0.85
fx_BigInt_asUintNFunction · 0.85
fx_BigInt_bitLengthFunction · 0.85
fxBigIntCoerceFunction · 0.85
xsBigInt.cFile · 0.85
fxToBigUint64Function · 0.85

Calls 5

fxBigInt_dupFunction · 0.85
fxIntegerToBigIntFunction · 0.85
fxNumberToBigIntFunction · 0.85
fxStringToBigIntFunction · 0.85
fxToPrimitiveFunction · 0.85

Tested by

no test coverage detected