public RuntimeObjComparer(RuntimeObj x, RuntimeObj y) { if (x == RuntimeObj.Null) { x = RuntimeObj.Undefined; } else { x = x.ToValue(); } if (y == RuntimeObj.Null) { y = RuntimeObj.Undefined; } else { y = y.ToValue(); } if ((Swapped = string.CompareOrdinal(x.Type, y.Type) > 0)) { X = y; Y = x; } else { X = x; Y = y; } }
RuntimeObj BitwiseShift(RuntimeObj val, RuntimeObj shift, bool right) { if (val == DoubleObj.Zero) { return(val); } double dR = shift.ToDouble(); int iShift; if (double.IsNaN(dR) || (iShift = (dR < 0 ? (int)Math.Ceiling(dR) : (int)Math.Floor(dR)) % 64) == 0) { return(val.ToValue() as DoubleObj ?? DoubleObj.Create(val.ToDouble())); } if (right && iShift < 0) { return(DoubleObj.Zero); } int lN = JSSupport.ToInt32(val.ToDouble()); if (lN == 0) { return(DoubleObj.Zero); } return(DoubleObj.Create(right ? lN >> iShift : lN << iShift)); }