internal override void InvokeInternal(ProcessingContext context, int argCount)
 {
     context.PushFrame();
     int iterationCount = context.IterationCount;
     if (iterationCount > 0)
     {
         string soapUri = context.Processor.SoapUri;
         if (soapUri == null)
         {
             Message contextMessage = context.Processor.ContextMessage;
             if (contextMessage == null)
             {
                 SeekableXPathNavigator contextNode = context.Processor.ContextNode;
                 long currentPosition = contextNode.CurrentPosition;
                 soapUri = ExtractFromNavigator(contextNode);
                 contextNode.CurrentPosition = currentPosition;
             }
             else
             {
                 soapUri = contextMessage.Version.Envelope.Namespace;
             }
             context.Processor.SoapUri = soapUri;
         }
         context.Push(soapUri, iterationCount);
     }
 }
 internal override Opcode Eval(ProcessingContext context)
 {
     StackFrame topArg = context.TopArg;
     bool flag = false;
     if (1 == topArg.Count)
     {
         flag = context.Values[topArg.basePtr].ToBoolean();
     }
     else
     {
         context.Processor.Result = false;
         for (int i = topArg.basePtr; i <= topArg.endPtr; i++)
         {
             if (context.Values[i].ToBoolean())
             {
                 flag = true;
                 break;
             }
         }
     }
     if (flag)
     {
         ICollection<MessageFilter> matchSet = context.Processor.MatchSet;
         int num2 = 0;
         int count = this.results.Count;
         while (num2 < count)
         {
             matchSet.Add((MessageFilter) this.results[num2]);
             num2++;
         }
     }
     context.PopFrame();
     return base.next;
 }
 internal override void InvokeInternal(ProcessingContext context, int argCount)
 {
     StackFrame topArg = context.TopArg;
     SeekableXPathNavigator contextNode = context.Processor.ContextNode;
     long currentPosition = contextNode.CurrentPosition;
     while (topArg.basePtr <= topArg.endPtr)
     {
         string str = context.PeekString(topArg.basePtr);
         NodeSequence val = context.CreateSequence();
         if (XPathMessageFunction.MoveToHeader(contextNode) && contextNode.MoveToFirstChild())
         {
             do
             {
                 long num2 = contextNode.CurrentPosition;
                 string str2 = XPathMessageFunctionActor.ExtractFromNavigator(contextNode);
                 contextNode.CurrentPosition = num2;
                 if (str2 == str)
                 {
                     val.Add(contextNode);
                 }
             }
             while (contextNode.MoveToNext());
         }
         context.SetValue(context, topArg.basePtr, val);
         topArg.basePtr++;
     }
     contextNode.CurrentPosition = currentPosition;
 }
 internal override void InvokeInternal(ProcessingContext context, int argCount)
 {
     context.PushFrame();
     int iterationCount = context.IterationCount;
     if (iterationCount > 0)
     {
         string messageId = context.Processor.MessageId;
         if (messageId == null)
         {
             Message contextMessage = context.Processor.ContextMessage;
             if (contextMessage == null)
             {
                 SeekableXPathNavigator contextNode = context.Processor.ContextNode;
                 long currentPosition = contextNode.CurrentPosition;
                 messageId = ExtractFromNavigator(contextNode);
                 contextNode.CurrentPosition = currentPosition;
             }
             else
             {
                 UniqueId id = contextMessage.Headers.MessageId;
                 if (id == null)
                 {
                     messageId = string.Empty;
                 }
                 else
                 {
                     messageId = id.ToString();
                 }
             }
             context.Processor.MessageId = messageId;
         }
         context.Push(messageId, iterationCount);
     }
 }
        internal override Opcode Eval(ProcessingContext context)
        {
            XPathResult result;
            StackFrame topArg = context.TopArg;
            switch (context.Values[topArg.basePtr].Type)
            {
                case ValueDataType.Boolean:
                    result = new XPathResult(context.Values[topArg.basePtr].GetBoolean());
                    break;

                case ValueDataType.Double:
                    result = new XPathResult(context.Values[topArg.basePtr].GetDouble());
                    break;

                case ValueDataType.Sequence:
                {
                    SafeNodeSequenceIterator nodeSetResult = new SafeNodeSequenceIterator(context.Values[topArg.basePtr].GetSequence(), context);
                    result = new XPathResult(nodeSetResult);
                    break;
                }
                case ValueDataType.String:
                    result = new XPathResult(context.Values[topArg.basePtr].GetString());
                    break;

                default:
                    throw Fx.AssertAndThrow("Unexpected result type.");
            }
            context.Processor.ResultSet.Add(new KeyValuePair<MessageQuery, XPathResult>((MessageQuery) this.results[0], result));
            for (int i = 1; i < this.results.Count; i++)
            {
                context.Processor.ResultSet.Add(new KeyValuePair<MessageQuery, XPathResult>((MessageQuery) this.results[i], result.Copy()));
            }
            context.PopFrame();
            return base.next;
        }
 internal override void Eval(ProcessingContext context)
 {
     StackFrame[] frameArray = new StackFrame[this.argCount];
     for (int i = 0; i < this.argCount; i++)
     {
         frameArray[i] = context[i];
     }
     StringBuilder builder = new StringBuilder();
     while (frameArray[0].basePtr <= frameArray[0].endPtr)
     {
         builder.Length = 0;
         for (int k = 0; k < this.argCount; k++)
         {
             builder.Append(context.PeekString(frameArray[k].basePtr));
         }
         context.SetValue(context, frameArray[this.argCount - 1].basePtr, builder.ToString());
         for (int m = 0; m < this.argCount; m++)
         {
             frameArray[m].basePtr++;
         }
     }
     for (int j = 0; j < (this.argCount - 1); j++)
     {
         context.PopFrame();
     }
 }
 internal override void InvokeInternal(ProcessingContext context, int argCount)
 {
     int iterationCount = context.IterationCount;
     context.PushSequenceFrame();
     if (iterationCount > 0)
     {
         NodeSequence seq = context.CreateSequence();
         seq.StartNodeset();
         SeekableXPathNavigator contextNode = context.Processor.ContextNode;
         long currentPosition = contextNode.CurrentPosition;
         if (XPathMessageFunction.MoveToAddressingHeader(contextNode, "RelatesTo"))
         {
             seq.Add(contextNode);
             while (XPathMessageFunction.MoveToAddressingHeaderSibling(contextNode, "RelatesTo"))
             {
                 seq.Add(contextNode);
             }
         }
         seq.StopNodeset();
         context.PushSequence(seq);
         for (int i = 1; i < iterationCount; i++)
         {
             seq.refCount++;
             context.PushSequence(seq);
         }
         contextNode.CurrentPosition = currentPosition;
     }
 }
 internal static void BooleanLang(ProcessingContext context)
 {
     StackFrame topArg = context.TopArg;
     StackFrame topSequenceArg = context.TopSequenceArg;
     Value[] sequences = context.Sequences;
     while (topSequenceArg.basePtr <= topSequenceArg.endPtr)
     {
         NodeSequence sequence = sequences[topSequenceArg.basePtr++].Sequence;
         for (int i = 0; i < sequence.Count; i++)
         {
             string strA = context.PeekString(topArg.basePtr).ToUpperInvariant();
             QueryNode node = sequence.Items[i].Node;
             long currentPosition = node.Node.CurrentPosition;
             node.Node.CurrentPosition = node.Position;
             string strB = node.Node.XmlLang.ToUpperInvariant();
             node.Node.CurrentPosition = currentPosition;
             if ((strA.Length == strB.Length) && (string.CompareOrdinal(strA, strB) == 0))
             {
                 context.SetValue(context, topArg.basePtr++, true);
             }
             else if (((strB.Length > 0) && (strA.Length < strB.Length)) && (strB.StartsWith(strA, StringComparison.Ordinal) && (strB[strA.Length] == '-')))
             {
                 context.SetValue(context, topArg.basePtr++, true);
             }
             else
             {
                 context.SetValue(context, topArg.basePtr++, false);
             }
         }
         topSequenceArg.basePtr++;
     }
 }
 internal override Opcode Eval(ProcessingContext context)
 {
     StackFrame topSequenceArg = context.TopSequenceArg;
     Value[] sequences = context.Sequences;
     bool sequenceStackInUse = context.SequenceStackInUse;
     context.PushSequenceFrame();
     for (int i = topSequenceArg.basePtr; i <= topSequenceArg.endPtr; i++)
     {
         NodeSequence sequence = sequences[i].Sequence;
         if (sequence.Count == 0)
         {
             if (!sequenceStackInUse)
             {
                 context.PushSequence(NodeSequence.Empty);
             }
         }
         else
         {
             NodeSequenceItem[] items = sequence.Items;
             for (int j = 0; j < sequence.Count; j++)
             {
                 SeekableXPathNavigator contextNode = items[j].GetNavigator();
                 NodeSequence destSequence = context.CreateSequence();
                 destSequence.StartNodeset();
                 base.criteria.Select(contextNode, destSequence);
                 destSequence.StopNodeset();
                 context.PushSequence(destSequence);
             }
         }
     }
     return base.next;
 }
 internal override void InvokeInternal(ProcessingContext context, int argCount)
 {
     context.PushFrame();
     int iterationCount = context.IterationCount;
     if (iterationCount > 0)
     {
         string toHeader = context.Processor.ToHeader;
         if (toHeader == null)
         {
             Message contextMessage = context.Processor.ContextMessage;
             if (contextMessage == null)
             {
                 SeekableXPathNavigator contextNode = context.Processor.ContextNode;
                 long currentPosition = contextNode.CurrentPosition;
                 toHeader = ExtractFromNavigator(contextNode);
                 contextNode.CurrentPosition = currentPosition;
             }
             else
             {
                 Uri to = contextMessage.Headers.To;
                 if (to == null)
                 {
                     toHeader = contextMessage.Version.Addressing.Anonymous;
                 }
                 else
                 {
                     toHeader = to.AbsoluteUri;
                 }
             }
             context.Processor.ToHeader = toHeader;
         }
         context.Push(toHeader, iterationCount);
     }
 }
 internal override Opcode Eval(ProcessingContext context)
 {
     if (!context.LoadVariable(this.expr.Variable))
     {
         context.PushSequenceFrame();
         NodeSequence seq = context.CreateSequence();
         seq.Add(context.Processor.ContextNode);
         context.PushSequence(seq);
         int counterMarker = context.Processor.CounterMarker;
         try
         {
             this.expr.Eval(context);
         }
         catch (XPathNavigatorException exception)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception.Process(this));
         }
         catch (NavigatorInvalidBodyAccessException exception2)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception2.Process(this));
         }
         context.Processor.CounterMarker = counterMarker;
         context.PopSequenceFrame();
         context.PopSequenceFrame();
         context.LoadVariable(this.expr.Variable);
     }
     return base.next;
 }
        internal override Opcode Eval(ProcessingContext context)
        {
            XPathResult result;
            StackFrame topArg = context.TopArg;
            switch (context.Values[topArg.basePtr].Type)
            {
                case ValueDataType.Boolean:
                    result = new XPathResult(context.Values[topArg.basePtr].GetBoolean());
                    break;

                case ValueDataType.Double:
                    result = new XPathResult(context.Values[topArg.basePtr].GetDouble());
                    break;

                case ValueDataType.Sequence:
                {
                    SafeNodeSequenceIterator nodeSetResult = new SafeNodeSequenceIterator(context.Values[topArg.basePtr].GetSequence(), context);
                    result = new XPathResult(nodeSetResult);
                    break;
                }
                case ValueDataType.String:
                    result = new XPathResult(context.Values[topArg.basePtr].GetString());
                    break;

                default:
                    throw Fx.AssertAndThrow("Unexpected result type.");
            }
            context.Processor.QueryResult = result;
            context.PopFrame();
            return base.next;
        }
 public SafeNodeSequenceIterator(NodeSequence seq, ProcessingContext context) : base(seq)
 {
     this.context = context;
     this.seq = seq;
     Interlocked.Increment(ref this.seq.refCount);
     this.context.Processor.AddRef();
 }
 internal override Opcode Eval(ProcessingContext context)
 {
     if (!context.LoadVariable(base.expr.Variable))
     {
         base.expr.Eval(context);
     }
     return base.next;
 }
 internal static void BooleanFalse(ProcessingContext context)
 {
     context.PushFrame();
     int iterationCount = context.IterationCount;
     if (iterationCount > 0)
     {
         context.Push(false, iterationCount);
     }
 }
 internal override void InvokeInternal(ProcessingContext context, int argCount)
 {
     context.PushFrame();
     int iterationCount = context.IterationCount;
     if (iterationCount > 0)
     {
         context.Push(XPathMessageFunction.ConvertDate(DateTime.Now), iterationCount);
     }
 }
 internal static void BooleanNot(ProcessingContext context)
 {
     StackFrame topArg = context.TopArg;
     Value[] values = context.Values;
     while (topArg.basePtr <= topArg.endPtr)
     {
         values[topArg.basePtr++].Not();
     }
 }
 internal static void BooleanBoolean(ProcessingContext context)
 {
     StackFrame topArg = context.TopArg;
     Value[] values = context.Values;
     while (topArg.basePtr <= topArg.endPtr)
     {
         values[topArg.basePtr++].ConvertTo(context, ValueDataType.Boolean);
     }
 }
 internal override Opcode Eval(ProcessingContext context)
 {
     context.PushFrame();
     int iterationCount = context.IterationCount;
     if (iterationCount > 0)
     {
         context.Push(this.literal, iterationCount);
     }
     return base.next;
 }
 internal override Opcode Eval(ProcessingContext context)
 {
     StackFrame topArg = context.TopArg;
     Value[] values = context.Values;
     for (int i = topArg.basePtr; i <= topArg.endPtr; i++)
     {
         values[i].ConvertTo(context, this.newType);
     }
     return base.next;
 }
 internal override Opcode Eval(ProcessingContext context)
 {
     Value[] values = context.Values;
     StackFrame topArg = context.TopArg;
     for (int i = topArg.basePtr; i <= topArg.endPtr; i++)
     {
         values[i].Update(context, values[i].CompareTo(this.literal, this.op));
     }
     return base.next;
 }
 internal override void InvokeInternal(ProcessingContext context, int argCount)
 {
     StackFrame topArg = context.TopArg;
     while (topArg.basePtr <= topArg.endPtr)
     {
         string dateStr = context.PeekString(topArg.basePtr);
         context.SetValue(context, topArg.basePtr, Convert(dateStr));
         topArg.basePtr++;
     }
 }
 internal override Opcode Eval(ProcessingContext context)
 {
     int num = this.UpdateResultMask(context);
     context.PopFrame();
     if (num == 0)
     {
         return base.Jump;
     }
     return base.next;
 }
 internal override Opcode Eval(ProcessingContext context)
 {
     SeekableXPathNavigator contextNode = context.Processor.ContextNode;
     bool flag = this.Match(contextNode);
     context.Processor.Result = flag;
     if ((flag && (base.item != null)) && (context.Processor.MatchSet != null))
     {
         context.Processor.MatchSet.Add((MessageFilter) base.item);
     }
     return base.next;
 }
 internal override Opcode Eval(ProcessingContext context)
 {
     StackFrame topArg = context.TopArg;
     for (int i = topArg.basePtr; i <= topArg.endPtr; i++)
     {
         if (this.test == context.Values[i].Boolean)
         {
             return base.next;
         }
     }
     return base.Jump;
 }
        internal override Opcode Eval(ProcessingContext context)
        {
            context.PushContextSequenceFrame();
            NodeSequence seq = context.CreateSequence();

            seq.StartNodeset();
            seq.Add(context.Processor.ContextNode);
            seq.StopNodeset();

            context.PushSequence(seq);

            return this.next;
        }
 internal override Opcode Eval(ProcessingContext context)
 {
     SeekableXPathNavigator contextNode = context.Processor.ContextNode;
     XPathResult result = this.Select(contextNode);
     if (context.Processor.ResultSet == null)
     {
         context.Processor.QueryResult = result;
     }
     else
     {
         context.Processor.ResultSet.Add(new KeyValuePair<MessageQuery, XPathResult>((MessageQuery) base.item, result));
     }
     return base.next;
 }
 internal override Opcode Eval(ProcessingContext context)
 {
     StackFrame topArg = context.TopArg;
     StackFrame secondArg = context.SecondArg;
     Value[] values = context.Values;
     int basePtr = topArg.basePtr;
     for (int i = secondArg.basePtr; basePtr <= topArg.endPtr; i++)
     {
         values[i].Add(values[basePtr].Double);
         basePtr++;
     }
     context.PopFrame();
     return base.next;
 }
 internal override Opcode Eval(ProcessingContext context)
 {
     StackFrame topArg = context.TopArg;
     StackFrame secondArg = context.SecondArg;
     Value[] values = context.Values;
     while (topArg.basePtr <= topArg.endPtr)
     {
         values[secondArg.basePtr].Update(context, values[secondArg.basePtr].CompareTo(ref values[topArg.basePtr], this.op));
         topArg.basePtr++;
         secondArg.basePtr++;
     }
     context.PopFrame();
     return base.next;
 }
        internal override Opcode Eval(ProcessingContext context)
        {
            NodeSequenceStack stack = context.SequenceStack;
            StackFrame sequences = stack.TopArg;

            stack.PushFrame();
            for (int i = 0; i < sequences.count; ++i)
            {
                NodeSequence sourceSeq = stack.Sequences[sequences[i]];
                sourceSeq.refCount++;
                stack.Push(sourceSeq);
            }

            return this.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);
        }
        internal override void InvokeInternal(ProcessingContext context, int argCount)
        {
            StackFrame topArg = context.TopArg;

            while (topArg.basePtr <= topArg.endPtr)
            {
                bool         val      = false;
                NodeSequence sequence = context.PeekSequence(topArg.basePtr);
                if (sequence.Count > 0)
                {
                    NodeSequenceItem       item      = sequence[0];
                    SeekableXPathNavigator node      = item.Node.Node;
                    long             currentPosition = node.CurrentPosition;
                    NodeSequenceItem item2           = sequence[0];
                    node.CurrentPosition = item2.Node.Position;
                    val = ExtractFromNavigator(node);
                    node.CurrentPosition = currentPosition;
                }
                context.SetValue(context, topArg.basePtr, val);
                topArg.basePtr++;
            }
        }
