Exemple #1
0
        internal override void InvokeInternal(ProcessingContext context, int argCount)
        {
            int iterationCount = context.IterationCount;

            context.PushSequenceFrame();
            if (iterationCount > 0)
            {
                NodeSequence seq = context.CreateSequence();
                seq.StartNodeset();
                SeekableXPathNavigator contextNode = context.Processor.ContextNode;
                long currentPosition = contextNode.CurrentPosition;
                if (XPathMessageFunction.MoveToAddressingHeader(contextNode, "ReplyTo"))
                {
                    seq.Add(contextNode);
                }
                seq.StopNodeset();
                context.PushSequence(seq);
                for (int i = 1; i < iterationCount; i++)
                {
                    seq.refCount++;
                    context.PushSequence(seq);
                }
                contextNode.CurrentPosition = currentPosition;
            }
        }
Exemple #2
0
        internal static void IterateAndPushSequences(ProcessingContext context)
        {
            StackFrame topSequenceArg = context.TopSequenceArg;

            Value[] sequences = context.Sequences;
            context.PushFrame();
            while (topSequenceArg.basePtr <= topSequenceArg.endPtr)
            {
                NodeSequence sequence = sequences[topSequenceArg.basePtr++].Sequence;
                if (sequence.Count == 0)
                {
                    context.PushSequence(NodeSequence.Empty);
                }
                else
                {
                    for (int i = 0; i < sequence.Count; i++)
                    {
                        NodeSequence sequence2 = context.CreateSequence();
                        sequence2.StartNodeset();
                        sequence2.Add(ref sequence.Items[i]);
                        sequence2.StopNodeset();
                        context.Push(sequence2);
                    }
                }
            }
        }
        internal static void IterateAndPushSequences(ProcessingContext context)
        {
            StackFrame sequences = context.TopSequenceArg;

            Value[] sequenceBuffer = context.Sequences;

            context.PushFrame();
            while (sequences.basePtr <= sequences.endPtr)
            {
                NodeSequence sourceSeq = sequenceBuffer[sequences.basePtr++].Sequence;
                int          count     = sourceSeq.Count;
                if (count == 0)
                {
                    context.PushSequence(NodeSequence.Empty);
                }
                else
                {
                    for (int item = 0; item < sourceSeq.Count; ++item)
                    {
                        NodeSequence newSequence = context.CreateSequence();
                        newSequence.StartNodeset();
                        newSequence.Add(ref sourceSeq.Items[item]);
                        newSequence.StopNodeset();
                        context.Push(newSequence);
                    }
                }
            }
        }
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame topSequenceArg = context.TopSequenceArg;

            Value[] sequences          = context.Sequences;
            bool    sequenceStackInUse = context.SequenceStackInUse;

            context.PushSequenceFrame();
            for (int i = topSequenceArg.basePtr; i <= topSequenceArg.endPtr; i++)
            {
                NodeSequence sequence = sequences[i].Sequence;
                if (sequence.Count == 0)
                {
                    if (!sequenceStackInUse)
                    {
                        context.PushSequence(NodeSequence.Empty);
                    }
                }
                else
                {
                    NodeSequenceItem[] items = sequence.Items;
                    for (int j = 0; j < sequence.Count; j++)
                    {
                        SeekableXPathNavigator contextNode  = items[j].GetNavigator();
                        NodeSequence           destSequence = context.CreateSequence();
                        destSequence.StartNodeset();
                        base.criteria.Select(contextNode, destSequence);
                        destSequence.StopNodeset();
                        context.PushSequence(destSequence);
                    }
                }
            }
            return(base.next);
        }
Exemple #5
0
 internal override Opcode Eval(NodeSequence sequence, SeekableXPathNavigator node)
 {
     if ((base.next != null) && ((base.next.Flags & OpcodeFlags.CompressableSelect) != OpcodeFlags.None))
     {
         return(this.criteria.Select(node, sequence, (SelectOpcode)base.next));
     }
     sequence.StartNodeset();
     this.criteria.Select(node, sequence);
     sequence.StopNodeset();
     return(base.next);
 }
        internal override Opcode Eval(ProcessingContext context)
        {
            context.PushContextSequenceFrame();
            NodeSequence seq = context.CreateSequence();

            seq.StartNodeset();
            seq.Add(context.Processor.ContextNode);
            seq.StopNodeset();
            context.PushSequence(seq);
            return(base.next);
        }
Exemple #7
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);
        }
Exemple #8
0
        internal override Opcode Eval(NodeSequence sequence, SeekableXPathNavigator node)
        {
            if (this.next == null || 0 == (this.next.Flags & OpcodeFlags.CompressableSelect))
            {
                // The next opcode is not a compressible select. Complete the select operation and return the next opcode
                sequence.StartNodeset();
                this.criteria.Select(node, sequence);
                sequence.StopNodeset();
                return(this.next);
            }

            return(this.criteria.Select(node, sequence, (SelectOpcode)this.next));
        }
Exemple #9
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);
        }
Exemple #10
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);
        }
Exemple #11
0
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame topFrame = context.TopSequenceArg;

            Value[] sequences = context.Sequences;

            bool wasInUse = context.SequenceStackInUse;

            context.PushSequenceFrame();
            for (int i = topFrame.basePtr; i <= topFrame.endPtr; ++i)
            {
                NodeSequence sourceSeq = sequences[i].Sequence;
                int          count     = sourceSeq.Count;
                if (count == 0)
                {
                    // Empty sequence.
                    // Since there are no nodes in the sequence, we will track this sequence also
                    // using an empty sequence
                    if (!wasInUse)
                    {
                        context.PushSequence(NodeSequence.Empty);
                    }
                }
                else
                {
                    NodeSequenceItem[] items = sourceSeq.Items;
                    for (int item = 0; item < sourceSeq.Count; ++item)
                    {
                        SeekableXPathNavigator node = items[item].GetNavigator();
                        Fx.Assert(null != node, "");

                        NodeSequence newSeq = context.CreateSequence();
                        newSeq.StartNodeset();

                        this.criteria.Select(node, newSeq);

                        newSeq.StopNodeset();

                        context.PushSequence(newSeq);
                    }
                }
            }
            return(this.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);
        }
        internal override Opcode Eval(NodeSequence sequence, SeekableXPathNavigator node)
        {
            if (this.next == null || 0 == (this.next.Flags & OpcodeFlags.CompressableSelect))
            {
                // The next opcode is not a compressible select. Complete the select operation and return the next opcode
                sequence.StartNodeset();
                this.criteria.Select(node, sequence);
                sequence.StopNodeset();
                return this.next;
            }

            return this.criteria.Select(node, sequence, (SelectOpcode)this.next);
        }
 internal override Opcode Eval(NodeSequence sequence, SeekableXPathNavigator node)
 {
     if ((base.next != null) && ((base.next.Flags & OpcodeFlags.CompressableSelect) != OpcodeFlags.None))
     {
         return this.criteria.Select(node, sequence, (SelectOpcode) base.next);
     }
     sequence.StartNodeset();
     this.criteria.Select(node, sequence);
     sequence.StopNodeset();
     return base.next;
 }