コード例 #1
0
 // <summary>
 // Copies a ConditionalOp
 // </summary>
 // <param name="op"> The Op to Copy </param>
 // <param name="n"> The Node that references the Op </param>
 // <returns> A copy of the original Node that references a copy of the original Op </returns>
 public override Node Visit(ConditionalOp op, Node n)
 {
     return(CopyDefault(m_destCmd.CreateConditionalOp(op.OpType), n));
 }
コード例 #2
0
        // <summary>
        // Combine two predicates by trying to avoid the predicate parts of the
        // second one that are already present in the first one.
        // In particular, given two nodes, predicate1 and predicate2,
        // it creates a combined predicate logically equivalent to
        // predicate1 AND predicate2,
        // but it does not include any AND parts of predicate2 that are present
        // in predicate1.
        // </summary>
        internal static Node CombinePredicates(Node predicate1, Node predicate2, Command command)
        {
            var andParts1 = BreakIntoAndParts(predicate1);
            var andParts2 = BreakIntoAndParts(predicate2);

            var result = predicate1;

            foreach (var predicatePart2 in andParts2)
            {
                var foundMatch = false;
                foreach (var predicatePart1 in andParts1)
                {
                    if (predicatePart1.IsEquivalent(predicatePart2))
                    {
                        foundMatch = true;
                        break;
                    }
                }
                if (!foundMatch)
                {
                    result = command.CreateNode(command.CreateConditionalOp(OpType.And), result, predicatePart2);
                }
            }
            return result;
        }