Exemplo n.º 1
0
 private LogicalExpr(LogicalExpr other)
     : base(other)
 {
     this.op = other.op;
     this.opnd1 = Clone(other.opnd1);
     this.opnd2 = Clone(other.opnd2);
 }
Exemplo n.º 2
0
        static bool cmpBoolBoolE(Operator.Op op, object val1, object val2)
        {
            bool n1 = (bool)val1;
            bool n2 = (bool)val2;

            return(cmpBoolBoolE(op, n1, n2));
        }
Exemplo n.º 3
0
        static bool cmpBoolNumberE(Operator.Op op, object val1, object val2)
        {
            bool n1 = (bool)val1;
            bool n2 = BooleanFunctions.toBoolean((double)val2);

            return(cmpBoolBoolE(op, n1, n2));
        }
Exemplo n.º 4
0
        static bool cmpBoolNumberO(Operator.Op op, object val1, object val2)
        {
            double n1 = NumberFunctions.Number((bool)val1);
            double n2 = (double)val2;

            return(cmpNumberNumberO(op, n1, n2));
        }
Exemplo n.º 5
0
        static bool cmpRtfRtfE(Operator.Op op, object val1, object val2)
        {
            string n1 = Rtf(val1);
            string n2 = Rtf(val2);

            return(cmpStringStringE(op, n1, n2));
        }
Exemplo n.º 6
0
        static bool cmpNumberNumber(Operator.Op op, object val1, object val2)
        {
            double n1 = (double)val1;
            double n2 = (double)val2;

            return(cmpNumberNumber(op, n1, n2));
        }
Exemplo n.º 7
0
 static bool cmpStringStringE(Operator.Op op, string n1, string n2)
 {
     Debug.Assert(op == Operator.Op.EQ || op == Operator.Op.NE,
                  "Unexpected Operator.op code in cmpStringStringE()"
                  );
     return((op == Operator.Op.EQ) == (n1 == n2));
 }
Exemplo n.º 8
0
 static bool cmpBoolStringO(Operator.Op op, object val1, object val2)
 {
     return(cmpNumberNumberO(op,
                             NumberFunctions.Number((bool)val1),
                             NumberFunctions.Number((string)val2)
                             ));
 }
Exemplo n.º 9
0
 static bool cmpRtfBoolO(Operator.Op op, object val1, object val2)
 {
     return(cmpNumberNumberO(op,
                             NumberFunctions.Number(Rtf(val1)),
                             NumberFunctions.Number((bool)val2)
                             ));
 }
Exemplo n.º 10
0
        static bool cmpRtfBoolE(Operator.Op op, object val1, object val2)
        {
            bool n1 = BooleanFunctions.toBoolean(Rtf(val1));
            bool n2 = (bool)val2;

            return(cmpBoolBoolE(op, n1, n2));
        }
Exemplo n.º 11
0
        private static bool cmpRtfStringE(Operator.Op op, object val1, object val2)
        {
            string n1 = Rtf(val1);
            string n2 = (string)val2;

            return(cmpStringStringE(op, n1, n2));
        }
Exemplo n.º 12
0
        private static bool cmpRtfNumber(Operator.Op op, object val1, object val2)
        {
            double n2 = (double)val2;
            double n1 = NumberFunctions.Number(Rtf(val1));

            return(cmpNumberNumber(op, n1, n2));
        }
Exemplo n.º 13
0
        static bool cmpStringStringO(Operator.Op op, object val1, object val2)
        {
            double n1 = NumberFunctions.Number((string)val1);
            double n2 = NumberFunctions.Number((string)val2);

            return(cmpNumberNumberO(op, n1, n2));
        }
Exemplo n.º 14
0
        static bool cmpStringStringE(Operator.Op op, object val1, object val2)
        {
            string n1 = (string)val1;
            string n2 = (string)val2;

            return(cmpStringStringE(op, n1, n2));
        }
Exemplo n.º 15
0
        static bool cmpRtfRtfO(Operator.Op op, object val1, object val2)
        {
            double n1 = NumberFunctions.Number(Rtf(val1));
            double n2 = NumberFunctions.Number(Rtf(val2));

            return(cmpNumberNumberO(op, n1, n2));
        }
Exemplo n.º 16
0
 static bool cmpBoolBoolE(Operator.Op op, bool n1, bool n2)
 {
     Debug.Assert(op == Operator.Op.EQ || op == Operator.Op.NE,
                  "Unexpected Operator.op code in cmpBoolBoolE()"
                  );
     return((op == Operator.Op.EQ) == (n1 == n2));
 }
