Пример #1
0
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame             topFrame = context.TopSequenceArg;
            SeekableXPathNavigator node     = null;

            Value[] sequences = context.Sequences;

            for (int i = topFrame.basePtr; i <= topFrame.endPtr; ++i)
            {
                // Each NodeSequence will generate a new one, but only if the source FilterSequence isn't empty
                // If the source FilterSequence is empty, release it and replace it with an empty sequence
                NodeSequence sourceSeq      = sequences[i].Sequence;
                int          sourceSeqCount = sourceSeq.Count;
                if (sourceSeqCount == 0)
                {
                    context.ReplaceSequenceAt(i, NodeSequence.Empty);
                    context.ReleaseSequence(sourceSeq);
                }
                else
                {
                    NodeSequenceItem[] items = sourceSeq.Items;
                    if (sourceSeq.CanReuse(context))
                    {
                        node = items[0].GetNavigator();
                        sourceSeq.Clear();
                        sourceSeq.StartNodeset();

                        this.criteria.Select(node, sourceSeq);

                        sourceSeq.StopNodeset();
                    }
                    else
                    {
                        NodeSequence newSeq = null;
                        for (int item = 0; item < sourceSeqCount; ++item)
                        {
                            node = items[item].GetNavigator();
                            Fx.Assert(null != node, "");
                            if (null == newSeq)
                            {
                                newSeq = context.CreateSequence();
                            }
                            newSeq.StartNodeset();
                            this.criteria.Select(node, newSeq);
                            newSeq.StopNodeset();
                        }
                        context.ReplaceSequenceAt(i, (null != newSeq) ? newSeq : NodeSequence.Empty);
                        context.ReleaseSequence(sourceSeq);
                    }
                }
            }

            return(this.next);
        }
        internal void ReleaseSequence(ProcessingContext context)
        {
            Fx.Assert(null != context && this.type == ValueDataType.Sequence && null != this.sequence, "");

            context.ReleaseSequence(this.sequence);
            this.sequence = null;
        }
Пример #3
0
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame             topSequenceArg = context.TopSequenceArg;
            SeekableXPathNavigator contextNode    = null;

            Value[] sequences = context.Sequences;
            for (int i = topSequenceArg.basePtr; i <= topSequenceArg.endPtr; i++)
            {
                NodeSequence sequence = sequences[i].Sequence;
                int          count    = sequence.Count;
                if (count == 0)
                {
                    context.ReplaceSequenceAt(i, NodeSequence.Empty);
                    context.ReleaseSequence(sequence);
                }
                else
                {
                    NodeSequenceItem[] items = sequence.Items;
                    if (sequence.CanReuse(context))
                    {
                        contextNode = items[0].GetNavigator();
                        sequence.Clear();
                        sequence.StartNodeset();
                        this.criteria.Select(contextNode, sequence);
                        sequence.StopNodeset();
                    }
                    else
                    {
                        NodeSequence destSequence = null;
                        for (int j = 0; j < count; j++)
                        {
                            contextNode = items[j].GetNavigator();
                            if (destSequence == null)
                            {
                                destSequence = context.CreateSequence();
                            }
                            destSequence.StartNodeset();
                            this.criteria.Select(contextNode, destSequence);
                            destSequence.StopNodeset();
                        }
                        context.ReplaceSequenceAt(i, (destSequence != null) ? destSequence : NodeSequence.Empty);
                        context.ReleaseSequence(sequence);
                    }
                }
            }
            return(base.next);
        }
 internal override Opcode Eval(ProcessingContext context)
 {
     StackFrame topSequenceArg = context.TopSequenceArg;
     SeekableXPathNavigator contextNode = null;
     Value[] sequences = context.Sequences;
     for (int i = topSequenceArg.basePtr; i <= topSequenceArg.endPtr; i++)
     {
         NodeSequence sequence = sequences[i].Sequence;
         int count = sequence.Count;
         if (count == 0)
         {
             context.ReplaceSequenceAt(i, NodeSequence.Empty);
             context.ReleaseSequence(sequence);
         }
         else
         {
             NodeSequenceItem[] items = sequence.Items;
             if (sequence.CanReuse(context))
             {
                 contextNode = items[0].GetNavigator();
                 sequence.Clear();
                 sequence.StartNodeset();
                 this.criteria.Select(contextNode, sequence);
                 sequence.StopNodeset();
             }
             else
             {
                 NodeSequence destSequence = null;
                 for (int j = 0; j < count; j++)
                 {
                     contextNode = items[j].GetNavigator();
                     if (destSequence == null)
                     {
                         destSequence = context.CreateSequence();
                     }
                     destSequence.StartNodeset();
                     this.criteria.Select(contextNode, destSequence);
                     destSequence.StopNodeset();
                 }
                 context.ReplaceSequenceAt(i, (destSequence != null) ? destSequence : NodeSequence.Empty);
                 context.ReleaseSequence(sequence);
             }
         }
     }
     return base.next;
 }
