Ejemplo n.º 1
0
 //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);
 }
Ejemplo n.º 2
0
 protected override QilNode VisitUnknown(QilNode unknown)
 {
     Debug.Assert(unknown.NodeType == QilNodeType.Unknown);
     if (unknown == _fixupCurrent)
     {
         numCurrent++;
         if (!_justCount)
         {
             if (_environment != null)
             {
                 unknown = _environment.GetCurrent();
             }
             else if (_current != null)
             {
                 unknown = _current;
             }
         }
     }
     else if (unknown == _fixupPosition)
     {
         numPosition++;
         if (!_justCount)
         {
             if (_environment != null)
             {
                 unknown = _environment.GetPosition();
             }
             else if (_current != null)
             {
                 // position can be in predicate only and in predicate current olways an iterator
                 unknown = f.XsltConvert(f.PositionOf((QilIterator)_current), T.DoubleX);
             }
         }
     }
     else if (unknown == _fixupLast)
     {
         numLast++;
         if (!_justCount)
         {
             if (_environment != null)
             {
                 unknown = _environment.GetLast();
             }
             else if (_current != null)
             {
                 Debug.Assert(_last != null);
                 unknown = _last;
             }
         }
     }
     Debug.Assert(unknown != null);
     return(unknown);
 }