Пример #1
0
        internal static void Translate(ProcessingContext context)
        {
            StackFrame    topArg    = context.TopArg;
            StackFrame    secondArg = context.SecondArg;
            StackFrame    frame3    = context[2];
            StringBuilder builder   = new StringBuilder();

            while (topArg.basePtr <= topArg.endPtr)
            {
                builder.Length = 0;
                string str  = context.PeekString(topArg.basePtr);
                string str2 = context.PeekString(secondArg.basePtr);
                string str3 = context.PeekString(frame3.basePtr);
                for (int i = 0; i < str.Length; i++)
                {
                    char ch    = str[i];
                    int  index = str2.IndexOf(ch);
                    if (index < 0)
                    {
                        builder.Append(ch);
                    }
                    else if (index < str3.Length)
                    {
                        builder.Append(str3[index]);
                    }
                }
                context.SetValue(context, frame3.basePtr, builder.ToString());
                topArg.basePtr++;
                secondArg.basePtr++;
                frame3.basePtr++;
            }
            context.PopFrame();
            context.PopFrame();
        }
Пример #2
0
        internal static void StringStartsWith(ProcessingContext context)
        {
            StackFrame topArg    = context.TopArg;
            StackFrame secondArg = context.SecondArg;

            while (topArg.basePtr <= topArg.endPtr)
            {
                string str  = context.PeekString(topArg.basePtr);
                string str2 = context.PeekString(secondArg.basePtr);
                context.SetValue(context, secondArg.basePtr, str.StartsWith(str2, StringComparison.Ordinal));
                topArg.basePtr++;
                secondArg.basePtr++;
            }
            context.PopFrame();
        }
Пример #3
0
        internal static void StringConcatTwo(ProcessingContext context)
        {
            StackFrame arg1 = context[0];
            StackFrame arg2 = context[1];

            while (arg1.basePtr <= arg1.endPtr)
            {
                string str1 = context.PeekString(arg1.basePtr);
                string str2 = context.PeekString(arg2.basePtr);
                context.SetValue(context, arg2.basePtr, str1 + str2);
                arg1.basePtr++;
                arg2.basePtr++;
            }
            context.PopFrame();
        }
        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;
        }
Пример #5
0
        internal override void Eval(ProcessingContext context)
        {
            Fx.Assert(context != null, "");

            StackFrame[] args = new StackFrame[argCount];
            for (int i = 0; i < this.argCount; ++i)
            {
                args[i] = context[i];
            }

            StringBuilder builder = new StringBuilder();

            while (args[0].basePtr <= args[0].endPtr)
            {
                builder.Length = 0;

                for (int i = 0; i < this.argCount; ++i)
                {
                    builder.Append(context.PeekString(args[i].basePtr));
                }

                context.SetValue(context, args[this.argCount - 1].basePtr, builder.ToString());
                for (int i = 0; i < this.argCount; ++i)
                {
                    args[i].basePtr++;
                }
            }

            for (int i = 0; i < this.argCount - 1; ++i)
            {
                context.PopFrame();
            }
        }
 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;
 }
Пример #7
0
        internal static void SubstringLimit(ProcessingContext context)
        {
            StackFrame topArg    = context.TopArg;
            StackFrame secondArg = context.SecondArg;
            StackFrame frame3    = context[2];

            while (topArg.basePtr <= topArg.endPtr)
            {
                string str2;
                string str        = context.PeekString(topArg.basePtr);
                int    startIndex = ((int)Math.Round(context.PeekDouble(secondArg.basePtr))) - 1;
                if (startIndex < 0)
                {
                    startIndex = 0;
                }
                int length = (int)Math.Round(context.PeekDouble(frame3.basePtr));
                if ((length < 1) || ((startIndex + length) >= str.Length))
                {
                    str2 = string.Empty;
                }
                else
                {
                    str2 = str.Substring(startIndex, length);
                }
                context.SetValue(context, frame3.basePtr, str2);
                secondArg.basePtr++;
                topArg.basePtr++;
                frame3.basePtr++;
            }
            context.PopFrame();
            context.PopFrame();
        }
        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();
            }
        }
Пример #9
0
        internal static void SubstringBefore(ProcessingContext context)
        {
            StackFrame topArg    = context.TopArg;
            StackFrame secondArg = context.SecondArg;

            while (topArg.basePtr <= topArg.endPtr)
            {
                string str   = context.PeekString(topArg.basePtr);
                string str2  = context.PeekString(secondArg.basePtr);
                int    index = str.IndexOf(str2, StringComparison.Ordinal);
                context.SetValue(context, secondArg.basePtr, (index == -1) ? string.Empty : str.Substring(0, index));
                topArg.basePtr++;
                secondArg.basePtr++;
            }
            context.PopFrame();
        }