Example #33
0
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame topSequenceArg = context.TopSequenceArg;
            StackFrame topArg         = context.TopArg;

            Value[] sequences = context.Sequences;
            int     basePtr   = topSequenceArg.basePtr;
            int     index     = topArg.basePtr;

            while (basePtr <= topSequenceArg.endPtr)
            {
                NodeSequence sequence = sequences[basePtr].Sequence;
                for (int i = 0; i < sequence.Count; i++)
                {
                    NodeSequenceItem item = sequence[i];
                    context.Values[index].Boolean = item.Position == context.Values[index].Double;
                    index++;
                }
                basePtr++;
            }
            return(base.next);
        }
Example #34
0
        internal bool LoadVariable(ProcessingContext context, int var)
        {
            if (this.subExprVars[var].seq == null)
            {
                return(false);
            }

            int iter = context.IterationCount;

            this.counter.IncreaseBy(iter * this.subExprVars[var].count);

            NodeSequence seq = this.subExprVars[var].seq;

            context.PushSequenceFrame();
            for (int i = 0; i < iter; ++i)
            {
                seq.refCount++;
                context.PushSequence(seq);
            }

            return(true);
        }
Example #35
0
        protected bool IsSuccess(ProcessingContext context)
        {
            StackFrame topFrame = context.TopArg;

            if (1 == topFrame.Count)
            {
                return(context.Values[topFrame.basePtr].ToBoolean());
            }
            else
            {
                context.Processor.Result = false;
                for (int i = topFrame.basePtr; i <= topFrame.endPtr; ++i)
                {
                    if (context.Values[i].ToBoolean())
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #36
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);
        }
Example #37
0
        internal static void BooleanLang(ProcessingContext context)
        {
            StackFrame langArg   = context.TopArg;
            StackFrame sequences = context.TopSequenceArg;

            Value[] sequenceBuffer = context.Sequences;

            while (sequences.basePtr <= sequences.endPtr)
            {
                NodeSequence sourceSeq = sequenceBuffer[sequences.basePtr++].Sequence;

                for (int item = 0; item < sourceSeq.Count; ++item)
                {
                    string lang = context.PeekString(langArg.basePtr).ToUpperInvariant();

                    QueryNode node = sourceSeq.Items[item].Node;
                    long      pos  = node.Node.CurrentPosition;
                    node.Node.CurrentPosition = node.Position;
                    string docLang = node.Node.XmlLang.ToUpperInvariant();
                    node.Node.CurrentPosition = pos;

                    if (lang.Length == docLang.Length && string.CompareOrdinal(lang, docLang) == 0)
                    {
                        context.SetValue(context, langArg.basePtr++, true);
                    }
                    else if (docLang.Length > 0 && lang.Length < docLang.Length && docLang.StartsWith(lang, StringComparison.Ordinal) && docLang[lang.Length] == '-')
                    {
                        context.SetValue(context, langArg.basePtr++, true);
                    }
                    else
                    {
                        context.SetValue(context, langArg.basePtr++, false);
                    }
                }

                sequences.basePtr++;
            }
        }
Example #38
0
        internal static void Translate(ProcessingContext context)
        {
            StackFrame argSource = context.TopArg;
            StackFrame argKeys   = context.SecondArg;
            StackFrame argValues = context[2];

            // PERF, [....], this is really slow.
            StringBuilder builder = new StringBuilder();

            while (argSource.basePtr <= argSource.endPtr)
            {
                builder.Length = 0;

                string source = context.PeekString(argSource.basePtr);
                string keys   = context.PeekString(argKeys.basePtr);
                string values = context.PeekString(argValues.basePtr);
                for (int i = 0; i < source.Length; ++i)
                {
                    char c   = source[i];
                    int  idx = keys.IndexOf(c);
                    if (idx < 0)
                    {
                        builder.Append(c);
                    }
                    else if (idx < values.Length)
                    {
                        builder.Append(values[idx]);
                    }
                }
                context.SetValue(context, argValues.basePtr, builder.ToString());
                argSource.basePtr++;
                argKeys.basePtr++;
                argValues.basePtr++;
            }

            context.PopFrame();
            context.PopFrame();
        }
Example #39
0
        void InvokeSingleMatch(ProcessingContext context)
        {
            int marker = context.Processor.CounterMarker;
            QueryBranchResult result = this.resultTable[0];

            this.InitResults(context);
            context.Values[context.TopArg[result.ValIndex]].Boolean = true;

            try
            {
                context.EvalCodeBlock(result.Branch.Branch.Next);
            }
            catch (XPathNavigatorException e)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(e.Process(result.Branch.Branch.Next));
            }
            catch (NavigatorInvalidBodyAccessException e)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(e.Process(result.Branch.Branch.Next));
            }

            context.Processor.CounterMarker = marker;
        }