Exemplo n.º 17
0
        /*cmpXslt:*/
        static bool cmpQueryQueryO(Operator.Op op, object val1, object val2)
        {
            Debug.Assert(
                op == Operator.Op.LT || op == Operator.Op.GT ||
                op == Operator.Op.LE || op == Operator.Op.GE
                );

            NodeSet n1 = new NodeSet(val1);
            NodeSet n2 = new NodeSet(val2);

            while (true)
            {
                if (!n1.MoveNext())
                {
                    return(false);
                }
                if (!n2.MoveNext())
                {
                    return(false);
                }

                double num1 = NumberFunctions.Number(n1.Value);

                do
                {
                    if (cmpNumberNumber(op, num1, NumberFunctions.Number(n2.Value)))
                    {
                        return(true);
                    }
                } while (n2.MoveNext());
                n2.Reset();
            }
        }
Exemplo n.º 18
0
        static bool cmpBoolStringE(Operator.Op op, object val1, object val2)
        {
            bool n1 = (bool)val1;
            bool n2 = BooleanFunctions.toBoolean((string)val2);

            return(cmpBoolBoolE(op, n1, n2));
        }
Exemplo n.º 19
0
        /*cmpXslt:*/
        static bool cmpQueryQueryE(Operator.Op op, object val1, object val2)
        {
            Debug.Assert(op == Operator.Op.EQ || op == Operator.Op.NE);
            bool isEQ = (op == Operator.Op.EQ);

            NodeSet n1 = new NodeSet(val1);
            NodeSet n2 = new NodeSet(val2);

            while (true)
            {
                if (!n1.MoveNext())
                {
                    return(false);
                }
                if (!n2.MoveNext())
                {
                    return(false);
                }

                string str1 = n1.Value;

                do
                {
                    if ((str1 == n2.Value) == isEQ)
                    {
                        return(true);
                    }
                }while (n2.MoveNext());
                n2.Reset();
            }
        }
Exemplo n.º 20
0
        public override object Evaluate(XPathNodeIterator nodeIterator)
        {
            Operator.Op op    = this.op;
            object      val1  = this.opnd1.Evaluate(nodeIterator);
            object      val2  = this.opnd2.Evaluate(nodeIterator);
            int         type1 = (int)GetXPathType(val1);
            int         type2 = (int)GetXPathType(val2);

            if (type1 < type2)
            {
                op = Operator.InvertOperator(op);
                object valTemp = val1;
                val1 = val2;
                val2 = valTemp;
                int typeTmp = type1;
                type1 = type2;
                type2 = typeTmp;
            }

            if (op == Operator.Op.EQ || op == Operator.Op.NE)
            {
                return(CompXsltE[type1][type2](op, val1, val2));
            }
            else
            {
                return(CompXsltO[type1][type2](op, val1, val2));
            }
        }
Exemplo n.º 21
0
        private static bool cmpQueryBoolO(Operator.Op op, object val1, object val2)
        {
            NodeSet n1 = new NodeSet(val1);
            double  d1 = n1.MoveNext() ? 1.0 : 0;
            double  d2 = NumberFunctions.Number((bool)val2);

            return(cmpNumberNumberO(op, d1, d2));
        }
Exemplo n.º 22
0
        private static bool cmpQueryBoolO(Operator.Op op, object val1, object val2)
        {
            NodeSet set  = new NodeSet(val1);
            double  num  = set.MoveNext() ? 1.0 : 0.0;
            double  num2 = NumberFunctions.Number((bool)val2);

            return(cmpNumberNumberO(op, num, num2));
        }
Exemplo n.º 23
0
        private static bool cmpQueryBoolE(Operator.Op op, object val1, object val2)
        {
            NodeSet n1 = new NodeSet(val1);
            bool    b1 = n1.MoveNext();
            bool    b2 = (bool)val2;

            return(cmpBoolBoolE(op, b1, b2));
        }
Exemplo n.º 24
0
 public LogicalExpr(Operator.Op op, Query  opnd1, Query  opnd2) {
     Debug.Assert(
         Operator.Op.LT == op || Operator.Op.GT == op ||
         Operator.Op.LE == op || Operator.Op.GE == op ||
         Operator.Op.EQ == op || Operator.Op.NE == op
     );
     this.op    = op;
     this.opnd1 = opnd1;
     this.opnd2 = opnd2;
 }
