internal override Opcode Eval(ProcessingContext context)
 {
     QueryProcessor processor = context.Processor;
     SeekableXPathNavigator contextNode = processor.ContextNode;
     int counterMarker = processor.CounterMarker;
     long currentPosition = contextNode.CurrentPosition;
     int num3 = 0;
     int count = this.branches.Count;
     try
     {
         Opcode opcode;
         if (context.StacksInUse)
         {
             if (--count > 0)
             {
                 BranchContext context2 = new BranchContext(context);
                 while (num3 < count)
                 {
                     opcode = this.branches[num3];
                     if ((opcode.Flags & OpcodeFlags.Fx) != OpcodeFlags.None)
                     {
                         opcode.Eval(context);
                     }
                     else
                     {
                         ProcessingContext context3 = context2.Create();
                         while (opcode != null)
                         {
                             opcode = opcode.Eval(context3);
                         }
                     }
                     contextNode.CurrentPosition = currentPosition;
                     processor.CounterMarker = counterMarker;
                     num3++;
                 }
                 context2.Release();
             }
             opcode = this.branches[num3];
             while (opcode != null)
             {
                 opcode = opcode.Eval(context);
             }
         }
         else
         {
             int nodeCount = context.NodeCount;
             while (num3 < count)
             {
                 for (opcode = this.branches[num3]; opcode != null; opcode = opcode.Eval(context))
                 {
                 }
                 context.ClearContext();
                 context.NodeCount = nodeCount;
                 contextNode.CurrentPosition = currentPosition;
                 processor.CounterMarker = counterMarker;
                 num3++;
             }
         }
     }
     catch (XPathNavigatorException exception)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception.Process(this.branches[num3]));
     }
     catch (NavigatorInvalidBodyAccessException exception2)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception2.Process(this.branches[num3]));
     }
     processor.CounterMarker = counterMarker;
     return base.next;
 }
Esempio n. 2
0
        internal override Opcode Eval(ProcessingContext context)
        {
            QueryProcessor         processor   = context.Processor;
            SeekableXPathNavigator contextNode = processor.ContextNode;
            int  counterMarker   = processor.CounterMarker;
            long currentPosition = contextNode.CurrentPosition;
            int  num3            = 0;
            int  count           = this.branches.Count;

            try
            {
                Opcode opcode;
                if (context.StacksInUse)
                {
                    if (--count > 0)
                    {
                        BranchContext context2 = new BranchContext(context);
                        while (num3 < count)
                        {
                            opcode = this.branches[num3];
                            if ((opcode.Flags & OpcodeFlags.Fx) != OpcodeFlags.None)
                            {
                                opcode.Eval(context);
                            }
                            else
                            {
                                ProcessingContext context3 = context2.Create();
                                while (opcode != null)
                                {
                                    opcode = opcode.Eval(context3);
                                }
                            }
                            contextNode.CurrentPosition = currentPosition;
                            processor.CounterMarker     = counterMarker;
                            num3++;
                        }
                        context2.Release();
                    }
                    opcode = this.branches[num3];
                    while (opcode != null)
                    {
                        opcode = opcode.Eval(context);
                    }
                }
                else
                {
                    int nodeCount = context.NodeCount;
                    while (num3 < count)
                    {
                        for (opcode = this.branches[num3]; opcode != null; opcode = opcode.Eval(context))
                        {
                        }
                        context.ClearContext();
                        context.NodeCount           = nodeCount;
                        contextNode.CurrentPosition = currentPosition;
                        processor.CounterMarker     = counterMarker;
                        num3++;
                    }
                }
            }
            catch (XPathNavigatorException exception)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception.Process(this.branches[num3]));
            }
            catch (NavigatorInvalidBodyAccessException exception2)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception2.Process(this.branches[num3]));
            }
            processor.CounterMarker = counterMarker;
            return(base.next);
        }
Esempio n. 3
0
        internal override Opcode Eval(ProcessingContext context)
        {
            QueryProcessor         processor   = context.Processor;
            SeekableXPathNavigator contextNode = processor.ContextNode;
            int    marker = processor.CounterMarker;
            long   pos    = contextNode.CurrentPosition;
            Opcode branch;
            int    i           = 0;
            int    branchCount = this.branches.Count;

            try
            {
                if (context.StacksInUse)
                {
                    // If we have N branches, eval N-1 in a cloned context and the remainder in the
                    // original one
                    if (--branchCount > 0)
                    {
                        // Evaluate all but the first branch with a clone of the current context
                        // The first branch (right most) can be evaluated with the current context
                        BranchContext branchContext = new BranchContext(context); // struct. fast
                        for (; i < branchCount; ++i)
                        {
                            branch = this.branches[i];
                            if (0 != (branch.Flags & OpcodeFlags.Fx))
                            {
                                branch.Eval(context);
                            }
                            else
                            {
                                // This allocates a solitary context and then reuses it repeatedly
                                ProcessingContext newContext = branchContext.Create();
                                while (null != branch)
                                {
                                    branch = branch.Eval(newContext);
                                }
                            }
                            contextNode.CurrentPosition = pos;    // restore the navigator to its original position
                            processor.CounterMarker     = marker; // and the node count marker
                        }
                        branchContext.Release();
                    }

                    // Do the final branch with the existing context
                    branch = branches[i];
                    while (null != branch)
                    {
                        branch = branch.Eval(context);
                    }
                }
                else // since there is nothing on the stack, there is nothing to clone
                {
                    int nodeCountSav = context.NodeCount;
                    for (; i < branchCount; ++i)
                    {
                        branch = branches[i];
                        // Evaluate this branch
                        while (null != branch)
                        {
                            branch = branch.Eval(context);
                        }
                        // Restore the current context to its pristine state, so we can reuse it
                        context.ClearContext();
                        context.NodeCount           = nodeCountSav;
                        contextNode.CurrentPosition = pos;
                        processor.CounterMarker     = marker;
                    }
                }
            }
            catch (XPathNavigatorException e)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(e.Process(branches[i]));
            }
            catch (NavigatorInvalidBodyAccessException e)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(e.Process(branches[i]));
            }
            processor.CounterMarker = marker;

            return(this.next);
        }