Пример #5
0
 internal void Update(ProcessingContext context, NodeSequence val)
 {
     if (ValueDataType.Sequence == this.type)
     {
         context.ReleaseSequence(this.sequence);
     }
     this.Sequence = val;
 }
Пример #6
0
        internal override Opcode Eval(ProcessingContext context)
        {
            // The query processor object also serves as the query document root
            int    iterationCount = context.IterationCount;
            Opcode returnOpcode   = this.next;

            // A root is always an initial step
            context.PushSequenceFrame();
            NodeSequence seq = context.CreateSequence();

            if (this.next != null && 0 != (this.next.Flags & OpcodeFlags.CompressableSelect))
            {
                SeekableXPathNavigator node = context.Processor.ContextNode;
                node.MoveToRoot();
                returnOpcode = this.next.Eval(seq, node);
                while (returnOpcode != null && 0 != (returnOpcode.Flags & OpcodeFlags.CompressableSelect))
                {
                    returnOpcode = returnOpcode.Next;
                }
            }
            else
            {
                // Roots do not have any qnames..
                seq.StartNodeset();
                SeekableXPathNavigator node = context.Processor.ContextNode;
                node.MoveToRoot();
                seq.Add(node);
                seq.StopNodeset();
            }

            if (seq.Count == 0)
            {
                context.ReleaseSequence(seq);
                seq = NodeSequence.Empty;
            }

            for (int i = 0; i < iterationCount; ++i)
            {
                context.PushSequence(seq);
            }
            if (iterationCount > 1)
            {
                seq.refCount += iterationCount - 1;
            }

            return(returnOpcode);
        }
        internal override Opcode Eval(ProcessingContext context)
        {
            int    iterationCount = context.IterationCount;
            Opcode next           = base.next;

            context.PushSequenceFrame();
            NodeSequence empty = context.CreateSequence();

            if ((base.next != null) && ((base.next.Flags & OpcodeFlags.CompressableSelect) != OpcodeFlags.None))
            {
                SeekableXPathNavigator contextNode = context.Processor.ContextNode;
                contextNode.MoveToRoot();
                next = base.next.Eval(empty, contextNode);
                while ((next != null) && ((next.Flags & OpcodeFlags.CompressableSelect) != OpcodeFlags.None))
                {
                    next = next.Next;
                }
            }
            else
            {
                empty.StartNodeset();
                SeekableXPathNavigator node = context.Processor.ContextNode;
                node.MoveToRoot();
                empty.Add(node);
                empty.StopNodeset();
            }
            if (empty.Count == 0)
            {
                context.ReleaseSequence(empty);
                empty = NodeSequence.Empty;
            }
            for (int i = 0; i < iterationCount; i++)
            {
                context.PushSequence(empty);
            }
            if (iterationCount > 1)
            {
                empty.refCount += iterationCount - 1;
            }
            return(next);
        }
 internal override Opcode Eval(ProcessingContext context)
 {
     int iterationCount = context.IterationCount;
     Opcode next = base.next;
     context.PushSequenceFrame();
     NodeSequence empty = context.CreateSequence();
     if ((base.next != null) && ((base.next.Flags & OpcodeFlags.CompressableSelect) != OpcodeFlags.None))
     {
         SeekableXPathNavigator contextNode = context.Processor.ContextNode;
         contextNode.MoveToRoot();
         next = base.next.Eval(empty, contextNode);
         while ((next != null) && ((next.Flags & OpcodeFlags.CompressableSelect) != OpcodeFlags.None))
         {
             next = next.Next;
         }
     }
     else
     {
         empty.StartNodeset();
         SeekableXPathNavigator node = context.Processor.ContextNode;
         node.MoveToRoot();
         empty.Add(node);
         empty.StopNodeset();
     }
     if (empty.Count == 0)
     {
         context.ReleaseSequence(empty);
         empty = NodeSequence.Empty;
     }
     for (int i = 0; i < iterationCount; i++)
     {
         context.PushSequence(empty);
     }
     if (iterationCount > 1)
     {
         empty.refCount += iterationCount - 1;
     }
     return next;
 }