Пример #10
0
        internal static void NormalizeSpace(ProcessingContext context)
        {
            StackFrame argStr = context.TopArg;

            StringBuilder builder = new StringBuilder();

            while (argStr.basePtr <= argStr.endPtr)
            {
                char[] whitespace = new char[] { ' ', '\t', '\r', '\n' };
                string str        = context.PeekString(argStr.basePtr).Trim(whitespace);

                bool eatingWhitespace = false;
                builder.Length = 0;
                for (int i = 0; i < str.Length; ++i)
                {
                    char c = str[i];
                    if (XPathCharTypes.IsWhitespace(c))
                    {
                        if (!eatingWhitespace)
                        {
                            builder.Append(' ');
                            eatingWhitespace = true;
                        }
                    }
                    else
                    {
                        builder.Append(c);
                        eatingWhitespace = false;
                    }
                }

                context.SetValue(context, argStr.basePtr, builder.ToString());
                argStr.basePtr++;
            }
        }
Пример #11
0
        internal static void StringStartsWith(ProcessingContext context)
        {
            StackFrame arg1 = context.TopArg;
            StackFrame arg2 = context.SecondArg;

            Fx.Assert(arg1.Count == arg2.Count, "");
            while (arg1.basePtr <= arg1.endPtr)
            {
                string leftString  = context.PeekString(arg1.basePtr);
                string rightString = context.PeekString(arg2.basePtr);
                context.SetValue(context, arg2.basePtr, leftString.StartsWith(rightString, StringComparison.Ordinal));
                arg1.basePtr++;
                arg2.basePtr++;
            }
            context.PopFrame();
        }
 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();
     }
 }
Пример #13
0
        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++;
            }
        }
Пример #14
0
        internal static void NormalizeSpace(ProcessingContext context)
        {
            StackFrame    topArg  = context.TopArg;
            StringBuilder builder = new StringBuilder();

            while (topArg.basePtr <= topArg.endPtr)
            {
                char[] trimChars = new char[] { ' ', '\t', '\r', '\n' };
                string str       = context.PeekString(topArg.basePtr).Trim(trimChars);
                bool   flag      = false;
                builder.Length = 0;
                for (int i = 0; i < str.Length; i++)
                {
                    char c = str[i];
                    if (XPathCharTypes.IsWhitespace(c))
                    {
                        if (!flag)
                        {
                            builder.Append(' ');
                            flag = true;
                        }
                    }
                    else
                    {
                        builder.Append(c);
                        flag = false;
                    }
                }
                context.SetValue(context, topArg.basePtr, builder.ToString());
                topArg.basePtr++;
            }
        }
 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++;
     }
 }
Пример #16
0
        internal static void SubstringAfter(ProcessingContext context)
        {
            StackFrame arg1 = context.TopArg;
            StackFrame arg2 = context.SecondArg;

            Fx.Assert(arg1.Count == arg2.Count, "");
            while (arg1.basePtr <= arg1.endPtr)
            {
                string str1 = context.PeekString(arg1.basePtr);
                string str2 = context.PeekString(arg2.basePtr);
                int    idx  = str1.IndexOf(str2, StringComparison.Ordinal);
                context.SetValue(context, arg2.basePtr, idx == -1 ? string.Empty : str1.Substring(idx + str2.Length));
                arg1.basePtr++;
                arg2.basePtr++;
            }
            context.PopFrame();
        }
Пример #17
0
        internal static void StringLength(ProcessingContext context)
        {
            StackFrame arg = context.TopArg;

            while (arg.basePtr <= arg.endPtr)
            {
                context.SetValue(context, arg.basePtr, context.PeekString(arg.basePtr).Length);
                arg.basePtr++;
            }
        }
Пример #18
0
 internal override void InvokeInternal(ProcessingContext context, int argCount)
 {
     StackFrame topArg = context.TopArg;
     while (topArg.basePtr <= topArg.endPtr)
     {
         string spanStr = context.PeekString(topArg.basePtr);
         context.SetValue(context, topArg.basePtr, Convert(spanStr));
         topArg.basePtr++;
     }
 }
 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++;
     }
 }
Пример #20
0
        internal static void StringLength(ProcessingContext context)
        {
            StackFrame topArg = context.TopArg;

            while (topArg.basePtr <= topArg.endPtr)
            {
                context.SetValue(context, topArg.basePtr, (double)context.PeekString(topArg.basePtr).Length);
                topArg.basePtr++;
            }
        }
Пример #21
0
        internal static void StringConcatTwo(ProcessingContext context)
        {
            StackFrame frame  = context[0];
            StackFrame frame2 = context[1];

            while (frame.basePtr <= frame.endPtr)
            {
                context.SetValue(context, frame2.basePtr, context.PeekString(frame.basePtr) + context.PeekString(frame2.basePtr));
                frame.basePtr++;
                frame2.basePtr++;
            }
            context.PopFrame();
        }
