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

Function fxIsSameSlot

xs/sources/xsRun.c:4786–4826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4784}
4785
4786txBoolean fxIsSameSlot(txMachine* the, txSlot* a, txSlot* b)
4787{
4788 txBoolean result = 0;
4789 if (a->kind == b->kind) {
4790 if ((XS_UNDEFINED_KIND == a->kind) || (XS_NULL_KIND == a->kind))
4791 result = 1;
4792 else if (XS_BOOLEAN_KIND == a->kind)
4793 result = a->value.boolean == b->value.boolean;
4794 else if (XS_INTEGER_KIND == a->kind)
4795 result = a->value.integer == b->value.integer;
4796 else if (XS_NUMBER_KIND == a->kind) {
4797 result = (!c_isnan(a->value.number)) && (!c_isnan(b->value.number)) && (a->value.number == b->value.number);
4798 mxFloatingPointOp("same slot");
4799 }
4800 else if ((XS_STRING_KIND == a->kind) || (XS_STRING_X_KIND == a->kind))
4801 result = c_strcmp(a->value.string, b->value.string) == 0;
4802 else if (XS_SYMBOL_KIND == a->kind)
4803 result = a->value.symbol == b->value.symbol;
4804 else if ((XS_BIGINT_KIND == a->kind) || (XS_BIGINT_X_KIND == a->kind))
4805 result = gxTypeBigInt.compare(the, 0, 1, 0, a, b);
4806 else if (XS_REFERENCE_KIND == a->kind)
4807 result = fxIsSameReference(the, a, b);
4808 }
4809 else if ((XS_INTEGER_KIND == a->kind) && (XS_NUMBER_KIND == b->kind)) {
4810 result = (!c_isnan(b->value.number)) && ((txNumber)(a->value.integer) == b->value.number);
4811 mxFloatingPointOp("same slot");
4812 }
4813 else if ((XS_NUMBER_KIND == a->kind) && (XS_INTEGER_KIND == b->kind)) {
4814 result = (!c_isnan(a->value.number)) && (a->value.number == (txNumber)(b->value.integer));
4815 mxFloatingPointOp("same slot");
4816 }
4817 else if ((XS_STRING_KIND == a->kind) && (XS_STRING_X_KIND == b->kind))
4818 result = c_strcmp(a->value.string, b->value.string) == 0;
4819 else if ((XS_STRING_X_KIND == a->kind) && (XS_STRING_KIND == b->kind))
4820 result = c_strcmp(a->value.string, b->value.string) == 0;
4821 else if ((XS_BIGINT_KIND == a->kind) && (XS_BIGINT_X_KIND == b->kind))
4822 result = gxTypeBigInt.compare(the, 0, 1, 0, a, b);
4823 else if ((XS_BIGINT_X_KIND == a->kind) && (XS_BIGINT_KIND == b->kind))
4824 result = gxTypeBigInt.compare(the, 0, 1, 0, a, b);
4825 return result;
4826}
4827
4828txBoolean fxIsSameValue(txMachine* the, txSlot* a, txSlot* b, txBoolean zero)
4829{

Callers 11

fx_IteratorFunction · 0.85
fx_GeneratorFunctionFunction · 0.85
fx_FunctionFunction · 0.85
fx_AsyncFunctionFunction · 0.85
fx_ObjectFunction · 0.85

Calls 1

fxIsSameReferenceFunction · 0.85

Tested by

no test coverage detected