Пример #9
0
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame          topSequenceArg = context.TopSequenceArg;
            StackFrame          topArg         = context.TopArg;
            NodeSequenceBuilder builder        = new NodeSequenceBuilder(context);

            Value[] sequences = context.Sequences;
            int     basePtr   = topSequenceArg.basePtr;
            int     index     = topArg.basePtr;

            while (basePtr <= topSequenceArg.endPtr)
            {
                NodeSequence sequence = sequences[basePtr].Sequence;
                if (sequence.Count > 0)
                {
                    NodesetIterator iterator = new NodesetIterator(sequence);
                    while (iterator.NextNodeset())
                    {
                        builder.StartNodeset();
                        while (iterator.NextItem())
                        {
                            if (context.Values[index].Boolean)
                            {
                                builder.Add(ref sequence.Items[iterator.Index]);
                            }
                            index++;
                        }
                        builder.EndNodeset();
                    }
                    context.ReplaceSequenceAt(basePtr, builder.Sequence);
                    context.ReleaseSequence(sequence);
                    builder.Sequence = null;
                }
                basePtr++;
            }
            context.PopFrame();
            return(base.next);
        }
Пример #10
0
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame          sequences       = context.TopSequenceArg;
            StackFrame          results         = context.TopArg;
            NodeSequenceBuilder sequenceBuilder = new NodeSequenceBuilder(context);

            Value[] sequenceBuffer = context.Sequences;

            for (int seqIndex = sequences.basePtr, resultIndex = results.basePtr; seqIndex <= sequences.endPtr; ++seqIndex)
            {
                NodeSequence sourceSequence = sequenceBuffer[seqIndex].Sequence;
                if (sourceSequence.Count > 0)
                {
                    NodesetIterator nodesetIterator = new NodesetIterator(sourceSequence);
                    while (nodesetIterator.NextNodeset())
                    {
                        sequenceBuilder.StartNodeset();
                        while (nodesetIterator.NextItem())
                        {
                            Fx.Assert(context.Values[resultIndex].IsType(ValueDataType.Boolean), "");
                            if (context.Values[resultIndex].Boolean)
                            {
                                sequenceBuilder.Add(ref sourceSequence.Items[nodesetIterator.Index]);
                            }
                            ++resultIndex;
                        }
                        sequenceBuilder.EndNodeset();
                    }
                    context.ReplaceSequenceAt(seqIndex, sequenceBuilder.Sequence);
                    context.ReleaseSequence(sourceSequence);
                    sequenceBuilder.Sequence = null;
                }
            }

            context.PopFrame();
            return(this.next);
        }
 internal override Opcode Eval(ProcessingContext context)
 {
     StackFrame topSequenceArg = context.TopSequenceArg;
     StackFrame topArg = context.TopArg;
     NodeSequenceBuilder builder = new NodeSequenceBuilder(context);
     Value[] sequences = context.Sequences;
     int basePtr = topSequenceArg.basePtr;
     int index = topArg.basePtr;
     while (basePtr <= topSequenceArg.endPtr)
     {
         NodeSequence sequence = sequences[basePtr].Sequence;
         if (sequence.Count > 0)
         {
             NodesetIterator iterator = new NodesetIterator(sequence);
             while (iterator.NextNodeset())
             {
                 builder.StartNodeset();
                 while (iterator.NextItem())
                 {
                     if (context.Values[index].Boolean)
                     {
                         builder.Add(ref sequence.Items[iterator.Index]);
                     }
                     index++;
                 }
                 builder.EndNodeset();
             }
             context.ReplaceSequenceAt(basePtr, builder.Sequence);
             context.ReleaseSequence(sequence);
             builder.Sequence = null;
         }
         basePtr++;
     }
     context.PopFrame();
     return base.next;
 }