Пример #22
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();
        }
 internal override void InvokeInternal(ProcessingContext context, int argCount)
 {
     StackFrame topArg = context.TopArg;
     Message contextMessage = context.Processor.ContextMessage;
     CorrelationDataMessageProperty property = null;
     CorrelationDataMessageProperty.TryGet(contextMessage, out property);
     while (topArg.basePtr <= topArg.endPtr)
     {
         string str;
         if ((property == null) || !property.TryGetValue(context.PeekString(topArg.basePtr), out str))
         {
             str = string.Empty;
         }
         context.SetValue(context, topArg.basePtr, str);
         topArg.basePtr++;
     }
 }
        internal override void InvokeInternal(ProcessingContext context, int argCount)
        {
            StackFrame topArg         = context.TopArg;
            Message    contextMessage = context.Processor.ContextMessage;
            CorrelationDataMessageProperty property = null;

            CorrelationDataMessageProperty.TryGet(contextMessage, out property);
            while (topArg.basePtr <= topArg.endPtr)
            {
                string str;
                if ((property == null) || !property.TryGetValue(context.PeekString(topArg.basePtr), out str))
                {
                    str = string.Empty;
                }
                context.SetValue(context, topArg.basePtr, str);
                topArg.basePtr++;
            }
        }
Пример #25
0
        internal static void Substring(ProcessingContext context)
        {
            StackFrame topArg    = context.TopArg;
            StackFrame secondArg = context.SecondArg;

            while (topArg.basePtr <= topArg.endPtr)
            {
                string str        = context.PeekString(topArg.basePtr);
                int    startIndex = ((int)Math.Round(context.PeekDouble(secondArg.basePtr))) - 1;
                if (startIndex < 0)
                {
                    startIndex = 0;
                }
                context.SetValue(context, secondArg.basePtr, (startIndex >= str.Length) ? string.Empty : str.Substring(startIndex));
                topArg.basePtr++;
                secondArg.basePtr++;
            }
            context.PopFrame();
        }
Пример #26
0
        internal static void Substring(ProcessingContext context)
        {
            StackFrame arg1 = context.TopArg;
            StackFrame arg2 = context.SecondArg;

            Fx.Assert(arg1.Count == arg2.Count, "");
            while (arg1.basePtr <= arg1.endPtr)
            {
                string str     = context.PeekString(arg1.basePtr);
                int    startAt = ((int)Math.Round(context.PeekDouble(arg2.basePtr))) - 1;
                if (startAt < 0)
                {
                    startAt = 0;
                }
                context.SetValue(context, arg2.basePtr, (startAt >= str.Length) ? string.Empty : str.Substring(startAt));
                arg1.basePtr++;
                arg2.basePtr++;
            }
            context.PopFrame();
        }
Пример #27
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++;
            }
        }
Пример #28
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();
        }
Пример #29
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++;
            }
        }
Пример #30
0
        internal override Opcode Eval(ProcessingContext context)
        {
            XPathNavigator nav = context.Processor.ContextNode;
            if (nav != null && context.Processor.ContextMessage != null)
            {
                ((SeekableMessageNavigator)nav).Atomize();
            }

            if (this.argCount == 0)
            {
                context.PushFrame();
                int count = context.IterationCount;
                if (count > 0)
                {
                    object ret = this.function.Invoke(this.xsltContext, NullArgs, nav);
                    switch (this.function.ReturnType)
                    {
                        case XPathResultType.String:
                            context.Push((string)ret, count);
                            break;

                        case XPathResultType.Number:
                            context.Push((double)ret, count);
                            break;

                        case XPathResultType.Boolean:
                            context.Push((bool)ret, count);
                            break;

                        case XPathResultType.NodeSet:
                            NodeSequence seq = context.CreateSequence();
                            XPathNodeIterator iter = (XPathNodeIterator)ret;
                            seq.Add(iter);
                            context.Push(seq, count);
                            break;

                        default:
                            // This should never be reached
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryFunctionTypeNotSupported, this.function.ReturnType.ToString())));
                    }
                }
            }
            else
            {
                // PERF, [....], see if we can cache these arrays to avoid allocations
                object[] xsltArgs = new object[this.argCount];
                int iterationCount = context.TopArg.Count;
                for (int iteration = 0; iteration < iterationCount; ++iteration)
                {
                    for (int i = 0; i < this.argCount; ++i)
                    {
                        StackFrame arg = context[i];
                        Fx.Assert(iteration < arg.Count, "");

                        switch (this.function.ArgTypes[i])
                        {
                            case XPathResultType.String:
                                xsltArgs[i] = context.PeekString(arg[iteration]);
                                break;

                            case XPathResultType.Number:
                                xsltArgs[i] = context.PeekDouble(arg[iteration]);
                                break;

                            case XPathResultType.Boolean:
                                xsltArgs[i] = context.PeekBoolean(arg[iteration]);
                                break;

                            case XPathResultType.NodeSet:
                                NodeSequenceIterator iter = new NodeSequenceIterator(context.PeekSequence(arg[iteration]));
                                xsltArgs[i] = iter;
                                this.iterList.Add(iter);
                                break;

                            default:
                                // This should never be reached
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryFunctionTypeNotSupported, this.function.ArgTypes[i].ToString())));
                        }
                    }

                    object ret = this.function.Invoke(this.xsltContext, xsltArgs, nav);

                    if (this.iterList != null)
                    {
                        for (int i = 0; i < this.iterList.Count; ++i)
                        {
                            this.iterList[i].Clear();
                        }
                        this.iterList.Clear();
                    }

                    switch (this.function.ReturnType)
                    {
                        case XPathResultType.String:
                            context.SetValue(context, context[this.argCount - 1][iteration], (string)ret);
                            break;

                        case XPathResultType.Number:
                            context.SetValue(context, context[this.argCount - 1][iteration], (double)ret);
                            break;

                        case XPathResultType.Boolean:
                            context.SetValue(context, context[this.argCount - 1][iteration], (bool)ret);
                            break;

                        case XPathResultType.NodeSet:
                            NodeSequence seq = context.CreateSequence();
                            XPathNodeIterator iter = (XPathNodeIterator)ret;
                            seq.Add(iter);
                            context.SetValue(context, context[this.argCount - 1][iteration], seq);
                            break;

                        default:
                            // This should never be reached
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryFunctionTypeNotSupported, this.function.ReturnType.ToString())));
                    }
                }

                for (int i = 0; i < this.argCount - 1; ++i)
                {
                    context.PopFrame();
                }
            }
            return this.next;
        }
