Esempio n. 1
0
        /// <summary>
        /// Evaluate > >= != == less less than
        /// </summary>
        /// <returns></returns>
        public object VisitCondition(ConditionExpr expr)
        {
            // Validate
            var op = expr.Op;
            if (op != Operator.And && op != Operator.Or)
                throw new ArgumentException("Only && || supported");

            var result = false;
            var lhsVal = expr.Left.Evaluate(this);
            var rhsVal = expr.Right.Evaluate(this);
            var left = false;
            var right = false;
            if (lhsVal != null) left = ((LBool)lhsVal).Value;
            if (rhsVal != null) right = ((LBool)rhsVal).Value;

            if (op == Operator.Or)
            {
                result = left || right;
            }
            else if (op == Operator.And)
            {
                result = left && right;
            }
            return new LBool(result);
        }
Esempio n. 2
0
 /// <summary>
 /// Creates a unary expression with symbol scope, context, script refernce set.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="token"></param>
 /// <returns></returns>
 public static Expr Condition(Expr left, Operator op, Expr right, TokenData token)
 {
     var exp = new ConditionExpr();
     exp.Left = left;
     exp.Op = op;
     exp.Right = right;
     SetupContext(exp, token);
     return exp;
 }
Esempio n. 3
0
 /// <summary>
 /// Visits the condition expression tree
 /// </summary>
 /// <param name="exp"></param>
 public object VisitCondition(ConditionExpr exp)
 {
     _callBackOnNodeStart(exp);
     _callBackOnNodeStart(exp.Left);
     _callBackOnNodeStart(exp.Right);
     return null;
 }