internal BinaryRelationship GetNormalizedRelationship(BoolConstraint boolConstraint, SymbolicValue leftOperand, SymbolicValue rightOperand)
        {
            var invertCount = 0;

            var leftOp = leftOperand;
            var logicalNotLeftOp = leftOp as LogicalNotSymbolicValue;
            while (logicalNotLeftOp != null)
            {
                leftOp = logicalNotLeftOp.Operand;
                logicalNotLeftOp = leftOp as LogicalNotSymbolicValue;
                invertCount++;
            }

            var rightOp = rightOperand;
            var logicalNotRightOp = rightOp as LogicalNotSymbolicValue;
            while (logicalNotRightOp != null)
            {
                rightOp = logicalNotRightOp.Operand;
                logicalNotRightOp = rightOp as LogicalNotSymbolicValue;
                invertCount++;
            }

            var relationship = GetRelationship(boolConstraint, leftOp, rightOp);

            return invertCount % 2 == 0
                ? relationship
                : relationship.Negate();
        }
Exemple #2
0
        internal BinaryRelationship GetNormalizedRelationship(BoolConstraint boolConstraint, SymbolicValue leftOperand, SymbolicValue rightOperand)
        {
            var invertCount = 0;

            var leftOp           = leftOperand;
            var logicalNotLeftOp = leftOp as LogicalNotSymbolicValue;

            while (logicalNotLeftOp != null)
            {
                leftOp           = logicalNotLeftOp.Operand;
                logicalNotLeftOp = leftOp as LogicalNotSymbolicValue;
                invertCount++;
            }

            var rightOp           = rightOperand;
            var logicalNotRightOp = rightOp as LogicalNotSymbolicValue;

            while (logicalNotRightOp != null)
            {
                rightOp           = logicalNotRightOp.Operand;
                logicalNotRightOp = rightOp as LogicalNotSymbolicValue;
                invertCount++;
            }

            var relationship = GetRelationship(boolConstraint, leftOp, rightOp);

            return(invertCount % 2 == 0
                ? relationship
                : relationship.Negate());
        }
        private BinaryRelationship GetRelationship(BoolConstraint boolConstraint)
        {
            var relationship = new ComparisonRelationship(comparisonKind, leftOperand, rightOperand);

            return boolConstraint == BoolConstraint.True
                ? relationship
                : relationship.Negate();
        }
Exemple #4
0
        internal BinaryRelationship GetRelationship(BoolConstraint boolConstraint, SymbolicValue left, SymbolicValue right)
        {
            var equalsRelationship = GetRelationship(left, right);

            return(boolConstraint == BoolConstraint.True
                ? equalsRelationship
                : equalsRelationship.Negate());
        }
        internal BinaryRelationship GetRelationship(BoolConstraint boolConstraint, SymbolicValue left, SymbolicValue right)
        {
            var equalsRelationship = GetRelationship(left, right);

            return boolConstraint == BoolConstraint.True
                ? equalsRelationship
                : equalsRelationship.Negate();
        }
        private BinaryRelationship GetRelationship(BoolConstraint boolConstraint)
        {
            var relationship = new ComparisonRelationship(comparisonKind, leftOperand, rightOperand);

            return(boolConstraint == BoolConstraint.True
                ? relationship
                : relationship.Negate());
        }
Exemple #7
0
        internal override IEnumerable <ProgramState> SetConstraint(BoolConstraint boolConstraint,
                                                                   SymbolicValueConstraint leftConstraint, SymbolicValueConstraint rightConstraint,
                                                                   ProgramState programState)
        {
            if (boolConstraint == BoolConstraint.False)
            {
                return(rightOperand.TrySetConstraint(leftConstraint, programState)
                       .SelectMany(ps => leftOperand.TrySetConstraint(rightConstraint, ps)));
            }

            return(rightOperand.TrySetConstraint(leftConstraint?.OppositeForLogicalNot, programState)
                   .SelectMany(ps => leftOperand.TrySetConstraint(rightConstraint?.OppositeForLogicalNot, ps)));
        }
        internal override IEnumerable<ProgramState> SetConstraint(BoolConstraint boolConstraint,
            SymbolicValueConstraint leftConstraint, SymbolicValueConstraint rightConstraint,
            ProgramState programState)
        {
            if (boolConstraint == BoolConstraint.False)
            {
                return rightOperand.TrySetConstraint(leftConstraint, programState)
                    .SelectMany(ps => leftOperand.TrySetConstraint(rightConstraint, ps));
            }

            return rightOperand.TrySetConstraint(leftConstraint?.OppositeForLogicalNot, programState)
                .SelectMany(ps => leftOperand.TrySetConstraint(rightConstraint?.OppositeForLogicalNot, ps));
        }
        private IEnumerable <ProgramState> TrySetConstraint(BoolConstraint boolConstraint, SymbolicValueConstraint oldConstraint,
                                                            ProgramState currentProgramState)
        {
            if (oldConstraint == ObjectConstraint.Null)
            {
                // It was null, and now it should be true or false
                return(Enumerable.Empty <ProgramState>());
            }

            var oldBoolConstraint = oldConstraint as BoolConstraint;

            if (oldBoolConstraint != null &&
                oldBoolConstraint != boolConstraint)
            {
                return(Enumerable.Empty <ProgramState>());
            }

            // Either same bool constraint, or previously not null, and now a bool constraint
            return(new[] { SetConstraint(boolConstraint, currentProgramState) });
        }
Exemple #10
0
 internal BinaryRelationship GetRelationship(BoolConstraint boolConstraint)
 {
     return(GetNormalizedRelationship(boolConstraint, leftOperand, rightOperand));
 }
Exemple #11
0
 internal abstract IEnumerable <ProgramState> SetConstraint(BoolConstraint boolConstraint,
                                                            SymbolicValueConstraint leftConstraint, SymbolicValueConstraint rightConstraint,
                                                            ProgramState programState);
 internal BinaryRelationship GetRelationship(BoolConstraint boolConstraint)
 {
     return GetNormalizedRelationship(boolConstraint, leftOperand, rightOperand);
 }
 internal abstract IEnumerable<ProgramState> SetConstraint(BoolConstraint boolConstraint,
     SymbolicValueConstraint leftConstraint, SymbolicValueConstraint rightConstraint,
     ProgramState programState);