Пример #31
0
        internal static void NormalizeSpace(ProcessingContext context)
        {
            StackFrame argStr = context.TopArg;

            StringBuilder builder = new StringBuilder();
            while (argStr.basePtr <= argStr.endPtr)
            {
                char[] whitespace = new char[] { ' ', '\t', '\r', '\n' };
                string str = context.PeekString(argStr.basePtr).Trim(whitespace);

                bool eatingWhitespace = false;
                builder.Length = 0;
                for (int i = 0; i < str.Length; ++i)
                {
                    char c = str[i];
                    if (XPathCharTypes.IsWhitespace(c))
                    {
                        if (!eatingWhitespace)
                        {
                            builder.Append(' ');
                            eatingWhitespace = true;
                        }
                    }
                    else
                    {
                        builder.Append(c);
                        eatingWhitespace = false;
                    }
                }

                context.SetValue(context, argStr.basePtr, builder.ToString());
                argStr.basePtr++;
            }
        }
Пример #32
0
        internal override void Eval(ProcessingContext context)
        {
            Fx.Assert(context != null, "");

            StackFrame[] args = new StackFrame[argCount];
            for (int i = 0; i < this.argCount; ++i)
            {
                args[i] = context[i];
            }

            StringBuilder builder = new StringBuilder();
            while (args[0].basePtr <= args[0].endPtr)
            {
                builder.Length = 0;

                for (int i = 0; i < this.argCount; ++i)
                {
                    builder.Append(context.PeekString(args[i].basePtr));
                }

                context.SetValue(context, args[this.argCount - 1].basePtr, builder.ToString());
                for (int i = 0; i < this.argCount; ++i)
                {
                    args[i].basePtr++;
                }
            }

            for (int i = 0; i < this.argCount - 1; ++i)
            {
                context.PopFrame();
            }
        }
 internal static void StringStartsWith(ProcessingContext context)
 {
     StackFrame topArg = context.TopArg;
     StackFrame secondArg = context.SecondArg;
     while (topArg.basePtr <= topArg.endPtr)
     {
         string str = context.PeekString(topArg.basePtr);
         string str2 = context.PeekString(secondArg.basePtr);
         context.SetValue(context, secondArg.basePtr, str.StartsWith(str2, StringComparison.Ordinal));
         topArg.basePtr++;
         secondArg.basePtr++;
     }
     context.PopFrame();
 }
 internal static void StringLength(ProcessingContext context)
 {
     StackFrame topArg = context.TopArg;
     while (topArg.basePtr <= topArg.endPtr)
     {
         context.SetValue(context, topArg.basePtr, (double) context.PeekString(topArg.basePtr).Length);
         topArg.basePtr++;
     }
 }
Пример #35
0
        internal static void SubstringAfter(ProcessingContext context)
        {
            StackFrame arg1 = context.TopArg;
            StackFrame arg2 = context.SecondArg;

            Fx.Assert(arg1.Count == arg2.Count, "");
            while (arg1.basePtr <= arg1.endPtr)
            {
                string str1 = context.PeekString(arg1.basePtr);
                string str2 = context.PeekString(arg2.basePtr);
                int idx = str1.IndexOf(str2, StringComparison.Ordinal);
                context.SetValue(context, arg2.basePtr, idx == -1 ? string.Empty : str1.Substring(idx + str2.Length));
                arg1.basePtr++;
                arg2.basePtr++;
            }
            context.PopFrame();
        }
 internal static void SubstringBefore(ProcessingContext context)
 {
     StackFrame topArg = context.TopArg;
     StackFrame secondArg = context.SecondArg;
     while (topArg.basePtr <= topArg.endPtr)
     {
         string str = context.PeekString(topArg.basePtr);
         string str2 = context.PeekString(secondArg.basePtr);
         int index = str.IndexOf(str2, StringComparison.Ordinal);
         context.SetValue(context, secondArg.basePtr, (index == -1) ? string.Empty : str.Substring(0, index));
         topArg.basePtr++;
         secondArg.basePtr++;
     }
     context.PopFrame();
 }
