Inheritance: System.Xml.Xsl.Qil.QilPatternFactory
Example #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);
 }
Example #2
0
            public void CastArguments(IList <QilNode> args, string name, XPathQilFactory f)
            {
                CheckArity(this.minArgs, this.maxArgs, name, args.Count);

                // Convert arguments to the appropriate types
                if (maxArgs == Infinity)
                {
                    // Special case for concat() function
                    for (int i = 0; i < args.Count; i++)
                    {
                        args[i] = f.ConvertToType(XmlTypeCode.String, args[i]);
                    }
                }
                else
                {
                    for (int i = 0; i < args.Count; i++)
                    {
                        if (argTypes[i] == XmlTypeCode.Node && f.CannotBeNodeSet(args[i]))
                        {
                            throw new XPathCompileException(SR.XPath_NodeSetArgumentExpected, name, (i + 1).ToString(CultureInfo.InvariantCulture));
                        }
                        args[i] = f.ConvertToType(argTypes[i], args[i]);
                    }
                }
            }
Example #3
0
        //  ----------------------------------------------------------------------------

        public XPathBuilder(IXPathEnvironment environment)
        {
            _environment       = environment;
            _f                 = _environment.Factory;
            this.fixupCurrent  = _f.Unknown(T.NodeNotRtf);
            this.fixupPosition = _f.Unknown(T.DoubleX);
            this.fixupLast     = _f.Unknown(T.DoubleX);
            _fixupVisitor      = new FixupVisitor(_f, fixupCurrent, fixupPosition, fixupLast);
        }
Example #4
0
 private QilNode CompareNodeSetAndValue(XPathOperator op, QilNode nodeset, QilNode val, XmlTypeCode compType)
 {
     XPathQilFactory.CheckNodeSet(nodeset);
     Debug.Assert(val.XmlType !.IsSingleton);
     Debug.Assert(compType == XmlTypeCode.Boolean || compType == XmlTypeCode.Double || compType == XmlTypeCode.String, "I don't know what to do with RTF here");
     if (compType == XmlTypeCode.Boolean || nodeset.XmlType !.IsSingleton)
     {
         return(CompareValues(op, nodeset, val, compType));
     }
        public XPathPatternBuilder(IXPathEnvironment environment) {
            Debug.Assert(environment != null);
            this.environment = environment;
            this.f           = environment.Factory;
            this.predicateEnvironment = new XPathPredicateEnvironment(environment);
            this.predicateBuilder     = new XPathBuilder(predicateEnvironment);

            this.fixupNode = f.Unknown(T.NodeNotRtfS);
        }
Example #6
0
        //also used by XPathPatternBuilder
        public static QilNode BuildOnePredicate(QilNode nodeset, QilNode predicate, bool isReverseStep,
                                                XPathQilFactory f, FixupVisitor fixupVisitor,
                                                ref int numFixupCurrent, ref int numFixupPosition, ref int numFixupLast)
        {
            nodeset = f.EnsureNodeSet(nodeset);

            // Mirgeing nodeset and predicate:
            // 1. Predicate contains 0 last() :
            //      for $i in nodeset
            //      where predicate
            //      return $i
            //   Note: Currently we are keepeing old output to minimize diff.
            // 2. Predicate contains 1 last()
            //      let $cach := nodeset return
            //          for $i in $cach
            //          where predicate(length($cach))
            //          return $i
            //   Suggestion: This is a little optimisation we can do or don't do.
            // 3. Predicate contains 2+ last()
            //      let $cash := nodeset return
            //          let $size := length($cash) return
            //              for $i in $cash
            //              where predicate($size)
            //              return $i

            QilNode result;

            if (numFixupLast != 0 && fixupVisitor.CountUnfixedLast(predicate) != 0)
            {
                // this subtree has unfixed last() nodes
                QilIterator cash = f.Let(nodeset);
                QilIterator size = f.Let(f.XsltConvert(f.Length(cash), T.DoubleX));
                QilIterator it   = f.For(cash);
                predicate         = fixupVisitor.Fixup(predicate, /*current:*/ it, /*last:*/ size);
                numFixupCurrent  -= fixupVisitor.numCurrent;
                numFixupPosition -= fixupVisitor.numPosition;
                numFixupLast     -= fixupVisitor.numLast;
                result            = f.Loop(cash, f.Loop(size, f.Filter(it, predicate)));
            }
            else
            {
                QilIterator it = f.For(nodeset);
                predicate         = fixupVisitor.Fixup(predicate, /*current:*/ it, /*last:*/ null);
                numFixupCurrent  -= fixupVisitor.numCurrent;
                numFixupPosition -= fixupVisitor.numPosition;
                numFixupLast     -= fixupVisitor.numLast;
                result            = f.Filter(it, predicate);
            }
            if (isReverseStep)
            {
                result = f.DocOrderDistinct(result);
            }
            return(result);
        }
Example #7
0
            public void CastArguments(IList <QilNode> args, string name, XPathQilFactory f)
            {
                CheckArity(this.minArgs, this.maxArgs, name, args.Count);

                // Convert arguments to the appropriate types
                if (maxArgs == Infinity)
                {
                    // Special case for concat() function
                    for (int i = 0; i < args.Count; i++)
                    {
                        args[i] = f.ConvertToType(XmlTypeCode.String, args[i]);
                    }
                }
                else
                {
                    Debug.Assert(args.Count == 0 || argTypes != null);
                    for (int i = 0; i < args.Count; i++)
                    {
                        if (argTypes ![i] == XmlTypeCode.Node && f.CannotBeNodeSet(args[i]))
 public QilStrConcatenator(XPathQilFactory f) {
     this.f  = f;
     builder = new StringBuilder();
 }
Example #9
0
 public SingletonFocus(XPathQilFactory f)
 {
     _f = f;
     _focusType = SingletonFocusType.None;
     _current = null;
 }
Example #10
0
 public LoopFocus(XPathQilFactory f)
 {
     _f = f;
     _current = _cached = _last = null;
 }
Example #11
0
 public PathConvertor(XPathQilFactory f) : base (f.BaseFactory) {
     this.f = f;
 }
Example #12
0
 public SingletonFocus(XPathQilFactory f) {
     this.f    = f;
     focusType = SingletonFocusType.None;
     current   = null;
 }
Example #13
0
 public LoopFocus(XPathQilFactory f) {
     this.f = f;
     current = cached = last = null;
 }
Example #14
0
 public VariableHelper(XPathQilFactory f)
 {
     _f = f;
 }
 public XPathPredicateEnvironment(IXPathEnvironment baseEnvironment) {
     this.baseEnvironment = baseEnvironment;
     this.f = baseEnvironment.Factory;
     cloner = new Cloner(f.BaseFactory);
 }