Пример #12
0
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame sequences = context.TopSequenceArg;
            StackFrame results = context.TopArg;
            NodeSequenceBuilder sequenceBuilder = new NodeSequenceBuilder(context);
            Value[] sequenceBuffer = context.Sequences;

            for (int seqIndex = sequences.basePtr, resultIndex = results.basePtr; seqIndex <= sequences.endPtr; ++seqIndex)
            {
                NodeSequence sourceSequence = sequenceBuffer[seqIndex].Sequence;
                if (sourceSequence.Count > 0)
                {
                    NodesetIterator nodesetIterator = new NodesetIterator(sourceSequence);
                    while (nodesetIterator.NextNodeset())
                    {
                        sequenceBuilder.StartNodeset();
                        while (nodesetIterator.NextItem())
                        {
                            Fx.Assert(context.Values[resultIndex].IsType(ValueDataType.Boolean), "");
                            if (context.Values[resultIndex].Boolean)
                            {
                                sequenceBuilder.Add(ref sourceSequence.Items[nodesetIterator.Index]);
                            }
                            ++resultIndex;
                        }
                        sequenceBuilder.EndNodeset();
                    }
                    context.ReplaceSequenceAt(seqIndex, sequenceBuilder.Sequence);
                    context.ReleaseSequence(sourceSequence);
                    sequenceBuilder.Sequence = null;
                }
            }

            context.PopFrame();
            return this.next;
        }
Пример #13
0
 internal void Update(ProcessingContext context, NodeSequence val)
 {
     if (ValueDataType.Sequence == this.type)
     {
         context.ReleaseSequence(this.sequence);
     }
     this.Sequence = val;
 }
Пример #14
0
        internal void ReleaseSequence(ProcessingContext context)
        {
            Fx.Assert(null != context && this.type == ValueDataType.Sequence && null != this.sequence, "");

            context.ReleaseSequence(this.sequence);
            this.sequence = null;
        }