Пример #37
0
 internal static void StringLength(ProcessingContext context)
 {
     StackFrame arg = context.TopArg;
     while (arg.basePtr <= arg.endPtr)
     {
         context.SetValue(context, arg.basePtr, context.PeekString(arg.basePtr).Length);
         arg.basePtr++;
     }
 }
Пример #38
0
        internal static void StringStartsWith(ProcessingContext context)
        {
            StackFrame arg1 = context.TopArg;
            StackFrame arg2 = context.SecondArg;

            Fx.Assert(arg1.Count == arg2.Count, "");
            while (arg1.basePtr <= arg1.endPtr)
            {
                string leftString = context.PeekString(arg1.basePtr);
                string rightString = context.PeekString(arg2.basePtr);
                context.SetValue(context, arg2.basePtr, leftString.StartsWith(rightString, StringComparison.Ordinal));
                arg1.basePtr++;
                arg2.basePtr++;
            }
            context.PopFrame();
        }
Пример #39
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();
 }
        internal override void InvokeInternal(ProcessingContext context, int argCount)
        {
            StackFrame actorArg = context.TopArg;

            SeekableXPathNavigator nav = context.Processor.ContextNode;
            long p = nav.CurrentPosition;
            while (actorArg.basePtr <= actorArg.endPtr)
            {
                string actor = context.PeekString(actorArg.basePtr);
                NodeSequence seq = context.CreateSequence();

                if (MoveToHeader(nav) && nav.MoveToFirstChild())
                {
                    do
                    {
                        // PERF, [....], this will be faster if I cache the envelope namespace to do the
                        //               actor lookup by hand
                        long pos = nav.CurrentPosition;
                        string navActor = XPathMessageFunctionActor.ExtractFromNavigator(nav);
                        nav.CurrentPosition = pos;

                        if (navActor == actor)
                        {
                            seq.Add(nav);
                        }
                    } while (nav.MoveToNext());
                }

                context.SetValue(context, actorArg.basePtr, seq);

                actorArg.basePtr++;
            }
            nav.CurrentPosition = p;
        }
        internal override void InvokeInternal(ProcessingContext context, int argCount)
        {
            StackFrame nameArg = context.TopArg;
            Message message = context.Processor.ContextMessage;
            CorrelationDataMessageProperty data = null;

            CorrelationDataMessageProperty.TryGet(message, out data);

            while (nameArg.basePtr <= nameArg.endPtr)
            {
                string value;

                if (data == null || !data.TryGetValue(context.PeekString(nameArg.basePtr), out value))
                {
                    value = string.Empty;
                }

                context.SetValue(context, nameArg.basePtr, value);
                nameArg.basePtr++;
            }
        }
 internal static void Translate(ProcessingContext context)
 {
     StackFrame topArg = context.TopArg;
     StackFrame secondArg = context.SecondArg;
     StackFrame frame3 = context[2];
     StringBuilder builder = new StringBuilder();
     while (topArg.basePtr <= topArg.endPtr)
     {
         builder.Length = 0;
         string str = context.PeekString(topArg.basePtr);
         string str2 = context.PeekString(secondArg.basePtr);
         string str3 = context.PeekString(frame3.basePtr);
         for (int i = 0; i < str.Length; i++)
         {
             char ch = str[i];
             int index = str2.IndexOf(ch);
             if (index < 0)
             {
                 builder.Append(ch);
             }
             else if (index < str3.Length)
             {
                 builder.Append(str3[index]);
             }
         }
         context.SetValue(context, frame3.basePtr, builder.ToString());
         topArg.basePtr++;
         secondArg.basePtr++;
         frame3.basePtr++;
     }
     context.PopFrame();
     context.PopFrame();
 }
        internal override Opcode Eval(ProcessingContext context)
        {
            XPathNavigator contextNode = context.Processor.ContextNode;
            if ((contextNode != null) && (context.Processor.ContextMessage != null))
            {
                ((SeekableMessageNavigator) contextNode).Atomize();
            }
            if (this.argCount == 0)
            {
                context.PushFrame();
                int iterationCount = context.IterationCount;
                if (iterationCount > 0)
                {
                    object obj2 = this.function.Invoke(this.xsltContext, NullArgs, contextNode);
                    switch (this.function.ReturnType)
                    {
                        case XPathResultType.Number:
                            context.Push((double) obj2, iterationCount);
                            goto Label_03F6;

                        case XPathResultType.String:
                            context.Push((string) obj2, iterationCount);
                            goto Label_03F6;

                        case XPathResultType.Boolean:
                            context.Push((bool) obj2, iterationCount);
                            goto Label_03F6;

                        case XPathResultType.NodeSet:
                        {
                            NodeSequence sequence = context.CreateSequence();
                            XPathNodeIterator iter = (XPathNodeIterator) obj2;
                            sequence.Add(iter);
                            context.Push(sequence, iterationCount);
                            goto Label_03F6;
                        }
                    }
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryFunctionTypeNotSupported", new object[] { this.function.ReturnType.ToString() })));
                }
            }
            else
            {
                object[] args = new object[this.argCount];
                int count = context.TopArg.Count;
                for (int i = 0; i < count; i++)
                {
                    for (int k = 0; k < this.argCount; k++)
                    {
                        StackFrame frame = context[k];
                        switch (this.function.ArgTypes[k])
                        {
                            case XPathResultType.Number:
                                args[k] = context.PeekDouble(frame[i]);
                                break;

                            case XPathResultType.String:
                                args[k] = context.PeekString(frame[i]);
                                break;

                            case XPathResultType.Boolean:
                                args[k] = context.PeekBoolean(frame[i]);
                                break;

                            case XPathResultType.NodeSet:
                            {
                                NodeSequenceIterator item = new NodeSequenceIterator(context.PeekSequence(frame[i]));
                                args[k] = item;
                                this.iterList.Add(item);
                                break;
                            }
                            default:
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryFunctionTypeNotSupported", new object[] { this.function.ArgTypes[k].ToString() })));
                        }
                    }
                    object obj3 = this.function.Invoke(this.xsltContext, args, contextNode);
                    if (this.iterList != null)
                    {
                        for (int m = 0; m < this.iterList.Count; m++)
                        {
                            this.iterList[m].Clear();
                        }
                        this.iterList.Clear();
                    }
                    switch (this.function.ReturnType)
                    {
                        case XPathResultType.Number:
                        {
                            StackFrame frame4 = context[this.argCount - 1];
                            context.SetValue(context, frame4[i], (double) obj3);
                            break;
                        }
                        case XPathResultType.String:
                        {
                            StackFrame frame3 = context[this.argCount - 1];
                            context.SetValue(context, frame3[i], (string) obj3);
                            break;
                        }
                        case XPathResultType.Boolean:
                        {
                            StackFrame frame5 = context[this.argCount - 1];
                            context.SetValue(context, frame5[i], (bool) obj3);
                            break;
                        }
                        case XPathResultType.NodeSet:
                        {
                            NodeSequence val = context.CreateSequence();
                            XPathNodeIterator iterator3 = (XPathNodeIterator) obj3;
                            val.Add(iterator3);
                            StackFrame frame6 = context[this.argCount - 1];
                            context.SetValue(context, frame6[i], val);
                            break;
                        }
                        default:
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryFunctionTypeNotSupported", new object[] { this.function.ReturnType.ToString() })));
                    }
                }
                for (int j = 0; j < (this.argCount - 1); j++)
                {
                    context.PopFrame();
                }
            }
        Label_03F6:
            return base.next;
        }
 internal static void SubstringLimit(ProcessingContext context)
 {
     StackFrame topArg = context.TopArg;
     StackFrame secondArg = context.SecondArg;
     StackFrame frame3 = context[2];
     while (topArg.basePtr <= topArg.endPtr)
     {
         string str2;
         string str = context.PeekString(topArg.basePtr);
         int startIndex = ((int) Math.Round(context.PeekDouble(secondArg.basePtr))) - 1;
         if (startIndex < 0)
         {
             startIndex = 0;
         }
         int length = (int) Math.Round(context.PeekDouble(frame3.basePtr));
         if ((length < 1) || ((startIndex + length) >= str.Length))
         {
             str2 = string.Empty;
         }
         else
         {
             str2 = str.Substring(startIndex, length);
         }
         context.SetValue(context, frame3.basePtr, str2);
         secondArg.basePtr++;
         topArg.basePtr++;
         frame3.basePtr++;
     }
     context.PopFrame();
     context.PopFrame();
 }
