Esempio n. 1
0
    private static void FoldExpression_Binary_BoolBool_Arithmetic(
        ref ES_AstExpression expr, SimpleBinaryExprType op,
        ES_AstBooleanConstantExpression lhs, ES_AstBooleanConstantExpression rhs
        )
    {
        Debug.Assert(!op.IsComparison() && !op.IsBitShift());

        bool finalValue;

        switch (op)
        {
        // Bit ops
        case SimpleBinaryExprType.BitAnd:
            finalValue = lhs.Value & rhs.Value;
            break;

        case SimpleBinaryExprType.BitOr:
            finalValue = lhs.Value | rhs.Value;
            break;

        case SimpleBinaryExprType.BitXor:
            finalValue = lhs.Value ^ rhs.Value;
            break;

        default:
            return;
        }

        expr = new ES_AstBooleanConstantExpression(finalValue, expr);
    }
Esempio n. 2
0
    private static void FoldExpression_Binary_BoolBool_Comp(
        ref ES_AstExpression expr, SimpleBinaryExprType op,
        ES_AstBooleanConstantExpression lhs, ES_AstBooleanConstantExpression rhs
        )
    {
        Debug.Assert(op.IsComparison());

        bool finalValue;

        switch (op)
        {
        case SimpleBinaryExprType.Equals:
            finalValue = lhs.Value == rhs.Value;
            break;

        case SimpleBinaryExprType.NotEquals:
            finalValue = lhs.Value != rhs.Value;
            break;

        default:
            return;
        }

        expr = new ES_AstBooleanConstantExpression(finalValue, expr);
    }