Ejemplo n.º 1
0
        public static bool JSEquals(JSValue a, JSValue b)
        {
            JSType t1 = a.ObjectType;
            JSType t2 = b.ObjectType;

            if (t1 != t2)
            {
                switch (t2)
                {
                case JSType.Boolean:
                    return(JSEquals(a, b.ToJSNumber()));

                case JSType.Object:
                    return(JSEquals(a, b.ToPrimitive()));
                }
                switch (t1)
                {
                case JSType.Number:
                    if (t2 != JSType.String)
                    {
                        goto Label_016F;
                    }
                    return(a.NumberValue() == b.NumberValue());

                case JSType.String:
                    if (t2 != JSType.Number)
                    {
                        goto Label_016F;
                    }
                    return(a.NumberValue() == b.NumberValue());

                case JSType.Boolean:
                    return(JSEquals(a.ToJSNumber(), b));

                case JSType.Object:
                    return(JSEquals(a.ToPrimitive(), b));

                case JSType.Array:
                case JSType.Function:
                    goto Label_016F;

                case JSType.Null:
                    return(t2 == JSType.Undefined);

                case JSType.Undefined:
                    return(t2 == JSType.Null);
                }
            }
            else
            {
                switch (t1)
                {
                case JSType.Number:
                    return(a.NumberValue() == b.NumberValue());

                case JSType.String:
                    return(a.StringValue() == b.StringValue());

                case JSType.Boolean:
                    return(a.BoolValue() == b.BoolValue());

                case JSType.Null:
                    return(true);

                case JSType.Undefined:
                    return(true);
                }
                return(a == b);
            }
Label_016F:
            return(false);
        }
Ejemplo n.º 2
0
        public static bool JSEquals(JSValue a, JSValue b)
        {
            JSType t1 = a.ObjectType;
            JSType t2 = b.ObjectType;
            if (t1 != t2)
            {
                switch (t2)
                {
                    case JSType.Boolean:
                        return JSEquals(a, b.ToJSNumber());

                    case JSType.Object:
                        return JSEquals(a, b.ToPrimitive());
                }
                switch (t1)
                {
                    case JSType.Number:
                        if (t2 != JSType.String)
                        {
                            goto Label_016F;
                        }
                        return (a.NumberValue() == b.NumberValue());

                    case JSType.String:
                        if (t2 != JSType.Number)
                        {
                            goto Label_016F;
                        }
                        return (a.NumberValue() == b.NumberValue());

                    case JSType.Boolean:
                        return JSEquals(a.ToJSNumber(), b);

                    case JSType.Object:
                        return JSEquals(a.ToPrimitive(), b);

                    case JSType.Array:
                    case JSType.Function:
                        goto Label_016F;

                    case JSType.Null:
                        return (t2 == JSType.Undefined);

                    case JSType.Undefined:
                        return (t2 == JSType.Null);
                }
            }
            else
            {
                switch (t1)
                {
                    case JSType.Number:
                        return (a.NumberValue() == b.NumberValue());

                    case JSType.String:
                        return (a.StringValue() == b.StringValue());

                    case JSType.Boolean:
                        return (a.BoolValue() == b.BoolValue());

                    case JSType.Null:
                        return true;

                    case JSType.Undefined:
                        return true;
                }
                return (a == b);
            }
            Label_016F:
            return false;
        }