Пример #45
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();
        }
 internal static void Substring(ProcessingContext context)
 {
     StackFrame topArg = context.TopArg;
     StackFrame secondArg = context.SecondArg;
     while (topArg.basePtr <= topArg.endPtr)
     {
         string str = context.PeekString(topArg.basePtr);
         int startIndex = ((int) Math.Round(context.PeekDouble(secondArg.basePtr))) - 1;
         if (startIndex < 0)
         {
             startIndex = 0;
         }
         context.SetValue(context, secondArg.basePtr, (startIndex >= str.Length) ? string.Empty : str.Substring(startIndex));
         topArg.basePtr++;
         secondArg.basePtr++;
     }
     context.PopFrame();
 }
Пример #47
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();
        }
Пример #48
0
        internal static void Substring(ProcessingContext context)
        {
            StackFrame arg1 = context.TopArg;
            StackFrame arg2 = context.SecondArg;

            Fx.Assert(arg1.Count == arg2.Count, "");
            while (arg1.basePtr <= arg1.endPtr)
            {
                string str = context.PeekString(arg1.basePtr);
                int startAt = ((int)Math.Round(context.PeekDouble(arg2.basePtr))) - 1;
                if (startAt < 0)
                {
                    startAt = 0;
                }
                context.SetValue(context, arg2.basePtr, (startAt >= str.Length) ? string.Empty : str.Substring(startAt));
                arg1.basePtr++;
                arg2.basePtr++;
            }
            context.PopFrame();
        }
 internal override void InvokeInternal(ProcessingContext context, int argCount)
 {
     StackFrame spanArg = context.TopArg;
     while (spanArg.basePtr <= spanArg.endPtr)
     {
         string spanStr = context.PeekString(spanArg.basePtr);
         context.SetValue(context, spanArg.basePtr, Convert(spanStr));
         spanArg.basePtr++;
     }
 }