Exemplo n.º 25
0
 public LogicalExpr(Operator.Op op, Query opnd1, Query opnd2)
 {
     Debug.Assert(
         Operator.Op.LT == op || Operator.Op.GT == op ||
         Operator.Op.LE == op || Operator.Op.GE == op ||
         Operator.Op.EQ == op || Operator.Op.NE == op
         );
     _op    = op;
     _opnd1 = opnd1;
     _opnd2 = opnd2;
 }
Exemplo n.º 26
0
 internal NumericExpr(Operator.Op op, IQuery  opnd1, IQuery  opnd2) {
     if ( opnd1 is VariableQuery || opnd1 is XsltFunction  || opnd1.ReturnType() != XPathResultType.Number)
         _opnd1= new NumberFunctions(opnd1);
     else
         _opnd1 = opnd1;
     if (opnd2 != null && (opnd2 is VariableQuery || opnd2 is XsltFunction ||   opnd2.ReturnType() != XPathResultType.Number))
         _opnd2= new NumberFunctions(opnd2);
     else
         _opnd2 = opnd2;
     _op= op;
 }
Exemplo n.º 27
0
 private static double GetValue(Operator.Op op, double n1, double n2)
 {
     Debug.Assert(op == Operator.Op.PLUS || op == Operator.Op.MINUS || op == Operator.Op.MOD || op == Operator.Op.DIV || op == Operator.Op.MUL);
     return(op switch
     {
         Operator.Op.PLUS => n1 + n2,
         Operator.Op.MINUS => n1 - n2,
         Operator.Op.MOD => n1 % n2,
         Operator.Op.DIV => n1 / n2,
         Operator.Op.MUL => n1 * n2,
         _ => 0,
     });
 public NumericExpr(Operator.Op op, Query opnd1, Query opnd2)
 {
     if (opnd1.StaticType != XPathResultType.Number)
     {
         opnd1 = new NumberFunctions(Function.FunctionType.FuncNumber, opnd1);
     }
     if (opnd2.StaticType != XPathResultType.Number)
     {
         opnd2 = new NumberFunctions(Function.FunctionType.FuncNumber, opnd2);
     }
     this.op    = op;
     this.opnd1 = opnd1;
     this.opnd2 = opnd2;
 }
 public BooleanExpr(Operator.Op op, Query opnd1, Query opnd2)
 {
     if (opnd1.StaticType != XPathResultType.Boolean)
     {
         opnd1 = new BooleanFunctions(Function.FunctionType.FuncBoolean, opnd1);
     }
     if (opnd2.StaticType != XPathResultType.Boolean)
     {
         opnd2 = new BooleanFunctions(Function.FunctionType.FuncBoolean, opnd2);
     }
     this.opnd1 = opnd1;
     this.opnd2 = opnd2;
     this.isOr  = op == Operator.Op.OR;
 }
Exemplo n.º 30
0
        private static bool cmpRtfQueryE(Operator.Op op, object val1, object val2)
        {
            string  n1 = Rtf(val1);
            NodeSet n2 = new NodeSet(val2);

            while (n2.MoveNext())
            {
                if (cmpStringStringE(op, n1, n2.Value))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 31
0
        private static bool cmpRtfQueryO(Operator.Op op, object val1, object val2)
        {
            double  n1 = NumberFunctions.Number(Rtf(val1));
            NodeSet n2 = new NodeSet(val2);

            while (n2.MoveNext())
            {
                if (cmpNumberNumberO(op, n1, NumberFunctions.Number(n2.Value)))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 32
0
        private static bool cmpQueryStringE(Operator.Op op, object val1, object val2)
        {
            NodeSet n1 = new NodeSet(val1);
            string  n2 = (string)val2;

            while (n1.MoveNext())
            {
                if (cmpStringStringE(op, n1.Value, n2))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 33
0
        private static bool cmpQueryStringO(Operator.Op op, object val1, object val2)
        {
            NodeSet n1 = new NodeSet(val1);
            double  n2 = NumberFunctions.Number((string)val2);

            while (n1.MoveNext())
            {
                if (cmpNumberNumberO(op, NumberFunctions.Number(n1.Value), n2))
                {
                    return(true);
                }
            }
            return(false);
        }
 public NumericExpr(Operator.Op op, Query opnd1, Query opnd2)
 {
     if (opnd1.StaticType != XPathResultType.Number)
     {
         opnd1 = new NumberFunctions(Function.FunctionType.FuncNumber, opnd1);
     }
     if (opnd2.StaticType != XPathResultType.Number)
     {
         opnd2 = new NumberFunctions(Function.FunctionType.FuncNumber, opnd2);
     }
     this.op = op;
     this.opnd1 = opnd1;
     this.opnd2 = opnd2;
 }
Exemplo n.º 35
0
 public NumericExpr(Operator.Op op, Query opnd1, Query  opnd2) {
     Debug.Assert(
         op == Operator.Op.PLUS || op == Operator.Op.MINUS || 
         op == Operator.Op.MUL  || op == Operator.Op.DIV ||
         op == Operator.Op.MOD
     );
     Debug.Assert(opnd1 != null && opnd2 != null);
     if (opnd1.StaticType != XPathResultType.Number) {
         opnd1 = new NumberFunctions(Function.FunctionType.FuncNumber, opnd1);
     }
     if (opnd2.StaticType != XPathResultType.Number) {
         opnd2 = new NumberFunctions(Function.FunctionType.FuncNumber, opnd2);
     }
     this.op = op;
     this.opnd1 = opnd1;
     this.opnd2 = opnd2;
 }
Exemplo n.º 36
0
        public override object Evaluate(XPathNodeIterator nodeIterator) {
            Operator.Op op = this.op;
            object val1 = this.opnd1.Evaluate(nodeIterator);
            object val2 = this.opnd2.Evaluate(nodeIterator);
            int type1 = (int)GetXPathType(val1);
            int type2 = (int)GetXPathType(val2);
            if (type1 < type2) {
                op = Operator.InvertOperator(op);
                object valTemp = val1;
                val1 = val2;
                val2 = valTemp;
                int typeTmp = type1;
                type1 = type2;
                type2 = typeTmp;
            }

            if (op == Operator.Op.EQ || op == Operator.Op.NE) {
                return CompXsltE[type1][type2](op, val1, val2);
            } else {
                return CompXsltO[type1][type2](op, val1, val2);
            }
        }
Exemplo n.º 37
0
 private LogicalExpr(LogicalExpr other) : base(other)
 {
     _op = other._op;
     _opnd1 = Clone(other._opnd1);
     _opnd2 = Clone(other._opnd2);
 }
 private NumericExpr(NumericExpr other) : base(other)
 {
     this.op = other.op;
     this.opnd1 = Query.Clone(other.opnd1);
     this.opnd2 = Query.Clone(other.opnd2);
 }
Exemplo n.º 39
0
        //
        // The operand needs to use the number function
        // to covert to numbers
        internal NumericExpr(Operator.Op op, IQuery opnd1, IQuery opnd2) {

            if (opnd1.ReturnType() != XPathResultType.Number) {
                this.opnd1= new NumberFunctions(opnd1);
            }
            else {
                this.opnd1 = opnd1;
            }

            if (opnd2 != null && (opnd2.ReturnType() != XPathResultType.Number)) {
                this.opnd2= new NumberFunctions(opnd2);
            }
            else{
                this.opnd2 = opnd2;
            }

            this.op= op;
        }
Exemplo n.º 40
0
 internal LogicalExpr(Operator.Op op, IQuery opnd1, IQuery opnd2){
     this.opnd1= opnd1;
     this.opnd2= opnd2;
     this.op= op;
 }
 public LogicalExpr(Operator.Op op, Query opnd1, Query opnd2)
 {
     this.op = op;
     this.opnd1 = opnd1;
     this.opnd2 = opnd2;
 }
Exemplo n.º 42
0
 internal LogicalExpr(Operator.Op op, IQuery  opnd1, IQuery  opnd2) {
     _opnd1= opnd1;
     _opnd2= opnd2;
     _op= op;
 }
Exemplo n.º 43
0
 private NumericExpr(NumericExpr other) : base(other)
 {
     _op = other._op;
     _opnd1 = Clone(other._opnd1);
     _opnd2 = Clone(other._opnd2);
 }
 public override object Evaluate(XPathNodeIterator nodeIterator)
 {
     Operator.Op op = this.op;
     object obj2 = this.opnd1.Evaluate(nodeIterator);
     object obj3 = this.opnd2.Evaluate(nodeIterator);
     int xPathType = (int) base.GetXPathType(obj2);
     int index = (int) base.GetXPathType(obj3);
     if (xPathType < index)
     {
         op = Operator.InvertOperator(op);
         object obj4 = obj2;
         obj2 = obj3;
         obj3 = obj4;
         int num3 = xPathType;
         xPathType = index;
         index = num3;
     }
     if ((op != Operator.Op.EQ) && (op != Operator.Op.NE))
     {
         return CompXsltO[xPathType][index](op, obj2, obj3);
     }
     return CompXsltE[xPathType][index](op, obj2, obj3);
 }