public static IntExpression Create(IntExpression lhs, IntExpression rhs, bool shiftLeft) { int lhsValue, rhsValue; if(lhs.TryGetConstant(out lhsValue) && rhs.TryGetConstant(out rhsValue)) { return shiftLeft ? lhsValue<<rhsValue : lhsValue>>rhsValue; } return new Shift(lhs, rhs, shiftLeft); }
public static IntExpression Create(IntExpression lhs, IntExpression rhs, bool shiftLeft) { int lhsValue, rhsValue; if (lhs.TryGetConstant(out lhsValue) && rhs.TryGetConstant(out rhsValue)) { return(shiftLeft ? lhsValue << rhsValue : lhsValue >> rhsValue); } return(new Shift(lhs, rhs, shiftLeft)); }
public static IntExpression Create(IntExpression expr) { int value; if(expr.TryGetConstant(out value)) { return new IntConstant(-value); } var alreadyNegatedExpression=expr as UnaryMinus; return ReferenceEquals(alreadyNegatedExpression, null) ? new UnaryMinus(expr) : alreadyNegatedExpression.expr; }
public static IntExpression Create(IntExpression expr) { int value; if (expr.TryGetConstant(out value)) { return(new IntConstant(-value)); } var alreadyNegatedExpression = expr as UnaryMinus; return(ReferenceEquals(alreadyNegatedExpression, null) ? new UnaryMinus(expr) : alreadyNegatedExpression.expr); }