Пример #15
0
        internal override void EvalSpecial(ProcessingContext context)
        {
            int marker = context.Processor.CounterMarker;

            if (!context.LoadVariable(this.var))
            {
                XPathMessageContext.HeaderFun.InvokeInternal(context, 0);
                context.SaveVariable(this.var, context.Processor.ElapsedCount(marker));
            }

            // WS, Microsoft, see if we can put this array in the processor to save
            //             an allocation.  Perhaps we can use the variables slot we're going to fill
            NodeSequence[] childSequences = new NodeSequence[this.children.Count];
            NodeSequence   seq            = context.Sequences[context.TopSequenceArg.basePtr].Sequence;

            for (int i = 0; i < this.children.Count; ++i)
            {
                childSequences[i] = context.CreateSequence();
                childSequences[i].StartNodeset();
            }

            // Perform the index
            SeekableXPathNavigator nav = seq[0].GetNavigator();

            if (nav.MoveToFirstChild())
            {
                do
                {
                    if (nav.NodeType == XPathNodeType.Element)
                    {
                        List <SubExpr> lst;
                        string         name = nav.LocalName;
                        string         ns   = nav.NamespaceURI;
                        Dictionary <string, List <SubExpr> > nextLookup;
                        if (this.nameLookup.TryGetValue(ns, out nextLookup))
                        {
                            if (nextLookup.TryGetValue(name, out lst))
                            {
                                for (int i = 0; i < lst.Count; ++i)
                                {
                                    childSequences[this.indexLookup[lst[i]].i].Add(nav);
                                }
                            }

                            if (nextLookup.TryGetValue(QueryDataModel.Wildcard, out lst))
                            {
                                for (int i = 0; i < lst.Count; ++i)
                                {
                                    childSequences[this.indexLookup[lst[i]].i].Add(nav);
                                }
                            }
                        }

                        if (this.nameLookup.TryGetValue(QueryDataModel.Wildcard, out nextLookup))
                        {
                            if (nextLookup.TryGetValue(QueryDataModel.Wildcard, out lst))
                            {
                                for (int i = 0; i < lst.Count; ++i)
                                {
                                    childSequences[this.indexLookup[lst[i]].i].Add(nav);
                                }
                            }
                        }
                    }
                } while (nav.MoveToNext());
            }

            int secondMarker = context.Processor.CounterMarker;

            for (int i = 0; i < this.children.Count; ++i)
            {
                if (this.children[i].useSpecial)
                {
                    childSequences[i].StopNodeset();
                    context.Processor.CounterMarker = secondMarker;
                    context.PushSequenceFrame();
                    context.PushSequence(childSequences[i]);
                    Opcode op = this.children[i].FirstOp.Next;
                    while (op != null)
                    {
                        op = op.Eval(context);
                    }
                    context.SaveVariable(this.children[i].var, context.Processor.ElapsedCount(marker));
                    context.PopSequenceFrame();
                }
                else
                {
                    context.ReleaseSequence(childSequences[i]);
                    //context.SetVariable(this.children[i].Variable, null, 0);
                }
            }

            context.Processor.CounterMarker = marker;
        }
 internal void ReleaseSequence(ProcessingContext context)
 {
     context.ReleaseSequence(this.sequence);
     this.sequence = null;
 }
 internal override void EvalSpecial(ProcessingContext context)
 {
     int counterMarker = context.Processor.CounterMarker;
     if (!context.LoadVariable(base.var))
     {
         XPathMessageContext.HeaderFun.InvokeInternal(context, 0);
         context.SaveVariable(base.var, context.Processor.ElapsedCount(counterMarker));
     }
     NodeSequence[] sequenceArray = new NodeSequence[base.children.Count];
     NodeSequence sequence = context.Sequences[context.TopSequenceArg.basePtr].Sequence;
     for (int i = 0; i < base.children.Count; i++)
     {
         sequenceArray[i] = context.CreateSequence();
         sequenceArray[i].StartNodeset();
     }
     SeekableXPathNavigator node = sequence[0].GetNavigator();
     if (node.MoveToFirstChild())
     {
         do
         {
             if (node.NodeType == XPathNodeType.Element)
             {
                 List<SubExpr> list;
                 Dictionary<string, List<SubExpr>> dictionary;
                 string localName = node.LocalName;
                 string namespaceURI = node.NamespaceURI;
                 if (this.nameLookup.TryGetValue(namespaceURI, out dictionary))
                 {
                     if (dictionary.TryGetValue(localName, out list))
                     {
                         for (int k = 0; k < list.Count; k++)
                         {
                             sequenceArray[this.indexLookup[list[k]].i].Add(node);
                         }
                     }
                     if (dictionary.TryGetValue(QueryDataModel.Wildcard, out list))
                     {
                         for (int m = 0; m < list.Count; m++)
                         {
                             sequenceArray[this.indexLookup[list[m]].i].Add(node);
                         }
                     }
                 }
                 if (this.nameLookup.TryGetValue(QueryDataModel.Wildcard, out dictionary) && dictionary.TryGetValue(QueryDataModel.Wildcard, out list))
                 {
                     for (int n = 0; n < list.Count; n++)
                     {
                         sequenceArray[this.indexLookup[list[n]].i].Add(node);
                     }
                 }
             }
         }
         while (node.MoveToNext());
     }
     int num6 = context.Processor.CounterMarker;
     for (int j = 0; j < base.children.Count; j++)
     {
         if (base.children[j].useSpecial)
         {
             sequenceArray[j].StopNodeset();
             context.Processor.CounterMarker = num6;
             context.PushSequenceFrame();
             context.PushSequence(sequenceArray[j]);
             for (Opcode opcode = base.children[j].FirstOp.Next; opcode != null; opcode = opcode.Eval(context))
             {
             }
             context.SaveVariable(base.children[j].var, context.Processor.ElapsedCount(counterMarker));
             context.PopSequenceFrame();
         }
         else
         {
             context.ReleaseSequence(sequenceArray[j]);
         }
     }
     context.Processor.CounterMarker = counterMarker;
 }
Пример #18
0
 internal void ReleaseSequence(ProcessingContext context)
 {
     context.ReleaseSequence(this.sequence);
     this.sequence = null;
 }