Example #40
0
        protected int UpdateResultMask(ProcessingContext context)
        {
            StackFrame results    = context.TopArg;
            StackFrame resultMask = context.SecondArg;

            Value[] values    = context.Values;
            int     testCount = 0;

            for (int maskIndex = resultMask.basePtr, resultIndex = results.basePtr; maskIndex <= resultMask.endPtr; ++maskIndex)
            {
                if (this.test == values[maskIndex].Boolean)
                {
                    bool boolResult = values[resultIndex].Boolean;
                    if (this.test == boolResult)
                    {
                        testCount++;
                    }
                    values[maskIndex].Boolean = boolResult;
                    ++resultIndex;
                }
            }
            return(testCount);
        }
Example #41
0
        internal void CopyFrom(ProcessingContext context)
        {
            Fx.Assert(null != context, "");

            this.processor = context.processor;
            if (context.sequenceStack.frames.Count > 0)
            {
                this.sequenceStack.CopyFrom(ref context.sequenceStack);
            }
            else
            {
                this.sequenceStack.Clear();
            }
            if (context.valueStack.frames.Count > 0)
            {
                this.valueStack.CopyFrom(ref context.valueStack);
            }
            else
            {
                this.valueStack.Clear();
            }
            this.nodeCount = context.nodeCount;
        }
