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

Function fxIsSameValue

xs/sources/xsRun.c:4828–4870  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4826}
4827
4828txBoolean fxIsSameValue(txMachine* the, txSlot* a, txSlot* b, txBoolean zero)
4829{
4830 txBoolean result = 0;
4831 if (a->kind == b->kind) {
4832 if ((XS_UNDEFINED_KIND == a->kind) || (XS_NULL_KIND == a->kind))
4833 result = 1;
4834 else if (XS_BOOLEAN_KIND == a->kind)
4835 result = a->value.boolean == b->value.boolean;
4836 else if (XS_INTEGER_KIND == a->kind)
4837 result = a->value.integer == b->value.integer;
4838 else if (XS_NUMBER_KIND == a->kind) {
4839 result = ((c_isnan(a->value.number) && c_isnan(b->value.number)) || ((a->value.number == b->value.number) && (zero || (c_signbit(a->value.number) == c_signbit(b->value.number)))));
4840 mxFloatingPointOp("same value");
4841 }
4842 else if ((XS_STRING_KIND == a->kind) || (XS_STRING_X_KIND == a->kind))
4843 result = c_strcmp(a->value.string, b->value.string) == 0;
4844 else if (XS_SYMBOL_KIND == a->kind)
4845 result = a->value.symbol == b->value.symbol;
4846 else if ((XS_BIGINT_KIND == a->kind) || (XS_BIGINT_X_KIND == a->kind))
4847 result = gxTypeBigInt.compare(the, 0, 1, 0, a, b);
4848 else if (XS_REFERENCE_KIND == a->kind)
4849 result = fxIsSameReference(the, a, b);
4850 }
4851 else if ((XS_INTEGER_KIND == a->kind) && (XS_NUMBER_KIND == b->kind)) {
4852 txNumber aNumber = a->value.integer;
4853 result = (aNumber == b->value.number) && (zero || (signbit(aNumber) == signbit(b->value.number)));
4854 mxFloatingPointOp("same value");
4855 }
4856 else if ((XS_NUMBER_KIND == a->kind) && (XS_INTEGER_KIND == b->kind)) {
4857 txNumber bNumber = b->value.integer;
4858 result = (a->value.number == bNumber) && (zero || (signbit(a->value.number) == signbit(bNumber)));
4859 mxFloatingPointOp("same value");
4860 }
4861 else if ((XS_STRING_KIND == a->kind) && (XS_STRING_X_KIND == b->kind))
4862 result = c_strcmp(a->value.string, b->value.string) == 0;
4863 else if ((XS_STRING_X_KIND == a->kind) && (XS_STRING_KIND == b->kind))
4864 result = c_strcmp(a->value.string, b->value.string) == 0;
4865 else if ((XS_BIGINT_KIND == a->kind) && (XS_BIGINT_X_KIND == b->kind))
4866 result = gxTypeBigInt.compare(the, 0, 1, 0, a, b);
4867 else if ((XS_BIGINT_X_KIND == a->kind) && (XS_BIGINT_KIND == b->kind))
4868 result = gxTypeBigInt.compare(the, 0, 1, 0, a, b);
4869 return result;
4870}
4871
4872txBoolean fxIsScopableSlot(txMachine* the, txSlot* instance, txID id)
4873{

Callers 15

fxStepAsyncFunction · 0.85
fx_Object_isFunction · 0.85
fxProxyGetPropertyValueFunction · 0.85
fxProxyGetPrototypeFunction · 0.85
fxProxySetPropertyValueFunction · 0.85
fxProxySetPrototypeFunction · 0.85

Calls 1

fxIsSameReferenceFunction · 0.85

Tested by

no test coverage detected