示例#1
0
        /// <summary>
        /// Deep copy of BoolExpr
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public static BoolExpr CreateCopy(BoolExpr other)
        {
            switch (other.Op)
            {
            case OperatorType.LEAF:
                return(CreateLiteral(other.Lit));

            case OperatorType.NOT:
            {     // keep copy variable local to this case only
                var copy = new BoolExprNegation(CreateCopy(other.Right));
                copy.Right.Parent = copy;
                return(copy);
            }

            case OperatorType.AND:
            case OperatorType.OR:
            case OperatorType.CONDITIONAL:
            case OperatorType.BICONDITIONAL:
            case OperatorType.XOR:
            {     // keep copy variable local to this case only
                var copy = CreateBinary(other.Op.ToString(), CreateCopy(other.Left), CreateCopy(other.Right));
                copy.Left.Parent  = copy;
                copy.Right.Parent = copy;
                return(copy);
            }

            default:
                return(null);
            }
        }