Example #42
0
        internal static void StringConcatFour(ProcessingContext context)
        {
            StackFrame arg1 = context[0];
            StackFrame arg2 = context[1];
            StackFrame arg3 = context[2];
            StackFrame arg4 = context[3];

            while (arg1.basePtr <= arg1.endPtr)
            {
                string str1 = context.PeekString(arg1.basePtr);
                string str2 = context.PeekString(arg2.basePtr);
                string str3 = context.PeekString(arg3.basePtr);
                string str4 = context.PeekString(arg4.basePtr);
                context.SetValue(context, arg4.basePtr, str1 + str2 + str3 + str4);
                arg1.basePtr++;
                arg2.basePtr++;
                arg3.basePtr++;
                arg4.basePtr++;
            }
            context.PopFrame();
            context.PopFrame();
            context.PopFrame();
        }
Example #43
0
        internal void Eval(ProcessingContext context)
        {
            int count = 0, marker = context.Processor.CounterMarker;

            Opcode op = this.ops;

            if (this.useSpecial)
            {
                op.EvalSpecial(context);
                context.LoadVariable(this.var);
                //context.Processor.CounterMarker = marker;
                return;
            }

            while (op != null)
            {
                op = op.Eval(context);
            }

            count = context.Processor.ElapsedCount(marker);
            //context.Processor.CounterMarker = marker;
            context.SaveVariable(this.var, count);
        }
