Пример #1
0
        protected Expr HandleNAry(NAryExpr e)
        {
            if (e.Fun is FunctionCall)
            {
                var    FC        = (FunctionCall)e.Fun;
                string bvbuiltin = QKeyValue.FindStringAttribute(FC.Func.Attributes, "bvbuiltin");
                if (bvbuiltin != null)
                {
                    return(HandlerBvBuiltIns(e, bvbuiltin));
                }
                else
                {
                    string builtin = QKeyValue.FindStringAttribute(FC.Func.Attributes, "builtin");
                    if (builtin != null)
                    {
                        return(HandlerBuiltIns(e, builtin));
                    }

                    // Not a bvbuiltin so treat as generic function call.
                    return(Visitor.VisitFunctionCall(e));
                }
            }
            else if (e.Fun is UnaryOperator)
            {
                var U = (UnaryOperator)e.Fun;
                switch (U.Op)
                {
                case UnaryOperator.Opcode.Neg:
                    return(Visitor.VisitNeg(e));

                case UnaryOperator.Opcode.Not:
                    return(Visitor.VisitNot(e));

                default:
                    throw new NotImplementedException("Unary operator not supported");
                }
            }
            else if (e.Fun is BinaryOperator)
            {
                var B = (BinaryOperator)e.Fun;
                switch (B.Op)
                {
                // Integer or Real number operators
                case BinaryOperator.Opcode.Add:
                    return(Visitor.VisitAdd(e));

                case BinaryOperator.Opcode.Sub:
                    return(Visitor.VisitSub(e));

                case BinaryOperator.Opcode.Mul:
                    return(Visitor.VisitMul(e));

                case BinaryOperator.Opcode.Div:
                    return(Visitor.VisitDiv(e));

                case BinaryOperator.Opcode.Mod:
                    return(Visitor.VisitMod(e));

                case BinaryOperator.Opcode.RealDiv:
                    return(Visitor.VisitRealDiv(e));

                case BinaryOperator.Opcode.Pow:
                    return(Visitor.VisitPow(e));

                // Comparision operators
                case BinaryOperator.Opcode.Eq:
                    return(Visitor.VisitEq(e));

                case BinaryOperator.Opcode.Neq:
                    return(Visitor.VisitNeq(e));

                case BinaryOperator.Opcode.Gt:
                    return(Visitor.VisitGt(e));

                case BinaryOperator.Opcode.Ge:
                    return(Visitor.VisitGe(e));

                case BinaryOperator.Opcode.Lt:
                    return(Visitor.VisitLt(e));

                case BinaryOperator.Opcode.Le:
                    return(Visitor.VisitLe(e));

                // Bool operators
                case BinaryOperator.Opcode.And:
                    return(Visitor.VisitAnd(e));

                case BinaryOperator.Opcode.Or:
                    return(Visitor.VisitOr(e));

                case BinaryOperator.Opcode.Imp:
                    return(Visitor.VisitImp(e));

                case BinaryOperator.Opcode.Iff:
                    return(Visitor.VisitIff(e));

                case BinaryOperator.Opcode.Subtype:
                    return(Visitor.VisitSubType(e));

                default:
                    throw new NotImplementedException("Binary operator not supported!");
                }
            }
            else if (e.Fun is MapStore)
            {
                return(Visitor.VisitMapStore(e));
            }
            else if (e.Fun is MapSelect)
            {
                return(Visitor.VisitMapSelect(e));
            }
            else if (e.Fun is IfThenElse)
            {
                return(Visitor.VisitIfThenElse(e));
            }
            else if (e.Fun is TypeCoercion)
            {
                return(Visitor.VisitTypeCoercion(e));
            }
            else if (e.Fun is ArithmeticCoercion)
            {
                return(Visitor.VisitArithmeticCoercion(e));
            }
            else if (e.Fun is DistinctOperator)
            {
                return(Visitor.VisitDistinct(e));
            }

            throw new NotImplementedException("NAry not handled!");
        }