//also used by XPathPatternBuilder public static QilNode PredicateToBoolean(QilNode predicate, XPathQilFactory f, IXPathEnvironment env) { // Prepocess predicate: if (predicate is number) then predicate := (position() == predicate) if (!f.IsAnyType(predicate)) { if (predicate.XmlType.TypeCode == XmlTypeCode.Double) { predicate = f.Eq(env.GetPosition(), predicate); } else { predicate = f.ConvertToBoolean(predicate); } } else { QilIterator i; predicate = f.Loop(i = f.Let(predicate), f.Conditional(f.IsType(i, T.Double), f.Eq(env.GetPosition(), f.TypeAssert(i, T.DoubleX)), f.ConvertToBoolean(i) ) ); } return(predicate); }
private QilNode LogicalOperator(XPathOperator op, QilNode left, QilNode right) { Debug.Assert(op == XPathOperator.Or || op == XPathOperator.And); left = _f.ConvertToBoolean(left); right = _f.ConvertToBoolean(right); return( op == XPathOperator.Or ? _f.Or(left, right) : /*default*/ _f.And(left, right) ); }