Example #44
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);
        }
        internal override Opcode Eval(ProcessingContext context)
        {
            StackFrame arg = context.TopArg;

            if (1 == arg.Count)
            {
                Fx.Assert(context.Values[arg.basePtr].IsType(ValueDataType.String), "");

                string target = context.Values[arg.basePtr].String;
                context.Values[arg.basePtr].Boolean = target.StartsWith(this.literal, StringComparison.Ordinal);
            }
            else
            {
                for (int i = arg.basePtr; i <= arg.endPtr; ++i)
                {
                    Fx.Assert(context.Values[i].IsType(ValueDataType.String), "");
                    string target = context.Values[i].String;
                    context.Values[i].Boolean = target.StartsWith(this.literal, StringComparison.Ordinal);
                }
            }

            return(this.next);
        }
Example #46
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);
        }
Example #47
0
        internal override Opcode Eval(ProcessingContext context)
        {
            XPathResult result;
            StackFrame  topArg = context.TopArg;

            switch (context.Values[topArg.basePtr].Type)
            {
            case ValueDataType.Boolean:
                result = new XPathResult(context.Values[topArg.basePtr].GetBoolean());
                break;

            case ValueDataType.Double:
                result = new XPathResult(context.Values[topArg.basePtr].GetDouble());
                break;

            case ValueDataType.Sequence:
            {
                SafeNodeSequenceIterator nodeSetResult = new SafeNodeSequenceIterator(context.Values[topArg.basePtr].GetSequence(), context);
                result = new XPathResult(nodeSetResult);
                break;
            }

            case ValueDataType.String:
                result = new XPathResult(context.Values[topArg.basePtr].GetString());
                break;

            default:
                throw Fx.AssertAndThrow("Unexpected result type.");
            }
            context.Processor.ResultSet.Add(new KeyValuePair <MessageQuery, XPathResult>((MessageQuery)this.results[0], result));
            for (int i = 1; i < this.results.Count; i++)
            {
                context.Processor.ResultSet.Add(new KeyValuePair <MessageQuery, XPathResult>((MessageQuery)this.results[i], result.Copy()));
            }
            context.PopFrame();
            return(base.next);
        }
        internal void InvokeNonMatches(ProcessingContext context, QueryBranchTable nonMatchTable)
        {
            int           counterMarker = context.Processor.CounterMarker;
            BranchContext context2      = new BranchContext(context);
            int           num2          = 0;
            int           num3          = 0;

            while ((num3 < this.resultTable.Count) && (num2 < nonMatchTable.Count))
            {
                QueryBranchResult result = this.resultTable[num3];
                int num4 = result.Branch.ID - nonMatchTable[num2].ID;
                if (num4 > 0)
                {
                    ProcessingContext context3 = context2.Create();
                    this.InvokeNonMatch(context3, nonMatchTable[num2]);
                    context.Processor.CounterMarker = counterMarker;
                    num2++;
                }
                else
                {
                    if (num4 == 0)
                    {
                        num2++;
                        continue;
                    }
                    num3++;
                }
            }
            while (num2 < nonMatchTable.Count)
            {
                ProcessingContext context4 = context2.Create();
                this.InvokeNonMatch(context4, nonMatchTable[num2]);
                context.Processor.CounterMarker = counterMarker;
                num2++;
            }
            context2.Release();
        }
