Esempio n. 1
0
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame sequences = context.TopSequenceArg;

            Value[]    values     = context.Values;
            StackFrame resultMask = context.TopArg;

            Value[] sequenceBuffer = context.Sequences;

            context.PushSequenceFrame();
            for (int seqIndex = sequences.basePtr; seqIndex <= sequences.endPtr; ++seqIndex)
            {
                NodeSequence sourceSeq = sequenceBuffer[seqIndex].Sequence;
                if (sourceSeq.Count > 0)
                {
                    NodeSequenceItem[] items  = sourceSeq.Items;
                    NodeSequence       newSeq = null;
                    // Loop over the sequence, selecting those items for which the previous expression returned a result that
                    // matches the test value. Only those items will be processed further
                    // Note that the original position and size information is retained.
                    for (int i = resultMask.basePtr, n = 0; i <= resultMask.endPtr; ++i, ++n)
                    {
                        if (this.test == values[i].Boolean)
                        {
                            if (null == newSeq)
                            {
                                newSeq = context.CreateSequence();
                            }
                            newSeq.AddCopy(ref items[n], NodeSequence.GetContextSize(sourceSeq, n));
                        }
                        else
                        {
                            if (items[n].Last && null != newSeq)
                            {
                                newSeq.Items[newSeq.Count - 1].Last = true; // maintain nodeset boundaries...
                            }
                        }
                    }
                    context.PushSequence((null == newSeq) ? NodeSequence.Empty : newSeq);
                    newSeq = null;
                }
            }

            return(this.next);
        }
        internal override Opcode Eval(ProcessingContext context)
        {
            Value[]    values = context.Values;
            StackFrame topArg = context.TopArg;

            for (int i = topArg.basePtr; i <= topArg.endPtr; i++)
            {
                NodeSequence sequence = values[i].Sequence;
                NodeSequence val      = context.CreateSequence();
                for (int j = 0; j < sequence.Count; j++)
                {
                    NodeSequenceItem item = sequence[j];
                    val.AddCopy(ref item);
                }
                val.Merge();
                context.SetValue(context, i, val);
            }
            return(base.next);
        }
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame topSequenceArg = context.TopSequenceArg;

            Value[]    values = context.Values;
            StackFrame topArg = context.TopArg;

            Value[] sequences = context.Sequences;
            context.PushSequenceFrame();
            for (int i = topSequenceArg.basePtr; i <= topSequenceArg.endPtr; i++)
            {
                NodeSequence sequence = sequences[i].Sequence;
                if (sequence.Count > 0)
                {
                    NodeSequenceItem[] items     = sequence.Items;
                    NodeSequence       sequence2 = null;
                    int basePtr = topArg.basePtr;
                    for (int j = 0; basePtr <= topArg.endPtr; j++)
                    {
                        if (this.test == values[basePtr].Boolean)
                        {
                            if (sequence2 == null)
                            {
                                sequence2 = context.CreateSequence();
                            }
                            sequence2.AddCopy(ref items[j], NodeSequence.GetContextSize(sequence, j));
                        }
                        else if (items[j].Last && (sequence2 != null))
                        {
                            sequence2.Items[sequence2.Count - 1].Last = true;
                        }
                        basePtr++;
                    }
                    context.PushSequence((sequence2 == null) ? NodeSequence.Empty : sequence2);
                    sequence2 = null;
                }
            }
            return(base.next);
        }
Esempio n. 4
0
        internal override Opcode Eval(ProcessingContext context)
        {
            Value[]    values = context.Values;
            StackFrame arg    = context.TopArg;

            for (int i = arg.basePtr; i <= arg.endPtr; ++i)
            {
                Fx.Assert(ValueDataType.Sequence == values[i].Type, "");
                NodeSequence seq = values[i].Sequence;

                NodeSequence newSeq = context.CreateSequence();
                for (int j = 0; j < seq.Count; ++j)
                {
                    NodeSequenceItem item = seq[j];
                    newSeq.AddCopy(ref item);
                }
                newSeq.Merge();

                context.SetValue(context, i, newSeq);
            }

            return(this.next);
        }