| 825 | } |
| 826 | |
| 827 | txBigInt* fxToBigInt(txMachine* the, txSlot* slot, txFlag strict) |
| 828 | { |
| 829 | again: |
| 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 | |
| 867 | void fxFromBigInt64(txMachine* the, txSlot* slot, txS8 it) |
| 868 | { |
no test coverage detected