Пример #19
0
        internal override Opcode Eval(ProcessingContext context)
        {
            // The query processor object also serves as the query document root
            int iterationCount = context.IterationCount;
            Opcode returnOpcode = this.next;

            // A root is always an initial step
            context.PushSequenceFrame();
            NodeSequence seq = context.CreateSequence();
            if (this.next != null && 0 != (this.next.Flags & OpcodeFlags.CompressableSelect))
            {
                SeekableXPathNavigator node = context.Processor.ContextNode;
                node.MoveToRoot();
                returnOpcode = this.next.Eval(seq, node);
                while (returnOpcode != null && 0 != (returnOpcode.Flags & OpcodeFlags.CompressableSelect))
                {
                    returnOpcode = returnOpcode.Next;
                }
            }
            else
            {
                // Roots do not have any qnames..
                seq.StartNodeset();
                SeekableXPathNavigator node = context.Processor.ContextNode;
                node.MoveToRoot();
                seq.Add(node);
                seq.StopNodeset();
            }

            if (seq.Count == 0)
            {
                context.ReleaseSequence(seq);
                seq = NodeSequence.Empty;
            }

            for (int i = 0; i < iterationCount; ++i)
            {
                context.PushSequence(seq);
            }
            if (iterationCount > 1)
                seq.refCount += iterationCount - 1;

            return returnOpcode;
        }
Пример #20
0
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame topFrame = context.TopSequenceArg;
            SeekableXPathNavigator node = null;
            Value[] sequences = context.Sequences;

            for (int i = topFrame.basePtr; i <= topFrame.endPtr; ++i)
            {
                // Each NodeSequence will generate a new one, but only if the source FilterSequence isn't empty
                // If the source FilterSequence is empty, release it and replace it with an empty sequence
                NodeSequence sourceSeq = sequences[i].Sequence;
                int sourceSeqCount = sourceSeq.Count;
                if (sourceSeqCount == 0)
                {
                    context.ReplaceSequenceAt(i, NodeSequence.Empty);
                    context.ReleaseSequence(sourceSeq);
                }
                else
                {
                    NodeSequenceItem[] items = sourceSeq.Items;
                    if (sourceSeq.CanReuse(context))
                    {
                        node = items[0].GetNavigator();
                        sourceSeq.Clear();
                        sourceSeq.StartNodeset();

                        this.criteria.Select(node, sourceSeq);

                        sourceSeq.StopNodeset();
                    }
                    else
                    {
                        NodeSequence newSeq = null;
                        for (int item = 0; item < sourceSeqCount; ++item)
                        {
                            node = items[item].GetNavigator();
                            Fx.Assert(null != node, "");
                            if (null == newSeq)
                            {
                                newSeq = context.CreateSequence();
                            }
                            newSeq.StartNodeset();
                            this.criteria.Select(node, newSeq);
                            newSeq.StopNodeset();
                        }
                        context.ReplaceSequenceAt(i, (null != newSeq) ? newSeq : NodeSequence.Empty);
                        context.ReleaseSequence(sourceSeq);
                    }
                }
            }

            return this.next;
        }
        internal override void EvalSpecial(ProcessingContext context)
        {
            int marker = context.Processor.CounterMarker;

            if (!context.LoadVariable(this.var))
            {
                XPathMessageContext.HeaderFun.InvokeInternal(context, 0);
                context.SaveVariable(this.var, context.Processor.ElapsedCount(marker));
            }

            // WS, [....], see if we can put this array in the processor to save
            //             an allocation.  Perhaps we can use the variables slot we're going to fill
            NodeSequence[] childSequences = new NodeSequence[this.children.Count];
            NodeSequence seq = context.Sequences[context.TopSequenceArg.basePtr].Sequence;
            for (int i = 0; i < this.children.Count; ++i)
            {
                childSequences[i] = context.CreateSequence();
                childSequences[i].StartNodeset();
            }

            // Perform the index
            SeekableXPathNavigator nav = seq[0].GetNavigator();
            if (nav.MoveToFirstChild())
            {
                do
                {
                    if (nav.NodeType == XPathNodeType.Element)
                    {
                        List<SubExpr> lst;
                        string name = nav.LocalName;
                        string ns = nav.NamespaceURI;
                        Dictionary<string, List<SubExpr>> nextLookup;
                        if (this.nameLookup.TryGetValue(ns, out nextLookup))
                        {
                            if (nextLookup.TryGetValue(name, out lst))
                            {
                                for (int i = 0; i < lst.Count; ++i)
                                {
                                    childSequences[this.indexLookup[lst[i]].i].Add(nav);
                                }
                            }

                            if (nextLookup.TryGetValue(QueryDataModel.Wildcard, out lst))
                            {
                                for (int i = 0; i < lst.Count; ++i)
                                {
                                    childSequences[this.indexLookup[lst[i]].i].Add(nav);
                                }
                            }
                        }

                        if (this.nameLookup.TryGetValue(QueryDataModel.Wildcard, out nextLookup))
                        {
                            if (nextLookup.TryGetValue(QueryDataModel.Wildcard, out lst))
                            {
                                for (int i = 0; i < lst.Count; ++i)
                                {
                                    childSequences[this.indexLookup[lst[i]].i].Add(nav);
                                }
                            }
                        }
                    }
                } while (nav.MoveToNext());
            }

            int secondMarker = context.Processor.CounterMarker;
            for (int i = 0; i < this.children.Count; ++i)
            {
                if (this.children[i].useSpecial)
                {
                    childSequences[i].StopNodeset();
                    context.Processor.CounterMarker = secondMarker;
                    context.PushSequenceFrame();
                    context.PushSequence(childSequences[i]);
                    Opcode op = this.children[i].FirstOp.Next;
                    while (op != null)
                    {
                        op = op.Eval(context);
                    }
                    context.SaveVariable(this.children[i].var, context.Processor.ElapsedCount(marker));
                    context.PopSequenceFrame();
                }
                else
                {
                    context.ReleaseSequence(childSequences[i]);
                    //context.SetVariable(this.children[i].Variable, null, 0);
                }
            }

            context.Processor.CounterMarker = marker;
        }