Example #49
0
        internal static void SubstringLimit(ProcessingContext context)
        {
            StackFrame argString  = context.TopArg;
            StackFrame argStartAt = context.SecondArg;
            StackFrame argLimit   = context[2];

            Fx.Assert(argString.Count == argStartAt.Count, "");
            Fx.Assert(argString.Count == argLimit.Count, "");

            while (argString.basePtr <= argString.endPtr)
            {
                string str     = context.PeekString(argString.basePtr);
                int    startAt = ((int)Math.Round(context.PeekDouble(argStartAt.basePtr))) - 1;
                if (startAt < 0)
                {
                    startAt = 0;
                }
                int length = (int)Math.Round(context.PeekDouble(argLimit.basePtr));

                string substr;
                if (length < 1 || ((startAt + length) >= str.Length))
                {
                    substr = string.Empty;
                }
                else
                {
                    substr = str.Substring(startAt, length);
                }
                context.SetValue(context, argLimit.basePtr, substr);
                argStartAt.basePtr++;
                argString.basePtr++;
                argLimit.basePtr++;
            }

            context.PopFrame();
            context.PopFrame();
        }
Example #50
0
        internal override void InvokeInternal(ProcessingContext context, int argCount)
        {
            int iterationCount = context.IterationCount;

            context.PushSequenceFrame();
            if (iterationCount > 0)
            {
                NodeSequence seq = context.CreateSequence();
                seq.StartNodeset();
                SeekableXPathNavigator contextNode = context.Processor.ContextNode;
                long currentPosition = contextNode.CurrentPosition;
                if (XPathMessageFunction.MoveToHeader(contextNode))
                {
                    seq.Add(contextNode);
                }
                contextNode.CurrentPosition = currentPosition;
                seq.StopNodeset();
                context.PushSequence(seq);
                for (int i = 1; i < iterationCount; i++)
                {
                    context.PushSequence(seq);
                }
            }
        }
