Exemplo n.º 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);
        }
Exemplo n.º 2
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;
 }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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;
 }
Exemplo n.º 7
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;
        }
Exemplo n.º 8
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;
        }