Пример #50
0
        internal override Opcode Eval(ProcessingContext context)
        {
            XPathNavigator nav = context.Processor.ContextNode;

            if (nav != null && context.Processor.ContextMessage != null)
            {
                ((SeekableMessageNavigator)nav).Atomize();
            }

            if (this.argCount == 0)
            {
                context.PushFrame();
                int count = context.IterationCount;
                if (count > 0)
                {
                    object ret = this.function.Invoke(this.xsltContext, NullArgs, nav);
                    switch (this.function.ReturnType)
                    {
                    case XPathResultType.String:
                        context.Push((string)ret, count);
                        break;

                    case XPathResultType.Number:
                        context.Push((double)ret, count);
                        break;

                    case XPathResultType.Boolean:
                        context.Push((bool)ret, count);
                        break;

                    case XPathResultType.NodeSet:
                        NodeSequence      seq  = context.CreateSequence();
                        XPathNodeIterator iter = (XPathNodeIterator)ret;
                        seq.Add(iter);
                        context.Push(seq, count);
                        break;

                    default:
                        // This should never be reached
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryFunctionTypeNotSupported, this.function.ReturnType.ToString())));
                    }
                }
            }
            else
            {
                // PERF, [....], see if we can cache these arrays to avoid allocations
                object[] xsltArgs       = new object[this.argCount];
                int      iterationCount = context.TopArg.Count;
                for (int iteration = 0; iteration < iterationCount; ++iteration)
                {
                    for (int i = 0; i < this.argCount; ++i)
                    {
                        StackFrame arg = context[i];
                        Fx.Assert(iteration < arg.Count, "");

                        switch (this.function.ArgTypes[i])
                        {
                        case XPathResultType.String:
                            xsltArgs[i] = context.PeekString(arg[iteration]);
                            break;

                        case XPathResultType.Number:
                            xsltArgs[i] = context.PeekDouble(arg[iteration]);
                            break;

                        case XPathResultType.Boolean:
                            xsltArgs[i] = context.PeekBoolean(arg[iteration]);
                            break;

                        case XPathResultType.NodeSet:
                            NodeSequenceIterator iter = new NodeSequenceIterator(context.PeekSequence(arg[iteration]));
                            xsltArgs[i] = iter;
                            this.iterList.Add(iter);
                            break;

                        default:
                            // This should never be reached
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryFunctionTypeNotSupported, this.function.ArgTypes[i].ToString())));
                        }
                    }

                    object ret = this.function.Invoke(this.xsltContext, xsltArgs, nav);

                    if (this.iterList != null)
                    {
                        for (int i = 0; i < this.iterList.Count; ++i)
                        {
                            this.iterList[i].Clear();
                        }
                        this.iterList.Clear();
                    }

                    switch (this.function.ReturnType)
                    {
                    case XPathResultType.String:
                        context.SetValue(context, context[this.argCount - 1][iteration], (string)ret);
                        break;

                    case XPathResultType.Number:
                        context.SetValue(context, context[this.argCount - 1][iteration], (double)ret);
                        break;

                    case XPathResultType.Boolean:
                        context.SetValue(context, context[this.argCount - 1][iteration], (bool)ret);
                        break;

                    case XPathResultType.NodeSet:
                        NodeSequence      seq  = context.CreateSequence();
                        XPathNodeIterator iter = (XPathNodeIterator)ret;
                        seq.Add(iter);
                        context.SetValue(context, context[this.argCount - 1][iteration], seq);
                        break;

                    default:
                        // This should never be reached
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, SR.GetString(SR.QueryFunctionTypeNotSupported, this.function.ReturnType.ToString())));
                    }
                }

                for (int i = 0; i < this.argCount - 1; ++i)
                {
                    context.PopFrame();
                }
            }
            return(this.next);
        }
 internal static void StringConcatTwo(ProcessingContext context)
 {
     StackFrame frame = context[0];
     StackFrame frame2 = context[1];
     while (frame.basePtr <= frame.endPtr)
     {
         context.SetValue(context, frame2.basePtr, context.PeekString(frame.basePtr) + context.PeekString(frame2.basePtr));
         frame.basePtr++;
         frame2.basePtr++;
     }
     context.PopFrame();
 }