Example #51
0
 internal NodeSequenceBuilder(ProcessingContext context)
     : this(context, null)
 {
 }
Example #52
0
 internal override Opcode EvalSpecial(ProcessingContext context)
 {
     this.expr.EvalSpecial(context);
     return(this.next);
 }
Example #53
0
        internal override void EvalSpecial(ProcessingContext context)
        {
            int marker = context.Processor.CounterMarker;

            if (!context.LoadVariable(this.var))
            {
                XPathMessageContext.HeaderFun.InvokeInternal(context, 0);
                context.SaveVariable(this.var, context.Processor.ElapsedCount(marker));
            }

            // WS, Microsoft, see if we can put this array in the processor to save
            //             an allocation.  Perhaps we can use the variables slot we're going to fill
            NodeSequence[] childSequences = new NodeSequence[this.children.Count];
            NodeSequence   seq            = context.Sequences[context.TopSequenceArg.basePtr].Sequence;

            for (int i = 0; i < this.children.Count; ++i)
            {
                childSequences[i] = context.CreateSequence();
                childSequences[i].StartNodeset();
            }

            // Perform the index
            SeekableXPathNavigator nav = seq[0].GetNavigator();

            if (nav.MoveToFirstChild())
            {
                do
                {
                    if (nav.NodeType == XPathNodeType.Element)
                    {
                        List <SubExpr> lst;
                        string         name = nav.LocalName;
                        string         ns   = nav.NamespaceURI;
                        Dictionary <string, List <SubExpr> > nextLookup;
                        if (this.nameLookup.TryGetValue(ns, out nextLookup))
                        {
                            if (nextLookup.TryGetValue(name, out lst))
                            {
                                for (int i = 0; i < lst.Count; ++i)
                                {
                                    childSequences[this.indexLookup[lst[i]].i].Add(nav);
                                }
                            }

                            if (nextLookup.TryGetValue(QueryDataModel.Wildcard, out lst))
                            {
                                for (int i = 0; i < lst.Count; ++i)
                                {
                                    childSequences[this.indexLookup[lst[i]].i].Add(nav);
                                }
                            }
                        }

                        if (this.nameLookup.TryGetValue(QueryDataModel.Wildcard, out nextLookup))
                        {
                            if (nextLookup.TryGetValue(QueryDataModel.Wildcard, out lst))
                            {
                                for (int i = 0; i < lst.Count; ++i)
                                {
                                    childSequences[this.indexLookup[lst[i]].i].Add(nav);
                                }
                            }
                        }
                    }
                } while (nav.MoveToNext());
            }

            int secondMarker = context.Processor.CounterMarker;

            for (int i = 0; i < this.children.Count; ++i)
            {
                if (this.children[i].useSpecial)
                {
                    childSequences[i].StopNodeset();
                    context.Processor.CounterMarker = secondMarker;
                    context.PushSequenceFrame();
                    context.PushSequence(childSequences[i]);
                    Opcode op = this.children[i].FirstOp.Next;
                    while (op != null)
                    {
                        op = op.Eval(context);
                    }
                    context.SaveVariable(this.children[i].var, context.Processor.ElapsedCount(marker));
                    context.PopSequenceFrame();
                }
                else
                {
                    context.ReleaseSequence(childSequences[i]);
                    //context.SetVariable(this.children[i].Variable, null, 0);
                }
            }

            context.Processor.CounterMarker = marker;
        }
 internal void SetValue(ProcessingContext context, int index, NodeSequence val)
 {
     this.valueStack.SetValue(this, index, val);
 }
 internal void SetValue(ProcessingContext context, int index, string val)
 {
     this.valueStack.SetValue(this, index, val);
 }
Example #56
0
 internal void SetValue(ProcessingContext context, int index, NodeSequence val)
 {
     this.buffer.buffer[index].Update(context, val);
 }
Example #57
0
 internal void SetValue(ProcessingContext context, int index, string val)
 {
     this.buffer.buffer[index].Update(context, val);
 }
Example #58
0
 internal bool CanReuse(ProcessingContext context)
 {
     return(this.count == 1 && this.ownerContext == context && this.refCount == 1);
 }
Example #59
0
 internal void SetValue(ProcessingContext context, int index, NodeSequence val)
 {
     Fx.Assert(this.stack.IsValidStackPtr(index), "");
     this.buffer.buffer[index].Update(context, val);
 }
Example #60
0
 internal NodeSequenceBuilder(ProcessingContext context, NodeSequence sequence)
 {
     this.context  = context;
     this.sequence = sequence;
 }