private JsConstantWrapper BitwiseXor(JsConstantWrapper left, JsConstantWrapper right) { JsConstantWrapper newLiteral = null; if (m_parser.Settings.IsModificationAllowed(JsTreeModifications.EvaluateNumericExpressions)) { try { Int32 lValue = left.ToInt32(); Int32 rValue = right.ToInt32(); newLiteral = new JsConstantWrapper(Convert.ToDouble(lValue ^ rValue), JsPrimitiveType.Number, null, m_parser); } catch (InvalidCastException) { // some kind of casting in ToNumber caused a situation where we don't want // to perform the combination on these operands } } return newLiteral; }
private JsConstantWrapper RightShift(JsConstantWrapper left, JsConstantWrapper right) { JsConstantWrapper newLiteral = null; if (m_parser.Settings.IsModificationAllowed(JsTreeModifications.EvaluateNumericExpressions)) { try { // left-hand value is a 32-bit signed integer Int32 lvalue = left.ToInt32(); // mask only the bottom 5 bits of the right-hand value int rvalue = (int)(right.ToUInt32() & 0x1F); // convert the result to a double double result = Convert.ToDouble(lvalue >> rvalue); newLiteral = new JsConstantWrapper(result, JsPrimitiveType.Number, null, m_parser); } catch (InvalidCastException) { // some kind of casting in ToNumber caused a situation where we don't want // to perform the combination on these operands } } return newLiteral; }