Exemplo 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);
        }
Exemplo n.º 2
0
        internal void TransferSequenceSizeTo(ref EvalStack stack)
        {
            StackFrame topArg = this.TopArg;

            stack.PushFrame();
            for (int i = topArg.basePtr; i <= topArg.endPtr; i++)
            {
                NodeSequence sequence = this.buffer.buffer[i].Sequence;
                int          count    = sequence.Count;
                if ((this.stack.stackPtr + count) > this.stack.bounds.end)
                {
                    this.GrowStack(count);
                }
                for (int j = 0; j < count; j++)
                {
                    stack.Push((double)NodeSequence.GetContextSize(sequence, j));
                }
            }
        }
Exemplo n.º 3
0
        internal void TransferSequenceSizeTo(ref EvalStack stack)
        {
            StackFrame arg = this.TopArg;

            stack.PushFrame();
            for (int i = arg.basePtr; i <= arg.endPtr; ++i)
            {
                NodeSequence seq       = this.buffer.buffer[i].Sequence;
                int          nodeCount = seq.Count;

                if ((this.stack.stackPtr + nodeCount) > this.stack.bounds.end)
                {
                    this.GrowStack(nodeCount);
                }

                for (int n = 0; n < nodeCount; ++n)
                {
                    stack.Push((double)NodeSequence.GetContextSize(seq, n));
                }
            }
        }
        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);
        }