Пример #52
0
        internal override Opcode Eval(ProcessingContext context)
        {
            XPathNavigator contextNode = context.Processor.ContextNode;

            if ((contextNode != null) && (context.Processor.ContextMessage != null))
            {
                ((SeekableMessageNavigator)contextNode).Atomize();
            }
            if (this.argCount == 0)
            {
                context.PushFrame();
                int iterationCount = context.IterationCount;
                if (iterationCount > 0)
                {
                    object obj2 = this.function.Invoke(this.xsltContext, NullArgs, contextNode);
                    switch (this.function.ReturnType)
                    {
                    case XPathResultType.Number:
                        context.Push((double)obj2, iterationCount);
                        goto Label_03F6;

                    case XPathResultType.String:
                        context.Push((string)obj2, iterationCount);
                        goto Label_03F6;

                    case XPathResultType.Boolean:
                        context.Push((bool)obj2, iterationCount);
                        goto Label_03F6;

                    case XPathResultType.NodeSet:
                    {
                        NodeSequence      sequence = context.CreateSequence();
                        XPathNodeIterator iter     = (XPathNodeIterator)obj2;
                        sequence.Add(iter);
                        context.Push(sequence, iterationCount);
                        goto Label_03F6;
                    }
                    }
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryFunctionTypeNotSupported", new object[] { this.function.ReturnType.ToString() })));
                }
            }
            else
            {
                object[] args  = new object[this.argCount];
                int      count = context.TopArg.Count;
                for (int i = 0; i < count; i++)
                {
                    for (int k = 0; k < this.argCount; k++)
                    {
                        StackFrame frame = context[k];
                        switch (this.function.ArgTypes[k])
                        {
                        case XPathResultType.Number:
                            args[k] = context.PeekDouble(frame[i]);
                            break;

                        case XPathResultType.String:
                            args[k] = context.PeekString(frame[i]);
                            break;

                        case XPathResultType.Boolean:
                            args[k] = context.PeekBoolean(frame[i]);
                            break;

                        case XPathResultType.NodeSet:
                        {
                            NodeSequenceIterator item = new NodeSequenceIterator(context.PeekSequence(frame[i]));
                            args[k] = item;
                            this.iterList.Add(item);
                            break;
                        }

                        default:
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryFunctionTypeNotSupported", new object[] { this.function.ArgTypes[k].ToString() })));
                        }
                    }
                    object obj3 = this.function.Invoke(this.xsltContext, args, contextNode);
                    if (this.iterList != null)
                    {
                        for (int m = 0; m < this.iterList.Count; m++)
                        {
                            this.iterList[m].Clear();
                        }
                        this.iterList.Clear();
                    }
                    switch (this.function.ReturnType)
                    {
                    case XPathResultType.Number:
                    {
                        StackFrame frame4 = context[this.argCount - 1];
                        context.SetValue(context, frame4[i], (double)obj3);
                        break;
                    }

                    case XPathResultType.String:
                    {
                        StackFrame frame3 = context[this.argCount - 1];
                        context.SetValue(context, frame3[i], (string)obj3);
                        break;
                    }

                    case XPathResultType.Boolean:
                    {
                        StackFrame frame5 = context[this.argCount - 1];
                        context.SetValue(context, frame5[i], (bool)obj3);
                        break;
                    }

                    case XPathResultType.NodeSet:
                    {
                        NodeSequence      val       = context.CreateSequence();
                        XPathNodeIterator iterator3 = (XPathNodeIterator)obj3;
                        val.Add(iterator3);
                        StackFrame frame6 = context[this.argCount - 1];
                        context.SetValue(context, frame6[i], val);
                        break;
                    }

                    default:
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperCritical(new QueryProcessingException(QueryProcessingError.Unexpected, System.ServiceModel.SR.GetString("QueryFunctionTypeNotSupported", new object[] { this.function.ReturnType.ToString() })));
                    }
                }
                for (int j = 0; j < (this.argCount - 1); j++)
                {
                    context.PopFrame();
                }
            }
Label_03F6:
            return(base.next);
        }
 internal static void NormalizeSpace(ProcessingContext context)
 {
     StackFrame topArg = context.TopArg;
     StringBuilder builder = new StringBuilder();
     while (topArg.basePtr <= topArg.endPtr)
     {
         char[] trimChars = new char[] { ' ', '\t', '\r', '\n' };
         string str = context.PeekString(topArg.basePtr).Trim(trimChars);
         bool flag = false;
         builder.Length = 0;
         for (int i = 0; i < str.Length; i++)
         {
             char c = str[i];
             if (XPathCharTypes.IsWhitespace(c))
             {
                 if (!flag)
                 {
                     builder.Append(' ');
                     flag = true;
                 }
             }
             else
             {
                 builder.Append(c);
                 flag = false;
             }
         }
         context.SetValue(context, topArg.basePtr, builder.ToString());
         topArg.basePtr++;
     }
 }