Example #1
0
        public static bool Match_E1aritopE2eq0 <Variable, Expression>(
            this IExpressionDecoder <Variable, Expression> decoder,
            Expression e1, Expression e2,
            out ExpressionOperator op, out Expression e11, out Expression e12)
        {
            Contract.Requires(decoder != null);

            Int32 value;

            if (decoder.IsConstantInt(e2, out value) && value == 0)
            {
                op = decoder.OperatorFor(e1);
                if (op.Equals(ExpressionOperator.Addition) || op.Equals(ExpressionOperator.Subtraction))
                {
                    e11 = decoder.LeftExpressionFor(e1);
                    e12 = decoder.RightExpressionFor(e1);
                    return(true);
                }
            }

            op  = default(ExpressionOperator);
            e11 = e12 = default(Expression);

            return(false);
        }