Пример #22
0
        internal override void EvalSpecial(ProcessingContext context)
        {
            int counterMarker = context.Processor.CounterMarker;

            if (!context.LoadVariable(base.var))
            {
                XPathMessageContext.HeaderFun.InvokeInternal(context, 0);
                context.SaveVariable(base.var, context.Processor.ElapsedCount(counterMarker));
            }
            NodeSequence[] sequenceArray = new NodeSequence[base.children.Count];
            NodeSequence   sequence      = context.Sequences[context.TopSequenceArg.basePtr].Sequence;

            for (int i = 0; i < base.children.Count; i++)
            {
                sequenceArray[i] = context.CreateSequence();
                sequenceArray[i].StartNodeset();
            }
            SeekableXPathNavigator node = sequence[0].GetNavigator();

            if (node.MoveToFirstChild())
            {
                do
                {
                    if (node.NodeType == XPathNodeType.Element)
                    {
                        List <SubExpr> list;
                        Dictionary <string, List <SubExpr> > dictionary;
                        string localName    = node.LocalName;
                        string namespaceURI = node.NamespaceURI;
                        if (this.nameLookup.TryGetValue(namespaceURI, out dictionary))
                        {
                            if (dictionary.TryGetValue(localName, out list))
                            {
                                for (int k = 0; k < list.Count; k++)
                                {
                                    sequenceArray[this.indexLookup[list[k]].i].Add(node);
                                }
                            }
                            if (dictionary.TryGetValue(QueryDataModel.Wildcard, out list))
                            {
                                for (int m = 0; m < list.Count; m++)
                                {
                                    sequenceArray[this.indexLookup[list[m]].i].Add(node);
                                }
                            }
                        }
                        if (this.nameLookup.TryGetValue(QueryDataModel.Wildcard, out dictionary) && dictionary.TryGetValue(QueryDataModel.Wildcard, out list))
                        {
                            for (int n = 0; n < list.Count; n++)
                            {
                                sequenceArray[this.indexLookup[list[n]].i].Add(node);
                            }
                        }
                    }
                }while (node.MoveToNext());
            }
            int num6 = context.Processor.CounterMarker;

            for (int j = 0; j < base.children.Count; j++)
            {
                if (base.children[j].useSpecial)
                {
                    sequenceArray[j].StopNodeset();
                    context.Processor.CounterMarker = num6;
                    context.PushSequenceFrame();
                    context.PushSequence(sequenceArray[j]);
                    for (Opcode opcode = base.children[j].FirstOp.Next; opcode != null; opcode = opcode.Eval(context))
                    {
                    }
                    context.SaveVariable(base.children[j].var, context.Processor.ElapsedCount(counterMarker));
                    context.PopSequenceFrame();
                }
                else
                {
                    context.ReleaseSequence(sequenceArray[j]);
                }
            }
            context.Processor.CounterMarker = counterMarker;
        }