示例#1
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);
        }
示例#2
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);
        }